[Top][All Lists]

[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: Wed, 26 Oct 2022 10:15:20 -0400
User-agent: Evolution 3.46.0 (by

On Wed, 2022-10-26 at 15:43 +0200, Sébastien Hinderer wrote:
> Okay. Actually in the original Makefile (which is more complex than
> what I showed above) I had added the ".SECONDEXPANSION:" target so
> because of that and the doubled dollars I thought I did use secondary
> expansion already but I realise with your repsonse that this was a
> wrong assumption of mine. But then, just to make sure, is it because
> of eval that all the double dollars were necessary? Because I think I
> wrote the macro in the simplest way possible and it would not have
> worked if I had used less dollars than I did, right?

The extra dollars are needed because of the "call" function,
technically.  The call will expand the macro that is being called, with
$1, $2, etc. in scope (that's the entire point of the call function!!)

So if you don't want some macro or function to be expanded by the call
function, so it can be passed to eval, then you need to escape it.

eval doesn't _itself_ expand things, but it invokes the make parser on
the text to be evaluated, and the makefile parser *MIGHT* expand
things, the same way any other makefile text *MIGHT* be expanded,
depending on the context as in the link to the manual I provided:

> > See for example:
> >
> > Makefiles.html

> Is it necessary to use a variable, here?

You do not have to use a variable.  I think it makes the result simpler
to read but certainly if you prefer to write it all out that will work.
It's all just expansion after all.

reply via email to

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