#! /bin/sh

sw=/nfs/cxc/a1
swarch=$sw/$ARCH
SLANG_PREFIX=$swarch
PKG_CONFIG=/nfs/cxc/a1/$ARCH/opt/bin

while getopts c:p:s:S: opt 2>/dev/null ; do
  case $opt in
	c) PKG_CONFIG=$OPTARG
	   PKG_CONFIG_OVERRIDE=1
	   PATH=$OPTARG:$PATH
	   ;;
	p) prefix=$OPTARG
	   if test -z "$PKG_CONFIG_OVERRIDE" ; then
		PKG_CONFIG=$prefix/bin
	   fi
	   if test -z "$CFLAGS" ; then
		CFLAGS=-O2
	   fi
	   ;;
	s) SLANG_PREFIX=$OPTARG
	   ;;
	S) SLIRP=--with-slirp=$OPTARG
	   ;;
  esac
done
shift `expr $OPTIND - 1`

if [ -z "$prefix" ] ; then
   if [ ! -d CVS ] || [ -n "$CFLAGS" ] ; then
	prefix=$swarch
	if [ "$CFLAGS" = "" ] ; then 
	   CFLAGS=-O2	# Ensure local release builds have no -g debug info
	fi
   else
	CFLAGS=-g	# Ensure that development builds DO have -g debug info
	prefix=$sw/src/slgtk/slgtk-`cat VERSION`
	SLGTK_DEVEL_BUILD=true
   fi
fi
export CFLAGS SLGTK_DEVEL_BUILD

make distclean >/dev/null 2>&1

/bin/sh admin/gtk-configure $prefix \
	--config-cache \
	--with-pkgconfig=$PKG_CONFIG \
	--with-slang=$SLANG_PREFIX \
	--with-gtk-static=$HOME/install/$ARCH \
	$SLIRP \
	"$@"
