Am 27.09.2023 um 12:17 schrieb Renaud Pacalet <renaud.pacalet@telecom-paris.fr>:
Dear all,
I read the manual carefully (especially section 4.11 "Multiple Rules for One
Target") and searched the help-make archives but couldn't find a clear description of
how $^ and $< are computed when there are several rules for the same target and only one
has a recipe.
According the manual "All the prerequisites mentioned in all the rules are merged into
one list of prerequisites for the target". But when the recipe gets expanded what is
the order of prerequisites in $^ and, more important, what is $<? Does it depend on the
order of rules in the Makefile(s)? On the type of rules (pattern, static pattern,
explicit...)? On which rule has a recipe? Is it deterministic? etc.
I did some tests and came up with the following algorithm for $^ and $<
computation:
0. When the list of prerequisites of a rule is added to $^, the order is
preserved.
1. Initialize $^ with the list of prerequisites of the rule with a recipe,
implicit or not.
2. Consider all other applicable explicit or static pattern rules, in their
order of appearance in the Makefile(s), and for each of them append its list of
prerequisites to $^.
3. Ignore all other implicit rules (which seems to contradict 4.11).
4. Remove duplicates from $^, keeping only the first occurrence.
5. Set $< to the first prerequisite in $^.
Can someone confirm?
Renaud.