help-make
[Top][All Lists]
Advanced

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

Re: 6.2 The Two Flavors of Variables


From: grischka
Subject: Re: 6.2 The Two Flavors of Variables
Date: Thu, 24 Feb 2011 15:42:54 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

CFLAGS = $(CFLAGS) -O

Why it causes an infinite loop? The first time $(CFLAGS) is null so
the right side will be expanded to "null -O". There will be no second
time as null is a final value and CFLAGS becomes -O

Your statement "the first time $(CFLAGS) is null" indicates that you've
missing the critical aspect of recursive variables.
> [...]
Now make wants to expand $(CFLAGS) and it sees that the value of that
variable is '$(CFLAGS) -O'.  So it then tries to expand that, and sees
that $(CFLAGS) expands to '$(CFLAGS) -O'.  And so on until you run out
of memory.

I'd still argue that this is nothing more than a pretty accurate
description of an implementation bug.  Which is also the only way
to explain why gnu-make invented the term "recursive variable" to
denote a variable that must not be used recursively.

For example, there is no difference semantically whether you write
    CFLAGS = $(CFLAGS) -O
or
    CFLAGS += -O

Now since gnu-make does support the latter there cannot be a quasi
natural logical reason why it can't support the former, because +=
also implicitly references an value of the variable which if it was
expanded like you describe above would cause the same memory overflow.

See also:
    http://lists.gnu.org/archive/html/help-make/2008-04/msg00034.html
which basically discusses a -= operator as in
    CFLAGS -= -O
.

--- grischka



reply via email to

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