Thu 16 Jan 2003 06:03:38 PM UTC, original submission:
Make 3.80: At last, a (simple) way to reverse a list.
Consider this function:
..9 := 0 1 2 3 4 5 6 7 8 9
rev=$(eval res:=)$(foreach word,$1,$(eval res:=${word} ${res}))${res}
When used with this makefile snippet:
$(error [$(call rev,${..9})])
we get:
$ make -f bug.mak
1:3: *** [ 9 8 7 6 5 4 3 2 1 0 ]. Stop.
This is fine. However, if we generate the result via a simply expanded variable, then oddness occurs. Change the $(error...) above to:
a:=$(call rev,${..9})
$(error [${a}])
This time make reports:
$ make -f bug.mak
1:5: *** [ 9 8 7 6 5 4 3 2 1 0 1 0 ]. Stop.
What's that extra "1 0 " doing there? Strangely, things start working again if we change "a" to a recursive variable.
Problem occurs on 3.80, and the head of CVS (a version marked as 3.81 beta 1) on cygwin/win2k and Linux (a recent SuSE).
|