#!/bin/ksh
#--------------------------------------------------------------------------------
#	Licensed Program Product:
#	VisualAge Smalltalk Enterprise on Solaris
#
#	(C) Copyright International Business Machines Corp. 1994, 2006.
#
#--------------------------------------------------------------------------------

if [ -z "$VASTROOT_60_ENV_SET" ]
then

	# Ensure that the environment variables get set only once -- even when
	# this script gets called recursively.
	export VASTROOT_60_ENV_SET=yes

	export VASTROOT_60=${VASTROOT_60:-/opt/IBMvast/6.0}
	export PATH=$VASTROOT_60/bin:$PATH

	#
	# Setup platform-specific shared library search path
	#
	abtslpath=$VASTROOT_60/bin:/usr/dt/lib:/usr/openwin/lib

	if [ ! -z "$DB2INSTANCE" ]
	then
		eval 'cd ~'${DB2INSTANCE}
		abtinstpath=`(pwd)`
		abtslpath=$abtslpath:$abtinstpath/sqllib/lib
		cd -
	fi

	if [ ! -z "$ORACLE_HOME" ]
	then
		abtslpath=$abtslpath:$ORACLE_HOME/lib
	fi

	export LD_LIBRARY_PATH=$abtslpath:$LD_LIBRARY_PATH
	
fi

#
# Image location logic:
#
# 1. If "-i<imagename>" was specified, use it.
#    NOTE:  -ini:<optionfilename> has been added as a valid parm and
#           must be accounted for in the following test
# 2. Otherwise, check for "<shellName>.icx".  If present, use it.
# 3. Otherwise, default to "image".

IMAGE=""
IOPTION=0

# NOTE:  VA ST options do not conform to standard Unix syntax since the
#        parameter MUST be immediately adjacent to the option AND
#        multicharacter options are supported.  This means that we can
#        not use getopts to parse the command line!
for KEY in $*
do
  test ${KEY#-i} != $KEY  &&  test ${KEY#-ini:} = $KEY  &&  IOPTION=1
done
test  $IOPTION -eq 0  &&  test -r $0.icx  &&  IMAGE="-i$0.icx"

#
# Runtime determination logic:
#
# 1. If <shellName> = "abt" then development time; otherwise runtime.
# 2. If development time, run es adding -mcd switch to disable code caching;
#    if runtime, run es adding -no_break switch so user break window not shown
#
# As of VAST 5.5 the install no longer sets up symbolic links to /usr/bin/es.
# (This permits the coexistence of multiple VAST versions on the same UNIX machine)

if [ "${0##*/}" = "abt" ]
  then
	$VASTROOT_60/bin/es -mcd $IMAGE $*
  else
	$VASTROOT_60/bin/es -no_break $IMAGE $*
fi
