Hello, I was reading section 3.7 of the GNU make online manual (https://www.gnu.org/software/make/manual/make.html#Reading-Makefiles), especially the second paragraph:
"It’s important to understand this two-phase approach because it has a direct impact on how variable and function expansion happens; this is often a source of some confusion when writing makefiles. Here we will present a summary of the phases in which expansion happens for different constructs within the makefile. We say that expansion is immediate if it happens during the first phase: in this case make will expand any variables or functions in that section of a construct as the makefile is parsed. We say that expansion is deferred if expansion is not performed immediately. Expansion of a deferred construct is not performed until either the construct appears later in an immediate context, or until the second phase." I believe this paragraph is not worded very accurately. In the following I will try to show how I understand some of its sentences. First, from the following two sentences "We say that expansion is immediate if it happens during the first phase: in this case make will expand any variables or functions in that section of a construct as the makefile is parsed. We say that expansion is deferred if expansion is not performed immediately." I understand the following: - each cmake construct (i.e. rule, variable definition, directive and comment) has sections (e.g. a rule has 3 sections: targets, prerequisites and recipe) - text written in some of these sections will be expanded immediately (i.e. variable and function references are expanded); - text written in the remaining sections is not expanded immediately However, the next sentence, "Expansion of a deferred construct is not performed until either the construct appears later in an immediate context, or until the second phase.", uses a different terminology and does not seem to be accurate. The following questions arise: - what is a "deferred construct"? - how is a "deferred construct" expanded? - how can a "deferred construct" appear in an immediate context? My impression is that this sentence intends to refer to both ["recursively expanded variables"] and [recipes] as being "deferred constructs". First, a "recursively expanded variable" can "appear in an immediate context" (e.g. in the value of a "simply expanded variable"), however it is not expanded during the second phase. Furthermore, a deferred section of a rule (i.e. the recipe) is expanded during the second phase, however it cannot "appear in an immediate context". As a conclusion, I think that the last sentence of the quoted paragraph from section 3.7 uses the word "construct" to refer to both "recursively expanded variables" and "recipes" (a completely different meaning than the one used in the previous sentences) and it specifies two situations when they are expanded (however one situations appertains only to "recursively expanded variables" and the other only to "recipes"). Am I misunderstanding something or is this paragraph wrong? Thank you, Razvan Maris _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make