Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Feb 2005 17:26:07 +0200
From:      Peter Pentchev <roam@ringlet.net>
To:        Alejandro Pulver <alejandro@varnet.biz>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: Building port with options
Message-ID:  <20050222152607.GI805@straylight.m.ringlet.net>
In-Reply-To: <20050219150641.43dd175f@ale.varnet.bsd>
References:  <20050219150641.43dd175f@ale.varnet.bsd>

next in thread | previous in thread | raw e-mail | index | archive | help

--MPkR1dXiUZqK+927
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Feb 19, 2005 at 03:06:41PM -0300, Alejandro Pulver wrote:
> Hello,
>=20
> I am making a port of an application that allows to build with the
> following options:
>=20
> 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+).
>=20
> 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'.
>=20
> 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.
>=20
> I also tried 'WANT_GNOME' before including 'bsd.ports.pre.mk' and
> 'USE_GNOME' instead of 'WITH_GNOME'.
>=20
> 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

--=20
Peter Pentchev	roam@ringlet.net    roam@cnsys.bg    roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
=2Esiht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI

--MPkR1dXiUZqK+927
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)

iD8DBQFCG08P7Ri2jRYZRVMRAvScAKC58f1KHCxgCxqALowu9sgUJDIISgCfXAFR
xnDKW44WtDGTnzJ3UPKo7u8=
=Iwf8
-----END PGP SIGNATURE-----

--MPkR1dXiUZqK+927--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050222152607.GI805>