#!/bin/sh
# 
# install.sh 
# Install AXENE software 1.4.6
# 
# Copyright (c)1995-98 AXENE. All Rights reserved.
# EMail: <axene@axene.com>
# Web  : http://www.axene.com/
# 
# Please report ANY installation trouble to support@axene.com
# 
# Started on  Fri Nov 17 17:34:10 1995 Nucleus
# Last update Sun Mar  8 18:55:09 1998 DeweY
#

ECHONL1="echo "
ECHONL2=

test_echo=`echo -n test`
if [ $test_echo = "-n test" ]; then
 test_echo=`echo "test\c"`
 if [ $test_echo = "test\c" ]; then
  test_echo=`echo -e "test\c"`
  if [ $test_echo = "test" ]; then
   ECHONL1="echo -e "
   ECHONL2="\c"
  fi
 else
  ECHONL1="echo "
  ECHONL2="\c"
 fi
else
  ECHONL1="echo -n "
fi

#--- Init global variables
SkipLine() { echo " "; }
Fatal() { echo "${progname}: error: ${1}" 1>&2 ; exit 1; }
#Debug() { echo "${progname}: debug: ${1}" 1>&2 ; }
Debug() { :; }

progname=`basename $0`
cmd_gunzip=
cmd_tar=
src_dir=`pwd`
archive_list=

is_common="no"
is_exec="no"
is_xcl="no"
is_xquad="no"
is_xallwrite="no"
is_xmayday="no"
is_axeneoffice="no"

# ----------------------------------------------------------------- # 
# CheckDir - Check existence and authorizations on directory        #
#            <path>                                                 # 
# ----------------------------------------------------------------- #
CheckDir()
{
  if [ ! -d $1 ]; then
    echo "  creating dir $1"
    mkdir $1 || exit 1
    chmod 755 $1 || exit 1
  else
    Debug "  $1 already exists"
    if [ ! -w $1 -o ! -x $1 -o ! -r $1 ]; then
      Fatal "$1 not readable, not writable or not executable."
    fi
  fi
}

# ---------------------------------------------------------------------- # 
# AskOneFromList - Let the user choose an item among a list              # 
#                  <text> <default-index> <var > <choice-1>...<choice-n> #
# ---------------------------------------------------------------------- #
AskOneFromList()
{
 _ask_text=$1
 _ask_default=$2
 _ask_var=$3
 shift 3
 _arg_all=$@
 _arg_num=$#

 if [ "$force_flag" = "yes" ]; then
  return $_ask_default
 else
  echo $_ask_text
  _ask_count=0
  while [ $_ask_count -lt $_arg_num ]; do
   if [ $_ask_count -eq $_ask_default ]; then
    _ask_reply="(DEFAULT)"
   else
    _ask_reply=
   fi
   _ask_count=`expr $_ask_count + 1`
   eval "echo \"  \$_ask_count. \$1 $_ask_reply\""
   shift 1
  done
 fi

 while :; do
  $ECHONL1"Your choice: "$ECHONL2
  read _ask_reply
   
  if [ -z "$_ask_reply" ]; then
   _arg_cnt=0
   for _ask_phrase in $_arg_all; do
    if [ $_arg_cnt -eq $_ask_default ]; then
     eval "$_ask_var=\"\$_ask_phrase\""
     break
    fi
    _arg_cnt=`expr $_arg_cnt + 1`
   done        
   return $_ask_default
  fi
  if [ ! `expr "$_ask_reply" : "^[0-9][0-9]*$"` = "0" ]; then
   if [ $_ask_reply -gt 0 -a $_ask_reply -le $_arg_num ]; then
    SkipLine
    _arg_cnt=1
    for _ask_phrase in $_arg_all; do
     if [ $_arg_cnt -eq $_ask_reply ]; then
      eval "$_ask_var=\"\$_ask_phrase\""
      break
     fi
     _arg_cnt=`expr $_arg_cnt + 1`
    done
    return `expr $_ask_reply - 1`
   fi
  fi
  echo "ERROR: You must enter a number between 1 and $_arg_num"
 done
}    

# ------------------------------------------------------------------ # 
# AskManyFromList - Let the user choose items among a list           # 
#                   <text> <variable> <choice-1> ... <choice-n>      #
# ------------------------------------------------------------------ #
AskManyFromList()
{
  _ask_text=$1
  _ask_var=$2

  shift 2
  _arg_all=$@
  _arg_num=$#

  echo "$_ask_text (ex: 1 2)"
  _ask_count=0
  while [ $_ask_count -lt $_arg_num ]; do
    _ask_count=`expr $_ask_count + 1`
    eval "echo \"  \$_ask_count. \$1\""
    shift 1
  done

  $ECHONL1"Your choice: "$ECHONL2
  read _ask_reply
 
  eval $_ask_var=
  for _ask_nb in $_ask_reply; do
   if [ ! `expr "$_ask_nb" : "^[0-9][0-9]*$"` = "0" ]; then
    if [ $_ask_nb -ge 1 -a $_ask_nb -le $_arg_num ]; then
     _arg_cnt=1
     for _ask_phrase in $_arg_all; do
       if [ $_arg_cnt -eq $_ask_nb ]; then
         eval "$_ask_var=\"\$$_ask_var \$_ask_phrase\""
         break
       fi
       _arg_cnt=`expr $_arg_cnt + 1`
     done
    else
      eval $_ask_var= 
      echo "ERROR: Each number must be between 1 and $_arg_num"
      return 1
    fi
   else
    eval $_ask_var= 
    echo "ERROR: Each choice must be a number between 1 and $_arg_num"
    return 1
   fi
  done
  SkipLine
  return 0
}

# ------------------------------------------------------------------ # 
# AskYesNo - Let the user choose for y or n                          # 
#                   <text> <var>                                     #
# ------------------------------------------------------------------ #
AskYesNo()
{
  _message=$1
  _answer=$2

  $ECHONL1$_message" "$ECHONL2

  read _ask_proceed

  _answer=-1
  if [ "$_ask_proceed" = "n" -o "$_ask_proceed" = "no" ]; then
    _answer=0
  fi

  if [ "$_ask_proceed" = "y"  -o "$_ask_proceed" = "yes" ]; then
    _answer=1
  fi
  return 0
}
# ----------------------------------------------------------------- # 
# Main part                                                         # 
# ----------------------------------------------------------------- #

cat << __EOT__
==============================================================================
                         AXENE Installation Script
==============================================================================

  BY INSTALLING THIS SOFTWARE, YOU ARE CONSENTING TO BE BOUND BY THE LICENSE
  AGREEMENT (check out the LICENSE file).  IF YOU DO NOT AGREE TO ALL OF THE 
       TERMS OF THE LICENSE AGREEMENT, CANCEL THE INSTALLATION PROCESS.

==============================================================================

__EOT__

