#!/bin/sh
#
# USAGE: www-install [latex-file] [directory]
#
# Runs latex four times on the file (this should suffice 8-)).
# Produces a gzipped postscript file.
# Removes the .aux-file (needed for hyperref to work)
# Runs pdflatex four times to produce a pdf file.
## Runs latex2html to produce an HTML approximation.
# Moves the gzipped postscript file, pdf file and the HTML stuff
# into the directory you specified.
# Checks the files into CVS.
#
if ( test $# -ne 2 ) then
    echo Usage: $0 [latex-file] [directory]
else
  file=`basename $1 .tex`
  latex $file ; latex $file ; latex $file ; latex $file
  dvips $file -o
  gzip $file.ps
  rm $file.aux
  pdflatex $file ; pdflatex $file ; pdflatex $file ; pdflatex $file
#  latex2html -dir .l2h-tmp -mkdir -auto_prefix -html_version 4.0,math -split 0 -nonavigation -noinfo -address='Maintainer: <a href="mailto:6042-webmaster@theory.lcs.mit.edu">6042-webmaster@theory.lcs.mit.edu</a>' -up_url='http://theory.lcs.mit.edu/classes/6.042/spring01/handouts/' -up_title='6.042 Spring 2001 -- Handouts' $file.tex
#  mkdir $file
#  cp .l2h-tmp/*.png $file
#  fgrep -v '.css' .l2h-tmp/$file.html > $file/$file.html
#  rm -rf .l2h-tmp
#  chmod 664 $file.ps.gz $file.pdf $file/*
#  tar cf - $file.ps.gz $file.pdf $file | (cd $2 ; tar xf -)
#  rm -rf $file.ps.gz $file.pdf $file
#  (cd $2 ; cvs add $file.ps.gz $file.pdf $file $file/* || /bin/true ; cvs commit $file.ps.gz $file.pdf $file)
  chmod 664 $file.ps.gz $file.pdf
  tar cf - $file.ps.gz $file.pdf | (cd $2 ; tar xf -)
  rm -rf $file.ps.gz $file.pdf
  (cd $2 ; cvs add $file.ps.gz $file.pdf || /bin/true ; cvs commit $file.ps.gz $file.pdf)
fi
