help-make
[Top][All Lists]
Advanced

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

Re: Preventing variables from being passed to a sub-make


From: Paul Smith
Subject: Re: Preventing variables from being passed to a sub-make
Date: Thu, 07 Jun 2007 09:09:41 -0400

On Thu, 2007-06-07 at 13:53 +0100, Will Newton wrote:
> On 6/7/07, Paul Smith <address@hidden> wrote:
> > On Wed, 2007-06-06 at 17:29 +0100, Will Newton wrote:
> >
> > > I'm having problems stopping make from passing variables passed on the
> > > command line to a sub-make.
> >
> > I think it's very, very unwise to break this capability, personally.  I
> > would rather change your top-level makefile to use some different
> > variable that won't interfere with submakefiles (or vice versa).
> 
> Perhaps. But in this case I am trying to build a system from a number
> of component parts taken from third parties. Does that mean before
> writing my top-level makefile I have to audit all these third party
> components for any variable that may clash? That doesn't seem very
> scaleable.

Overriding variables on the command line is an important feature of
make.  I suppose if you have lots of different components it may not
make as much sense as otherwise, but being able to say "make CFLAGS=-g"
and be assured that this setting will be in effect for the entire build
is something that most makefile users have come to expect.

Anyway, one option is the one I gave.  Another option would be to make
your top-level makefile slightly more complex and pass the override
values in through the environment rather than the command line.  If you
use something like:

        SUBDIRS=foo make

rather than:

        make SUBDIRS=foo

then the SUBDIRS value will be passed to sub-makes but through the
environment, and any settings in the submake makefiles will take
precedence over the environment setting.


Cheers!

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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