bug-make
[Top][All Lists]
Advanced

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

Re: append assignment operator in target specific variable


From: Henrik Carlqvist
Subject: Re: append assignment operator in target specific variable
Date: Sun, 19 May 2019 22:06:12 +0200

> 1. "foo" is simple variable.
>    so result have to be 100 but is 200
> 
> foo :=
> val := 100
> 
> all : foo += $(val)
> all :
>       @echo foo : $(foo)
> 
> val := 200
> 
> result is : 200

Yes, the result will become 200 because foo is not expanded until it is
usead at the line "@echo foo : $(foo)". At that time, before building
"all" the entire Makefile will have been read and val was assigned to 200
at the last line in the Makefile.

> -------------------------------------------------------
> 
> 2. If i change '+=' operator to ':=' then result is 100
> 
> foo :=
> val := 100
> 
> all : foo := $(val)
> all :
>       @echo foo : $(foo)
> 
> val := 200
> 
> result is : 100
> ----------------------------------

Yes, because ":=" unlike "=" and "+=" is expanded at that very line. 

regards Henrik



reply via email to

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