help-make
[Top][All Lists]
Advanced

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

Re: Multiple rules for same target: what is the order of prerequisites i


From: Paul Smith
Subject: Re: Multiple rules for same target: what is the order of prerequisites in $^ and what does $< expand to?
Date: Mon, 02 Oct 2023 09:08:23 -0400
User-agent: Evolution 3.48.4 (by Flathub.org)

On Mon, 2023-10-02 at 09:06 +0200, Mark Piffer wrote:
> For the sake of reliability I wouldn't use pure `$<` anywhere.

I'm not sure what you mean by "reliability" (I'm not aware of any
change to the behavior of $< in the 30+ year history of GNU make) and I
don't know what you mean by "pure $<"; what would one use instead, that
is "non-pure"?

> And if the answer to your question "Which one, listed in another
> rule, becomes $<?" isn't "All collected prerequisites, with
> duplicates purged"

I don't understand what this means.  $< is always a single word.  It's
never multiple words so it can never be "all collected prerequisites".

Also make doesn't drop duplicates (this is necessary because sometimes,
for example for linking, duplicates are important).  But that doesn't
matter for $< which is always a single word, as I mentioned.

The behavior is straightforward: when make parses a rule _without_ a
recipe, it will append new prerequisites to the END of its targets'
list of prerequisites.

When make parses an explicit rule that _has_ a recipe, then those
prerequisites are added to the BEGINNING of the target's list of
prerequisites.

For implicit rules, the prerequisites on the matching rule are added to
the BEGINNING of the target's list of prerequisites when it matches.

Then, when $< is expanded, it expands to the first prerequisite.



reply via email to

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