Re: Deferred->immediate variable reassignment trick.

Kaz Kylheku <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
On 2023-06-20 12:55, Paul Smith wrote:
> I don't understand how this is different than just:
> 
>     IMPORTANT_VAR := $(IMPORTANT_VAR)
> 
> If the user specifies an override of the variable on the command line
> then the value in the makefile will never be used, so the shell command
> will never be invoked.

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. (In an installation with Make 4.1.)

If I just have this:

  IMPORTANT_VAR = $(shell sh -c "echo calculate; echo executed 1>&2")

and use $(IMPORTANT_VAR) in multiple places, I see multiple "executed",
of course.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.