[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: variable reassign value in same makefile
From: |
David |
Subject: |
Re: variable reassign value in same makefile |
Date: |
Thu, 4 Apr 2024 00:28:20 +0000 |
On Wed, 3 Apr 2024 at 13:07, anand akhare <anandstraight@outlook.com> wrote:
> 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.
Hi, what you are not understanding is explained in this part of the
documentation:
https://www.gnu.org/software/make/manual/make.html#Reading-Makefiles
Where it explains:
"GNU make does its work in two distinct phases".
Variable values are assigned during "first phase".
"Run the recipes" occurs during "second phase", after all variable values
are assigned.
In other words: make files are NOT processed ONCE from top to bottom.
They are processed from top to bottom MORE THAN ONCE, and different things
happen each time.
So all of these assignments are processed during "first phase":
VAR="abc"
VAR="def"
VAR="jklmn"
and each one of them overwrites the previous one, so that only the final
one controls the value used by the rules, which execute during "second
phase".