This is my makefile:
.SILENT:
latexargs = -output-directory=temp -interaction=batchmode -file-line-error-style
thesis: mktemp
latex $(latexargs) thesis || make errors
bibtex -terse temp/A || make errors
bibtex -terse temp/B || make errors
latex $(latexargs) thesis || make errors
pdflatex $(latexargs) thesis || make errors
cat temp/thesis.pdf > thesis.pdf
diff: mktemp
latex $(latexargs) thesis-diff || make errors
bibtex temp/A || make errors
bibtex temp/B || make errors
latex $(latexargs) thesis-diff || make errors
pdflatex $(latexargs) thesis-diff || make errors
rm thesis-diff.tex
clean:
test -e temp
rm -f temp/*
mktemp:
mkdir -p temp
errors:
grep ":[^:]*:" temp/thesis.log
false
Is there no better way to run something if a command exits with a non zero code?
I have looked at the manual but could not find any special targets for that purpose.
I don’t know of any way to set a flag so that any and all errors in recipes will trigger a certain action, but this is a little cleaner than what you have: