#!/bin/sh
# $Id: cfg-ncurses6,v 1.38 2022/04/09 15:35:49 tom Exp $
PACKAGE=ncurses
OPTS=
HERE=`partition`

MY_ABI=6
MY_DIR=/usr/local/ncurses6
MYDATA=/usr/local/ncurses/share/terminfo

case $HERE in
*debian*|*ubuntu*|*kfreebsd*)
	;;
fb*|nb*|ob*|*bsd*)
	OPTS="--with-hashed-db --enable-string-hacks"
	;;
esac

OPTS="$OPTS --disable-root-environ --disable-root-access"

if [ -z "$CFLAGS" ]
then
case $HERE in
*debian5-*)
	;;
*debian*|*ubuntu*|*kfreebsd*)
	case "$CC" in
	*gcc-stricter[345])
		FIX_FORT="sed -e 's/-D_FORTIFY_SOURCE=.//'"
		;;
	*)
		FIX_FORT="cat"
		;;
	esac
	CFLAGS=`dpkg-buildflags   --get CFLAGS   | $FIX_FORT`; export CFLAGS
	CXXFLAGS=`dpkg-buildflags --get CXXFLAGS | $FIX_FORT`; export CXXFLAGS
	CPPFLAGS=`dpkg-buildflags --get CPPFLAGS | $FIX_FORT`; export CPPFLAGS
	LDFLAGS=`dpkg-buildflags  --get LDFLAGS`;  export LDFLAGS
	OPTS="$OPTS --with-cxx-shared"
	;;
esac
fi

OPTS="$OPTS --enable-pthreads-eintr"

case $HERE in
nowhere)
	;;
*)
	OPTS="$OPTS --enable-weak-symbols"
	;;
esac

case $HERE in
*debian*|*fedora*|*suse*|*freebsd*|*netbsd*|*openbsd*)
	OPTS="$OPTS --with-versioned-syms"
	;;
esac

case $HERE in
*cygwin*)
	;;
*)
	OPTS="$OPTS --with-extra-suffix=$MY_ABI"
	;;
esac

case $HERE in
*bsd*)
	export RPATH_LIST=../lib:$MY_DIR/lib
	;;
esac

case "$*" in
*--with-termlib*)
	;;
*)
	CPPFLAGS="$CPPFLAGS -DEXP_XTERM_1005"
	export CPPFLAGS
	;;
esac

case $HERE in
*debianold*)
	OPTS="$OPTS --with-gpm --with-pcre2"
	;;
esac

case $HERE in
*cygwin*)
	# my stuff is in /usr/local; pkg-config is not there
	;;
*)
	OPTS="$OPTS --enable-pc-files"
	;;
esac

. with-cppcheck

cfg-ext-color $OPTS \
	--prefix=$MY_DIR \
	--program-suffix=$MY_ABI \
	--with-abi-version=$MY_ABI \
	--bindir=/usr/local/bin \
	--with-chtype=uint32_t \
	--enable-opaque-curses \
	--enable-opaque-form \
	--enable-opaque-menu \
	--enable-opaque-panel \
	--enable-sp-funcs \
	--enable-ext-mouse \
	--enable-ext-putwin \
	--enable-rpath \
	--enable-stdnoreturn \
	--enable-wgetch-events \
	--enable-xmc-glitch \
	--with-default-terminfo-dir=$MYDATA \
	--with-terminfo-dirs=$MYDATA:/usr/share/terminfo \
	--with-develop \
	$*
