help-make
[Top][All Lists]
Advanced

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

Re: Undefined environment variable and operator ?=


From: Paul Smith
Subject: Re: Undefined environment variable and operator ?=
Date: Mon, 17 Apr 2017 09:37:41 -0400

On Mon, 2017-04-17 at 09:43 +0200, zosrothko wrote:
> Here a simple makefile that sets the variable CXX if not defined to
> $(FOO)g++
> CXX     ?=$(FOO)g++
> 
> test:
>         @echo $(CXX)
> 
> and the some stories
> 
> address@hidden:~/make$ unset CXX
> address@hidden:~/make$ make
> g++
> address@hidden:~/make$ make FOO=bar
> g++
> address@hidden:~/make$ FOO=bar make
> g++
> address@hidden:~/make$ export FOO=bar;make
> g++
> 
> Why CXX is never set to 'barg++' ?

?= only assigns a value if the variable has no value.

However, CXX always has a value, because there's a default value set:

  $ make -pf/dev/null | grep ^CXX
  make: *** No targets.  Stop.
  CXX = g++

If you had chosen a different value to set your variable to it may have
been more clear; using:

  CXX ?= $(FOO)bar

you would still see output:

  address@hidden:~/make$ make
  g++

so clearly your assignment is not having any effect at any time.



reply via email to

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