On Sat, 12 Feb 2005, Kris Kennaway wrote: KK>The following small makefile doesn't behave as one would naively KK>expect: KK> KK>MANLANG?=foo "" KK>all: KK>.for i in ${MANLANG} KK>.if empty(${i}) KK> @echo foo ${i} KK>.endif KK>.endfor KK> KK>ports-i386%make KK>foo foo KK>foo KK> KK>I think this is because the .if evaluation is happening too early, and KK>it's not being done after the .for loop is expanded and the i variable KK>is set. KK> KK>In order to get this to work I seem to have to do the following: KK> KK>MANLANG?=foo "" KK>.for i in ${MANLANG} KK>j= ${i} KK>.if (${j} != "\"\"") KK>.for l in ${j} KK>k+= ${l} KK>.endfor KK>.endif KK>.endfor KK>all: KK> @echo ${k} KK> KK>ports-i386%make KK>foo KK> KK>If I remove the inner .for it breaks, and if I remove the j assignment KK>it breaks. Also if I try and remove the use of k and put an echo KK>inside the inner .for (with the all: preceding the whole loop) it KK>breaks. KK> KK>This is extremely nasty. KK> KK>Am I missing an easier way to do this?
As far as I can see you just discovered the limitation of make that is documented under the BUGs section in the man page. This is the result of the quit simple minded .for implementation (it's basically like expanding a macro). harti _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"