Date: Sun, 13 Feb 2005 11:51:09 +0100 (CET) From: Harti Brandt <hartmut.brandt@dlr.de> To: Kris Kennaway <kris@obsecurity.org> Cc: hackers@FreeBSD.org Subject: Re: Makefile .for and .if expansion Message-ID: <20050213114853.Q6360@beagle.kn.op.dlr.de> In-Reply-To: <20050213023201.GB24426@xor.obsecurity.org> References: <20050213023201.GB24426@xor.obsecurity.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050213114853.Q6360>