help-make
[Top][All Lists]
Advanced

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

Re: Variables


From: Paul D. Smith
Subject: Re: Variables
Date: Mon, 25 Jun 2001 16:44:41 -0400

%% "Kyle McFarlane" <address@hidden> writes:

  >> %% address@hidden writes:
  >> 
  w> How can I set a variable in makefile and have that variable's w> updated 
  >> value seen the makefile that called it?
  >> 
  >> The same way you can set a variable in a shell script or a program in 
  >> general and have the updated value be seen in the program that called it:
  >> 
  >> You can't.

  km> Couldn't one write the variable contents to a temp file, and read it into 
  km> the parent file/program with VARIABLEX=`cat tempfilename` ??

Depends on what you wanted to do with it.

First, note that the above string doesn't actually read tempfilename, it
just sets the value of VARIABLEX to the static string "`cat
tempfilename`".

Then if you were to use that later in a command script context, such as:

  all:
        @echo $(VARIABLEX)

this would be evaluated and executed as:

  echo `cat tempfilename`

and the shell would print out the contents of tempfilename (sans
newlines, and assuming it wasn't too long :).  This might solve your
problem... depending on what your problem is.


However, if what you want is to modify the contents of the variables
that are internal to make, then this won't work; there's no way to do
that that I can think of, short of using recursion.


If the OP wants to rephrase the question to ask how to get some
particular result, with a higher-level description of what he wants to
accomplish, then maybe we will be better able to provide help.

But, the answer to the question asked is that there's no way to change
the value of any parent make's variables from within a sub-make process.

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