Re: Multiple rules for same target: what is the order of prerequisites in $^ and what does $< expand to?

Mark Piffer <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <CAL1B-VwVQa1STfaHowqHKMZP+fASqpGM7J3=waDS0524Y0+9Rg@mail.gmail.com>
I apologize for using the wrong automatic variable. I had the firm
assumption that we were talking about "$^", not "$<" as I would never use
the latter in a case where the genesis of its content is not explicit.

Am Mo., 2. Okt. 2023 um 15:08 Uhr schrieb Paul Smith <[email protected]>:

> 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.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.