#!/bin/sh -x
# also:
# with-system-type=XXX
# with-shlib-version=X
if [ $# != 0 ]
then
	if [ ! -d $1 ] ; then
		echo "not a directory $1"
		exit 1
	fi
	OUT=build-opt-`partition`-`pd`.log
	cat >>$OUT <<EOF
** `date`
** run: $*
EOF
	( cd $1 && eval $0 2>&1 ) | tee -a $OUT
	exit
fi

mkdir -p options
for OPT in `all-opts-ncurses`
do
	if [ -e options/$OPT ] ; then
		echo SKIP options/$OPT
		continue
	fi
	echo MAKE $OPT
	OPTS="--$OPT"
	case "$OPT" in
	disable-database)
		OPTS="$OPTS --with-fallbacks=vt100"
		;;
	disable-libtool-version)
		OPTS="$OPTS --with-libtool"
		;;
	disable-tic-depends)
		OPTS="$OPTS --with-ticlib --with-shared"
		;;
	esac
	DST=`echo "$OPT" |sed -e 's@/@_@g'`
	clean-ncurses
	if ( cfg-shared $OPTS && make-out all )
	then
		touch options/$DST
	else
		cat *.out >options/$DST
	fi
done
