[Top][All Lists]

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

Re: --no-builtin-variables then assign to a builtin variable

From: Paul Smith
Subject: Re: --no-builtin-variables then assign to a builtin variable
Date: Sat, 25 Jul 2015 15:26:20 -0400

On Sat, 2015-07-25 at 08:55 -0700, John Reiser wrote:
> The workaround in GNU Make 4.0 is to use a different name
> because it looks like --no-builtin-variables permanently disables
> those names.

That's not what's happening.  You can see that by using a different

  $ cat Makefile
  CC = foobar
  all: ; @echo '$(CC)'

  $ make

The thing that's confusing you is that make doesn't interpret changes to
the MAKEFLAGS variable immediately every time that variable is reset in
the makefile.  Instead it reads all the makefiles, then after it's done
with all makefiles it re-interprets the MAKEFLAGS variable one time and
sets things up to align with the flags it finds.

So in your makefile when make checks this:

  ifeq ($(CC),)

the variable CC still has its built-in value and so this statement is
not true, and so your local value of CC is never set and the built-in
value is preserved.  Then later when make unsets built-in values, the
built-in value for CC is removed and now the variable is empty.

Another way to see this:

  $ cat Makefile

  $(info CC=$(CC))

  ifeq ($(CC),)
  CC = foobar

  $(info CC=$(CC))

  all: ; @echo 'CC=$(CC)'



reply via email to

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