help-make
[Top][All Lists]
Advanced

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

Re: Evaluating a variable only once after a recipe has run


From: Paul Smith
Subject: Re: Evaluating a variable only once after a recipe has run
Date: Sat, 18 Apr 2020 18:15:45 -0400

On Sat, 2020-04-18 at 21:17 +0200, R. Diez wrote:
> > I don't see why not.  Do you think there is some reason it wouldn't
> > be possible?
> 
> Hahaha. I was obviously trying to get you to write it. Well, maybe
> just the code, I can write the comments myself... O8-)

Oh.  Well, you should just ask :)

You need to escape all the "$" other than the ones you want to be
evaluated by the call (e.g., the arguments to the call).

Something like:

  Deferred = $1 = $$(eval $1 := $$$$(shell $2))$$($1)

Then:

  $(eval $(call Deferred,OUTPUT,some-command))

Defines OUTPUT as a deferred variable assigned to running some-command
in $(shell ...)

There are issues with this.  If the command you want to run has
unmatched ")" you have problems.  Also if you want use a literal '$' in
some-command you'll have problems getting enough escaping although it
can be done.

But for simple commands it should work.

Personally I'm not convinced the eval/call version is more readable but
YMMV.




reply via email to

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