Is it possible to get make variable without recursive expansion?
Alfred Perlstein
bright at mu.org
Fri Feb 7 19:07:47 UTC 2014
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 at freefall.freebsd.org)
~ % make
echo "AMB=\${A} and \${B}"
AMB=${A} and ${B}
.(19:07:30)(alfred at 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
More information about the freebsd-hackers
mailing list