help-make
[Top][All Lists]
Advanced

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

Re: append to/from command line variable


From: Paul D. Smith
Subject: Re: append to/from command line variable
Date: Mon, 7 Nov 2005 08:13:39 -0500

%% "Martin d'Anjou" <address@hidden> writes:


  md> $ make
  md> makefile:2: FOO = foo
  md> makefile:5: FOO = foo bar
  md> makefile:9: FOO = foo bar biz
  md> FOO = boz baz / $FOO =

Oh whoops... I should have added "export FOO" to the makefile.

  md> $ setenv FOO gig
  md> $ make
  md> makefile:2: FOO = gig foo
  md> makefile:5: FOO = gig foo bar
  md> makefile:9: FOO = gig foo bar biz
  md> FOO = boz baz / $FOO = boz baz

  md> Why in the second case "/ $FOO" prints "boz baz" and not the empty
  md> string?

Make automatically exports all variables that were in the environment
when it started up.  It doesn't export other, normal make variables.

So, by adding FOO to the environment before you started make you caused
it to be exported.

  md> When I do "make -e":

  md> $ make -e
  md> makefile:2: FOO = gig
  md> makefile:5: FOO = gig
  md> makefile:9: FOO = gig
  md> FOO = gig / $FOO = gig

Right.  Adding -e changes the precedence rules and causes values in the
environment to take precedence over values set in the makefile.

-- 
-------------------------------------------------------------------------------
 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]