#!/bin/sh
#
# This is the installation script for the USFS distribution
#

# You may need to edit the following variable definitions
# according to your environment
#
# set this to the base directory of the distribution
#
USFS=`pwd`;
export USFS;

# This variable describes machine name for solaris, but is not
# terribly portable. You can hardcode this value to something like
# Sparc_Solaris_2.6, i386_Solaris_2.6, i386_Linux_2.5.2, etc.
#
ISIP_BINARY=`uname -psr | awk '{ print $3"_"$1"_"$2 }'`;
export ISIP_BINARY;

# The C++ compiler
#
ISIP_CPLUS_COMPILER="gcc";
export ISIP_CPLUS_COMPILER;

ISIP_MAKE="gmake";
export ISIP_MAKE;

ISIP_LIBS="-lm";
export ISIP_LIBS;

# You should not edit anything beyond this point
#
PATH="$PATH:$USFS/bin/$ISIP_BINARY/:$USFS/bin/scripts/";
export PATH;

echo "starting installation";

# Make sure that the base directory exists, exit on error
#
if (test ! -d "$USFS") then
    echo "FATAL ERROR: base directory does not exist";
    echo "             please edit the INSTALL.sh script";
    exit;
fi

# make sure that a few important directories exist, building them if
# necessary
#
if (test ! -d "$USFS/lib/$ISIP_BINARY/") then
    echo "Creating library directory $USFS/lib/$ISIP_BINARY";
    mkdir "$USFS/lib/$ISIP_BINARY";
fi
if (test ! -d "$USFS/bin/$ISIP_BINARY/") then
    echo "Creating binary directory $USFS/bin/$ISIP_BINARY";
    mkdir "$USFS/bin/$ISIP_BINARY";
fi

echo "Installing the class libraries."

# build the class libraries
#
cd $USFS/class;
./Make.sh;

echo "Installing the utilities."

# build the utilities
#
cd $USFS/util;
./Make.sh;

cd $USFS;

# the installation is now complete, prompt the user
#
echo "The installation was successful."

# EOF
