Philip Guenther wrote:
On Thursday, August 20, 2009, Yuri Shtil <[email protected]> wrote:
It look like the shell function is evaluated even though commented out in the
following code:
define FUNC
###FOO := $(shell sleep 10)
endef
all:
@echo DONE
$(eval $(call FUNC,$(platform)))
What's so surprising? The $(shell) is evaluated in the following too:
define FUNC
###FOO := $(shell sleep 10)
endef
all:
@echo DONE
noop =
$(noop $(call FUNC,$(platform)))
And ditto if you replace the last line with
$(noop $(FUNC))
In each case, FUNC has to be expanded to determine the argument to a
function. In your post, that function is $(eval), in mine it's
$(noop).
The argument to $(eval) is expanded TWICE: one before $(eval) 'starts'
and then once by $(eval). If you don't understand that and choose
when each variable should be expanded, the results will be fragile.
It may be subtle and only show up when you decide to reference both
normal and automatic variables or a variable that contains shell
commands using shell variables...which just means you're laying a trap
for a time when you've forgotten the details.
Philip Guenther
What is surprising is that a line segment starting with a hash sign must
be ignored up to the end of the line, this is the whole purpose of
having comments in the code.
--
Yuri
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make