Building port with options

Alejandro Pulver alejandro at varnet.biz
Tue Feb 22 12:46:46 PST 2005


On Tue, 22 Feb 2005 17:26:07 +0200
Peter Pentchev <roam at ringlet.net> wrote:

> On Sat, Feb 19, 2005 at 03:06:41PM -0300, Alejandro Pulver wrote:
> > Hello,
> > 
> > I am making a port of an application that allows to build with the
> > following options:
> > 
> > WITH_GTK	GTK+ interface (default).
> > WITH_SDL	Command-line interface (with WITH_SDL_AUDIO).
> > WITH_SDL_AUDIO	Use SDL audio instead of OSS (only available with GTK+).
> > 
> > The port always uses SDL, but it offers a graphical UI (GTK+). If the
> > command-line program is built, it will automatically use SDL audio. If
> > compiled with the GTK+ GUI, it allows the use of SDL audio or OSS.
> > This is done by passing different options to 'configure'.
> > 
> > I can build it with all (3) the combinations (make -DWITH_*), but when
> > the build terminates, I change the option "-D" to compile a different
> > version, but it does nothing. So I have to 'make clean' or 'rm -rf
> > work' before compiling with a different option.
> > 
> > I also tried 'WANT_GNOME' before including 'bsd.ports.pre.mk' and
> > 'USE_GNOME' instead of 'WITH_GNOME'.
> > 
> > What am I doing wrong?
> 
> Nothing; that's the way things are supposed to work :)
> 
> That's the way that the 'fetch', 'extract', 'patch', 'configure', 'all',
> and 'install' targets behave - after their work is done, they touch a
> file in the work/ directory, and they actually depend on this file.  You
> can see these files with a 'ls -A work/' - there should be files with
> names like ".extract_done.generator-cbiere-1.0._usr_local".  If such a
> file exists, 'make extract' will do nothing, since make(1) will know
> that the 'extract' target has already been fulfilled.
> 
> Consider this, now: if you have already configured and built the port
> with, say, the WITH_GTK option defined, then the configure script has
> generated a Makefile, object files have been created from all the source
> files, and the final executable file has been linked from the object
> files.  What is the Ports framework supposed to do if you do a 'make'
> now *without* WITH_GTK?  An attempt to just do 'make all' in the port's
> directory would not do anything, since the executable is newer than the
> object files, and each object file is newer than the respective source
> file, so there's nothing to be done.  To accomplish something different,
> the configure script should be run anew to recreate the Makefile so it
> does not try to link the GTK library, and a 'make clean' or some
> equivalent should be run in the port's WRKSRC directory to get rid of
> the object files and the executable.  Okay, but how is the ports
> framework supposed to know whether it should run a 'make clean', then
> reconfigure the thing, and how does it know when to stop on the way
> back?  In some cases, the fact that some option is or is not defined
> influences things in post-patch, sometimes pre-patch, sometimes even
> patch files are added or removed depending on whether some option is
> selected.
> 
> In short, the only way for the Ports framework to be *sure* that it has
> a clean environment to build the port with the new options is to, well,
> provide a really clean environment - remove the WRKSRC directory
> whatsoever, and redo the full extract/patch/configure/build cycle from
> scratch.  That's basically what 'make clean' does, and that's what 'rm
> -rf work' effectively does, as you have discovered :)
> 
> G'luck,
> Peter
> 
> -- 
> Peter Pentchev	roam at ringlet.net    roam at cnsys.bg    roam at FreeBSD.org
> PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
> Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
> .siht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI
> 

Thanks for your reply.

I was confused with the port of Vim, that uses different variables to
pass the options (but I think it depends on the Vim build environment).

So the port is just fine?

I mean: Do I have to implement extra steps to make 'make' notice the
changes? Can you please mention some ports that use build options?

Thanks and Best Regards,
Ale


More information about the freebsd-ports mailing list