1

这是我的生成文件:

.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

如果命令以非零代码退出,是否没有更好的方法来运行某些东西?

我查看了手册,但找不到任何用于此目的的特殊目标。

4

1 回答 1

2

我不知道有什么方法可以设置一个标志,以便食谱中的任何和所有错误都会触发某个动作,但这比你所拥有的要干净一点:

reportError = (grep  ":[^:]*:" temp/thesis.log && false)

thesis: mktemp
    latex $(latexargs) thesis || $(reportError)
    bibtex -terse temp/A || $(reportError)
    ...
于 2012-05-17T17:01:41.660 回答