2005-12-05 15:11:09 +01:00
|
|
|
source $stdenv/setup
|
2005-06-20 15:51:48 +02:00
|
|
|
|
|
|
|
ensureDir $out
|
|
|
|
|
2008-05-16 13:48:46 +02:00
|
|
|
mkdir root
|
|
|
|
cd root
|
|
|
|
|
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=
|
2008-03-05 15:37:41 +01:00
|
|
|
if fgrep -q \
|
|
|
|
-e "LaTeX Warning: Label(s) may have changed." \
|
|
|
|
-e "Rerun to get citations correct." \
|
|
|
|
"$tmpFile"; then
|
2006-03-23 15:34:17 +01:00
|
|
|
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
|
|
|
|
2008-05-16 13:48:46 +02:00
|
|
|
if test -n "$copySources"; then
|
|
|
|
cp -prd $TMPDIR/root $out/tex-srcs
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-01-08 10:54:04 +01:00
|
|
|
# Run bibtex to process all bibliographies. There may be several when
|
|
|
|
# we're using the multibib package.
|
|
|
|
for auxFile in $(find . -name "*.aux"); do
|
|
|
|
if grep -q '\\citation' $auxFile; then
|
|
|
|
echo "RUNNING BIBTEX ON $auxFile..."
|
|
|
|
auxBase=$(basename $auxFile .aux)
|
|
|
|
bibtex --terse $auxBase
|
|
|
|
cp $auxBase.bbl $out
|
|
|
|
runNeeded=1
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
done
|
2006-03-23 15:34:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2008-04-02 17:10:49 +02:00
|
|
|
if test "$runNeeded"; then
|
|
|
|
echo "PASS 4..."
|
|
|
|
runLaTeX
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2006-03-23 15:34:17 +01:00
|
|
|
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
|