#!/bin/ksh -p

# @(#)javaws	1.9 02/12/11
#Script to start Java Web Start. Directory that this script is in is added to the
#LD_LIBRARY_PATH. JAVAWS_HOME is also set to the directory this script is in,
#unless it is already set.

PRG=`whence $0` > /dev/null 2>&1

while [ -h "$PRG" ]; do
    ls=`/usr/bin/ls -ld "$PRG"`
    link=`/usr/bin/expr "$ls" : '^.*-> \(.*\)$'`
    if /usr/bin/expr "$link" : '^/' > /dev/null; then
       prg="$link"
    else
       prg="`/usr/bin/dirname $PRG`/$link"
    fi
    PRG=`whence "$prg"` > /dev/null 2>&1
done

DIRNAME=`/usr/bin/dirname "$PRG"`
APPHOME=`cd $DIRNAME; /usr/bin/pwd`

CPUV=`getconf CPU_VERSION 2>/dev/null`
if [[ -z "${CPUV}" || ${CPUV} -lt 532 ]]; then
    # PA_RISC:
    # update SHLIB_PATH to include the directory containing this file
    if [ -z "${SHLIB_PATH}" ]; then
      SHLIB_PATH=${APPHOME}
    else
      SHLIB_PATH=${SHLIB_PATH}:${APPHOME}
    fi
    export SHLIB_PATH
    ARCH=PA_RISC
else
    if [[ ${CPUV} -gt 767 ]]; then
	# IPF:
	# update LD_LIBRARY_PATH to include the directory containing this file
	if [ -z "${LD_LIBRARY_PATH}" ]; then
	  LD_LIBRARY_PATH=${APPHOME}
	else
	  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${APPHOME}
	fi
	export LD_LIBRARY_PATH
	ARCH=IA64N

    else # -ge 532 && -le 767
	# PA_RISC2.0:
	# update SHLIB_PATH to include the directory containing this file
	if [ -z "${SHLIB_PATH}" ]; then
	  SHLIB_PATH=${APPHOME}
	else
	  SHLIB_PATH=${SHLIB_PATH}:${APPHOME}
	fi
	export SHLIB_PATH
	ARCH=PA_RISC2.0
    fi
fi

# Update JAVAWS_HOME to be the directory the script is running from.
if [ -z "${JAVAWS_HOME}" ]; then
  JAVAWS_HOME=${APPHOME}
  export JAVAWS_HOME
fi

exec ${APPHOME}/javawsbin.${ARCH} "$@"
