help-make
[Top][All Lists]
Advanced

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

Re: Variable export, recursion, and environment


From: Paul D. Smith
Subject: Re: Variable export, recursion, and environment
Date: Mon, 16 Oct 2000 16:40:20 -0400

%% Sankaranarayanan K V <address@hidden> writes:

  skv> Case 1:

  skv>   1. The environment does NOT have a variable VAR set.
  skv>   2. The top level Makefile does NOT export VAR.
  skv>   3. The top level Makefile sets VAR to x.

  skv>   Result: The sub-make invocation does NOT inherit a value for VAR.

Yes.

  skv> Case 2:

  skv>   Same as Case (1) except that the environment defines VAR=y.

  skv>   Result: The sub-make invocation inherits a value for VAR.
  skv>   But the value is x (set by the parent Makefile) and not y.

Yes.

  skv> Somehow, this seems a bit strange to me.
  skv> What is the rationale behind such a behaviour?

You should check the GNU make manual section "Variables from the
Environment" to see how make handles this.

  skv> I would expect make to either pass the environment value 
  skv> _or_ not to pass any value at all to the sub-make.

You're not thinking of this correctly.  Make uses variables the same way
the shell does, basically.  Variables that are obtained from the parent
process are considered "exported" and passed to any sub-processes, but
any value changes that happen in the current process are also exported.

You would find it darn strange if you changed the value of a variable in
the shell, but any subshells got the _previous_ value and not the new
one... well, make handles these the same way.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "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]