#! /bin/sh 
#
# This file is part of the validate package.
# ------------------------------------------
#
# Makes a .tlg file from a test file with the extension .lvt
# Run's tex two times to get aux files etc.
#
# usage: maketlg <format name> <test file base>
# or
# usage: maketlg <test file base>
#
# In the later case a format called latfs will be used. 
# This is LaTeX with nfss running on my machine. If you don't this
# use the first form.




# check number of args and set format etc.
#
if [ $# = 1 ]
then
LATEX=latfs
BASE=`basename $1 .lvt`
else
LATEX="virtex &$1"
BASE=`basename $2 .lvt`
fi


# remove all kind of rubbish
#
rm -f $BASE.log $BASE.au?  $BASE.tmp.tlg $BASE.tlg.diff $BASE.dvi
rm -f $BASE.glo $BASE.idx  $BASE.lof $BASE.toc $BASE.lot


# run TeX twice with chosen format
#
$LATEX $BASE.lvt
$LATEX $BASE.lvt

# remove stuff from the log which is of no interest and save the result
# in tmp file
#
sed -e "1,/START-TEST-LOG/d" \
    -e "/END-TEST-LOG/,//d"  \
    -e "/OMIT/,/TIMO/d"      \
    -e "s/$BASE//"           \
                              $BASE.log > $BASE.tlg


echo TLG file produced for $BASE

#
