[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Automake-NG] [FYI] [ng] vars: names of iterating vars in $(foreach)
From: |
Stefano Lattarini |
Subject: |
Re: [Automake-NG] [FYI] [ng] vars: names of iterating vars in $(foreach) loops shorter & simpler |
Date: |
Tue, 24 Jul 2012 18:48:19 +0200 |
Hi Akim.
On 07/24/2012 04:34 PM, Akim Demaille wrote:
>
> Le 24 juil. 2012 à 16:03, Stefano Lattarini a écrit :
>
>>> I might be stretching things too far, but imagine that some
>>> one defines v in her Makefile.am, at the top level, because
>>> for instance she can factor longish definitions in EXTRA_DIST.
>>>
>>> v = headers/include/pkg
>>> EXTRA_DIST = $(v)/1.h $(v)/2.h $(v)/3.h $(v)/4.h $(v)/5.h
>>>
>>> Then I guess you are capturing this $(v) to mean something else.
>>>
>> No. My point is exactly that, even with your "devil's advocate"
>> example above, the use of an "$(foreach v, ...)" construct between
>> the 'v' and 'EXTRA_DIST' definition would not cause any problem!
>> Isn't that great? :-) See also new test 't/spy-foreach.sh'.
>
> I think you are missing my point. Your spy test does not
> check what I am talking about. Yet it does work, because,
> quoting the documentation:
>
>> The first two arguments, VAR and LIST, are expanded before anything
>> else is done; note that the last argument, TEXT, is *not* expanded at
>> the same time.
>
> So, indeed, in the following example, every use of the
> outer $(v) is resolved even before the first temporary
> $(v) is defined. So my point is moot.
>
So we agree in the end?
> $ cat Makefile
> v = $(info "v")root
> list = $(v)/1 $(v)/2
> all:
> echo $(foreach v,$(list),{$(info "body")$(v)})
> $ make
> "v"
> "v"
> "body"
> "body"
> echo {root/1} {root/2}
> {root/1} {root/2}
>
Nice :-)
Would you fancy adding the above to the 't/spy-foreach.sh' test?
Thanks,
Stefano