bug-make
[Top][All Lists]
Advanced

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

Re: Possible bug with pattern-specific variables


From: Bahman Movaqar
Subject: Re: Possible bug with pattern-specific variables
Date: Wed, 27 Sep 2023 07:20:42 -0700
User-agent: Evolution 3.50.0

Invoking make like `make FOO=X BAR=Y' causes Make to consider `FOO' and
`BAR' as special recursive/deferred variables.

>From GNU Make manual:

> all ordinary assignments of the same variable in the makefile are 
> ignored; we say they have been overridden by the command line 
> argument. 

Each one will be appended to twice (matching pattern rules) before
being expanded as `$(FOO)' and `$(BAR)'.

See https://www.gnu.org/software/make/manual/make.html#Overriding

∎

On the other hand, `env FOO=X BAR=Y make' creates two environment
variables which make does not treat as recursive variables.  They just
always expand to the same value.

∎

HTH,

-- 
Bahman

Join the chatter on Matrix:
         🌐 https://matrix.to/#/#.mk:matrix.org
      
Subscribe to the Lemmy community:
         🌐 https://lemmy.ml/c/makefile





On Wed, 2023-09-27 at 08:03 +0200, Markus F.X.J. Oberhumer wrote:
> Very stange GNU make behaviour with pattern-specific variables - note
> the "X X X" in the output below:
> 
> $ env FOO=X BAR=Y make
> FOO='X  ' BAR='Y  '
> 
> $ make FOO=X BAR=Y
> FOO='X X X' BAR='Y'
> 
> It this really intended?
> 
> ~Markus
> 
> 
> $ cat Makefile
> 
> default: build/release
> 
> build/%: FOO +=
> build/%: FOO +=
> BAR +=
> BAR +=
> 
> build/release:
>         @echo "FOO='$(FOO)' BAR='$(BAR)'"
> 
> .PHONY: default build/release
> 
> 
> # END of Makefile
> 
> 
> 



reply via email to

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