From owner-freebsd-hackers@FreeBSD.ORG Fri May 16 05:30:18 2003 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 A8EA737B404 for ; Fri, 16 May 2003 05:30:18 -0700 (PDT) Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9FD1A43F85 for ; Fri, 16 May 2003 05:30:11 -0700 (PDT) (envelope-from ru@whale.sunbay.crimea.ua) Received: from whale.sunbay.crimea.ua (ru@localhost [127.0.0.1]) h4GCU1Ed009649 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 16 May 2003 15:30:02 +0300 (EEST) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.12.9/8.12.8/Submit) id h4GCU1c0009631 for freebsd-hackers@freebsd.org; Fri, 16 May 2003 15:30:01 +0300 (EEST) (envelope-from ru) Date: Fri, 16 May 2003 15:30:01 +0300 From: Ruslan Ermilov To: freebsd-hackers Message-ID: <20030516123001.GD2047@sunbay.com> References: <20030425184400.GS13541@freepuppy.bellavista.cz> <20030426115336.GF761@straylight.oblivion.bg> <20030427124812.GU13541@freepuppy.bellavista.cz> <20030429103404.GA680@straylight.oblivion.bg> <20030429130143.GK13541@freepuppy.bellavista.cz> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="C1iGAkRnbeBonpVg" Content-Disposition: inline In-Reply-To: <20030429130143.GK13541@freepuppy.bellavista.cz> User-Agent: Mutt/1.5.4i Subject: Re: make: variable expansion in .for/.endfor 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: Fri, 16 May 2003 12:30:19 -0000 --C1iGAkRnbeBonpVg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 29, 2003 at 03:01:43PM +0200, Roman Neuhauser wrote: > # roam@ringlet.net / 2003-04-29 13:34:04 +0300: > > On Sun, Apr 27, 2003 at 02:48:12PM +0200, Roman Neuhauser wrote: > > > # roam@ringlet.net / 2003-04-26 14:53:36 +0300: > > > > On Fri, Apr 25, 2003 at 08:44:00PM +0200, Roman Neuhauser wrote: > > > > > Try the following makefile: it works if called with -DONE, but do= es not > > > > > if called with -DTWO. Should I treat it as a bug and file a PR? > > > > >=20 > > > > > LIST=3D foo bar baz > > > > >=20 > > > > > .if defined(ONE) > > > > > . for v in ${LIST} > > > > > . if !defined(WITHOUT_${v:U}) > > > > > WITH_${v:U}=3Dyes > > > > > . endif > > > > > . endfor > > > > > .endif > > > > >=20 > > > > > .if defined(TWO) > > > > > . for v in ${LIST} > > > > > V=3D${v:U} > > > > > . if !defined(WITHOUT_${V}) > > > > > WITH_${V}=3Dyes > > > > > . endif > > > > > . endfor > > > > > .endif > > > > >=20 > > > > > a: > > > > > @echo \$${WITH_FOO}: ${WITH_FOO} > > > > > @echo \$${WITH_BAR}: ${WITH_BAR} > > > > > @echo \$${WITH_BAZ}: ${WITH_BAZ} > > > > >=20 > > > > > .PHONY: a > > > >=20 > > > > I think this is a known bug, and it seems to even be documented > > > > in the BUGS section of -STABLE's make(1) manual page. > > >=20 > > > I don't think this is covered. Can you point out the relevant tex= t? > >=20 > > Looking at: > > $FreeBSD: src/usr.bin/make/make.1,v 1.29.2.15 2002/12/17 19:01:18 sea= nc Exp $ > >=20 > > The rendered version reads, right at the end of the BUGS section: > >=20 > > For loops are expanded before tests, so a fragment such as: > >=20 > > .for TMACHINE in ${SHARED_ARCHS} > > .if ${TMACHINE} =3D ${MACHINE} > > ... > > .endif > > .endfor > > won't work, and should be rewritten the other way around. > >=20 > > This particular part of the manual page seems to have been there > > for the past three years, since Tim Vanderhoek's merge from OpenBSD > > in rev. 1.23. > >=20 > > At least, I think that this is similar (actually, nearly identical) to > > your Makefile fragment. >=20 > both fragments are "nearly identical", and the first one works. it's > the assignment (V=3D${v:U}) that breaks. so, where's the similarity > (or identity), given that the snippet from the make man page is > unrelated to assignments? >=20 > again, the first version (wrapped in ifdef ONE) works just fine. >=20 Yes, BUGS section talks about a different problem, is that =2Efor loops are unrolled before parsing, so if loop variable "v" has the value "X", the =2Eif ${v} =3D=3D "foo" becomes =2Eif X =3D=3D "foo" and now recall the (documented) limitation that "An expression may also be an arithmetic or string comparison, with the left-hand side being a variable expansion." FWIW, the code snippet above works perfectly under 5.x make(1). I recall this problem was fixed (perhaps, it was even me, not sure). Sorry, but I don't have enough time to invest into backporting the bugfix into RELENG_4, the latter is becoming less priority for me as 5.x evolves. If you'll be able to extract it from HEAD (there is a huge backlog of non-backported fixes for make(1) there), I will happily commit it for you. $ uname -r 5.1-BETA $ make -DONE ${WITH_FOO}: yes ${WITH_BAR}: yes ${WITH_BAZ}: yes $ make -DTWO ${WITH_FOO}: yes ${WITH_BAR}: yes ${WITH_BAZ}: yes Cheers, --=20 Ruslan Ermilov Sysadmin and DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age --C1iGAkRnbeBonpVg Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+xNnJUkv4P6juNwoRAgXtAJ0SHU2hec0hXl6Ch9SWBRLS+8VsUgCfdE74 8S/vn8tj/kKaCmKE27lSRIA= =g8IE -----END PGP SIGNATURE----- --C1iGAkRnbeBonpVg--