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: Toan Pham
Subject: Re: Undefined environment variable and operator ?=
Date: Mon, 17 Apr 2017 10:00:58 -0400

Paul,

What is the best way to override the default compiler?  is this good
practice:


CXX:=$(CROSS_COMPILE)$(CXX)


thanks,

TP


On Mon, Apr 17, 2017 at 9:37 AM, Paul Smith <address@hidden> wrote:

> 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.
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-make
>


reply via email to

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