#!/bin/sh
# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
# Shell script to build an InterBase kit

if [ $# -lt 2 -o $# -gt 3 ]; then
    echo 'Usage: build_kit builds {SUPER | CLASSIC} [ccflags]'
    exit 1
fi

# The following no longer makes sense, since $1 is always builds, rather
# than the name of the platform.  Hence it has been commented out.
#    if [ $1 = 'SCO_EV' ]; then
#	MAKE=gmake
#    else
#	MAKE=make
#    fi
MAKE=make

if [ "`uname -s`" = "SunOS" ]; then
    LM_LICENSE_FILE='/etc/opt/licenses/licenses_combined'
    export LM_LICENSE_FILE
fi

CURDIR=`pwd`
HOSTNAME=`hostname | cut -d'.' -f1`
ISC_MSGS=$CURDIR/interbase/interbase.msg
INTERBASE=$CURDIR/interbase
export ISC_MSGS
export INTERBASE

if [ "`uname -s`" = "SunOS" ] ; then
    CC_PATH=/netapp/apps/lang/workshop/5.1/SUNWspro/bin
else if [ "`uname -sr`" = "HP-UX B.10.20" ]; then
    CC_PATH=/opt/softbench/bin
else
    CC_PATH=
fi
fi

#

LD_LIBRARY_PATH=$CURDIR/jrd:$CURDIR/interbase/lib
SHLIB_PATH=$CURDIR/jrd

export LD_LIBRARY_PATH
export SHLIB_PATH

PATH=.:/netapp/apps/isc/bin:$CURDIR/interbase/bin:/usr/interbase/bin:/usr/gds.${HOSTNAME}/bin:${CC_PATH}:/usr/ccs/bin:/bin:/usr/bin:$PATH
export PATH


#Build superserver if directory source/super exists
if [ $2 = SUPER ]; then
    GDS_SUPER="super_targets"
    export GDS_SUPER
fi
if [ $# = 2 ]; then
    $MAKE -f ./make_kit interbase SYSTEM=$1 SUPER_SERVER="$GDS_SUPER"
else
    $MAKE -f ./make_kit interbase CFLAGS="$3" SYSTEM=$1 SUPER_SERVER="$GDS_SUPER"
fi
#
STATUS=$?

rasu ./unset_prot builder

if [ $STATUS = 0 ]; then
    exit 0
else
    exit 1
fi
