bug-make
[Top][All Lists]
Advanced

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

Re: [bug #17529] Variable set with $(shell date '+%Y%m%d-%H%M%S') change


From: Sam Ravnborg
Subject: Re: [bug #17529] Variable set with $(shell date '+%Y%m%d-%H%M%S') changes mid-make
Date: Sat, 26 Aug 2006 15:05:48 +0200
User-agent: Mutt/1.4.2.1i

On Sat, Aug 26, 2006 at 03:06:33AM +0200, Terry Jones wrote:
> Hi Martin
> 
> | > base = xxx-$(shell date '+%Y%m%d-%H%M%S')
> | 
> | Perhaps you wanted := instead of =.  The difference is explained in (for
> | example):
> | 
> | http://www.gnu.org/software/make/manual/html_node/Reading-Makefiles.html
> | #Reading-Makefiles
> 
> Thanks for the pointer. But, at least as I read that page, it sounds like
> all variables are expanded exactly once - whether they are immediate or
> deferred.
Nope - this is wrong.
Variables with deferred assignment are evaluated each time they are
referenced which your example shows.

And this is needed in many situations. Just think of the following variable:

info = INFO $@

Here each time you reference $(info) is is evaluated.
And in different command $@ may have different values.

And for variables there is no difference if they are used twice in a
command or in different commands.

My rule of thumb is: Always use immediate (:=) variables unless there is
a reason to use deferred variables.

        Sam




reply via email to

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