:  
#@(#) mschak v1.2   SCHAKAL 99 Install
#
# Date:   30.09.1997 
#
# Author: Werner Dueck (for SCHAKAL 97)
#
# 03.01.2000:
# slightly modified for SCHAKAL 99 by E. Keller
#         
#


clear

echo
echo
echo "Installation of SCHAKAL 99 / X"
echo
echo

if test ! -f mschak
   then
      echo
      echo
      echo "To run <mschak>, you must change to the SCHAKAL 99 main directory"
      echo
      echo
      exit
else
   chmod +x `pwd`/uschak
fi

echo
echo
echo
###################DETERMINE STARTER#######################################
echo
echo "This installation routine tries to install a pure"
echo "X-Windows version  of  SCHAKAL 99 "
echo

Starter=X11 

###################DOWNSIZING FILENAMES####################################
echo "Scanning filenames ..."
echo

for ActFile in `ls`
   do
      RenActFile=`echo $ActFile | tr "[A-Z]" "[a-z]"`
      if test ! "$RenActFile" = "$ActFile"
         then
            echo renaming \"$ActFile\" as \"$RenActFile\" ...
            mv $ActFile $RenActFile
      fi
done
echo
echo
###################RENAMING SPECIALS#######################################
if test -f varyz.scf
   then
      echo Rename varyz.scf to varyZ.scf ...
      mv varyz.scf varyZ.scf
fi
if test -f cupbs.scf
   then
      echo Rename cupbs.scf to cupBS.scf ...
      mv cupbs.scf cupBS.scf
fi
if test -f fileselect_gridboxp.h 
   then
      echo Rename fileselect_gridboxp.h to fileselect_gridboxP.h ...
      mv fileselect_gridboxp.h fileselect_gridboxP.h
fi
if test -f fileselect_selectp.h 
   then
      echo Rename fileselect_selectp.h to fileselect_selectP.h ...
      mv fileselect_selectp.h fileselect_selectP.h
fi
echo
echo
###################CREATE DAT AND COPY FILES###############################
if test ! -d ./dat
   then
      echo Make directory ./dat ...
      mkdir ./dat
      echo
fi
for ActFile in *.dat
   do
      if test -f $ActFile
         then
            echo Copy $ActFile to ./dat/$ActFile ...
            cp $ActFile ./dat/.
            rm $ActFile 
      fi
done
      cp ex2a.ics ./dat/.
      rm ex2a.ics
echo
###################CREATE SCF AND COPY FILES###############################
if test ! -d ./scf
   then
      echo Make directory ./scf ...
      mkdir ./scf
      echo
fi
for ActFile in *.scf
   do
      if test -f $ActFile
         then
            echo Copy $ActFile to ./scf/$ActFile ...
            cp $ActFile ./scf/.
            rm $ActFile 
      fi
done
echo
for ActFile in *.txt
   do
      if test -f $ActFile
         then
            echo Copy $ActFile to ./scf/$ActFile ...
            cp $ActFile ./scf/.
            rm $ActFile
      fi
done
echo
###################CREATE SPF##############################################
if test ! -d ./spf
   then
      echo Make directory ./spf ...
      mkdir ./spf
      echo
fi
echo
###################CREATE SIF##############################################
if test ! -d ./sif
   then
      echo Make directory ./sif ...
      mkdir ./sif
      echo
fi
###################CREATE STARTSCRIPT AND MAKEFILE#########################
echo "Create startscript and makefile ..."
cp sch99.ini SCH99.INI
echo  "sch99x \\\\"\\n"   -s:"`pwd`"/ \\\\\\n   -u:"`pwd`"/ \\\\\\n   \$1" >s.sh
        
Starter="X Window Version"
cp makefile.x makefile

ln `pwd`/s.sh `pwd`/s 2>/dev/null
echo `pwd`/ >x;sed 's/\//\\\//g' x >y;xx=`cat y`
sed 's/\.\//'$xx'/g' sch99.ini >x;mv x sch99.ini
rm y
echo 
echo
echo "Now generating SCHAKAL 99 "$Starter", please wait ..."
echo

make

echo
echo
echo
chmod +x `pwd`/*.sh
echo "SCHAKAL 99 installation completed"
echo
echo
