[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Deferred->immediate variable reassignment trick.
From: |
Paul Smith |
Subject: |
Re: Deferred->immediate variable reassignment trick. |
Date: |
Wed, 21 Jun 2023 12:51:56 -0400 |
User-agent: |
Evolution 3.48.3 (by Flathub.org) |
On Wed, 2023-06-21 at 11:55 -0400, Brian J. Murrell wrote:
> On Wed, 2023-06-21 at 11:47 -0400, Paul Smith wrote:
> > On Wed, 2023-06-21 at 08:31 -0700, Kaz Kylheku wrote:
> > > If I just have this:
> > >
> > > IMPORTANT_VAR := $(shell sh -c "echo calculate; echo executed
> > > 1>&2")
> > >
> > > and do "make IMPORTANT_VAR=alternative", I still see "executed"
> > > on standard output.
> >
> > IMO that is a bug and it should be reported as such on Savannah.
>
> Is it? Isn't the functionality of not overriding a variable value
> set on the make command line with a value in the Makefile what the ?=
> assignment operator is for?
No. Variables assigned on the command line always take precedence over
values set in the makefile, regardless of which assignment operator is
used. This is easy to see:
$ cat Makefile
V ?= foo
all: ; @echo '$(V)'
$ make
foo
$ make V=bar
bar
The only way to have a variable in a makefile take precedence over a
command line variable is by adding the override statement.
https://www.gnu.org/software/make/manual/html_node/Overriding.html