bug-make
[Top][All Lists]
Advanced

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

Re: New conditional assignment facility


From: Paul Smith
Subject: Re: New conditional assignment facility
Date: Thu, 11 Jan 2024 08:38:49 -0500
User-agent: Evolution 3.50.2 (by Flathub.org)

On Thu, 2024-01-11 at 14:28 +0100, Alejandro Colomar wrote:
> > >   alx@debian:~/tmp$ cat Makefile 
> > >   var ?= foo
> > >   var ?+= bar
> > >   $(info $(var))
> > >   alx@debian:~/tmp$ make-9000
> > >   foo bar
> > >   make: *** No targets.  Stop.
> > >   alx@debian:~/tmp$ make-9000 var=foo
> > >   foo
> > >   make: *** No targets.  Stop.
> > >   alx@debian:~/tmp$ var=foo make-9000
> > >   foo
> > >   make: *** No targets.  Stop.

Sorry Alejandro; maybe you need to rewrite your examples again without
all the corrections, because I don't understand what you mean.

In all your examples, the value of var is set by the first line if it's
not already set:

    var ?= foo

After this line, var will either be "foo" or it will be whatever value
var had before that assignment (from the environment or command line or
whatever, it doesn't matter).  But it's definitely defined.

Once that happens, any subsequent "?" assignments, of any type, are
simply ignored and useless because "?" means "set if not defined" but
after the above line, var is always defined.

So it doesn't matter if the next line is "var ?= bar" or "var ?+= bar"
or whatever: it is just ignored.

-- 
Paul D. Smith <psmith@gnu.org>            Find some GNU make tips at:
https://www.gnu.org                       http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad
Scientist



reply via email to

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