+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl Check for data that is usually declared in <stdio.h> or <errno.h>
+dnl $1 = the name to check
+AC_DEFUN([CF_CHECK_ERRNO],
+[
+AC_MSG_CHECKING([declaration of $1])
+AC_CACHE_VAL(cf_cv_dcl_$1,[
+ AC_TRY_COMPILE([
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h> ],
+ [long x = (long) $1],
+ [eval 'cf_cv_dcl_'$1'=yes'],
+ [eval 'cf_cv_dcl_'$1'=no]')])
+eval 'cf_result=$cf_cv_dcl_'$1
+AC_MSG_RESULT($cf_result)
+
+# It's possible (for near-UNIX clones) that the data doesn't exist
+AC_CACHE_VAL(cf_cv_have_$1,[
+if test $cf_result = no ; then
+ eval 'cf_result=DECL_'$1
+ CF_UPPER(cf_result,$cf_result)
+ AC_DEFINE_UNQUOTED($cf_result)
+ AC_MSG_CHECKING([existence of $1])
+ AC_TRY_LINK([
+#undef $1
+extern long $1;
+],
+ [$1 = 2],
+ [eval 'cf_cv_have_'$1'=yes'],
+ [eval 'cf_cv_have_'$1'=no'])
+ eval 'cf_result=$cf_cv_have_'$1
+ AC_MSG_RESULT($cf_result)
+else
+ eval 'cf_cv_have_'$1'=yes'
+fi
+])
+eval 'cf_result=HAVE_'$1
+CF_UPPER(cf_result,$cf_result)
+eval 'test $cf_cv_have_'$1' = yes && AC_DEFINE_UNQUOTED($cf_result)'
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl Check if the terminal-capability database functions are available. If not,
+dnl ncurses has a much-reduced version.
+AC_DEFUN([CF_CGETENT],[
+AC_MSG_CHECKING(for terminal-capability database functions)
+AC_CACHE_VAL(cf_cv_cgetent,[
+AC_TRY_LINK([
+#include <stdlib.h>],[
+ char temp[128];
+ char *buf = temp;
+ char *db_array = temp;
+ cgetent(&buf, /* int *, */ &db_array, "vt100");
+ cgetcap(buf, "tc", '=');
+ cgetmatch(buf, "tc");
+ ],
+ [cf_cv_cgetent=yes],
+ [cf_cv_cgetent=no])
+])
+AC_MSG_RESULT($cf_cv_cgetent)
+test $cf_cv_cgetent = yes && AC_DEFINE(HAVE_BSD_CGETENT)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl Check if we're accidentally using a cache from a different machine.
+dnl Derive the system name, as a check for reusing the autoconf cache.
+dnl
+dnl If we've packaged config.guess and config.sub, run that (since it does a
+dnl better job than uname).
+AC_DEFUN([CF_CHECK_CACHE],
+[
+if test -f $srcdir/config.guess ; then
+ AC_CANONICAL_HOST
+ system_name="$host_os"
+else
+ system_name="`(uname -s -r) 2>/dev/null`"
+ if test -z "$system_name" ; then
+ system_name="`(hostname) 2>/dev/null`"
+ fi
+fi
+test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
+AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
+
+test -z "$system_name" && system_name="$cf_cv_system_name"
+test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name")
+
+if test ".$system_name" != ".$cf_cv_system_name" ; then
+ AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
+ AC_ERROR("Please remove config.cache and try again.")
+fi