#!/bin/sh
# $Id: cfg-normal,v 1.35 2023/01/20 21:58:18 tom Exp $
OUT=configure.out

case "$*" in
*enable-debug*)
	;;
*)
	case "${CC:-cc}" in
	c89|*/c89)
		CFLAGS="-O $CFLAGS"
		;;
	*)
		case "x`partition`" in
		*solaris10)
			echo "NOTE: optimization in gcc 3.4.3 is broken"
			CFLAGS="-O $CFLAGS"
			;;
		*)
			CFLAGS="-O2 $CFLAGS"
			;;
		esac
		;;
	esac
	;;
esac
export CFLAGS

rm -f config.log config.status config.cache ./*.out

OPTS=
case `pwd` in
*ncurses*)
	OPTS="\
	--enable-hard-tabs \
	--disable-termcap \
	--disable-getcap"
	;;
*lynx*|*xterm*)
	case "x`partition`" in
	*solaris*)
		MYPKG=/opt/dickey
		CPPFLAGS="$CPPFLAGS -I$MYPKG/include"
		LDFLAGS="$LDFLAGS -L$MYPKG/lib"
		PKG_CONFIG_PATH="$MYPKG/lib/pkgconfig"
		export CPPFLAGS
		export LDFLAGS
		export PKG_CONFIG_PATH
		;;
	esac
	;;
esac

if test -h .@ ; then
	OPTS="$OPTS --srcdir=.@"
fi

case ".$1" in
.cfg*)
eval "$*"
;;
*)
test -z "$ME" && ME=`partition 2>/dev/null`
cat >>$OUT <<EOF/
** `date`
** node: `hostname`
** node: $ME
** user: `id`
** conf: $*
EOF/

case .$SHELL in
.*/sh)
	;;
*)
	SHELL=/bin/sh
	test -f /usr/xpg4/bin/sh && SHELL=/usr/xpg4/bin/sh 
	;;
esac

export SHELL
CONFIG_SHELL=$SHELL
export CONFIG_SHELL

SRCDIR=.
SRCOPT=no
for i in "$@"
do
	case $i in
	--srcdir)
		SRCOPT=yes
		;;
	--srcdir=*)
		SRCDIR=`echo "x$i" | sed -e 's/^[^=]*=//'`
		SRCOPT=no
		;;
	*)
		test $SRCOPT = yes && SRCDIR=$i
		SRCOPT=no
		;;
	esac
done

$SHELL "$SRCDIR"/configure \
	--verbose \
	--disable-echo \
	--enable-warnings \
	--with-warnings \
	$OPTS \
	"$@" 2>&1 | tee -a $OUT
;;
esac
