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: John Graham-Cumming
Subject: Re: about immediate and deferred variable assignment in GNU make
Date: Wed, 26 Apr 2006 16:10:26 +0200

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.
reply via email to

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