From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 13 10:48:44 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 3236F16A4CE for ; Sun, 13 Feb 2005 10:48:44 +0000 (GMT) Received: from smtp-1.dlr.de (smtp-1.dlr.de [195.37.61.185]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C25943D31 for ; Sun, 13 Feb 2005 10:48:43 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from beagle.kn.op.dlr.de ([129.247.173.6]) by smtp-1.dlr.de over TLS secured channel with Microsoft SMTPSVC(5.0.2195.6713); Sun, 13 Feb 2005 11:48:42 +0100 Date: Sun, 13 Feb 2005 11:51:09 +0100 (CET) From: Harti Brandt X-X-Sender: brandt_h@beagle.kn.op.dlr.de To: Kris Kennaway In-Reply-To: <20050213023201.GB24426@xor.obsecurity.org> Message-ID: <20050213114853.Q6360@beagle.kn.op.dlr.de> References: <20050213023201.GB24426@xor.obsecurity.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 13 Feb 2005 10:48:42.0755 (UTC) FILETIME=[95AAD530:01C511B9] 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 Reply-To: Harti Brandt 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 10:48:44 -0000 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