_answer=-1
while [ "$_answer" = "-1" ]; do
 AskYesNo "Proceed installation ? [y/n]:" _answer
 if [ $_answer = 0 ]; then
   echo "Installation aborted."
   exit 0
 fi
done
SkipLine

#Does not work with linux
#test -r *.tar.gz || Fatal "No package found in current dir"

_file=*.tar.gz
if [ "`echo $_file`" = "*.tar.gz" ]; then
 Fatal "No package found in current dir"
fi

AskManyFromList "Please select packages to be installed" archive_list *.tar.gz
test -z "$archive_list" && Fatal "No package selected"

#--- Get basedir ---
if [ -w /usr/local/Axene ]; then
 prefix=/usr/local/Axene
else
 if [ -w /usr/Axene ]; then
  prefix=/usr/Axene
 else
  prefix=`dirname ${AXENE_LIB:-/usr/local/Axene/install}`
  if [ ! -w `dirname $prefix` ]; then
   prefix="~/Axene"
  fi
 fi
fi

echo "Where do you want to install the software ?"
echo "(DEFAULT: $prefix)"
$ECHONL1"Your location: "$ECHONL2
read _ask
test -z "$_ask" || prefix=$_ask
prefix=`eval "echo $prefix"`
CheckDir $prefix

for _package in $archive_list; do
  _tmp_str=`echo $_package | grep "^common"`
  if [ -n "$_tmp_str" ]; then is_common="yes"; fi
  _tmp_str=`echo $_package | grep "^Xclamation"`
  if [ -n "$_tmp_str" ]; then is_xcl="yes"; is_exec="yes" ; fi
  _tmp_str=`echo $_package | grep "^XQuad"`
  if [ -n "$_tmp_str" ]; then is_xquad="yes"; is_exec="yes" ; fi
  _tmp_str=`echo $_package | grep "^XAllWrite"`
  if [ -n "$_tmp_str" ]; then is_xallwrite="yes"; is_exec="yes" ; fi
  _tmp_str=`echo $_package | grep "^XMayday"`
  if [ -n "$_tmp_str" ]; then is_xmayday="yes"; is_exec="yes" ; fi
  _tmp_str=`echo $_package | grep "^AxeneOffice"`
  if [ -n "$_tmp_str" ]; then is_axeneoffice="yes"; is_exec="yes" ; fi
done

if [ $is_common = "yes" -o $is_xmayday = "yes" ]; then
 if [ -f $prefix/lib/X11/nls/nls.dir -a ! -w $prefix/lib/X11/nls/nls.dir ]; \
 then
  rm -fr $prefix/lib/X11
 fi
fi

if [ $is_xcl = "yes" -a -w $prefix/lib/xclamationrc ]; then
 _answer=-1
 echo "A version of Xclamation is already installed."
 while [ "$_answer" = "-1" ]; do
  AskYesNo "\ Continue the installation of Xclamation's package(s) ? [y/n]:" \
           _answer
  if [ "$_answer" = "0" ]; then
   _new_archive=""
   for archive in $archive_list; do
    _tmp_str=`echo $archive | grep "^Xclamation"`
    if [ -z "$_tmp_str" ]; then
     _new_archive="$_new_archive $archive"
    fi
   done
   archive_list=$_new_archive
   is_xcl="no"
  fi
 done	
fi

if [ $is_xquad = "yes" -a -w $prefix/lib/xquadrc ]; then
 _answer=-1
 echo "A version of XQuad is already installed."
 while [ "$_answer" = "-1" ]; do
  AskYesNo "\ Continue the installation of XQuad's package(s) ? [y/n]:" _answer
  if [ "$_answer" = "0" ]; then
   _new_archive=""
   for archive in $archive_list; do
    _tmp_str=`echo $archive | grep "^XQuad"`
    if [ -z "$_tmp_str" ]; then
     _new_archive="$_new_archive $archive"
    fi
   done
   archive_list=$_new_archive
   is_xquad="no"
  fi
 done	
fi

if [ $is_xallwrite = "yes" -a -w $prefix/lib/xallwriterc ]; then
 _answer=-1
 echo "A version of XAllWrite is already installed."
 while [ "$_answer" = "-1" ]; do
  AskYesNo "\ Continue the installation of XAllWrite's package(s) ? [y/n]:" \
    _answer
  if [ "$_answer" = "0" ]; then
   _new_archive=""
   for archive in $archive_list; do
    _tmp_str=`echo $archive | grep "^XAllWrite"`
    if [ -z "$_tmp_str" ]; then
     _new_archive="$_new_archive $archive"
    fi
   done
   archive_list=$_new_archive
   is_xallwrite="no"
  fi
 done	
fi

if [ $is_xmayday = "yes" -a -w $prefix/lib/xmaydayrc ]; then
 _answer=-1
 echo "A version of XMayday is already installed."
 while [ "$_answer" = "-1" ]; do
  AskYesNo "\ Continue the installation of XMayday's package(s) ? [y/n]:" \
           _answer
  if [ "$_answer" = "0" ]; then
   _new_archive=""
   for archive in $archive_list; do
    _tmp_str=`echo $archive | grep "^XMayday"`
    if [ -z "$_tmp_str" ]; then
     _new_archive="$_new_archive $archive"
    fi
   done
   archive_list=$_new_archive
   is_xmayday="no"
  fi
 done	
fi

if [ $is_axeneoffice = "yes" -a -w $prefix/app-defaults/AxeneOffice ]; then
 _answer=-1
 echo "A version of AxeneOffice is already installed."
 while [ "$_answer" = "-1" ]; do
  AskYesNo "\ Continue the installation of AxeneOffice's package(s) ? [y/n]:" \
           _answer
  if [ "$_answer" = "0" ]; then
   _new_archive=""
   for archive in $archive_list; do
    _tmp_str=`echo $archive | grep "^AxeneOffice"`
    if [ -z "$_tmp_str" ]; then
     _new_archive="$_new_archive $archive"
    fi
   done
   archive_list=$_new_archive
   is_axeneoffice="no"
  fi
 done	
fi

if [ -z "$archive_list" ]; then
 SkipLine
 echo "No package to install. The installation is over."
 exit 0
fi

if [ "$is_xcl" = "no" -a "$is_xquad" = "no" -a "$is_xallwrite" = "no" -a \
"$is_xmayday" = "no" -a "$is_axeneoffice" = "no" ]; then
 is_exec="no"
fi

