From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 13 02:45:26 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1027216A4CE for ; Sun, 13 Feb 2005 02:45:26 +0000 (GMT) Received: from obsecurity.dyndns.org (CPE0050040655c8-CM00111ae02aac.cpe.net.cable.rogers.com [69.199.47.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id C5F9543D49 for ; Sun, 13 Feb 2005 02:45:25 +0000 (GMT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id F317351485; Sat, 12 Feb 2005 18:45:24 -0800 (PST) Date: Sat, 12 Feb 2005 18:45:24 -0800 From: Kris Kennaway To: Kris Kennaway Message-ID: <20050213024524.GA24740@xor.obsecurity.org> References: <20050213023201.GB24426@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline In-Reply-To: <20050213023201.GB24426@xor.obsecurity.org> User-Agent: Mutt/1.4.2.1i cc: hackers@FreeBSD.org Subject: Re: Makefile .for and .if expansion X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Feb 2005 02:45:26 -0000 --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Feb 12, 2005 at 06:32:01PM -0800, Kris Kennaway wrote: > The following small makefile doesn't behave as one would naively > expect: >=20 > MANLANG?=3Dfoo "" > all: > .for i in ${MANLANG} > .if empty(${i}) > @echo foo ${i} > .endif > .endfor >=20 > ports-i386%make > foo foo > foo >=20 > 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. Actually it looks like it's happening too late: For: Iterator i List foo "" For: end for 1 Global:i =3D "" --- i =3D "" =2Eif empty(i) @echo foo "" =2Eendif ---- at line 3 Global:delete i Global:i =3D foo --- i =3D foo =2Eif empty(i) @echo foo foo =2Eendif ---- at line 3 Global:delete i i.e. the series of .if statements are expanded out by .for and then the variable i is deleted, so by the time the .if is evaluated the unset variable evaluates to empty. Kris --mYCpIKhGyMATD0i+ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFCDr9EWry0BWjoQKURAlFhAJ9E3wZ31rE+8mFXIYYamxaGqvhBhwCg/5bq WAYdKl9f2212Gw7rCT8KShg= =nIdg -----END PGP SIGNATURE----- --mYCpIKhGyMATD0i+--