Hi, The static pattern solution looks very nice, thanks. It seems to work fine in the real Makefile. And there is no visible performance impact, as far as I can tell (I'm not sure about how efficiently static pattern rules are implemented). So I think I'll go for this one.
I also tried idea suggested by Sébastien to add prerequisites using a target-specific variable. It can be made to work using secondary expansion: foo_prereqs = additional prerequisites specific to foo .SECONDEXPANSION: %.t: %.x $$($$*_prereqs) ... But I find this more complex. Thanks for your help ! Tiphaine ________________________________ From: Help-make <help-make-bounces+tiphaine.turpin=mathworks...@gnu.org> on behalf of Max Gautier <ashelia1...@gmail.com> Sent: Wednesday, September 5, 2018 11:03 AM To: help-make@gnu.org Subject: Re: Proper usage of multiple rules for the same targets 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 _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make