dnl CF_CURSES_CHECK_DATA version: 4 updated: 2011/01/15 16:39:24
dnl --------------------
dnl Check if curses.h defines the given data/variable.
dnl Use this after CF_NCURSES_CONFIG or CF_CURSES_CONFIG.
AC_DEFUN([CF_CURSES_CHECK_DATA],
[
AC_MSG_CHECKING(for data $1 declaration in ${cf_cv_ncurses_header:-curses.h})

AC_TRY_COMPILE(CF__CURSES_HEAD,[
void *foo = &($1)
],cf_result=yes,cf_result=no)
AC_MSG_RESULT($cf_result)

if test $cf_result = yes ; then
	CF_UPPER(cf_result,have_curses_data_$1)
	AC_DEFINE_UNQUOTED($cf_result)
else
	AC_MSG_CHECKING(for data $1 in library)
	# BSD linkers insist on making weak linkage, but resolve at runtime.
	AC_TRY_RUN(CF__CURSES_HEAD
[
extern char $1;
int main(void)
{
	void *foo = &($1);
	${cf_cv_main_return:-return}(foo == 0);
}],[cf_result=yes],[cf_result=no],[
	# cross-compiling
	AC_TRY_LINK(CF__CURSES_HEAD
[extern char $1;],[
	do {
		void *foo = &($1);
		${cf_cv_main_return:-return}(foo == 0);
	} while (0)
],[cf_result=yes],[cf_result=no])
])
	AC_MSG_RESULT($cf_result)
	if test $cf_result = yes ; then
		CF_UPPER(cf_result,decl_curses_data_$1)
		AC_DEFINE_UNQUOTED($cf_result)
	fi
fi
])dnl
