#!/bin/sh

# This script installs new scripts: csplain, cslatex, pdfcsplain and
# pdfcslatex into bin directory (these new scripts use TCX tables).
# Next, install-cstex generates CSTeX formats in texmf/web2c.
# For more details, see README.tetex-1.0 in CSTeX distribution.

# (C) 1999, Petr Olsak

# $binpath ... where to install csplain, cslatex, pdfcsplain, pdfcslatex:
binpath=`which tex`
binpath=`dirname $binpath`

# $fmtpath ... where to install csplain.fmt and others:
fmtpath=`kpsewhich texmf.cnf`
fmtpath=`dirname $fmtpath`

# installing csplain, cslatex, pdfcsplain a pdfcslatex:
echo installing scripts:
for fmtname in csplain cslatex pdfcsplain pdfcslatex; do
  echo $binpath/$fmtname
  rm -f $binpath/$fmtname
  echo '#!/bin/sh' > $binpath/$fmtname 
  if [ ! -f $binpath/csplain ]; then
     echo You have no write permissions to $binpath
     exit
  fi
  if [ "$fmtname" = "pdfcsplain" -o "$fmtname" = "pdfcslatex" ]; then
    pre=pdf
  fi
  echo "exec ${pre}tex -fmt=$fmtname -translate-file=il2-cs" '${1+"$@"}' >> $binpath/$fmtname
  chmod a+x $binpath/$fmtname
done

# generovani formatu:
mktexlsr
cd $fmtpath
tex    -ini -progname=csplain    -fmt=csplain    csplain.ini
if [ ! -f csplain.fmt ]; then
   echo Inpossible to make csplain format, something wrong
   echo Have you csplain.tar, csfonts.tar and cslatex.tar installed in your texmf?
   exit
fi
tex    -ini -progname=cslatex    -fmt=cslatex    cslatex.ini
pdftex -ini -progname=pdfcsplain -fmt=pdfcsplain csplain.ini
pdftex -ini -progname=pdfcslatex -fmt=pdfcslatex cslatex.ini

mktexlsr
