[Tex/LaTex] How to only output dependencies from latexmk

latexmkmakefile

I'd like to use latexmk in a Makefile, so I've read the manual section on that. However, the dependency generation step seems less than ideal. Specifically, it seems that latexmk can only show dependencies after fully building an output file (which can take a long time in my case). Is there a way to have latexmk only output dependencies to a file and not mark the actual output file as up-to-date?

I've tried the following rule in my Makefile, but it seems to mark the output file as up-to-date. I'd also think it could run multiple times (or think it has failed) depending on what's in the log file.

%.d: %.tex
    @echo "Generating $@ from $<"
    @set -e; \
     $(LATEXMK) -M -MF $@ -quiet -pdf \
      -pdflatex="echo Generating dependencies from %T" $<

Best Answer

@tohecz: You are correct.

The problem is that the dependencies depend in a complicated way on the detailed contents of the TeX file (and all the files it calls in, including the class file and the style files). The only easy way to determine the dependencies is to run pdflatex (or latex as appropriate), and then analyze the resulting files (the relevant ones are the .fls, .log and .aux files). If the .tex file changes, then both the .pdf and the dependency information are simultaneously out of date.

Therefore, if you want to run pdflatex to determine the dependencies, you get a new .pdf file as a side effect. So there's no point to trying to update the dependency information without updating the .pdf file.