help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

suppressing $ resolution in variable value


From: Brian J. Murrell
Subject: suppressing $ resolution in variable value
Date: Thu, 02 Sep 2021 09:33:51 -0400
User-agent: Evolution 3.40.4 (3.40.4-1.fc34)

Given a Makefile:

debug:
        echo "$(foo)"
        echo "$(subst $,$$,$(foo))"
        echo "$(subst $$,%,$(foo))"

and given the make command:

$ foo='FOO$BAR' make -f /tmp/Makefile

How can I get make to not try to resolve the $ in the value as it seems
to be doing for all of the echos in the debug target:

$ foo='FOO$BAR' make -f /tmp/Makefile
echo "FOOAR"
FOOAR
echo "FOOAR"
FOOAR
echo "FOOAR"
FOOAR

I suppose the $(subst) attempts are too late and $(foo) has it's $B
resolved as the variable is expanded before $(subst) can even get a
chance to try to escape it.

An obvious solution is to escape the $ in the caller's foo assignment
before calling make, but that is asking the caller to do something
surprising simply to appease make.  Not nice to do.

Any solutions other than asking the caller to alter their normal
behaviour?

Cheers,
b.

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]