2005-12-05 14:11:09 +00:00
|
|
|
source $stdenv/setup
|
2005-06-20 14:51:48 +01:00
|
|
|
|
|
|
|
ensureDir $out
|
|
|
|
|
2010-03-15 10:02:24 +00:00
|
|
|
export TEXMFCNF=$TMPDIR:
|
|
|
|
echo 'max_print_line = 8192' >> $TMPDIR/texmf.cnf
|
|
|
|
|
2008-05-16 12:48:46 +01:00
|
|
|
mkdir root
|
|
|
|
cd root
|
|
|
|
|
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
|
|
|
|
2008-05-16 12:48:46 +01:00
|
|
|
if test -n "$copySources"; then
|
|
|
|
cp -prd $TMPDIR/root $out/tex-srcs
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-01-08 09:54:04 +00: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 14:34:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2008-04-02 16:10:49 +01:00
|
|
|
if test "$runNeeded"; then
|
|
|
|
echo "PASS 4..."
|
|
|
|
runLaTeX
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2006-03-23 14:34:17 +00:00
|
|
|
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
|
|
|
|
2010-03-15 10:02:24 +00:00
|
|
|
echo "WARNINGS:"
|
|
|
|
cat $tmpFile | grep "Warning:" | grep -v "Citation.*undefined" || true
|
|
|
|
|
|
|
|
echo
|
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
|