help-make
[Top][All Lists]
Advanced

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

Re: about immediate and deferred variable assignment in GNU make


From: Lin George
Subject: Re: about immediate and deferred variable assignment in GNU make
Date: Wed, 26 Apr 2006 07:51:19 -0700 (PDT)

Thanks John!
 
 
Your sample is so great! I suggest you add them to GNU make manual. :-)
 
> You might benefit from getting a copy of Robert Mecklenburg's 'Managing Projects
> with GNU Make' book since it contains many examples.
 
I have Googled "Managing Projects with GNU Make" and it is a published book and there is no free version (copy) of this book on the Internet. Correct?
 
 
regards,
George

John Graham-Cumming <address@hidden> wrote:
Here's an example that I hope helps:

FOO = at the start
BAR = $(FOO)
BAZ := $(FOO)
FOO = at the end

BAR has deferred expansion (it was defined with =) and BAZ has immediate (it was defined with :=).   In this example, when BAR is used its value will be 'at the end' and BAZ will have the value 'at the start'.  That's because when BAR was defined it was set to be $(FOO) without any substitution.  Only when BAR is used in the Makefile will $(FOO) be expanded and since FOO is set to 'at the end' last that's the value that will be used.

On the other hand, BAZ has the value 'at the start' because it was set to $(FOO) using :=.  That means that $(FOO) was immediately expanded to its then value 'at the start' and it was 'at the start' that was stored in BAZ.

You might benefit from getting a copy of Robert Mecklenburg's 'Managing Projects with GNU Make' book since it contains many examples.

John.


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.
reply via email to

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