#--- Check the umask validity ---
_umask=`umask 2>/dev/null`
if [ "$?" = "0" ]; then 
 _o=`expr $_umask % 10`
 _g=`expr $_umask / 10 % 10`
 _u=`expr $_umask / 100 % 10`
 _ask4umask=0
 if [ ! "$_u" = "0" ]; then _ask4umask=1; else
  if [ ! "$_g" = "0" -a ! "$_g" = "2" ]; then _ask4umask=2; else
   if [ ! "$_o" = "0" -a ! "$_o" = "2" ]; then _ask4umask=3; fi
  fi
 fi
 if [ ! "$_ask4umask" = "0" ]; then
  SkipLine
  if [ $is_exec = "yes" ]; then
   _access="execute Axene's softwares."
  else
   _access="have access to software's data."
  fi
  case $_ask4umask in
   "1")
    echo "Your umask ($_umask) won't allow you to $_access";;
   "2")
    echo "Your umask ($_umask) won't let the users of your group $_access";;
   "3") 
    echo "Your umask ($_umask) won't let every users $_access";;
  esac
  _answer=-1
  while [ "$_answer" = "-1" ]; do
   AskYesNo "\ Change the rights for depacking ? [y/n]:" _answer
   if [ "$_answer" = "1" ]; then
    SkipLine
    echo "  1. Let every users $_access [Default]"
    echo "  2. Let only the users of your group $_access"
    echo "  3. Let only you execute $_access"
    echo "  4. Enter the umask for depacking. [for expert user]"
    echo "  5. Proceed with original umask ($_umask)."
    _answer=-1
    while [ "$_answer" = "-1" ]; do
     $ECHONL1"Your choice: "$ECHONL2
     read _ask
     if [ -z "$_ask" ]; then _ask="1"; fi
     case $_ask in
      "1")
       umask 022 2>/dev/null || Fatal "failed to change the umask."
       _answer=1;;
      "2")
       umask 027 2>/dev/null || Fatal "failed to change the umask."
       _answer=1;;
      "3")
       umask 077 2>/dev/null || Fatal "failed to change the umask."
       _answer=1;;
      "4")
       while [ "$_answer" = "-1" ]; do
        $ECHONL1" Enter the umask for depacking: "$ECHONL2
        read _ask
        if [ `expr "$_ask" : "^[0-7][0-7][0-7]$"` = "0" ]; then
         echo " Malformed umask."
        else
         umask $_ask 2>/dev/null || Fatal "failed to change the umask."
         _answer=1
        fi
       done;;
      "5")
       _answer=1;;
     esac
    done
   fi
  done
 fi
fi

#--- Get Gunzip and tar ---
Debug "Find Gunzip and tar"
old_ifs="$IFS"
IFS="$IFS:"
for mypath in $PATH; do
  if [ -n "$mypath" ]; then
    test -z "$cmd_gunzip" -a -x $mypath/gunzip && cmd_gunzip=$mypath/gunzip
    test -z "$cmd_tar" -a -x $mypath/gtar && cmd_tar=$mypath/gtar
    test -z "$cmd_tar" -a -x $mypath/tar && cmd_tar=$mypath/tar
  fi
done
IFS=$old_ifs

#--- Check Gunzip ---
if [ -z "$cmd_gunzip" ]; then
  echo "command \`gunzip' not found, please enter full path and name"
  echo "(RETURN: Abort installation)"
  cmd_gunzip="NoNe"
  while [ ! -x $cmd_gunzip -o -d $cmd_gunzip ]; do
   $ECHONL1"Your \`gunzip' location: "$ECHONL2
   read _ask
   test -n "$_ask" || Fatal "You can get gunzip for your machine at ftp.axene.com"
   cmd_gunzip="$_ask"
   if [ -d $cmd_gunzip ]; then
    echo "command '$cmd_gunzip' is a directory, try again (or RETURN to abort)"
    continue
   fi
   if [ ! -x $cmd_gunzip ]; then
    echo "command '$cmd_gunzip' not found, try again (or RETURN to abort)"
   fi
  done
else
  echo "Using $cmd_gunzip to decompress archives"
fi

#--- Check tar ---
if [ -z "$cmd_tar" ]; then
  echo "Command \`tar' not found, please enter location"
  echo "(RETURN: Abort installation)"
  cmd_tar="NoNe"
  while [ ! -x $cmd_tar -o -d $cmd_tar ]; do
   $ECHONL1"Your \`tar' location: "$ECHONL2
   read _ask
   test -n "$_ask" || Fatal "Installation aborted"
   cmd_tar="$_ask"
   if [ -d $cmd_tar ]; then
    echo "'$cmd_tar' is a directory, try again (or RETURN to abort)"
    continue
   fi
   if [ ! -x $cmd_tar ]; then
    echo "file '$cmd_tar' not found, try again (or RETURN to abort)"
   fi
  done
else
  echo "Using $cmd_tar to extract files from archives"
fi

#--- Depack archives ---
cd $prefix
for archive in $archive_list; do
  SkipLine
  echo "=============================================================="
  echo "Depacking archive $archive:"
  echo "=============================================================="
  _tmp_str=`echo $_package | grep "^Xclamation"`
  if [ -n "$_tmp_str" ]; then
   if [ -w $prefix/lib/xclamationrc ]; then
    rm -f $prefix/lib/xclamationrc
   fi
   if [ -w $prefix/app-defaults/Xclamation ]; then
    rm -f $prefix/app-defaults/Xclamation
   fi
  fi
  _tmp_str=`echo $_package | grep "^XQuad"`
  if [ -n "$_tmp_str" ]; then
   if [ -w $prefix/lib/xquadrc ]; then
    rm -f $prefix/lib/xquadrc
   fi
   if [ -w $prefix/app-defaults/XQuad ]; then
    rm -f $prefix/app-defaults/XQuad
   fi
  fi
  _tmp_str=`echo $_package | grep "^XAllWrite"`
  if [ -n "$_tmp_str" ]; then
   if [ -w $prefix/lib/xallwriterc ]; then
    rm -f $prefix/lib/xallwriterc
   fi
   if [ -w $prefix/app-defaults/XAllWrite ]; then
    rm -f $prefix/app-defaults/XAllWrite
   fi
  fi
  _tmp_str=`echo $_package | grep "^XMayday"`
  if [ -n "$_tmp_str" ]; then
   if [ -w $prefix/lib/xmaydayrc ]; then
    rm -f $prefix/lib/xmaydayrc
   fi
   if [ -w $prefix/app-defaults/XMayday ]; then
    rm -f $prefix/app-defaults/XMayday
   fi
  fi
  _tmp_str=`echo $_package | grep "^AxeneOffice"`
  if [ -n "$_tmp_str" ]; then
   if [ -w $prefix/app-defaults/AxeneOffice ]; then
    rm -f $prefix/app-defaults/AxeneOffice
   fi
  fi
  $cmd_gunzip -c $src_dir/$archive | $cmd_tar xvf - || \
    Fatal "Installation aborted"
  rm -f $prefix/.[a-zA-Z]*  
done


