dnl CF_NCURSES_ADDON version: 3 updated: 2010/10/23 15:54:49
dnl ----------------
dnl Configure an ncurses add-on, built outside the ncurses tree.
AC_DEFUN([CF_NCURSES_ADDON],[

AC_PROVIDE([CF_SUBST_NCURSES_VERSION])

AC_MSG_CHECKING(if you want wide-character code)
AC_ARG_ENABLE(widec,
	[  --enable-widec          compile with wide-char/UTF-8 code],
	[with_widec=$enableval],
	[with_widec=no])
AC_MSG_RESULT($with_widec)
if test "$with_widec" = yes ; then
	CF_UTF8_LIB 
	CF_NCURSES_CONFIG(ncursesw)
else
	CF_NCURSES_CONFIG(ncurses)
fi

if test "$NCURSES_CONFIG" != none ; then

cf_version=`$NCURSES_CONFIG --version`

NCURSES_MAJOR=`echo "$cf_version" | sed -e 's/\..*//'`
NCURSES_MINOR=`echo "$cf_version" | sed -e 's/^[[0-9]]\+\.//' -e 's/\..*//'`
NCURSES_PATCH=`echo "$cf_version" | sed -e 's/^[[0-9]]\+\.[[0-9]]\+\.//'`

# ABI version is not available from headers
cf_cv_abi_version=`$NCURSES_CONFIG --abi-version`

else

for cf_name in MAJOR MINOR PATCH
do
cat >conftest.$ac_ext <<CF_EOF
#include <${cf_cv_ncurses_header:-curses.h}>
AUTOCONF_$cf_name NCURSES_VERSION_$cf_name
CF_EOF
	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | fgrep AUTOCONF_$cf_name >conftest.out"
	AC_TRY_EVAL(cf_try)
	if test -f conftest.out ; then
		cf_result=`cat conftest.out | sed -e "s/^.*AUTOCONF_$cf_name[[ 	]]\+//"`
		eval NCURSES_$cf_name=$cf_result
		cat conftest.$ac_ext
		cat conftest.out
	fi
done

cf_cv_abi_version=${NCURSES_MAJOR}

fi

cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}

dnl Show the computed version, for logging
cf_cv_timestamp=`date`

AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))

dnl We need these values in the generated headers
AC_SUBST(NCURSES_MAJOR)
AC_SUBST(NCURSES_MINOR)
AC_SUBST(NCURSES_PATCH)

dnl We need these values in the generated makefiles
AC_SUBST(cf_cv_rel_version)
AC_SUBST(cf_cv_abi_version)

dnl FIXME - not needed for Ada95
AC_SUBST(cf_cv_builtin_bool)
AC_SUBST(cf_cv_header_stdbool_h)
AC_SUBST(cf_cv_type_of_bool)dnl

])
