#!/bin/sh

## $Id$
##
## BEGIN LICENSE BLOCK
##
## Copyright (C) 2002  Damon Courtney
## 
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## version 2 as published by the Free Software Foundation.
## 
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License version 2 for more details.
## 
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the
##     Free Software Foundation, Inc.
##     51 Franklin Street, Fifth Floor
##     Boston, MA  02110-1301, USA.
##
## END LICENSE BLOCK

##
## Set this variable to the string that matches your platform if this script
## cannot find a suitable InstallKit binary.  A list of supported platforms
## can be found in the Binaries/ subdirectory.
##
PLATFORM=""

##
## This script attempts to find an installkit to start InstallJammer.
##

platform() {
    OS=`uname`
    MACHINE=`uname -m`

    case $MACHINE in
        *86)
            MACHINE=x86
            ;;
        *sun*)
            MACHINE=sparc
            ;;
        Power*)
            MACHINE=ppc
            ;;
    esac

    case $OS in
        AIX)
            PLATFORM=AIX-ppc
            ;;
        Darwin)
            PLATFORM="MacOS-X"
            ;;
        FreeBSD)
            VERSION=`uname -r | cut -f 1 -d .`
            PLATFORM=$OS-$VERSION-$MACHINE
            ;;
        HP-UX)
            PLATFORM=HPUX-hppa
            ;;
        IRIX*)
            PLATFORM=IRIX-mips
            ;;
        SunOS)
            PLATFORM=Solaris-$MACHINE
            ;;
        *MINGW*|*CYGWIN*)
            PLATFORM=Windows
            ;;
        *)
            PLATFORM=$OS-$MACHINE
            ;;
    esac
}

if test -z "$PLATFORM"; then
    platform
fi

INSTALLJAMMER_HOME=`dirname "$0"`

INSTALLKIT="$INSTALLJAMMER_HOME/Binaries/$PLATFORM/installkit"

if test ! -f "$INSTALLKIT"; then
    echo
    echo "Could not find an installkit for your platform '$PLATFORM'."
    echo "You must modify this script and define a platform at the top."
    echo
    exit 1
fi

chmod -f +x ${INSTALLKIT}
exec "${INSTALLKIT}" "${INSTALLJAMMER_HOME}/installjammer.tcl" $*
