help-make
[Top][All Lists]
Advanced

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

variable reassign value in same makefile


From: anand akhare
Subject: variable reassign value in same makefile
Date: Wed, 3 Apr 2024 09:52:31 +0000

Hello make team,
    according to the info make page, recursive variable takes value at the time 
it is used. However, no reference is there in doc what happens if value is 
changed for the variable. To verify this I created small makefile as below and 
on executing make trg1, it shows VAR value as jklmn. Output pasted below the 
makefile. Pls clarify if value of variable is taken once in makefile as last 
one assigned and rest are discarded. My idea is that intermediate values of 
variable should be used until changed for target and recipe. Same behavior is 
seen with non-recursive variables. (like VAR:=abc)

Regards
Anand

---------------------
VAR="abc"

trg1:
        echo "trg1 ${VAR}"

VAR="def"

trg2:
        echo ${VAR}

trg3:
        echo ${VAR}


all: trg1 trg2 trg3


VAR="jklmn"
----------------------

output of make trg1:

$ make trg1
echo "trg1 "jklmn""
trg1 jklmn


















reply via email to

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