Makefile .for and .if expansion
Kris Kennaway
kris at obsecurity.org
Sat Feb 12 18:32:02 PST 2005
The following small makefile doesn't behave as one would naively
expect:
MANLANG?=foo ""
all:
.for i in ${MANLANG}
.if empty(${i})
@echo foo ${i}
.endif
.endfor
ports-i386%make
foo foo
foo
I think this is because the .if evaluation is happening too early, and
it's not being done after the .for loop is expanded and the i variable
is set.
In order to get this to work I seem to have to do the following:
MANLANG?=foo ""
.for i in ${MANLANG}
j= ${i}
.if (${j} != "\"\"")
.for l in ${j}
k+= ${l}
.endfor
.endif
.endfor
all:
@echo ${k}
ports-i386%make
foo
If I remove the inner .for it breaks, and if I remove the j assignment
it breaks. Also if I try and remove the use of k and put an echo
inside the inner .for (with the all: preceding the whole loop) it
breaks.
This is extremely nasty.
Am I missing an easier way to do this?
Kris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20050212/b958a8a3/attachment.bin
More information about the freebsd-hackers
mailing list