#!/bin/ksh

#
# A easy to use shell script to compile and launch the HotJava basher,
# for internal consumption within the JDK development team. Known to
# work with HotJava 1.0.1.
#

scriptName=`basename ${0}`
usage() {
  cat <<__EOF
    
    ${scriptName} is a simple-minded front-end for Steve Byrne's
    HotJava basher. It works with hjb1.0.1 on Solaris and Win32, and
    understands jdk1.1.x and jdk1.2 workspace structures. Chmod before
    you run (SCCS strips execute bits).
    
Usage: 
    % ${scriptName} -hjdir <hotjava.home>
where
    <hotjava.home>  is typically "/usr/local/java/hjb1.0.1/solaris"
                    or "C:/HOTJAVA" (forward slash must).

You can also set JAVADIR to point to an alternate Java location
(default java is from current workspace). On my shell (bash), this
works:

  % (export JAVADIR=/usr/local/java/jdk1.2/solaris; \\
          ./${scriptName} -hjdir /usr/local/java/jdk1.2/solaris)

__EOF
}

if [ $# != 2 ]; then
    usage
    exit 1
fi

if [ "$1" != "-hjdir" ]; then
    usage
    exit 2
fi

HJB_DIR="$2"

#
# Don't even think about inherting any of these.
#
unset JAVA_HOME
unset CLASSPATH
unset JDK_HOME

#
# Where is Java?
#
if [ `uname` = "SunOS" ]; then
    PLATFORM=solaris
    DIR_SEP=':'
else
    PLATFORM=win32
    DIR_SEP=';'
fi
if [ ${PLATFORM} = solaris ]; then
    if [ -x ../../../../build/bin/java ]; then 
	# Hmm, 1.1.x workspace
	PLATFORM=""
    fi
fi
JAVADIR=${JAVADIR:-../../../../build/${PLATFORM}}

#
# Compile the basher, if .class file appears outdated.
#
if [ BasherApplet.java -nt BasherApplet.class ]; then
    (export CLASSPATH=${HJB_DIR}/lib/classes.zip; \
     ${JAVADIR}/bin/javac BasherApplet.java)
fi

#
# Launch HotJava.
#
export CLASSPATH=.${DIR_SEP}${HJB_DIR}/lib/classes.zip
${JAVADIR}/bin/java${G} -Dhotjava.home=${HJB_DIR} -ms16m -mx32m \
                        sun.hotjava.Main file:`pwd`/index.html

#
# classpath is bogus now. careful after this point.
#
