2005-12-05 14:11:09 +00:00
|
|
|
source $stdenv/setup
|
2005-06-20 14:51:48 +01:00
|
|
|
|
|
|
|
ensureDir $out
|
|
|
|
|
2005-08-30 14:10:30 +01:00
|
|
|
startDir=$(perl $copyIncludes $includes)
|
|
|
|
cd $startDir
|
2005-06-20 16:06:58 +01:00
|
|
|
|
2005-06-20 23:43:35 +01: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 14:51:48 +01: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 21:59:39 +01: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 13:13:37 +01:00
|
|
|
bzip2 $tmpFile
|
2005-08-16 21:59:39 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
runLaTeX() {
|
2006-03-23 14:34:17 +00:00
|
|
|
if ! $latex $latexFlags $rootName >$tmpFile 2>&1; then showError; fi
|
|
|
|
runNeeded=
|
2008-03-05 14:37:41 +00:00
|
|
|
if fgrep -q \
|
|
|
|
-e "LaTeX Warning: Label(s) may have changed." \
|
|
|
|
-e "Rerun to get citations correct." \
|
|
|
|
"$tmpFile"; then
|
2006-03-23 14:34:17 +00:00
|
|
|
runNeeded=1
|
|
|
|
fi
|
2005-08-16 21:59:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo
|
2005-06-20 14:51:48 +01:00
|
|
|
|
2006-03-23 14:34:17 +00:00
|
|
|
|
2005-08-16 21:59:39 +01:00
|
|
|
echo "PASS 1..."
|
|
|
|
runLaTeX
|
|
|
|
echo
|
2005-06-20 14:51:48 +01:00
|
|
|
|
2006-03-23 14:34:17 +00:00
|
|
|
|
2005-06-20 16:20:37 +01:00
|
|
|
if grep -q '\\citation' $rootNameBase.aux; then
|
2005-08-16 21:59:39 +01:00
|
|
|
echo "RUNNING BIBTEX..."
|
|
|
|
bibtex --terse $rootNameBase
|
2005-10-02 16:49:09 +01:00
|
|
|
cp $rootNameBase.bbl $out
|
2006-03-23 14:34:17 +00:00
|
|
|
runNeeded=1
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if test "$runNeeded"; then
|
|
|
|
echo "PASS 2..."
|
|
|
|
runLaTeX
|
2005-08-16 21:59:39 +01:00
|
|
|
echo
|
2005-06-20 16:20:37 +01:00
|
|
|
fi
|
2005-06-20 14:51:48 +01:00
|
|
|
|
|
|
|
|
2005-08-16 21:59:39 +01:00
|
|
|
if test -f $rootNameBase.idx; then
|
|
|
|
echo "MAKING INDEX..."
|
2005-11-28 14:19:46 +00:00
|
|
|
if test -n "$compressBlanksInIndex"; then
|
|
|
|
makeindexFlags="$makeindexFlags -c"
|
|
|
|
fi
|
|
|
|
makeindex $makeindexFlags $rootNameBase.idx
|
2006-03-23 14:34:17 +00:00
|
|
|
runNeeded=1
|
2005-08-16 21:59:39 +01:00
|
|
|
echo
|
|
|
|
fi
|
2005-06-20 14:51:48 +01:00
|
|
|
|
2006-03-23 14:34:17 +00: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 14:51:48 +01:00
|
|
|
if test -n "$generatePDF"; then
|
|
|
|
cp $rootNameBase.pdf $out
|
|
|
|
else
|
|
|
|
cp $rootNameBase.dvi $out
|
2007-03-12 17:55:08 +00:00
|
|
|
if test -n "$generatePS"; then
|
|
|
|
echo "CONVERTING TO POSTSCRIPT..."
|
|
|
|
dvips $rootNameBase.dvi -o $out/$rootNameBase.ps
|
|
|
|
echo
|
|
|
|
fi
|
2005-06-20 16:06:58 +01:00
|
|
|
fi
|
2005-08-16 21:59:39 +01:00
|
|
|
|
2006-03-23 14:34:17 +00:00
|
|
|
|
2005-08-16 21:59:39 +01: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 22:53:46 +01:00
|
|
|
printf "%5d pages\n" \
|
|
|
|
$(cat $tmpFile | grep "Output written.*(.*pages" | sed "s/.*(\([0-9]*\) pages.*/\1/" || true)
|
2005-08-16 21:59:39 +01:00
|
|
|
echo
|
2006-09-19 13:13:37 +01:00
|
|
|
|
|
|
|
bzip2 $tmpFile
|