started with presentation, outline
[msc-thesis1617.git] / build
diff --git a/build.sh b/build
old mode 100644 (file)
new mode 100755 (executable)
similarity index 74%
rename from build.sh
rename to build
index 0a84c8f..35b62ec
--- a/build.sh
+++ b/build
@@ -17,25 +17,43 @@ deps(){
 
 recompile(){
        for dep in $(deps "$1"); do
-               [ "$dep" -nt "$2" ] && return 0
+               if [ "$dep" -nt "$2" ]; then
+                       log "$dep is newer than $2, thus recompiling"
+                       return 0
+               fi
        done
        return 1
 }
 
 preamble(){
        pdflatex $LATEXFLAGS -ini -jobname="$2" "&pdflatex $1\dump"
+       ret=$?
        rm -f $2.pdf
+       [ $ret -ne 0 ] && exit 1
 }
 
 compile(){
-       pdflatex $LATEXFLAGS $1
-       grep -q '^\\bibdata{' $1.aux && bibtex $1
-       grep -q '\@istfilename' $1.aux && makeglossaries $1
-       [ -f $1.idx ] && makeindex $1
+       pdflatex $LATEXFLAGS $1 || exit 1
+
+       if grep -q '^\\bibdata{' $1.aux
+       then bibtex $1 || exit 1
+       fi
+
+       if grep -q '\@istfilename' $1.aux
+       then makeglossaries $1 || exit 1
+       fi
+
+       if [ -f $1.idx ]
+       then makeindex $1 || exit 1
+       fi
+
        tmpf=$(mktemp)
-       trap RETURN rm -v $tmpf
-       pdflatex $LATEXFLAGS $1 | tee $tmpf
-       grep -Fiq "Rerun" $tmpf && pdflatex $LATEXFLAGS $1
+       pdflatex $LATEXFLAGS $1 | tee $tmpf || exit 1
+
+       if grep -Fiq "Rerun" $tmpf
+       then pdflatex $LATEXFLAGS $1 || exit 1
+       fi
+
        rm -vf $tmpf
 }