Hi Paul! On Thu, Jan 11, 2024 at 01:44:19AM -0500, Paul Smith wrote: > I've implemented a new capability for conditional assignments (not > pushed yet). > > After these changes, a "?" can precede any type of assignment > operation, not just "=", and make it conditional (that is, it only > takes effect if the variable is not already set). > > So for example, in addition to "?=" which creates a recursive variable > if the variable is not set yet, GNU Make will support "?:=" which > creates a simple variable if the variable is not set yet.
Thanks!!
> Of course if
> it's already set then the right-hand side of the assignment is not
> expanded.
>
> Similarly the assignments "?::=" and "?:::=" are also supported.
>
>
> There is one question I wanted to ask for opinions on: what should we
> do with the "?+=" operator?
There's a use for it: appending to a variable if it wasn't set in the
environment (ignoring what happened in the Makefile).
Here's what += does:
alx@debian:~/tmp$ cat Makefile
var ?= foo
var += bar
$(info $(var))
alx@debian:~/tmp$ make
foo bar
make: *** No targets. Stop.
alx@debian:~/tmp$ make var=foo
foo
make: *** No targets. Stop.
alx@debian:~/tmp$ var=foo make
foo bar
make: *** No targets. Stop.
And here's what ?+= could do:
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.
In the last case (environment variable), since var was set, ?+= would do
nothing, unlike +=.
Have a lovely day,
Alex
--
<https://www.alejandro-colomar.es/>
Looking for a remote C programming job at the moment.
signature.asc
Description: PGP signature
