help-make
[Top][All Lists]
Advanced

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

Re: Bug


From: Philip Guenther
Subject: Re: Bug
Date: Thu, 20 Aug 2009 22:15:36 -0700

On Thursday, August 20, 2009, Yuri Shtil <address@hidden> 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




reply via email to

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