I am aware of LatexMk, but can't install that on the machine where I want to run pdflatex
, so I need to write a Makefile of which %.pdf
files are targets that depend on %.tex
and the *.tex
files that %.tex
is inputting. For this I wrote the following:
%.pdf : %.tex $(shell perl -lne 'print "$$1\n" if /\\input{([\w-]+\.tex)}/' %.tex)
Now, I tested the regular expression and it seems to work fine, but the %.tex
at the end isn't passed correctly, running make output.pdf
gives me:
Can't open %.tex: No such file or directory.
How can I pass %.tex
to the $(shell)
command?
I'm using GNU make.
make
syntax at all, but the text before the $ could be a SunPro-make enhancement that was introduced in Spring 1986: an implicit pattern matching rule. Such a rule may not be followed by everything you wrote starting with $ and the command line for the rule is missing.%.pdf
is the target,%.tex
is the first dependency and$(shell ...)
should create a further list with dependencies. That's what I learned here. I'm using GNU Make 3.81, and all this runs fine except that the final%.tex
doesn't expand. Please provide reference for "This is notmake
syntax at all".make
. $(shell ) is definitely illegal make syntax. Text like this is not permitted in a pattern matching rule and even a pattern matching rule is a SunPro-make enhancement already. See the POSIX make description for lealmake
syntax: pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html