#! /bin/sh
# Wrapper script to start up Tcl/Tk Wish 8.0 with tclBlend

# Do not edit this script unless it is called jwish.in.
# tclBlend/unix/configure takes jwish.in, substitutes the @xx@
# fields and creates jwish.

# Author:  Christopher Hylands
# Version: $Id: jwish.in,v 1.6 1998/11/07 02:17:16 hylands Exp $
#
# Copyright (c) 1997-1998 The Regents of the University of California.
# 	All Rights Reserved.
#
# Permission is hereby granted, without written agreement and without
# license or royalty fees, to use, copy, modify, and distribute this
# software and its documentation for any purpose, provided that the
# above copyright notice and the following two paragraphs appear in all
# copies of this software.
# 
# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
# ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
# THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# 
# THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
# PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
# CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
# ENHANCEMENTS, OR MODIFICATIONS.
# 
# 						PT_COPYRIGHT_VERSION_2
# 						COPYRIGHTENDKEY

# The next two lines gets substituted by configure
prefix=@prefix@
LIB_INSTALL_DIR=@exec_prefix@/lib

# Location of your tclBlend distribution
TCLBLEND=$LIB_INSTALL_DIR/tclblend@TCLJAVA_VERSION@

# Full path name of wish and tclsh
WISH80=@WISH80@
TCLSH80=@TCLSH80@


# The root of our java install
JAVA_DIR=@JAVA_DIR@

# The setting we will use for CLASSPATH
JAVA_CLASSPATH=@JAVA_CLASSPATH@


# The arch dependent directories
JAVA_ARCH_LIB=@JAVA_ARCH_LIB@
JAVA_ARCH_RUNTIME_LIBS=@JAVA_ARCH_RUNTIME_LIBS@:${JAVA_ARCH_LIB}:${LIB_INSTALL_DIR}




#################
# You probably don't want to edit below here
#################


# Make sure we can find the tclBlend directory so that we can do
#   package require java
if test ! -d $TCLBLEND ; then
    echo "$0: TCLBLEND was set to $TCLBLEND, which does not exist."
    echo " Please edit the value of TCLBLEND in the $0 script"
	exit 3
fi

# Check the value of JAVA_DIR
if test ! -d "$JAVA_DIR" ; then
    echo "$0: tclBlend was configured with '$JAVA_DIR', which"
    echo " does not seem to exist"
    exit 3
fi

#  Check that the main arch lib exists
if test ! -d $JAVA_ARCH_LIB ; then
    echo "$0: JAVA_ARCH_LIB does not exist or is not readable"
    echo " To use tclBlend under Solaris, you must install JDK1.1.4 "
    echo " and the native threads pack, along with a few OS patches"
    echo " see http://www.javasoft.com/products/jdk/1.1/index.html"
fi




# Set up our LD_LIBRARY_PATH or SHLIB_PATH
if test "`arch -s`" = "HP-UX" ; then
    SHLIB_PATH=${JAVA_ARCH_RUNTIME_LIBS}:${SHLIB_PATH}
    # Export these variables so the wish process can get at them. 
    export SHLIB_PATH CLASSPATH
else
    LD_LIBRARY_PATH=${JAVA_ARCH_RUNTIME_LIBS}:${LD_LIBRARY_PATH}
    
    # THREADS_FLAG tells java to use native threads, see README.ntp
    # in the native threads distribution.
    THREADS_FLAG=native

    # Export these variables so the wish process can get at them. 
    export LD_LIBRARY_PATH CLASSPATH THREADS_FLAG
fi    


# Set the TCLLIBPATH so that Tcl knows where to look for
# a "package require java"
if test "$TCLLIBPATH" = ""; then
    TCLLIBPATH="${TCLBLEND}"
else
    TCLLIBPATH="${TCLLIBPATH} ${TCLBLEND}"
fi
export TCLLIBPATH


# If the script is called as jtclsh, then use tclsh8.0, otherwise, use wish8.0
if test "`basename $0`" = "jtclsh" ; then
    WISH_OR_TCLSH=$TCLSH80
else
    WISH_OR_TCLSH=$WISH80
fi

# exec wish of tclsh with the env vars already set up
exec $WISH_OR_TCLSH ${1+"$@"}
