Subject: Re: sanitising make(1) variable overrides
To: Luke Mewburn <lukem@cs.rmit.edu.au>
From: Chris G. Demetriou <cgd@netbsd.org>
List: tech-userlevel
Date: 02/14/1999 16:45:42
Luke Mewburn <lukem@cs.rmit.edu.au> writes:
> At this time, the user settings of LDSTATIC are:
> 	LDSTATIC=-static	build all the tree static
> 	LDSTATIC=		build all the tree dynamic
> 	!defined(LDSTATIC)	build most the tree dynamic, except
> 				for where there's overrides (e.g, /bin)
> 
> The problem here is that there's one variable to perform the following:
> 	* building the entire tree dynamic, unless overridden by parts of
> 	  the tree, depending upon the setting of LDSTATIC (default)
> 	* building the entire tree dynamic, irregardless of Makefile
> 	* building the entire tree static, irregardless of Makefile
> 	* indicate to the link how to statically link
> 
> Solving this is a bit tricky. This might work:
> 	MKSTATIC	if "no", build all dynamic (default)
> 			if "yes, build all static
> 			Makefiles should override with MKSTATIC?=yes
> 			will need various Makefiles changed from
> 			setting LDSTATIC
> 
> 	LDFLAGS		gets -static added if MKSTATIC!="yes"

So, it's worth noting that if you look at "-static" as a funny way of
saying 'yes' to MKSTATIC, i think you end up with pretty much the same
situation as the current one.  The only difference is that 'yes' is
slightly more understandable from the POV of someone who doesn't know
what's going on (and who probably shouldn't be tweaking the defaults
to begin with 8-).

Note that:

>       MKSTATIC        if "no", build all dynamic (default)
>                       if "yes, build all static
>                       Makefiles should override with MKSTATIC?=yes
>                       will need various Makefiles changed from
>                       setting LDSTATIC

doesn't really work.  you need it to be tri-state, just like the
existing LDSTATIC.

if you default to 'no' then have makefiles override it with ?=, then
everything will end up being 'no'.  the default needs to be "unset" to
have things work right unless you want to introduce a second variable,
and that seems like the Wrong thing to do.




cgd
-- 
Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.