help-make
[Top][All Lists]
Advanced

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

Re: $(info ...) in variable, with expansion in recipes


From: Etan Reisner
Subject: Re: $(info ...) in variable, with expansion in recipes
Date: Fri, 4 Jul 2014 14:01:55 -0400

The contents seem to be being evaluated twice. With make 3.81 I get:

$ make -f info.mk RECIPE=': $(warning 2)' SHELL+=-x
1
info.mk:9: 2
3
make: 2
+ :
+ :
+ :

But this isn't limited to make commands as you seem to think (which is
a good thing since this makes it more "normal").

$ rm -f /tmp/make-test-*; make -f info.mk RECIPE=': $(shell mktemp
/tmp/make-test-XXXXXX)' SHELL+=-x; ls /tmp/make-test-*
1
+ mktemp /tmp/make-test-XXXXXX
3
+ mktemp /tmp/make-test-XXXXXX
+ :
+ : /tmp/make-test-XW3836
+ :
/tmp/make-test-XW3836  /tmp/make-test-sb3837

If you create RECIPE as a simply expanded variable you avoid this
behavior though.

$ rm -f /tmp/make-test-*; make -f info.mk RECIPE:=': $(shell mktemp
/tmp/make-test-XXXXXX)' SHELL+=-x; ls /tmp/make-test-*
1
3
+ :
+ : /tmp/make-test-cW3847
+ :
/tmp/make-test-cW3847

So while I don't know why/when make is performing the extra evaluation
it seems clear that it is related to the way recursively expanded
variables work.

Your "workaround" avoids the normal usage of (and expansion of) the
recursively expanded variable and thus only evaluates the contents
once (similarly to using a simply expanded variable though with
different timing).

make seems to be evaluating the RHS of the command line assignment
immediately when simply expanded and again at the end when recursively
expanded.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]