help-make
[Top][All Lists]
Advanced

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

Re: Parsing makefiles.


From: Paul D. Smith
Subject: Re: Parsing makefiles.
Date: Tue, 30 Aug 2005 12:08:36 -0400

%% Travis Spencer <address@hidden> writes:

  >> *pass the relevant variables to my program* <-- how can i do this?

  ts> What about using make's `-p' option?  It will output the variables and
  ts> their values in a format that is very easy to parse (e.g.,
  ts> http://travisspencer.com/stash2/tests/python/capmake2.py).

I thought of this, too, but note it won't fully evaluate the values
before it prints them.  For example if you have in your makefile:

    FOO = $(BAR)

then the output of -p will print "$(BAR)" as the value; it won't expand
the reference to BAR.

Obviously if you use := instead, then it WILL be expanded in the -p
output.


The other idea is to write a special rule that just prints the values of
variables.  You could use $(.VARIABLES) if you have a new-enough version
of GNU make (beware of blowing out your environment :-/).  Then you
would run "make print-my-vars" or whatever to get the output.

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