[Top][All Lists]

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

Re: How to stop a variable from being exported?

From: Paul D. Smith
Subject: Re: How to stop a variable from being exported?
Date: Wed, 27 Oct 2004 13:09:47 -0400

%% Boris Kolpackov <address@hidden> writes:

  bk> Alexey Neyman <address@hidden> writes:

  >> $(warning "selector: $(selector)")
  >> ifneq ($(selector),)
  >> override selector :=
  >> endif
  >> $(warning "selector: $(selector)")
  >> aaa:
  >> $(MAKE) selector=abc bbb
  >> bbb:
  >> $(MAKE) ccc

  >> That is, the lowest sub-make receives selector=abc, though the 2nd
  >> sub-make overrided it with empty string. Is it right behavior? If
  >> so, how could one prevent a variable from being exported to
  >> sub-make processes? (unexport selector does not help either).

  bk> IMO, it's a bug in GNU make (confirmed with make from cvs). Paul,
  bk> what do you think?

No, this is correct behavior.

When you invoke a make with a specific value like this:

    make selector=abc

then the variable override static string "selector=abc" will be passed
to every submake.  Whether you set your local copy of the "selector"
variable in that version of make doesn't change the value of the command
line string passed to sub-makes.

Put another way, make doesn't go through your command line arguments and
try to replace values of variable overrides found there with values from
the current makefile.

If you want something like this, you either need to invoke make with a
variable reference like this:

  make selector='$(_selector)'

then set _selector in your makefile; this will work (I've used this many

Or, you can modify the variables that make sends to submakes by
manipulating the contents of the MAKEOVERRIDES variable (see the section
"Communicating Options to a sub-'make'" in the GNU make manual.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]