I thought that having multiple targets in a rule was the same as defining multiple rules with the same recipe for each of the targets; however, I seem to have a problem when the target/dependency have patterns.
Here's a simplified sample makefile with two different methods for building files.
all: $(foreach n, 1 2 3, $(foreach l, a b, out.$(l).$(n).txt))
1.txt 2.txt 3.txt:
touch $@
#Method One
out.a.%.txt out.b.%.txt: %.txt
touch $@
#Method Two
out.a.%.txt: %.txt
touch $@
out.b.%.txt: %.txt
touch $@
Using method one with a "make -n" I get
touch 1.txt
touch out.a.1.txt
touch 2.txt
touch out.a.2.txt
touch 3.txt
touch out.a.3.txt
but with method two I get the desired output
touch 1.txt
touch out.a.1.txt
touch out.b.1.txt
touch 2.txt
touch out.a.2.txt
touch out.b.2.txt
touch 3.txt
touch out.a.3.txt
touch out.b.3.txt
I didn't see any exceptions to the multiple target in a rule in the on-line docs. Did i miss a part of the documentation that explains why this doesn't work? Is there an easy way to make it work? (In reality, I have many more combinations of files to build than in this simple example).
(Using GNU Make 3.81)