#!/bin/sh

# generated by xteminstall

# If you need to change this file (e.g. adding environment settings etc.),
# you can prevent xteminstall from overwriting this file
# at further calls of xteminstall: 
# just create a file "xtemInstalled" in this directory, eg with Unix command:
#
#      touch xtemInstalled

#####  command to call wish (must include Tcl and Tk)
wishcall="/usr/bin/wish"

#####  command to call tcl (pure Tcl, without Tk)
tclcall="/usr/bin/tclsh"

#####  path in which xtem is installed:
#####  can be set by the environment variable XTEMPATH; 
#####  if XTEMPATH doesn't exist, it will be set to the following default value:
: ${XTEMPATH=${XTEMPATH-/misc/local/xtem/xtem}}
#####  (i.e. files      /misc/local/xtem/xtem/*.tcl     will be found)

#####  one of the following language defining lines must be made active! 
#defaultlanguage="german"
#defaultlanguage="english"
defaultlanguage="german"

if [ ! -d "$XTEMPATH" ]
then
  echo "error at xtem call: directory  XTEMPATH=$XTEMPATH   doesn't exist"
  echo "probably your installation is incomplete, see: xtem Installation Guide)"
  exit
fi

if [ -z "$HOME" ]
then
  echo "error at xtem call: environment variable HOME  doesn't exist"
  echo "(xtem needs this variable pointing to your home directory!)"
  exit
fi

if [ -n "$XTEMDEFLANG" ]
then
  defaultlanguage=`echo $XTEMDEFLANG | tr '[:upper:]' '[:lower:]'`
elif [ "$defaultlanguage" = "" ]
then
  defaultlanguage="english"
  echo "installation incomplete: default language is not specified;  set to $defaultlanguage"
  echo "please modify file (shell script) \"$0\""
fi

if  [ ! -n "$XTEMDEFLANG" ]
then
  if [ -f $HOME/.xtem_deflang=deutsch ]
  then  mv $HOME/.xtem_deflang=deutsch  $HOME/.xtem_deflang=german
  fi
  if [ -f $HOME/.xtem_deflang=german -a -f $HOME/.xtem_deflang=english ]
  then
    rm $HOME/.xtem_deflang=german $HOME/.xtem_deflang=english
  fi
  if [ ! -f $HOME/.xtem_deflang=german -a ! -f $HOME/.xtem_deflang=english ]
  then
    $wishcall -f $XTEMPATH/setdeflang.tcl -n "xtem Language Selection" $defaultlanguage
  fi
  if [ -f $HOME/.xtem_deflang=german ];  then  defaultlanguage="german";   fi
  if [ -f $HOME/.xtem_deflang=english ]; then  defaultlanguage="english";  fi
fi

language=$defaultlanguage

if [ "$1 " = "-l " ] ;# Blanks inserted for Linux
then language="$2"; shift
  if [ "$1" = "" ]
  then
    echo "syntax:  `basename $0` [ -l language ] [ filename[.tex] ]"
  else
    shift
  fi
fi

if [ "$language" = "deutsch" ]; then language="german"; fi
if [ \
        "$language" != "german" \
     -a "$language" != "english" \
   ]
then
  echo "Warning: language \"$language\" not implemented; we use \"$defaultlanguage\" instead"
  echo "         supported languages are:   german | deutsch, english"
  language=$defaultlanguage
fi

exec $wishcall -f $XTEMPATH/xtem.tcl -n xtem $wishcall $tclcall $XTEMPATH $language $*
####

