From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 10 14:34:40 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 304C716A4E0; Thu, 10 Aug 2006 14:34:40 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8A2C343D49; Thu, 10 Aug 2006 14:34:39 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id k7AEYY0t074000; Thu, 10 Aug 2006 10:34:34 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Thu, 10 Aug 2006 10:34:24 -0400 User-Agent: KMail/1.9.1 References: <20060810160836.40eb4128@localhost> In-Reply-To: <20060810160836.40eb4128@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200608101034.24589.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [192.168.0.1]); Thu, 10 Aug 2006 10:34:36 -0400 (EDT) X-Virus-Scanned: ClamAV 0.87.1/1644/Wed Aug 9 23:55:42 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: ports@freebsd.org, Stanislav Sedov Subject: Re: make(1) is broken? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Aug 2006 14:34:40 -0000 On Thursday 10 August 2006 06:08, Stanislav Sedov wrote: > Hi! > > I have a strange problem linked with make(1) > > Consider the following Makefile: > --------------------------------------------------------------- > COMPS=aa ab ac > AA=aa > > VAR1=${COMPS:Maa} > VAR2=${COMPS:M${AA}} > > .for COMP in ${AA} > VAR3=${COMPS:M${COMP}} > .endfor > --------------------------------------------------------------- > > Now, running make(1) gives: > % make -V VAR1 > aa > % make -V VAR2 > } > % make -V VAR3 > aa > > Results for VAR2 seems quite strange for me. It looks like > ${COMP}!=${AA} > > So, the question: is make(1) broken, or it's my misunderstanding? > > Any help greatly appreciated. Thanks! I think it's your misunderstanding, when you do .for, make expands $COMP to generate more lines that it then later evaluates, so with the .for expanded you get: COMPS= AA= VAR1=${COMPS:Maa} VAR2=${COMPS:M${AA}} VAR3=${COMPS:Maa} Then when make evaluates VAR2, it doesn't expand ${AA} but tries to match that substring ('${AA}') in COMPS. Actually, though, it's less obvious than that, as since it isn't looking to do variable expansion in an M modifier, it ends the $COMPS expansion when it sees the first }, so what you end up with is this: VAR2='${COMPS:M${AA}'} That is, it tries to match the substring '${AA' in ${COMPS} and then appends a '}' character to that, which gives the '}' result you saw. -- John Baldwin