On Wed, Feb 20, 2019 at 1:04 AM LeJacq, Jean Pierre <jeanpierre.lej...@quoininc.com> wrote: > > On Tuesday, February 19, 2019 10:51:42 AM EST Masahiro Yamada wrote: > > > > ------------(Makefile begin)--------- > > .PHONY: all > > all: foo.x foo.z > > > > %.x %.z: > > touch $@ > > -------------(Makefile end)---------- > > > > $ rm foo* > > $ make > > touch foo.x > > $ make > > touch foo.z > > $ make > > make: Nothing to be done for 'all'. > > > > When multiple targets appear in one implicit rule, > > Make runs the recipe just once instead of twice > > even when it is requested to create two targets. > > > > In this case, does Make assume the recipe > > will create both %.x and %.z ? > > > > Is this behavior intentional? > > Documented somewhere? > > There are two cases, both documented in the GNU Make manual: > > 1. https://www.gnu.org/software/make/manual/html_node/Multiple-Targets.html > 2. https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html
Thanks for the links. > Your example is covered by the first reference which describes multiple > targets for a normal rule. No. My case is covered by the second reference. The second one exactly explains this case: Pattern rules may have more than one target. Unlike normal rules, this does not act as many different rules with the same prerequisites and recipe. If a pattern rule has multiple targets, make knows that the rule’s recipe is responsible for making all of the targets. The recipe is executed only once to make all the targets. When searching for a pattern rule to match a target, the target patterns of a rule other than the one that matches the target in need of a rule are incidental: make worries only about giving a recipe and prerequisites to the file presently in question. However, when this file’s recipe is run, the other targets are marked as having been updated themselves. Thanks. > If you want the recipe in a rule to create more > than one target, you have to use a pattern rule as documented in the second > reference. > > -- > JP > > > > > _______________________________________________ > Bug-make mailing list > Bug-make@gnu.org > https://lists.gnu.org/mailman/listinfo/bug-make -- Best Regards Masahiro Yamada _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make