Le 24 juil. 2012 à 18:48, Stefano Lattarini a écrit : >>> 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?
That the idiom is safe, yes.
>> $ 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?
I started to, but there are issues with building automake-ng:
+ gmake -rR V=1
rm -f t/ax/test-defs.sh t/ax/test-defs.sh-t
sed -e 's,@datadir@,/opt/gostai/share,g' -e
's,@amdir@,/opt/gostai/share/automake-ng-1.12a/am,g' -e
's,@bindir@,/opt/gostai/bin,g' -e
's,@docdir@,/opt/gostai/share/doc/automake-ng,g' -e
's,@pkgvdatadir@,/opt/gostai/share/automake-ng-1.12a,g' -e
's,@scriptdir@,/opt/gostai/share/automake-ng-1.12a,g' -e
's,@automake_acdir@,/opt/gostai/share/aclocal-1.12a,g' -e
's,@system_acdir@,/opt/gostai/share/aclocal,g' -e
"s,[@]configure_input@,Generated from test-defs.in do not edit by hand.,g"
<"../../t/ax/test-defs.in" | /bin/sh ./config.status --file=-
>"t/ax/test-defs.sh-t"
/bin/sh: t/ax/test-defs.sh-t: No such file or directory
gmake: *** [t/ax/test-defs.sh] Error 1
Compilation FAILED: /Users/akim/src/gnu/automake-ng: build-for-darwin V=1 exit 2
I don't have any t/ax in my builddir.
Attached, a patch. Tweak as much as you want.
0001-tests-check-the-behavior-of-GNU-Make-s-foreach.patch
Description: Binary data
