#!/bin/sh
#
# This is the bootstrapping configuration script for Ganymede. The
# only thing we count on to run this script is that /bin/sh works.
#
# Get enough information from the user to be able to find Perl 5 and
# run scripts/configurator.perl.  We'll set a bunch of environment variables
# for configurator.perl to use to do its thing.
#
# Release: $Name: ganymede_107 $
# Version: $Revision: 1.13 $
# Last Mod Date: $Date: 2001/06/02 01:27:10 $
#
###############################################################################

echo "Ganymede configure script"
echo

# 
# Figure out how to do an echo without trailing newline
#

case "`echo 'x\c'`" in
'x\c')  echo="echo -n"   nnl= ;;       # BSD 
x)      echo="echo"      nnl="\c" ;;   # Sys V
*)      echo "$0 quitting: Can't set up echo." 1>&2; exit 1 ;;
esac

# Find the source files, if location was not specified.

# Try the directory containing this script, then its parent.

prog=$0

GROOTDIR=`echo $prog|sed 's%/[^/][^/]*$%%'`
# if the program name is the same as the srcdir name, we have no path
# set.. must be .
test "x$GROOTDIR" = "x$prog" && GROOTDIR=.
if test ! -d $GROOTDIR/src/classes; then
  echo "configure: error: can not find sources in $rootdir" 1>&2; exit 1;
fi
export GROOTDIR

# Find perl (GPERL)

guessperl=`which perl5`

 if test ! -r "$guessperl"; then
  guessperl=`which perl`
 fi

 if `$guessperl $GROOTDIR/scripts/versiontest.pl > /dev/null 2>&1`; then
	GPERL=$guessperl
    else
	$echo "Where is perl 5 installed? [$guessperl] ${nnl}" 

	read userperl

	if  test ! -z "$userperl"; then
	    GPERL=$userperl
	else
	    GPERL=$guessperl
	fi
 fi

export GPERL

# Find java

guessjava=`which java`
guessjava=`dirname ${guessjava}`

$echo "What is the location of the directory where java is installed? [$guessjava] ${nnl}"

read userjava

if  test ! -z "$userjava"; then
	GJAVA=$userjava
    else
	GJAVA=$guessjava
fi

export GJAVA

# Find swing libraries

guessswing="/opt/depot/swing-1.1.1"

$echo "Where are the Swing jar files located (only needed for JDK 1.1)? [$guessswing] ${nnl}"

read userswing

if  test ! -z "$userswing"; then
	GSWING=$userswing
    else
	GSWING=$guessswing
fi

export GSWING

# If we are in develop mode, ask where we want to put the generated
# class files.. this is so we can build the sources in the CVS tree
# while placing the .class files into another location out of the
# tree.

if [ "$1" = "-develop" ]
    then
    $echo "Where should the class files be located? ${nnl}"
    read GCLASSDIR
fi

# echo $GCLASSDIR
export GCLASSDIR


$GPERL $GROOTDIR/scripts/configurator.perl
