On 28/09/2023 15:41, Paul Smith wrote:
On Wed, 2023-09-27 at 16:50 +0200, Renaud Pacalet wrote:
Thanks for your answer, Bahman. Not sure what "equivalent" means but
with the following Makefile:
%.a: %.b
a.a: a.c
echo $^
The first pattern rule here does not define a pattern rule. It
*cancels* a pattern rule. See:
https://www.gnu.org/software/make/manual/html_node/Canceling-Rules.html
It's not possible for two different pattern rules to both be in effect
when building the same target, just like it's not possible for multiple
implicit rules with recipes to be in effect.
Basically, the way it works is that the prerequisites on the rule that
has the recipe come first, and any other prerequisites added by rules
without recipes are added afterwards, in the order in which they appear
in the makefile.
Thanks a lot Paul for your explanations. I suggest to add something in
the documentation, at least to clearly specify the result of the
expansion of $< in the recipe, because it's not as simple as it seems
(first prerequisite of rule with the recipe if it has prerequisites,
else first prerequisite of first applicable rule in makefile). Does it
make sense?
Renaud.
--
Renaud Pacalet
Télécom Paris
Campus SophiaTech
450 Route des Chappes, CS 50193
06904 Biot Sophia Antipolis cedex, FRANCE
Tel : +33 (0) 4 9300 8402
Web : http://www.telecom-paris.fr/