#!/usr/bin/ksh
#
# $Header: mk,v 78.2 96/05/02 09:33:23 ssa Exp $
#
# Purpose:
#
#    interface to gnu make executable.  the palladium makefiles
#    support the following environment variables which are set
#    from this script:
#
#    VERBOSE:  if set, make commands are echoed
#    NOLIBCK:  if set, libraries are not checked during link of exe
#    DEPCK:    if set, header file dependencies are checked.
#    NOSHARED: if set, non shared libraries are linked
#
# Usage:
#
#    mk [-v] [-nl] [-d] [-b] [-g] [regular_make_options] [target ...]
#
#    -v   set VERBOSE
#    -nl  set NOLIBCK
#    -d   set DEPCK
#    -ns  set NOSHARED
#    -g   add -g to UOPT
#    -b   set ULDOPT to create a load map file: load.map
#    -gui set GUI so that gui shared libraries are referenced
#         in makefile instead of pd shared libraries.
#
export PATH=$PATH:/usr/local/bin
here=`pwd`
export UOPT


if [ $(uname) = HP-UX ]; then
    export OS="hpux"
    UOPT="-s -Wl,-Fw"
else
    export OS="aix"
fi

# #---------------------------------------------------------------------------
# # Added 18Sep95 by ssabat/jbralley.
# # Following sets up PDBASE after make.
# 
# if [ $(uname) = HP-UX ]; then
# typeset bn=$( basename $0 )
# export SRCDIR=/pd/$LOGNAME
# export PDBASE=$SRCDIR/pdbase
# export NLSPATH=$PDBASE/%N
# if [ ! -d $PDBASE/Pd ]; then
#     mkdir -p $PDBASE/Pd
#     if [ $? -ne 0 ]; then
#         printf "%s[%d]: mkdir $PDBASE/Pd failed...exiting...\n" $bn $LINENO
#         exit 1
#     fi
# fi
# cd $PDBASE
# ln -sf $SRCDIR/src/common/fpa.cat     fpa.cat
# ln -sf $SRCDIR/src/common/fpahelp.cat fpahelp.cat
# ln -sf $SRCDIR/oids                   oids
# cd Pd
# for f in $SRCDIR/src/oid/*.cat; do
#     ln -sf $f .
# done
# fi
# cd $SRCDIR

continue="T"
while [ $continue = "T" ]
do
	case $1 in
	#######################
	-O1) UOPT="$UOPT +O1"
		 echo "+O1 has been added to UOPT" ...
		 shift;;
	-O2) UOPT="$UOPT +O2"
		 echo "+O2 has been added to UOPT" ...
		 shift;;
	-O3) UOPT="$UOPT +O3"
		 echo "+O3 has been added to UOPT" ...
		 shift;;
	-O4) UOPT="$UOPT +O4"
		 echo "+O4 has been added to UOPT" ...
		 shift;;
	#######################
	-v) export VERBOSE=1
		echo "Using VERBOSE ..."
		shift;;
	-b) export ULDOPT=-bloadmap:load.map
		echo "Creating loadmap: load.map" ...
		shift;;
	-g) UOPT=" -g"
		 echo "-g has been added to UOPT" ...
		 shift;;
	-nl) export NOLIBCK=1
		echo "Using NOLIBCK ..."
		shift;;
	-ns) export NOSHARED=1
		echo "Using NOSHARED ..."
		shift;;
	-d) export DEPCK=1
		echo "Using DEPCK ..."
		shift;;
	-gui) export GUI=1
		echo "Using GUI shared libraries ..."
		shift;;
	*) continue="F"
	esac
done

# call the gnu make tool passing remaining arguments on
/usr/local/bin/gmake $*
return $?
