help-make
[Top][All Lists]
Advanced

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

Re: Proper usage of multiple rules for the same targets


From: Max Gautier
Subject: Re: Proper usage of multiple rules for the same targets
Date: Wed, 5 Sep 2018 11:03:13 +0200

Hi.

To force the behavior you want, I think you could use a static pattern rule :

The syntax being as follow :

<list_of_target>:<pattern_target>:<prerequisite_pattern>

In your case, that would give :

foo.t: %.t: %.x
    touch $@

foo.t: another_file

That achieves what you want, if I'm testing correctly.
(You'll need to have a way to have all of your concerned target in a variable
for readabilite, of course, something like

$(TARGETS): %.t: %.x

)

The reason for that is that static pattern rules are not really pattern rules,
which act as default when no other rules can be found.
The static pattern rule is in fact more a template, which is applied to
all of the targets listed in the <list_of_target>.
Thus, a static pattern rule is equivalent to write the same rule
for all of your listed targets, and each behave as a normal rule. (aka
: will always apply to that target)

(This is explained more clearly in the Static Pattern section in the
Gnu Make manual).


I'm not sure that this solution will not conflict with your other
requirements, though.
Specifically, you mentions using $^ in recipes : I think the
'another_file' dependency would
end up in it ; although I dont think there is any way to avoid it.
Let me know if you managed to work around it.

Regards,

Max



reply via email to

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