#!/bin/sh

# Daniel Diaz 
# LaTeX fix-point
#
# usage check_fp prefix verbose
# prefix: LaTeX prefix file name
# verbose: 0 no, 1 yes

verbose_msg ()

{
 if [ $verbose = 1 ]
 then
	echo $*
 fi
}



differ ()

{
 if diff $1 $2  >/dev/null 2>&1
 then
	false
 else
	true
 fi
}


copy ()

{
 f=$1.$2
 fp=$f.fp
 dvi=$1.dvi

 if [ ! -f $f ] 
 then
	verbose_msg "$f does not exist - redo LaTeX (rm $dvi)"
        rm -f $dvi
	return
 fi
 if [ ! -f $fp ] || `differ $f $fp`
 then
	verbose_msg "$f and $fp differ - redo LaTeX (rm $dvi)"
	cp $f $fp
        rm -f $dvi
 else
	verbose_msg $f and $fp are identical
 fi
}

verbose=$2

copy $1 aux
copy $1 toc
copy $1 idx
exit 0

