2005-12-05 15:11:09 +01:00
|
|
|
source $stdenv/setup
|
2005-06-20 15:51:48 +02:00
|
|
|
|
|
|
|
ensureDir $out
|
|
|
|
|
2005-08-30 15:10:30 +02:00
|
|
|
startDir=$(perl $copyIncludes $includes)
|
|
|
|
cd $startDir
|
2005-06-20 17:06:58 +02:00
|
|
|
|
2005-06-21 00:43:35 +02:00
|
|
|
for i in $extraFiles; do
|
|
|
|
if test -d $i; then
|
|
|
|
ln -s $i/* .
|
|
|
|
else
|
|
|
|
ln -s $i $(stripHash $i; echo $strippedName)
|
|
|
|
fi
|
|
|
|
done
|
2005-06-20 15:51:48 +02:00
|
|
|
|
|
|
|
rootName=$(basename $(stripHash "$rootFile"; echo $strippedName))
|
|
|
|
|
|
|
|
rootNameBase=$(echo "$rootName" | sed 's/\..*//')
|
|
|
|
|
|
|
|
if test -n "$generatePDF"; then
|
|
|
|
latex=pdflatex
|
|
|
|
else
|
|
|
|
latex=latex
|
2005-08-16 22:59:39 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
latexFlags="-file-line-error"
|
|
|
|
tmpFile=$out/log
|
|
|
|
|
|
|
|
showError() {
|
|
|
|
echo
|
|
|
|
echo "LATEX ERROR (LAST LOG LINES SHOWN):"
|
|
|
|
tail -n 20 $tmpFile
|
2006-09-19 14:13:37 +02:00
|
|
|
bzip2 $tmpFile
|
2005-08-16 22:59:39 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
runLaTeX() {
|
2006-03-23 15:34:17 +01:00
|
|
|
if ! $latex $latexFlags $rootName >$tmpFile 2>&1; then showError; fi
|
|
|
|
runNeeded=
|
|
|
|
if grep -q "LaTeX Warning: Label(s) may have changed." "$tmpFile"; then
|
|
|
|
runNeeded=1
|
|
|
|
fi
|
2005-08-16 22:59:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo
|
2005-06-20 15:51:48 +02:00
|
|
|
|
2006-03-23 15:34:17 +01:00
|
|
|
|
2005-08-16 22:59:39 +02:00
|
|
|
echo "PASS 1..."
|
|
|
|
runLaTeX
|
|
|
|
echo
|
2005-06-20 15:51:48 +02:00
|
|
|
|
2006-03-23 15:34:17 +01:00
|
|
|
|
2005-06-20 17:20:37 +02:00
|
|
|
if grep -q '\\citation' $rootNameBase.aux; then
|
2005-08-16 22:59:39 +02:00
|
|
|
echo "RUNNING BIBTEX..."
|
|
|
|
bibtex --terse $rootNameBase
|
2005-10-02 17:49:09 +02:00
|
|
|
cp $rootNameBase.bbl $out
|
2006-03-23 15:34:17 +01:00
|
|
|
runNeeded=1
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if test "$runNeeded"; then
|
|
|
|
echo "PASS 2..."
|
|
|
|
runLaTeX
|
2005-08-16 22:59:39 +02:00
|
|
|
echo
|
2005-06-20 17:20:37 +02:00
|
|
|
fi
|
2005-06-20 15:51:48 +02:00
|
|
|
|
|
|
|
|
2005-08-16 22:59:39 +02:00
|
|
|
if test -f $rootNameBase.idx; then
|
|
|
|
echo "MAKING INDEX..."
|
2005-11-28 15:19:46 +01:00
|
|
|
if test -n "$compressBlanksInIndex"; then
|
|
|
|
makeindexFlags="$makeindexFlags -c"
|
|
|
|
fi
|
|
|
|
makeindex $makeindexFlags $rootNameBase.idx
|
2006-03-23 15:34:17 +01:00
|
|
|
runNeeded=1
|
2005-08-16 22:59:39 +02:00
|
|
|
echo
|
|
|
|
fi
|
2005-06-20 15:51:48 +02:00
|
|
|
|
2006-03-23 15:34:17 +01:00
|
|
|
|
|
|
|
if test "$runNeeded"; then
|
|
|
|
echo "PASS 3..."
|
|
|
|
runLaTeX
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if test "$runNeeded"; then
|
|
|
|
echo "Hm, still not done :-("
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2005-06-20 15:51:48 +02:00
|
|
|
if test -n "$generatePDF"; then
|
|
|
|
cp $rootNameBase.pdf $out
|
|
|
|
else
|
|
|
|
cp $rootNameBase.dvi $out
|
2007-03-12 18:55:08 +01:00
|
|
|
if test -n "$generatePS"; then
|
|
|
|
echo "CONVERTING TO POSTSCRIPT..."
|
|
|
|
dvips $rootNameBase.dvi -o $out/$rootNameBase.ps
|
|
|
|
echo
|
|
|
|
fi
|
2005-06-20 17:06:58 +02:00
|
|
|
fi
|
2005-08-16 22:59:39 +02:00
|
|
|
|
2006-03-23 15:34:17 +01:00
|
|
|
|
2005-08-16 22:59:39 +02:00
|
|
|
echo "OVERFULL/UNDERFULL:"
|
|
|
|
cat $tmpFile | egrep "Overfull|Underfull" || true
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "UNDEFINED REFERENCES:"
|
|
|
|
cat $tmpFile | grep "Reference.*undefined" || true
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "UNDEFINED CITATIONS:"
|
|
|
|
cat $tmpFile | grep "Citation.*undefined" || true
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "STATS:"
|
|
|
|
printf "%5d overfull/underfull h/vboxes\n" $(cat $tmpFile | egrep -c "Overfull|Underfull" || true)
|
|
|
|
printf "%5d undefined references\n" $(cat $tmpFile | grep -c "Reference.*undefined" || true)
|
|
|
|
printf "%5d undefined citations\n" $(cat $tmpFile | grep -c "Citation.*undefined" || true)
|
2005-08-16 23:53:46 +02:00
|
|
|
printf "%5d pages\n" \
|
|
|
|
$(cat $tmpFile | grep "Output written.*(.*pages" | sed "s/.*(\([0-9]*\) pages.*/\1/" || true)
|
2005-08-16 22:59:39 +02:00
|
|
|
echo
|
2006-09-19 14:13:37 +02:00
|
|
|
|
|
|
|
bzip2 $tmpFile
|