From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 7 19:07:47 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A1059A8; Fri, 7 Feb 2014 19:07:47 +0000 (UTC) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 8A8C11E49; Fri, 7 Feb 2014 19:07:47 +0000 (UTC) Received: from Alfreds-MacBook-Pro-9.local (c-76-21-10-192.hsd1.ca.comcast.net [76.21.10.192]) by elvis.mu.org (Postfix) with ESMTPSA id B7A9D1A3C20; Fri, 7 Feb 2014 11:07:46 -0800 (PST) Message-ID: <52F52F06.8080605@mu.org> Date: Fri, 07 Feb 2014 11:07:50 -0800 From: Alfred Perlstein User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: lev@FreeBSD.org Subject: Re: Is it possible to get make variable without recursive expansion? References: <12310461351.20140207203417@serebryakov.spb.ru> <52F5251A.8020401@mu.org> <201495029.20140207225205@serebryakov.spb.ru> In-Reply-To: <201495029.20140207225205@serebryakov.spb.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Feb 2014 19:07:47 -0000 On 2/7/14 10:52 AM, Lev Serebryakov wrote: > Hello, Alfred. > You wrote 7 февраля 2014 г., 22:25:30: > > AP> On 2/7/14 8:34 AM, Lev Serebryakov wrote: >>> Hello, Freebsd-hackers. >>> >>> >>> Suppose, I have in my Makefile such construction: >>> >>> A=xxx >>> B=yyy >>> ANB=${A} and ${B} >>> >>> Is it possible to get value of ANB without recursive expansion, i.e. string >>> "${A} and ${B} and" in this case? I know, that all expansions are done at >>> last moment (If I don't use ":=" operator), but is it possible to block >>> second- and more-level expansion? >>> >>> I need to output "ANB=${ANB}" construction to external file without further >>> expansion... >>> > AP> a: > AP> echo "AMB=\$${AMB}" > It will echo "AMB=${AMB}" as-is, as far as I understand, it is simple. And I need to get > "ANB=${A} and ${B}" output. > > > I do not think it's possible. You're basically asking "is there a way to ask Make for the text on the lhs of the variable assignment WITHOUT expansion? Your only option would be to "cheat" and not use the expanded form I think: A=aaa B=bbb AMB=\$${A} and \$${B} a: echo "AMB=${AMB}" Results in: .(19:07:30)(alfred@freefall.freebsd.org) ~ % make echo "AMB=\${A} and \${B}" AMB=${A} and ${B} .(19:07:30)(alfred@freefall.freebsd.org) ~ % There is no way to query make(1) (that I can see) for the exact value at the time of assignment and before expansion. -- Alfred Perlstein