I've got a latex project that looks like this:
project/ |-- main.tex |-- main.bib |-- preamble.tex |-- preamble.fmt |-- makefile
The preamble (
preamble.tex) is being precompiled into
main.bib is generated using the
file contents environment in
This is what is in my
TEX = pdflatex -shell-escape -interaction=nonstopmode -file-line-error PRE = $(TEX) -ini -job-name="preamble" "&pdflatex preamble.tex\dump" BIB = bibtex .PHONY: all view all : main.pdf view : open main.pdf main.pdf : main.tex preamble.fmt main.bbl main.blg $(TEX) main.tex main.bbl main.blg : main.bib main.aux $(BIB) main main.aux : main.tex $(TEX) main.tex main.bib : main.tex $(TEX) main.tex preamble.fmt : preamble.tex $(PRE) preamble.tex
The problem is here that
bibtex relies on
main.aux to be generated, and
main.aux is regenerated every
pdftex run. This leads to regeneration of the bibtex files every run, which causes makefile to run
$(TEX) main.tex a second time (it thinks the
.blg files are changed, because it looks at their edit time).
So, basically every time I call
make all latex is compiled twice, even if there are no changes to references made anywhere in the document (thus making this unnecessary).
Is there a way I can tell
make that it only compiles twice if there is an actual change to the
.aux and the
.bib files. Perhaps by checking of md5 sums?
I'm kind of new to the whole makefile thing, so I thought I'd ask here. It could be off-topic, but I thought the latex gurus that reside on this site might have an answer.