[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mixing grouped explicit targets rule with static pattern rule
From: |
Kaz Kylheku (gmake) |
Subject: |
Re: Mixing grouped explicit targets rule with static pattern rule |
Date: |
Mon, 22 Mar 2021 12:02:11 -0700 |
User-agent: |
Roundcube Webmail/0.9.2 |
On 2021-03-22 09:21, Nithish Chandran wrote:
I tried using grouped targets with pattern rules which worked. But
like you said this would defeat the purpose of advanced dependency
generation.
%.o %.d &: %.c
g++ -c $< -o $@ -MMD -MF $*.d -MP -MT $*.o
Hi, I'm the person who initially implemented grouped
semantics for direct targets.
Nevertheless, please take everything I write with a grain of salt
because I have not looked at the code or documentation since that time.
Pattern rules have grouped target semantics already, and in
fact their implementation was used as the basis for :&.
I would therefore advise users not to try to use :& in
pattern rules because it is redundant. By which I mean
that I hope it is redundant. My sincere wishes are that
the code treats it as redundant, but even if you're finding
it so, perhaps don't do it.
When a pattern rule like:
%.o %.d : %.c # note ordinary colon
matches a stem like "foo", it instantiates a direct rule,
internally. Now that we have :&, we can express what that
generated rule looks like using syntax:
foo.o foo.d &: foo.c
see? The :& feature gives you access to the target grouping that
was previously available only to the pattern-rule-instantiating
logic.
Before :&, you could group targets using a pattern rule.
For that to be applicable, you needed all the files involved
to have a usable common stem, and to write a pattern rule
instead of a direct rule.
Cheers ...