Reputation: 7487
I experienced the following:
$ cat Makefile
POLYSCRIPTER=${HOLDIR}/Manual/Tools/polyscripter
UMAP=${HOLDIR}/Manual/Tools/umap
all: tactics.pdf
%.tex: %.stex
${POLYSCRIPTER} ${UMAP} <%.stex >%.tex
tactics.pdf: %.tex
pdflatex tactics.tex
bibtex tactics
pdflatex tactics.tex
pdflatex tactics.tex
clean:
rm tactics.{aux,bbl,blg,log,pdf,tex,ui,uo}
$ make
make: *** No rule to make target '%.tex', needed by 'tactics.pdf'. Stop.
There is a %.tex target. What am I doing wrong?
This is GNU Make 4.3 .
UPDATE: What I want to express: create any %.tex file from the corresponding %.stex file, and then produce the tactics.pdf from latexing tactics.tex that includes all the %.tex files.
UPDATE2: I edited a line, learning how to refer to the dependency and the target:
${POLYSCRIPTER} ${UMAP} <$< >$@
Upvotes: 1
Views: 423
Reputation: 100836
A pattern rule is a template that tells make how to build a target. It doesn't provide make with a list of targets to build: it's just a recipe for building targets. So this pattern rule:
%.tex: %.stex
Doesn't tell make "go out to the filesystem and find all files that match %.stex
that could be turned into .tex
files and do that". It tells make, "hey, if you find that for some reason you want to build a target that matches the pattern %.tex
then here's a way you could build it".
This, on the other hand:
tactics.pdf: %.tex
is not a pattern rule at all. A pattern rule MUST have a %
in the target name. This is a straightforward explicit rule that just happens to depend on a file named, literally %.tex
. Make doesn't know of any way to build a file named %.tex
(because there is no file named literally %.stex
and so the pattern rule you defined above doesn't apply).
You could do this instead:
tactics.pdf: *.tex
using shell globbing. This is closer, because it tells make a group of .tex
files to build. But this won't work either because when you first run make no .tex
files exist! So, this expression will not match any files and you'll have an empty set of prerequisites.
What you have to do is (1) find all the source files you want to build:
STEX := $(wildcard *.stex)
Then (2) convert that into the set of targets you want to build:
TEX := $(patsubst %.stex,%.tex,$(STEX))
Then (3) list these targets as prerequisites of the PDF file:
tactics.pdf: $(TEX)
Now, make will use your pattern rule to determine how to build these .tex
files.
Upvotes: 2