这是我的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
如果命令以非零代码退出,有没有更好的方法来运行某些东西?
我查看了manual,但找不到任何特殊目标。
答案 0 :(得分:2)
我不知道设置标志的任何方式,以便食谱中的任何和所有错误都会触发某个动作,但这比你所拥有的更清洁:
reportError = (grep ":[^:]*:" temp/thesis.log && false)
thesis: mktemp
latex $(latexargs) thesis || $(reportError)
bibtex -terse temp/A || $(reportError)
...