if [ $is_exec = "yes" ]; then
 #--- Get languages ---
 SkipLine
 languages=
 test -r lib/locale/languages || Fatal "The \`languages' file is missing!"
 exec 5<lib/locale/languages
 while read lang <&5 ; do
   languages="$languages $lang"
 done
 exec 5<&-
 AskOneFromList "Choose language" 0 lang $languages

 #--- Link ressources files ---
 if [ ! -d $prefix/app-defaults ]; then
  mkdir $prefix/app-defaults || exit 1
  chmod 755 $prefix/app-defaults || exit 1
 fi

 #--- Link config files ---
 cd $prefix/lib/locale/
 for file in *rc.$lang; do
  cd $prefix/lib
  file=`basename $file .$lang`
  if [ -f $file -a -w $file ]; then
   doit="no"
   case `basename $file` in
    "xclamationrc") [ $is_xcl = "yes" ] && doit="yes";;
    "xquadrc") [ $is_xquad = "yes" ] && doit="yes";;
    "xallwriterc") [ $is_xallwrite = "yes" ] && doit="yes";;
    "xmaydayrc") [ $is_xmayday = "yes" ] && doit="yes";;
   esac
   if [ $doit = "yes" ]; then
    echo deleting old $file
    rm $file
    ln -s locale/$file.$lang $file
   fi
  fi
 done

 cd $prefix/lib/locale/
 for file in *.$lang; do
  cd $prefix/app-defaults
  file=`basename $file .$lang`
  if [ -f $file -a -w $file ]; then
   doit="no"
   case `basename $file` in
    "Xclamation") [ $is_xcl = "yes" ] && doit="yes";;
    "XQuad") [ $is_xquad = "yes" ] && doit="yes";;
    "XAllWrite") [ $is_xallwrite = "yes" ] && doit="yes";;
    "XMayday") [ $is_xmayday = "yes" ] && doit="yes";;
    "AxeneOffice") [ $is_axeneoffice = "yes" ] && doit="yes";;
   esac
   if [ $doit = "yes" ]; then
    echo deleting old $file
    rm $file
    ln -s ../lib/locale/$file.$lang $file
   fi
  fi
 done
fi 
 
if [ $is_xcl = "yes" ]; then

#--- Create Exec Script For Xclamation ---
echo "Building script for Xclamation: Xclamation"
cat << __EOT__ > $prefix/Xclamation
#!/bin/sh
# 
# Xclamation
# Xclamation script
# 
# Copyright (c)1996-1998. All Rights reserved Axene.
# EMail: <xcalibur@axene.com>
# 
# Started on  Fri Nov 17 17:34:10 1995 Nucleus
# Last update Fri Feb  9 14:47:40 1996 Gudul
#

#--- Init global variables
SkipLine() { echo " "; }
Fatal() { echo "\${progname}: error: \${1}" 1>&2 ; exit 1; }

