#! /bin/sh
#	Driver script for Saber-C 2.1
#	Copyright (C) 1989 by Saber Software, Inc.
#
# $Header: saber.src,v 1.2 89/06/09 08:22:33 raeburn Exp $
# $Source: /u3/saber.2.1/saber_dir/common/RCS/saber.src,v $
#

# These parameters are set by the installation procedure.
SABER_DIR=NotInstalledCorrectly
ARCH=NotInstalledCorrectly
MANAGER=NotInstalledCorrectly

EXEC=saber_exec
# Don't depend on user's PATH.  Leave PATH unexported, so that the user
# program gets it unmodified.
PATH=/bin:/usr/bin:/usr/ucb

case $ARCH in
sun3 )	if [ -f /usr/lib/ld.so ]; then DIR=sun3-40; else DIR=sun3-35; fi ;;
sun4 )	if [ -f /usr/lib/ld.so ]; then DIR=sun4-40; else DIR=sun4-32; fi ;;
sun386 ) DIR=sun386-40 ;;
vax-bsd ) DIR=vax-bsd43 ;;
rt-bsd ) DIR=rt-bsd43 ;;
vax-ultrix )
	# This was the toughie.
	if [ -f /usr/include/sys/dyntypes.h -a -f /usr/include/capsar.h ]; then
		DIR=vax-ultrix30
	elif [ -f /usr/include/sys/dyntypes.h -o -f /usr/include/capsar.h ]; then
		>&2 echo \
"saber startup script: warning: assuming Ultrix 3.0 rather than 2.x, but not sure."
		DIR=vax-ultrix30
	else
		DIR=vax-ultrix23
	fi
	;;
* )	>&2 echo "$0 startup script internal error: $ARCH is unknown"
	exit 2
	;;
esac
D=$SABER_DIR/$DIR

# Test error conditions.
if [ ! -d $D -o ! -d $D/bin -o ! -f $D/bin/$MANAGER -o ! -f $D/bin/$EXEC ]
then
	if [ ! -d $SABER_DIR ]; then
		>&2 echo \
"saber startup script: error: directory '$SABER_DIR'
does not exist.  It should be the directory that contains Saber-C
binaries and support files.  Your system administrator should reinstall
Saber-C, being careful to specify a universal path that is good on all
clients of the file server."
	elif [ ! -d $D ]; then
		>&2 echo \
"saber startup script: error: directory '$D',
which contains the binaries and support files for this
architecture/operating system combination, does not exist.
Your system administrator should install this directory."
	else
		>&2 echo \
"saber startup script: directory '$D' exists
but is not set up correctly.  (It should contain 'bin/$MANAGER' and
'bin/$EXEC', but it doesn't.)  Your system administrator should
reinstall this directory."
	fi
	exit 2
fi

# Compensate for bug in "$@" in Ultrix sh.
case $# in
0 )	exec $D/bin/$MANAGER $D/bin/$EXEC -h$D
	;;
* )	exec $D/bin/$MANAGER $D/bin/$EXEC -h$D "$@"
	;;
esac
