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 preamble.fmt. main.bib is generated using the file contents environment in main.tex.
This is what is in my makefile
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 .bbl and .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.
rubber,latexmkor similar tools? Also, why are you building a format? – Joseph Wright♦ Jan 11 '12 at 11:13{makefile}tag, which I'm now scanning for useful code. I'll leave this question up for now. – romeovs Jan 11 '12 at 11:14c++code that generates data which I input into the tex file) and I don't know if that can be easily done usinglatexmkorrubber. – romeovs Jan 11 '12 at 11:17main.auxto the dependencies of$(BIB)(I don't know if its the right terminology). – egreg Jan 11 '12 at 13:26bibtexdoes need themain.auxfile to be present. Either way, I still would need to compilemain.texbeforebibtexis run to see ifmain.bib(which is generated in themain.texrun) has changed. The problem is in howmakechecks if a file has changed. Perhaps this question should be migrated to the Stack Overflow site? – romeovs Jan 11 '12 at 14:24