[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The explanation of the make manual regarding to $(call
From: |
Philip Guenther |
Subject: |
Re: The explanation of the make manual regarding to $(call |
Date: |
Tue, 16 Aug 2011 13:17:57 -0700 |
On Tue, Aug 16, 2011 at 1:10 PM, Philip Guenther <address@hidden> wrote:
> On Sun, Aug 14, 2011 at 5:10 AM, ali hagigat <address@hidden> wrote:
>> 8.6 The call Function
>> The call function expands the param arguments before assigning them to
>> temporary
>> variables. This means that variable values containing references to
>> builtin functions that
>> have special expansion rules, like foreach or if, may not work as you expect.
>> Some examples may make this clearer.
>> ---------------------------------
>> The above lines is talking about the expansion of 'param' before being
>> assigned to $(1), $(2) ...
>> And it says some examples makes it clearer. Where are the examples?
>> There is no example in relation with 'param' expansion!
>>
>> I wonder if anybody could bring an example.
>
> The simplest example is something like
Grrr, stupid gmail client sends too soon. Full example:
--------
myif = $(if $1,$2,$3)
false=
true=sdlfkj
$(if ${false},$(shell echo 1:true>>out),$(shell echo 1:false >>out))
$(if ${true},$(shell echo 2:true >>out),$(shell echo 2:false >>out))
$(call myif,${false},$(shell echo 3:true>>out),$(shell echo 3:false >>out))
$(call myif,${true},$(shell echo 4:true>>out),$(shell echo 4:false >>out))
all:
: nothing
--------
If you run that, you'll find that 'out' ends up containing this:
----
1:false
2:true
3:true
3:false
4:true
4:false
----
The first two $(if ...) lines only evaluate one of the two $(shell)
expansions on each line, so you get 1:false and 2:true and not 1:true
or 2:false. On the other hand, the two $(call myif,....) lines
evaluate both expansions, so you get 3:true *and* 3:false. You can't
write your own function with the same 'selective' expansion as the
built-in $(if).
Philip Guenther