#!/bin/sh

#Change this to your Together installtion root
#TGH=/usr/local/Together-4.2

# Change this to your JDK installation root
#
#JAVA_HOME=/usr/local/jdk1.2.2
#JAVA_HOME=/usr/local/jdk1.3


# Change that, if your java interpreter is different
#
JRE=$JAVA_HOME/jre
JAVA=$JRE/bin/java
JDK_RT_JAR=$JRE/lib/rt.jar
#JDK_TOOLS_JAR=$JAVA_HOME/lib/jpda.jar
#LD_LIBRARY_PATH=$JAVA_HOME/lib/i386:$LD_LIBRARY_PATH
#export LD_LIBRARY_PATH


if [ "D""$JAVA_HOME" = "D" ]
then
    echo
    echo Please provide a valid path to the recommended JDK by
    echo either configuring the file "$0" or defining the
    echo JAVA_HOME environment variable from the command line.
    echo
    echo If you have any problems or questions, please contact
    echo "technical support (http://www.togethersoft.com/support/)"
    exit
else
    if [ ! -x $JAVA ]
    then
        echo Please be sure you have properly set the JAVA_HOME variable.
        echo The executable file $JAVA is not found.
        exit
    fi

    VERSION=`$JAVA -version 2>&1 | awk 'BEGIN {FS="\""}\
    { for(i = 2; i<NF; i++) printf "%s", \$i }'`

    VC=`echo $VERSION | awk 'BEGIN {FS="."}\
    { printf "%s", \$2 }'`

    case $VC in
	2) if [ "D""$JDK_TOOLS_JAR" = "D" ]
	   then
            JDK_TOOLS_JAR=$JAVA_HOME/lib/jpda.jar
            LD_LIBRARY_PATH=$JAVA_HOME/lib/i386:$LD_LIBRARY_PATH
            export LD_LIBRARY_PATH
	   fi ;;
        3) JDK_TOOLS_JAR=$JAVA_HOME/lib/tools.jar ;;
    esac

    if [ ! -r $JDK_RT_JAR ]
    then
        echo Please be sure you have properly set the JDK_RT_JAR variable.
        echo The file $JDK_RT_JAR is not found.
        echo
        echo If you have any problems or questions, please contact
        echo "technical support (http://www.togethersoft.com/support/)"
        exit
    fi

    if [ ! -r $JDK_TOOLS_JAR ]
    then

	case $VC in
	    2) 	echo Please provide a valid path to jpda.jar by
                echo either configuring the file "$0" or defining the
                echo JDK_TOOLS_JAR environment variable from the command line.
                echo If you are running Solaris, make sure you have installed JPDA.
                echo
	        echo If you have any problems or questions, please contact
	        echo "technical support (http://www.togethersoft.com/support/)"
        	exit ;;


	    3)  echo Please be sure you have properly installed JDK 1.3.
	        echo The file $JDK_TOOLS_JAR is not found.
	        echo
	        echo If you have any problems or questions, please contact
	        echo "technical support (http://www.togethersoft.com/support/)"
	        exit ;;
	esac

    fi
fi

if [ -z "$TGH" ] ; then
    TGH=`dirname $0`/..
fi


PATH=$PATH:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib:../bin/linux/i686-unknown:../bin/sunos/sun4u-sparc:../bin/unix

#
# This command actually runs Together
#
if expr "`uname -s`" : "HP-UX" > /dev/null 2>&1; then
 hpfix="-Dhpux.im.disable=true -Xbootclasspath:$TGH/lib/pgup.jar:$JRE/lib/rt.jar"
fi


$JAVA $hpfix -Xms64m -Xmx512m \
-classpath $TGH/lib/gifs.zip:\
$TGH/out/classes:\
$TGH/modules:\
$TGH/lib/i18n:\
$TGH/lib/together.jar:\
$TGH/lib/openapi.jar:\
$TGH/lib/jgl.zip:\
$TGH/lib/jacl.jar:\
$TGH/lib/xml4j.jar:\
$TGH/lib/jcvs/application/jcvs.jar:\
$TGH/lib/tcljava.jar:\
$TGH/lib/misclib.zip:\
$TGH/lib/javax.jar:\
$TGH/lib/jcpagelayout401K.jar:\
$TGH/lib/jndi.jar:\
$TGH/lib/jhall.jar:\
$TGH/lib/pgup.jar:\
$TGH/help/together-help.jar:\
$JDK_TOOLS_JAR:\
$JDK_RT_JAR com.togethersoft.together.Main $*
