I have this makefile:
.PHONY: all
all: foo.o
makefile: ;
%.inc:
echo INC
touch $@
%.o: bar.inc
echo O
touch $@
%.o:
FAIL
I expect it to use the first %.o
rule, create bar.inc as a prerequisite, and then create foo.o. Instead it uses the last rule and I get this:
FAIL
make: FAIL: Command not found
make: *** [foo.o] Error 127
It works fine if I either change %.inc
to bar.inc
or change %.o
to foo.o
.
The documentation says
In order for the pattern rule to apply, its target pattern must match the file name under consideration and all of its prerequisites (after pattern substitution) must name files that exist or can be made.
Does the pattern rule %.inc
not count as "can be made"? I am using GNU Make 3.81.