help-make
[Top][All Lists]
Advanced

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

Re: Variable expansion question


From: Paul Smith
Subject: Re: Variable expansion question
Date: Thu, 27 Oct 2022 09:58:09 -0400
User-agent: Evolution 3.46.0 (by Flathub.org))

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.




reply via email to

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