#!/bin/sh
#
# jperf startup script for unix
# mark gates
# $Id: jperf,v 1.1 2000/01/10 20:06:02 mgates Exp $

########################################
# function find_prg_binary
# modifies $PRG to the pathname of its binary
#
# since `type -p foo` doesn't always work,
# use `type foo | sed -e 's/.* is //g'
#
# testing for sym links varies between -h or -L
# instead, do an `ls -l` and look for the sym link arrow
#
find_prg_binary( )
{
  PRG=`type $PRG | sed -e 's/.* is //g'`
  newprg=`expr "\`/bin/ls -l "$PRG"\`" : ".*$PRG -> \(.*\)"`
  while [ $newprg ]
  do
    expr "$newprg" : "\/" >/dev/null || newprg="`dirname $PRG`/$newprg"
    PRG="$newprg"
    newprg=`expr "\`/bin/ls -l "$PRG"\`" : ".*$PRG -> \(.*\)"`
  done
}

########################################
# add SWING_HOME to the classpath
#

if [ ! -z "${SWING_HOME}" ] ; then
  CLASSPATH=${CLASSPATH}:${SWING_HOME}/swing.jar
fi

########################################
# add jperf's jar file
# we have to know the path to the jar file, which
# should be in the same directory as this script
#

PRG=$0
find_prg_binary
JPERF_PATH=`dirname $PRG`

CLASSPATH=${CLASSPATH}:${JPERF_PATH}/jperf.jar
export CLASSPATH

CMD="java Interface $*"
${CMD}
