bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Override... but not really


From: Philip Prindeville
Subject: Re: Override... but not really
Date: Mon, 09 Aug 2010 12:41:56 -0700
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1

 On 8/9/10 12:12 PM, Paul Smith wrote:
On Mon, 2010-08-09 at 11:54 -0700, Philip Prindeville wrote:
I guess I was thinking that variables are exported between makes the
same way that environments variables are passed between processes.
Well, certainly variables CAN be exported by make (see the "export"
command) and passed to sub-makes that way.  However, those variables
have the least "priority" so you have to be very careful.  Using
"make CFLAGS=-DA" would still not be possible because that would
override the env. var.  You could run "CFLAGS=-DA make" and that would
work.

Also, see the -e flag to make which allows env. vars. to have a higher
precedence than makefile vars... but this is highly dangerous because
users might have odd env. vars. in their ~/.bashrc etc.

Hm.  Actually, you might be able to do this, because you can reset the
MAKEOVERRIDES variable to empty.  Of course that would delete ALL
command line variables, so it could limit your flexibility on the
command line.

But, what you'd do is override and export CFLAGS, then set MAKEOVERRIDES
to empty so that sub-makes wouldn't have any command-line settings.

Now I think sub-makes would get the value of CFLAGS from their parent.
It would have to be tested and proven; there may be subtle areas that
are not well-behaved.

This will require rewriting several hundred makefiles.
I don't think there's any possible way to do this without changing
makefiles.  It's a good idea to test the implementation on a small
subset before creating a huge environment based on that
implementation :-)

If you're going to have to do this anyway you might consider changing
your makefile environment so that individual makefiles only set a few
variables and all common bits are contained in some command makefiles
that are "include"'d by the rest.  This can drastically cut down on the
amount of editing you have to do when you change things.

Alas much of this is beyond my control, and it's not a single project: it's a 
Linux distro having a couple of hundred projects, many of which have several 
directories deep of makefile nesting.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]