#!/bin/sh
#
# use "i386" or "ppc.*" - nake sure to use a regex for PPC!

architecture="ppc.*"
if arch | grep -v "$architecture"
then
    if arch | grep "i386"
    then
	# You have an intel mac error message
	exit 115
    else
	# PowerPC message
	exit 116
    fi
fi

# Check to make sure the computer is running 10.3 or later.

version=`uname -a | sed 's/.*Darwin Kernel Version \([0-9.]*\):.*/\1/'`
major=`echo $version | sed 's/\([0-9]\)\.\([0-9]\)\.\([0-9]\)/\1/'`
minor=`echo $version | sed 's/\([0-9]\)\.\([0-9]\)\.\([0-9]\)/\2/'`

if test $major -lt 7 -o $major -eq 7 -a $minor -lt 9
then
    # Warn and display message 16
    exit 112
fi

# Now check for libdap: first check that we can run the config script, then
# check the version that's installed.

if test -z "`dap-config --version 2> /dev/null`"
then
    # fail and display message 17
    exit 113
fi

version=`dap-config --version | sed 's/\([0-9.]*\) .*/\1/'`
major=`echo $version | sed 's/\([0-9]\)\.\([0-9]\)\.\([0-9]\)/\1/'`
minor=`echo $version | sed 's/\([0-9]\)\.\([0-9]\)\.\([0-9]\)/\2/'`

if test $major -lt 3 -o $major -eq 3 -a $minor -lt 8
then
    exit 113
fi

# Now check for bes: first check that we can run the config script, then
# check the version that's installed.

if test -z "`bes-config --version 2> /dev/null`"
then
    # bes does not need to be installed, so just exit
    exit 0
fi

version=`bes-config --version | sed 's/\([0-9.]*\) .*/\1/'`
major=`echo $version | sed 's/\([0-9]\)\.\([0-9]\)\.\([0-9]\)/\1/'`
minor=`echo $version | sed 's/\([0-9]\)\.\([0-9]\)\.\([0-9]\)/\2/'`

if test $major -lt 3 -o $major -eq 3 -a $minor -lt 6
then
    # fail and display message 18
    exit 114
fi

exit 0

