Subject: Re: printing expanded variables?
To: NetBSD Toolchain Technical Discussion List <tech-toolchain@NetBSD.ORG>
From: Greg A. Woods <>
List: tech-toolchain
Date: 09/03/2003 12:22:08
[ On Wednesday, September 3, 2003 at 09:36:10 (+0200), Alan Barrett wrote: ]
> Subject: Re: printing expanded variables?
> Then let "-v -V VARNAME" mean "verbosely display the value of ${VARNAME)".

I think that confuses the meaning of the proposed "verbose" flag.

> I prefer not to use "-E" (as was suggested in another message), because
> it seems to be a waste of precious option letters.

I don't think option letters are that rare for "make" yet.  Even with
'-v' and '-E' added they would only be half gone.  :-)

I'd rather see '-E' used now than to already start overloading option
flags with different meanings in different contexts.

The other suggestion I was thinking of making was to possibly even
deprecate the existing '-V', and instead implement '-E' for "evaluate
this expression" which would allow all sorts of things to be done right
on the command line.  This way '-E' could eventually replace '-V'.

Another possibility would be to add a new function "eval()" which would
recursively expand all macro variables just as if they were used in some
statement like ".if" or in a command string for a rule:

	$ make -V CPPFLAGS

	$ make -V "eval(${CPPFLAGS})" main.o
	 -I/work/woods/NetBSD-src/usr.bin/make "-DMAKE_VERSION=\"netbsd-20030903\""

(note the use of an explict target name on the second command-line above)

Note that there are some other related bugs that should be fixed to make
this all really work properly.  For example "${.TARGET}" isn't properly
set up when '-V' is used now:

	$ make -V .TARGET main.o  

This actually seems to be why some things get evaluated/expanded with
'-V' now while others don't (real examples from the make src dir):

	$ grep MAKE_VERSION Makefile
	$ make -V BUILD_DATE         
	$ make -V CPPFLAGS_main.o

If "${.TARGET}" and other pseudo-varibles like it were expanded then
even "${CPPFLAGS}" could be fully expanded by '-V' (when either to the
default, i.e. first, target from the (first) makefile, or an explicit
target was given on the command line, then that first target from the
command line).

Maybe neither of '-E' nor '-vV" nor "eval()" are really necessary?

						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <>
Planix, Inc. <>          Secrets of the Weird <>