Re: Variable expansion question

Paul Smith <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Organization GNU's Not UNIX!
Message-ID <[email protected]>
On Thu, 2022-10-27 at 14:18 +0200, Sébastien Hinderer wrote:
> However, I noticed that secondary expansion seem to not play very
> well with the shorthand syntax for substitution: $$(foo:=.o) didnr't
> work, whereas $$(patsubst %,%.o, $$foo) works. Is this known /
> documented? Or did I perhaps miss something and there is a way to
> make the shorter syntax work?

If make is not parsing a variable (because you've escaped the "$" that
introduces a variable) then special characters are not treated
specially.  In particular, the "=" character is not treated specially.

So this:

  foo: $$(bar:=.o)

is no different (from the perspective of make's parser) than if you'd
typed this:

  foo: x(bar:=.o)

which make would interpret like this:

  foo: x(bar: = .o)

which would be interpreted as a variable assignment, with a very
strange variable name.

This is one of the reasons I prefer to use a separate variable to hold
the content that is to be secondarily-expanded: it hides these kinds of
weirdnesses from the make parser.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.