Re: Environment variables, debian/rules and dpkg-buildpackage
On Monday 04 May 2009 23:53:15 Manoj Srivastava wrote:
> On Mon, May 04 2009, Peter Eisentraut wrote:
> > Please be sure to use
> > FOO = bar
> > instead of ":=", unless you have determined that you really wanted ":=".
> > In most cases it won't make a difference, but in some it does, and then
> > it would behave contrary to how make usually treats variables.
> Why, in your opinion, would we want _not_ to use :=? What does
> delayed evaluation buy us?
That is up for debate, to some degree, I guess. I just want to make sure that
a conscious decision is made either way. (In my experience, many uses of :=
are made without knowledge about what it does.)
I think delayed evaluation is sort of the default way in which make treats
variables, and so to avoid surprises and confusion, we should go with that one
unless there is a specific reason otherwise.
In practical terms, using delayed evaluation makes the outcome mostly
independent of the order of the assignments. Which might become quite
relevant when you design an include-a-bit-here, override-a-bit-there scheme
that is supposed to be robust against all the nonsense that 10000 source
packages might do with it afterwards.
Also note that someone who wants to be careful not to overwrite values
supplied elsewhere might use ?=, which creates a delayed expansion type
In any case, we should be careful to define and document it one way or the
other. Otherwise stuff like
CPPFLAGS += -DFOO=$(BAR)
has unclear behavior, depending on how or whether CPPFLAGS was previously set
up. (And note that it will change if initially you don't define CPPFLAGS at
all and in a later version make a := definition for it -- delayed variables
being the default.)