# The SHELL is choosen by install.sh

# $Id: main_astk.sh,v 1.7 2003/11/05 08:33:45 mcourtoi Exp $
# $Name: v7_3-8 $

######################################################################
#
# Installation script for ASTK
#
######################################################################

umask 022

######################################################################
#
# load functions from utils
. `dirname $0`/utils.sh

######################################################################
#
CLEAR
echo " ASTK $vastk INSTALLATION SETUP"
echo " "
echo " Installation will check :"
echo "          - TclTk $tcl_v"
echo "          - Tktable"
echo "          - gzip"
echo " "
echo " If you have not exactly these versions, see README file"
echo " to known how change variables."
echo " "
compdir `dirname $0`/..
dirhome=$fulldir
if [ $dirhome = "." ]; then
   dirhome=`pwd`
fi
def_instdir=$HOME

######################################################################
#
#  system identification
#  modify system commands if necessary
#
OS_TYPE=`uname -s`
if [ $OS_TYPE = "SunOS" ]; then
 	OS_LEVEL=`uname -r`
   OS_NIV=`echo $OS_LEVEL | $awk -F'.' '{print $2}'`
   echo " System identification: SUN SunOS   $OS_LEVEL"
elif [ $OS_TYPE = "OSF1" ]; then
 	OS_LEVEL=`uname -r`
   echo " System identification: COMPAQ Tru64 $OS_LEVEL"
elif [ $OS_TYPE = "IRIX64" ]; then
 	OS_LEVEL=`uname -r`
   echo " System identification: SGI Irix $OS_LEVEL"
elif [ $OS_TYPE = "Linux" ]; then
   OS_LEVEL=`uname -r`
   echo " System identification: Linux $OS_LEVEL"
   nmD="$nm -D"
else
	echo " Operating system $OS_TYPE unknown on this distribution"
	echo " You will try with Linux options..."
   OS_TYPE="Linux"
   OS_LEVEL="2.0.0"
   nmD="$nm -D"
fi

echo " Installation for : $OS_TYPE - Release $OS_LEVEL"
echo " "
confirm "Accept" "bidon" "y"
iret=$?
if [ $iret -ne 0 ]; then
	echo "Installation aborted !"
	exit 8
fi
echo " "


######################################################################
#
# required Tcl/Tk installation
#
CLEAR
echo "Check for Tcl/Tk installation (binaries)"
echo " "
defdir="/usr/bin"
quoi="tclsh$tcl_v"
short="tclsh"
# for ASTK
wish_bin="wish$tcl_v"

# bin
echo " Search for $quoi, if not found, choose another path or cancel to search for $short (without release number)."
iret=1
while [ $iret -ne 0 ];
do
   a_supp="/bin/$quoi"
   search_bin "$quoi" "$defdir" "$a_supp" "n"
   iret=$?
   tcl_dir=$result
   if [ $iret -eq 0 ]; then
      confirm "Accept" "$result" "y"
      iret=$?
   else
      quoi="$short"
      wish_bin="wish"
   fi
   defdir=""
done
tcl_bin="$quoi"

# Tktable for ASTK
is_tktable=-1
# Tktable
search_find "tkTable.tcl" "$tcl_dir/lib" "tkTable.tcl" "n"
iret=$?
tktable_dir="$result"
is_tktable=$iret
if [ $iret -ne 0 ]; then
   echo " ASTK needs Tktable extension."
   confirm "Continue Code_Aster installation" "bidon" "y"
   iret=$?
   if [ $iret -ne 0 ]; then
      echo " Installation aborted"
      exit 8
   fi
   echo " "
fi

######################################################################
#
# gzip directory
#
CLEAR
echo "Check for GZIP installation (binary)"
echo " "
defdir="/usr/bin"
quoi="gzip"
a_supp="/$quoi"
search_bin $quoi $defdir $a_supp "y"
gzip=$result

######################################################################
#
# ASTK installation
#
inst_dir=$def_instdir
astk_inst=-1
. `dirname $0`/inst_astk.sh

exit 0
