Date: Fri, 07 Feb 2014 11:07:50 -0800 From: Alfred Perlstein <bright@mu.org> To: lev@FreeBSD.org Cc: freebsd-hackers@freebsd.org Subject: Re: Is it possible to get make variable without recursive expansion? Message-ID: <52F52F06.8080605@mu.org> In-Reply-To: <201495029.20140207225205@serebryakov.spb.ru> References: <12310461351.20140207203417@serebryakov.spb.ru> <52F5251A.8020401@mu.org> <201495029.20140207225205@serebryakov.spb.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?52F52F06.8080605>
