Date: Sat, 12 Feb 2005 18:32:01 -0800 From: Kris Kennaway <kris@obsecurity.org> To: hackers@FreeBSD.org Subject: Makefile .for and .if expansion Message-ID: <20050213023201.GB24426@xor.obsecurity.org>
next in thread | raw e-mail | index | archive | help
--IiVenqGWf+H9Y6IX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --IiVenqGWf+H9Y6IX Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFCDrwhWry0BWjoQKURAqwtAJ42w/TqXmlfi53hPkwpP29G0xr/VACgnrn2 hjVDAhUPs1ye6PD1XFptDPo= =qVYS -----END PGP SIGNATURE----- --IiVenqGWf+H9Y6IX--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050213023201.GB24426>