According to GNU Make Manual
A rule with multiple targets is equivalent to writing many rules, each with one target, and all identical aside from that. The same recipe applies to all the targets, but its effect may vary because you can substitute the actual target name into the recipe using ‘$@’. The rule contributes the same prerequisites to all the targets also.
This is my first Makefile:
%.in %.out: echo BLANK > $@
And this is my first bash session:
$ ls Makefile $ make a.in a.out echo BLANK > a.in make: Nothing to be done for 'a.out'. $ ls Makefile a.in $ make a.out echo BLANK > a.out $ ls Makefile a.in a.out $ make b.in c.out echo BLANK > b.in echo BLANK > c.out $ make d.in d.out echo BLANK > d.in make: Nothing to be done for 'd.out'. $ make e.out e.in echo BLANK > e.out make: Nothing to be done for 'e.in'. $ ls Makefile a.in a.out b.in c.out d.in e.out
This is my second Makefile:
%.in: echo BLANK > $@ %.out: echo BLANK > $@
And this is corresponding bash session:
$ ls Makefile $ make a.in a.out echo BLANK > a.in echo BLANK > a.out $ ls Makefile a.in a.out $ # nice
Why doesn't the first Makefile create targets like
<name>.in <same name>.out simultaneously? Why isn't it interpreted similar to the second Makefile?