#!/bin/csh
#
# author : A. Hebert
# use    : install
#
chmod 755 .
if (-e /usr/local/common/TeX.csh) then
  source /usr/local/common/TeX.csh
endif
#
ln -s ../../Dragon/data/tmacro_proc/TCM01.c2m TCM01.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM02.c2m TCM02.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM03.c2m TCM03.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM04.c2m TCM04.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM05.c2m TCM05.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM06.c2m TCM06.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM07.c2m TCM07.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM08.c2m TCM08.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM09.c2m TCM09.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM10.c2m TCM10.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM11.c2m TCM11.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM12.c2m TCM12.x2m
ln -s ../../Dragon/data/tmacro_proc/TCM13.c2m TCM13.x2m
#
ln -s ../../Dragon/data/twlup_proc/TCWU01.c2m TCWU01.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU02.c2m TCWU02.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU03.c2m TCWU03.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU04.c2m TCWU04.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU05.c2m TCWU05.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU06.c2m TCWU06.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU07.c2m TCWU07.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU08.c2m TCWU08.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU09.c2m TCWU09.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU10.c2m TCWU10.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU11.c2m TCWU11.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU12.c2m TCWU12.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU13.c2m TCWU13.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU14.c2m TCWU14.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU15.c2m TCWU15.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU17.c2m TCWU17.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU31.c2m TCWU31.x2m
ln -s ../../Dragon/data/twlup_proc/TCWU05Lib.c2m .
ln -s ../../Dragon/data/twlup_proc/TCWU17Lib.c2m .
#
ln -s ../../Dragon/data/tmatxs7a_proc/TCXA01.c2m TCXA01.x2m
#
ln -s ../../Dragon/data/assertS.c2m .
ln -s ../../Dragon/data/assertV.c2m .
#
ln -s ../../readme readme
#
chmod 644 TCM* TCWU* TCXA* assert*.c2m
if (-e $1.tex) then
  set nom_fich = $1
else
  set nom_fich = `basename $PWD`
endif
echo "begin typesetting file" $nom_fich.tex
latex $nom_fich.tex > /dev/null
echo "first typesetting completed"
if ( -f $nom_fich.idx ) then
  set header = $nom_fich
  set core = ` echo $nom_fich | sed -e's/header_//' `
  cp $header.idx header_tmp.idx
  makeindex header_tmp.idx
  if ( -f header_tmp.tex ) /bin/rm header_tmp.tex
  if ( -f tmp.tex ) /bin/rm tmp.tex
  cp $header.tex header_tmp.tex
  cp $core.tex tmp.tex
  latex header_tmp.tex > /dev/null
  latex header_tmp.tex > /dev/null
  latex header_tmp.tex > /dev/null
  dvips -f header_tmp.dvi -o header_tmp.ps
  mv header_tmp.ps $nom_fich.ps
else
  dvips -f $nom_fich.dvi -o $nom_fich.ps
endif
/bin/rm header_tmp.* tmp.tex
/bin/rm *.aux
echo "create pdf file" $nom_fich.pdf
ps2pdf $nom_fich.ps
echo "pdf file produced"
gv -antialias $nom_fich.pdf
/bin/rm $nom_fich.dvi $nom_fich.ps $nom_fich.idx $nom_fich.lof $nom_fich.log
/bin/rm $nom_fich.toc $nom_fich.lot $nom_fich.out
/bin/rm TCM* TCWU* TCX* assert* readme
exit