progname=\`basename \$0\`
bin_list=
name_base=Xclamation

# ---------------------------------------------------------------------- # 
# AskOneFromList - Let the user choose an item among a list              # 
#                  <text> <default-index> <var > <choice-1>...<choice-n> #
# ---------------------------------------------------------------------- #
AskOneFromList()
{
  _ask_text=\$1
  _ask_default=\$2
  _ask_var=\$3
  shift 3
  _arg_all=\$@
  _arg_num=\$#

  while :; do
    if [ "\$force_flag" = "yes" ]; then
      return \$_ask_default
    else
      echo \$_ask_text
      _ask_count=0
      while [ \$_ask_count -lt \$_arg_num ]; do
        if [ \$_ask_count -eq \$_ask_default ]; then
          _ask_reply="(DEFAULT)"
        else
          _ask_reply=
        fi
        _ask_count=\`expr \$_ask_count + 1\`
        eval "echo \"  \\\$_ask_count. \\\$1 \$_ask_reply\""
	shift 1
      done
      read _ask_reply
      if [ -z "\$_ask_reply" ]; then
	_arg_cnt=0
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_default ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
        fi
        _arg_cnt=\`expr \$_arg_cnt + 1\`
        done        
	return \$_ask_default
      fi
      if [ \$_ask_reply -gt 0 -a \$_ask_reply -le \$_arg_num ]; then
        SkipLine
	_arg_cnt=1
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_reply ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
         fi
         _arg_cnt=\`expr \$_arg_cnt + 1\`
        done
        return \`expr \$_ask_reply - 1\`
      fi
      echo "ERROR: You must enter a number between 1 and \$_arg_num"
      exit 1
    fi
  done
} 

# ---------------------------------------------------------------------- # 
# ---------------------------------------------------------------------- #
TestInHostList()
{
 _Host=\`hostname || uname -n\`
 _HostsDB=\$ZHOME/lib/locale/axene.hosts

 _count_exec=0
 for _file in \$ZHOME/bin/\${name_base}*; do
  if [ -x \$_file ]; then
   _count_exec=\`expr \$_count_exec + 1\`
  fi
 done

 if [ "\$_count_exec" -eq "0" ]; then
   Fatal "No executable found in \$ZHOME/bin/"
 fi

 if [ "\$_count_exec" -eq "1" ]; then
  bin_list=\$ZHOME/bin/\${name_base}*
 else
  _No_Host=0
  _Bin_ok=0
  test -r \$_HostsDB || _No_Host=1
  if [ "\$_No_Host" -eq "0" ]; then
   exec 5<\$_HostsDB
   while read _v_host <&5 ; do
     if [ "\$_v_host" = "\$_Host" ]; then
      read bin_list <&5
      bin_list=\$ZHOME/bin/\${name_base}.\${bin_list}
      _Bin_ok=1
      while read _v_host <&5 ; do
      echo flush > /dev/null
      done
     else
      read _v_burk <&5
      read _v_burk <&5
     fi
   done
   exec 5<&-
  else
   echo "No \$_HostsDB defined."
   if [ -w \$ZHOME/lib/locale/ ]; then
    touch \$_HostsDB
   else
    echo "Not authorized to write into directory \$ZHOME/lib/locale/"
   fi
  fi
 	
  if [ "\$_Bin_ok" -eq "0" ]; then
   AskOneFromList "Please select the program to execute on \$_Host" 0 bin_list \$ZHOME/bin/\${name_base}*
   if [ ! -w \$_HostsDB ]; then
    echo "Could not add this entry to \$_HostsDB"
   else
    echo "host \\\`\$_Host\' is now associated with program :"
    echo "\\\`\$bin_list\'."
    echo "(if error, edit or delete \$_HostsDB)" 
    echo \$_Host >> \$_HostsDB
    echo \$bin_list | cut -d"." -f2- >> \$_HostsDB
    echo ----- >> \$_HostsDB
   fi
  fi
 fi
}

ZHOME=$prefix
AXENE_LIB=\$ZHOME/lib
XCLAMATION_LIB=\$ZHOME/lib
XAPPLRESDIR=\$ZHOME/app-defaults
export AXENE_LIB XCLAMATION_LIB XAPPLRESDIR

TestInHostList
exec \$bin_list \$@

__EOT__
chmod 755 $prefix/Xclamation
fi

if [ $is_xquad = "yes" ]; then 
#--- Create Exec Script For XQuad ---
echo "Building script for XQuad: XQuad"
cat << __EOT__ > $prefix/XQuad
#!/bin/sh
# 
# XQuad
# XQuad script
# 
# Copyright (c)1996-1998. All Rights reserved Axene.
# EMail: <xcalibur@axene.com>
# 
# Started on  Fri Nov 17 17:34:10 1995 Nucleus
# Last update Fri Feb  9 14:47:40 1996 Gudul
#

#--- Init global variables
SkipLine() { echo " "; }
Fatal() { echo "\${progname}: error: \${1}" 1>&2 ; exit 1; }

progname=\`basename \$0\`
bin_list=
name_base=XQuad

# ---------------------------------------------------------------------- # 
# AskOneFromList - Let the user choose an item among a list              # 
#                  <text> <default-index> <var > <choice-1>...<choice-n> #
# ---------------------------------------------------------------------- #
AskOneFromList()
{
  _ask_text=\$1
  _ask_default=\$2
  _ask_var=\$3
  shift 3
  _arg_all=\$@
  _arg_num=\$#

  while :; do
    if [ "\$force_flag" = "yes" ]; then
      return \$_ask_default
    else
      echo \$_ask_text
      _ask_count=0
      while [ \$_ask_count -lt \$_arg_num ]; do
        if [ \$_ask_count -eq \$_ask_default ]; then
          _ask_reply="(DEFAULT)"
        else
          _ask_reply=
        fi
        _ask_count=\`expr \$_ask_count + 1\`
        eval "echo \"  \\\$_ask_count. \\\$1 \$_ask_reply\""
	shift 1
      done
      read _ask_reply
      if [ -z "\$_ask_reply" ]; then
	_arg_cnt=0
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_default ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
        fi
        _arg_cnt=\`expr \$_arg_cnt + 1\`
        done        
	return \$_ask_default
      fi
      if [ \$_ask_reply -gt 0 -a \$_ask_reply -le \$_arg_num ]; then
        SkipLine
	_arg_cnt=1
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_reply ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
         fi
         _arg_cnt=\`expr \$_arg_cnt + 1\`
        done
        return \`expr \$_ask_reply - 1\`
      fi
      echo "ERROR: You must enter a number between 1 and \$_arg_num"
      exit 1
    fi
  done
} 

# ---------------------------------------------------------------------- # 
# ---------------------------------------------------------------------- #
TestInHostList()
{
 _Host=\`hostname || uname -n\`
 _HostsDB=\$ZHOME/lib/locale/axene.hosts

 _count_exec=0
 for _file in \$ZHOME/bin/\${name_base}*; do
  if [ -x \$_file ]; then
   _count_exec=\`expr \$_count_exec + 1\`
  fi
 done

 if [ "\$_count_exec" -eq "0" ]; then
   Fatal "No executable found in \$ZHOME/bin/"
 fi

 if [ "\$_count_exec" -eq "1" ]; then
  bin_list=\$ZHOME/bin/\${name_base}*
 else
  _No_Host=0
  _Bin_ok=0
  test -r \$_HostsDB || _No_Host=1
  if [ "\$_No_Host" -eq "0" ]; then
   exec 5<\$_HostsDB
   while read _v_host <&5 ; do
     if [ "\$_v_host" = "\$_Host" ]; then
      read bin_list <&5
      bin_list=\$ZHOME/bin/\${name_base}.\${bin_list}
      _Bin_ok=1
      while read _v_host <&5 ; do
      echo flush > /dev/null
      done
     else
      read _v_burk <&5
      read _v_burk <&5
     fi
   done
   exec 5<&-
  else
   echo "No \$_HostsDB defined."
   if [ -w \$ZHOME/lib/locale/ ]; then
    touch \$_HostsDB
   else
    echo "Not authorized to write into directory \$ZHOME/lib/locale/"
   fi
  fi
 	
  if [ "\$_Bin_ok" -eq "0" ]; then
   AskOneFromList "Please select the program to execute on \$_Host" 0 bin_list \$ZHOME/bin/\${name_base}*
   if [ ! -w \$_HostsDB ]; then
    echo "Could not add this entry to \$_HostsDB"
   else
    echo "host \\\`\$_Host\' is now associated with program :"
    echo "\\\`\$bin_list\'."
    echo "(if error, edit or delete \$_HostsDB)" 
    echo \$_Host >> \$_HostsDB
    echo \$bin_list | cut -d"." -f2- >> \$_HostsDB
    echo ----- >> \$_HostsDB
   fi
  fi
 fi
}

ZHOME=$prefix
AXENE_LIB=\$ZHOME/lib
XQUAD_LIB=\$ZHOME/lib
XAPPLRESDIR=\$ZHOME/app-defaults
export AXENE_LIB XQUAD_LIB XAPPLRESDIR

TestInHostList
exec \$bin_list \$@

__EOT__
chmod 755 $prefix/XQuad
fi

if [ $is_xallwrite = "yes" ]; then 
#--- Create Exec Script For XAllWrite ---
echo "Building script for XAllWrite: XAllWrite"
cat << __EOT__ > $prefix/XAllWrite
#!/bin/sh
# 
# XAllWrite
# XAllWrite script
# 
# Copyright (c)1996-1998. All Rights reserved Axene.
# EMail: <xcalibur@axene.com>
# 
# Started on  Fri Nov 17 17:34:10 1995 Nucleus
# Last update Fri Feb  9 14:47:40 1996 Gudul
#

#--- Init global variables
SkipLine() { echo " "; }
Fatal() { echo "\${progname}: error: \${1}" 1>&2 ; exit 1; }

progname=\`basename \$0\`
bin_list=
name_base=XAllWrite

# ---------------------------------------------------------------------- # 
# AskOneFromList - Let the user choose an item among a list              # 
#                  <text> <default-index> <var > <choice-1>...<choice-n> #
# ---------------------------------------------------------------------- #
AskOneFromList()
{
  _ask_text=\$1
  _ask_default=\$2
  _ask_var=\$3
  shift 3
  _arg_all=\$@
  _arg_num=\$#

  while :; do
    if [ "\$force_flag" = "yes" ]; then
      return \$_ask_default
    else
      echo \$_ask_text
      _ask_count=0
      while [ \$_ask_count -lt \$_arg_num ]; do
        if [ \$_ask_count -eq \$_ask_default ]; then
          _ask_reply="(DEFAULT)"
        else
          _ask_reply=
        fi
        _ask_count=\`expr \$_ask_count + 1\`
        eval "echo \"  \\\$_ask_count. \\\$1 \$_ask_reply\""
	shift 1
      done
      read _ask_reply
      if [ -z "\$_ask_reply" ]; then
	_arg_cnt=0
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_default ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
        fi
        _arg_cnt=\`expr \$_arg_cnt + 1\`
        done        
	return \$_ask_default
      fi
      if [ \$_ask_reply -gt 0 -a \$_ask_reply -le \$_arg_num ]; then
        SkipLine
	_arg_cnt=1
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_reply ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
         fi
         _arg_cnt=\`expr \$_arg_cnt + 1\`
        done
        return \`expr \$_ask_reply - 1\`
      fi
      echo "ERROR: You must enter a number between 1 and \$_arg_num"
      exit 1
    fi
  done
} 

# ---------------------------------------------------------------------- # 
# ---------------------------------------------------------------------- #
TestInHostList()
{
 _Host=\`hostname || uname -n\`
 _HostsDB=\$ZHOME/lib/locale/axene.hosts

 _count_exec=0
 for _file in \$ZHOME/bin/\${name_base}*; do
  if [ -x \$_file ]; then
   _count_exec=\`expr \$_count_exec + 1\`
  fi
 done

 if [ "\$_count_exec" -eq "0" ]; then
   Fatal "No executable found in \$ZHOME/bin/"
 fi

 if [ "\$_count_exec" -eq "1" ]; then
  bin_list=\$ZHOME/bin/\${name_base}*
 else
  _No_Host=0
  _Bin_ok=0
  test -r \$_HostsDB || _No_Host=1
  if [ "\$_No_Host" -eq "0" ]; then
   exec 5<\$_HostsDB
   while read _v_host <&5 ; do
     if [ "\$_v_host" = "\$_Host" ]; then
      read bin_list <&5
      bin_list=\$ZHOME/bin/\${name_base}.\${bin_list}
      _Bin_ok=1
      while read _v_host <&5 ; do
      echo flush > /dev/null
      done
     else
      read _v_burk <&5
      read _v_burk <&5
     fi
   done
   exec 5<&-
  else
   echo "No \$_HostsDB defined."
   if [ -w \$ZHOME/lib/locale/ ]; then
    touch \$_HostsDB
   else
    echo "Not authorized to write into directory \$ZHOME/lib/locale/"
   fi
  fi
 	
  if [ "\$_Bin_ok" -eq "0" ]; then
   AskOneFromList "Please select the program to execute on \$_Host" 0 bin_list \$ZHOME/bin/\${name_base}*
   if [ ! -w \$_HostsDB ]; then
    echo "Could not add this entry to \$_HostsDB"
   else
    echo "host \\\`\$_Host\' is now associated with program :"
    echo "\\\`\$bin_list\'."
    echo "(if error, edit or delete \$_HostsDB)" 
    echo \$_Host >> \$_HostsDB
    echo \$bin_list | cut -d"." -f2- >> \$_HostsDB
    echo ----- >> \$_HostsDB
   fi
  fi
 fi
}

ZHOME=$prefix
AXENE_LIB=\$ZHOME/lib
XALLWRITE_LIB=\$ZHOME/lib
XAPPLRESDIR=\$ZHOME/app-defaults
export AXENE_LIB XALLWRITE_LIB XAPPLRESDIR

TestInHostList
exec \$bin_list \$@

__EOT__
chmod 755 $prefix/XAllWrite
fi

if [ $is_xmayday = "yes" ]; then 
#--- Create Exec Script For XMayday ---
echo "Building script for XMayday: XMayday"
cat << __EOT__ > $prefix/XMayday
#!/bin/sh
# 
# XMayday
# XMayday script
# 
# Copyright (c)1996-1998. All Rights reserved Axene.
# EMail: <xcalibur@axene.com>
# 
# Started on  Fri Nov 17 17:34:10 1995 Nucleus
# Last update Fri Feb  9 14:47:40 1996 Gudul
#

#--- Init global variables
SkipLine() { echo " "; }
Fatal() { echo "\${progname}: error: \${1}" 1>&2 ; exit 1; }

progname=\`basename \$0\`
bin_list=
name_base=XMayday

# ---------------------------------------------------------------------- # 
# AskOneFromList - Let the user choose an item among a list              # 
#                  <text> <default-index> <var > <choice-1>...<choice-n> #
# ---------------------------------------------------------------------- #
AskOneFromList()
{
  _ask_text=\$1
  _ask_default=\$2
  _ask_var=\$3
  shift 3
  _arg_all=\$@
  _arg_num=\$#

  while :; do
    if [ "\$force_flag" = "yes" ]; then
      return \$_ask_default
    else
      echo \$_ask_text
      _ask_count=0
      while [ \$_ask_count -lt \$_arg_num ]; do
        if [ \$_ask_count -eq \$_ask_default ]; then
          _ask_reply="(DEFAULT)"
        else
          _ask_reply=
        fi
        _ask_count=\`expr \$_ask_count + 1\`
        eval "echo \"  \\\$_ask_count. \\\$1 \$_ask_reply\""
	shift 1
      done
      read _ask_reply
      if [ -z "\$_ask_reply" ]; then
	_arg_cnt=0
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_default ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
        fi
        _arg_cnt=\`expr \$_arg_cnt + 1\`
        done        
	return \$_ask_default
      fi
      if [ \$_ask_reply -gt 0 -a \$_ask_reply -le \$_arg_num ]; then
        SkipLine
	_arg_cnt=1
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_reply ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
         fi
         _arg_cnt=\`expr \$_arg_cnt + 1\`
        done
        return \`expr \$_ask_reply - 1\`
      fi
      echo "ERROR: You must enter a number between 1 and \$_arg_num"
      exit 1
    fi
  done
} 

# ---------------------------------------------------------------------- # 
# ---------------------------------------------------------------------- #
TestInHostList()
{
 _Host=\`hostname || uname -n\`
 _HostsDB=\$ZHOME/lib/locale/axene.hosts

 _count_exec=0
 for _file in \$ZHOME/bin/\${name_base}*; do
  if [ -x \$_file ]; then
   _count_exec=\`expr \$_count_exec + 1\`
  fi
 done

 if [ "\$_count_exec" -eq "0" ]; then
   Fatal "No executable found in \$ZHOME/bin/"
 fi

 if [ "\$_count_exec" -eq "1" ]; then
  bin_list=\$ZHOME/bin/\${name_base}*
 else
  _No_Host=0
  _Bin_ok=0
  test -r \$_HostsDB || _No_Host=1
  if [ "\$_No_Host" -eq "0" ]; then
   exec 5<\$_HostsDB
   while read _v_host <&5 ; do
     if [ "\$_v_host" = "\$_Host" ]; then
      read bin_list <&5
      bin_list=\$ZHOME/bin/\${name_base}.\${bin_list}
      _Bin_ok=1
      while read _v_host <&5 ; do
      echo flush > /dev/null
      done
     else
      read _v_burk <&5
      read _v_burk <&5
     fi
   done
   exec 5<&-
  else
   echo "No \$_HostsDB defined."
   if [ -w \$ZHOME/lib/locale/ ]; then
    touch \$_HostsDB
   else
    echo "Not authorized to write into directory \$ZHOME/lib/locale/"
   fi
  fi
 	
  if [ "\$_Bin_ok" -eq "0" ]; then
   AskOneFromList "Please select the program to execute on \$_Host" 0 bin_list \$ZHOME/bin/\${name_base}*
   if [ ! -w \$_HostsDB ]; then
    echo "Could not add this entry to \$_HostsDB"
   else
    echo "host \\\`\$_Host\' is now associated with program :"
    echo "\\\`\$bin_list\'."
    echo "(if error, edit or delete \$_HostsDB)" 
    echo \$_Host >> \$_HostsDB
    echo \$bin_list | cut -d"." -f2- >> \$_HostsDB
    echo ----- >> \$_HostsDB
   fi
  fi
 fi
}

ZHOME=$prefix
AXENE_LIB=\$ZHOME/lib
XMAYDAY_LIB=\$ZHOME/lib
XAPPLRESDIR=\$ZHOME/app-defaults
export AXENE_LIB XMAYDAY_LIB XAPPLRESDIR

TestInHostList
exec \$bin_list \$@

__EOT__
chmod 755 $prefix/XMayday
fi

if [ $is_axeneoffice = "yes" ]; then 
#--- Create Exec Script For AxeneOffice ---
echo "Building script for AxeneOffice: AxeneOffice"
cat << __EOT__ > $prefix/AxeneOffice
#!/bin/sh
# 
# AxeneOffice
# AxeneOffice script
# 
# Copyright (c)1996-1998. All Rights reserved Axene.
# EMail: <xcalibur@axene.com>
# 
# Started on  Fri Nov 17 17:34:10 1995 Nucleus
# Last update Fri Feb  9 14:47:40 1996 Gudul
#

#--- Init global variables
SkipLine() { echo " "; }
Fatal() { echo "\${progname}: error: \${1}" 1>&2 ; exit 1; }

progname=\`basename \$0\`
bin_list=
name_base=AxeneOffice

# ---------------------------------------------------------------------- # 
# AskOneFromList - Let the user choose an item among a list              # 
#                  <text> <default-index> <var > <choice-1>...<choice-n> #
# ---------------------------------------------------------------------- #
AskOneFromList()
{
  _ask_text=\$1
  _ask_default=\$2
  _ask_var=\$3
  shift 3
  _arg_all=\$@
  _arg_num=\$#

  while :; do
    if [ "\$force_flag" = "yes" ]; then
      return \$_ask_default
    else
      echo \$_ask_text
      _ask_count=0
      while [ \$_ask_count -lt \$_arg_num ]; do
        if [ \$_ask_count -eq \$_ask_default ]; then
          _ask_reply="(DEFAULT)"
        else
          _ask_reply=
        fi
        _ask_count=\`expr \$_ask_count + 1\`
        eval "echo \"  \\\$_ask_count. \\\$1 \$_ask_reply\""
	shift 1
      done
      read _ask_reply
      if [ -z "\$_ask_reply" ]; then
	_arg_cnt=0
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_default ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
        fi
        _arg_cnt=\`expr \$_arg_cnt + 1\`
        done        
	return \$_ask_default
      fi
      if [ \$_ask_reply -gt 0 -a \$_ask_reply -le \$_arg_num ]; then
        SkipLine
	_arg_cnt=1
        for _ask_phrase in \$_arg_all; do
         if [ \$_arg_cnt -eq \$_ask_reply ]; then
          eval "\$_ask_var=\"\\\$_ask_phrase\""
          break
         fi
         _arg_cnt=\`expr \$_arg_cnt + 1\`
        done
        return \`expr \$_ask_reply - 1\`
      fi
      echo "ERROR: You must enter a number between 1 and \$_arg_num"
      exit 1
    fi
  done
} 

# ---------------------------------------------------------------------- # 
# ---------------------------------------------------------------------- #
TestInHostList()
{
 _Host=\`hostname || uname -n\`
 _HostsDB=\$ZHOME/lib/locale/axene.hosts

 _count_exec=0
 for _file in \$ZHOME/bin/\${name_base}*; do
  if [ -x \$_file ]; then
   _count_exec=\`expr \$_count_exec + 1\`
  fi
 done

 if [ "\$_count_exec" -eq "0" ]; then
   Fatal "No executable found in \$ZHOME/bin/"
 fi

 if [ "\$_count_exec" -eq "1" ]; then
  bin_list=\$ZHOME/bin/\${name_base}*
 else
  _No_Host=0
  _Bin_ok=0
  test -r \$_HostsDB || _No_Host=1
  if [ "\$_No_Host" -eq "0" ]; then
   exec 5<\$_HostsDB
   while read _v_host <&5 ; do
     if [ "\$_v_host" = "\$_Host" ]; then
      read bin_list <&5
      bin_list=\$ZHOME/bin/\${name_base}.\${bin_list}
      _Bin_ok=1
      while read _v_host <&5 ; do
      echo flush > /dev/null
      done
     else
      read _v_burk <&5
      read _v_burk <&5
     fi
   done
   exec 5<&-
  else
   echo "No \$_HostsDB defined."
   if [ -w \$ZHOME/lib/locale/ ]; then
    touch \$_HostsDB
   else
    echo "Not authorized to write into directory \$ZHOME/lib/locale/"
   fi
  fi
 	
  if [ "\$_Bin_ok" -eq "0" ]; then
   AskOneFromList "Please select the program to execute on \$_Host" 0 bin_list \$ZHOME/bin/\${name_base}*
   if [ ! -w \$_HostsDB ]; then
    echo "Could not add this entry to \$_HostsDB"
   else
    echo "host \\\`\$_Host\' is now associated with program :"
    echo "\\\`\$bin_list\'."
    echo "(if error, edit or delete \$_HostsDB)" 
    echo \$_Host >> \$_HostsDB
    echo \$bin_list | cut -d"." -f2- >> \$_HostsDB
    echo ----- >> \$_HostsDB
   fi
  fi
 fi
}

ZHOME=$prefix
AXENE_LIB=\$ZHOME/lib
AXENEOFFICE_LIB=\$ZHOME/lib
XAPPLRESDIR=\$ZHOME/app-defaults
export AXENE_LIB AXENEOFFICE_LIB XAPPLRESDIR

TestInHostList
exec \$bin_list \$@

__EOT__
chmod 755 $prefix/AxeneOffice
fi

if [ -w "/usr/local/bin" ]; then
 SkipLine

 if [ $is_xcl = "yes" ]; then
  _answer=-1
  while [ "$_answer" = "-1" ]; do
   AskYesNo "Make Xclamation available from /usr/local/bin ? [y/n]:" _answer
   if [ $_answer = 1 ]; then
     if [ -f /usr/local/bin/Xclamation ]; then
      _answer=-1
      while [ "$_answer" = "-1" ]; do
       AskYesNo "\ File /usr/local/bin/Xclamation exists ! Delete it ? [y/n]:" \
		_answer
       if [ $_answer = 1 ]; then
        echo "\ Removing file /usr/local/bin/Xclamation."
	rm -f "/usr/local/bin/Xclamation"
        echo "Linking "$prefix"/Xclamation to /usr/local/bin/Xclamation."
        ln -s $prefix/Xclamation /usr/local/bin/Xclamation
       fi 
      done
     else
      echo "Linking "$prefix"/Xclamation to /usr/local/bin/Xclamation."
      ln -s $prefix/Xclamation /usr/local/bin/Xclamation
     fi
   fi 
  done
 fi

 if [ $is_xquad = "yes" ]; then
  _answer=-1
  while [ "$_answer" = "-1" ]; do
   AskYesNo "Make XQuad available from /usr/local/bin ? [y/n]:" _answer
   if [ $_answer = 1 ]; then
     if [ -f /usr/local/bin/XQuad ]; then
      _answer=-1
      while [ "$_answer" = "-1" ]; do
       AskYesNo "\ File /usr/local/bin/XQuad exists ! Delete it ? [y/n]:" \
		_answer
       if [ $_answer = 1 ]; then
        echo "\ Removing file /usr/local/bin/XQuad."
	rm -f "/usr/local/bin/XQuad"
        echo "Linking "$prefix"/XQuad to /usr/local/bin/XQuad."
        ln -s $prefix/XQuad /usr/local/bin/XQuad
       fi 
      done
     else
      echo "Linking "$prefix"/XQuad to /usr/local/bin/XQuad."
      ln -s $prefix/XQuad /usr/local/bin/XQuad
     fi
   fi 
  done
 fi

 if [ $is_xallwrite = "yes" ]; then
  _answer=-1
  while [ "$_answer" = "-1" ]; do
   AskYesNo "Make XAllWrite available from /usr/local/bin ? [y/n]:" _answer
   if [ $_answer = 1 ]; then
     if [ -f /usr/local/bin/XAllWrite ]; then
      _answer=-1
      while [ "$_answer" = "-1" ]; do
       AskYesNo "\ File /usr/local/bin/XAllWrite exists ! Delete it ? [y/n]:" \
		_answer
       if [ $_answer = 1 ]; then
        echo "\ Removing file /usr/local/bin/XAllWrite."
	rm -f "/usr/local/bin/XAllWrite"
        echo "Linking "$prefix"/XAllWrite to /usr/local/bin/XAllWrite."
        ln -s $prefix/XAllWrite /usr/local/bin/XAllWrite
       fi 
      done
     else
      echo "Linking "$prefix"/XAllWrite to /usr/local/bin/XAllWrite."
      ln -s $prefix/XAllWrite /usr/local/bin/XAllWrite
     fi
   fi 
  done
 fi

 if [ $is_xmayday = "yes" ]; then
  _answer=-1
  while [ "$_answer" = "-1" ]; do
   AskYesNo "Make XMayday available from /usr/local/bin ? [y/n]:" _answer
   if [ $_answer = 1 ]; then
     if [ -f /usr/local/bin/XMayday ]; then
      _answer=-1
      while [ "$_answer" = "-1" ]; do
       AskYesNo "\ File /usr/local/bin/XMayday exists ! Delete it ? [y/n]:" \
		_answer
       if [ $_answer = 1 ]; then
        echo "\ Removing file /usr/local/bin/XMayday."
	rm -f "/usr/local/bin/XMayday"
        echo "Linking "$prefix"/XMayday to /usr/local/bin/XMayday."
        ln -s $prefix/XMayday /usr/local/bin/XMayday
       fi 
      done
     else
      echo "Linking "$prefix"/XMayday to /usr/local/bin/XMayday."
      ln -s $prefix/XMayday /usr/local/bin/XMayday
     fi
   fi 
  done
 fi

 if [ $is_axeneoffice = "yes" ]; then
  _answer=-1
  while [ "$_answer" = "-1" ]; do
   AskYesNo "Make AxeneOffice available from /usr/local/bin ? [y/n]:" _answer
   if [ $_answer = 1 ]; then
     if [ -f /usr/local/bin/AxeneOffice ]; then
      _answer=-1
      while [ "$_answer" = "-1" ]; do
       AskYesNo "\ File /usr/local/bin/AxeneOffice exists ! Delete it ? [y/n]:" \
		_answer
       if [ $_answer = 1 ]; then
        echo "\ Removing file /usr/local/bin/AxeneOffice."
	rm -f "/usr/local/bin/AxeneOffice"
        echo "Linking "$prefix"/AxeneOffice to /usr/local/bin/AxeneOffice."
        ln -s $prefix/AxeneOffice /usr/local/bin/AxeneOffice
       fi 
      done
     else
      echo "Linking "$prefix"/AxeneOffice to /usr/local/bin/AxeneOffice."
      ln -s $prefix/AxeneOffice /usr/local/bin/AxeneOffice
     fi
   fi 
  done
 fi
fi

cat << __EOM__

 ========================
 == INSTALLATION DONE. ==
 ========================

__EOM__

if [ ! -d $prefix/lib/fonts ]; then 
 if [ $is_xcl = "yes" -o $is_xquad = "yes" -o $is_xallwrite = "yes" ]; then
  $ECHONL1"You must install the common.tar.gz package to get "$ECHONL2
  if [ $is_xcl = "yes" -a $is_xquad = "yes" -a $is_xallwrite = "yes" ]; then
   $ECHONL1"Xclamation, XQuad and XAllWrite"$ECHONL2
  elif [ $is_xcl = "yes" -a $is_xquad = "yes" ]; then
   $ECHONL1"Xclamation and XQuad"$ECHONL2
  elif [ $is_xcl = "yes" -a $is_xallwrite = "yes" ]; then
   $ECHONL1"Xclamation and XAllWrite"$ECHONL2
  elif [ $is_xquad = "yes" -a $is_xallwrite = "yes" ]; then
   $ECHONL1"XQuad and XAllWrite"$ECHONL2
  elif [ $is_xcl = "yes" ]; then
   $ECHONL1"Xclamation"$ECHONL2
  elif [ $is_xquad = "yes" ]; then
   $ECHONL1"XQuad"$ECHONL2
  elif [ $is_xallwrite = "yes" ]; then
   $ECHONL1"XAllWrite"$ECHONL2
  fi
  echo " working."
 fi
fi

SkipLine
