]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/configure
ncurses 6.0 - patch 20171223
[ncurses.git] / test / configure
index f12396bd386fc538111c031491f58d0ac3c40f0c..db06cad17c42a20bc69f5fecf0e0821aae579983 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by Autoconf 2.52.20150926.
+# Generated by Autoconf 2.52.20170501.
 #
 # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
 # Free Software Foundation, Inc.
@@ -646,14 +646,15 @@ if test -n "$ac_init_help"; then
 
   cat <<\EOF
 
-Optional Packages:
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-
 Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
 
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+
+  --enable-string-hacks   work around bogus compiler/loader warnings
 General Options:
   --with-pkg-config{=path} enable/disable use of pkg-config
   --disable-echo          do not display "compiling" commands
@@ -672,6 +673,10 @@ Curses Version-dependent Options:
   --with-neXtaw           link with neXT Athena library
   --with-XawPlus          link with Athena-Plus library
   --with-x                use the X Window System
+  --with-x11-rgb=FILE   file containing X11 rgb information (EPREFIX/lib/X11/rgb.txt)
+  --disable-panel         disable checks for panel functions
+  --disable-menu          disable checks for menu functions
+  --disable-form          disable checks for form functions
 Testing/development Options:
   --enable-warnings       test: turn on gcc compiler warnings
   --with-dmalloc          test: use Gray Watson's dmalloc library
@@ -748,7 +753,7 @@ This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.52.20150926.  Invocation command line was
+generated by GNU Autoconf 2.52.20170501.  Invocation command line was
 
   $ $0 $@
 
@@ -872,7 +877,7 @@ if test -z "$CONFIG_SITE"; then
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
-    { echo "$as_me:875: loading site script $ac_site_file" >&5
+    { echo "$as_me:880: loading site script $ac_site_file" >&5
 echo "$as_me: loading site script $ac_site_file" >&6;}
     cat "$ac_site_file" >&5
     . "$ac_site_file"
@@ -883,7 +888,7 @@ if test -r "$cache_file"; then
   # Some versions of bash will fail to source /dev/null (special
   # files actually), so we avoid doing that.
   if test -f "$cache_file"; then
-    { echo "$as_me:886: loading cache $cache_file" >&5
+    { echo "$as_me:891: loading cache $cache_file" >&5
 echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . $cache_file;;
@@ -891,7 +896,7 @@ echo "$as_me: loading cache $cache_file" >&6;}
     esac
   fi
 else
-  { echo "$as_me:894: creating cache $cache_file" >&5
+  { echo "$as_me:899: creating cache $cache_file" >&5
 echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
@@ -907,21 +912,21 @@ for ac_var in `(set) 2>&1 |
   eval ac_new_val="\$ac_env_${ac_var}_value"
   case $ac_old_set,$ac_new_set in
     set,)
-      { echo "$as_me:910: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+      { echo "$as_me:915: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { echo "$as_me:914: error: \`$ac_var' was not set in the previous run" >&5
+      { echo "$as_me:919: error: \`$ac_var' was not set in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
-        { echo "$as_me:920: error: \`$ac_var' has changed since the previous run:" >&5
+        { echo "$as_me:925: error: \`$ac_var' has changed since the previous run:" >&5
 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-        { echo "$as_me:922:   former value:  $ac_old_val" >&5
+        { echo "$as_me:927:   former value:  $ac_old_val" >&5
 echo "$as_me:   former value:  $ac_old_val" >&2;}
-        { echo "$as_me:924:   current value: $ac_new_val" >&5
+        { echo "$as_me:929:   current value: $ac_new_val" >&5
 echo "$as_me:   current value: $ac_new_val" >&2;}
         ac_cache_corrupted=:
       fi;;
@@ -940,9 +945,9 @@ echo "$as_me:   current value: $ac_new_val" >&2;}
   fi
 done
 if $ac_cache_corrupted; then
-  { echo "$as_me:943: error: changes in the environment can compromise the build" >&5
+  { echo "$as_me:948: error: changes in the environment can compromise the build" >&5
 echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  { { echo "$as_me:945: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+  { { echo "$as_me:950: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -963,10 +968,10 @@ esac
 echo "#! $SHELL" >conftest.sh
 echo  "exit 0"   >>conftest.sh
 chmod +x conftest.sh
-if { (echo "$as_me:966: PATH=\".;.\"; conftest.sh") >&5
+if { (echo "$as_me:971: PATH=\".;.\"; conftest.sh") >&5
   (PATH=".;."; conftest.sh) 2>&5
   ac_status=$?
-  echo "$as_me:969: \$? = $ac_status" >&5
+  echo "$as_me:974: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   ac_path_separator=';'
 else
@@ -998,7 +1003,7 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:1001: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+  { { echo "$as_me:1006: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1008,11 +1013,11 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
 
 # Make sure we can run config.sub.
 $ac_config_sub sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:1011: error: cannot run $ac_config_sub" >&5
+  { { echo "$as_me:1016: error: cannot run $ac_config_sub" >&5
 echo "$as_me: error: cannot run $ac_config_sub" >&2;}
    { (exit 1); exit 1; }; }
 
-echo "$as_me:1015: checking build system type" >&5
+echo "$as_me:1020: checking build system type" >&5
 echo $ECHO_N "checking build system type... $ECHO_C" >&6
 if test "${ac_cv_build+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1021,16 +1026,16 @@ else
 test -z "$ac_cv_build_alias" &&
   ac_cv_build_alias=`$ac_config_guess`
 test -z "$ac_cv_build_alias" &&
-  { { echo "$as_me:1024: error: cannot guess build type; you must specify one" >&5
+  { { echo "$as_me:1029: error: cannot guess build type; you must specify one" >&5
 echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
    { (exit 1); exit 1; }; }
 ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
-  { { echo "$as_me:1028: error: $ac_config_sub $ac_cv_build_alias failed." >&5
+  { { echo "$as_me:1033: error: $ac_config_sub $ac_cv_build_alias failed." >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1033: result: $ac_cv_build" >&5
+echo "$as_me:1038: result: $ac_cv_build" >&5
 echo "${ECHO_T}$ac_cv_build" >&6
 build=$ac_cv_build
 build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
@@ -1038,7 +1043,7 @@ build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
-       echo "$as_me:1041: checking host system type" >&5
+       echo "$as_me:1046: checking host system type" >&5
 echo $ECHO_N "checking host system type... $ECHO_C" >&6
 if test "${ac_cv_host+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1047,12 +1052,12 @@ else
 test -z "$ac_cv_host_alias" &&
   ac_cv_host_alias=$ac_cv_build_alias
 ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
-  { { echo "$as_me:1050: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+  { { echo "$as_me:1055: error: $ac_config_sub $ac_cv_host_alias failed" >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1055: result: $ac_cv_host" >&5
+echo "$as_me:1060: result: $ac_cv_host" >&5
 echo "${ECHO_T}$ac_cv_host" >&6
 host=$ac_cv_host
 host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
@@ -1078,13 +1083,13 @@ else
 fi
 
 test -z "$system_name" && system_name="$cf_cv_system_name"
-test -n "$cf_cv_system_name" && echo "$as_me:1081: result: Configuring for $cf_cv_system_name" >&5
+test -n "$cf_cv_system_name" && echo "$as_me:1086: result: Configuring for $cf_cv_system_name" >&5
 echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6
 
 if test ".$system_name" != ".$cf_cv_system_name" ; then
-       echo "$as_me:1085: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
+       echo "$as_me:1090: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
 echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6
-       { { echo "$as_me:1087: error: \"Please remove config.cache and try again.\"" >&5
+       { { echo "$as_me:1092: error: \"Please remove config.cache and try again.\"" >&5
 echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1102,7 +1107,7 @@ _ACEOF
 program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
 rm conftest.sed
 
-echo "$as_me:1105: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "$as_me:1110: checking whether ${MAKE-make} sets \${MAKE}" >&5
 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
 if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
@@ -1122,11 +1127,11 @@ fi
 rm -f conftest.make
 fi
 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$as_me:1125: result: yes" >&5
+  echo "$as_me:1130: result: yes" >&5
 echo "${ECHO_T}yes" >&6
   SET_MAKE=
 else
-  echo "$as_me:1129: result: no" >&5
+  echo "$as_me:1134: result: no" >&5
 echo "${ECHO_T}no" >&6
   SET_MAKE="MAKE=${MAKE-make}"
 fi
@@ -1140,7 +1145,7 @@ ac_main_return=return
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:1143: checking for $ac_word" >&5
+echo "$as_me:1148: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1155,7 +1160,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="${ac_tool_prefix}gcc"
-echo "$as_me:1158: found $ac_dir/$ac_word" >&5
+echo "$as_me:1163: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1163,10 +1168,10 @@ fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1166: result: $CC" >&5
+  echo "$as_me:1171: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1169: result: no" >&5
+  echo "$as_me:1174: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1175,7 +1180,7 @@ if test -z "$ac_cv_prog_CC"; then
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-echo "$as_me:1178: checking for $ac_word" >&5
+echo "$as_me:1183: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1190,7 +1195,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="gcc"
-echo "$as_me:1193: found $ac_dir/$ac_word" >&5
+echo "$as_me:1198: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1198,10 +1203,10 @@ fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1201: result: $ac_ct_CC" >&5
+  echo "$as_me:1206: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1204: result: no" >&5
+  echo "$as_me:1209: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1214,7 +1219,7 @@ if test -z "$CC"; then
   if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:1217: checking for $ac_word" >&5
+echo "$as_me:1222: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1229,7 +1234,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="${ac_tool_prefix}cc"
-echo "$as_me:1232: found $ac_dir/$ac_word" >&5
+echo "$as_me:1237: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1237,10 +1242,10 @@ fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1240: result: $CC" >&5
+  echo "$as_me:1245: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1243: result: no" >&5
+  echo "$as_me:1248: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1249,7 +1254,7 @@ if test -z "$ac_cv_prog_CC"; then
   ac_ct_CC=$CC
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:1252: checking for $ac_word" >&5
+echo "$as_me:1257: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1264,7 +1269,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="cc"
-echo "$as_me:1267: found $ac_dir/$ac_word" >&5
+echo "$as_me:1272: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1272,10 +1277,10 @@ fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1275: result: $ac_ct_CC" >&5
+  echo "$as_me:1280: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1278: result: no" >&5
+  echo "$as_me:1283: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1288,7 +1293,7 @@ fi
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:1291: checking for $ac_word" >&5
+echo "$as_me:1296: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1308,7 +1313,7 @@ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
   continue
 fi
 ac_cv_prog_CC="cc"
-echo "$as_me:1311: found $ac_dir/$ac_word" >&5
+echo "$as_me:1316: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1330,10 +1335,10 @@ fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1333: result: $CC" >&5
+  echo "$as_me:1338: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1336: result: no" >&5
+  echo "$as_me:1341: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1344,7 +1349,7 @@ if test -z "$CC"; then
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:1347: checking for $ac_word" >&5
+echo "$as_me:1352: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1359,7 +1364,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-echo "$as_me:1362: found $ac_dir/$ac_word" >&5
+echo "$as_me:1367: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1367,10 +1372,10 @@ fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1370: result: $CC" >&5
+  echo "$as_me:1375: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1373: result: no" >&5
+  echo "$as_me:1378: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1383,7 +1388,7 @@ if test -z "$CC"; then
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:1386: checking for $ac_word" >&5
+echo "$as_me:1391: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1398,7 +1403,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="$ac_prog"
-echo "$as_me:1401: found $ac_dir/$ac_word" >&5
+echo "$as_me:1406: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1406,10 +1411,10 @@ fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1409: result: $ac_ct_CC" >&5
+  echo "$as_me:1414: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1412: result: no" >&5
+  echo "$as_me:1417: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1421,36 +1426,36 @@ fi
 
 fi
 
-test -z "$CC" && { { echo "$as_me:1424: error: no acceptable cc found in \$PATH" >&5
+test -z "$CC" && { { echo "$as_me:1429: error: no acceptable cc found in \$PATH" >&5
 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
    { (exit 1); exit 1; }; }
 
 # Provide some information about the compiler.
-echo "$as_me:1429:" \
+echo "$as_me:1434:" \
      "checking for C compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:1432: \"$ac_compiler --version </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1437: \"$ac_compiler --version </dev/null >&5\"") >&5
   (eval $ac_compiler --version </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1435: \$? = $ac_status" >&5
+  echo "$as_me:1440: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:1437: \"$ac_compiler -v </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1442: \"$ac_compiler -v </dev/null >&5\"") >&5
   (eval $ac_compiler -v </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1440: \$? = $ac_status" >&5
+  echo "$as_me:1445: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:1442: \"$ac_compiler -V </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1447: \"$ac_compiler -V </dev/null >&5\"") >&5
   (eval $ac_compiler -V </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1445: \$? = $ac_status" >&5
+  echo "$as_me:1450: \$? = $ac_status" >&5
   (exit $ac_status); }
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 1449 "configure"
+#line 1454 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -1462,13 +1467,13 @@ ac_clean_files="$ac_clean_files a.out a.exe"
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-echo "$as_me:1465: checking for C compiler default output" >&5
+echo "$as_me:1470: checking for C compiler default output" >&5
 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:1468: \"$ac_link_default\"") >&5
+if { (eval echo "$as_me:1473: \"$ac_link_default\"") >&5
   (eval $ac_link_default) 2>&5
   ac_status=$?
-  echo "$as_me:1471: \$? = $ac_status" >&5
+  echo "$as_me:1476: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   # Find the output, starting from the most likely.  This scheme is
 # not robust to junk in `.', hence go to wildcards (a.*) only as a last
@@ -1491,34 +1496,34 @@ done
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-{ { echo "$as_me:1494: error: C compiler cannot create executables" >&5
+{ { echo "$as_me:1499: error: C compiler cannot create executables" >&5
 echo "$as_me: error: C compiler cannot create executables" >&2;}
    { (exit 77); exit 77; }; }
 fi
 
 ac_exeext=$ac_cv_exeext
-echo "$as_me:1500: result: $ac_file" >&5
+echo "$as_me:1505: result: $ac_file" >&5
 echo "${ECHO_T}$ac_file" >&6
 
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1505: checking whether the C compiler works" >&5
+echo "$as_me:1510: checking whether the C compiler works" >&5
 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
   if { ac_try='./$ac_file'
-  { (eval echo "$as_me:1511: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1516: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1514: \$? = $ac_status" >&5
+  echo "$as_me:1519: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
        cross_compiling=yes
     else
-       { { echo "$as_me:1521: error: cannot run C compiled programs.
+       { { echo "$as_me:1526: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'." >&5
 echo "$as_me: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'." >&2;}
@@ -1526,24 +1531,24 @@ If you meant to cross compile, use \`--host'." >&2;}
     fi
   fi
 fi
-echo "$as_me:1529: result: yes" >&5
+echo "$as_me:1534: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
 rm -f a.out a.exe conftest$ac_cv_exeext
 ac_clean_files=$ac_clean_files_save
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1536: checking whether we are cross compiling" >&5
+echo "$as_me:1541: checking whether we are cross compiling" >&5
 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:1538: result: $cross_compiling" >&5
+echo "$as_me:1543: result: $cross_compiling" >&5
 echo "${ECHO_T}$cross_compiling" >&6
 
-echo "$as_me:1541: checking for executable suffix" >&5
+echo "$as_me:1546: checking for executable suffix" >&5
 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
-if { (eval echo "$as_me:1543: \"$ac_link\"") >&5
+if { (eval echo "$as_me:1548: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:1546: \$? = $ac_status" >&5
+  echo "$as_me:1551: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
@@ -1559,29 +1564,29 @@ for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
   esac
 done
 else
-  { { echo "$as_me:1562: error: cannot compute EXEEXT: cannot compile and link" >&5
+  { { echo "$as_me:1567: error: cannot compute EXEEXT: cannot compile and link" >&5
 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 rm -f conftest$ac_cv_exeext
-echo "$as_me:1568: result: $ac_cv_exeext" >&5
+echo "$as_me:1573: result: $ac_cv_exeext" >&5
 echo "${ECHO_T}$ac_cv_exeext" >&6
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-echo "$as_me:1574: checking for object suffix" >&5
+echo "$as_me:1579: checking for object suffix" >&5
 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
 if test "${ac_cv_objext+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1580 "configure"
+#line 1585 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -1589,10 +1594,10 @@ main ()
 }
 _ACEOF
 rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:1592: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1597: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1595: \$? = $ac_status" >&5
+  echo "$as_me:1600: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
   case $ac_file in
@@ -1604,28 +1609,28 @@ done
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-{ { echo "$as_me:1607: error: cannot compute OBJEXT: cannot compile" >&5
+{ { echo "$as_me:1612: error: cannot compute OBJEXT: cannot compile" >&5
 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-echo "$as_me:1614: result: $ac_cv_objext" >&5
+echo "$as_me:1619: result: $ac_cv_objext" >&5
 echo "${ECHO_T}$ac_cv_objext" >&6
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-echo "$as_me:1618: checking whether we are using the GNU C compiler" >&5
+echo "$as_me:1623: checking whether we are using the GNU C compiler" >&5
 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
 if test "${ac_cv_c_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1624 "configure"
+#line 1629 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 #ifndef __GNUC__
        choke me
@@ -1636,16 +1641,16 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1639: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1644: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1642: \$? = $ac_status" >&5
+  echo "$as_me:1647: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1645: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1650: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1648: \$? = $ac_status" >&5
+  echo "$as_me:1653: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_compiler_gnu=yes
 else
@@ -1657,23 +1662,23 @@ rm -f conftest.$ac_objext conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:1660: result: $ac_cv_c_compiler_gnu" >&5
+echo "$as_me:1665: result: $ac_cv_c_compiler_gnu" >&5
 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
 GCC=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
 CFLAGS="-g"
-echo "$as_me:1666: checking whether $CC accepts -g" >&5
+echo "$as_me:1671: checking whether $CC accepts -g" >&5
 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1672 "configure"
+#line 1677 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -1681,16 +1686,16 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1684: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1689: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1687: \$? = $ac_status" >&5
+  echo "$as_me:1692: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1690: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1695: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1693: \$? = $ac_status" >&5
+  echo "$as_me:1698: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_prog_cc_g=yes
 else
@@ -1700,7 +1705,7 @@ ac_cv_prog_cc_g=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:1703: result: $ac_cv_prog_cc_g" >&5
+echo "$as_me:1708: result: $ac_cv_prog_cc_g" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
@@ -1727,16 +1732,16 @@ cat >conftest.$ac_ext <<_ACEOF
 #endif
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1730: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1735: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1733: \$? = $ac_status" >&5
+  echo "$as_me:1738: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1736: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1741: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1739: \$? = $ac_status" >&5
+  echo "$as_me:1744: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   for ac_declaration in \
    ''\
@@ -1748,12 +1753,12 @@ if { (eval echo "$as_me:1730: \"$ac_compile\"") >&5
    'void exit (int);'
 do
   cat >conftest.$ac_ext <<_ACEOF
-#line 1751 "configure"
+#line 1756 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 $ac_declaration
 int
-main ()
+main (void)
 {
 exit (42);
   ;
@@ -1761,16 +1766,16 @@ exit (42);
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1764: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1769: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1767: \$? = $ac_status" >&5
+  echo "$as_me:1772: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1770: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1775: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1773: \$? = $ac_status" >&5
+  echo "$as_me:1778: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -1780,11 +1785,11 @@ continue
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
   cat >conftest.$ac_ext <<_ACEOF
-#line 1783 "configure"
+#line 1788 "configure"
 #include "confdefs.h"
 $ac_declaration
 int
-main ()
+main (void)
 {
 exit (42);
   ;
@@ -1792,16 +1797,16 @@ exit (42);
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1795: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1800: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1798: \$? = $ac_status" >&5
+  echo "$as_me:1803: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1801: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1806: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1804: \$? = $ac_status" >&5
+  echo "$as_me:1809: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   break
 else
@@ -1831,15 +1836,15 @@ ac_main_return=return
 
 GCC_VERSION=none
 if test "$GCC" = yes ; then
-       echo "$as_me:1834: checking version of $CC" >&5
+       echo "$as_me:1839: checking version of $CC" >&5
 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
        GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
        test -z "$GCC_VERSION" && GCC_VERSION=unknown
-       echo "$as_me:1838: result: $GCC_VERSION" >&5
+       echo "$as_me:1843: result: $GCC_VERSION" >&5
 echo "${ECHO_T}$GCC_VERSION" >&6
 fi
 
-echo "$as_me:1842: checking for $CC option to accept ANSI C" >&5
+echo "$as_me:1847: checking for $CC option to accept ANSI C" >&5
 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1847,7 +1852,7 @@ else
   ac_cv_prog_cc_stdc=no
 ac_save_CC=$CC
 cat >conftest.$ac_ext <<_ACEOF
-#line 1850 "configure"
+#line 1855 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 #include <stdio.h>
@@ -1878,7 +1883,7 @@ int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, i
 int argc;
 char **argv;
 int
-main ()
+main (void)
 {
 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
   ;
@@ -1896,16 +1901,16 @@ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIO
 do
   CC="$ac_save_CC $ac_arg"
   rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1899: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1904: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1902: \$? = $ac_status" >&5
+  echo "$as_me:1907: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1905: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1910: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1908: \$? = $ac_status" >&5
+  echo "$as_me:1913: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_prog_cc_stdc=$ac_arg
 break
@@ -1922,10 +1927,10 @@ fi
 
 case "x$ac_cv_prog_cc_stdc" in
   x|xno)
-    echo "$as_me:1925: result: none needed" >&5
+    echo "$as_me:1930: result: none needed" >&5
 echo "${ECHO_T}none needed" >&6 ;;
   *)
-    echo "$as_me:1928: result: $ac_cv_prog_cc_stdc" >&5
+    echo "$as_me:1933: result: $ac_cv_prog_cc_stdc" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
     CC="$CC $ac_cv_prog_cc_stdc" ;;
 esac
@@ -1933,24 +1938,29 @@ esac
 # This should have been defined by AC_PROG_CC
 : ${CC:=cc}
 
-echo "$as_me:1936: checking \$CC variable" >&5
+echo "$as_me:1941: checking \$CC variable" >&5
 echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6
 case "$CC" in
 (*[\ \ ]-*)
-       echo "$as_me:1940: result: broken" >&5
+       echo "$as_me:1945: result: broken" >&5
 echo "${ECHO_T}broken" >&6
-       { echo "$as_me:1942: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5
+       { echo "$as_me:1947: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5
 echo "$as_me: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;}
        # humor him...
-       cf_flags=`echo "$CC" | sed -e 's/^[^    ]*[     ][      ]*//'`
-       CC=`echo "$CC " | sed -e 's/[   ]-[IUD][^       ][^     ]*//g' -e 's/[  ]*$//'`
+       cf_prog=`echo "$CC" | sed -e 's/        / /g' -e 's/[ ]* / /g' -e 's/[ ]*[ ]-[^ ].*//'`
+       cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", substr($0,1+length(prog))); }'`
+       CC="$cf_prog"
+       for cf_arg in $cf_flags
+       do
+               case "x$cf_arg" in
+               (x-[IUDfgOW]*)
 
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_flags
+for cf_add_cflags in $cf_arg
 do
 case $cf_fix_cppflags in
 (no)
@@ -1965,10 +1975,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -1987,17 +2003,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -2010,45 +2034,109 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
+                       ;;
+               (*)
+                       CC="$CC $cf_arg"
+                       ;;
+               esac
+       done
        test -n "$verbose" && echo "    resulting CC: '$CC'" 1>&6
 
-echo "${as_me:-configure}:2028: testing resulting CC: '$CC' ..." 1>&5
+echo "${as_me:-configure}:2064: testing resulting CC: '$CC' ..." 1>&5
 
        test -n "$verbose" && echo "    resulting CFLAGS: '$CFLAGS'" 1>&6
 
-echo "${as_me:-configure}:2032: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5
+echo "${as_me:-configure}:2068: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5
 
        test -n "$verbose" && echo "    resulting CPPFLAGS: '$CPPFLAGS'" 1>&6
 
-echo "${as_me:-configure}:2036: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5
+echo "${as_me:-configure}:2072: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5
 
        ;;
 (*)
-       echo "$as_me:2040: result: ok" >&5
+       echo "$as_me:2076: result: ok" >&5
 echo "${ECHO_T}ok" >&6
        ;;
 esac
 
+echo "$as_me:2081: checking for inline" >&5
+echo $ECHO_N "checking for inline... $ECHO_C" >&6
+if test "${ac_cv_c_inline+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2089 "configure"
+#include "confdefs.h"
+#ifndef __cplusplus
+static $ac_kw int static_foo () {return 0; }
+$ac_kw int foo () {return 0; }
+#endif
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2098: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2101: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2104: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2107: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_inline=$ac_kw; break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+
+fi
+echo "$as_me:2118: result: $ac_cv_c_inline" >&5
+echo "${ECHO_T}$ac_cv_c_inline" >&6
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  no)
+cat >>confdefs.h <<\EOF
+#define inline
+EOF
+ ;;
+  *)  cat >>confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 ac_main_return=return
-echo "$as_me:2051: checking how to run the C preprocessor" >&5
+echo "$as_me:2139: checking how to run the C preprocessor" >&5
 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
@@ -2069,18 +2157,18 @@ do
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
-#line 2072 "configure"
+#line 2160 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:2077: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:2165: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2083: \$? = $ac_status" >&5
+  echo "$as_me:2171: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2103,17 +2191,17 @@ rm -f conftest.err conftest.$ac_ext
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
-#line 2106 "configure"
+#line 2194 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:2110: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:2198: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2116: \$? = $ac_status" >&5
+  echo "$as_me:2204: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2150,7 +2238,7 @@ fi
 else
   ac_cv_prog_CPP=$CPP
 fi
-echo "$as_me:2153: result: $CPP" >&5
+echo "$as_me:2241: result: $CPP" >&5
 echo "${ECHO_T}$CPP" >&6
 ac_preproc_ok=false
 for ac_c_preproc_warn_flag in '' yes
@@ -2160,18 +2248,18 @@ do
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
-#line 2163 "configure"
+#line 2251 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:2168: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:2256: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2174: \$? = $ac_status" >&5
+  echo "$as_me:2262: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2194,17 +2282,17 @@ rm -f conftest.err conftest.$ac_ext
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
-#line 2197 "configure"
+#line 2285 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:2201: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:2289: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2207: \$? = $ac_status" >&5
+  echo "$as_me:2295: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2232,7 +2320,7 @@ rm -f conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:2235: error: C preprocessor \"$CPP\" fails sanity check" >&5
+  { { echo "$as_me:2323: error: C preprocessor \"$CPP\" fails sanity check" >&5
 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -2248,7 +2336,7 @@ for ac_prog in mawk gawk nawk awk
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2251: checking for $ac_word" >&5
+echo "$as_me:2339: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_AWK+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2263,7 +2351,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_AWK="$ac_prog"
-echo "$as_me:2266: found $ac_dir/$ac_word" >&5
+echo "$as_me:2354: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2271,10 +2359,10 @@ fi
 fi
 AWK=$ac_cv_prog_AWK
 if test -n "$AWK"; then
-  echo "$as_me:2274: result: $AWK" >&5
+  echo "$as_me:2362: result: $AWK" >&5
 echo "${ECHO_T}$AWK" >&6
 else
-  echo "$as_me:2277: result: no" >&5
+  echo "$as_me:2365: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2293,7 +2381,7 @@ done
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:2296: checking for a BSD compatible install" >&5
+echo "$as_me:2384: checking for a BSD compatible install" >&5
 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
 if test -z "$INSTALL"; then
 if test "${ac_cv_path_install+set}" = set; then
@@ -2342,7 +2430,7 @@ fi
     INSTALL=$ac_install_sh
   fi
 fi
-echo "$as_me:2345: result: $INSTALL" >&5
+echo "$as_me:2433: result: $INSTALL" >&5
 echo "${ECHO_T}$INSTALL" >&6
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
@@ -2367,7 +2455,7 @@ for ac_prog in lint cppcheck splint
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2370: checking for $ac_word" >&5
+echo "$as_me:2458: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_LINT+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2382,7 +2470,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_LINT="$ac_prog"
-echo "$as_me:2385: found $ac_dir/$ac_word" >&5
+echo "$as_me:2473: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2390,17 +2478,17 @@ fi
 fi
 LINT=$ac_cv_prog_LINT
 if test -n "$LINT"; then
-  echo "$as_me:2393: result: $LINT" >&5
+  echo "$as_me:2481: result: $LINT" >&5
 echo "${ECHO_T}$LINT" >&6
 else
-  echo "$as_me:2396: result: no" >&5
+  echo "$as_me:2484: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
   test -n "$LINT" && break
 done
 
-echo "$as_me:2403: checking if filesystem supports mixed-case filenames" >&5
+echo "$as_me:2491: checking if filesystem supports mixed-case filenames" >&5
 echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6
 if test "${cf_cv_mixedcase+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2427,7 +2515,7 @@ else
 fi
 
 fi
-echo "$as_me:2430: result: $cf_cv_mixedcase" >&5
+echo "$as_me:2518: result: $cf_cv_mixedcase" >&5
 echo "${ECHO_T}$cf_cv_mixedcase" >&6
 test "$cf_cv_mixedcase" = yes &&
 cat >>confdefs.h <<\EOF
@@ -2438,7 +2526,7 @@ for ac_prog in exctags ctags
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2441: checking for $ac_word" >&5
+echo "$as_me:2529: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CTAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2453,7 +2541,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CTAGS="$ac_prog"
-echo "$as_me:2456: found $ac_dir/$ac_word" >&5
+echo "$as_me:2544: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2461,10 +2549,10 @@ fi
 fi
 CTAGS=$ac_cv_prog_CTAGS
 if test -n "$CTAGS"; then
-  echo "$as_me:2464: result: $CTAGS" >&5
+  echo "$as_me:2552: result: $CTAGS" >&5
 echo "${ECHO_T}$CTAGS" >&6
 else
-  echo "$as_me:2467: result: no" >&5
+  echo "$as_me:2555: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2475,7 +2563,7 @@ for ac_prog in exetags etags
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2478: checking for $ac_word" >&5
+echo "$as_me:2566: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ETAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2490,7 +2578,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ETAGS="$ac_prog"
-echo "$as_me:2493: found $ac_dir/$ac_word" >&5
+echo "$as_me:2581: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2498,10 +2586,10 @@ fi
 fi
 ETAGS=$ac_cv_prog_ETAGS
 if test -n "$ETAGS"; then
-  echo "$as_me:2501: result: $ETAGS" >&5
+  echo "$as_me:2589: result: $ETAGS" >&5
 echo "${ECHO_T}$ETAGS" >&6
 else
-  echo "$as_me:2504: result: no" >&5
+  echo "$as_me:2592: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2510,7 +2598,7 @@ done
 
 # Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args.
 set dummy ${CTAGS:-ctags}; ac_word=$2
-echo "$as_me:2513: checking for $ac_word" >&5
+echo "$as_me:2601: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2525,7 +2613,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAKE_LOWER_TAGS="yes"
-echo "$as_me:2528: found $ac_dir/$ac_word" >&5
+echo "$as_me:2616: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2534,17 +2622,17 @@ fi
 fi
 MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS
 if test -n "$MAKE_LOWER_TAGS"; then
-  echo "$as_me:2537: result: $MAKE_LOWER_TAGS" >&5
+  echo "$as_me:2625: result: $MAKE_LOWER_TAGS" >&5
 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6
 else
-  echo "$as_me:2540: result: no" >&5
+  echo "$as_me:2628: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
 if test "$cf_cv_mixedcase" = yes ; then
        # Extract the first word of "${ETAGS:-etags}", so it can be a program name with args.
 set dummy ${ETAGS:-etags}; ac_word=$2
-echo "$as_me:2547: checking for $ac_word" >&5
+echo "$as_me:2635: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2559,7 +2647,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAKE_UPPER_TAGS="yes"
-echo "$as_me:2562: found $ac_dir/$ac_word" >&5
+echo "$as_me:2650: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2568,10 +2656,10 @@ fi
 fi
 MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS
 if test -n "$MAKE_UPPER_TAGS"; then
-  echo "$as_me:2571: result: $MAKE_UPPER_TAGS" >&5
+  echo "$as_me:2659: result: $MAKE_UPPER_TAGS" >&5
 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6
 else
-  echo "$as_me:2574: result: no" >&5
+  echo "$as_me:2662: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2591,21 +2679,22 @@ else
        MAKE_LOWER_TAGS="#"
 fi
 
-echo "$as_me:2594: checking if -lm needed for math functions" >&5
+echo "$as_me:2682: checking if -lm needed for math functions" >&5
 echo $ECHO_N "checking if -lm needed for math functions... $ECHO_C" >&6
 if test "${cf_cv_need_libm+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
        cat >conftest.$ac_ext <<_ACEOF
-#line 2601 "configure"
+#line 2689 "configure"
 #include "confdefs.h"
 
        #include <stdio.h>
+       #include <stdlib.h>
        #include <math.h>
 
 int
-main ()
+main (void)
 {
 double x = rand(); printf("result = %g\n", pow(sin(x),x))
   ;
@@ -2613,16 +2702,16 @@ double x = rand(); printf("result = %g\n", pow(sin(x),x))
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:2616: \"$ac_link\"") >&5
+if { (eval echo "$as_me:2705: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:2619: \$? = $ac_status" >&5
+  echo "$as_me:2708: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:2622: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2711: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2625: \$? = $ac_status" >&5
+  echo "$as_me:2714: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_need_libm=no
 else
@@ -2632,7 +2721,7 @@ cf_cv_need_libm=yes
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:2635: result: $cf_cv_need_libm" >&5
+echo "$as_me:2724: result: $cf_cv_need_libm" >&5
 echo "${ECHO_T}$cf_cv_need_libm" >&6
 if test "$cf_cv_need_libm" = yes
 then
@@ -2691,10 +2780,10 @@ cat > conftest.i <<EOF
 EOF
 if test "$GCC" = yes
 then
-       { echo "$as_me:2694: checking for $CC __attribute__ directives..." >&5
+       { echo "$as_me:2783: checking for $CC __attribute__ directives..." >&5
 echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
 cat > conftest.$ac_ext <<EOF
-#line 2697 "${as_me:-configure}"
+#line 2786 "${as_me:-configure}"
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -2743,12 +2832,12 @@ EOF
                        ;;
                esac
 
-               if { (eval echo "$as_me:2746: \"$ac_compile\"") >&5
+               if { (eval echo "$as_me:2835: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2749: \$? = $ac_status" >&5
+  echo "$as_me:2838: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-                       test -n "$verbose" && echo "$as_me:2751: result: ... $cf_attribute" >&5
+                       test -n "$verbose" && echo "$as_me:2840: result: ... $cf_attribute" >&5
 echo "${ECHO_T}... $cf_attribute" >&6
                        cat conftest.h >>confdefs.h
                        case $cf_attribute in
 rm -rf conftest*
 fi
 
-cf_XOPEN_SOURCE=500
-cf_POSIX_C_SOURCE=199506L
-cf_xopen_source=
-
-case $host_os in
-(aix[4-7]*)
-       cf_xopen_source="-D_ALL_SOURCE"
-       ;;
-(cygwin|msys)
-       cf_XOPEN_SOURCE=600
-       ;;
-(darwin[0-8].*)
-       cf_xopen_source="-D_APPLE_C_SOURCE"
-       ;;
-(darwin*)
-       cf_xopen_source="-D_DARWIN_C_SOURCE"
-       cf_XOPEN_SOURCE=
-       ;;
-(freebsd*|dragonfly*)
-       # 5.x headers associate
-       #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
-       #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
-       cf_POSIX_C_SOURCE=200112L
-       cf_XOPEN_SOURCE=600
-       cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
-       ;;
-(hpux11*)
-       cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
-       ;;
-(hpux*)
-       cf_xopen_source="-D_HPUX_SOURCE"
-       ;;
-(irix[56].*)
-       cf_xopen_source="-D_SGI_SOURCE"
-       cf_XOPEN_SOURCE=
-       ;;
-(linux*|gnu*|mint*|k*bsd*-gnu)
+echo "$as_me:2899: checking if you want to work around bogus compiler/loader warnings" >&5
+echo $ECHO_N "checking if you want to work around bogus compiler/loader warnings... $ECHO_C" >&6
 
-echo "$as_me:2848: checking if we must define _GNU_SOURCE" >&5
-echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
-if test "${cf_cv_gnu_source+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+# Check whether --enable-string-hacks or --disable-string-hacks was given.
+if test "${enable_string_hacks+set}" = set; then
+  enableval="$enable_string_hacks"
+  with_string_hacks=$enableval
 else
+  with_string_hacks=no
+fi;
+echo "$as_me:2909: result: $with_string_hacks" >&5
+echo "${ECHO_T}$with_string_hacks" >&6
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 2855 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int
-main ()
-{
+if test "x$with_string_hacks" = "xyes"; then
 
-#ifndef _XOPEN_SOURCE
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2870: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:2873: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2876: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:2879: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_gnu_source=no
+cat >>confdefs.h <<\EOF
+#define USE_STRING_HACKS 1
+EOF
+
+       { echo "$as_me:2918: WARNING: enabling string-hacks to work around bogus compiler/loader warnings" >&5
+echo "$as_me: WARNING: enabling string-hacks to work around bogus compiler/loader warnings" >&2;}
+       echo "$as_me:2920: checking for strlcat" >&5
+echo $ECHO_N "checking for strlcat... $ECHO_C" >&6
+if test "${ac_cv_func_strlcat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_save="$CPPFLAGS"
-        CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
-        cat >conftest.$ac_ext <<_ACEOF
-#line 2888 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2926 "configure"
 #include "confdefs.h"
-#include <sys/types.h>
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char strlcat (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char strlcat ();
+char (*f) ();
+
 int
-main ()
+main (void)
 {
-
-#ifdef _XOPEN_SOURCE
-make an error
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_strlcat) || defined (__stub___strlcat)
+choke me
+#else
+f = strlcat; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
 #endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2903: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:2957: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:2906: \$? = $ac_status" >&5
+  echo "$as_me:2960: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2909: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:2963: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2912: \$? = $ac_status" >&5
+  echo "$as_me:2966: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_gnu_source=no
+  ac_cv_func_strlcat=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_gnu_source=yes
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-       CPPFLAGS="$cf_save"
-
+ac_cv_func_strlcat=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:2927: result: $cf_cv_gnu_source" >&5
-echo "${ECHO_T}$cf_cv_gnu_source" >&6
-test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
-
-       ;;
-(minix*)
-       cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
-       ;;
-(mirbsd*)
-       # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
-       cf_XOPEN_SOURCE=
-
-cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
-
-cf_save_CFLAGS="$CFLAGS"
-cf_save_CPPFLAGS="$CPPFLAGS"
+echo "$as_me:2976: result: $ac_cv_func_strlcat" >&5
+echo "${ECHO_T}$ac_cv_func_strlcat" >&6
+if test $ac_cv_func_strlcat = yes; then
 
-cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \
-       sed     -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?$//g'`
+cat >>confdefs.h <<\EOF
+#define HAVE_STRLCAT 1
+EOF
 
-cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
-       sed     -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?$//g'`
+else
 
-echo "$as_me:2952: checking if we should define _POSIX_C_SOURCE" >&5
-echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
-if test "${cf_cv_posix_c_source+set}" = set; then
+               echo "$as_me:2986: checking for strlcat in -lbsd" >&5
+echo $ECHO_N "checking for strlcat in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_strlcat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
-echo "${as_me:-configure}:2958: testing if the symbol is already defined go no further ..." 1>&5
-
-       cat >conftest.$ac_ext <<_ACEOF
-#line 2961 "configure"
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbsd  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 2994 "configure"
 #include "confdefs.h"
-#include <sys/types.h>
-int
-main ()
-{
 
-#ifndef _POSIX_C_SOURCE
-make an error
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
 #endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2976: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:2979: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2982: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:2985: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_posix_c_source=no
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_want_posix_source=no
-        case .$cf_POSIX_C_SOURCE in
-        (.[12]??*)
-               cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
-               ;;
-        (.2)
-               cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
-               cf_want_posix_source=yes
-               ;;
-        (.*)
-               cf_want_posix_source=yes
-               ;;
-        esac
-        if test "$cf_want_posix_source" = yes ; then
-               cat >conftest.$ac_ext <<_ACEOF
-#line 3006 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char strlcat ();
 int
-main ()
+main (void)
 {
-
-#ifdef _POSIX_SOURCE
-make an error
-#endif
+strlcat ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3021: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3013: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:3024: \$? = $ac_status" >&5
+  echo "$as_me:3016: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3027: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3019: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3030: \$? = $ac_status" >&5
+  echo "$as_me:3022: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+  ac_cv_lib_bsd_strlcat=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
+ac_cv_lib_bsd_strlcat=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-        fi
-
-echo "${as_me:-configure}:3041: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
-
-        CFLAGS="$cf_trim_CFLAGS"
-        CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:3033: result: $ac_cv_lib_bsd_strlcat" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_strlcat" >&6
+if test $ac_cv_lib_bsd_strlcat = yes; then
 
-echo "${as_me:-configure}:3046: testing if the second compile does not leave our definition intact error ..." 1>&5
+cf_add_libs="-lbsd"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-        cat >conftest.$ac_ext <<_ACEOF
-#line 3049 "configure"
+for ac_header in bsd/string.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:3056: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3062 "configure"
 #include "confdefs.h"
-#include <sys/types.h>
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:3066: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:3072: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:3091: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+cat >>confdefs.h <<\EOF
+#define HAVE_STRLCAT 1
+EOF
+
+fi
+
+fi
+
+for ac_func in strlcpy snprintf
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:3112: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3118 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
+
 int
-main ()
+main (void)
 {
-
-#ifndef _POSIX_C_SOURCE
-make an error
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
 #endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3064: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3149: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:3067: \$? = $ac_status" >&5
+  echo "$as_me:3152: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3070: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3155: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3073: \$? = $ac_status" >&5
+  echo "$as_me:3158: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+  eval "$as_ac_var=yes"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_posix_c_source=no
+eval "$as_ac_var=no"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-        CFLAGS="$cf_save_CFLAGS"
-        CPPFLAGS="$cf_save_CPPFLAGS"
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:3168: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
 
 fi
-echo "$as_me:3089: result: $cf_cv_posix_c_source" >&5
-echo "${ECHO_T}$cf_cv_posix_c_source" >&6
-
-if test "$cf_cv_posix_c_source" != no ; then
-       CFLAGS="$cf_trim_CFLAGS"
-       CPPFLAGS="$cf_trim_CPPFLAGS"
-
-cf_fix_cppflags=no
-cf_new_cflags=
-cf_new_cppflags=
-cf_new_extra_cppflags=
-
-for cf_add_cflags in $cf_cv_posix_c_source
-do
-case $cf_fix_cppflags in
-(no)
-       case $cf_add_cflags in
-       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-               case $cf_add_cflags in
-               (-D*)
-                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
-
-                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-                               && test -z "${cf_tst_cflags}" \
-                               && cf_fix_cppflags=yes
-
-                       if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       fi
-                       ;;
-               esac
-               case "$CPPFLAGS" in
-               (*$cf_add_cflags)
-                       ;;
-               (*)
-                       case $cf_add_cflags in
-                       (-D*)
-                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
-
-CPPFLAGS=`echo "$CPPFLAGS" | \
-       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
-
-                               ;;
-                       esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
-                       ;;
-               esac
-               ;;
-       (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
-               ;;
-       esac
-       ;;
-(yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-
-       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
-
-       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-               && test -z "${cf_tst_cflags}" \
-               && cf_fix_cppflags=no
-       ;;
-esac
 done
 
-if test -n "$cf_new_cflags" ; then
-
-       CFLAGS="$CFLAGS $cf_new_cflags"
-fi
-
-if test -n "$cf_new_cppflags" ; then
-
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
-fi
-
-if test -n "$cf_new_extra_cppflags" ; then
-
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
 fi
 
-fi
+cf_XOPEN_SOURCE=500
+cf_POSIX_C_SOURCE=199506L
+cf_xopen_source=
 
+case $host_os in
+(aix[4-7]*)
+       cf_xopen_source="-D_ALL_SOURCE"
        ;;
-(netbsd*)
-       cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
-       ;;
-(openbsd[4-9]*)
-       # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
-       cf_xopen_source="-D_BSD_SOURCE"
+(msys)
        cf_XOPEN_SOURCE=600
        ;;
-(openbsd*)
-       # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+(darwin[0-8].*)
+       cf_xopen_source="-D_APPLE_C_SOURCE"
        ;;
-(os2*)
+(darwin*)
+       cf_xopen_source="-D_DARWIN_C_SOURCE"
        cf_XOPEN_SOURCE=
        ;;
-(osf[45]*)
-       cf_xopen_source="-D_OSF_SOURCE"
-       ;;
-(nto-qnx*)
-       cf_xopen_source="-D_QNX_SOURCE"
+(freebsd*|dragonfly*)
+       # 5.x headers associate
+       #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+       #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+       cf_POSIX_C_SOURCE=200112L
+       cf_XOPEN_SOURCE=600
+       cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
        ;;
-(sco*)
-       # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+(hpux11*)
+       cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
        ;;
-(solaris2.*)
-       cf_xopen_source="-D__EXTENSIONS__"
-       cf_cv_xopen_source=broken
+(hpux*)
+       cf_xopen_source="-D_HPUX_SOURCE"
        ;;
-(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
+(irix[56].*)
+       cf_xopen_source="-D_SGI_SOURCE"
        cf_XOPEN_SOURCE=
-       cf_POSIX_C_SOURCE=
        ;;
-(*)
+(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
 
-echo "$as_me:3210: checking if we should define _XOPEN_SOURCE" >&5
-echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
-if test "${cf_cv_xopen_source+set}" = set; then
+echo "$as_me:3218: checking if we must define _GNU_SOURCE" >&5
+echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_gnu_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-       cat >conftest.$ac_ext <<_ACEOF
-#line 3217 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 3225 "configure"
 #include "confdefs.h"
-
-#include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
-
 int
-main ()
+main (void)
 {
 
 #ifndef _XOPEN_SOURCE
@@ -3233,33 +3237,29 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3236: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3240: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3239: \$? = $ac_status" >&5
+  echo "$as_me:3243: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3242: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3246: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3245: \$? = $ac_status" >&5
+  echo "$as_me:3249: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_xopen_source=no
+  cf_cv_gnu_source=no
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 cf_save="$CPPFLAGS"
-        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+        CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
         cat >conftest.$ac_ext <<_ACEOF
-#line 3254 "configure"
+#line 3258 "configure"
 #include "confdefs.h"
-
-#include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
-
 int
-main ()
+main (void)
 {
 
 #ifdef _XOPEN_SOURCE
@@ -3281,11 +3281,11 @@ if { (eval echo "$as_me:3273: \"$ac_compile\"") >&5
   ac_status=$?
   echo "$as_me:3282: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_xopen_source=no
+  cf_cv_gnu_source=no
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_xopen_source=$cf_XOPEN_SOURCE
+cf_cv_gnu_source=yes
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
        CPPFLAGS="$cf_save"
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:3297: result: $cf_cv_xopen_source" >&5
-echo "${ECHO_T}$cf_cv_xopen_source" >&6
-
-if test "$cf_cv_xopen_source" != no ; then
-
-CFLAGS=`echo "$CFLAGS" | \
-       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
-
-CPPFLAGS=`echo "$CPPFLAGS" | \
-       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
-
-       cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
-
-cf_fix_cppflags=no
-cf_new_cflags=
-cf_new_cppflags=
-cf_new_extra_cppflags=
-
-for cf_add_cflags in $cf_temp_xopen_source
-do
-case $cf_fix_cppflags in
-(no)
-       case $cf_add_cflags in
-       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-               case $cf_add_cflags in
-               (-D*)
-                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
-
-                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-                               && test -z "${cf_tst_cflags}" \
-                               && cf_fix_cppflags=yes
-
-                       if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       fi
-                       ;;
-               esac
-               case "$CPPFLAGS" in
-               (*$cf_add_cflags)
-                       ;;
-               (*)
-                       case $cf_add_cflags in
-                       (-D*)
-                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
-
-CPPFLAGS=`echo "$CPPFLAGS" | \
-       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
-
-                               ;;
-                       esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
-                       ;;
-               esac
-               ;;
-       (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
-               ;;
-       esac
-       ;;
-(yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-
-       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+echo "$as_me:3297: result: $cf_cv_gnu_source" >&5
+echo "${ECHO_T}$cf_cv_gnu_source" >&6
 
-       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-               && test -z "${cf_tst_cflags}" \
-               && cf_fix_cppflags=no
-       ;;
-esac
-done
+if test "$cf_cv_gnu_source" = yes
+then
+echo "$as_me:3302: checking if we should also define _DEFAULT_SOURCE" >&5
+echo $ECHO_N "checking if we should also define _DEFAULT_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_default_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-if test -n "$cf_new_cflags" ; then
+CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 3310 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main (void)
+{
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+#ifdef _DEFAULT_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3325: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3328: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3331: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3334: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_default_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_default_source=yes
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-if test -n "$cf_new_cppflags" ; then
-
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
 fi
-
-if test -n "$cf_new_extra_cppflags" ; then
-
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+echo "$as_me:3345: result: $cf_cv_default_source" >&5
+echo "${ECHO_T}$cf_cv_default_source" >&6
+test "$cf_cv_default_source" = yes && CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE"
 fi
 
-fi
+       ;;
+(minix*)
+       cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
+       ;;
+(mirbsd*)
+       # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
+       cf_XOPEN_SOURCE=
 
 cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
 
@@ -3402,20 +3368,20 @@ cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
        sed     -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?[         ]/ /g' \
                -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?$//g'`
 
-echo "$as_me:3405: checking if we should define _POSIX_C_SOURCE" >&5
+echo "$as_me:3371: checking if we should define _POSIX_C_SOURCE" >&5
 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_posix_c_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-echo "${as_me:-configure}:3411: testing if the symbol is already defined go no further ..." 1>&5
+echo "${as_me:-configure}:3377: testing if the symbol is already defined go no further ..." 1>&5
 
        cat >conftest.$ac_ext <<_ACEOF
-#line 3414 "configure"
+#line 3380 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
@@ -3426,16 +3392,16 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3429: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3395: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3432: \$? = $ac_status" >&5
+  echo "$as_me:3398: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3435: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3401: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3438: \$? = $ac_status" >&5
+  echo "$as_me:3404: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_posix_c_source=no
 else
@@ -3456,11 +3422,11 @@ cf_want_posix_source=no
         esac
         if test "$cf_want_posix_source" = yes ; then
                cat >conftest.$ac_ext <<_ACEOF
-#line 3459 "configure"
+#line 3425 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifdef _POSIX_SOURCE
@@ -3471,16 +3437,16 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3474: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3440: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3477: \$? = $ac_status" >&5
+  echo "$as_me:3443: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3480: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3446: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3483: \$? = $ac_status" >&5
+  echo "$as_me:3449: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -3491,19 +3457,19 @@ fi
 rm -f conftest.$ac_objext conftest.$ac_ext
         fi
 
-echo "${as_me:-configure}:3494: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+echo "${as_me:-configure}:3460: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
 
         CFLAGS="$cf_trim_CFLAGS"
         CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
 
-echo "${as_me:-configure}:3499: testing if the second compile does not leave our definition intact error ..." 1>&5
+echo "${as_me:-configure}:3465: testing if the second compile does not leave our definition intact error ..." 1>&5
 
         cat >conftest.$ac_ext <<_ACEOF
-#line 3502 "configure"
+#line 3468 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
@@ -3514,16 +3480,16 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3517: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3483: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3520: \$? = $ac_status" >&5
+  echo "$as_me:3486: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3523: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3489: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3526: \$? = $ac_status" >&5
+  echo "$as_me:3492: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -3539,7 +3505,7 @@ fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:3542: result: $cf_cv_posix_c_source" >&5
+echo "$as_me:3508: result: $cf_cv_posix_c_source" >&5
 echo "${ECHO_T}$cf_cv_posix_c_source" >&6
 
 if test "$cf_cv_posix_c_source" != no ; then
@@ -3566,10 +3532,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -3588,17 +3560,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -3611,32 +3591,166 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 fi
 
        ;;
-esac
+(netbsd*)
+       cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+       ;;
+(openbsd[4-9]*)
+       # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
+       cf_xopen_source="-D_BSD_SOURCE"
+       cf_XOPEN_SOURCE=600
+       ;;
+(openbsd*)
+       # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+       ;;
+(osf[45]*)
+       cf_xopen_source="-D_OSF_SOURCE"
+       ;;
+(nto-qnx*)
+       cf_xopen_source="-D_QNX_SOURCE"
+       ;;
+(sco*)
+       # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+       ;;
+(solaris2.*)
+       cf_xopen_source="-D__EXTENSIONS__"
+       cf_cv_xopen_source=broken
+       ;;
+(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
+       cf_XOPEN_SOURCE=
+       cf_POSIX_C_SOURCE=
+       ;;
+(*)
 
-if test -n "$cf_xopen_source" ; then
+echo "$as_me:3646: checking if we should define _XOPEN_SOURCE" >&5
+echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_xopen_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 3653 "configure"
+#include "confdefs.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+int
+main (void)
+{
+
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3672: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3675: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3678: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3681: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xopen_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_save="$CPPFLAGS"
+        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+        cat >conftest.$ac_ext <<_ACEOF
+#line 3690 "configure"
+#include "confdefs.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+int
+main (void)
+{
+
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3709: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3712: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3715: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3718: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xopen_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xopen_source=$cf_XOPEN_SOURCE
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+       CPPFLAGS="$cf_save"
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:3733: result: $cf_cv_xopen_source" >&5
+echo "${ECHO_T}$cf_cv_xopen_source" >&6
+
+if test "$cf_cv_xopen_source" != no ; then
+
+CFLAGS=`echo "$CFLAGS" | \
+       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
+
+       cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
 
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_xopen_source
+for cf_add_cflags in $cf_temp_xopen_source
 do
 case $cf_fix_cppflags in
 (no)
@@ -3651,10 +3765,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -3673,17 +3793,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -3695,43 +3823,58 @@ esac
 done
 
 if test -n "$cf_new_cflags" ; then
-       test -n "$verbose" && echo "    add to \$CFLAGS $cf_new_cflags" 1>&6
 
-echo "${as_me:-configure}:3700: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
 fi
 
 if test -n "$cf_new_cppflags" ; then
-       test -n "$verbose" && echo "    add to \$CPPFLAGS $cf_new_cppflags" 1>&6
 
-echo "${as_me:-configure}:3708: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
-       test -n "$verbose" && echo "    add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
 
-echo "${as_me:-configure}:3716: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
 fi
 
 fi
 
-if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
-       echo "$as_me:3724: checking if _XOPEN_SOURCE really is set" >&5
-echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6
+cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
+
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+
+cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \
+       sed     -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?$//g'`
+
+cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
+       sed     -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?$//g'`
+
+echo "$as_me:3861: checking if we should define _POSIX_C_SOURCE" >&5
+echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_posix_c_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+echo "${as_me:-configure}:3867: testing if the symbol is already defined go no further ..." 1>&5
+
        cat >conftest.$ac_ext <<_ACEOF
-#line 3727 "configure"
+#line 3870 "configure"
 #include "confdefs.h"
-#include <stdlib.h>
+#include <sys/types.h>
 int
-main ()
+main (void)
 {
 
-#ifndef _XOPEN_SOURCE
+#ifndef _POSIX_C_SOURCE
 make an error
 #endif
   ;
@@ -3739,37 +3882,44 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3742: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3885: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3745: \$? = $ac_status" >&5
+  echo "$as_me:3888: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3748: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3891: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3751: \$? = $ac_status" >&5
+  echo "$as_me:3894: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_XOPEN_SOURCE_set=yes
+  cf_cv_posix_c_source=no
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_XOPEN_SOURCE_set=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-       echo "$as_me:3760: result: $cf_XOPEN_SOURCE_set" >&5
-echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6
-       if test $cf_XOPEN_SOURCE_set = yes
-       then
+cf_want_posix_source=no
+        case .$cf_POSIX_C_SOURCE in
+        (.[12]??*)
+               cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+               ;;
+        (.2)
+               cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+               cf_want_posix_source=yes
+               ;;
+        (.*)
+               cf_want_posix_source=yes
+               ;;
+        esac
+        if test "$cf_want_posix_source" = yes ; then
                cat >conftest.$ac_ext <<_ACEOF
-#line 3765 "configure"
+#line 3915 "configure"
 #include "confdefs.h"
-#include <stdlib.h>
+#include <sys/types.h>
 int
-main ()
+main (void)
 {
 
-#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
+#ifdef _POSIX_SOURCE
 make an error
 #endif
   ;
@@ -3777,87 +3927,42 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3780: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3930: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3783: \$? = $ac_status" >&5
+  echo "$as_me:3933: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3786: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3936: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3789: \$? = $ac_status" >&5
+  echo "$as_me:3939: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_XOPEN_SOURCE_set_ok=yes
+  :
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_XOPEN_SOURCE_set_ok=no
+cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-               if test $cf_XOPEN_SOURCE_set_ok = no
-               then
-                       { echo "$as_me:3800: WARNING: _XOPEN_SOURCE is lower than requested" >&5
-echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;}
-               fi
-       else
-
-echo "$as_me:3805: checking if we should define _XOPEN_SOURCE" >&5
-echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
-if test "${cf_cv_xopen_source+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+        fi
 
-       cat >conftest.$ac_ext <<_ACEOF
-#line 3812 "configure"
-#include "confdefs.h"
+echo "${as_me:-configure}:3950: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+        CFLAGS="$cf_trim_CFLAGS"
+        CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
 
-int
-main ()
-{
+echo "${as_me:-configure}:3955: testing if the second compile does not leave our definition intact error ..." 1>&5
 
-#ifndef _XOPEN_SOURCE
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3831: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:3834: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3837: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:3840: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_xopen_source=no
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_save="$CPPFLAGS"
-        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
         cat >conftest.$ac_ext <<_ACEOF
-#line 3849 "configure"
+#line 3958 "configure"
 #include "confdefs.h"
-
-#include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
-
 int
-main ()
+main (void)
 {
 
-#ifdef _XOPEN_SOURCE
+#ifndef _POSIX_C_SOURCE
 make an error
 #endif
   ;
@@ -3865,51 +3970,44 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3868: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3973: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3871: \$? = $ac_status" >&5
+  echo "$as_me:3976: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3874: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3979: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3877: \$? = $ac_status" >&5
+  echo "$as_me:3982: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_xopen_source=no
+  :
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_xopen_source=$cf_XOPEN_SOURCE
+cf_cv_posix_c_source=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-       CPPFLAGS="$cf_save"
+        CFLAGS="$cf_save_CFLAGS"
+        CPPFLAGS="$cf_save_CPPFLAGS"
 
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:3892: result: $cf_cv_xopen_source" >&5
-echo "${ECHO_T}$cf_cv_xopen_source" >&6
-
-if test "$cf_cv_xopen_source" != no ; then
-
-CFLAGS=`echo "$CFLAGS" | \
-       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
-
-CPPFLAGS=`echo "$CPPFLAGS" | \
-       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
+echo "$as_me:3998: result: $cf_cv_posix_c_source" >&5
+echo "${ECHO_T}$cf_cv_posix_c_source" >&6
 
-       cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+if test "$cf_cv_posix_c_source" != no ; then
+       CFLAGS="$cf_trim_CFLAGS"
+       CPPFLAGS="$cf_trim_CPPFLAGS"
 
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_temp_xopen_source
+for cf_add_cflags in $cf_cv_posix_c_source
 do
 case $cf_fix_cppflags in
 (no)
@@ -3924,10 +4022,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -3946,17 +4050,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
-fi
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
 fi
 
-       fi
 fi
 
-echo "$as_me:3990: checking for signal global datatype" >&5
-echo $ECHO_N "checking for signal global datatype... $ECHO_C" >&6
-if test "${cf_cv_sig_atomic_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+       ;;
+esac
 
-       for cf_type in \
-               "volatile sig_atomic_t" \
-               "sig_atomic_t" \
-               "int"
-       do
-       cat >conftest.$ac_ext <<_ACEOF
-#line 4002 "configure"
-#include "confdefs.h"
+if test -n "$cf_xopen_source" ; then
 
-#include <sys/types.h>
-#include <signal.h>
-#include <stdio.h>
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
 
-extern $cf_type x;
-$cf_type x;
-static void handler(int sig)
-{
-       x = 5;
-}
-int
-main ()
-{
-signal(SIGINT, handler);
-                x = 1
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4025: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:4028: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4031: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:4034: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_sig_atomic_t=$cf_type
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_sig_atomic_t=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-               test "$cf_cv_sig_atomic_t" != no && break
-       done
+for cf_add_cflags in $cf_xopen_source
+do
+case $cf_fix_cppflags in
+(no)
+       case $cf_add_cflags in
+       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+               case $cf_add_cflags in
+               (-D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
-fi
+                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
 
-echo "$as_me:4048: result: $cf_cv_sig_atomic_t" >&5
-echo "${ECHO_T}$cf_cv_sig_atomic_t" >&6
-test "$cf_cv_sig_atomic_t" != no &&
-cat >>confdefs.h <<EOF
-#define SIG_ATOMIC_T $cf_cv_sig_atomic_t
-EOF
+                       if test $cf_fix_cppflags = yes ; then
 
-# Work around breakage on OS X
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
-echo "$as_me:4057: checking if SIGWINCH is defined" >&5
-echo $ECHO_N "checking if SIGWINCH is defined... $ECHO_C" >&6
-if test "${cf_cv_define_sigwinch+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
 
-       cat >conftest.$ac_ext <<_ACEOF
-#line 4064 "configure"
-#include "confdefs.h"
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
-#include <sys/types.h>
-#include <sys/signal.h>
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               (*$cf_add_cflags)
+                       ;;
+               (*)
+                       case $cf_add_cflags in
+                       (-D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
-int
-main ()
-{
-int x = SIGWINCH
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4079: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:4082: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4085: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:4088: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_define_sigwinch=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 4095 "configure"
-#include "confdefs.h"
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
 
-#undef _XOPEN_SOURCE
-#undef _POSIX_SOURCE
-#undef _POSIX_C_SOURCE
-#include <sys/types.h>
-#include <sys/signal.h>
+                               ;;
+                       esac
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+                       ;;
+               esac
+               ;;
+       (*)
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+               ;;
+       esac
+       ;;
+(yes)
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+       test -n "$verbose" && echo "    add to \$CFLAGS $cf_new_cflags" 1>&6
+
+echo "${as_me:-configure}:4190: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+       test -n "$verbose" && echo "    add to \$CPPFLAGS $cf_new_cppflags" 1>&6
+
+echo "${as_me:-configure}:4200: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+       test -n "$verbose" && echo "    add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
+
+echo "${as_me:-configure}:4210: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+fi
 
+if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
+       echo "$as_me:4220: checking if _XOPEN_SOURCE really is set" >&5
+echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4223 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
 int
-main ()
+main (void)
 {
-int x = SIGWINCH
+
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4113: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:4238: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4116: \$? = $ac_status" >&5
+  echo "$as_me:4241: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4119: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4244: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4122: \$? = $ac_status" >&5
+  echo "$as_me:4247: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_define_sigwinch=maybe
+  cf_XOPEN_SOURCE_set=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_define_sigwinch=no
+cf_XOPEN_SOURCE_set=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
+       echo "$as_me:4256: result: $cf_XOPEN_SOURCE_set" >&5
+echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6
+       if test $cf_XOPEN_SOURCE_set = yes
+       then
+               cat >conftest.$ac_ext <<_ACEOF
+#line 4261 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+int
+main (void)
+{
 
+#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4276: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4279: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4282: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4285: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_XOPEN_SOURCE_set_ok=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_XOPEN_SOURCE_set_ok=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
+               if test $cf_XOPEN_SOURCE_set_ok = no
+               then
+                       { echo "$as_me:4296: WARNING: _XOPEN_SOURCE is lower than requested" >&5
+echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;}
+               fi
+       else
 
-fi
-echo "$as_me:4136: result: $cf_cv_define_sigwinch" >&5
-echo "${ECHO_T}$cf_cv_define_sigwinch" >&6
-
-if test "$cf_cv_define_sigwinch" = maybe ; then
-echo "$as_me:4140: checking for actual SIGWINCH definition" >&5
-echo $ECHO_N "checking for actual SIGWINCH definition... $ECHO_C" >&6
-if test "${cf_cv_fixup_sigwinch+set}" = set; then
+echo "$as_me:4301: checking if we should define _XOPEN_SOURCE" >&5
+echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_xopen_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cf_cv_fixup_sigwinch=unknown
-cf_sigwinch=32
-while test $cf_sigwinch != 1
-do
        cat >conftest.$ac_ext <<_ACEOF
-#line 4151 "configure"
+#line 4308 "configure"
 #include "confdefs.h"
 
-#undef _XOPEN_SOURCE
-#undef _POSIX_SOURCE
-#undef _POSIX_C_SOURCE
+#include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
-#include <sys/signal.h>
 
 int
-main ()
+main (void)
 {
 
-#if SIGWINCH != $cf_sigwinch
+#ifndef _XOPEN_SOURCE
 make an error
 #endif
-int x = SIGWINCH
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4173: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:4327: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4176: \$? = $ac_status" >&5
+  echo "$as_me:4330: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4179: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4333: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4182: \$? = $ac_status" >&5
+  echo "$as_me:4336: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_fixup_sigwinch=$cf_sigwinch
-        break
+  cf_cv_xopen_source=no
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-
-cf_sigwinch=`expr $cf_sigwinch - 1`
-done
-
-fi
-echo "$as_me:4196: result: $cf_cv_fixup_sigwinch" >&5
-echo "${ECHO_T}$cf_cv_fixup_sigwinch" >&6
-
-       if test "$cf_cv_fixup_sigwinch" != unknown ; then
-               CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
-       fi
-fi
+cf_save="$CPPFLAGS"
+        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+        cat >conftest.$ac_ext <<_ACEOF
+#line 4345 "configure"
+#include "confdefs.h"
 
-# Checks for CODESET support.
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
 
-echo "$as_me:4206: checking for nl_langinfo and CODESET" >&5
-echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
-if test "${am_cv_langinfo_codeset+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 4212 "configure"
-#include "confdefs.h"
-#include <langinfo.h>
 int
-main ()
+main (void)
 {
-char* cs = nl_langinfo(CODESET);
+
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4224: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4364: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4227: \$? = $ac_status" >&5
+  echo "$as_me:4367: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:4230: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4370: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4233: \$? = $ac_status" >&5
+  echo "$as_me:4373: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  am_cv_langinfo_codeset=yes
+  cf_cv_xopen_source=no
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-am_cv_langinfo_codeset=no
+cf_cv_xopen_source=$cf_XOPEN_SOURCE
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest.$ac_ext
+       CPPFLAGS="$cf_save"
 
 fi
-echo "$as_me:4244: result: $am_cv_langinfo_codeset" >&5
-echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
-       if test $am_cv_langinfo_codeset = yes; then
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-cat >>confdefs.h <<\EOF
-#define HAVE_LANGINFO_CODESET 1
-EOF
+fi
+echo "$as_me:4388: result: $cf_cv_xopen_source" >&5
+echo "${ECHO_T}$cf_cv_xopen_source" >&6
 
-       fi
+if test "$cf_cv_xopen_source" != no ; then
 
-echo "$as_me:4254: checking if you want to use pkg-config" >&5
-echo $ECHO_N "checking if you want to use pkg-config... $ECHO_C" >&6
+CFLAGS=`echo "$CFLAGS" | \
+       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
 
-# Check whether --with-pkg-config or --without-pkg-config was given.
-if test "${with_pkg_config+set}" = set; then
-  withval="$with_pkg_config"
-  cf_pkg_config=$withval
-else
-  cf_pkg_config=yes
-fi;
-echo "$as_me:4264: result: $cf_pkg_config" >&5
-echo "${ECHO_T}$cf_pkg_config" >&6
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
 
-case $cf_pkg_config in
+       cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_temp_xopen_source
+do
+case $cf_fix_cppflags in
 (no)
-       PKG_CONFIG=none
-       ;;
-(yes)
+       case $cf_add_cflags in
+       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+               case $cf_add_cflags in
+               (-D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
-set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
-echo "$as_me:4276: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  case $PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  if $as_executable_p "$ac_dir/$ac_word"; then
-   ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word"
-   echo "$as_me:4293: found $ac_dir/$ac_word" >&5
-   break
-fi
-done
+                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
 
-  ;;
-esac
-fi
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+                       if test $cf_fix_cppflags = yes ; then
 
-if test -n "$PKG_CONFIG"; then
-  echo "$as_me:4304: result: $PKG_CONFIG" >&5
-echo "${ECHO_T}$PKG_CONFIG" >&6
-else
-  echo "$as_me:4307: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
-fi
-if test -z "$ac_cv_path_PKG_CONFIG"; then
-  ac_pt_PKG_CONFIG=$PKG_CONFIG
-  # Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
-echo "$as_me:4316: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  case $ac_pt_PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  if $as_executable_p "$ac_dir/$ac_word"; then
-   ac_cv_path_ac_pt_PKG_CONFIG="$ac_dir/$ac_word"
-   echo "$as_me:4333: found $ac_dir/$ac_word" >&5
-   break
-fi
-done
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
 
-  test -z "$ac_cv_path_ac_pt_PKG_CONFIG" && ac_cv_path_ac_pt_PKG_CONFIG="none"
-  ;;
-esac
-fi
-ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
-if test -n "$ac_pt_PKG_CONFIG"; then
-  echo "$as_me:4345: result: $ac_pt_PKG_CONFIG" >&5
-echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6
-else
-  echo "$as_me:4348: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               (*$cf_add_cflags)
+                       ;;
+               (*)
+                       case $cf_add_cflags in
+                       (-D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
-  PKG_CONFIG=$ac_pt_PKG_CONFIG
-else
-  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
-fi
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
 
-       ;;
-(*)
-       PKG_CONFIG=$withval
-       ;;
-esac
+                               ;;
+                       esac
 
-test -z "$PKG_CONFIG" && PKG_CONFIG=none
-if test "$PKG_CONFIG" != none ; then
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
 
-if test "x$prefix" != xNONE; then
-       cf_path_syntax="$prefix"
-else
-       cf_path_syntax="$ac_default_prefix"
-fi
+                       ;;
+               esac
+               ;;
+       (*)
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
 
-case ".$PKG_CONFIG" in
-(.\$\(*\)*|.\'*\'*)
-       ;;
-(..|./*|.\\*)
-       ;;
-(.[a-zA-Z]:[\\/]*) # OS/2 EMX
-       ;;
-(.\${*prefix}*|.\${*dir}*)
-       eval PKG_CONFIG="$PKG_CONFIG"
-       case ".$PKG_CONFIG" in
-       (.NONE/*)
-               PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
                ;;
        esac
        ;;
-(.no|.NONE/*)
-       PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
-       ;;
-(*)
-       { { echo "$as_me:4391: error: expected a pathname, not \"$PKG_CONFIG\"" >&5
-echo "$as_me: error: expected a pathname, not \"$PKG_CONFIG\"" >&2;}
-   { (exit 1); exit 1; }; }
-       ;;
-esac
-
-elif test "x$cf_pkg_config" != xno ; then
-       { echo "$as_me:4398: WARNING: pkg-config is not installed" >&5
-echo "$as_me: WARNING: pkg-config is not installed" >&2;}
-fi
-
-echo "$as_me:4402: checking if you want to see long compiling messages" >&5
-echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6
-
-# Check whether --enable-echo or --disable-echo was given.
-if test "${enable_echo+set}" = set; then
-  enableval="$enable_echo"
-  test "$enableval" != no && enableval=yes
-       if test "$enableval" != "yes" ; then
-
-       ECHO_LT='--silent'
-       ECHO_LD='@echo linking $@;'
-       RULE_CC='@echo compiling $<'
-       SHOW_CC='@echo compiling $@'
-       ECHO_CC='@'
-
-       else
+(yes)
 
-       ECHO_LT=''
-       ECHO_LD=''
-       RULE_CC=''
-       SHOW_CC=''
-       ECHO_CC=''
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
-       fi
-else
-  enableval=yes
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
-       ECHO_LT=''
-       ECHO_LD=''
-       RULE_CC=''
-       SHOW_CC=''
-       ECHO_CC=''
+       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
 
-fi;
-echo "$as_me:4436: result: $enableval" >&5
-echo "${ECHO_T}$enableval" >&6
+if test -n "$cf_new_cflags" ; then
 
-echo "$as_me:4439: checking for ncurses wrap-prefix" >&5
-echo $ECHO_N "checking for ncurses wrap-prefix... $ECHO_C" >&6
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
 
-# Check whether --with-ncurses-wrap-prefix or --without-ncurses-wrap-prefix was given.
-if test "${with_ncurses_wrap_prefix+set}" = set; then
-  withval="$with_ncurses_wrap_prefix"
-  NCURSES_WRAP_PREFIX=$withval
-else
-  NCURSES_WRAP_PREFIX=_nc_
-fi;
-echo "$as_me:4449: result: $NCURSES_WRAP_PREFIX" >&5
-echo "${ECHO_T}$NCURSES_WRAP_PREFIX" >&6
+fi
 
-echo "$as_me:4452: checking if you want to check for wide-character functions" >&5
-echo $ECHO_N "checking if you want to check for wide-character functions... $ECHO_C" >&6
+if test -n "$cf_new_cppflags" ; then
 
-# Check whether --enable-widec or --disable-widec was given.
-if test "${enable_widec+set}" = set; then
-  enableval="$enable_widec"
-  test "$enableval" != no && enableval=yes
-       if test "$enableval" != "yes" ; then
-    cf_enable_widec=no
-       else
-               cf_enable_widec=yes
-       fi
-else
-  enableval=yes
-       cf_enable_widec=yes
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
 
-fi;
-echo "$as_me:4469: result: $cf_enable_widec" >&5
-echo "${ECHO_T}$cf_enable_widec" >&6
+fi
 
-echo "$as_me:4472: checking for specific curses-directory" >&5
-echo $ECHO_N "checking for specific curses-directory... $ECHO_C" >&6
+if test -n "$cf_new_extra_cppflags" ; then
 
-# Check whether --with-curses-dir or --without-curses-dir was given.
-if test "${with_curses_dir+set}" = set; then
-  withval="$with_curses_dir"
-  cf_cv_curses_dir=$withval
-else
-  cf_cv_curses_dir=no
-fi;
-echo "$as_me:4482: result: $cf_cv_curses_dir" >&5
-echo "${ECHO_T}$cf_cv_curses_dir" >&6
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
-if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
-then
+fi
 
-if test "x$prefix" != xNONE; then
-       cf_path_syntax="$prefix"
-else
-       cf_path_syntax="$ac_default_prefix"
 fi
 
-case ".$withval" in
-(.\$\(*\)*|.\'*\'*)
-       ;;
-(..|./*|.\\*)
-       ;;
-(.[a-zA-Z]:[\\/]*) # OS/2 EMX
-       ;;
-(.\${*prefix}*|.\${*dir}*)
-       eval withval="$withval"
-       case ".$withval" in
-       (.NONE/*)
-               withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
-               ;;
-       esac
-       ;;
-(.no|.NONE/*)
-       withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
-       ;;
-(*)
-       { { echo "$as_me:4513: error: expected a pathname, not \"$withval\"" >&5
-echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
-   { (exit 1); exit 1; }; }
-       ;;
-esac
+       fi
+fi
 
-       if test -d "$cf_cv_curses_dir"
-       then
+echo "$as_me:4506: checking for signal global datatype" >&5
+echo $ECHO_N "checking for signal global datatype... $ECHO_C" >&6
+if test "${cf_cv_sig_atomic_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-if test -n "$cf_cv_curses_dir/include" ; then
-  for cf_add_incdir in $cf_cv_curses_dir/include
-  do
-       while test $cf_add_incdir != /usr/include
+       for cf_type in \
+               "volatile sig_atomic_t" \
+               "sig_atomic_t" \
+               "int"
        do
-         if test -d $cf_add_incdir
-         then
-               cf_have_incdir=no
-               if test -n "$CFLAGS$CPPFLAGS" ; then
-                 # a loop is needed to ensure we can add subdirs of existing dirs
-                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
-                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
-                         cf_have_incdir=yes; break
-                       fi
-                 done
-               fi
-
-               if test "$cf_have_incdir" = no ; then
-                 if test "$cf_add_incdir" = /usr/local/include ; then
-                       if test "$GCC" = yes
-                       then
-                         cf_save_CPPFLAGS=$CPPFLAGS
-                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-                         cat >conftest.$ac_ext <<_ACEOF
-#line 4546 "configure"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4518 "configure"
 #include "confdefs.h"
+
+#include <sys/types.h>
+#include <signal.h>
 #include <stdio.h>
+
+extern $cf_type x;
+$cf_type x;
+static void handler(int sig)
+{
+       x = 5;
+}
 int
-main ()
+main (void)
 {
-printf("Hello")
+signal(SIGINT, handler);
+                x = 1
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4558: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:4541: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4561: \$? = $ac_status" >&5
+  echo "$as_me:4544: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4564: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4547: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4567: \$? = $ac_status" >&5
+  echo "$as_me:4550: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+  cf_cv_sig_atomic_t=$cf_type
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_have_incdir=yes
+cf_cv_sig_atomic_t=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-                         CPPFLAGS=$cf_save_CPPFLAGS
-                       fi
-                 fi
-               fi
-
-               if test "$cf_have_incdir" = no ; then
-                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
-
-echo "${as_me:-configure}:4584: testing adding $cf_add_incdir to include-path ..." 1>&5
-
-                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-
-                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
-                 test "$cf_top_incdir" = "$cf_add_incdir" && break
-                 cf_add_incdir="$cf_top_incdir"
-               else
-                 break
-               fi
-         else
-               break
-         fi
-       done
-  done
-fi
-
-if test -n "$cf_cv_curses_dir/lib" ; then
-       for cf_add_libdir in $cf_cv_curses_dir/lib
-       do
-               if test $cf_add_libdir = /usr/lib ; then
-                       :
-               elif test -d $cf_add_libdir
-               then
-                       cf_have_libdir=no
-                       if test -n "$LDFLAGS$LIBS" ; then
-                               # a loop is needed to ensure we can add subdirs of existing dirs
-                               for cf_test_libdir in $LDFLAGS $LIBS ; do
-                                       if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
-                                               cf_have_libdir=yes; break
-                                       fi
-                               done
-                       fi
-                       if test "$cf_have_libdir" = no ; then
-                               test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
-
-echo "${as_me:-configure}:4620: testing adding $cf_add_libdir to library-path ..." 1>&5
-
-                               LDFLAGS="-L$cf_add_libdir $LDFLAGS"
-                       fi
-               fi
+               test "$cf_cv_sig_atomic_t" != no && break
        done
-fi
 
-       fi
 fi
 
-cf_cv_screen=curses
-
-echo "$as_me:4633: checking for specified curses library type" >&5
-echo $ECHO_N "checking for specified curses library type... $ECHO_C" >&6
-
-# Check whether --with-screen or --without-screen was given.
-if test "${with_screen+set}" = set; then
-  withval="$with_screen"
-  cf_cv_screen=$withval
-else
-
-# Check whether --with-ncursesw or --without-ncursesw was given.
-if test "${with_ncursesw+set}" = set; then
-  withval="$with_ncursesw"
-  cf_cv_screen=ncursesw
-else
-
-# Check whether --with-ncurses or --without-ncurses was given.
-if test "${with_ncurses+set}" = set; then
-  withval="$with_ncurses"
-  cf_cv_screen=ncurses
-else
-
-# Check whether --with-pdcurses or --without-pdcurses was given.
-if test "${with_pdcurses+set}" = set; then
-  withval="$with_pdcurses"
-  cf_cv_screen=pdcurses
-else
-
-# Check whether --with-curses-colr or --without-curses-colr was given.
-if test "${with_curses_colr+set}" = set; then
-  withval="$with_curses_colr"
-  cf_cv_screen=curses_colr
-else
-
-# Check whether --with-curses-5lib or --without-curses-5lib was given.
-if test "${with_curses_5lib+set}" = set; then
-  withval="$with_curses_5lib"
-  cf_cv_screen=curses_5lib
-fi;
-fi;
-fi;
-fi;
-fi;
-fi;
-
-echo "$as_me:4677: result: $cf_cv_screen" >&5
-echo "${ECHO_T}$cf_cv_screen" >&6
+echo "$as_me:4564: result: $cf_cv_sig_atomic_t" >&5
+echo "${ECHO_T}$cf_cv_sig_atomic_t" >&6
+test "$cf_cv_sig_atomic_t" != no &&
+cat >>confdefs.h <<EOF
+#define SIG_ATOMIC_T $cf_cv_sig_atomic_t
+EOF
 
-case $cf_cv_screen in
-(curses|curses_*)
+# Work around breakage on OS X
 
-echo "$as_me:4683: checking for extra include directories" >&5
-echo $ECHO_N "checking for extra include directories... $ECHO_C" >&6
-if test "${cf_cv_curses_incdir+set}" = set; then
+echo "$as_me:4573: checking if SIGWINCH is defined" >&5
+echo $ECHO_N "checking if SIGWINCH is defined... $ECHO_C" >&6
+if test "${cf_cv_define_sigwinch+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cf_cv_curses_incdir=no
-case $host_os in
-(hpux10.*)
-       if test "x$cf_cv_screen" = "xcurses_colr"
-       then
-               test -d /usr/include/curses_colr && \
-               cf_cv_curses_incdir="-I/usr/include/curses_colr"
-       fi
-       ;;
-(sunos3*|sunos4*)
-       if test "x$cf_cv_screen" = "xcurses_5lib"
-       then
-               test -d /usr/5lib && \
-               test -d /usr/5include && \
-               cf_cv_curses_incdir="-I/usr/5include"
-       fi
-       ;;
-esac
-
-fi
-echo "$as_me:4709: result: $cf_cv_curses_incdir" >&5
-echo "${ECHO_T}$cf_cv_curses_incdir" >&6
-test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4580 "configure"
+#include "confdefs.h"
 
-echo "$as_me:4713: checking if we have identified curses headers" >&5
-echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
-if test "${cf_cv_ncurses_header+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+#include <sys/types.h>
+#include <sys/signal.h>
 
-cf_cv_ncurses_header=none
-for cf_header in \
-       ncurses.h  \
-       curses.h  ncurses/ncurses.h ncurses/curses.h
-do
-cat >conftest.$ac_ext <<_ACEOF
-#line 4725 "configure"
-#include "confdefs.h"
-#include <${cf_header}>
 int
-main ()
+main (void)
 {
-initscr(); tgoto("?", 0,0)
+int x = SIGWINCH
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4737: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:4595: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4740: \$? = $ac_status" >&5
+  echo "$as_me:4598: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4743: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4601: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4746: \$? = $ac_status" >&5
+  echo "$as_me:4604: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_ncurses_header=$cf_header; break
+  cf_cv_define_sigwinch=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-done
-
-fi
-echo "$as_me:4757: result: $cf_cv_ncurses_header" >&5
-echo "${ECHO_T}$cf_cv_ncurses_header" >&6
-
-if test "$cf_cv_ncurses_header" = none ; then
-       { { echo "$as_me:4761: error: No curses header-files found" >&5
-echo "$as_me: error: No curses header-files found" >&2;}
-   { (exit 1); exit 1; }; }
-fi
+cat >conftest.$ac_ext <<_ACEOF
+#line 4611 "configure"
+#include "confdefs.h"
 
-# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
 
-for ac_header in $cf_cv_ncurses_header
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:4771: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 4777 "configure"
-#include "confdefs.h"
-#include <$ac_header>
+int
+main (void)
+{
+int x = SIGWINCH
+  ;
+  return 0;
+}
 _ACEOF
-if { (eval echo "$as_me:4781: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4629: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:4787: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  eval "$as_ac_Header=yes"
+  echo "$as_me:4632: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4635: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4638: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_define_sigwinch=maybe
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  eval "$as_ac_Header=no"
+cat conftest.$ac_ext >&5
+cf_cv_define_sigwinch=no
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.$ac_objext conftest.$ac_ext
+
 fi
-echo "$as_me:4806: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-EOF
+rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-done
+echo "$as_me:4652: result: $cf_cv_define_sigwinch" >&5
+echo "${ECHO_T}$cf_cv_define_sigwinch" >&6
 
-echo "$as_me:4816: checking for terminfo header" >&5
-echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
-if test "${cf_cv_term_header+set}" = set; then
+if test "$cf_cv_define_sigwinch" = maybe ; then
+echo "$as_me:4656: checking for actual SIGWINCH definition" >&5
+echo $ECHO_N "checking for actual SIGWINCH definition... $ECHO_C" >&6
+if test "${cf_cv_fixup_sigwinch+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-case ${cf_cv_ncurses_header} in
-(*/ncurses.h|*/ncursesw.h)
-       cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
-       ;;
-(*)
-       cf_term_header=term.h
-       ;;
-esac
-
-for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
+cf_cv_fixup_sigwinch=unknown
+cf_sigwinch=32
+while test $cf_sigwinch != 1
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 4834 "configure"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4667 "configure"
 #include "confdefs.h"
-#include <stdio.h>
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <$cf_test>
+
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
 
 int
-main ()
+main (void)
 {
-int x = auto_left_margin
+
+#if SIGWINCH != $cf_sigwinch
+make an error
+#endif
+int x = SIGWINCH
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4849: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:4689: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4852: \$? = $ac_status" >&5
+  echo "$as_me:4692: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4855: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4695: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4858: \$? = $ac_status" >&5
+  echo "$as_me:4698: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-       cf_cv_term_header="$cf_test"
+  cf_cv_fixup_sigwinch=$cf_sigwinch
+        break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-
-       cf_cv_term_header=unknown
-
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-       test "$cf_cv_term_header" != unknown && break
+
+cf_sigwinch=`expr $cf_sigwinch - 1`
 done
 
 fi
-echo "$as_me:4874: result: $cf_cv_term_header" >&5
-echo "${ECHO_T}$cf_cv_term_header" >&6
-
-# Set definitions to allow ifdef'ing to accommodate subdirectories
-
-case $cf_cv_term_header in
-(*term.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_TERM_H 1
-EOF
-
-       ;;
-esac
-
-case $cf_cv_term_header in
-(ncurses/term.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSES_TERM_H 1
-EOF
-
-       ;;
-(ncursesw/term.h)
+echo "$as_me:4712: result: $cf_cv_fixup_sigwinch" >&5
+echo "${ECHO_T}$cf_cv_fixup_sigwinch" >&6
 
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSESW_TERM_H 1
-EOF
+       if test "$cf_cv_fixup_sigwinch" != unknown ; then
+               CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
+       fi
+fi
 
-       ;;
-esac
+# Checks for CODESET support.
 
-echo "$as_me:4906: checking for ncurses version" >&5
-echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
-if test "${cf_cv_ncurses_version+set}" = set; then
+echo "$as_me:4722: checking for nl_langinfo and CODESET" >&5
+echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
+if test "${am_cv_langinfo_codeset+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-       cf_cv_ncurses_version=no
-       cf_tempfile=out$$
-       rm -f $cf_tempfile
-       if test "$cross_compiling" = yes; then
-
-       # This will not work if the preprocessor splits the line after the
-       # Autoconf token.  The 'unproto' program does that.
-       cat > conftest.$ac_ext <<EOF
-#include <${cf_cv_ncurses_header:-curses.h}>
-#undef Autoconf
-#ifdef NCURSES_VERSION
-Autoconf NCURSES_VERSION
-#else
-#ifdef __NCURSES_H
-Autoconf "old"
-#endif
-;
-#endif
-EOF
-       cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-       { (eval echo "$as_me:4932: \"$cf_try\"") >&5
-  (eval $cf_try) 2>&5
-  ac_status=$?
-  echo "$as_me:4935: \$? = $ac_status" >&5
-  (exit $ac_status); }
-       if test -f conftest.out ; then
-               cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
-               test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
-               rm -f conftest.out
-       fi
-
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 4945 "configure"
-#include "confdefs.h"
-
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <stdio.h>
-int main()
-{
-       FILE *fp = fopen("$cf_tempfile", "w");
-#ifdef NCURSES_VERSION
-# ifdef NCURSES_VERSION_PATCH
-       fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
-# else
-       fprintf(fp, "%s\n", NCURSES_VERSION);
-# endif
-#else
-# ifdef __NCURSES_H
-       fprintf(fp, "old\n");
-# else
-       make an error
-# endif
-#endif
-       ${cf_cv_main_return:-return}(0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:4970: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:4973: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:4975: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:4978: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-       cf_cv_ncurses_version=`cat $cf_tempfile`
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-       rm -f $cf_tempfile
-
-fi
-echo "$as_me:4992: result: $cf_cv_ncurses_version" >&5
-echo "${ECHO_T}$cf_cv_ncurses_version" >&6
-test "$cf_cv_ncurses_version" = no ||
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
-
-echo "$as_me:4999: checking if we have identified curses libraries" >&5
-echo $ECHO_N "checking if we have identified curses libraries... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 5002 "configure"
+#line 4728 "configure"
 #include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
+#include <langinfo.h>
 int
-main ()
+main (void)
 {
-initscr(); tgoto("?", 0,0)
+char* cs = nl_langinfo(CODESET);
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5014: \"$ac_link\"") >&5
+if { (eval echo "$as_me:4740: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5017: \$? = $ac_status" >&5
+  echo "$as_me:4743: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5020: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4746: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5023: \$? = $ac_status" >&5
+  echo "$as_me:4749: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  am_cv_langinfo_codeset=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
+am_cv_langinfo_codeset=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-echo "$as_me:5032: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
 
-if test "$cf_result" = no ; then
-case $host_os in
-(freebsd*)
-       echo "$as_me:5038: checking for tgoto in -lmytinfo" >&5
-echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
-if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:4760: result: $am_cv_langinfo_codeset" >&5
+echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
+       if test $am_cv_langinfo_codeset = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_LANGINFO_CODESET 1
+EOF
+
+       fi
+
+echo "$as_me:4770: checking if you want to use pkg-config" >&5
+echo $ECHO_N "checking if you want to use pkg-config... $ECHO_C" >&6
+
+# Check whether --with-pkg-config or --without-pkg-config was given.
+if test "${with_pkg_config+set}" = set; then
+  withval="$with_pkg_config"
+  cf_pkg_config=$withval
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmytinfo  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 5046 "configure"
-#include "confdefs.h"
+  cf_pkg_config=yes
+fi;
+echo "$as_me:4780: result: $cf_pkg_config" >&5
+echo "${ECHO_T}$cf_pkg_config" >&6
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char tgoto ();
-int
-main ()
-{
-tgoto ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5065: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:5068: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5071: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:5074: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_mytinfo_tgoto=yes
+case $cf_pkg_config in
+(no)
+       PKG_CONFIG=none
+       ;;
+(yes)
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+echo "$as_me:4792: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_mytinfo_tgoto=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word"
+   echo "$as_me:4809: found $ac_dir/$ac_word" >&5
+   break
 fi
-echo "$as_me:5085: result: $ac_cv_lib_mytinfo_tgoto" >&5
-echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
-if test $ac_cv_lib_mytinfo_tgoto = yes; then
-
-cf_add_libs="-lmytinfo"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
 done
-LIBS="$cf_add_libs"
 
+  ;;
+esac
 fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
 
-       ;;
-(hpux10.*)
-       # Looking at HPUX 10.20, the Hcurses library is the oldest (1997), cur_colr
-       # next (1998), and xcurses "newer" (2000).  There is no header file for
-       # Hcurses; the subdirectory curses_colr has the headers (curses.h and
-       # term.h) for cur_colr
-       if test "x$cf_cv_screen" = "xcurses_colr"
-       then
-               echo "$as_me:5115: checking for initscr in -lcur_colr" >&5
-echo $ECHO_N "checking for initscr in -lcur_colr... $ECHO_C" >&6
-if test "${ac_cv_lib_cur_colr_initscr+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+if test -n "$PKG_CONFIG"; then
+  echo "$as_me:4820: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcur_colr  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 5123 "configure"
-#include "confdefs.h"
+  echo "$as_me:4823: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char initscr ();
-int
-main ()
-{
-initscr ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5142: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:5145: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5148: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:5151: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_cur_colr_initscr=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_cur_colr_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:4832: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_ac_pt_PKG_CONFIG="$ac_dir/$ac_word"
+   echo "$as_me:4849: found $ac_dir/$ac_word" >&5
+   break
 fi
-echo "$as_me:5162: result: $ac_cv_lib_cur_colr_initscr" >&5
-echo "${ECHO_T}$ac_cv_lib_cur_colr_initscr" >&6
-if test $ac_cv_lib_cur_colr_initscr = yes; then
-
-cf_add_libs="-lcur_colr"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
 done
-LIBS="$cf_add_libs"
 
-                       ac_cv_func_initscr=yes
+  test -z "$ac_cv_path_ac_pt_PKG_CONFIG" && ac_cv_path_ac_pt_PKG_CONFIG="none"
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
 
+if test -n "$ac_pt_PKG_CONFIG"; then
+  echo "$as_me:4861: result: $ac_pt_PKG_CONFIG" >&5
+echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6
 else
+  echo "$as_me:4864: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
 
-               echo "$as_me:5186: checking for initscr in -lHcurses" >&5
-echo $ECHO_N "checking for initscr in -lHcurses... $ECHO_C" >&6
-if test "${ac_cv_lib_Hcurses_initscr+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  PKG_CONFIG=$ac_pt_PKG_CONFIG
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lHcurses  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 5194 "configure"
-#include "confdefs.h"
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char initscr ();
-int
-main ()
-{
-initscr ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5213: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:5216: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5219: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:5222: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_Hcurses_initscr=yes
+       ;;
+(*)
+       PKG_CONFIG=$withval
+       ;;
+esac
+
+test -z "$PKG_CONFIG" && PKG_CONFIG=none
+if test "$PKG_CONFIG" != none ; then
+
+if test "x$prefix" != xNONE; then
+       cf_path_syntax="$prefix"
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_Hcurses_initscr=no
+       cf_path_syntax="$ac_default_prefix"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+
+case ".$PKG_CONFIG" in
+(.\$\(*\)*|.\'*\'*)
+       ;;
+(..|./*|.\\*)
+       ;;
+(.[a-zA-Z]:[\\/]*) # OS/2 EMX
+       ;;
+(.\${*prefix}*|.\${*dir}*)
+       eval PKG_CONFIG="$PKG_CONFIG"
+       case ".$PKG_CONFIG" in
+       (.NONE/*)
+               PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
+               ;;
+       esac
+       ;;
+(.no|.NONE/*)
+       PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
+       ;;
+(*)
+       { { echo "$as_me:4907: error: expected a pathname, not \"$PKG_CONFIG\"" >&5
+echo "$as_me: error: expected a pathname, not \"$PKG_CONFIG\"" >&2;}
+   { (exit 1); exit 1; }; }
+       ;;
+esac
+
+elif test "x$cf_pkg_config" != xno ; then
+       { echo "$as_me:4914: WARNING: pkg-config is not installed" >&5
+echo "$as_me: WARNING: pkg-config is not installed" >&2;}
 fi
-echo "$as_me:5233: result: $ac_cv_lib_Hcurses_initscr" >&5
-echo "${ECHO_T}$ac_cv_lib_Hcurses_initscr" >&6
-if test $ac_cv_lib_Hcurses_initscr = yes; then
 
-                       # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
+echo "$as_me:4918: checking if you want to see long compiling messages" >&5
+echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6
 
-cf_add_libs="-lHcurses"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
+# Check whether --enable-echo or --disable-echo was given.
+if test "${enable_echo+set}" = set; then
+  enableval="$enable_echo"
+  test "$enableval" != no && enableval=yes
+       if test "$enableval" != "yes" ; then
 
-                       CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
-                       ac_cv_func_initscr=yes
+       ECHO_LT='--silent'
+       ECHO_LD='@echo linking $@;'
+       RULE_CC='@echo compiling $<'
+       SHOW_CC='@echo compiling $@'
+       ECHO_CC='@'
 
-fi
+       else
 
-fi
+       ECHO_LT=''
+       ECHO_LD=''
+       RULE_CC=''
+       SHOW_CC=''
+       ECHO_CC=''
 
        fi
-       ;;
-(linux*)
-       case `arch 2>/dev/null` in
-       (x86_64)
-               if test -d /lib64
-               then
+else
+  enableval=yes
 
-if test -n "/lib64" ; then
-       for cf_add_libdir in /lib64
-       do
-               if test $cf_add_libdir = /usr/lib ; then
-                       :
-               elif test -d $cf_add_libdir
-               then
-                       cf_have_libdir=no
-                       if test -n "$LDFLAGS$LIBS" ; then
-                               # a loop is needed to ensure we can add subdirs of existing dirs
-                               for cf_test_libdir in $LDFLAGS $LIBS ; do
-                                       if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
-                                               cf_have_libdir=yes; break
-                                       fi
-                               done
-                       fi
-                       if test "$cf_have_libdir" = no ; then
-                               test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
+       ECHO_LT=''
+       ECHO_LD=''
+       RULE_CC=''
+       SHOW_CC=''
+       ECHO_CC=''
 
-echo "${as_me:-configure}:5289: testing adding $cf_add_libdir to library-path ..." 1>&5
+fi;
+echo "$as_me:4952: result: $enableval" >&5
+echo "${ECHO_T}$enableval" >&6
 
-                               LDFLAGS="-L$cf_add_libdir $LDFLAGS"
-                       fi
-               fi
-       done
-fi
+echo "$as_me:4955: checking for ncurses wrap-prefix" >&5
+echo $ECHO_N "checking for ncurses wrap-prefix... $ECHO_C" >&6
 
-               else
+# Check whether --with-ncurses-wrap-prefix or --without-ncurses-wrap-prefix was given.
+if test "${with_ncurses_wrap_prefix+set}" = set; then
+  withval="$with_ncurses_wrap_prefix"
+  NCURSES_WRAP_PREFIX=$withval
+else
+  NCURSES_WRAP_PREFIX=_nc_
+fi;
+echo "$as_me:4965: result: $NCURSES_WRAP_PREFIX" >&5
+echo "${ECHO_T}$NCURSES_WRAP_PREFIX" >&6
 
-if test -n "/lib" ; then
-       for cf_add_libdir in /lib
-       do
-               if test $cf_add_libdir = /usr/lib ; then
-                       :
-               elif test -d $cf_add_libdir
-               then
-                       cf_have_libdir=no
-                       if test -n "$LDFLAGS$LIBS" ; then
-                               # a loop is needed to ensure we can add subdirs of existing dirs
-                               for cf_test_libdir in $LDFLAGS $LIBS ; do
-                                       if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
-                                               cf_have_libdir=yes; break
-                                       fi
-                               done
-                       fi
-                       if test "$cf_have_libdir" = no ; then
-                               test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
+echo "$as_me:4968: checking if you want to check for wide-character functions" >&5
+echo $ECHO_N "checking if you want to check for wide-character functions... $ECHO_C" >&6
+
+# Check whether --enable-widec or --disable-widec was given.
+if test "${enable_widec+set}" = set; then
+  enableval="$enable_widec"
+  test "$enableval" != no && enableval=yes
+       if test "$enableval" != "yes" ; then
+    cf_enable_widec=no
+       else
+               cf_enable_widec=yes
+       fi
+else
+  enableval=yes
+       cf_enable_widec=yes
 
-echo "${as_me:-configure}:5318: testing adding $cf_add_libdir to library-path ..." 1>&5
+fi;
+echo "$as_me:4985: result: $cf_enable_widec" >&5
+echo "${ECHO_T}$cf_enable_widec" >&6
 
-                               LDFLAGS="-L$cf_add_libdir $LDFLAGS"
-                       fi
-               fi
-       done
+echo "$as_me:4988: checking for specific curses-directory" >&5
+echo $ECHO_N "checking for specific curses-directory... $ECHO_C" >&6
+
+# Check whether --with-curses-dir or --without-curses-dir was given.
+if test "${with_curses_dir+set}" = set; then
+  withval="$with_curses_dir"
+  cf_cv_curses_dir=$withval
+else
+  cf_cv_curses_dir=no
+fi;
+echo "$as_me:4998: result: $cf_cv_curses_dir" >&5
+echo "${ECHO_T}$cf_cv_curses_dir" >&6
+
+if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
+then
+
+if test "x$prefix" != xNONE; then
+       cf_path_syntax="$prefix"
+else
+       cf_path_syntax="$ac_default_prefix"
 fi
 
-               fi
+case ".$withval" in
+(.\$\(*\)*|.\'*\'*)
+       ;;
+(..|./*|.\\*)
+       ;;
+(.[a-zA-Z]:[\\/]*) # OS/2 EMX
+       ;;
+(.\${*prefix}*|.\${*dir}*)
+       eval withval="$withval"
+       case ".$withval" in
+       (.NONE/*)
+               withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
                ;;
-       (*)
+       esac
+       ;;
+(.no|.NONE/*)
+       withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
+       ;;
+(*)
+       { { echo "$as_me:5029: error: expected a pathname, not \"$withval\"" >&5
+echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
+   { (exit 1); exit 1; }; }
+       ;;
+esac
 
-if test -n "/lib" ; then
-       for cf_add_libdir in /lib
+       if test -d "$cf_cv_curses_dir"
+       then
+
+if test -n "$cf_cv_curses_dir/include" ; then
+  for cf_add_incdir in $cf_cv_curses_dir/include
+  do
+       while test $cf_add_incdir != /usr/include
        do
-               if test $cf_add_libdir = /usr/lib ; then
-                       :
-               elif test -d $cf_add_libdir
-               then
-                       cf_have_libdir=no
-                       if test -n "$LDFLAGS$LIBS" ; then
-                               # a loop is needed to ensure we can add subdirs of existing dirs
-                               for cf_test_libdir in $LDFLAGS $LIBS ; do
-                                       if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
-                                               cf_have_libdir=yes; break
-                                       fi
-                               done
+         if test -d $cf_add_incdir
+         then
+               cf_have_incdir=no
+               if test -n "$CFLAGS$CPPFLAGS" ; then
+                 # a loop is needed to ensure we can add subdirs of existing dirs
+                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
+                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
+                         cf_have_incdir=yes; break
                        fi
-                       if test "$cf_have_libdir" = no ; then
-                               test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
-
-echo "${as_me:-configure}:5349: testing adding $cf_add_libdir to library-path ..." 1>&5
+                 done
+               fi
 
-                               LDFLAGS="-L$cf_add_libdir $LDFLAGS"
+               if test "$cf_have_incdir" = no ; then
+                 if test "$cf_add_incdir" = /usr/local/include ; then
+                       if test "$GCC" = yes
+                       then
+                         cf_save_CPPFLAGS=$CPPFLAGS
+                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+                         cat >conftest.$ac_ext <<_ACEOF
+#line 5062 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int
+main (void)
+{
+printf("Hello")
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:5074: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:5077: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:5080: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5083: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_have_incdir=yes
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+                         CPPFLAGS=$cf_save_CPPFLAGS
                        fi
+                 fi
+               fi
+
+               if test "$cf_have_incdir" = no ; then
+                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
+
+echo "${as_me:-configure}:5100: testing adding $cf_add_incdir to include-path ..." 1>&5
+
+                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+
+                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+                 test "$cf_top_incdir" = "$cf_add_incdir" && break
+                 cf_add_incdir="$cf_top_incdir"
+               else
+                 break
                fi
+         else
+               break
+         fi
        done
+  done
 fi
 
-               ;;
-       esac
-       ;;
-(sunos3*|sunos4*)
-       if test "x$cf_cv_screen" = "xcurses_5lib"
-       then
-               if test -d /usr/5lib ; then
-
-if test -n "/usr/5lib" ; then
-       for cf_add_libdir in /usr/5lib
+if test -n "$cf_cv_curses_dir/lib" ; then
+       for cf_add_libdir in $cf_cv_curses_dir/lib
        do
                if test $cf_add_libdir = /usr/lib ; then
                        :
@@ -5381,7 +5133,7 @@ if test -n "/usr/5lib" ; then
                        if test "$cf_have_libdir" = no ; then
                                test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:5384: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:5136: testing adding $cf_add_libdir to library-path ..." 1>&5
 
                                LDFLAGS="-L$cf_add_libdir $LDFLAGS"
                        fi
@@ -5389,856 +5141,745 @@ echo "${as_me:-configure}:5384: testing adding $cf_add_libdir to library-path ..
        done
 fi
 
-cf_add_libs="-lcurses -ltermcap"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
-
-               fi
        fi
-       ac_cv_func_initscr=yes
-       ;;
-esac
+fi
 
-if test ".$ac_cv_func_initscr" != .yes ; then
-       cf_save_LIBS="$LIBS"
+cf_cv_screen=curses
 
-       if test ".${cf_cv_ncurses_version:-no}" != .no
-       then
-               cf_check_list="ncurses curses cursesX"
-       else
-               cf_check_list="cursesX curses ncurses"
-       fi
+echo "$as_me:5149: checking for specified curses library type" >&5
+echo $ECHO_N "checking for specified curses library type... $ECHO_C" >&6
 
-       # Check for library containing tgoto.  Do this before curses library
-       # because it may be needed to link the test-case for initscr.
-       if test "x$cf_term_lib" = x
-       then
-               echo "$as_me:5428: checking for tgoto" >&5
-echo $ECHO_N "checking for tgoto... $ECHO_C" >&6
-if test "${ac_cv_func_tgoto+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+# Check whether --with-screen or --without-screen was given.
+if test "${with_screen+set}" = set; then
+  withval="$with_screen"
+  cf_cv_screen=$withval
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 5434 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char tgoto (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char tgoto ();
-char (*f) ();
 
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_tgoto) || defined (__stub___tgoto)
-choke me
-#else
-f = tgoto; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
+# Check whether --with-ncursesw or --without-ncursesw was given.
+if test "${with_ncursesw+set}" = set; then
+  withval="$with_ncursesw"
+  cf_cv_screen=ncursesw
+else
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5465: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:5468: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5471: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:5474: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_tgoto=yes
+# Check whether --with-ncurses or --without-ncurses was given.
+if test "${with_ncurses+set}" = set; then
+  withval="$with_ncurses"
+  cf_cv_screen=ncurses
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_tgoto=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:5484: result: $ac_cv_func_tgoto" >&5
-echo "${ECHO_T}$ac_cv_func_tgoto" >&6
-if test $ac_cv_func_tgoto = yes; then
-  cf_term_lib=predefined
+
+# Check whether --with-pdcurses or --without-pdcurses was given.
+if test "${with_pdcurses+set}" = set; then
+  withval="$with_pdcurses"
+  cf_cv_screen=pdcurses
 else
 
-                       for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
-                       do
-                               as_ac_Lib=`echo "ac_cv_lib_$cf_term_lib''_tgoto" | $as_tr_sh`
-echo "$as_me:5493: checking for tgoto in -l$cf_term_lib" >&5
-echo $ECHO_N "checking for tgoto in -l$cf_term_lib... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+# Check whether --with-curses-colr or --without-curses-colr was given.
+if test "${with_curses_colr+set}" = set; then
+  withval="$with_curses_colr"
+  cf_cv_screen=curses_colr
+else
+
+# Check whether --with-curses-5lib or --without-curses-5lib was given.
+if test "${with_curses_5lib+set}" = set; then
+  withval="$with_curses_5lib"
+  cf_cv_screen=curses_5lib
+fi;
+fi;
+fi;
+fi;
+fi;
+fi;
+
+echo "$as_me:5193: result: $cf_cv_screen" >&5
+echo "${ECHO_T}$cf_cv_screen" >&6
+
+case $cf_cv_screen in
+(curses|curses_*)
+
+echo "$as_me:5199: checking for extra include directories" >&5
+echo $ECHO_N "checking for extra include directories... $ECHO_C" >&6
+if test "${cf_cv_curses_incdir+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$cf_term_lib  $LIBS"
+
+cf_cv_curses_incdir=no
+case $host_os in
+(hpux10.*)
+       if test "x$cf_cv_screen" = "xcurses_colr"
+       then
+               test -d /usr/include/curses_colr && \
+               cf_cv_curses_incdir="-I/usr/include/curses_colr"
+       fi
+       ;;
+(sunos3*|sunos4*)
+       if test "x$cf_cv_screen" = "xcurses_5lib"
+       then
+               test -d /usr/5lib && \
+               test -d /usr/5include && \
+               cf_cv_curses_incdir="-I/usr/5include"
+       fi
+       ;;
+esac
+
+fi
+echo "$as_me:5225: result: $cf_cv_curses_incdir" >&5
+echo "${ECHO_T}$cf_cv_curses_incdir" >&6
+test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
+
+echo "$as_me:5229: checking if we have identified curses headers" >&5
+echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
+if test "${cf_cv_ncurses_header+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_cv_ncurses_header=none
+for cf_header in \
+       ncurses.h  \
+       curses.h  ncurses/ncurses.h ncurses/curses.h
+do
 cat >conftest.$ac_ext <<_ACEOF
-#line 5501 "configure"
+#line 5241 "configure"
 #include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char tgoto ();
+#include <${cf_header}>
 int
-main ()
+main (void)
 {
-tgoto ();
+initscr(); tgoto("?", 0,0)
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5520: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:5253: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:5523: \$? = $ac_status" >&5
+  echo "$as_me:5256: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5526: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:5259: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5529: \$? = $ac_status" >&5
+  echo "$as_me:5262: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
+  cf_cv_ncurses_header=$cf_header; break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:5540: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  break
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
 
-                       done
+fi
+echo "$as_me:5273: result: $cf_cv_ncurses_header" >&5
+echo "${ECHO_T}$cf_cv_ncurses_header" >&6
 
+if test "$cf_cv_ncurses_header" = none ; then
+       { { echo "$as_me:5277: error: No curses header-files found" >&5
+echo "$as_me: error: No curses header-files found" >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
-       fi
+# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
 
-       # Check for library containing initscr
-       test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
-       if test "x$cf_curs_lib" = x
-       then
-               for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
-               do
-                       as_ac_Lib=`echo "ac_cv_lib_$cf_curs_lib''_initscr" | $as_tr_sh`
-echo "$as_me:5559: checking for initscr in -l$cf_curs_lib" >&5
-echo $ECHO_N "checking for initscr in -l$cf_curs_lib... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+for ac_header in $cf_cv_ncurses_header
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:5287: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$cf_curs_lib  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 5567 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5293 "configure"
 #include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char initscr ();
-int
-main ()
-{
-initscr ();
-  ;
-  return 0;
-}
+#include <$ac_header>
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5586: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:5589: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5592: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+if { (eval echo "$as_me:5297: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
-  echo "$as_me:5595: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:5303: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:5606: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  break
+echo "$as_me:5322: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
 fi
+done
 
-               done
-       fi
-       test $cf_curs_lib = unknown && { { echo "$as_me:5614: error: no curses library found" >&5
-echo "$as_me: error: no curses library found" >&2;}
-   { (exit 1); exit 1; }; }
+echo "$as_me:5332: checking for terminfo header" >&5
+echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
+if test "${cf_cv_term_header+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-       LIBS="-l$cf_curs_lib $cf_save_LIBS"
-       if test "$cf_term_lib" = unknown ; then
-               echo "$as_me:5620: checking if we can link with $cf_curs_lib library" >&5
-echo $ECHO_N "checking if we can link with $cf_curs_lib library... $ECHO_C" >&6
-               cat >conftest.$ac_ext <<_ACEOF
-#line 5623 "configure"
+case ${cf_cv_ncurses_header} in
+(*/ncurses.h|*/ncursesw.h)
+       cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
+       ;;
+(*)
+       cf_term_header=term.h
+       ;;
+esac
+
+for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
+do
+cat >conftest.$ac_ext <<_ACEOF
+#line 5350 "configure"
 #include "confdefs.h"
+#include <stdio.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
+#include <$cf_test>
+
 int
-main ()
+main (void)
 {
-initscr()
+int x = auto_left_margin
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5635: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:5365: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:5638: \$? = $ac_status" >&5
+  echo "$as_me:5368: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5641: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:5371: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5644: \$? = $ac_status" >&5
+  echo "$as_me:5374: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+
+       cf_cv_term_header="$cf_test"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
+
+       cf_cv_term_header=unknown
+
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-               echo "$as_me:5653: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-               test $cf_result = no && { { echo "$as_me:5655: error: Cannot link curses library" >&5
-echo "$as_me: error: Cannot link curses library" >&2;}
-   { (exit 1); exit 1; }; }
-       elif test "$cf_curs_lib" = "$cf_term_lib" ; then
-               :
-       elif test "$cf_term_lib" != predefined ; then
-               echo "$as_me:5661: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
-echo $ECHO_N "checking if we need both $cf_curs_lib and $cf_term_lib libraries... $ECHO_C" >&6
-               cat >conftest.$ac_ext <<_ACEOF
-#line 5664 "configure"
-#include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
-int
-main ()
-{
-initscr(); tgoto((char *)0, 0, 0);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5676: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:5679: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5682: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:5685: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=no
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+rm -f conftest.$ac_objext conftest.$ac_ext
+       test "$cf_cv_term_header" != unknown && break
+done
 
-                       LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
-                       cat >conftest.$ac_ext <<_ACEOF
-#line 5694 "configure"
-#include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
-int
-main ()
-{
-initscr()
-  ;
-  return 0;
+fi
+echo "$as_me:5390: result: $cf_cv_term_header" >&5
+echo "${ECHO_T}$cf_cv_term_header" >&6
+
+# Set definitions to allow ifdef'ing to accommodate subdirectories
+
+case $cf_cv_term_header in
+(*term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_TERM_H 1
+EOF
+
+       ;;
+esac
+
+case $cf_cv_term_header in
+(ncurses/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_TERM_H 1
+EOF
+
+       ;;
+(ncursesw/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_TERM_H 1
+EOF
+
+       ;;
+esac
+
+echo "$as_me:5422: checking for ncurses version" >&5
+echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
+if test "${cf_cv_ncurses_version+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cf_cv_ncurses_version=no
+       cf_tempfile=out$$
+       rm -f $cf_tempfile
+       if test "$cross_compiling" = yes; then
+
+       # This will not work if the preprocessor splits the line after the
+       # Autoconf token.  The 'unproto' program does that.
+       cat > conftest.$ac_ext <<EOF
+#include <${cf_cv_ncurses_header:-curses.h}>
+#undef Autoconf
+#ifdef NCURSES_VERSION
+Autoconf NCURSES_VERSION
+#else
+#ifdef __NCURSES_H
+Autoconf "old"
+#endif
+;
+#endif
+EOF
+       cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
+       { (eval echo "$as_me:5448: \"$cf_try\"") >&5
+  (eval $cf_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5451: \$? = $ac_status" >&5
+  (exit $ac_status); }
+       if test -f conftest.out ; then
+               cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+               test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
+               rm -f conftest.out
+       fi
+
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5461 "configure"
+#include "confdefs.h"
+
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <stdio.h>
+int main(void)
+{
+       FILE *fp = fopen("$cf_tempfile", "w");
+#ifdef NCURSES_VERSION
+# ifdef NCURSES_VERSION_PATCH
+       fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
+# else
+       fprintf(fp, "%s\n", NCURSES_VERSION);
+# endif
+#else
+# ifdef __NCURSES_H
+       fprintf(fp, "old\n");
+# else
+       make an error
+# endif
+#endif
+       ${cf_cv_main_return:-return}(0);
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5706: \"$ac_link\"") >&5
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:5486: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5709: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5712: \"$ac_try\"") >&5
+  echo "$as_me:5489: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:5491: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5715: \$? = $ac_status" >&5
+  echo "$as_me:5494: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+
+       cf_cv_ncurses_version=`cat $cf_tempfile`
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=error
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-               echo "$as_me:5727: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-       fi
 fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
+       rm -f $cf_tempfile
 
-       ;;
-(ncursesw*)
-
-echo "$as_me:5736: checking for multibyte character support" >&5
-echo $ECHO_N "checking for multibyte character support... $ECHO_C" >&6
-if test "${cf_cv_utf8_lib+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+fi
+echo "$as_me:5508: result: $cf_cv_ncurses_version" >&5
+echo "${ECHO_T}$cf_cv_ncurses_version" >&6
+test "$cf_cv_ncurses_version" = no ||
+cat >>confdefs.h <<\EOF
+#define NCURSES 1
+EOF
 
-       cf_save_LIBS="$LIBS"
-       cat >conftest.$ac_ext <<_ACEOF
-#line 5744 "configure"
+echo "$as_me:5515: checking if we have identified curses libraries" >&5
+echo $ECHO_N "checking if we have identified curses libraries... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 5518 "configure"
 #include "confdefs.h"
-
-#include <stdlib.h>
+#include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-putwc(0,0);
+initscr(); tgoto("?", 0,0)
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5757: \"$ac_link\"") >&5
+if { (eval echo "$as_me:5530: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5760: \$? = $ac_status" >&5
+  echo "$as_me:5533: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5763: \"$ac_try\"") >&5
+  { (eval echo "$as_me:5536: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5766: \$? = $ac_status" >&5
+  echo "$as_me:5539: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_utf8_lib=yes
+  cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+cf_result=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+echo "$as_me:5548: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
 
-# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
-# will be set on completion of the AC_TRY_LINK below.
-cf_cv_header_path_utf8=
-cf_cv_library_path_utf8=
-
-echo "${as_me:-configure}:5778: testing Starting FIND_LINKAGE(utf8,) ..." 1>&5
-
-cf_save_LIBS="$LIBS"
-
+if test "$cf_result" = no ; then
+case $host_os in
+(freebsd*)
+       echo "$as_me:5554: checking for tgoto in -lmytinfo" >&5
+echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
+if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmytinfo  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 5783 "configure"
+#line 5562 "configure"
 #include "confdefs.h"
 
-#include <libutf8.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char tgoto ();
 int
-main ()
+main (void)
 {
-putwc(0,0);
+tgoto ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5796: \"$ac_link\"") >&5
+if { (eval echo "$as_me:5581: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5799: \$? = $ac_status" >&5
+  echo "$as_me:5584: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5802: \"$ac_try\"") >&5
+  { (eval echo "$as_me:5587: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5805: \$? = $ac_status" >&5
+  echo "$as_me:5590: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-       cf_cv_find_linkage_utf8=yes
-       cf_cv_header_path_utf8=/usr/include
-       cf_cv_library_path_utf8=/usr/lib
-
+  ac_cv_lib_mytinfo_tgoto=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+ac_cv_lib_mytinfo_tgoto=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:5601: result: $ac_cv_lib_mytinfo_tgoto" >&5
+echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
+if test $ac_cv_lib_mytinfo_tgoto = yes; then
 
-LIBS="-lutf8  $cf_save_LIBS"
+cf_add_libs="-lmytinfo"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
+fi
+
+       ;;
+(hpux10.*)
+       # Looking at HPUX 10.20, the Hcurses library is the oldest (1997), cur_colr
+       # next (1998), and xcurses "newer" (2000).  There is no header file for
+       # Hcurses; the subdirectory curses_colr has the headers (curses.h and
+       # term.h) for cur_colr
+       if test "x$cf_cv_screen" = "xcurses_colr"
+       then
+               echo "$as_me:5631: checking for initscr in -lcur_colr" >&5
+echo $ECHO_N "checking for initscr in -lcur_colr... $ECHO_C" >&6
+if test "${ac_cv_lib_cur_colr_initscr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcur_colr  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 5819 "configure"
+#line 5639 "configure"
 #include "confdefs.h"
 
-#include <libutf8.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char initscr ();
 int
-main ()
+main (void)
 {
-putwc(0,0);
+initscr ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5832: \"$ac_link\"") >&5
+if { (eval echo "$as_me:5658: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5835: \$? = $ac_status" >&5
+  echo "$as_me:5661: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5838: \"$ac_try\"") >&5
+  { (eval echo "$as_me:5664: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5841: \$? = $ac_status" >&5
+  echo "$as_me:5667: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-       cf_cv_find_linkage_utf8=yes
-       cf_cv_header_path_utf8=/usr/include
-       cf_cv_library_path_utf8=/usr/lib
-       cf_cv_library_file_utf8="-lutf8"
-
+  ac_cv_lib_cur_colr_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+ac_cv_lib_cur_colr_initscr=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:5678: result: $ac_cv_lib_cur_colr_initscr" >&5
+echo "${ECHO_T}$ac_cv_lib_cur_colr_initscr" >&6
+if test $ac_cv_lib_cur_colr_initscr = yes; then
 
-       cf_cv_find_linkage_utf8=no
-       LIBS="$cf_save_LIBS"
+cf_add_libs="-lcur_colr"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-       test -n "$verbose" && echo "    find linkage for utf8 library" 1>&6
+                       ac_cv_func_initscr=yes
 
-echo "${as_me:-configure}:5858: testing find linkage for utf8 library ..." 1>&5
+else
 
-echo "${as_me:-configure}:5860: testing Searching for headers in FIND_LINKAGE(utf8,) ..." 1>&5
-
-       cf_save_CPPFLAGS="$CPPFLAGS"
-       cf_test_CPPFLAGS="$CPPFLAGS"
-
-cf_search=
-
-# collect the current set of include-directories from compiler flags
-cf_header_path_list=""
-if test -n "${CFLAGS}${CPPFLAGS}" ; then
-       for cf_header_path in $CPPFLAGS $CFLAGS
-       do
-               case $cf_header_path in
-               (-I*)
-                       cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
-
-test "x$cf_header_path" != "xNONE" && \
-test -d "$cf_header_path" && \
- {
-       test -n "$verbose" && echo "    ... testing for include-directories under $cf_header_path"
-       test -d $cf_header_path/include &&          cf_search="$cf_search $cf_header_path/include"
-       test -d $cf_header_path/include/utf8 &&       cf_search="$cf_search $cf_header_path/include/utf8"
-       test -d $cf_header_path/include/utf8/include &&    cf_search="$cf_search $cf_header_path/include/utf8/include"
-       test -d $cf_header_path/utf8/include &&       cf_search="$cf_search $cf_header_path/utf8/include"
-       test -d $cf_header_path/utf8/include/utf8 &&    cf_search="$cf_search $cf_header_path/utf8/include/utf8"
-}
-
-                       cf_header_path_list="$cf_header_path_list $cf_search"
-                       ;;
-               esac
-       done
-fi
-
-# add the variations for the package we are looking for
-
-cf_search=
-
-test "x$prefix" != "xNONE" && \
-test -d "$prefix" && \
- {
-       test -n "$verbose" && echo "    ... testing for include-directories under $prefix"
-       test -d $prefix/include &&          cf_search="$cf_search $prefix/include"
-       test -d $prefix/include/utf8 &&       cf_search="$cf_search $prefix/include/utf8"
-       test -d $prefix/include/utf8/include &&    cf_search="$cf_search $prefix/include/utf8/include"
-       test -d $prefix/utf8/include &&       cf_search="$cf_search $prefix/utf8/include"
-       test -d $prefix/utf8/include/utf8 &&    cf_search="$cf_search $prefix/utf8/include/utf8"
-}
-
-for cf_subdir_prefix in \
-       /usr \
-       /usr/local \
-       /usr/pkg \
-       /opt \
-       /opt/local \
-       $HOME
-do
-
-test "x$cf_subdir_prefix" != "x$prefix" && \
-test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
-       test -n "$verbose" && echo "    ... testing for include-directories under $cf_subdir_prefix"
-       test -d $cf_subdir_prefix/include &&          cf_search="$cf_search $cf_subdir_prefix/include"
-       test -d $cf_subdir_prefix/include/utf8 &&       cf_search="$cf_search $cf_subdir_prefix/include/utf8"
-       test -d $cf_subdir_prefix/include/utf8/include &&    cf_search="$cf_search $cf_subdir_prefix/include/utf8/include"
-       test -d $cf_subdir_prefix/utf8/include &&       cf_search="$cf_search $cf_subdir_prefix/utf8/include"
-       test -d $cf_subdir_prefix/utf8/include/utf8 &&    cf_search="$cf_search $cf_subdir_prefix/utf8/include/utf8"
-}
-
-done
-
-test "$includedir" != NONE && \
-test "$includedir" != "/usr/include" && \
-test -d "$includedir" && {
-       test -d $includedir &&    cf_search="$cf_search $includedir"
-       test -d $includedir/utf8 && cf_search="$cf_search $includedir/utf8"
-}
-
-test "$oldincludedir" != NONE && \
-test "$oldincludedir" != "/usr/include" && \
-test -d "$oldincludedir" && {
-       test -d $oldincludedir    && cf_search="$cf_search $oldincludedir"
-       test -d $oldincludedir/utf8 && cf_search="$cf_search $oldincludedir/utf8"
-}
-
-cf_search="$cf_search $cf_header_path_list"
-
-       for cf_cv_header_path_utf8 in $cf_search
-       do
-               if test -d $cf_cv_header_path_utf8 ; then
-                       test -n "$verbose" && echo "    ... testing $cf_cv_header_path_utf8" 1>&6
-
-echo "${as_me:-configure}:5951: testing ... testing $cf_cv_header_path_utf8 ..." 1>&5
-
-                       CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_utf8"
-                       cat >conftest.$ac_ext <<_ACEOF
-#line 5955 "configure"
+               echo "$as_me:5702: checking for initscr in -lHcurses" >&5
+echo $ECHO_N "checking for initscr in -lHcurses... $ECHO_C" >&6
+if test "${ac_cv_lib_Hcurses_initscr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lHcurses  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 5710 "configure"
 #include "confdefs.h"
 
-#include <libutf8.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char initscr ();
 int
-main ()
+main (void)
 {
-putwc(0,0);
+initscr ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:5968: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:5729: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5971: \$? = $ac_status" >&5
+  echo "$as_me:5732: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:5974: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:5735: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5977: \$? = $ac_status" >&5
+  echo "$as_me:5738: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-                               test -n "$verbose" && echo "    ... found utf8 headers in $cf_cv_header_path_utf8" 1>&6
-
-echo "${as_me:-configure}:5982: testing ... found utf8 headers in $cf_cv_header_path_utf8 ..." 1>&5
-
-                               cf_cv_find_linkage_utf8=maybe
-                               cf_test_CPPFLAGS="$CPPFLAGS"
-                               break
+  ac_cv_lib_Hcurses_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+ac_cv_lib_Hcurses_initscr=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:5749: result: $ac_cv_lib_Hcurses_initscr" >&5
+echo "${ECHO_T}$ac_cv_lib_Hcurses_initscr" >&6
+if test $ac_cv_lib_Hcurses_initscr = yes; then
 
-                               CPPFLAGS="$cf_save_CPPFLAGS"
+                       # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
 
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+cf_add_libs="-lHcurses"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
                fi
        done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-       if test "$cf_cv_find_linkage_utf8" = maybe ; then
+                       CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
+                       ac_cv_func_initscr=yes
 
-echo "${as_me:-configure}:6000: testing Searching for utf8 library in FIND_LINKAGE(utf8,) ..." 1>&5
+fi
 
-               cf_save_LIBS="$LIBS"
-               cf_save_LDFLAGS="$LDFLAGS"
+fi
 
-               if test "$cf_cv_find_linkage_utf8" != yes ; then
+       fi
+       ;;
+(linux*)
+       case `arch 2>/dev/null` in
+       (x86_64)
+               if test -d /lib64
+               then
 
-cf_search=
-cf_library_path_list=""
-if test -n "${LDFLAGS}${LIBS}" ; then
-       for cf_library_path in $LDFLAGS $LIBS
+if test -n "/lib64" ; then
+       for cf_add_libdir in /lib64
        do
-               case $cf_library_path in
-               (-L*)
-                       cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
+               if test $cf_add_libdir = /usr/lib ; then
+                       :
+               elif test -d $cf_add_libdir
+               then
+                       cf_have_libdir=no
+                       if test -n "$LDFLAGS$LIBS" ; then
+                               # a loop is needed to ensure we can add subdirs of existing dirs
+                               for cf_test_libdir in $LDFLAGS $LIBS ; do
+                                       if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
+                                               cf_have_libdir=yes; break
+                                       fi
+                               done
+                       fi
+                       if test "$cf_have_libdir" = no ; then
+                               test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
 
-test "x$cf_library_path" != "xNONE" && \
-test -d "$cf_library_path" && \
- {
-       test -n "$verbose" && echo "    ... testing for lib-directories under $cf_library_path"
-       test -d $cf_library_path/lib &&          cf_search="$cf_search $cf_library_path/lib"
-       test -d $cf_library_path/lib/utf8 &&       cf_search="$cf_search $cf_library_path/lib/utf8"
-       test -d $cf_library_path/lib/utf8/lib &&    cf_search="$cf_search $cf_library_path/lib/utf8/lib"
-       test -d $cf_library_path/utf8/lib &&       cf_search="$cf_search $cf_library_path/utf8/lib"
-       test -d $cf_library_path/utf8/lib/utf8 &&    cf_search="$cf_search $cf_library_path/utf8/lib/utf8"
-}
+echo "${as_me:-configure}:5805: testing adding $cf_add_libdir to library-path ..." 1>&5
 
-                       cf_library_path_list="$cf_library_path_list $cf_search"
-                       ;;
-               esac
+                               LDFLAGS="-L$cf_add_libdir $LDFLAGS"
+                       fi
+               fi
        done
 fi
 
-cf_search=
+               else
 
-test "x$prefix" != "xNONE" && \
-test -d "$prefix" && \
- {
-       test -n "$verbose" && echo "    ... testing for lib-directories under $prefix"
-       test -d $prefix/lib &&          cf_search="$cf_search $prefix/lib"
-       test -d $prefix/lib/utf8 &&       cf_search="$cf_search $prefix/lib/utf8"
-       test -d $prefix/lib/utf8/lib &&    cf_search="$cf_search $prefix/lib/utf8/lib"
-       test -d $prefix/utf8/lib &&       cf_search="$cf_search $prefix/utf8/lib"
-       test -d $prefix/utf8/lib/utf8 &&    cf_search="$cf_search $prefix/utf8/lib/utf8"
-}
+if test -n "/lib" ; then
+       for cf_add_libdir in /lib
+       do
+               if test $cf_add_libdir = /usr/lib ; then
+                       :
+               elif test -d $cf_add_libdir
+               then
+                       cf_have_libdir=no
+                       if test -n "$LDFLAGS$LIBS" ; then
+                               # a loop is needed to ensure we can add subdirs of existing dirs
+                               for cf_test_libdir in $LDFLAGS $LIBS ; do
+                                       if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
+                                               cf_have_libdir=yes; break
+                                       fi
+                               done
+                       fi
+                       if test "$cf_have_libdir" = no ; then
+                               test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
 
-for cf_subdir_prefix in \
-       /usr \
-       /usr/local \
-       /usr/pkg \
-       /opt \
-       /opt/local \
-       $HOME
-do
+echo "${as_me:-configure}:5834: testing adding $cf_add_libdir to library-path ..." 1>&5
 
-test "x$cf_subdir_prefix" != "x$prefix" && \
-test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
-       test -n "$verbose" && echo "    ... testing for lib-directories under $cf_subdir_prefix"
-       test -d $cf_subdir_prefix/lib &&          cf_search="$cf_search $cf_subdir_prefix/lib"
-       test -d $cf_subdir_prefix/lib/utf8 &&       cf_search="$cf_search $cf_subdir_prefix/lib/utf8"
-       test -d $cf_subdir_prefix/lib/utf8/lib &&    cf_search="$cf_search $cf_subdir_prefix/lib/utf8/lib"
-       test -d $cf_subdir_prefix/utf8/lib &&       cf_search="$cf_search $cf_subdir_prefix/utf8/lib"
-       test -d $cf_subdir_prefix/utf8/lib/utf8 &&    cf_search="$cf_search $cf_subdir_prefix/utf8/lib/utf8"
-}
+                               LDFLAGS="-L$cf_add_libdir $LDFLAGS"
+                       fi
+               fi
+       done
+fi
 
-done
-
-cf_search="$cf_library_path_list $cf_search"
-
-                       for cf_cv_library_path_utf8 in $cf_search
-                       do
-                               if test -d $cf_cv_library_path_utf8 ; then
-                                       test -n "$verbose" && echo "    ... testing $cf_cv_library_path_utf8" 1>&6
-
-echo "${as_me:-configure}:6075: testing ... testing $cf_cv_library_path_utf8 ..." 1>&5
-
-                                       CPPFLAGS="$cf_test_CPPFLAGS"
-                                       LIBS="-lutf8  $cf_save_LIBS"
-                                       LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_utf8"
-                                       cat >conftest.$ac_ext <<_ACEOF
-#line 6081 "configure"
-#include "confdefs.h"
-
-#include <libutf8.h>
-int
-main ()
-{
-putwc(0,0);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:6094: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:6097: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:6100: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6103: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-                                       test -n "$verbose" && echo "    ... found utf8 library in $cf_cv_library_path_utf8" 1>&6
-
-echo "${as_me:-configure}:6108: testing ... found utf8 library in $cf_cv_library_path_utf8 ..." 1>&5
-
-                                       cf_cv_find_linkage_utf8=yes
-                                       cf_cv_library_file_utf8="-lutf8"
-                                       break
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-
-                                       CPPFLAGS="$cf_save_CPPFLAGS"
-                                       LIBS="$cf_save_LIBS"
-                                       LDFLAGS="$cf_save_LDFLAGS"
-
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-                               fi
-                       done
-                       CPPFLAGS="$cf_save_CPPFLAGS"
-                       LDFLAGS="$cf_save_LDFLAGS"
                fi
+               ;;
+       (*)
 
-       else
-               cf_cv_find_linkage_utf8=no
-       fi
-
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-LIBS="$cf_save_LIBS"
-
-if test "$cf_cv_find_linkage_utf8" = yes ; then
-cf_cv_utf8_lib=add-on
-else
-cf_cv_utf8_lib=no
-fi
-
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:6150: result: $cf_cv_utf8_lib" >&5
-echo "${ECHO_T}$cf_cv_utf8_lib" >&6
-
-# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
-# ncurses/ncursesw:
-if test "$cf_cv_utf8_lib" = "add-on" ; then
-
-cat >>confdefs.h <<\EOF
-#define HAVE_LIBUTF8_H 1
-EOF
-
-if test -n "$cf_cv_header_path_utf8" ; then
-  for cf_add_incdir in $cf_cv_header_path_utf8
-  do
-       while test $cf_add_incdir != /usr/include
+if test -n "/lib" ; then
+       for cf_add_libdir in /lib
        do
-         if test -d $cf_add_incdir
-         then
-               cf_have_incdir=no
-               if test -n "$CFLAGS$CPPFLAGS" ; then
-                 # a loop is needed to ensure we can add subdirs of existing dirs
-                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
-                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
-                         cf_have_incdir=yes; break
-                       fi
-                 done
-               fi
-
-               if test "$cf_have_incdir" = no ; then
-                 if test "$cf_add_incdir" = /usr/local/include ; then
-                       if test "$GCC" = yes
-                       then
-                         cf_save_CPPFLAGS=$CPPFLAGS
-                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-                         cat >conftest.$ac_ext <<_ACEOF
-#line 6185 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-int
-main ()
-{
-printf("Hello")
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6197: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6200: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6203: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6206: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_have_incdir=yes
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-                         CPPFLAGS=$cf_save_CPPFLAGS
+               if test $cf_add_libdir = /usr/lib ; then
+                       :
+               elif test -d $cf_add_libdir
+               then
+                       cf_have_libdir=no
+                       if test -n "$LDFLAGS$LIBS" ; then
+                               # a loop is needed to ensure we can add subdirs of existing dirs
+                               for cf_test_libdir in $LDFLAGS $LIBS ; do
+                                       if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
+                                               cf_have_libdir=yes; break
+                                       fi
+                               done
                        fi
-                 fi
-               fi
-
-               if test "$cf_have_incdir" = no ; then
-                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
-
-echo "${as_me:-configure}:6223: testing adding $cf_add_incdir to include-path ..." 1>&5
+                       if test "$cf_have_libdir" = no ; then
+                               test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
 
-                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+echo "${as_me:-configure}:5865: testing adding $cf_add_libdir to library-path ..." 1>&5
 
-                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
-                 test "$cf_top_incdir" = "$cf_add_incdir" && break
-                 cf_add_incdir="$cf_top_incdir"
-               else
-                 break
+                               LDFLAGS="-L$cf_add_libdir $LDFLAGS"
+                       fi
                fi
-         else
-               break
-         fi
        done
-  done
 fi
 
-if test -n "$cf_cv_library_path_utf8" ; then
-       for cf_add_libdir in $cf_cv_library_path_utf8
+               ;;
+       esac
+       ;;
+(sunos3*|sunos4*)
+       if test "x$cf_cv_screen" = "xcurses_5lib"
+       then
+               if test -d /usr/5lib ; then
+
+if test -n "/usr/5lib" ; then
+       for cf_add_libdir in /usr/5lib
        do
                if test $cf_add_libdir = /usr/lib ; then
                        :
@@ -6256,7 +5897,7 @@ if test -n "$cf_cv_library_path_utf8" ; then
                        if test "$cf_have_libdir" = no ; then
                                test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:6259: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:5900: testing adding $cf_add_libdir to library-path ..." 1>&5
 
                                LDFLAGS="-L$cf_add_libdir $LDFLAGS"
                        fi
@@ -6264,7 +5905,7 @@ echo "${as_me:-configure}:6259: testing adding $cf_add_libdir to library-path ..
        done
 fi
 
-cf_add_libs="$cf_cv_library_file_utf8"
+cf_add_libs="-lcurses -ltermcap"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-fi
-
-cf_ncuconfig_root=$cf_cv_screen
-cf_have_ncuconfig=no
-
-if test "x${PKG_CONFIG:=none}" != xnone; then
-       echo "$as_me:6289: checking pkg-config for $cf_ncuconfig_root" >&5
-echo $ECHO_N "checking pkg-config for $cf_ncuconfig_root... $ECHO_C" >&6
-       if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
-               echo "$as_me:6292: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-               echo "$as_me:6295: checking if the $cf_ncuconfig_root package files work" >&5
-echo $ECHO_N "checking if the $cf_ncuconfig_root package files work... $ECHO_C" >&6
-               cf_have_ncuconfig=unknown
-
-               cf_save_CPPFLAGS="$CPPFLAGS"
-               cf_save_LIBS="$LIBS"
+               fi
+       fi
+       ac_cv_func_initscr=yes
+       ;;
+esac
 
-               CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
+if test ".$ac_cv_func_initscr" != .yes ; then
+       cf_save_LIBS="$LIBS"
 
-cf_add_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
+       if test ".${cf_cv_ncurses_version:-no}" != .no
+       then
+               cf_check_list="ncurses curses cursesX"
+       else
+               cf_check_list="cursesX curses ncurses"
+       fi
 
-               cat >conftest.$ac_ext <<_ACEOF
-#line 6321 "configure"
-#include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
-int
-main ()
-{
-initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:6333: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:6336: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:6339: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6342: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  if test "$cross_compiling" = yes; then
-  cf_have_ncuconfig=maybe
+       # Check for library containing tgoto.  Do this before curses library
+       # because it may be needed to link the test-case for initscr.
+       if test "x$cf_term_lib" = x
+       then
+               echo "$as_me:5944: checking for tgoto" >&5
+echo $ECHO_N "checking for tgoto... $ECHO_C" >&6
+if test "${ac_cv_func_tgoto+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 6348 "configure"
+#line 5950 "configure"
 #include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
-                               int main(void)
-                               { char *xx = curses_version(); return (xx == 0); }
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char tgoto (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char tgoto ();
+char (*f) ();
+
+int
+main (void)
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_tgoto) || defined (__stub___tgoto)
+choke me
+#else
+f = tgoto; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
+
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:6355: \"$ac_link\"") >&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:5981: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6358: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:6360: \"$ac_try\"") >&5
+  echo "$as_me:5984: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:5987: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6363: \$? = $ac_status" >&5
+  echo "$as_me:5990: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_have_ncuconfig=yes
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_have_ncuconfig=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
+  ac_cv_func_tgoto=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_have_ncuconfig=no
+ac_cv_func_tgoto=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-               echo "$as_me:6380: result: $cf_have_ncuconfig" >&5
-echo "${ECHO_T}$cf_have_ncuconfig" >&6
-               test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
-               if test "$cf_have_ncuconfig" != "yes"
-               then
-                       CPPFLAGS="$cf_save_CPPFLAGS"
-                       LIBS="$cf_save_LIBS"
-                       NCURSES_CONFIG_PKG=none
-               else
-
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
-
-                       NCURSES_CONFIG_PKG=$cf_ncuconfig_root
-               fi
-
-       else
-               echo "$as_me:6398: result: no" >&5
-echo "${ECHO_T}no" >&6
-               NCURSES_CONFIG_PKG=none
-       fi
-else
-       NCURSES_CONFIG_PKG=none
-fi
-
-if test "x$cf_have_ncuconfig" = "xno"; then
-       echo "Looking for ${cf_ncuconfig_root}-config"
-
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:6414: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_NCURSES_CONFIG+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$NCURSES_CONFIG"; then
-  ac_cv_prog_NCURSES_CONFIG="$NCURSES_CONFIG" # Let the user override the test.
-else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_NCURSES_CONFIG="$ac_tool_prefix$ac_prog"
-echo "$as_me:6429: found $ac_dir/$ac_word" >&5
-break
-done
-
 fi
-fi
-NCURSES_CONFIG=$ac_cv_prog_NCURSES_CONFIG
-if test -n "$NCURSES_CONFIG"; then
-  echo "$as_me:6437: result: $NCURSES_CONFIG" >&5
-echo "${ECHO_T}$NCURSES_CONFIG" >&6
+echo "$as_me:6000: result: $ac_cv_func_tgoto" >&5
+echo "${ECHO_T}$ac_cv_func_tgoto" >&6
+if test $ac_cv_func_tgoto = yes; then
+  cf_term_lib=predefined
 else
-  echo "$as_me:6440: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
 
-    test -n "$NCURSES_CONFIG" && break
-  done
-fi
-if test -z "$NCURSES_CONFIG"; then
-  ac_ct_NCURSES_CONFIG=$NCURSES_CONFIG
-  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:6453: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_NCURSES_CONFIG+set}" = set; then
+                       for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
+                       do
+                               as_ac_Lib=`echo "ac_cv_lib_$cf_term_lib''_tgoto" | $as_tr_sh`
+echo "$as_me:6009: checking for tgoto in -l$cf_term_lib" >&5
+echo $ECHO_N "checking for tgoto in -l$cf_term_lib... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$ac_ct_NCURSES_CONFIG"; then
-  ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_ct_NCURSES_CONFIG" # Let the user override the test.
-else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_prog"
-echo "$as_me:6468: found $ac_dir/$ac_word" >&5
-break
-done
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$cf_term_lib  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 6017 "configure"
+#include "confdefs.h"
 
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char tgoto ();
+int
+main (void)
+{
+tgoto ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6036: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6039: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6042: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6045: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Lib=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_Lib=no"
 fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-ac_ct_NCURSES_CONFIG=$ac_cv_prog_ac_ct_NCURSES_CONFIG
-if test -n "$ac_ct_NCURSES_CONFIG"; then
-  echo "$as_me:6476: result: $ac_ct_NCURSES_CONFIG" >&5
-echo "${ECHO_T}$ac_ct_NCURSES_CONFIG" >&6
-else
-  echo "$as_me:6479: result: no" >&5
-echo "${ECHO_T}no" >&6
+echo "$as_me:6056: result: `eval echo '${'$as_ac_Lib'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+  break
 fi
 
-  test -n "$ac_ct_NCURSES_CONFIG" && break
-done
-test -n "$ac_ct_NCURSES_CONFIG" || ac_ct_NCURSES_CONFIG="none"
+                       done
 
-  NCURSES_CONFIG=$ac_ct_NCURSES_CONFIG
 fi
 
-       if test "$NCURSES_CONFIG" != none ; then
-
-               CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
-
-cf_add_libs="`$NCURSES_CONFIG --libs`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
-
-               # even with config script, some packages use no-override for curses.h
-
-echo "$as_me:6512: checking if we have identified curses headers" >&5
-echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
-if test "${cf_cv_ncurses_header+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+       fi
 
-cf_cv_ncurses_header=none
-for cf_header in \
-       ncurses.h $cf_cv_screen/ncurses.h \
-       curses.h $cf_cv_screen/curses.h
-do
-cat >conftest.$ac_ext <<_ACEOF
-#line 6524 "configure"
+       # Check for library containing initscr
+       test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
+       if test "x$cf_curs_lib" = x
+       then
+               for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
+               do
+                       LIBS="-l$cf_curs_lib $cf_save_LIBS"
+                       if test "$cf_term_lib" = unknown || test "$cf_term_lib" = "$cf_curs_lib" ; then
+                               echo "$as_me:6076: checking if we can link with $cf_curs_lib library" >&5
+echo $ECHO_N "checking if we can link with $cf_curs_lib library... $ECHO_C" >&6
+                               cat >conftest.$ac_ext <<_ACEOF
+#line 6079 "configure"
 #include "confdefs.h"
-#include <${cf_header}>
+#include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-initscr(); tgoto("?", 0,0)
+initscr()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6536: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6091: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6539: \$? = $ac_status" >&5
+  echo "$as_me:6094: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6542: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6097: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6545: \$? = $ac_status" >&5
+  echo "$as_me:6100: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_ncurses_header=$cf_header; break
+  cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-done
-
-fi
-echo "$as_me:6556: result: $cf_cv_ncurses_header" >&5
-echo "${ECHO_T}$cf_cv_ncurses_header" >&6
-
-if test "$cf_cv_ncurses_header" = none ; then
-       { { echo "$as_me:6560: error: No curses header-files found" >&5
-echo "$as_me: error: No curses header-files found" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
-
-for ac_header in $cf_cv_ncurses_header
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:6570: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 6576 "configure"
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+                               echo "$as_me:6109: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+                               test $cf_result = yes && break
+                       elif test "$cf_curs_lib" = "$cf_term_lib" ; then
+                               cf_result=no
+                       elif test "$cf_term_lib" != predefined ; then
+                               echo "$as_me:6115: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
+echo $ECHO_N "checking if we need both $cf_curs_lib and $cf_term_lib libraries... $ECHO_C" >&6
+                               cat >conftest.$ac_ext <<_ACEOF
+#line 6118 "configure"
 #include "confdefs.h"
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:6580: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+initscr(); tgoto((char *)0, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6130: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:6586: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
+  echo "$as_me:6133: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6136: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6139: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_result=no
 else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  eval "$as_ac_Header=yes"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+                                       LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
+                                       cat >conftest.$ac_ext <<_ACEOF
+#line 6148 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+initscr()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6160: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6163: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6166: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6169: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_ext
+cat conftest.$ac_ext >&5
+cf_result=error
 fi
-echo "$as_me:6605: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-EOF
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 fi
-done
-
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
-
-cf_nculib_ROOT=`echo "HAVE_LIB$cf_ncuconfig_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-               cat >>confdefs.h <<EOF
-#define $cf_nculib_ROOT 1
-EOF
-
-                               cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
-
-       else
-
-cf_ncuhdr_root=$cf_cv_screen
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+                               echo "$as_me:6181: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+                               test $cf_result != error && break
+                       fi
+               done
+       fi
+       test $cf_curs_lib = unknown && { { echo "$as_me:6187: error: no curses library found" >&5
+echo "$as_me: error: no curses library found" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+fi
 
-test -n "$cf_cv_curses_dir" && \
-test "$cf_cv_curses_dir" != "no" && { \
+       ;;
+(ncursesw*)
 
-if test -n "$cf_cv_curses_dir/include/$cf_ncuhdr_root" ; then
-  for cf_add_incdir in $cf_cv_curses_dir/include/$cf_ncuhdr_root
-  do
-       while test $cf_add_incdir != /usr/include
-       do
-         if test -d $cf_add_incdir
-         then
-               cf_have_incdir=no
-               if test -n "$CFLAGS$CPPFLAGS" ; then
-                 # a loop is needed to ensure we can add subdirs of existing dirs
-                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
-                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
-                         cf_have_incdir=yes; break
-                       fi
-                 done
-               fi
+echo "$as_me:6196: checking for multibyte character support" >&5
+echo $ECHO_N "checking for multibyte character support... $ECHO_C" >&6
+if test "${cf_cv_utf8_lib+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-               if test "$cf_have_incdir" = no ; then
-                 if test "$cf_add_incdir" = /usr/local/include ; then
-                       if test "$GCC" = yes
-                       then
-                         cf_save_CPPFLAGS=$CPPFLAGS
-                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-                         cat >conftest.$ac_ext <<_ACEOF
-#line 6658 "configure"
+       cf_save_LIBS="$LIBS"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 6204 "configure"
 #include "confdefs.h"
-#include <stdio.h>
+
+#include <stdlib.h>
 int
-main ()
+main (void)
 {
-printf("Hello")
+putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6670: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6217: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6673: \$? = $ac_status" >&5
+  echo "$as_me:6220: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6676: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6223: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6679: \$? = $ac_status" >&5
+  echo "$as_me:6226: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+  cf_cv_utf8_lib=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_have_incdir=yes
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-                         CPPFLAGS=$cf_save_CPPFLAGS
-                       fi
-                 fi
-               fi
 
-               if test "$cf_have_incdir" = no ; then
-                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
+# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
+# will be set on completion of the AC_TRY_LINK below.
+cf_cv_header_path_utf8=
+cf_cv_library_path_utf8=
 
-echo "${as_me:-configure}:6696: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:6238: testing Starting FIND_LINKAGE(utf8,) ..." 1>&5
 
-                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+cf_save_LIBS="$LIBS"
 
-                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
-                 test "$cf_top_incdir" = "$cf_add_incdir" && break
-                 cf_add_incdir="$cf_top_incdir"
-               else
-                 break
-               fi
-         else
-               break
-         fi
-       done
-  done
-fi
+cat >conftest.$ac_ext <<_ACEOF
+#line 6243 "configure"
+#include "confdefs.h"
 
+#include <libutf8.h>
+int
+main (void)
+{
+putwc(0,0);
+  ;
+  return 0;
 }
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6256: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6259: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6262: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6265: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+       cf_cv_find_linkage_utf8=yes
+       cf_cv_header_path_utf8=/usr/include
+       cf_cv_library_path_utf8=/usr/lib
 
-echo "$as_me:6715: checking for $cf_ncuhdr_root header in include-path" >&5
-echo $ECHO_N "checking for $cf_ncuhdr_root header in include-path... $ECHO_C" >&6
-if test "${cf_cv_ncurses_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
 
-       cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
-       ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
-       for cf_header in $cf_header_list
-       do
+LIBS="-lutf8  $cf_save_LIBS"
 
-       cat >conftest.$ac_ext <<_ACEOF
-#line 6727 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 6279 "configure"
 #include "confdefs.h"
 
-#include <$cf_header>
+#include <libutf8.h>
 int
-main ()
+main (void)
 {
-
-#ifdef NCURSES_VERSION
-
-printf("%s\n", NCURSES_VERSION);
-#else
-#ifdef __NCURSES_H
-printf("old\n");
-#else
-       make an error
-#endif
-#endif
-
+putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6751: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6292: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6754: \$? = $ac_status" >&5
+  echo "$as_me:6295: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6757: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6298: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6760: \$? = $ac_status" >&5
+  echo "$as_me:6301: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_ncurses_h=$cf_header
+
+       cf_cv_find_linkage_utf8=yes
+       cf_cv_header_path_utf8=/usr/include
+       cf_cv_library_path_utf8=/usr/lib
+       cf_cv_library_file_utf8="-lutf8"
 
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_ncurses_h=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
 
-               test "$cf_cv_ncurses_h" != no && break
-       done
+       cf_cv_find_linkage_utf8=no
+       LIBS="$cf_save_LIBS"
 
-fi
-echo "$as_me:6775: result: $cf_cv_ncurses_h" >&5
-echo "${ECHO_T}$cf_cv_ncurses_h" >&6
+       test -n "$verbose" && echo "    find linkage for utf8 library" 1>&6
 
-if test "$cf_cv_ncurses_h" != no ; then
-       cf_cv_ncurses_header=$cf_cv_ncurses_h
-else
+echo "${as_me:-configure}:6318: testing find linkage for utf8 library ..." 1>&5
 
-echo "$as_me:6782: checking for $cf_ncuhdr_root include-path" >&5
-echo $ECHO_N "checking for $cf_ncuhdr_root include-path... $ECHO_C" >&6
-if test "${cf_cv_ncurses_h2+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+echo "${as_me:-configure}:6320: testing Searching for headers in FIND_LINKAGE(utf8,) ..." 1>&5
 
-       test -n "$verbose" && echo
+       cf_save_CPPFLAGS="$CPPFLAGS"
+       cf_test_CPPFLAGS="$CPPFLAGS"
 
 cf_search=
 
@@ -6803,10 +6338,10 @@ test -d "$cf_header_path" && \
  {
        test -n "$verbose" && echo "    ... testing for include-directories under $cf_header_path"
        test -d $cf_header_path/include &&          cf_search="$cf_search $cf_header_path/include"
-       test -d $cf_header_path/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root"
-       test -d $cf_header_path/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root/include"
-       test -d $cf_header_path/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include"
-       test -d $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+       test -d $cf_header_path/include/utf8 &&       cf_search="$cf_search $cf_header_path/include/utf8"
+       test -d $cf_header_path/include/utf8/include &&    cf_search="$cf_search $cf_header_path/include/utf8/include"
+       test -d $cf_header_path/utf8/include &&       cf_search="$cf_search $cf_header_path/utf8/include"
+       test -d $cf_header_path/utf8/include/utf8 &&    cf_search="$cf_search $cf_header_path/utf8/include/utf8"
 }
 
                        cf_header_path_list="$cf_header_path_list $cf_search"
@@ -6824,11 +6359,11 @@ test -d "$prefix" && \
  {
        test -n "$verbose" && echo "    ... testing for include-directories under $prefix"
        test -d $prefix/include &&          cf_search="$cf_search $prefix/include"
-       test -d $prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
-       test -d $prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
-       test -d $prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
-       test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
-}
+       test -d $prefix/include/utf8 &&       cf_search="$cf_search $prefix/include/utf8"
+       test -d $prefix/include/utf8/include &&    cf_search="$cf_search $prefix/include/utf8/include"
+       test -d $prefix/utf8/include &&       cf_search="$cf_search $prefix/utf8/include"
+       test -d $prefix/utf8/include/utf8 &&    cf_search="$cf_search $prefix/utf8/include/utf8"
+}
 
 for cf_subdir_prefix in \
        /usr \
@@ -6844,10 +6379,10 @@ test -d "$cf_subdir_prefix" && \
 (test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
        test -n "$verbose" && echo "    ... testing for include-directories under $cf_subdir_prefix"
        test -d $cf_subdir_prefix/include &&          cf_search="$cf_search $cf_subdir_prefix/include"
-       test -d $cf_subdir_prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root"
-       test -d $cf_subdir_prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root/include"
-       test -d $cf_subdir_prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include"
-       test -d $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+       test -d $cf_subdir_prefix/include/utf8 &&       cf_search="$cf_search $cf_subdir_prefix/include/utf8"
+       test -d $cf_subdir_prefix/include/utf8/include &&    cf_search="$cf_search $cf_subdir_prefix/include/utf8/include"
+       test -d $cf_subdir_prefix/utf8/include &&       cf_search="$cf_search $cf_subdir_prefix/utf8/include"
+       test -d $cf_subdir_prefix/utf8/include/utf8 &&    cf_search="$cf_search $cf_subdir_prefix/utf8/include/utf8"
 }
 
 done
@@ -6856,178 +6391,235 @@ test "$includedir" != NONE && \
 test "$includedir" != "/usr/include" && \
 test -d "$includedir" && {
        test -d $includedir &&    cf_search="$cf_search $includedir"
-       test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
+       test -d $includedir/utf8 && cf_search="$cf_search $includedir/utf8"
 }
 
 test "$oldincludedir" != NONE && \
 test "$oldincludedir" != "/usr/include" && \
 test -d "$oldincludedir" && {
        test -d $oldincludedir    && cf_search="$cf_search $oldincludedir"
-       test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
+       test -d $oldincludedir/utf8 && cf_search="$cf_search $oldincludedir/utf8"
 }
 
 cf_search="$cf_search $cf_header_path_list"
 
-       test -n "$verbose" && echo search path $cf_search
-       cf_save2_CPPFLAGS="$CPPFLAGS"
-       for cf_incdir in $cf_search
+       for cf_cv_header_path_utf8 in $cf_search
        do
+               if test -d $cf_cv_header_path_utf8 ; then
+                       test -n "$verbose" && echo "    ... testing $cf_cv_header_path_utf8" 1>&6
 
-if test -n "$cf_incdir" ; then
-  for cf_add_incdir in $cf_incdir
-  do
-       while test $cf_add_incdir != /usr/include
-       do
-         if test -d $cf_add_incdir
-         then
-               cf_have_incdir=no
-               if test -n "$CFLAGS$CPPFLAGS" ; then
-                 # a loop is needed to ensure we can add subdirs of existing dirs
-                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
-                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
-                         cf_have_incdir=yes; break
-                       fi
-                 done
-               fi
+echo "${as_me:-configure}:6411: testing ... testing $cf_cv_header_path_utf8 ..." 1>&5
 
-               if test "$cf_have_incdir" = no ; then
-                 if test "$cf_add_incdir" = /usr/local/include ; then
-                       if test "$GCC" = yes
-                       then
-                         cf_save_CPPFLAGS=$CPPFLAGS
-                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-                         cat >conftest.$ac_ext <<_ACEOF
-#line 6900 "configure"
+                       CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_utf8"
+                       cat >conftest.$ac_ext <<_ACEOF
+#line 6415 "configure"
 #include "confdefs.h"
-#include <stdio.h>
+
+#include <libutf8.h>
 int
-main ()
+main (void)
 {
-printf("Hello")
+putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6912: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:6428: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6915: \$? = $ac_status" >&5
+  echo "$as_me:6431: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6918: \"$ac_try\"") >&5
+  { (eval echo "$as_me:6434: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6921: \$? = $ac_status" >&5
+  echo "$as_me:6437: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+
+                               test -n "$verbose" && echo "    ... found utf8 headers in $cf_cv_header_path_utf8" 1>&6
+
+echo "${as_me:-configure}:6442: testing ... found utf8 headers in $cf_cv_header_path_utf8 ..." 1>&5
+
+                               cf_cv_find_linkage_utf8=maybe
+                               cf_test_CPPFLAGS="$CPPFLAGS"
+                               break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_have_incdir=yes
+
+                               CPPFLAGS="$cf_save_CPPFLAGS"
+
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-                         CPPFLAGS=$cf_save_CPPFLAGS
-                       fi
-                 fi
                fi
+       done
 
-               if test "$cf_have_incdir" = no ; then
-                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
+       if test "$cf_cv_find_linkage_utf8" = maybe ; then
 
-echo "${as_me:-configure}:6938: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:6460: testing Searching for utf8 library in FIND_LINKAGE(utf8,) ..." 1>&5
 
-                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+               cf_save_LIBS="$LIBS"
+               cf_save_LDFLAGS="$LDFLAGS"
 
-                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
-                 test "$cf_top_incdir" = "$cf_add_incdir" && break
-                 cf_add_incdir="$cf_top_incdir"
-               else
-                 break
-               fi
-         else
-               break
-         fi
+               if test "$cf_cv_find_linkage_utf8" != yes ; then
+
+cf_search=
+cf_library_path_list=""
+if test -n "${LDFLAGS}${LIBS}" ; then
+       for cf_library_path in $LDFLAGS $LIBS
+       do
+               case $cf_library_path in
+               (-L*)
+                       cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
+
+test "x$cf_library_path" != "xNONE" && \
+test -d "$cf_library_path" && \
+ {
+       test -n "$verbose" && echo "    ... testing for lib-directories under $cf_library_path"
+       test -d $cf_library_path/lib &&          cf_search="$cf_search $cf_library_path/lib"
+       test -d $cf_library_path/lib/utf8 &&       cf_search="$cf_search $cf_library_path/lib/utf8"
+       test -d $cf_library_path/lib/utf8/lib &&    cf_search="$cf_search $cf_library_path/lib/utf8/lib"
+       test -d $cf_library_path/utf8/lib &&       cf_search="$cf_search $cf_library_path/utf8/lib"
+       test -d $cf_library_path/utf8/lib/utf8 &&    cf_search="$cf_search $cf_library_path/utf8/lib/utf8"
+}
+
+                       cf_library_path_list="$cf_library_path_list $cf_search"
+                       ;;
+               esac
        done
-  done
 fi
 
-               for cf_header in \
-                       ncurses.h \
-                       curses.h
-               do
+cf_search=
 
-       cat >conftest.$ac_ext <<_ACEOF
-#line 6961 "configure"
-#include "confdefs.h"
+test "x$prefix" != "xNONE" && \
+test -d "$prefix" && \
+ {
+       test -n "$verbose" && echo "    ... testing for lib-directories under $prefix"
+       test -d $prefix/lib &&          cf_search="$cf_search $prefix/lib"
+       test -d $prefix/lib/utf8 &&       cf_search="$cf_search $prefix/lib/utf8"
+       test -d $prefix/lib/utf8/lib &&    cf_search="$cf_search $prefix/lib/utf8/lib"
+       test -d $prefix/utf8/lib &&       cf_search="$cf_search $prefix/utf8/lib"
+       test -d $prefix/utf8/lib/utf8 &&    cf_search="$cf_search $prefix/utf8/lib/utf8"
+}
 
-#include <$cf_header>
-int
-main ()
-{
+for cf_subdir_prefix in \
+       /usr \
+       /usr/local \
+       /usr/pkg \
+       /opt \
+       /opt/local \
+       $HOME
+do
 
-#ifdef NCURSES_VERSION
+test "x$cf_subdir_prefix" != "x$prefix" && \
+test -d "$cf_subdir_prefix" && \
+(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+       test -n "$verbose" && echo "    ... testing for lib-directories under $cf_subdir_prefix"
+       test -d $cf_subdir_prefix/lib &&          cf_search="$cf_search $cf_subdir_prefix/lib"
+       test -d $cf_subdir_prefix/lib/utf8 &&       cf_search="$cf_search $cf_subdir_prefix/lib/utf8"
+       test -d $cf_subdir_prefix/lib/utf8/lib &&    cf_search="$cf_search $cf_subdir_prefix/lib/utf8/lib"
+       test -d $cf_subdir_prefix/utf8/lib &&       cf_search="$cf_search $cf_subdir_prefix/utf8/lib"
+       test -d $cf_subdir_prefix/utf8/lib/utf8 &&    cf_search="$cf_search $cf_subdir_prefix/utf8/lib/utf8"
+}
 
-printf("%s\n", NCURSES_VERSION);
-#else
-#ifdef __NCURSES_H
-printf("old\n");
-#else
-       make an error
-#endif
-#endif
+done
+
+cf_search="$cf_library_path_list $cf_search"
 
+                       for cf_cv_library_path_utf8 in $cf_search
+                       do
+                               if test -d $cf_cv_library_path_utf8 ; then
+                                       test -n "$verbose" && echo "    ... testing $cf_cv_library_path_utf8" 1>&6
+
+echo "${as_me:-configure}:6535: testing ... testing $cf_cv_library_path_utf8 ..." 1>&5
+
+                                       CPPFLAGS="$cf_test_CPPFLAGS"
+                                       LIBS="-lutf8  $cf_save_LIBS"
+                                       LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_utf8"
+                                       cat >conftest.$ac_ext <<_ACEOF
+#line 6541 "configure"
+#include "confdefs.h"
+
+#include <libutf8.h>
+int
+main (void)
+{
+putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6985: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6554: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6988: \$? = $ac_status" >&5
+  echo "$as_me:6557: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6991: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6560: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6994: \$? = $ac_status" >&5
+  echo "$as_me:6563: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_ncurses_h2=$cf_header
 
+                                       test -n "$verbose" && echo "    ... found utf8 library in $cf_cv_library_path_utf8" 1>&6
+
+echo "${as_me:-configure}:6568: testing ... found utf8 library in $cf_cv_library_path_utf8 ..." 1>&5
+
+                                       cf_cv_find_linkage_utf8=yes
+                                       cf_cv_library_file_utf8="-lutf8"
+                                       break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_ncurses_h2=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
 
-                       if test "$cf_cv_ncurses_h2" != no ; then
-                               cf_cv_ncurses_h2=$cf_incdir/$cf_header
-                               test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&6
-                               break
-                       fi
-                       test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&6
-               done
-               CPPFLAGS="$cf_save2_CPPFLAGS"
-               test "$cf_cv_ncurses_h2" != no && break
-       done
-       test "$cf_cv_ncurses_h2" = no && { { echo "$as_me:7015: error: not found" >&5
-echo "$as_me: error: not found" >&2;}
-   { (exit 1); exit 1; }; }
+                                       CPPFLAGS="$cf_save_CPPFLAGS"
+                                       LIBS="$cf_save_LIBS"
+                                       LDFLAGS="$cf_save_LDFLAGS"
 
 fi
-echo "$as_me:7020: result: $cf_cv_ncurses_h2" >&5
-echo "${ECHO_T}$cf_cv_ncurses_h2" >&6
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+                               fi
+                       done
+                       CPPFLAGS="$cf_save_CPPFLAGS"
+                       LDFLAGS="$cf_save_LDFLAGS"
+               fi
 
-       cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'`
-       cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
-       if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
-               cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
+       else
+               cf_cv_find_linkage_utf8=no
        fi
 
-if test -n "$cf_1st_incdir" ; then
-  for cf_add_incdir in $cf_1st_incdir
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+LIBS="$cf_save_LIBS"
+
+if test "$cf_cv_find_linkage_utf8" = yes ; then
+cf_cv_utf8_lib=add-on
+else
+cf_cv_utf8_lib=no
+fi
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:6610: result: $cf_cv_utf8_lib" >&5
+echo "${ECHO_T}$cf_cv_utf8_lib" >&6
+
+# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
+# ncurses/ncursesw:
+if test "$cf_cv_utf8_lib" = "add-on" ; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_LIBUTF8_H 1
+EOF
+
+if test -n "$cf_cv_header_path_utf8" ; then
+  for cf_add_incdir in $cf_cv_header_path_utf8
   do
        while test $cf_add_incdir != /usr/include
        do
@@ -7050,11 +6642,11 @@ if test -n "$cf_1st_incdir" ; then
                          cf_save_CPPFLAGS=$CPPFLAGS
                          CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
                          cat >conftest.$ac_ext <<_ACEOF
-#line 7053 "configure"
+#line 6645 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
@@ -7062,16 +6654,16 @@ printf("Hello")
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7065: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:6657: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7068: \$? = $ac_status" >&5
+  echo "$as_me:6660: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7071: \"$ac_try\"") >&5
+  { (eval echo "$as_me:6663: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7074: \$? = $ac_status" >&5
+  echo "$as_me:6666: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -7088,7 +6680,7 @@ rm -f conftest.$ac_objext conftest.$ac_ext
                if test "$cf_have_incdir" = no ; then
                  test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:7091: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:6683: testing adding $cf_add_incdir to include-path ..." 1>&5
 
                  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
@@ -7105,38 +6697,164 @@ echo "${as_me:-configure}:7091: testing adding $cf_add_incdir to include-path ..
   done
 fi
 
-fi
-
-# Set definitions to allow ifdef'ing for ncurses.h
-
-case $cf_cv_ncurses_header in
-(*ncurses.h)
+if test -n "$cf_cv_library_path_utf8" ; then
+       for cf_add_libdir in $cf_cv_library_path_utf8
+       do
+               if test $cf_add_libdir = /usr/lib ; then
+                       :
+               elif test -d $cf_add_libdir
+               then
+                       cf_have_libdir=no
+                       if test -n "$LDFLAGS$LIBS" ; then
+                               # a loop is needed to ensure we can add subdirs of existing dirs
+                               for cf_test_libdir in $LDFLAGS $LIBS ; do
+                                       if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
+                                               cf_have_libdir=yes; break
+                                       fi
+                               done
+                       fi
+                       if test "$cf_have_libdir" = no ; then
+                               test -n "$verbose" && echo "    adding $cf_add_libdir to library-path" 1>&6
 
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSES_H 1
-EOF
+echo "${as_me:-configure}:6719: testing adding $cf_add_libdir to library-path ..." 1>&5
 
-       ;;
-esac
+                               LDFLAGS="-L$cf_add_libdir $LDFLAGS"
+                       fi
+               fi
+       done
+fi
 
-case $cf_cv_ncurses_header in
-(ncurses/curses.h|ncurses/ncurses.h)
+cf_add_libs="$cf_cv_library_file_utf8"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSES_NCURSES_H 1
-EOF
+fi
 
-       ;;
-(ncursesw/curses.h|ncursesw/ncurses.h)
+cf_ncuconfig_root=$cf_cv_screen
+cf_have_ncuconfig=no
+
+if test "x${PKG_CONFIG:=none}" != xnone; then
+       echo "$as_me:6749: checking pkg-config for $cf_ncuconfig_root" >&5
+echo $ECHO_N "checking pkg-config for $cf_ncuconfig_root... $ECHO_C" >&6
+       if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
+               echo "$as_me:6752: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+               echo "$as_me:6755: checking if the $cf_ncuconfig_root package files work" >&5
+echo $ECHO_N "checking if the $cf_ncuconfig_root package files work... $ECHO_C" >&6
+               cf_have_ncuconfig=unknown
+
+               cf_save_CPPFLAGS="$CPPFLAGS"
+               cf_save_LIBS="$LIBS"
+
+               CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
+
+cf_add_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
+
+               cat >conftest.$ac_ext <<_ACEOF
+#line 6781 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6793: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6796: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6799: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6802: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  if test "$cross_compiling" = yes; then
+  cf_have_ncuconfig=maybe
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6808 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+                               int main(void)
+                               { char *xx = curses_version(); return (xx == 0); }
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:6815: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6818: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:6820: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6823: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_have_ncuconfig=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_have_ncuconfig=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_have_ncuconfig=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+               echo "$as_me:6840: result: $cf_have_ncuconfig" >&5
+echo "${ECHO_T}$cf_have_ncuconfig" >&6
+               test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
+               if test "$cf_have_ncuconfig" != "yes"
+               then
+                       CPPFLAGS="$cf_save_CPPFLAGS"
+                       LIBS="$cf_save_LIBS"
+                       NCURSES_CONFIG_PKG=none
+               else
 
 cat >>confdefs.h <<\EOF
-#define HAVE_NCURSESW_NCURSES_H 1
+#define NCURSES 1
 EOF
 
-       ;;
-esac
+                       NCURSES_CONFIG_PKG=$cf_ncuconfig_root
+               fi
 
-echo "$as_me:7139: checking for terminfo header" >&5
+echo "$as_me:6857: checking for terminfo header" >&5
 echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
 if test "${cf_cv_term_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7154,14 +6872,14 @@ esac
 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
 do
 cat >conftest.$ac_ext <<_ACEOF
-#line 7157 "configure"
+#line 6875 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <$cf_test>
 
 int
-main ()
+main (void)
 {
 int x = auto_left_margin
   ;
@@ -7169,16 +6887,16 @@ int x = auto_left_margin
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7172: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:6890: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7175: \$? = $ac_status" >&5
+  echo "$as_me:6893: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7178: \"$ac_try\"") >&5
+  { (eval echo "$as_me:6896: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7181: \$? = $ac_status" >&5
+  echo "$as_me:6899: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
        cf_cv_term_header="$cf_test"
@@ -7194,7 +6912,7 @@ rm -f conftest.$ac_objext conftest.$ac_ext
 done
 
 fi
-echo "$as_me:7197: result: $cf_cv_term_header" >&5
+echo "$as_me:6915: result: $cf_cv_term_header" >&5
 echo "${ECHO_T}$cf_cv_term_header" >&6
 
 # Set definitions to allow ifdef'ing to accommodate subdirectories
@@ -7226,300 +6944,104 @@ EOF
        ;;
 esac
 
-# some applications need this, but should check for NCURSES_VERSION
+       else
+               echo "$as_me:6948: result: no" >&5
+echo "${ECHO_T}no" >&6
+               NCURSES_CONFIG_PKG=none
+       fi
+else
+       NCURSES_CONFIG_PKG=none
+fi
 
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
+if test "x$cf_have_ncuconfig" = "xno"; then
+       echo "Looking for ${cf_ncuconfig_root}-config"
 
-echo "$as_me:7235: checking for ncurses version" >&5
-echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
-if test "${cf_cv_ncurses_version+set}" = set; then
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:6964: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_NCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
-       cf_cv_ncurses_version=no
-       cf_tempfile=out$$
-       rm -f $cf_tempfile
-       if test "$cross_compiling" = yes; then
-
-       # This will not work if the preprocessor splits the line after the
-       # Autoconf token.  The 'unproto' program does that.
-       cat > conftest.$ac_ext <<EOF
-#include <${cf_cv_ncurses_header:-curses.h}>
-#undef Autoconf
-#ifdef NCURSES_VERSION
-Autoconf NCURSES_VERSION
-#else
-#ifdef __NCURSES_H
-Autoconf "old"
-#endif
-;
-#endif
-EOF
-       cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-       { (eval echo "$as_me:7261: \"$cf_try\"") >&5
-  (eval $cf_try) 2>&5
-  ac_status=$?
-  echo "$as_me:7264: \$? = $ac_status" >&5
-  (exit $ac_status); }
-       if test -f conftest.out ; then
-               cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
-               test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
-               rm -f conftest.out
-       fi
-
+  if test -n "$NCURSES_CONFIG"; then
+  ac_cv_prog_NCURSES_CONFIG="$NCURSES_CONFIG" # Let the user override the test.
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 7274 "configure"
-#include "confdefs.h"
-
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <stdio.h>
-int main()
-{
-       FILE *fp = fopen("$cf_tempfile", "w");
-#ifdef NCURSES_VERSION
-# ifdef NCURSES_VERSION_PATCH
-       fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
-# else
-       fprintf(fp, "%s\n", NCURSES_VERSION);
-# endif
-#else
-# ifdef __NCURSES_H
-       fprintf(fp, "old\n");
-# else
-       make an error
-# endif
-#endif
-       ${cf_cv_main_return:-return}(0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7299: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:7302: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7304: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:7307: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_NCURSES_CONFIG="$ac_tool_prefix$ac_prog"
+echo "$as_me:6979: found $ac_dir/$ac_word" >&5
+break
+done
 
-       cf_cv_ncurses_version=`cat $cf_tempfile`
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-       rm -f $cf_tempfile
+NCURSES_CONFIG=$ac_cv_prog_NCURSES_CONFIG
+if test -n "$NCURSES_CONFIG"; then
+  echo "$as_me:6987: result: $NCURSES_CONFIG" >&5
+echo "${ECHO_T}$NCURSES_CONFIG" >&6
+else
+  echo "$as_me:6990: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
 
+    test -n "$NCURSES_CONFIG" && break
+  done
 fi
-echo "$as_me:7321: result: $cf_cv_ncurses_version" >&5
-echo "${ECHO_T}$cf_cv_ncurses_version" >&6
-test "$cf_cv_ncurses_version" = no ||
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
-
-cf_nculib_root=$cf_cv_screen
-       # This works, except for the special case where we find gpm, but
-       # ncurses is in a nonstandard location via $LIBS, and we really want
-       # to link gpm.
-cf_ncurses_LIBS=""
-cf_ncurses_SAVE="$LIBS"
-echo "$as_me:7334: checking for Gpm_Open in -lgpm" >&5
-echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
-if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
+if test -z "$NCURSES_CONFIG"; then
+  ac_ct_NCURSES_CONFIG=$NCURSES_CONFIG
+  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:7003: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_NCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgpm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 7342 "configure"
-#include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char Gpm_Open ();
-int
-main ()
-{
-Gpm_Open ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7361: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:7364: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7367: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:7370: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_gpm_Gpm_Open=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_gpm_Gpm_Open=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:7381: result: $ac_cv_lib_gpm_Gpm_Open" >&5
-echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
-if test $ac_cv_lib_gpm_Gpm_Open = yes; then
-  echo "$as_me:7384: checking for initscr in -lgpm" >&5
-echo $ECHO_N "checking for initscr in -lgpm... $ECHO_C" >&6
-if test "${ac_cv_lib_gpm_initscr+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  if test -n "$ac_ct_NCURSES_CONFIG"; then
+  ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_ct_NCURSES_CONFIG" # Let the user override the test.
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgpm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 7392 "configure"
-#include "confdefs.h"
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_prog"
+echo "$as_me:7018: found $ac_dir/$ac_word" >&5
+break
+done
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char initscr ();
-int
-main ()
-{
-initscr ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7411: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:7414: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7417: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:7420: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_gpm_initscr=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_gpm_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7431: result: $ac_cv_lib_gpm_initscr" >&5
-echo "${ECHO_T}$ac_cv_lib_gpm_initscr" >&6
-if test $ac_cv_lib_gpm_initscr = yes; then
-  LIBS="$cf_ncurses_SAVE"
+ac_ct_NCURSES_CONFIG=$ac_cv_prog_ac_ct_NCURSES_CONFIG
+if test -n "$ac_ct_NCURSES_CONFIG"; then
+  echo "$as_me:7026: result: $ac_ct_NCURSES_CONFIG" >&5
+echo "${ECHO_T}$ac_ct_NCURSES_CONFIG" >&6
 else
-  cf_ncurses_LIBS="-lgpm"
-fi
-
+  echo "$as_me:7029: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-case $host_os in
-(freebsd*)
-       # This is only necessary if you are linking against an obsolete
-       # version of ncurses (but it should do no harm, since it's static).
-       if test "$cf_nculib_root" = ncurses ; then
-               echo "$as_me:7446: checking for tgoto in -lmytinfo" >&5
-echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
-if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmytinfo  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 7454 "configure"
-#include "confdefs.h"
+  test -n "$ac_ct_NCURSES_CONFIG" && break
+done
+test -n "$ac_ct_NCURSES_CONFIG" || ac_ct_NCURSES_CONFIG="none"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char tgoto ();
-int
-main ()
-{
-tgoto ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7473: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:7476: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7479: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:7482: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_mytinfo_tgoto=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_mytinfo_tgoto=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:7493: result: $ac_cv_lib_mytinfo_tgoto" >&5
-echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
-if test $ac_cv_lib_mytinfo_tgoto = yes; then
-  cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"
+  NCURSES_CONFIG=$ac_ct_NCURSES_CONFIG
 fi
 
-       fi
-       ;;
-esac
-
-cf_add_libs="$cf_ncurses_LIBS"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
+       if test "$NCURSES_CONFIG" != none ; then
 
-if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
-then
+               CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
 
-cf_add_libs="-l$cf_nculib_root"
+cf_add_libs="`$NCURSES_CONFIG --libs`"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-else
+               # even with config script, some packages use no-override for curses.h
 
-       eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
-       cf_libdir=""
-       echo "$as_me:7542: checking for initscr" >&5
-echo $ECHO_N "checking for initscr... $ECHO_C" >&6
-if test "${ac_cv_func_initscr+set}" = set; then
+echo "$as_me:7062: checking if we have identified curses headers" >&5
+echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
+if test "${cf_cv_ncurses_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 7548 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char initscr (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char initscr ();
-char (*f) ();
 
+cf_cv_ncurses_header=none
+for cf_header in \
+       ncurses.h $cf_cv_screen/ncurses.h \
+       curses.h $cf_cv_screen/curses.h
+do
+cat >conftest.$ac_ext <<_ACEOF
+#line 7074 "configure"
+#include "confdefs.h"
+#include <${cf_header}>
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_initscr) || defined (__stub___initscr)
-choke me
-#else
-f = initscr; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
-
+initscr(); tgoto("?", 0,0)
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7579: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7086: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7582: \$? = $ac_status" >&5
+  echo "$as_me:7089: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7585: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7092: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7588: \$? = $ac_status" >&5
+  echo "$as_me:7095: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_func_initscr=yes
+  cf_cv_ncurses_header=$cf_header; break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_func_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+
 fi
-echo "$as_me:7598: result: $ac_cv_func_initscr" >&5
-echo "${ECHO_T}$ac_cv_func_initscr" >&6
-if test $ac_cv_func_initscr = yes; then
-  eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
-else
+echo "$as_me:7106: result: $cf_cv_ncurses_header" >&5
+echo "${ECHO_T}$cf_cv_ncurses_header" >&6
 
-               cf_save_LIBS="$LIBS"
-               echo "$as_me:7605: checking for initscr in -l$cf_nculib_root" >&5
-echo $ECHO_N "checking for initscr in -l$cf_nculib_root... $ECHO_C" >&6
-               LIBS="-l$cf_nculib_root $LIBS"
-               cat >conftest.$ac_ext <<_ACEOF
-#line 7609 "configure"
-#include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
-int
-main ()
-{
-initscr()
-  ;
-  return 0;
-}
+if test "$cf_cv_ncurses_header" = none ; then
+       { { echo "$as_me:7110: error: No curses header-files found" >&5
+echo "$as_me: error: No curses header-files found" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
+
+for ac_header in $cf_cv_ncurses_header
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:7120: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7126 "configure"
+#include "confdefs.h"
+#include <$ac_header>
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7621: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:7624: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7627: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+if { (eval echo "$as_me:7130: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
-  echo "$as_me:7630: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:7632: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-                        eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
-
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:7136: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:7639: result: no" >&5
-echo "${ECHO_T}no" >&6
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:7155: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
 
-cf_search=
-cf_library_path_list=""
-if test -n "${LDFLAGS}${LIBS}" ; then
-       for cf_library_path in $LDFLAGS $LIBS
-       do
-               case $cf_library_path in
-               (-L*)
-                       cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
+fi
+done
 
-test "x$cf_library_path" != "xNONE" && \
-test -d "$cf_library_path" && \
- {
-       test -n "$verbose" && echo "    ... testing for lib-directories under $cf_library_path"
-       test -d $cf_library_path/lib &&          cf_search="$cf_search $cf_library_path/lib"
-       test -d $cf_library_path/lib/$cf_nculib_root &&       cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root"
-       test -d $cf_library_path/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root/lib"
-       test -d $cf_library_path/$cf_nculib_root/lib &&       cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib"
-       test -d $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root"
-}
+cat >>confdefs.h <<\EOF
+#define NCURSES 1
+EOF
 
-                       cf_library_path_list="$cf_library_path_list $cf_search"
-                       ;;
-               esac
-       done
-fi
+cf_nculib_ROOT=`echo "HAVE_LIB$cf_ncuconfig_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-cf_search=
+               cat >>confdefs.h <<EOF
+#define $cf_nculib_ROOT 1
+EOF
 
-test "x$prefix" != "xNONE" && \
-test -d "$prefix" && \
- {
-       test -n "$verbose" && echo "    ... testing for lib-directories under $prefix"
-       test -d $prefix/lib &&          cf_search="$cf_search $prefix/lib"
-       test -d $prefix/lib/$cf_nculib_root &&       cf_search="$cf_search $prefix/lib/$cf_nculib_root"
-       test -d $prefix/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib"
-       test -d $prefix/$cf_nculib_root/lib &&       cf_search="$cf_search $prefix/$cf_nculib_root/lib"
-       test -d $prefix/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root"
-}
+                               cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
 
-for cf_subdir_prefix in \
-       /usr \
-       /usr/local \
-       /usr/pkg \
-       /opt \
-       /opt/local \
-       $HOME
-do
+       else
 
-test "x$cf_subdir_prefix" != "x$prefix" && \
-test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
-       test -n "$verbose" && echo "    ... testing for lib-directories under $cf_subdir_prefix"
-       test -d $cf_subdir_prefix/lib &&          cf_search="$cf_search $cf_subdir_prefix/lib"
-       test -d $cf_subdir_prefix/lib/$cf_nculib_root &&       cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root"
-       test -d $cf_subdir_prefix/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root/lib"
-       test -d $cf_subdir_prefix/$cf_nculib_root/lib &&       cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib"
-       test -d $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root"
-}
+cf_ncuhdr_root=$cf_cv_screen
 
-done
+test -n "$cf_cv_curses_dir" && \
+test "$cf_cv_curses_dir" != "no" && { \
 
-cf_search="$cf_library_path_list $cf_search"
+if test -n "$cf_cv_curses_dir/include/$cf_ncuhdr_root" ; then
+  for cf_add_incdir in $cf_cv_curses_dir/include/$cf_ncuhdr_root
+  do
+       while test $cf_add_incdir != /usr/include
+       do
+         if test -d $cf_add_incdir
+         then
+               cf_have_incdir=no
+               if test -n "$CFLAGS$CPPFLAGS" ; then
+                 # a loop is needed to ensure we can add subdirs of existing dirs
+                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
+                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
+                         cf_have_incdir=yes; break
+                       fi
+                 done
+               fi
 
-                       for cf_libdir in $cf_search
-                       do
-                               echo "$as_me:7707: checking for -l$cf_nculib_root in $cf_libdir" >&5
-echo $ECHO_N "checking for -l$cf_nculib_root in $cf_libdir... $ECHO_C" >&6
-                               LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
-                               cat >conftest.$ac_ext <<_ACEOF
-#line 7711 "configure"
+               if test "$cf_have_incdir" = no ; then
+                 if test "$cf_add_incdir" = /usr/local/include ; then
+                       if test "$GCC" = yes
+                       then
+                         cf_save_CPPFLAGS=$CPPFLAGS
+                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+                         cat >conftest.$ac_ext <<_ACEOF
+#line 7208 "configure"
 #include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
+#include <stdio.h>
 int
-main ()
+main (void)
 {
-initscr()
+printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7723: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7220: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7726: \$? = $ac_status" >&5
+  echo "$as_me:7223: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7729: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7226: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7732: \$? = $ac_status" >&5
+  echo "$as_me:7229: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  echo "$as_me:7734: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-                                        eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
-                                        break
+  :
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-echo "$as_me:7741: result: no" >&5
-echo "${ECHO_T}no" >&6
-                                        LIBS="$cf_save_LIBS"
+cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-                       done
+rm -f conftest.$ac_objext conftest.$ac_ext
+                         CPPFLAGS=$cf_save_CPPFLAGS
+                       fi
+                 fi
+               fi
 
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+               if test "$cf_have_incdir" = no ; then
+                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
 
-fi
+echo "${as_me:-configure}:7246: testing adding $cf_add_incdir to include-path ..." 1>&5
 
-eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root
+                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-if test $cf_found_library = no ; then
-       { { echo "$as_me:7756: error: Cannot link $cf_nculib_root library" >&5
-echo "$as_me: error: Cannot link $cf_nculib_root library" >&2;}
-   { (exit 1); exit 1; }; }
+                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+                 test "$cf_top_incdir" = "$cf_add_incdir" && break
+                 cf_add_incdir="$cf_top_incdir"
+               else
+                 break
+               fi
+         else
+               break
+         fi
+       done
+  done
 fi
 
-fi
+}
+
+echo "$as_me:7265: checking for $cf_ncuhdr_root header in include-path" >&5
+echo $ECHO_N "checking for $cf_ncuhdr_root header in include-path... $ECHO_C" >&6
+if test "${cf_cv_ncurses_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
+       ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
+       for cf_header in $cf_header_list
+       do
 
-if test -n "$cf_ncurses_LIBS" ; then
-       echo "$as_me:7764: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
-echo $ECHO_N "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS... $ECHO_C" >&6
-       cf_ncurses_SAVE="$LIBS"
-       for p in $cf_ncurses_LIBS ; do
-               q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
-               if test "$q" != "$LIBS" ; then
-                       LIBS="$q"
-               fi
-       done
        cat >conftest.$ac_ext <<_ACEOF
-#line 7774 "configure"
+#line 7277 "configure"
 #include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
+
+#include <$cf_header>
 int
-main ()
+main (void)
 {
-initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+
+#ifdef NCURSES_VERSION
+
+printf("%s\n", NCURSES_VERSION);
+#else
+#ifdef __NCURSES_H
+printf("old\n");
+#else
+       make an error
+#endif
+#endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7786: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7301: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7789: \$? = $ac_status" >&5
+  echo "$as_me:7304: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7792: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7307: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7795: \$? = $ac_status" >&5
+  echo "$as_me:7310: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  echo "$as_me:7797: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  cf_cv_ncurses_h=$cf_header
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-echo "$as_me:7802: result: no" >&5
-echo "${ECHO_T}no" >&6
-                LIBS="$cf_ncurses_SAVE"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+cf_cv_ncurses_h=no
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-cf_nculib_ROOT=`echo "HAVE_LIB$cf_nculib_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+               test "$cf_cv_ncurses_h" != no && break
+       done
 
-cat >>confdefs.h <<EOF
-#define $cf_nculib_ROOT 1
-EOF
+fi
+echo "$as_me:7325: result: $cf_cv_ncurses_h" >&5
+echo "${ECHO_T}$cf_cv_ncurses_h" >&6
 
-       fi
+if test "$cf_cv_ncurses_h" != no ; then
+       cf_cv_ncurses_header=$cf_cv_ncurses_h
 else
-       NCURSES_CONFIG=none
-fi
 
-       ;;
-(ncurses*)
+echo "$as_me:7332: checking for $cf_ncuhdr_root include-path" >&5
+echo $ECHO_N "checking for $cf_ncuhdr_root include-path... $ECHO_C" >&6
+if test "${cf_cv_ncurses_h2+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-cf_ncuconfig_root=$cf_cv_screen
-cf_have_ncuconfig=no
+       test -n "$verbose" && echo
 
-if test "x${PKG_CONFIG:=none}" != xnone; then
-       echo "$as_me:7827: checking pkg-config for $cf_ncuconfig_root" >&5
-echo $ECHO_N "checking pkg-config for $cf_ncuconfig_root... $ECHO_C" >&6
-       if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
-               echo "$as_me:7830: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+cf_search=
 
-               echo "$as_me:7833: checking if the $cf_ncuconfig_root package files work" >&5
-echo $ECHO_N "checking if the $cf_ncuconfig_root package files work... $ECHO_C" >&6
-               cf_have_ncuconfig=unknown
+# collect the current set of include-directories from compiler flags
+cf_header_path_list=""
+if test -n "${CFLAGS}${CPPFLAGS}" ; then
+       for cf_header_path in $CPPFLAGS $CFLAGS
+       do
+               case $cf_header_path in
+               (-I*)
+                       cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
 
-               cf_save_CPPFLAGS="$CPPFLAGS"
-               cf_save_LIBS="$LIBS"
+test "x$cf_header_path" != "xNONE" && \
+test -d "$cf_header_path" && \
+ {
+       test -n "$verbose" && echo "    ... testing for include-directories under $cf_header_path"
+       test -d $cf_header_path/include &&          cf_search="$cf_search $cf_header_path/include"
+       test -d $cf_header_path/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root"
+       test -d $cf_header_path/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root/include"
+       test -d $cf_header_path/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include"
+       test -d $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+}
 
-               CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
+                       cf_header_path_list="$cf_header_path_list $cf_search"
+                       ;;
+               esac
+       done
+fi
 
-cf_add_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+# add the variations for the package we are looking for
+
+cf_search=
+
+test "x$prefix" != "xNONE" && \
+test -d "$prefix" && \
+ {
+       test -n "$verbose" && echo "    ... testing for include-directories under $prefix"
+       test -d $prefix/include &&          cf_search="$cf_search $prefix/include"
+       test -d $prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
+       test -d $prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
+       test -d $prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
+       test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+}
+
+for cf_subdir_prefix in \
+       /usr \
+       /usr/local \
+       /usr/pkg \
+       /opt \
+       /opt/local \
+       $HOME
 do
-       for cf_add_2lib in $cf_add_libs
+
+test "x$cf_subdir_prefix" != "x$prefix" && \
+test -d "$cf_subdir_prefix" && \
+(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+       test -n "$verbose" && echo "    ... testing for include-directories under $cf_subdir_prefix"
+       test -d $cf_subdir_prefix/include &&          cf_search="$cf_search $cf_subdir_prefix/include"
+       test -d $cf_subdir_prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root"
+       test -d $cf_subdir_prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root/include"
+       test -d $cf_subdir_prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include"
+       test -d $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+}
+
+done
+
+test "$includedir" != NONE && \
+test "$includedir" != "/usr/include" && \
+test -d "$includedir" && {
+       test -d $includedir &&    cf_search="$cf_search $includedir"
+       test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
+}
+
+test "$oldincludedir" != NONE && \
+test "$oldincludedir" != "/usr/include" && \
+test -d "$oldincludedir" && {
+       test -d $oldincludedir    && cf_search="$cf_search $oldincludedir"
+       test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
+}
+
+cf_search="$cf_search $cf_header_path_list"
+
+       test -n "$verbose" && echo search path $cf_search
+       cf_save2_CPPFLAGS="$CPPFLAGS"
+       for cf_incdir in $cf_search
        do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
+
+if test -n "$cf_incdir" ; then
+  for cf_add_incdir in $cf_incdir
+  do
+       while test $cf_add_incdir != /usr/include
+       do
+         if test -d $cf_add_incdir
+         then
+               cf_have_incdir=no
+               if test -n "$CFLAGS$CPPFLAGS" ; then
+                 # a loop is needed to ensure we can add subdirs of existing dirs
+                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
+                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
+                         cf_have_incdir=yes; break
+                       fi
+                 done
                fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
 
-               cat >conftest.$ac_ext <<_ACEOF
-#line 7859 "configure"
+               if test "$cf_have_incdir" = no ; then
+                 if test "$cf_add_incdir" = /usr/local/include ; then
+                       if test "$GCC" = yes
+                       then
+                         cf_save_CPPFLAGS=$CPPFLAGS
+                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+                         cat >conftest.$ac_ext <<_ACEOF
+#line 7450 "configure"
 #include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
+#include <stdio.h>
 int
-main ()
+main (void)
 {
-initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7871: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7462: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7874: \$? = $ac_status" >&5
+  echo "$as_me:7465: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7877: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7468: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7880: \$? = $ac_status" >&5
+  echo "$as_me:7471: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  if test "$cross_compiling" = yes; then
-  cf_have_ncuconfig=maybe
+  :
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 7886 "configure"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_have_incdir=yes
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+                         CPPFLAGS=$cf_save_CPPFLAGS
+                       fi
+                 fi
+               fi
+
+               if test "$cf_have_incdir" = no ; then
+                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
+
+echo "${as_me:-configure}:7488: testing adding $cf_add_incdir to include-path ..." 1>&5
+
+                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+
+                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+                 test "$cf_top_incdir" = "$cf_add_incdir" && break
+                 cf_add_incdir="$cf_top_incdir"
+               else
+                 break
+               fi
+         else
+               break
+         fi
+       done
+  done
+fi
+
+               for cf_header in \
+                       ncurses.h \
+                       curses.h
+               do
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 7511 "configure"
 #include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
-                               int main(void)
-                               { char *xx = curses_version(); return (xx == 0); }
+
+#include <$cf_header>
+int
+main (void)
+{
+
+#ifdef NCURSES_VERSION
+
+printf("%s\n", NCURSES_VERSION);
+#else
+#ifdef __NCURSES_H
+printf("old\n");
+#else
+       make an error
+#endif
+#endif
+
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7893: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7535: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7896: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7898: \"$ac_try\"") >&5
+  echo "$as_me:7538: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7541: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7901: \$? = $ac_status" >&5
+  echo "$as_me:7544: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_have_ncuconfig=yes
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_have_ncuconfig=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
+  cf_cv_ncurses_h2=$cf_header
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_have_ncuconfig=no
+cf_cv_ncurses_h2=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-               echo "$as_me:7918: result: $cf_have_ncuconfig" >&5
-echo "${ECHO_T}$cf_have_ncuconfig" >&6
-               test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
-               if test "$cf_have_ncuconfig" != "yes"
-               then
-                       CPPFLAGS="$cf_save_CPPFLAGS"
-                       LIBS="$cf_save_LIBS"
-                       NCURSES_CONFIG_PKG=none
-               else
-
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
-
-                       NCURSES_CONFIG_PKG=$cf_ncuconfig_root
-               fi
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-       else
-               echo "$as_me:7936: result: no" >&5
-echo "${ECHO_T}no" >&6
-               NCURSES_CONFIG_PKG=none
-       fi
-else
-       NCURSES_CONFIG_PKG=none
-fi
-
-if test "x$cf_have_ncuconfig" = "xno"; then
-       echo "Looking for ${cf_ncuconfig_root}-config"
-
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:7952: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_NCURSES_CONFIG+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$NCURSES_CONFIG"; then
-  ac_cv_prog_NCURSES_CONFIG="$NCURSES_CONFIG" # Let the user override the test.
-else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_NCURSES_CONFIG="$ac_tool_prefix$ac_prog"
-echo "$as_me:7967: found $ac_dir/$ac_word" >&5
-break
-done
-
-fi
-fi
-NCURSES_CONFIG=$ac_cv_prog_NCURSES_CONFIG
-if test -n "$NCURSES_CONFIG"; then
-  echo "$as_me:7975: result: $NCURSES_CONFIG" >&5
-echo "${ECHO_T}$NCURSES_CONFIG" >&6
-else
-  echo "$as_me:7978: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-    test -n "$NCURSES_CONFIG" && break
-  done
-fi
-if test -z "$NCURSES_CONFIG"; then
-  ac_ct_NCURSES_CONFIG=$NCURSES_CONFIG
-  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:7991: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_NCURSES_CONFIG+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_NCURSES_CONFIG"; then
-  ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_ct_NCURSES_CONFIG" # Let the user override the test.
-else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_prog"
-echo "$as_me:8006: found $ac_dir/$ac_word" >&5
-break
-done
-
-fi
-fi
-ac_ct_NCURSES_CONFIG=$ac_cv_prog_ac_ct_NCURSES_CONFIG
-if test -n "$ac_ct_NCURSES_CONFIG"; then
-  echo "$as_me:8014: result: $ac_ct_NCURSES_CONFIG" >&5
-echo "${ECHO_T}$ac_ct_NCURSES_CONFIG" >&6
-else
-  echo "$as_me:8017: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  test -n "$ac_ct_NCURSES_CONFIG" && break
-done
-test -n "$ac_ct_NCURSES_CONFIG" || ac_ct_NCURSES_CONFIG="none"
-
-  NCURSES_CONFIG=$ac_ct_NCURSES_CONFIG
-fi
-
-       if test "$NCURSES_CONFIG" != none ; then
-
-               CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
-
-cf_add_libs="`$NCURSES_CONFIG --libs`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
+                       if test "$cf_cv_ncurses_h2" != no ; then
+                               cf_cv_ncurses_h2=$cf_incdir/$cf_header
+                               test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&6
+                               break
+                       fi
+                       test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&6
+               done
+               CPPFLAGS="$cf_save2_CPPFLAGS"
+               test "$cf_cv_ncurses_h2" != no && break
        done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
-
-               # even with config script, some packages use no-override for curses.h
-
-echo "$as_me:8050: checking if we have identified curses headers" >&5
-echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
-if test "${cf_cv_ncurses_header+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-cf_cv_ncurses_header=none
-for cf_header in \
-       ncurses.h $cf_cv_screen/ncurses.h \
-       curses.h $cf_cv_screen/curses.h
-do
-cat >conftest.$ac_ext <<_ACEOF
-#line 8062 "configure"
-#include "confdefs.h"
-#include <${cf_header}>
-int
-main ()
-{
-initscr(); tgoto("?", 0,0)
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8074: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:8077: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8080: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:8083: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_ncurses_header=$cf_header; break
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-done
-
-fi
-echo "$as_me:8094: result: $cf_cv_ncurses_header" >&5
-echo "${ECHO_T}$cf_cv_ncurses_header" >&6
-
-if test "$cf_cv_ncurses_header" = none ; then
-       { { echo "$as_me:8098: error: No curses header-files found" >&5
-echo "$as_me: error: No curses header-files found" >&2;}
+       test "$cf_cv_ncurses_h2" = no && { { echo "$as_me:7565: error: not found" >&5
+echo "$as_me: error: not found" >&2;}
    { (exit 1); exit 1; }; }
-fi
-
-# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
-
-for ac_header in $cf_cv_ncurses_header
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:8108: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 8114 "configure"
-#include "confdefs.h"
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:8118: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:8124: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  eval "$as_ac_Header=yes"
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_ext
-fi
-echo "$as_me:8143: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-EOF
 
 fi
-done
-
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
-
-cf_nculib_ROOT=`echo "HAVE_LIB$cf_ncuconfig_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-               cat >>confdefs.h <<EOF
-#define $cf_nculib_ROOT 1
-EOF
-
-                               cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
-
-       else
-
-cf_ncuhdr_root=$cf_cv_screen
+echo "$as_me:7570: result: $cf_cv_ncurses_h2" >&5
+echo "${ECHO_T}$cf_cv_ncurses_h2" >&6
 
-test -n "$cf_cv_curses_dir" && \
-test "$cf_cv_curses_dir" != "no" && { \
+       cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'`
+       cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
+       if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
+               cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
+       fi
 
-if test -n "$cf_cv_curses_dir/include/$cf_ncuhdr_root" ; then
-  for cf_add_incdir in $cf_cv_curses_dir/include/$cf_ncuhdr_root
+if test -n "$cf_1st_incdir" ; then
+  for cf_add_incdir in $cf_1st_incdir
   do
        while test $cf_add_incdir != /usr/include
        do
@@ -8193,11 +7600,11 @@ if test -n "$cf_cv_curses_dir/include/$cf_ncuhdr_root" ; then
                          cf_save_CPPFLAGS=$CPPFLAGS
                          CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
                          cat >conftest.$ac_ext <<_ACEOF
-#line 8196 "configure"
+#line 7603 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
@@ -8205,16 +7612,16 @@ printf("Hello")
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8208: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7615: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8211: \$? = $ac_status" >&5
+  echo "$as_me:7618: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8214: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7621: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8217: \$? = $ac_status" >&5
+  echo "$as_me:7624: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -8231,7 +7638,7 @@ rm -f conftest.$ac_objext conftest.$ac_ext
                if test "$cf_have_incdir" = no ; then
                  test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:8234: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:7641: testing adding $cf_add_incdir to include-path ..." 1>&5
 
                  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
@@ -8248,943 +7655,548 @@ echo "${as_me:-configure}:8234: testing adding $cf_add_incdir to include-path ..
   done
 fi
 
-}
+fi
 
-echo "$as_me:8253: checking for $cf_ncuhdr_root header in include-path" >&5
-echo $ECHO_N "checking for $cf_ncuhdr_root header in include-path... $ECHO_C" >&6
-if test "${cf_cv_ncurses_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+# Set definitions to allow ifdef'ing for ncurses.h
 
-       cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
-       ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
-       for cf_header in $cf_header_list
-       do
+case $cf_cv_ncurses_header in
+(*ncurses.h)
 
-       cat >conftest.$ac_ext <<_ACEOF
-#line 8265 "configure"
-#include "confdefs.h"
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_H 1
+EOF
 
-#include <$cf_header>
-int
-main ()
-{
+       ;;
+esac
 
-#ifdef NCURSES_VERSION
+case $cf_cv_ncurses_header in
+(ncurses/curses.h|ncurses/ncurses.h)
 
-printf("%s\n", NCURSES_VERSION);
-#else
-#ifdef __NCURSES_H
-printf("old\n");
-#else
-       make an error
-#endif
-#endif
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_NCURSES_H 1
+EOF
+
+       ;;
+(ncursesw/curses.h|ncursesw/ncurses.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_NCURSES_H 1
+EOF
+
+       ;;
+esac
+
+echo "$as_me:7689: checking for terminfo header" >&5
+echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
+if test "${cf_cv_term_header+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+case ${cf_cv_ncurses_header} in
+(*/ncurses.h|*/ncursesw.h)
+       cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
+       ;;
+(*)
+       cf_term_header=term.h
+       ;;
+esac
+
+for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
+do
+cat >conftest.$ac_ext <<_ACEOF
+#line 7707 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <$cf_test>
 
+int
+main (void)
+{
+int x = auto_left_margin
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8289: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7722: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8292: \$? = $ac_status" >&5
+  echo "$as_me:7725: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8295: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7728: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8298: \$? = $ac_status" >&5
+  echo "$as_me:7731: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_ncurses_h=$cf_header
 
+       cf_cv_term_header="$cf_test"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_ncurses_h=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
 
-               test "$cf_cv_ncurses_h" != no && break
-       done
+       cf_cv_term_header=unknown
 
 fi
-echo "$as_me:8313: result: $cf_cv_ncurses_h" >&5
-echo "${ECHO_T}$cf_cv_ncurses_h" >&6
-
-if test "$cf_cv_ncurses_h" != no ; then
-       cf_cv_ncurses_header=$cf_cv_ncurses_h
-else
-
-echo "$as_me:8320: checking for $cf_ncuhdr_root include-path" >&5
-echo $ECHO_N "checking for $cf_ncuhdr_root include-path... $ECHO_C" >&6
-if test "${cf_cv_ncurses_h2+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-       test -n "$verbose" && echo
+rm -f conftest.$ac_objext conftest.$ac_ext
+       test "$cf_cv_term_header" != unknown && break
+done
 
-cf_search=
+fi
+echo "$as_me:7747: result: $cf_cv_term_header" >&5
+echo "${ECHO_T}$cf_cv_term_header" >&6
 
-# collect the current set of include-directories from compiler flags
-cf_header_path_list=""
-if test -n "${CFLAGS}${CPPFLAGS}" ; then
-       for cf_header_path in $CPPFLAGS $CFLAGS
-       do
-               case $cf_header_path in
-               (-I*)
-                       cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
+# Set definitions to allow ifdef'ing to accommodate subdirectories
 
-test "x$cf_header_path" != "xNONE" && \
-test -d "$cf_header_path" && \
- {
-       test -n "$verbose" && echo "    ... testing for include-directories under $cf_header_path"
-       test -d $cf_header_path/include &&          cf_search="$cf_search $cf_header_path/include"
-       test -d $cf_header_path/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root"
-       test -d $cf_header_path/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root/include"
-       test -d $cf_header_path/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include"
-       test -d $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
-}
+case $cf_cv_term_header in
+(*term.h)
 
-                       cf_header_path_list="$cf_header_path_list $cf_search"
-                       ;;
-               esac
-       done
-fi
+cat >>confdefs.h <<\EOF
+#define HAVE_TERM_H 1
+EOF
 
-# add the variations for the package we are looking for
+       ;;
+esac
 
-cf_search=
+case $cf_cv_term_header in
+(ncurses/term.h)
 
-test "x$prefix" != "xNONE" && \
-test -d "$prefix" && \
- {
-       test -n "$verbose" && echo "    ... testing for include-directories under $prefix"
-       test -d $prefix/include &&          cf_search="$cf_search $prefix/include"
-       test -d $prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
-       test -d $prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
-       test -d $prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
-       test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
-}
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_TERM_H 1
+EOF
 
-for cf_subdir_prefix in \
-       /usr \
-       /usr/local \
-       /usr/pkg \
-       /opt \
-       /opt/local \
-       $HOME
-do
+       ;;
+(ncursesw/term.h)
 
-test "x$cf_subdir_prefix" != "x$prefix" && \
-test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
-       test -n "$verbose" && echo "    ... testing for include-directories under $cf_subdir_prefix"
-       test -d $cf_subdir_prefix/include &&          cf_search="$cf_search $cf_subdir_prefix/include"
-       test -d $cf_subdir_prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root"
-       test -d $cf_subdir_prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root/include"
-       test -d $cf_subdir_prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include"
-       test -d $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
-}
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_TERM_H 1
+EOF
 
-done
+       ;;
+esac
 
-test "$includedir" != NONE && \
-test "$includedir" != "/usr/include" && \
-test -d "$includedir" && {
-       test -d $includedir &&    cf_search="$cf_search $includedir"
-       test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
-}
+# some applications need this, but should check for NCURSES_VERSION
 
-test "$oldincludedir" != NONE && \
-test "$oldincludedir" != "/usr/include" && \
-test -d "$oldincludedir" && {
-       test -d $oldincludedir    && cf_search="$cf_search $oldincludedir"
-       test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
-}
+cat >>confdefs.h <<\EOF
+#define NCURSES 1
+EOF
 
-cf_search="$cf_search $cf_header_path_list"
+echo "$as_me:7785: checking for ncurses version" >&5
+echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
+if test "${cf_cv_ncurses_version+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-       test -n "$verbose" && echo search path $cf_search
-       cf_save2_CPPFLAGS="$CPPFLAGS"
-       for cf_incdir in $cf_search
-       do
+       cf_cv_ncurses_version=no
+       cf_tempfile=out$$
+       rm -f $cf_tempfile
+       if test "$cross_compiling" = yes; then
 
-if test -n "$cf_incdir" ; then
-  for cf_add_incdir in $cf_incdir
-  do
-       while test $cf_add_incdir != /usr/include
-       do
-         if test -d $cf_add_incdir
-         then
-               cf_have_incdir=no
-               if test -n "$CFLAGS$CPPFLAGS" ; then
-                 # a loop is needed to ensure we can add subdirs of existing dirs
-                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
-                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
-                         cf_have_incdir=yes; break
-                       fi
-                 done
-               fi
+       # This will not work if the preprocessor splits the line after the
+       # Autoconf token.  The 'unproto' program does that.
+       cat > conftest.$ac_ext <<EOF
+#include <${cf_cv_ncurses_header:-curses.h}>
+#undef Autoconf
+#ifdef NCURSES_VERSION
+Autoconf NCURSES_VERSION
+#else
+#ifdef __NCURSES_H
+Autoconf "old"
+#endif
+;
+#endif
+EOF
+       cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
+       { (eval echo "$as_me:7811: \"$cf_try\"") >&5
+  (eval $cf_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7814: \$? = $ac_status" >&5
+  (exit $ac_status); }
+       if test -f conftest.out ; then
+               cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+               test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
+               rm -f conftest.out
+       fi
 
-               if test "$cf_have_incdir" = no ; then
-                 if test "$cf_add_incdir" = /usr/local/include ; then
-                       if test "$GCC" = yes
-                       then
-                         cf_save_CPPFLAGS=$CPPFLAGS
-                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-                         cat >conftest.$ac_ext <<_ACEOF
-#line 8438 "configure"
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7824 "configure"
 #include "confdefs.h"
+
+#include <${cf_cv_ncurses_header:-curses.h}>
 #include <stdio.h>
-int
-main ()
+int main(void)
 {
-printf("Hello")
-  ;
-  return 0;
+       FILE *fp = fopen("$cf_tempfile", "w");
+#ifdef NCURSES_VERSION
+# ifdef NCURSES_VERSION_PATCH
+       fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
+# else
+       fprintf(fp, "%s\n", NCURSES_VERSION);
+# endif
+#else
+# ifdef __NCURSES_H
+       fprintf(fp, "old\n");
+# else
+       make an error
+# endif
+#endif
+       ${cf_cv_main_return:-return}(0);
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8450: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:7849: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8453: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8456: \"$ac_try\"") >&5
+  echo "$as_me:7852: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:7854: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8459: \$? = $ac_status" >&5
+  echo "$as_me:7857: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+
+       cf_cv_ncurses_version=`cat $cf_tempfile`
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-                         CPPFLAGS=$cf_save_CPPFLAGS
-                       fi
-                 fi
-               fi
-
-               if test "$cf_have_incdir" = no ; then
-                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
-
-echo "${as_me:-configure}:8476: testing adding $cf_add_incdir to include-path ..." 1>&5
-
-                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-
-                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
-                 test "$cf_top_incdir" = "$cf_add_incdir" && break
-                 cf_add_incdir="$cf_top_incdir"
-               else
-                 break
-               fi
-         else
-               break
-         fi
-       done
-  done
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
+       rm -f $cf_tempfile
 
-               for cf_header in \
-                       ncurses.h \
-                       curses.h
-               do
+fi
+echo "$as_me:7871: result: $cf_cv_ncurses_version" >&5
+echo "${ECHO_T}$cf_cv_ncurses_version" >&6
+test "$cf_cv_ncurses_version" = no ||
+cat >>confdefs.h <<\EOF
+#define NCURSES 1
+EOF
 
-       cat >conftest.$ac_ext <<_ACEOF
-#line 8499 "configure"
+cf_nculib_root=$cf_cv_screen
+       # This works, except for the special case where we find gpm, but
+       # ncurses is in a nonstandard location via $LIBS, and we really want
+       # to link gpm.
+cf_ncurses_LIBS=""
+cf_ncurses_SAVE="$LIBS"
+echo "$as_me:7884: checking for Gpm_Open in -lgpm" >&5
+echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
+if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgpm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 7892 "configure"
 #include "confdefs.h"
 
-#include <$cf_header>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char Gpm_Open ();
 int
-main ()
+main (void)
 {
-
-#ifdef NCURSES_VERSION
-
-printf("%s\n", NCURSES_VERSION);
-#else
-#ifdef __NCURSES_H
-printf("old\n");
-#else
-       make an error
-#endif
-#endif
-
+Gpm_Open ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8523: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7911: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8526: \$? = $ac_status" >&5
+  echo "$as_me:7914: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8529: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7917: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8532: \$? = $ac_status" >&5
+  echo "$as_me:7920: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_ncurses_h2=$cf_header
-
+  ac_cv_lib_gpm_Gpm_Open=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_ncurses_h2=no
+ac_cv_lib_gpm_Gpm_Open=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-
-                       if test "$cf_cv_ncurses_h2" != no ; then
-                               cf_cv_ncurses_h2=$cf_incdir/$cf_header
-                               test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&6
-                               break
-                       fi
-                       test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&6
-               done
-               CPPFLAGS="$cf_save2_CPPFLAGS"
-               test "$cf_cv_ncurses_h2" != no && break
-       done
-       test "$cf_cv_ncurses_h2" = no && { { echo "$as_me:8553: error: not found" >&5
-echo "$as_me: error: not found" >&2;}
-   { (exit 1); exit 1; }; }
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:8558: result: $cf_cv_ncurses_h2" >&5
-echo "${ECHO_T}$cf_cv_ncurses_h2" >&6
-
-       cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'`
-       cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
-       if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
-               cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
-       fi
-
-if test -n "$cf_1st_incdir" ; then
-  for cf_add_incdir in $cf_1st_incdir
-  do
-       while test $cf_add_incdir != /usr/include
-       do
-         if test -d $cf_add_incdir
-         then
-               cf_have_incdir=no
-               if test -n "$CFLAGS$CPPFLAGS" ; then
-                 # a loop is needed to ensure we can add subdirs of existing dirs
-                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
-                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
-                         cf_have_incdir=yes; break
-                       fi
-                 done
-               fi
-
-               if test "$cf_have_incdir" = no ; then
-                 if test "$cf_add_incdir" = /usr/local/include ; then
-                       if test "$GCC" = yes
-                       then
-                         cf_save_CPPFLAGS=$CPPFLAGS
-                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-                         cat >conftest.$ac_ext <<_ACEOF
-#line 8591 "configure"
+echo "$as_me:7931: result: $ac_cv_lib_gpm_Gpm_Open" >&5
+echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
+if test $ac_cv_lib_gpm_Gpm_Open = yes; then
+  echo "$as_me:7934: checking for initscr in -lgpm" >&5
+echo $ECHO_N "checking for initscr in -lgpm... $ECHO_C" >&6
+if test "${ac_cv_lib_gpm_initscr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgpm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 7942 "configure"
 #include "confdefs.h"
-#include <stdio.h>
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char initscr ();
 int
-main ()
+main (void)
 {
-printf("Hello")
+initscr ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8603: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7961: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8606: \$? = $ac_status" >&5
+  echo "$as_me:7964: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8609: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7967: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8612: \$? = $ac_status" >&5
+  echo "$as_me:7970: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+  ac_cv_lib_gpm_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_have_incdir=yes
+ac_cv_lib_gpm_initscr=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-                         CPPFLAGS=$cf_save_CPPFLAGS
-                       fi
-                 fi
-               fi
-
-               if test "$cf_have_incdir" = no ; then
-                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
-
-echo "${as_me:-configure}:8629: testing adding $cf_add_incdir to include-path ..." 1>&5
-
-                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-
-                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
-                 test "$cf_top_incdir" = "$cf_add_incdir" && break
-                 cf_add_incdir="$cf_top_incdir"
-               else
-                 break
-               fi
-         else
-               break
-         fi
-       done
-  done
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-
+echo "$as_me:7981: result: $ac_cv_lib_gpm_initscr" >&5
+echo "${ECHO_T}$ac_cv_lib_gpm_initscr" >&6
+if test $ac_cv_lib_gpm_initscr = yes; then
+  LIBS="$cf_ncurses_SAVE"
+else
+  cf_ncurses_LIBS="-lgpm"
 fi
 
-# Set definitions to allow ifdef'ing for ncurses.h
-
-case $cf_cv_ncurses_header in
-(*ncurses.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSES_H 1
-EOF
-
-       ;;
-esac
-
-case $cf_cv_ncurses_header in
-(ncurses/curses.h|ncurses/ncurses.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSES_NCURSES_H 1
-EOF
-
-       ;;
-(ncursesw/curses.h|ncursesw/ncurses.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSESW_NCURSES_H 1
-EOF
-
-       ;;
-esac
+fi
 
-echo "$as_me:8677: checking for terminfo header" >&5
-echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
-if test "${cf_cv_term_header+set}" = set; then
+case $host_os in
+(freebsd*)
+       # This is only necessary if you are linking against an obsolete
+       # version of ncurses (but it should do no harm, since it's static).
+       if test "$cf_nculib_root" = ncurses ; then
+               echo "$as_me:7996: checking for tgoto in -lmytinfo" >&5
+echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
+if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
-case ${cf_cv_ncurses_header} in
-(*/ncurses.h|*/ncursesw.h)
-       cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
-       ;;
-(*)
-       cf_term_header=term.h
-       ;;
-esac
-
-for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
-do
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmytinfo  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 8695 "configure"
+#line 8004 "configure"
 #include "confdefs.h"
-#include <stdio.h>
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <$cf_test>
 
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char tgoto ();
 int
-main ()
+main (void)
 {
-int x = auto_left_margin
+tgoto ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8710: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:8023: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8713: \$? = $ac_status" >&5
+  echo "$as_me:8026: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8716: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:8029: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8719: \$? = $ac_status" >&5
+  echo "$as_me:8032: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-       cf_cv_term_header="$cf_test"
+  ac_cv_lib_mytinfo_tgoto=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-
-       cf_cv_term_header=unknown
-
+ac_cv_lib_mytinfo_tgoto=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-       test "$cf_cv_term_header" != unknown && break
-done
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:8043: result: $ac_cv_lib_mytinfo_tgoto" >&5
+echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
+if test $ac_cv_lib_mytinfo_tgoto = yes; then
+  cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"
 fi
-echo "$as_me:8735: result: $cf_cv_term_header" >&5
-echo "${ECHO_T}$cf_cv_term_header" >&6
-
-# Set definitions to allow ifdef'ing to accommodate subdirectories
-
-case $cf_cv_term_header in
-(*term.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_TERM_H 1
-EOF
-
-       ;;
-esac
-
-case $cf_cv_term_header in
-(ncurses/term.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSES_TERM_H 1
-EOF
-
-       ;;
-(ncursesw/term.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSESW_TERM_H 1
-EOF
 
+       fi
        ;;
 esac
 
-# some applications need this, but should check for NCURSES_VERSION
-
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
-
-echo "$as_me:8773: checking for ncurses version" >&5
-echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
-if test "${cf_cv_ncurses_version+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-       cf_cv_ncurses_version=no
-       cf_tempfile=out$$
-       rm -f $cf_tempfile
-       if test "$cross_compiling" = yes; then
-
-       # This will not work if the preprocessor splits the line after the
-       # Autoconf token.  The 'unproto' program does that.
-       cat > conftest.$ac_ext <<EOF
-#include <${cf_cv_ncurses_header:-curses.h}>
-#undef Autoconf
-#ifdef NCURSES_VERSION
-Autoconf NCURSES_VERSION
-#else
-#ifdef __NCURSES_H
-Autoconf "old"
-#endif
-;
-#endif
-EOF
-       cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-       { (eval echo "$as_me:8799: \"$cf_try\"") >&5
-  (eval $cf_try) 2>&5
-  ac_status=$?
-  echo "$as_me:8802: \$? = $ac_status" >&5
-  (exit $ac_status); }
-       if test -f conftest.out ; then
-               cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
-               test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
-               rm -f conftest.out
-       fi
+cf_add_libs="$cf_ncurses_LIBS"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 8812 "configure"
-#include "confdefs.h"
+if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
+then
 
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <stdio.h>
-int main()
-{
-       FILE *fp = fopen("$cf_tempfile", "w");
-#ifdef NCURSES_VERSION
-# ifdef NCURSES_VERSION_PATCH
-       fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
-# else
-       fprintf(fp, "%s\n", NCURSES_VERSION);
-# endif
-#else
-# ifdef __NCURSES_H
-       fprintf(fp, "old\n");
-# else
-       make an error
-# endif
-#endif
-       ${cf_cv_main_return:-return}(0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:8837: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:8840: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:8842: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:8845: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+cf_add_libs="-l$cf_nculib_root"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-       cf_cv_ncurses_version=`cat $cf_tempfile`
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-       rm -f $cf_tempfile
-
-fi
-echo "$as_me:8859: result: $cf_cv_ncurses_version" >&5
-echo "${ECHO_T}$cf_cv_ncurses_version" >&6
-test "$cf_cv_ncurses_version" = no ||
-cat >>confdefs.h <<\EOF
-#define NCURSES 1
-EOF
 
-cf_nculib_root=$cf_cv_screen
-       # This works, except for the special case where we find gpm, but
-       # ncurses is in a nonstandard location via $LIBS, and we really want
-       # to link gpm.
-cf_ncurses_LIBS=""
-cf_ncurses_SAVE="$LIBS"
-echo "$as_me:8872: checking for Gpm_Open in -lgpm" >&5
-echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
-if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
+       eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
+       cf_libdir=""
+       echo "$as_me:8092: checking for initscr" >&5
+echo $ECHO_N "checking for initscr... $ECHO_C" >&6
+if test "${ac_cv_func_initscr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgpm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 8880 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 8098 "configure"
 #include "confdefs.h"
-
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char initscr (); below.  */
+#include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char Gpm_Open ();
+char initscr ();
+char (*f) ();
+
 int
-main ()
+main (void)
 {
-Gpm_Open ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_initscr) || defined (__stub___initscr)
+choke me
+#else
+f = initscr; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8899: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8129: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8902: \$? = $ac_status" >&5
+  echo "$as_me:8132: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8905: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8135: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8908: \$? = $ac_status" >&5
+  echo "$as_me:8138: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_gpm_Gpm_Open=yes
+  ac_cv_func_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_gpm_Gpm_Open=no
+ac_cv_func_initscr=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:8919: result: $ac_cv_lib_gpm_Gpm_Open" >&5
-echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
-if test $ac_cv_lib_gpm_Gpm_Open = yes; then
-  echo "$as_me:8922: checking for initscr in -lgpm" >&5
-echo $ECHO_N "checking for initscr in -lgpm... $ECHO_C" >&6
-if test "${ac_cv_lib_gpm_initscr+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+echo "$as_me:8148: result: $ac_cv_func_initscr" >&5
+echo "${ECHO_T}$ac_cv_func_initscr" >&6
+if test $ac_cv_func_initscr = yes; then
+  eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgpm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 8930 "configure"
-#include "confdefs.h"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char initscr ();
+               cf_save_LIBS="$LIBS"
+               echo "$as_me:8155: checking for initscr in -l$cf_nculib_root" >&5
+echo $ECHO_N "checking for initscr in -l$cf_nculib_root... $ECHO_C" >&6
+               LIBS="-l$cf_nculib_root $LIBS"
+               cat >conftest.$ac_ext <<_ACEOF
+#line 8159 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-initscr ();
+initscr()
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8949: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8171: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8952: \$? = $ac_status" >&5
+  echo "$as_me:8174: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8955: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8177: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8958: \$? = $ac_status" >&5
+  echo "$as_me:8180: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_gpm_initscr=yes
+  echo "$as_me:8182: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+                        eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_gpm_initscr=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:8969: result: $ac_cv_lib_gpm_initscr" >&5
-echo "${ECHO_T}$ac_cv_lib_gpm_initscr" >&6
-if test $ac_cv_lib_gpm_initscr = yes; then
-  LIBS="$cf_ncurses_SAVE"
-else
-  cf_ncurses_LIBS="-lgpm"
-fi
+echo "$as_me:8189: result: no" >&5
+echo "${ECHO_T}no" >&6
 
-fi
-
-case $host_os in
-(freebsd*)
-       # This is only necessary if you are linking against an obsolete
-       # version of ncurses (but it should do no harm, since it's static).
-       if test "$cf_nculib_root" = ncurses ; then
-               echo "$as_me:8984: checking for tgoto in -lmytinfo" >&5
-echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
-if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmytinfo  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 8992 "configure"
-#include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char tgoto ();
-int
-main ()
-{
-tgoto ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9011: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:9014: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9017: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:9020: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_mytinfo_tgoto=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_mytinfo_tgoto=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:9031: result: $ac_cv_lib_mytinfo_tgoto" >&5
-echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
-if test $ac_cv_lib_mytinfo_tgoto = yes; then
-  cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"
-fi
-
-       fi
-       ;;
-esac
-
-cf_add_libs="$cf_ncurses_LIBS"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
-
-if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
-then
-
-cf_add_libs="-l$cf_nculib_root"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
-
-else
-
-       eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
-       cf_libdir=""
-       echo "$as_me:9080: checking for initscr" >&5
-echo $ECHO_N "checking for initscr... $ECHO_C" >&6
-if test "${ac_cv_func_initscr+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 9086 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char initscr (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char initscr ();
-char (*f) ();
-
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_initscr) || defined (__stub___initscr)
-choke me
-#else
-f = initscr; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9117: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:9120: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9123: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:9126: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_initscr=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_initscr=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:9136: result: $ac_cv_func_initscr" >&5
-echo "${ECHO_T}$ac_cv_func_initscr" >&6
-if test $ac_cv_func_initscr = yes; then
-  eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
-else
-
-               cf_save_LIBS="$LIBS"
-               echo "$as_me:9143: checking for initscr in -l$cf_nculib_root" >&5
-echo $ECHO_N "checking for initscr in -l$cf_nculib_root... $ECHO_C" >&6
-               LIBS="-l$cf_nculib_root $LIBS"
-               cat >conftest.$ac_ext <<_ACEOF
-#line 9147 "configure"
-#include "confdefs.h"
-#include <${cf_cv_ncurses_header:-curses.h}>
-int
-main ()
-{
-initscr()
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9159: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:9162: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9165: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:9168: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:9170: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-                        eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
-
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:9177: result: no" >&5
-echo "${ECHO_T}no" >&6
-
-cf_search=
-cf_library_path_list=""
-if test -n "${LDFLAGS}${LIBS}" ; then
-       for cf_library_path in $LDFLAGS $LIBS
-       do
-               case $cf_library_path in
-               (-L*)
-                       cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
+cf_search=
+cf_library_path_list=""
+if test -n "${LDFLAGS}${LIBS}" ; then
+       for cf_library_path in $LDFLAGS $LIBS
+       do
+               case $cf_library_path in
+               (-L*)
+                       cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
 
 test "x$cf_library_path" != "xNONE" && \
 test -d "$cf_library_path" && \
@@ -9242,15 +8254,15 @@ cf_search="$cf_library_path_list $cf_search"
 
                        for cf_libdir in $cf_search
                        do
-                               echo "$as_me:9245: checking for -l$cf_nculib_root in $cf_libdir" >&5
+                               echo "$as_me:8257: checking for -l$cf_nculib_root in $cf_libdir" >&5
 echo $ECHO_N "checking for -l$cf_nculib_root in $cf_libdir... $ECHO_C" >&6
                                LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
                                cat >conftest.$ac_ext <<_ACEOF
-#line 9249 "configure"
+#line 8261 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 initscr()
   ;
@@ -9258,25 +8270,25 @@ initscr()
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9261: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8273: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9264: \$? = $ac_status" >&5
+  echo "$as_me:8276: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9267: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8279: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9270: \$? = $ac_status" >&5
+  echo "$as_me:8282: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  echo "$as_me:9272: result: yes" >&5
+  echo "$as_me:8284: result: yes" >&5
 echo "${ECHO_T}yes" >&6
                                         eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
                                         break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-echo "$as_me:9279: result: no" >&5
+echo "$as_me:8291: result: no" >&5
 echo "${ECHO_T}no" >&6
                                         LIBS="$cf_save_LIBS"
 fi
@@ -9291,7 +8303,7 @@ fi
 eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root
 
 if test $cf_found_library = no ; then
-       { { echo "$as_me:9294: error: Cannot link $cf_nculib_root library" >&5
+       { { echo "$as_me:8306: error: Cannot link $cf_nculib_root library" >&5
 echo "$as_me: error: Cannot link $cf_nculib_root library" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -9299,7 +8311,7 @@ fi
 fi
 
 if test -n "$cf_ncurses_LIBS" ; then
-       echo "$as_me:9302: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
+       echo "$as_me:8314: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
 echo $ECHO_N "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS... $ECHO_C" >&6
        cf_ncurses_SAVE="$LIBS"
        for p in $cf_ncurses_LIBS ; do
@@ -9309,11 +8321,11 @@ echo $ECHO_N "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS..
                fi
        done
        cat >conftest.$ac_ext <<_ACEOF
-#line 9312 "configure"
+#line 8324 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
   ;
@@ -9321,23 +8333,23 @@ initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9324: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8336: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9327: \$? = $ac_status" >&5
+  echo "$as_me:8339: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9330: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8342: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9333: \$? = $ac_status" >&5
+  echo "$as_me:8345: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  echo "$as_me:9335: result: yes" >&5
+  echo "$as_me:8347: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-echo "$as_me:9340: result: no" >&5
+echo "$as_me:8352: result: no" >&5
 echo "${ECHO_T}no" >&6
                 LIBS="$cf_ncurses_SAVE"
 fi
 fi
 
        ;;
-(pdcurses)
-       echo "$as_me:9360: checking for X" >&5
-echo $ECHO_N "checking for X... $ECHO_C" >&6
+(ncurses*)
 
-# Check whether --with-x or --without-x was given.
-if test "${with_x+set}" = set; then
-  withval="$with_x"
+cf_ncuconfig_root=$cf_cv_screen
+cf_have_ncuconfig=no
 
-fi;
-# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
-if test "x$with_x" = xno; then
-  # The user explicitly disabled X.
-  have_x=disabled
-else
-  if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
-    # Both variables are already set.
-    have_x=yes
-  else
-    if test "${ac_cv_have_x+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # One or both of the vars are not set, and there is no cached value.
-ac_x_includes=no ac_x_libraries=no
-rm -fr conftest.dir
-if mkdir conftest.dir; then
-  cd conftest.dir
-  # Make sure to not put "make" in the Imakefile rules, since we grep it out.
-  cat >Imakefile <<'EOF'
-acfindx:
-       @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
-EOF
-  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
-    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-    eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
-    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
-    for ac_extension in a so sl dylib dll; do
-      if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
-         test -f $ac_im_libdir/libX11.$ac_extension; then
-        ac_im_usrlibdir=$ac_im_libdir; break
-      fi
-    done
-    # Screen out bogus values from the imake configuration.  They are
-    # bogus both because they are the default anyway, and because
-    # using them would break gcc on systems where it needs fixed includes.
-    case $ac_im_incroot in
-       /usr/include) ;;
-       *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
-    esac
-    case $ac_im_usrlibdir in
-       /usr/lib | /lib) ;;
-       *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
-    esac
-  fi
-  cd ..
-  rm -fr conftest.dir
-fi
+if test "x${PKG_CONFIG:=none}" != xnone; then
+       echo "$as_me:8377: checking pkg-config for $cf_ncuconfig_root" >&5
+echo $ECHO_N "checking pkg-config for $cf_ncuconfig_root... $ECHO_C" >&6
+       if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
+               echo "$as_me:8380: result: yes" >&5
+echo "${ECHO_T}yes" >&6
 
-# Standard set of common directories for X headers.
-# Check X11 before X11Rn because it is often a symlink to the current release.
-ac_x_header_dirs='
-/usr/X11/include
-/usr/X11R6/include
-/usr/X11R5/include
-/usr/X11R4/include
+               echo "$as_me:8383: checking if the $cf_ncuconfig_root package files work" >&5
+echo $ECHO_N "checking if the $cf_ncuconfig_root package files work... $ECHO_C" >&6
+               cf_have_ncuconfig=unknown
 
-/usr/include/X11
-/usr/include/X11R6
-/usr/include/X11R5
-/usr/include/X11R4
-
-/usr/local/X11/include
-/usr/local/X11R6/include
-/usr/local/X11R5/include
-/usr/local/X11R4/include
-
-/usr/local/include/X11
-/usr/local/include/X11R6
-/usr/local/include/X11R5
-/usr/local/include/X11R4
-
-/usr/X386/include
-/usr/x386/include
-/usr/XFree86/include/X11
-
-/usr/include
-/usr/local/include
-/usr/unsupported/include
-/usr/athena/include
-/usr/local/x11r5/include
-/usr/lpp/Xamples/include
+               cf_save_CPPFLAGS="$CPPFLAGS"
+               cf_save_LIBS="$LIBS"
 
-/usr/openwin/include
-/usr/openwin/share/include'
+               CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
 
-if test "$ac_x_includes" = no; then
-  # Guess where to find include files, by looking for Intrinsic.h.
-  # First, try using that file with no special directory specified.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 9457 "configure"
-#include "confdefs.h"
-#include <X11/Intrinsic.h>
-_ACEOF
-if { (eval echo "$as_me:9461: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:9467: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  # We can compile using X headers with no special include directory.
-ac_x_includes=
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  for ac_dir in $ac_x_header_dirs; do
-  if test -r "$ac_dir/X11/Intrinsic.h"; then
-    ac_x_includes=$ac_dir
-    break
-  fi
+cf_add_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
 done
-fi
-rm -f conftest.err conftest.$ac_ext
-fi # $ac_x_includes = no
+LIBS="$cf_add_libs"
 
-if test "$ac_x_libraries" = no; then
-  # Check for the libraries.
-  # See if we find them without any special options.
-  # Don't add to $LIBS permanently.
-  ac_save_LIBS=$LIBS
-  LIBS="-lXt $LIBS"
-  cat >conftest.$ac_ext <<_ACEOF
-#line 9500 "configure"
+               cat >conftest.$ac_ext <<_ACEOF
+#line 8409 "configure"
 #include "confdefs.h"
-#include <X11/Intrinsic.h>
+#include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-XtMalloc (0)
+initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9512: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8421: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9515: \$? = $ac_status" >&5
+  echo "$as_me:8424: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9518: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8427: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9521: \$? = $ac_status" >&5
+  echo "$as_me:8430: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  LIBS=$ac_save_LIBS
-# We can link X programs with no special library path.
-ac_x_libraries=
+  if test "$cross_compiling" = yes; then
+  cf_have_ncuconfig=maybe
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-LIBS=$ac_save_LIBS
-for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
-do
-  # Don't even attempt the hair of trying to link an X program!
-  for ac_extension in a so sl dylib dll; do
-    if test -r $ac_dir/libXt.$ac_extension; then
-      ac_x_libraries=$ac_dir
-      break 2
-    fi
-  done
-done
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi # $ac_x_libraries = no
-
-if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
-  # Didn't find X anywhere.  Cache the known absence of X.
-  ac_cv_have_x="have_x=no"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 8436 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+                               int main(void)
+                               { char *xx = curses_version(); return (xx == 0); }
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:8443: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8446: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:8448: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8451: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_have_ncuconfig=yes
 else
-  # Record where we found X for the cache.
-  ac_cv_have_x="have_x=yes \
-               ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_have_ncuconfig=no
 fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-
-  fi
-  eval "$ac_cv_have_x"
-fi # $with_x != no
-
-if test "$have_x" != yes; then
-  echo "$as_me:9559: result: $have_x" >&5
-echo "${ECHO_T}$have_x" >&6
-  no_x=yes
 else
-  # If each of the values was on the command line, it overrides each guess.
-  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
-  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
-  # Update the cache value to reflect the command line values.
-  ac_cv_have_x="have_x=yes \
-               ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
-  echo "$as_me:9569: result: libraries $x_libraries, headers $x_includes" >&5
-echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_have_ncuconfig=no
 fi
-
-if test "$no_x" = yes; then
-  # Not all programs may use this symbol, but it does not hurt to define it.
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+               echo "$as_me:8468: result: $cf_have_ncuconfig" >&5
+echo "${ECHO_T}$cf_have_ncuconfig" >&6
+               test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
+               if test "$cf_have_ncuconfig" != "yes"
+               then
+                       CPPFLAGS="$cf_save_CPPFLAGS"
+                       LIBS="$cf_save_LIBS"
+                       NCURSES_CONFIG_PKG=none
+               else
 
 cat >>confdefs.h <<\EOF
-#define X_DISPLAY_MISSING 1
+#define NCURSES 1
 EOF
 
-  X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
+                       NCURSES_CONFIG_PKG=$cf_ncuconfig_root
+               fi
+
+echo "$as_me:8485: checking for terminfo header" >&5
+echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
+if test "${cf_cv_term_header+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$x_includes"; then
-    X_CFLAGS="$X_CFLAGS -I$x_includes"
-  fi
 
-  # It would also be nice to do this for all -L options, not just this one.
-  if test -n "$x_libraries"; then
-    X_LIBS="$X_LIBS -L$x_libraries"
-    # For Solaris; some versions of Sun CC require a space after -R and
-    # others require no space.  Words are not sufficient . . . .
-    case `(uname -sr) 2>/dev/null` in
-    "SunOS 5"*)
-      echo "$as_me:9593: checking whether -R must be followed by a space" >&5
-echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6
-      ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
-      cat >conftest.$ac_ext <<_ACEOF
-#line 9597 "configure"
+case ${cf_cv_ncurses_header} in
+(*/ncurses.h|*/ncursesw.h)
+       cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
+       ;;
+(*)
+       cf_term_header=term.h
+       ;;
+esac
+
+for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
+do
+cat >conftest.$ac_ext <<_ACEOF
+#line 8503 "configure"
 #include "confdefs.h"
+#include <stdio.h>
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <$cf_test>
 
 int
-main ()
+main (void)
 {
-
+int x = auto_left_margin
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9609: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:8518: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9612: \$? = $ac_status" >&5
+  echo "$as_me:8521: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9615: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:8524: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9618: \$? = $ac_status" >&5
+  echo "$as_me:8527: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_R_nospace=yes
+
+       cf_cv_term_header="$cf_test"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_R_nospace=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-      if test $ac_R_nospace = yes; then
-       echo "$as_me:9628: result: no" >&5
-echo "${ECHO_T}no" >&6
-       X_LIBS="$X_LIBS -R$x_libraries"
-      else
-       LIBS="$ac_xsave_LIBS -R $x_libraries"
-       cat >conftest.$ac_ext <<_ACEOF
-#line 9634 "configure"
-#include "confdefs.h"
 
-int
-main ()
-{
+       cf_cv_term_header=unknown
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9646: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:9649: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9652: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:9655: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_R_space=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_R_space=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-       if test $ac_R_space = yes; then
-         echo "$as_me:9665: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-         X_LIBS="$X_LIBS -R $x_libraries"
-       else
-         echo "$as_me:9669: result: neither works" >&5
-echo "${ECHO_T}neither works" >&6
-       fi
-      fi
-      LIBS=$ac_xsave_LIBS
-    esac
-  fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+       test "$cf_cv_term_header" != unknown && break
+done
 
-  # Check for system-dependent libraries X programs must link with.
-  # Do this before checking for the system-independent R6 libraries
-  # (-lICE), since we may need -lsocket or whatever for X linking.
+fi
+echo "$as_me:8543: result: $cf_cv_term_header" >&5
+echo "${ECHO_T}$cf_cv_term_header" >&6
 
-  if test "$ISC" = yes; then
-    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
-  else
-    # Martyn Johnson says this is needed for Ultrix, if the X
-    # libraries were built with DECnet support.  And Karl Berry says
-    # the Alpha needs dnet_stub (dnet does not exist).
-    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
-    cat >conftest.$ac_ext <<_ACEOF
-#line 9689 "configure"
-#include "confdefs.h"
+# Set definitions to allow ifdef'ing to accommodate subdirectories
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
-int
-main ()
-{
-XOpenDisplay ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9708: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:9711: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9714: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:9717: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
+case $cf_cv_term_header in
+(*term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_TERM_H 1
+EOF
+
+       ;;
+esac
+
+case $cf_cv_term_header in
+(ncurses/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_TERM_H 1
+EOF
+
+       ;;
+(ncursesw/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_TERM_H 1
+EOF
+
+       ;;
+esac
+
+       else
+               echo "$as_me:8576: result: no" >&5
+echo "${ECHO_T}no" >&6
+               NCURSES_CONFIG_PKG=none
+       fi
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:9723: checking for dnet_ntoa in -ldnet" >&5
-echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
-if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
+       NCURSES_CONFIG_PKG=none
+fi
+
+if test "x$cf_have_ncuconfig" = "xno"; then
+       echo "Looking for ${cf_ncuconfig_root}-config"
+
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:8592: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_NCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9731 "configure"
-#include "confdefs.h"
+  if test -n "$NCURSES_CONFIG"; then
+  ac_cv_prog_NCURSES_CONFIG="$NCURSES_CONFIG" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_NCURSES_CONFIG="$ac_tool_prefix$ac_prog"
+echo "$as_me:8607: found $ac_dir/$ac_word" >&5
+break
+done
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char dnet_ntoa ();
-int
-main ()
-{
-dnet_ntoa ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9750: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:9753: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9756: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:9759: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_dnet_dnet_ntoa=yes
+fi
+fi
+NCURSES_CONFIG=$ac_cv_prog_NCURSES_CONFIG
+if test -n "$NCURSES_CONFIG"; then
+  echo "$as_me:8615: result: $NCURSES_CONFIG" >&5
+echo "${ECHO_T}$NCURSES_CONFIG" >&6
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_dnet_dnet_ntoa=no
+  echo "$as_me:8618: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+
+    test -n "$NCURSES_CONFIG" && break
+  done
 fi
-echo "$as_me:9770: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
-echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
-if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
+if test -z "$NCURSES_CONFIG"; then
+  ac_ct_NCURSES_CONFIG=$NCURSES_CONFIG
+  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:8631: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_NCURSES_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_NCURSES_CONFIG"; then
+  ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_ct_NCURSES_CONFIG" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_prog"
+echo "$as_me:8646: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_NCURSES_CONFIG=$ac_cv_prog_ac_ct_NCURSES_CONFIG
+if test -n "$ac_ct_NCURSES_CONFIG"; then
+  echo "$as_me:8654: result: $ac_ct_NCURSES_CONFIG" >&5
+echo "${ECHO_T}$ac_ct_NCURSES_CONFIG" >&6
+else
+  echo "$as_me:8657: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
-      echo "$as_me:9777: checking for dnet_ntoa in -ldnet_stub" >&5
-echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
-if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
+  test -n "$ac_ct_NCURSES_CONFIG" && break
+done
+test -n "$ac_ct_NCURSES_CONFIG" || ac_ct_NCURSES_CONFIG="none"
+
+  NCURSES_CONFIG=$ac_ct_NCURSES_CONFIG
+fi
+
+       if test "$NCURSES_CONFIG" != none ; then
+
+               CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
+
+cf_add_libs="`$NCURSES_CONFIG --libs`"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
+
+               # even with config script, some packages use no-override for curses.h
+
+echo "$as_me:8690: checking if we have identified curses headers" >&5
+echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
+if test "${cf_cv_ncurses_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet_stub  $LIBS"
+
+cf_cv_ncurses_header=none
+for cf_header in \
+       ncurses.h $cf_cv_screen/ncurses.h \
+       curses.h $cf_cv_screen/curses.h
+do
 cat >conftest.$ac_ext <<_ACEOF
-#line 9785 "configure"
+#line 8702 "configure"
 #include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char dnet_ntoa ();
+#include <${cf_header}>
 int
-main ()
+main (void)
 {
-dnet_ntoa ();
+initscr(); tgoto("?", 0,0)
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9804: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:8714: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9807: \$? = $ac_status" >&5
+  echo "$as_me:8717: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9810: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:8720: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9813: \$? = $ac_status" >&5
+  echo "$as_me:8723: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_dnet_stub_dnet_ntoa=yes
+  cf_cv_ncurses_header=$cf_header; break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_dnet_stub_dnet_ntoa=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:9824: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
-echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
-if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+
 fi
+echo "$as_me:8734: result: $cf_cv_ncurses_header" >&5
+echo "${ECHO_T}$cf_cv_ncurses_header" >&6
 
-    fi
+if test "$cf_cv_ncurses_header" = none ; then
+       { { echo "$as_me:8738: error: No curses header-files found" >&5
+echo "$as_me: error: No curses header-files found" >&2;}
+   { (exit 1); exit 1; }; }
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-    LIBS="$ac_xsave_LIBS"
 
-    # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
-    # to get the SysV transport functions.
-    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
-    # needs -lnsl.
-    # The nsl library prevents programs from opening the X display
-    # on Irix 5.2, according to T.E. Dickey.
-    # The functions gethostbyname, getservbyname, and inet_addr are
-    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
-    echo "$as_me:9843: checking for gethostbyname" >&5
-echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
-if test "${ac_cv_func_gethostbyname+set}" = set; then
+# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
+
+for ac_header in $cf_cv_ncurses_header
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:8748: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9849 "configure"
+#line 8754 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char gethostbyname (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
-char (*f) ();
-
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
-choke me
-#else
-f = gethostbyname; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
-
-  ;
-  return 0;
-}
+#include <$ac_header>
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9880: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:9883: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9886: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+if { (eval echo "$as_me:8758: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
-  echo "$as_me:9889: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_gethostbyname=yes
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:8764: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_gethostbyname=no
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:9899: result: $ac_cv_func_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
+echo "$as_me:8783: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
 
-    if test $ac_cv_func_gethostbyname = no; then
-      echo "$as_me:9903: checking for gethostbyname in -lnsl" >&5
-echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
-if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnsl  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9911 "configure"
-#include "confdefs.h"
+fi
+done
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
+cat >>confdefs.h <<\EOF
+#define NCURSES 1
+EOF
+
+cf_nculib_ROOT=`echo "HAVE_LIB$cf_ncuconfig_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+               cat >>confdefs.h <<EOF
+#define $cf_nculib_ROOT 1
+EOF
+
+                               cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
+
+       else
+
+cf_ncuhdr_root=$cf_cv_screen
+
+test -n "$cf_cv_curses_dir" && \
+test "$cf_cv_curses_dir" != "no" && { \
+
+if test -n "$cf_cv_curses_dir/include/$cf_ncuhdr_root" ; then
+  for cf_add_incdir in $cf_cv_curses_dir/include/$cf_ncuhdr_root
+  do
+       while test $cf_add_incdir != /usr/include
+       do
+         if test -d $cf_add_incdir
+         then
+               cf_have_incdir=no
+               if test -n "$CFLAGS$CPPFLAGS" ; then
+                 # a loop is needed to ensure we can add subdirs of existing dirs
+                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
+                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
+                         cf_have_incdir=yes; break
+                       fi
+                 done
+               fi
+
+               if test "$cf_have_incdir" = no ; then
+                 if test "$cf_add_incdir" = /usr/local/include ; then
+                       if test "$GCC" = yes
+                       then
+                         cf_save_CPPFLAGS=$CPPFLAGS
+                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+                         cat >conftest.$ac_ext <<_ACEOF
+#line 8836 "configure"
+#include "confdefs.h"
+#include <stdio.h>
 int
-main ()
+main (void)
 {
-gethostbyname ();
+printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9930: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:8848: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9933: \$? = $ac_status" >&5
+  echo "$as_me:8851: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9936: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:8854: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9939: \$? = $ac_status" >&5
+  echo "$as_me:8857: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_nsl_gethostbyname=yes
+  :
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_nsl_gethostbyname=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+cf_have_incdir=yes
 fi
-echo "$as_me:9950: result: $ac_cv_lib_nsl_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
-if test $ac_cv_lib_nsl_gethostbyname = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
+rm -f conftest.$ac_objext conftest.$ac_ext
+                         CPPFLAGS=$cf_save_CPPFLAGS
+                       fi
+                 fi
+               fi
+
+               if test "$cf_have_incdir" = no ; then
+                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
+
+echo "${as_me:-configure}:8874: testing adding $cf_add_incdir to include-path ..." 1>&5
+
+                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+
+                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+                 test "$cf_top_incdir" = "$cf_add_incdir" && break
+                 cf_add_incdir="$cf_top_incdir"
+               else
+                 break
+               fi
+         else
+               break
+         fi
+       done
+  done
 fi
 
-      if test $ac_cv_lib_nsl_gethostbyname = no; then
-        echo "$as_me:9957: checking for gethostbyname in -lbsd" >&5
-echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
-if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
+}
+
+echo "$as_me:8893: checking for $cf_ncuhdr_root header in include-path" >&5
+echo $ECHO_N "checking for $cf_ncuhdr_root header in include-path... $ECHO_C" >&6
+if test "${cf_cv_ncurses_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbsd  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9965 "configure"
+
+       cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
+       ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
+       for cf_header in $cf_header_list
+       do
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 8905 "configure"
 #include "confdefs.h"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
+#include <$cf_header>
 int
-main ()
+main (void)
 {
-gethostbyname ();
+
+#ifdef NCURSES_VERSION
+
+printf("%s\n", NCURSES_VERSION);
+#else
+#ifdef __NCURSES_H
+printf("old\n");
+#else
+       make an error
+#endif
+#endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9984: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:8929: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9987: \$? = $ac_status" >&5
+  echo "$as_me:8932: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9990: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:8935: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9993: \$? = $ac_status" >&5
+  echo "$as_me:8938: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_bsd_gethostbyname=yes
+  cf_cv_ncurses_h=$cf_header
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_bsd_gethostbyname=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+cf_cv_ncurses_h=no
 fi
-echo "$as_me:10004: result: $ac_cv_lib_bsd_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
-if test $ac_cv_lib_bsd_gethostbyname = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+               test "$cf_cv_ncurses_h" != no && break
+       done
+
 fi
+echo "$as_me:8953: result: $cf_cv_ncurses_h" >&5
+echo "${ECHO_T}$cf_cv_ncurses_h" >&6
 
-      fi
-    fi
+if test "$cf_cv_ncurses_h" != no ; then
+       cf_cv_ncurses_header=$cf_cv_ncurses_h
+else
 
-    # lieder@skyler.mavd.honeywell.com says without -lsocket,
-    # socket/setsockopt and other routines are undefined under SCO ODT
-    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
-    # on later versions), says Simon Leinen: it contains gethostby*
-    # variants that don't use the nameserver (or something).  -lsocket
-    # must be given before -lnsl if both are needed.  We assume that
-    # if connect needs -lnsl, so does gethostbyname.
-    echo "$as_me:10020: checking for connect" >&5
-echo $ECHO_N "checking for connect... $ECHO_C" >&6
-if test "${ac_cv_func_connect+set}" = set; then
+echo "$as_me:8960: checking for $cf_ncuhdr_root include-path" >&5
+echo $ECHO_N "checking for $cf_ncuhdr_root include-path... $ECHO_C" >&6
+if test "${cf_cv_ncurses_h2+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 10026 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char connect (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char connect ();
-char (*f) ();
 
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_connect) || defined (__stub___connect)
-choke me
-#else
-f = connect; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
+       test -n "$verbose" && echo
 
-  ;
-  return 0;
+cf_search=
+
+# collect the current set of include-directories from compiler flags
+cf_header_path_list=""
+if test -n "${CFLAGS}${CPPFLAGS}" ; then
+       for cf_header_path in $CPPFLAGS $CFLAGS
+       do
+               case $cf_header_path in
+               (-I*)
+                       cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
+
+test "x$cf_header_path" != "xNONE" && \
+test -d "$cf_header_path" && \
+ {
+       test -n "$verbose" && echo "    ... testing for include-directories under $cf_header_path"
+       test -d $cf_header_path/include &&          cf_search="$cf_search $cf_header_path/include"
+       test -d $cf_header_path/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root"
+       test -d $cf_header_path/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root/include"
+       test -d $cf_header_path/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include"
+       test -d $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
 }
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10057: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:10060: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10063: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:10066: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_connect=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_connect=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+                       cf_header_path_list="$cf_header_path_list $cf_search"
+                       ;;
+               esac
+       done
 fi
-echo "$as_me:10076: result: $ac_cv_func_connect" >&5
-echo "${ECHO_T}$ac_cv_func_connect" >&6
 
-    if test $ac_cv_func_connect = no; then
-      echo "$as_me:10080: checking for connect in -lsocket" >&5
-echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
-if test "${ac_cv_lib_socket_connect+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 10088 "configure"
-#include "confdefs.h"
+# add the variations for the package we are looking for
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char connect ();
+cf_search=
+
+test "x$prefix" != "xNONE" && \
+test -d "$prefix" && \
+ {
+       test -n "$verbose" && echo "    ... testing for include-directories under $prefix"
+       test -d $prefix/include &&          cf_search="$cf_search $prefix/include"
+       test -d $prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
+       test -d $prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
+       test -d $prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
+       test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+}
+
+for cf_subdir_prefix in \
+       /usr \
+       /usr/local \
+       /usr/pkg \
+       /opt \
+       /opt/local \
+       $HOME
+do
+
+test "x$cf_subdir_prefix" != "x$prefix" && \
+test -d "$cf_subdir_prefix" && \
+(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+       test -n "$verbose" && echo "    ... testing for include-directories under $cf_subdir_prefix"
+       test -d $cf_subdir_prefix/include &&          cf_search="$cf_search $cf_subdir_prefix/include"
+       test -d $cf_subdir_prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root"
+       test -d $cf_subdir_prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root/include"
+       test -d $cf_subdir_prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include"
+       test -d $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+}
+
+done
+
+test "$includedir" != NONE && \
+test "$includedir" != "/usr/include" && \
+test -d "$includedir" && {
+       test -d $includedir &&    cf_search="$cf_search $includedir"
+       test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
+}
+
+test "$oldincludedir" != NONE && \
+test "$oldincludedir" != "/usr/include" && \
+test -d "$oldincludedir" && {
+       test -d $oldincludedir    && cf_search="$cf_search $oldincludedir"
+       test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
+}
+
+cf_search="$cf_search $cf_header_path_list"
+
+       test -n "$verbose" && echo search path $cf_search
+       cf_save2_CPPFLAGS="$CPPFLAGS"
+       for cf_incdir in $cf_search
+       do
+
+if test -n "$cf_incdir" ; then
+  for cf_add_incdir in $cf_incdir
+  do
+       while test $cf_add_incdir != /usr/include
+       do
+         if test -d $cf_add_incdir
+         then
+               cf_have_incdir=no
+               if test -n "$CFLAGS$CPPFLAGS" ; then
+                 # a loop is needed to ensure we can add subdirs of existing dirs
+                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
+                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
+                         cf_have_incdir=yes; break
+                       fi
+                 done
+               fi
+
+               if test "$cf_have_incdir" = no ; then
+                 if test "$cf_add_incdir" = /usr/local/include ; then
+                       if test "$GCC" = yes
+                       then
+                         cf_save_CPPFLAGS=$CPPFLAGS
+                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+                         cat >conftest.$ac_ext <<_ACEOF
+#line 9078 "configure"
+#include "confdefs.h"
+#include <stdio.h>
 int
-main ()
+main (void)
 {
-connect ();
+printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10107: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:9090: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10110: \$? = $ac_status" >&5
+  echo "$as_me:9093: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10113: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:9096: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10116: \$? = $ac_status" >&5
+  echo "$as_me:9099: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_socket_connect=yes
+  :
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_socket_connect=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+cf_have_incdir=yes
 fi
-echo "$as_me:10127: result: $ac_cv_lib_socket_connect" >&5
-echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
-if test $ac_cv_lib_socket_connect = yes; then
-  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
+rm -f conftest.$ac_objext conftest.$ac_ext
+                         CPPFLAGS=$cf_save_CPPFLAGS
+                       fi
+                 fi
+               fi
+
+               if test "$cf_have_incdir" = no ; then
+                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
+
+echo "${as_me:-configure}:9116: testing adding $cf_add_incdir to include-path ..." 1>&5
+
+                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+
+                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+                 test "$cf_top_incdir" = "$cf_add_incdir" && break
+                 cf_add_incdir="$cf_top_incdir"
+               else
+                 break
+               fi
+         else
+               break
+         fi
+       done
+  done
 fi
 
-    fi
+               for cf_header in \
+                       ncurses.h \
+                       curses.h
+               do
 
-    # Guillermo Gomez says -lposix is necessary on A/UX.
-    echo "$as_me:10136: checking for remove" >&5
-echo $ECHO_N "checking for remove... $ECHO_C" >&6
-if test "${ac_cv_func_remove+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 10142 "configure"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 9139 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char remove (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char remove ();
-char (*f) ();
 
+#include <$cf_header>
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_remove) || defined (__stub___remove)
-choke me
+
+#ifdef NCURSES_VERSION
+
+printf("%s\n", NCURSES_VERSION);
 #else
-f = remove; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#ifdef __NCURSES_H
+printf("old\n");
+#else
+       make an error
+#endif
 #endif
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10173: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:9163: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10176: \$? = $ac_status" >&5
+  echo "$as_me:9166: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10179: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:9169: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10182: \$? = $ac_status" >&5
+  echo "$as_me:9172: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_func_remove=yes
+  cf_cv_ncurses_h2=$cf_header
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_func_remove=no
+cf_cv_ncurses_h2=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+                       if test "$cf_cv_ncurses_h2" != no ; then
+                               cf_cv_ncurses_h2=$cf_incdir/$cf_header
+                               test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&6
+                               break
+                       fi
+                       test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&6
+               done
+               CPPFLAGS="$cf_save2_CPPFLAGS"
+               test "$cf_cv_ncurses_h2" != no && break
+       done
+       test "$cf_cv_ncurses_h2" = no && { { echo "$as_me:9193: error: not found" >&5
+echo "$as_me: error: not found" >&2;}
+   { (exit 1); exit 1; }; }
+
 fi
-echo "$as_me:10192: result: $ac_cv_func_remove" >&5
-echo "${ECHO_T}$ac_cv_func_remove" >&6
+echo "$as_me:9198: result: $cf_cv_ncurses_h2" >&5
+echo "${ECHO_T}$cf_cv_ncurses_h2" >&6
 
-    if test $ac_cv_func_remove = no; then
-      echo "$as_me:10196: checking for remove in -lposix" >&5
-echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
-if test "${ac_cv_lib_posix_remove+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lposix  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 10204 "configure"
-#include "confdefs.h"
+       cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'`
+       cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
+       if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
+               cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
+       fi
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char remove ();
+if test -n "$cf_1st_incdir" ; then
+  for cf_add_incdir in $cf_1st_incdir
+  do
+       while test $cf_add_incdir != /usr/include
+       do
+         if test -d $cf_add_incdir
+         then
+               cf_have_incdir=no
+               if test -n "$CFLAGS$CPPFLAGS" ; then
+                 # a loop is needed to ensure we can add subdirs of existing dirs
+                 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
+                       if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
+                         cf_have_incdir=yes; break
+                       fi
+                 done
+               fi
+
+               if test "$cf_have_incdir" = no ; then
+                 if test "$cf_add_incdir" = /usr/local/include ; then
+                       if test "$GCC" = yes
+                       then
+                         cf_save_CPPFLAGS=$CPPFLAGS
+                         CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+                         cat >conftest.$ac_ext <<_ACEOF
+#line 9231 "configure"
+#include "confdefs.h"
+#include <stdio.h>
 int
-main ()
+main (void)
 {
-remove ();
+printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10223: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:9243: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10226: \$? = $ac_status" >&5
+  echo "$as_me:9246: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10229: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:9249: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10232: \$? = $ac_status" >&5
+  echo "$as_me:9252: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_posix_remove=yes
+  :
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_posix_remove=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:10243: result: $ac_cv_lib_posix_remove" >&5
-echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
-if test $ac_cv_lib_posix_remove = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
+cf_have_incdir=yes
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+                         CPPFLAGS=$cf_save_CPPFLAGS
+                       fi
+                 fi
+               fi
 
-    fi
+               if test "$cf_have_incdir" = no ; then
+                 test -n "$verbose" && echo "  adding $cf_add_incdir to include-path" 1>&6
 
-    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
-    echo "$as_me:10252: checking for shmat" >&5
-echo $ECHO_N "checking for shmat... $ECHO_C" >&6
-if test "${ac_cv_func_shmat+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 10258 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char shmat (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char shmat ();
-char (*f) ();
+echo "${as_me:-configure}:9269: testing adding $cf_add_incdir to include-path ..." 1>&5
 
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_shmat) || defined (__stub___shmat)
-choke me
-#else
-f = shmat; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
+                 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10289: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:10292: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10295: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:10298: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_shmat=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_shmat=no
+                 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+                 test "$cf_top_incdir" = "$cf_add_incdir" && break
+                 cf_add_incdir="$cf_top_incdir"
+               else
+                 break
+               fi
+         else
+               break
+         fi
+       done
+  done
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
 fi
-echo "$as_me:10308: result: $ac_cv_func_shmat" >&5
-echo "${ECHO_T}$ac_cv_func_shmat" >&6
 
-    if test $ac_cv_func_shmat = no; then
-      echo "$as_me:10312: checking for shmat in -lipc" >&5
-echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
-if test "${ac_cv_lib_ipc_shmat+set}" = set; then
+# Set definitions to allow ifdef'ing for ncurses.h
+
+case $cf_cv_ncurses_header in
+(*ncurses.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_H 1
+EOF
+
+       ;;
+esac
+
+case $cf_cv_ncurses_header in
+(ncurses/curses.h|ncurses/ncurses.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_NCURSES_H 1
+EOF
+
+       ;;
+(ncursesw/curses.h|ncursesw/ncurses.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_NCURSES_H 1
+EOF
+
+       ;;
+esac
+
+echo "$as_me:9317: checking for terminfo header" >&5
+echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
+if test "${cf_cv_term_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lipc  $LIBS"
+
+case ${cf_cv_ncurses_header} in
+(*/ncurses.h|*/ncursesw.h)
+       cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
+       ;;
+(*)
+       cf_term_header=term.h
+       ;;
+esac
+
+for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
+do
 cat >conftest.$ac_ext <<_ACEOF
-#line 10320 "configure"
+#line 9335 "configure"
 #include "confdefs.h"
+#include <stdio.h>
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <$cf_test>
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char shmat ();
 int
-main ()
+main (void)
 {
-shmat ();
+int x = auto_left_margin
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10339: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:9350: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10342: \$? = $ac_status" >&5
+  echo "$as_me:9353: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10345: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:9356: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10348: \$? = $ac_status" >&5
+  echo "$as_me:9359: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_ipc_shmat=yes
+
+       cf_cv_term_header="$cf_test"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_ipc_shmat=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+
+       cf_cv_term_header=unknown
+
 fi
-echo "$as_me:10359: result: $ac_cv_lib_ipc_shmat" >&5
-echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
-if test $ac_cv_lib_ipc_shmat = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
+rm -f conftest.$ac_objext conftest.$ac_ext
+       test "$cf_cv_term_header" != unknown && break
+done
+
 fi
+echo "$as_me:9375: result: $cf_cv_term_header" >&5
+echo "${ECHO_T}$cf_cv_term_header" >&6
 
-    fi
-  fi
+# Set definitions to allow ifdef'ing to accommodate subdirectories
 
-  # Check for libraries that X11R6 Xt/Xaw programs need.
-  ac_save_LDFLAGS=$LDFLAGS
-  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
-  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
-  # check for ICE first), but we must link in the order -lSM -lICE or
-  # we get undefined symbols.  So assume we have SM if we have ICE.
-  # These have to be linked with before -lX11, unlike the other
-  # libraries we check for below, so use a different variable.
-  # John Interrante, Karl Berry
-  echo "$as_me:10377: checking for IceConnectionNumber in -lICE" >&5
-echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
-if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lICE $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 10385 "configure"
-#include "confdefs.h"
+case $cf_cv_term_header in
+(*term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_TERM_H 1
+EOF
+
+       ;;
+esac
+
+case $cf_cv_term_header in
+(ncurses/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_TERM_H 1
+EOF
+
+       ;;
+(ncursesw/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_TERM_H 1
+EOF
+
+       ;;
+esac
+
+# some applications need this, but should check for NCURSES_VERSION
+
+cat >>confdefs.h <<\EOF
+#define NCURSES 1
+EOF
+
+echo "$as_me:9413: checking for ncurses version" >&5
+echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
+if test "${cf_cv_ncurses_version+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cf_cv_ncurses_version=no
+       cf_tempfile=out$$
+       rm -f $cf_tempfile
+       if test "$cross_compiling" = yes; then
+
+       # This will not work if the preprocessor splits the line after the
+       # Autoconf token.  The 'unproto' program does that.
+       cat > conftest.$ac_ext <<EOF
+#include <${cf_cv_ncurses_header:-curses.h}>
+#undef Autoconf
+#ifdef NCURSES_VERSION
+Autoconf NCURSES_VERSION
+#else
+#ifdef __NCURSES_H
+Autoconf "old"
+#endif
+;
+#endif
+EOF
+       cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
+       { (eval echo "$as_me:9439: \"$cf_try\"") >&5
+  (eval $cf_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9442: \$? = $ac_status" >&5
+  (exit $ac_status); }
+       if test -f conftest.out ; then
+               cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+               test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
+               rm -f conftest.out
+       fi
+
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 9452 "configure"
+#include "confdefs.h"
+
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <stdio.h>
+int main(void)
+{
+       FILE *fp = fopen("$cf_tempfile", "w");
+#ifdef NCURSES_VERSION
+# ifdef NCURSES_VERSION_PATCH
+       fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
+# else
+       fprintf(fp, "%s\n", NCURSES_VERSION);
+# endif
+#else
+# ifdef __NCURSES_H
+       fprintf(fp, "old\n");
+# else
+       make an error
+# endif
+#endif
+       ${cf_cv_main_return:-return}(0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:9477: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9480: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:9482: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9485: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+       cf_cv_ncurses_version=`cat $cf_tempfile`
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+       rm -f $cf_tempfile
+
+fi
+echo "$as_me:9499: result: $cf_cv_ncurses_version" >&5
+echo "${ECHO_T}$cf_cv_ncurses_version" >&6
+test "$cf_cv_ncurses_version" = no ||
+cat >>confdefs.h <<\EOF
+#define NCURSES 1
+EOF
+
+cf_nculib_root=$cf_cv_screen
+       # This works, except for the special case where we find gpm, but
+       # ncurses is in a nonstandard location via $LIBS, and we really want
+       # to link gpm.
+cf_ncurses_LIBS=""
+cf_ncurses_SAVE="$LIBS"
+echo "$as_me:9512: checking for Gpm_Open in -lgpm" >&5
+echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
+if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgpm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 9520 "configure"
+#include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
@@ -10391,227 +9526,159 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char IceConnectionNumber ();
+char Gpm_Open ();
 int
-main ()
+main (void)
 {
-IceConnectionNumber ();
+Gpm_Open ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10404: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9539: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10407: \$? = $ac_status" >&5
+  echo "$as_me:9542: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10410: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9545: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10413: \$? = $ac_status" >&5
+  echo "$as_me:9548: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_ICE_IceConnectionNumber=yes
+  ac_cv_lib_gpm_Gpm_Open=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_ICE_IceConnectionNumber=no
+ac_cv_lib_gpm_Gpm_Open=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:10424: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
-echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
-if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
-  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
-fi
-
-  LDFLAGS=$ac_save_LDFLAGS
-
-fi
-
-cf_x_athena=${cf_x_athena:-Xaw}
-
-echo "$as_me:10436: checking if you want to link with Xaw 3d library" >&5
-echo $ECHO_N "checking if you want to link with Xaw 3d library... $ECHO_C" >&6
-withval=
-
-# Check whether --with-Xaw3d or --without-Xaw3d was given.
-if test "${with_Xaw3d+set}" = set; then
-  withval="$with_Xaw3d"
-
-fi;
-if test "$withval" = yes ; then
-       cf_x_athena=Xaw3d
-       echo "$as_me:10447: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+echo "$as_me:9559: result: $ac_cv_lib_gpm_Gpm_Open" >&5
+echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
+if test $ac_cv_lib_gpm_Gpm_Open = yes; then
+  echo "$as_me:9562: checking for initscr in -lgpm" >&5
+echo $ECHO_N "checking for initscr in -lgpm... $ECHO_C" >&6
+if test "${ac_cv_lib_gpm_initscr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-       echo "$as_me:10450: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-echo "$as_me:10454: checking if you want to link with Xaw 3d xft library" >&5
-echo $ECHO_N "checking if you want to link with Xaw 3d xft library... $ECHO_C" >&6
-withval=
-
-# Check whether --with-Xaw3dxft or --without-Xaw3dxft was given.
-if test "${with_Xaw3dxft+set}" = set; then
-  withval="$with_Xaw3dxft"
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgpm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 9570 "configure"
+#include "confdefs.h"
 
-fi;
-if test "$withval" = yes ; then
-       cf_x_athena=Xaw3dxft
-       echo "$as_me:10465: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char initscr ();
+int
+main (void)
+{
+initscr ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9589: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9592: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9595: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9598: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_gpm_initscr=yes
 else
-       echo "$as_me:10468: result: no" >&5
-echo "${ECHO_T}no" >&6
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_gpm_initscr=no
 fi
-
-echo "$as_me:10472: checking if you want to link with neXT Athena library" >&5
-echo $ECHO_N "checking if you want to link with neXT Athena library... $ECHO_C" >&6
-withval=
-
-# Check whether --with-neXtaw or --without-neXtaw was given.
-if test "${with_neXtaw+set}" = set; then
-  withval="$with_neXtaw"
-
-fi;
-if test "$withval" = yes ; then
-       cf_x_athena=neXtaw
-       echo "$as_me:10483: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:9609: result: $ac_cv_lib_gpm_initscr" >&5
+echo "${ECHO_T}$ac_cv_lib_gpm_initscr" >&6
+if test $ac_cv_lib_gpm_initscr = yes; then
+  LIBS="$cf_ncurses_SAVE"
 else
-       echo "$as_me:10486: result: no" >&5
-echo "${ECHO_T}no" >&6
+  cf_ncurses_LIBS="-lgpm"
 fi
 
-echo "$as_me:10490: checking if you want to link with Athena-Plus library" >&5
-echo $ECHO_N "checking if you want to link with Athena-Plus library... $ECHO_C" >&6
-withval=
-
-# Check whether --with-XawPlus or --without-XawPlus was given.
-if test "${with_XawPlus+set}" = set; then
-  withval="$with_XawPlus"
+fi
 
-fi;
-if test "$withval" = yes ; then
-       cf_x_athena=XawPlus
-       echo "$as_me:10501: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+case $host_os in
+(freebsd*)
+       # This is only necessary if you are linking against an obsolete
+       # version of ncurses (but it should do no harm, since it's static).
+       if test "$cf_nculib_root" = ncurses ; then
+               echo "$as_me:9624: checking for tgoto in -lmytinfo" >&5
+echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
+if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-       echo "$as_me:10504: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmytinfo  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 9632 "configure"
+#include "confdefs.h"
 
-cf_x_athena_lib=""
-
-if test "$PKG_CONFIG" != none ; then
-       cf_athena_list=
-       test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
-       for cf_athena_pkg in \
-               $cf_athena_list \
-               ${cf_x_athena} \
-               ${cf_x_athena}-devel \
-               lib${cf_x_athena} \
-               lib${cf_x_athena}-devel
-       do
-
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $cf_athena_pkg; then
-       test -n "$verbose" && echo "    found package $cf_athena_pkg" 1>&6
-
-echo "${as_me:-configure}:10524: testing found package $cf_athena_pkg ..." 1>&5
-
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags $cf_athena_pkg 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   $cf_athena_pkg 2>/dev/null`"
-       test -n "$verbose" && echo "    package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs" 1>&6
-
-echo "${as_me:-configure}:10530: testing package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs ..." 1>&5
-
-       test -n "$verbose" && echo "    package $cf_athena_pkg LIBS: $cf_pkgconfig_libs" 1>&6
-
-echo "${as_me:-configure}:10534: testing package $cf_athena_pkg LIBS: $cf_pkgconfig_libs ..." 1>&5
-
-cf_fix_cppflags=no
-cf_new_cflags=
-cf_new_cppflags=
-cf_new_extra_cppflags=
-
-for cf_add_cflags in $cf_pkgconfig_incs
-do
-case $cf_fix_cppflags in
-(no)
-       case $cf_add_cflags in
-       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-               case $cf_add_cflags in
-               (-D*)
-                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
-
-                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-                               && test -z "${cf_tst_cflags}" \
-                               && cf_fix_cppflags=yes
-
-                       if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       fi
-                       ;;
-               esac
-               case "$CPPFLAGS" in
-               (*$cf_add_cflags)
-                       ;;
-               (*)
-                       case $cf_add_cflags in
-                       (-D*)
-                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
-
-CPPFLAGS=`echo "$CPPFLAGS" | \
-       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
-
-                               ;;
-                       esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
-                       ;;
-               esac
-               ;;
-       (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
-               ;;
-       esac
-       ;;
-(yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-
-       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
-
-       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-               && test -z "${cf_tst_cflags}" \
-               && cf_fix_cppflags=no
-       ;;
-esac
-done
-
-if test -n "$cf_new_cflags" ; then
-
-       CFLAGS="$CFLAGS $cf_new_cflags"
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char tgoto ();
+int
+main (void)
+{
+tgoto ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9651: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9654: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9657: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9660: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_mytinfo_tgoto=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_mytinfo_tgoto=no
 fi
-
-if test -n "$cf_new_cppflags" ; then
-
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-
-if test -n "$cf_new_extra_cppflags" ; then
-
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+echo "$as_me:9671: result: $ac_cv_lib_mytinfo_tgoto" >&5
+echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
+if test $ac_cv_lib_mytinfo_tgoto = yes; then
+  cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
+       fi
+       ;;
+esac
+
+cf_add_libs="$cf_ncurses_LIBS"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-                       cf_x_athena_lib="$cf_pkgconfig_libs"
-
-cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-                       cat >>confdefs.h <<EOF
-#define $cf_x_athena_LIBS 1
-EOF
+if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
+then
 
-       for cf_trim_lib in Xmu Xt X11
+cf_add_libs="-l$cf_nculib_root"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
        do
-               case "$LIBS" in
-               (*-l$cf_trim_lib\ *-l$cf_trim_lib*)
-                       LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
-                       test -n "$verbose" && echo "    ..trimmed $LIBS" 1>&6
-
-echo "${as_me:-configure}:10645: testing ..trimmed $LIBS ..." 1>&5
-
-                       ;;
-               esac
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
        done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-echo "$as_me:10651: checking for usable $cf_x_athena/Xmu package" >&5
-echo $ECHO_N "checking for usable $cf_x_athena/Xmu package... $ECHO_C" >&6
-if test "${cf_cv_xaw_compat+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 10658 "configure"
+       eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
+       cf_libdir=""
+       echo "$as_me:9720: checking for initscr" >&5
+echo $ECHO_N "checking for initscr... $ECHO_C" >&6
+if test "${ac_cv_func_initscr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 9726 "configure"
 #include "confdefs.h"
-
-#include <X11/Xmu/CharSet.h>
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char initscr (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char initscr ();
+char (*f) ();
 
 int
-main ()
+main (void)
 {
-
-int check = XmuCompareISOLatin1("big", "small")
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_initscr) || defined (__stub___initscr)
+choke me
+#else
+f = initscr; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
 
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10674: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9757: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10677: \$? = $ac_status" >&5
+  echo "$as_me:9760: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10680: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9763: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10683: \$? = $ac_status" >&5
+  echo "$as_me:9766: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_xaw_compat=yes
+  ac_cv_func_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_xaw_compat=no
+ac_cv_func_initscr=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:10693: result: $cf_cv_xaw_compat" >&5
-echo "${ECHO_T}$cf_cv_xaw_compat" >&6
-
-                       if test "$cf_cv_xaw_compat" = no
-                       then
-                               # workaround for broken ".pc" files...
-                               case "$cf_x_athena_lib" in
-                               (*-lXmu*)
-                                       ;;
-                               (*)
-                                       test -n "$verbose" && echo "    work around broken package" 1>&6
-
-echo "${as_me:-configure}:10705: testing work around broken package ..." 1>&5
-
-                                       cf_save_xmu="$LIBS"
-                                       cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^  *//' -e 's/ .*//'`
-
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xmu; then
-       test -n "$verbose" && echo "    found package xmu" 1>&6
+echo "$as_me:9776: result: $ac_cv_func_initscr" >&5
+echo "${ECHO_T}$ac_cv_func_initscr" >&6
+if test $ac_cv_func_initscr = yes; then
+  eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+else
 
-echo "${as_me:-configure}:10713: testing found package xmu ..." 1>&5
+               cf_save_LIBS="$LIBS"
+               echo "$as_me:9783: checking for initscr in -l$cf_nculib_root" >&5
+echo $ECHO_N "checking for initscr in -l$cf_nculib_root... $ECHO_C" >&6
+               LIBS="-l$cf_nculib_root $LIBS"
+               cat >conftest.$ac_ext <<_ACEOF
+#line 9787 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+initscr()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9799: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9802: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9805: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9808: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  echo "$as_me:9810: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+                        eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xmu 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xmu 2>/dev/null`"
-       test -n "$verbose" && echo "    package xmu CFLAGS: $cf_pkgconfig_incs" 1>&6
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "$as_me:9817: result: no" >&5
+echo "${ECHO_T}no" >&6
 
-echo "${as_me:-configure}:10719: testing package xmu CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+cf_search=
+cf_library_path_list=""
+if test -n "${LDFLAGS}${LIBS}" ; then
+       for cf_library_path in $LDFLAGS $LIBS
+       do
+               case $cf_library_path in
+               (-L*)
+                       cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
 
-       test -n "$verbose" && echo "    package xmu LIBS: $cf_pkgconfig_libs" 1>&6
-
-echo "${as_me:-configure}:10723: testing package xmu LIBS: $cf_pkgconfig_libs ..." 1>&5
-
-cf_fix_cppflags=no
-cf_new_cflags=
-cf_new_cppflags=
-cf_new_extra_cppflags=
-
-for cf_add_cflags in $cf_pkgconfig_incs
-do
-case $cf_fix_cppflags in
-(no)
-       case $cf_add_cflags in
-       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-               case $cf_add_cflags in
-               (-D*)
-                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
-
-                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-                               && test -z "${cf_tst_cflags}" \
-                               && cf_fix_cppflags=yes
-
-                       if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       fi
-                       ;;
-               esac
-               case "$CPPFLAGS" in
-               (*$cf_add_cflags)
-                       ;;
-               (*)
-                       case $cf_add_cflags in
-                       (-D*)
-                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
-
-CPPFLAGS=`echo "$CPPFLAGS" | \
-       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+test "x$cf_library_path" != "xNONE" && \
+test -d "$cf_library_path" && \
+ {
+       test -n "$verbose" && echo "    ... testing for lib-directories under $cf_library_path"
+       test -d $cf_library_path/lib &&          cf_search="$cf_search $cf_library_path/lib"
+       test -d $cf_library_path/lib/$cf_nculib_root &&       cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root"
+       test -d $cf_library_path/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root/lib"
+       test -d $cf_library_path/$cf_nculib_root/lib &&       cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib"
+       test -d $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root"
+}
 
-                               ;;
-                       esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       cf_library_path_list="$cf_library_path_list $cf_search"
                        ;;
                esac
-               ;;
-       (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
-               ;;
-       esac
-       ;;
-(yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-
-       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
-
-       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-               && test -z "${cf_tst_cflags}" \
-               && cf_fix_cppflags=no
-       ;;
-esac
-done
-
-if test -n "$cf_new_cflags" ; then
-
-       CFLAGS="$CFLAGS $cf_new_cflags"
-fi
-
-if test -n "$cf_new_cppflags" ; then
-
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       done
 fi
 
-if test -n "$cf_new_extra_cppflags" ; then
+cf_search=
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
-fi
+test "x$prefix" != "xNONE" && \
+test -d "$prefix" && \
+ {
+       test -n "$verbose" && echo "    ... testing for lib-directories under $prefix"
+       test -d $prefix/lib &&          cf_search="$cf_search $prefix/lib"
+       test -d $prefix/lib/$cf_nculib_root &&       cf_search="$cf_search $prefix/lib/$cf_nculib_root"
+       test -d $prefix/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib"
+       test -d $prefix/$cf_nculib_root/lib &&       cf_search="$cf_search $prefix/$cf_nculib_root/lib"
+       test -d $prefix/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root"
+}
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+for cf_subdir_prefix in \
+       /usr \
+       /usr/local \
+       /usr/pkg \
+       /opt \
+       /opt/local \
+       $HOME
 do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
-
-                                                       LIBS="$cf_save_xmu"
 
-test -n "$verbose" && echo "   ...before $LIBS" 1>&6
-
-echo "${as_me:-configure}:10823: testing ...before $LIBS ..." 1>&5
+test "x$cf_subdir_prefix" != "x$prefix" && \
+test -d "$cf_subdir_prefix" && \
+(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+       test -n "$verbose" && echo "    ... testing for lib-directories under $cf_subdir_prefix"
+       test -d $cf_subdir_prefix/lib &&          cf_search="$cf_search $cf_subdir_prefix/lib"
+       test -d $cf_subdir_prefix/lib/$cf_nculib_root &&       cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root"
+       test -d $cf_subdir_prefix/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root/lib"
+       test -d $cf_subdir_prefix/$cf_nculib_root/lib &&       cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib"
+       test -d $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root"
+}
 
-LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s%$cf_first_lib %$cf_first_lib $cf_pkgconfig_libs %" -e 's%  % %g'`
-test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+done
 
-echo "${as_me:-configure}:10828: testing ...after  $LIBS ..." 1>&5
+cf_search="$cf_library_path_list $cf_search"
 
+                       for cf_libdir in $cf_search
+                       do
+                               echo "$as_me:9885: checking for -l$cf_nculib_root in $cf_libdir" >&5
+echo $ECHO_N "checking for -l$cf_nculib_root in $cf_libdir... $ECHO_C" >&6
+                               LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
+                               cat >conftest.$ac_ext <<_ACEOF
+#line 9889 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+initscr()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9901: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9904: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9907: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9910: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  echo "$as_me:9912: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+                                        eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+                                        break
 else
-       cf_pkgconfig_incs=
-       cf_pkgconfig_libs=
-
-test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "$as_me:9919: result: no" >&5
+echo "${ECHO_T}no" >&6
+                                        LIBS="$cf_save_LIBS"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+                       done
 
-echo "${as_me:-configure}:10836: testing ...before $LIBS ..." 1>&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
-LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s%$cf_first_lib %$cf_first_lib -lXmu %" -e 's%  % %g'`
-test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+fi
 
-echo "${as_me:-configure}:10841: testing ...after  $LIBS ..." 1>&5
+eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root
 
+if test $cf_found_library = no ; then
+       { { echo "$as_me:9934: error: Cannot link $cf_nculib_root library" >&5
+echo "$as_me: error: Cannot link $cf_nculib_root library" >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
-       for cf_trim_lib in Xmu Xt X11
-       do
-               case "$LIBS" in
-               (*-l$cf_trim_lib\ *-l$cf_trim_lib*)
-                       LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
-                       test -n "$verbose" && echo "    ..trimmed $LIBS" 1>&6
-
-echo "${as_me:-configure}:10852: testing ..trimmed $LIBS ..." 1>&5
+fi
 
-                       ;;
-               esac
+if test -n "$cf_ncurses_LIBS" ; then
+       echo "$as_me:9942: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
+echo $ECHO_N "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS... $ECHO_C" >&6
+       cf_ncurses_SAVE="$LIBS"
+       for p in $cf_ncurses_LIBS ; do
+               q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
+               if test "$q" != "$LIBS" ; then
+                       LIBS="$q"
+               fi
        done
-
-                                       ;;
-                               esac
-                       fi
-
-                       break
+       cat >conftest.$ac_ext <<_ACEOF
+#line 9952 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9964: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9967: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9970: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9973: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  echo "$as_me:9975: result: yes" >&5
+echo "${ECHO_T}yes" >&6
 else
-       cf_pkgconfig_incs=
-       cf_pkgconfig_libs=
-       :
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "$as_me:9980: result: no" >&5
+echo "${ECHO_T}no" >&6
+                LIBS="$cf_ncurses_SAVE"
 fi
-
-       done
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
 
-if test -z "$cf_x_athena_lib" ; then
-
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists Xext; then
-       test -n "$verbose" && echo "    found package Xext" 1>&6
-
-echo "${as_me:-configure}:10877: testing found package Xext ..." 1>&5
-
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags Xext 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   Xext 2>/dev/null`"
-       test -n "$verbose" && echo "    package Xext CFLAGS: $cf_pkgconfig_incs" 1>&6
+cf_nculib_ROOT=`echo "HAVE_LIB$cf_nculib_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-echo "${as_me:-configure}:10883: testing package Xext CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+cat >>confdefs.h <<EOF
+#define $cf_nculib_ROOT 1
+EOF
 
-       test -n "$verbose" && echo "    package Xext LIBS: $cf_pkgconfig_libs" 1>&6
+       fi
+else
+       NCURSES_CONFIG=none
+fi
 
-echo "${as_me:-configure}:10887: testing package Xext LIBS: $cf_pkgconfig_libs ..." 1>&5
+       ;;
+(pdcurses)
+       echo "$as_me:10000: checking for X" >&5
+echo $ECHO_N "checking for X... $ECHO_C" >&6
 
-cf_fix_cppflags=no
-cf_new_cflags=
-cf_new_cppflags=
-cf_new_extra_cppflags=
+# Check whether --with-x or --without-x was given.
+if test "${with_x+set}" = set; then
+  withval="$with_x"
 
-for cf_add_cflags in $cf_pkgconfig_incs
-do
-case $cf_fix_cppflags in
-(no)
-       case $cf_add_cflags in
-       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-               case $cf_add_cflags in
-               (-D*)
-                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+fi;
+# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
+if test "x$with_x" = xno; then
+  # The user explicitly disabled X.
+  have_x=disabled
+else
+  if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
+    # Both variables are already set.
+    have_x=yes
+  else
+    if test "${ac_cv_have_x+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # One or both of the vars are not set, and there is no cached value.
+ac_x_includes=no ac_x_libraries=no
+rm -fr conftest.dir
+if mkdir conftest.dir; then
+  cd conftest.dir
+  # Make sure to not put "make" in the Imakefile rules, since we grep it out.
+  cat >Imakefile <<'EOF'
+acfindx:
+       @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
+EOF
+  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
+    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+    eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
+    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+    for ac_extension in a so sl dylib dll; do
+      if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
+         test -f $ac_im_libdir/libX11.$ac_extension; then
+        ac_im_usrlibdir=$ac_im_libdir; break
+      fi
+    done
+    # Screen out bogus values from the imake configuration.  They are
+    # bogus both because they are the default anyway, and because
+    # using them would break gcc on systems where it needs fixed includes.
+    case $ac_im_incroot in
+       /usr/include) ;;
+       *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+    esac
+    case $ac_im_usrlibdir in
+       /usr/lib | /lib) ;;
+       *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+    esac
+  fi
+  cd ..
+  rm -fr conftest.dir
+fi
+
+# Standard set of common directories for X headers.
+# Check X11 before X11Rn because it is often a symlink to the current release.
+ac_x_header_dirs='
+/usr/X11/include
+/usr/X11R6/include
+/usr/X11R5/include
+/usr/X11R4/include
+
+/usr/include/X11
+/usr/include/X11R6
+/usr/include/X11R5
+/usr/include/X11R4
+
+/usr/local/X11/include
+/usr/local/X11R6/include
+/usr/local/X11R5/include
+/usr/local/X11R4/include
+
+/usr/local/include/X11
+/usr/local/include/X11R6
+/usr/local/include/X11R5
+/usr/local/include/X11R4
+
+/usr/X386/include
+/usr/x386/include
+/usr/XFree86/include/X11
+
+/usr/include
+/usr/local/include
+/usr/unsupported/include
+/usr/athena/include
+/usr/local/x11r5/include
+/usr/lpp/Xamples/include
+
+/usr/openwin/include
+/usr/openwin/share/include'
+
+if test "$ac_x_includes" = no; then
+  # Guess where to find include files, by looking for Intrinsic.h.
+  # First, try using that file with no special directory specified.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10097 "configure"
+#include "confdefs.h"
+#include <X11/Intrinsic.h>
+_ACEOF
+if { (eval echo "$as_me:10101: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:10107: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # We can compile using X headers with no special include directory.
+ac_x_includes=
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  for ac_dir in $ac_x_header_dirs; do
+  if test -r "$ac_dir/X11/Intrinsic.h"; then
+    ac_x_includes=$ac_dir
+    break
+  fi
+done
+fi
+rm -f conftest.err conftest.$ac_ext
+fi # $ac_x_includes = no
+
+if test "$ac_x_libraries" = no; then
+  # Check for the libraries.
+  # See if we find them without any special options.
+  # Don't add to $LIBS permanently.
+  ac_save_LIBS=$LIBS
+  LIBS="-lXt $LIBS"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10140 "configure"
+#include "confdefs.h"
+#include <X11/Intrinsic.h>
+int
+main (void)
+{
+XtMalloc (0)
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10152: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10155: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10158: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10161: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  LIBS=$ac_save_LIBS
+# We can link X programs with no special library path.
+ac_x_libraries=
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+LIBS=$ac_save_LIBS
+for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+do
+  # Don't even attempt the hair of trying to link an X program!
+  for ac_extension in a so sl dylib dll; do
+    if test -r $ac_dir/libXt.$ac_extension; then
+      ac_x_libraries=$ac_dir
+      break 2
+    fi
+  done
+done
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi # $ac_x_libraries = no
+
+if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
+  # Didn't find X anywhere.  Cache the known absence of X.
+  ac_cv_have_x="have_x=no"
+else
+  # Record where we found X for the cache.
+  ac_cv_have_x="have_x=yes \
+               ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
+fi
+fi
+
+  fi
+  eval "$ac_cv_have_x"
+fi # $with_x != no
+
+if test "$have_x" != yes; then
+  echo "$as_me:10199: result: $have_x" >&5
+echo "${ECHO_T}$have_x" >&6
+  no_x=yes
+else
+  # If each of the values was on the command line, it overrides each guess.
+  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
+  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
+  # Update the cache value to reflect the command line values.
+  ac_cv_have_x="have_x=yes \
+               ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
+  echo "$as_me:10209: result: libraries $x_libraries, headers $x_includes" >&5
+echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
+fi
+
+if test "$no_x" = yes; then
+  # Not all programs may use this symbol, but it does not hurt to define it.
+
+cat >>confdefs.h <<\EOF
+#define X_DISPLAY_MISSING 1
+EOF
+
+  X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
+else
+  if test -n "$x_includes"; then
+    X_CFLAGS="$X_CFLAGS -I$x_includes"
+  fi
+
+  # It would also be nice to do this for all -L options, not just this one.
+  if test -n "$x_libraries"; then
+    X_LIBS="$X_LIBS -L$x_libraries"
+    # For Solaris; some versions of Sun CC require a space after -R and
+    # others require no space.  Words are not sufficient . . . .
+    case `(uname -sr) 2>/dev/null` in
+    "SunOS 5"*)
+      echo "$as_me:10233: checking whether -R must be followed by a space" >&5
+echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6
+      ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
+      cat >conftest.$ac_ext <<_ACEOF
+#line 10237 "configure"
+#include "confdefs.h"
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10249: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10252: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10255: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10258: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_R_nospace=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_R_nospace=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+      if test $ac_R_nospace = yes; then
+       echo "$as_me:10268: result: no" >&5
+echo "${ECHO_T}no" >&6
+       X_LIBS="$X_LIBS -R$x_libraries"
+      else
+       LIBS="$ac_xsave_LIBS -R $x_libraries"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 10274 "configure"
+#include "confdefs.h"
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10286: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10289: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10292: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10295: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_R_space=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_R_space=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       if test $ac_R_space = yes; then
+         echo "$as_me:10305: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+         X_LIBS="$X_LIBS -R $x_libraries"
+       else
+         echo "$as_me:10309: result: neither works" >&5
+echo "${ECHO_T}neither works" >&6
+       fi
+      fi
+      LIBS=$ac_xsave_LIBS
+    esac
+  fi
+
+  # Check for system-dependent libraries X programs must link with.
+  # Do this before checking for the system-independent R6 libraries
+  # (-lICE), since we may need -lsocket or whatever for X linking.
+
+  if test "$ISC" = yes; then
+    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
+  else
+    # Martyn Johnson says this is needed for Ultrix, if the X
+    # libraries were built with DECnet support.  And Karl Berry says
+    # the Alpha needs dnet_stub (dnet does not exist).
+    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
+    cat >conftest.$ac_ext <<_ACEOF
+#line 10329 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+int
+main (void)
+{
+XOpenDisplay ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10348: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10351: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10354: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10357: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "$as_me:10363: checking for dnet_ntoa in -ldnet" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10371 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa ();
+int
+main (void)
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10390: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10393: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10396: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10399: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dnet_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_dnet_dnet_ntoa=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10410: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
+if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
+fi
+
+    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
+      echo "$as_me:10417: checking for dnet_ntoa in -ldnet_stub" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet_stub  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10425 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa ();
+int
+main (void)
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10444: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10447: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10450: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10453: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dnet_stub_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_dnet_stub_dnet_ntoa=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10464: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
+if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
+fi
+
+    fi
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_xsave_LIBS"
+
+    # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
+    # to get the SysV transport functions.
+    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
+    # needs -lnsl.
+    # The nsl library prevents programs from opening the X display
+    # on Irix 5.2, according to T.E. Dickey.
+    # The functions gethostbyname, getservbyname, and inet_addr are
+    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
+    echo "$as_me:10483: checking for gethostbyname" >&5
+echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
+if test "${ac_cv_func_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10489 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char gethostbyname (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+char (*f) ();
+
+int
+main (void)
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
+choke me
+#else
+f = gethostbyname; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10520: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10523: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10526: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10529: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:10539: result: $ac_cv_func_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
+
+    if test $ac_cv_func_gethostbyname = no; then
+      echo "$as_me:10543: checking for gethostbyname in -lnsl" >&5
+echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
+if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnsl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10551 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+int
+main (void)
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10570: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10573: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10576: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10579: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_nsl_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_nsl_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10590: result: $ac_cv_lib_nsl_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
+if test $ac_cv_lib_nsl_gethostbyname = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
+fi
+
+      if test $ac_cv_lib_nsl_gethostbyname = no; then
+        echo "$as_me:10597: checking for gethostbyname in -lbsd" >&5
+echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbsd  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10605 "configure"
+#include "confdefs.h"
 
-                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-                               && test -z "${cf_tst_cflags}" \
-                               && cf_fix_cppflags=yes
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+int
+main (void)
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10624: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10627: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10630: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10633: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_bsd_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_bsd_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10644: result: $ac_cv_lib_bsd_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
+if test $ac_cv_lib_bsd_gethostbyname = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
+fi
 
-                       if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
-                               continue
-                       fi
-                       ;;
-               esac
-               case "$CPPFLAGS" in
-               (*$cf_add_cflags)
-                       ;;
-               (*)
-                       case $cf_add_cflags in
-                       (-D*)
-                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+      fi
+    fi
 
-CPPFLAGS=`echo "$CPPFLAGS" | \
-       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
-               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+    # lieder@skyler.mavd.honeywell.com says without -lsocket,
+    # socket/setsockopt and other routines are undefined under SCO ODT
+    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
+    # on later versions), says Simon Leinen: it contains gethostby*
+    # variants that don't use the nameserver (or something).  -lsocket
+    # must be given before -lnsl if both are needed.  We assume that
+    # if connect needs -lnsl, so does gethostbyname.
+    echo "$as_me:10660: checking for connect" >&5
+echo $ECHO_N "checking for connect... $ECHO_C" >&6
+if test "${ac_cv_func_connect+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10666 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char connect (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char connect ();
+char (*f) ();
 
-                               ;;
-                       esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
-                       ;;
-               esac
-               ;;
-       (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
-               ;;
-       esac
-       ;;
-(yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+int
+main (void)
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_connect) || defined (__stub___connect)
+choke me
+#else
+f = connect; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10697: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10700: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10703: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10706: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_connect=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_connect=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:10716: result: $ac_cv_func_connect" >&5
+echo "${ECHO_T}$ac_cv_func_connect" >&6
+
+    if test $ac_cv_func_connect = no; then
+      echo "$as_me:10720: checking for connect in -lsocket" >&5
+echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
+if test "${ac_cv_lib_socket_connect+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10728 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char connect ();
+int
+main (void)
+{
+connect ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10747: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10750: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10753: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10756: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_socket_connect=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_socket_connect=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10767: result: $ac_cv_lib_socket_connect" >&5
+echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
+if test $ac_cv_lib_socket_connect = yes; then
+  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
+fi
+
+    fi
+
+    # Guillermo Gomez says -lposix is necessary on A/UX.
+    echo "$as_me:10776: checking for remove" >&5
+echo $ECHO_N "checking for remove... $ECHO_C" >&6
+if test "${ac_cv_func_remove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10782 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char remove (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char remove ();
+char (*f) ();
+
+int
+main (void)
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_remove) || defined (__stub___remove)
+choke me
+#else
+f = remove; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10813: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10816: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10819: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10822: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_remove=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_remove=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:10832: result: $ac_cv_func_remove" >&5
+echo "${ECHO_T}$ac_cv_func_remove" >&6
+
+    if test $ac_cv_func_remove = no; then
+      echo "$as_me:10836: checking for remove in -lposix" >&5
+echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
+if test "${ac_cv_lib_posix_remove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lposix  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10844 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char remove ();
+int
+main (void)
+{
+remove ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10863: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10866: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10869: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10872: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_posix_remove=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_posix_remove=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10883: result: $ac_cv_lib_posix_remove" >&5
+echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
+if test $ac_cv_lib_posix_remove = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
+fi
 
-       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+    fi
 
-       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
-               && test -z "${cf_tst_cflags}" \
-               && cf_fix_cppflags=no
-       ;;
-esac
-done
+    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
+    echo "$as_me:10892: checking for shmat" >&5
+echo $ECHO_N "checking for shmat... $ECHO_C" >&6
+if test "${ac_cv_func_shmat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10898 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shmat (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shmat ();
+char (*f) ();
 
-if test -n "$cf_new_cflags" ; then
+int
+main (void)
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_shmat) || defined (__stub___shmat)
+choke me
+#else
+f = shmat; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10929: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10932: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10935: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10938: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_shmat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_shmat=no
 fi
-
-if test -n "$cf_new_cppflags" ; then
-
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
+echo "$as_me:10948: result: $ac_cv_func_shmat" >&5
+echo "${ECHO_T}$ac_cv_func_shmat" >&6
 
-if test -n "$cf_new_extra_cppflags" ; then
+    if test $ac_cv_func_shmat = no; then
+      echo "$as_me:10952: checking for shmat in -lipc" >&5
+echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
+if test "${ac_cv_lib_ipc_shmat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lipc  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10960 "configure"
+#include "confdefs.h"
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shmat ();
+int
+main (void)
+{
+shmat ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10979: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10982: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10985: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10988: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_ipc_shmat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_ipc_shmat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10999: result: $ac_cv_lib_ipc_shmat" >&5
+echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
+if test $ac_cv_lib_ipc_shmat = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
-
-       :
-else
-       cf_pkgconfig_incs=
-       cf_pkgconfig_libs=
+    fi
+  fi
 
-       echo "$as_me:10988: checking for XextCreateExtension in -lXext" >&5
-echo $ECHO_N "checking for XextCreateExtension in -lXext... $ECHO_C" >&6
-if test "${ac_cv_lib_Xext_XextCreateExtension+set}" = set; then
+  # Check for libraries that X11R6 Xt/Xaw programs need.
+  ac_save_LDFLAGS=$LDFLAGS
+  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
+  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
+  # check for ICE first), but we must link in the order -lSM -lICE or
+  # we get undefined symbols.  So assume we have SM if we have ICE.
+  # These have to be linked with before -lX11, unlike the other
+  # libraries we check for below, so use a different variable.
+  # John Interrante, Karl Berry
+  echo "$as_me:11017: checking for IceConnectionNumber in -lICE" >&5
+echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
+if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXext  $LIBS"
+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 10996 "configure"
+#line 11025 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -11002,83 +11031,147 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XextCreateExtension ();
+char IceConnectionNumber ();
 int
-main ()
+main (void)
 {
-XextCreateExtension ();
+IceConnectionNumber ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:11015: \"$ac_link\"") >&5
+if { (eval echo "$as_me:11044: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11018: \$? = $ac_status" >&5
+  echo "$as_me:11047: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:11021: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11050: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11024: \$? = $ac_status" >&5
+  echo "$as_me:11053: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_Xext_XextCreateExtension=yes
+  ac_cv_lib_ICE_IceConnectionNumber=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_Xext_XextCreateExtension=no
+ac_cv_lib_ICE_IceConnectionNumber=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:11035: result: $ac_cv_lib_Xext_XextCreateExtension" >&5
-echo "${ECHO_T}$ac_cv_lib_Xext_XextCreateExtension" >&6
-if test $ac_cv_lib_Xext_XextCreateExtension = yes; then
+echo "$as_me:11064: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
+echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
+if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
+  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
+fi
 
-cf_add_libs="-lXext"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
+  LDFLAGS=$ac_save_LDFLAGS
+
+fi
+
+cf_x_athena=${cf_x_athena:-Xaw}
 
+echo "$as_me:11076: checking if you want to link with Xaw 3d library" >&5
+echo $ECHO_N "checking if you want to link with Xaw 3d library... $ECHO_C" >&6
+withval=
+
+# Check whether --with-Xaw3d or --without-Xaw3d was given.
+if test "${with_Xaw3d+set}" = set; then
+  withval="$with_Xaw3d"
+
+fi;
+if test "$withval" = yes ; then
+       cf_x_athena=Xaw3d
+       echo "$as_me:11087: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+       echo "$as_me:11090: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
+echo "$as_me:11094: checking if you want to link with Xaw 3d xft library" >&5
+echo $ECHO_N "checking if you want to link with Xaw 3d xft library... $ECHO_C" >&6
+withval=
+
+# Check whether --with-Xaw3dxft or --without-Xaw3dxft was given.
+if test "${with_Xaw3dxft+set}" = set; then
+  withval="$with_Xaw3dxft"
+
+fi;
+if test "$withval" = yes ; then
+       cf_x_athena=Xaw3dxft
+       echo "$as_me:11105: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+       echo "$as_me:11108: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
-# in some cases has installed dummy files in the former, other cases replaced
-# it with a link to the new location).  This complicates the configure script.
-# Check for that pitfall, and recover using pkg-config
-#
-# If none of these are set, the configuration is almost certainly broken.
-if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
-then
+echo "$as_me:11112: checking if you want to link with neXT Athena library" >&5
+echo $ECHO_N "checking if you want to link with neXT Athena library... $ECHO_C" >&6
+withval=
+
+# Check whether --with-neXtaw or --without-neXtaw was given.
+if test "${with_neXtaw+set}" = set; then
+  withval="$with_neXtaw"
+
+fi;
+if test "$withval" = yes ; then
+       cf_x_athena=neXtaw
+       echo "$as_me:11123: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+       echo "$as_me:11126: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+echo "$as_me:11130: checking if you want to link with Athena-Plus library" >&5
+echo $ECHO_N "checking if you want to link with Athena-Plus library... $ECHO_C" >&6
+withval=
+
+# Check whether --with-XawPlus or --without-XawPlus was given.
+if test "${with_XawPlus+set}" = set; then
+  withval="$with_XawPlus"
+
+fi;
+if test "$withval" = yes ; then
+       cf_x_athena=XawPlus
+       echo "$as_me:11141: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+       echo "$as_me:11144: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+cf_x_athena_lib=""
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
-       test -n "$verbose" && echo "    found package x11" 1>&6
+if test "$PKG_CONFIG" != none ; then
+       cf_athena_list=
+       test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
+       for cf_athena_pkg in \
+               $cf_athena_list \
+               ${cf_x_athena} \
+               ${cf_x_athena}-devel \
+               lib${cf_x_athena} \
+               lib${cf_x_athena}-devel
+       do
 
-echo "${as_me:-configure}:11071: testing found package x11 ..." 1>&5
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $cf_athena_pkg; then
+       test -n "$verbose" && echo "    found package $cf_athena_pkg" 1>&6
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
-       test -n "$verbose" && echo "    package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6
+echo "${as_me:-configure}:11164: testing found package $cf_athena_pkg ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags $cf_athena_pkg 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   $cf_athena_pkg 2>/dev/null`"
+       test -n "$verbose" && echo "    package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11077: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:11170: testing package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
-       test -n "$verbose" && echo "    package x11 LIBS: $cf_pkgconfig_libs" 1>&6
+       test -n "$verbose" && echo "    package $cf_athena_pkg LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11081: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:11174: testing package $cf_athena_pkg LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11100,10 +11193,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -11122,17 +11221,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -11145,17 +11252,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 cf_add_libs="$cf_pkgconfig_libs"
 done
 LIBS="$cf_add_libs"
 
-       :
+                       cf_x_athena_lib="$cf_pkgconfig_libs"
+
+cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+                       cat >>confdefs.h <<EOF
+#define $cf_x_athena_LIBS 1
+EOF
+
+       for cf_trim_lib in Xmu Xt X11
+       do
+               case "$LIBS" in
+               (*-l$cf_trim_lib\ *-l$cf_trim_lib*)
+                       LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
+                       test -n "$verbose" && echo "    ..trimmed $LIBS" 1>&6
+
+echo "${as_me:-configure}:11305: testing ..trimmed $LIBS ..." 1>&5
+
+                       ;;
+               esac
+       done
+
+echo "$as_me:11311: checking for usable $cf_x_athena/Xmu package" >&5
+echo $ECHO_N "checking for usable $cf_x_athena/Xmu package... $ECHO_C" >&6
+if test "${cf_cv_xaw_compat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-       cf_pkgconfig_incs=
-       cf_pkgconfig_libs=
-       { echo "$as_me:11181: WARNING: unable to find X11 library" >&5
-echo "$as_me: WARNING: unable to find X11 library" >&2;}
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 11318 "configure"
+#include "confdefs.h"
+
+#include <X11/Xmu/CharSet.h>
+
+int
+main (void)
+{
+
+int check = XmuCompareISOLatin1("big", "small")
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:11334: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:11337: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:11340: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11343: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xaw_compat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xaw_compat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
+echo "$as_me:11353: result: $cf_cv_xaw_compat" >&5
+echo "${ECHO_T}$cf_cv_xaw_compat" >&6
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
-       test -n "$verbose" && echo "    found package ice" 1>&6
+                       if test "$cf_cv_xaw_compat" = no
+                       then
+                               # workaround for broken ".pc" files...
+                               case "$cf_x_athena_lib" in
+                               (*-lXmu*)
+                                       ;;
+                               (*)
+                                       test -n "$verbose" && echo "    work around broken package" 1>&6
 
-echo "${as_me:-configure}:11188: testing found package ice ..." 1>&5
+echo "${as_me:-configure}:11365: testing work around broken package ..." 1>&5
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
-       test -n "$verbose" && echo "    package ice CFLAGS: $cf_pkgconfig_incs" 1>&6
+                                       cf_save_xmu="$LIBS"
+                                       cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^  *//' -e 's/ .*//'`
 
-echo "${as_me:-configure}:11194: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xmu; then
+       test -n "$verbose" && echo "    found package xmu" 1>&6
 
-       test -n "$verbose" && echo "    package ice LIBS: $cf_pkgconfig_libs" 1>&6
+echo "${as_me:-configure}:11373: testing found package xmu ..." 1>&5
 
-echo "${as_me:-configure}:11198: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xmu 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xmu 2>/dev/null`"
+       test -n "$verbose" && echo "    package xmu CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:11379: testing package xmu CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package xmu LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:11383: testing package xmu LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11217,10 +11402,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -11239,17 +11430,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -11262,17 +11461,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 cf_add_libs="$cf_pkgconfig_libs"
 done
 LIBS="$cf_add_libs"
 
-       :
+                                                       LIBS="$cf_save_xmu"
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:11503: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s%$cf_first_lib %$cf_first_lib $cf_pkgconfig_libs %" -e 's%  % %g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:11508: testing ...after  $LIBS ..." 1>&5
+
 else
        cf_pkgconfig_incs=
        cf_pkgconfig_libs=
-       { echo "$as_me:11298: WARNING: unable to find ICE library" >&5
-echo "$as_me: WARNING: unable to find ICE library" >&2;}
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:11516: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s%$cf_first_lib %$cf_first_lib -lXmu %" -e 's%  % %g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:11521: testing ...after  $LIBS ..." 1>&5
+
 fi
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
-       test -n "$verbose" && echo "    found package sm" 1>&6
+       for cf_trim_lib in Xmu Xt X11
+       do
+               case "$LIBS" in
+               (*-l$cf_trim_lib\ *-l$cf_trim_lib*)
+                       LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
+                       test -n "$verbose" && echo "    ..trimmed $LIBS" 1>&6
 
-echo "${as_me:-configure}:11305: testing found package sm ..." 1>&5
+echo "${as_me:-configure}:11532: testing ..trimmed $LIBS ..." 1>&5
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
-       test -n "$verbose" && echo "    package sm CFLAGS: $cf_pkgconfig_incs" 1>&6
+                       ;;
+               esac
+       done
 
-echo "${as_me:-configure}:11311: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+                                       ;;
+                               esac
+                       fi
 
-       test -n "$verbose" && echo "    package sm LIBS: $cf_pkgconfig_libs" 1>&6
+                       break
+else
+       cf_pkgconfig_incs=
+       cf_pkgconfig_libs=
+       :
+fi
+
+       done
+fi
+
+if test -z "$cf_x_athena_lib" ; then
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists Xext; then
+       test -n "$verbose" && echo "    found package Xext" 1>&6
+
+echo "${as_me:-configure}:11557: testing found package Xext ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags Xext 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   Xext 2>/dev/null`"
+       test -n "$verbose" && echo "    package Xext CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:11563: testing package Xext CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
-echo "${as_me:-configure}:11315: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
+       test -n "$verbose" && echo "    package Xext LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:11567: testing package Xext LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11334,10 +11586,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -11356,17 +11614,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -11379,20 +11645,98 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+cf_add_libs="$cf_pkgconfig_libs"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
+
+       :
+else
+       cf_pkgconfig_incs=
+       cf_pkgconfig_libs=
+
+       echo "$as_me:11688: checking for XextCreateExtension in -lXext" >&5
+echo $ECHO_N "checking for XextCreateExtension in -lXext... $ECHO_C" >&6
+if test "${ac_cv_lib_Xext_XextCreateExtension+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXext  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 11696 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XextCreateExtension ();
+int
+main (void)
+{
+XextCreateExtension ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:11715: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:11718: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:11721: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11724: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_Xext_XextCreateExtension=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_Xext_XextCreateExtension=no
 fi
-
-if test -n "$cf_new_extra_cppflags" ; then
-
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
+echo "$as_me:11735: result: $ac_cv_lib_Xext_XextCreateExtension" >&5
+echo "${ECHO_T}$ac_cv_lib_Xext_XextCreateExtension" >&6
+if test $ac_cv_lib_Xext_XextCreateExtension = yes; then
 
-cf_add_libs="$cf_pkgconfig_libs"
+cf_add_libs="-lXext"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-       :
-else
-       cf_pkgconfig_incs=
-       cf_pkgconfig_libs=
-       { echo "$as_me:11415: WARNING: unable to find SM library" >&5
-echo "$as_me: WARNING: unable to find SM library" >&2;}
 fi
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
-       test -n "$verbose" && echo "    found package xt" 1>&6
+fi
+
+# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
+# in some cases has installed dummy files in the former, other cases replaced
+# it with a link to the new location).  This complicates the configure script.
+# Check for that pitfall, and recover using pkg-config
+#
+# If none of these are set, the configuration is almost certainly broken.
+if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
+then
 
-echo "${as_me:-configure}:11422: testing found package xt ..." 1>&5
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
+       test -n "$verbose" && echo "    found package x11" 1>&6
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
-       test -n "$verbose" && echo "    package xt CFLAGS: $cf_pkgconfig_incs" 1>&6
+echo "${as_me:-configure}:11771: testing found package x11 ..." 1>&5
 
-echo "${as_me:-configure}:11428: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
+       test -n "$verbose" && echo "    package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-       test -n "$verbose" && echo "    package xt LIBS: $cf_pkgconfig_libs" 1>&6
+echo "${as_me:-configure}:11777: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
-echo "${as_me:-configure}:11432: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
+       test -n "$verbose" && echo "    package x11 LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:11781: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11451,10 +11800,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -11473,17 +11828,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -11496,17 +11859,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 cf_add_libs="$cf_pkgconfig_libs"
@@ -11529,28 +11898,24 @@ LIBS="$cf_add_libs"
 else
        cf_pkgconfig_incs=
        cf_pkgconfig_libs=
-       { echo "$as_me:11532: WARNING: unable to find Xt library" >&5
-echo "$as_me: WARNING: unable to find Xt library" >&2;}
-fi
-
+       { echo "$as_me:11901: WARNING: unable to find X11 library" >&5
+echo "$as_me: WARNING: unable to find X11 library" >&2;}
 fi
 
-cf_have_X_LIBS=no
-
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
-       test -n "$verbose" && echo "    found package xt" 1>&6
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
+       test -n "$verbose" && echo "    found package ice" 1>&6
 
-echo "${as_me:-configure}:11543: testing found package xt ..." 1>&5
+echo "${as_me:-configure}:11908: testing found package ice ..." 1>&5
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
-       test -n "$verbose" && echo "    package xt CFLAGS: $cf_pkgconfig_incs" 1>&6
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
+       test -n "$verbose" && echo "    package ice CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11549: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:11914: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
-       test -n "$verbose" && echo "    package xt LIBS: $cf_pkgconfig_libs" 1>&6
+       test -n "$verbose" && echo "    package ice LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11553: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:11918: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11572,10 +11937,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -11594,17 +11965,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -11617,17 +11996,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 cf_add_libs="$cf_pkgconfig_libs"
 done
 LIBS="$cf_add_libs"
 
-       case "x$LIBS" in
-       (*-lX11*)
-               ;;
-       (*)
-# we have an "xt" package, but it may omit Xt's dependency on X11
-echo "$as_me:11654: checking for usable X dependency" >&5
-echo $ECHO_N "checking for usable X dependency... $ECHO_C" >&6
-if test "${cf_cv_xt_x11_compat+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-cat >conftest.$ac_ext <<_ACEOF
-#line 11661 "configure"
-#include "confdefs.h"
-
-#include <X11/Xlib.h>
-
-int
-main ()
-{
-
-       int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
-       int rc2 = XClearWindow((Display*) 0, (Window) 0);
-       int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
-       int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:11680: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:11683: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:11686: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:11689: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_xt_x11_compat=yes
+       :
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_xt_x11_compat=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       cf_pkgconfig_incs=
+       cf_pkgconfig_libs=
+       { echo "$as_me:12038: WARNING: unable to find ICE library" >&5
+echo "$as_me: WARNING: unable to find ICE library" >&2;}
 fi
-echo "$as_me:11699: result: $cf_cv_xt_x11_compat" >&5
-echo "${ECHO_T}$cf_cv_xt_x11_compat" >&6
-               if test "$cf_cv_xt_x11_compat" = no
-               then
-                       test -n "$verbose" && echo "    work around broken X11 dependency" 1>&6
-
-echo "${as_me:-configure}:11705: testing work around broken X11 dependency ..." 1>&5
-
-                       # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
-       test -n "$verbose" && echo "    found package x11" 1>&6
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
+       test -n "$verbose" && echo "    found package sm" 1>&6
 
-echo "${as_me:-configure}:11712: testing found package x11 ..." 1>&5
+echo "${as_me:-configure}:12045: testing found package sm ..." 1>&5
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
-       test -n "$verbose" && echo "    package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
+       test -n "$verbose" && echo "    package sm CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11718: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:12051: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
-       test -n "$verbose" && echo "    package x11 LIBS: $cf_pkgconfig_libs" 1>&6
+       test -n "$verbose" && echo "    package sm LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11722: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:12055: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11741,10 +12074,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -11763,17 +12102,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -11786,17 +12133,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 cf_add_libs="$cf_pkgconfig_libs"
@@ -11819,93 +12172,24 @@ LIBS="$cf_add_libs"
 else
        cf_pkgconfig_incs=
        cf_pkgconfig_libs=
-
-test -n "$verbose" && echo "   ...before $LIBS" 1>&6
-
-echo "${as_me:-configure}:11825: testing ...before $LIBS ..." 1>&5
-
-LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s%-lXt %-lXt -lX11 %" -e 's%  % %g'`
-test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
-
-echo "${as_me:-configure}:11830: testing ...after  $LIBS ..." 1>&5
-
-fi
-
-               fi
-               ;;
-       esac
-
-echo "$as_me:11838: checking for usable X Toolkit package" >&5
-echo $ECHO_N "checking for usable X Toolkit package... $ECHO_C" >&6
-if test "${cf_cv_xt_ice_compat+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-cat >conftest.$ac_ext <<_ACEOF
-#line 11845 "configure"
-#include "confdefs.h"
-
-#include <X11/Shell.h>
-
-int
-main ()
-{
-int num = IceConnectionNumber(0)
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:11860: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:11863: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:11866: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:11869: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_xt_ice_compat=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_xt_ice_compat=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       { echo "$as_me:12175: WARNING: unable to find SM library" >&5
+echo "$as_me: WARNING: unable to find SM library" >&2;}
 fi
-echo "$as_me:11879: result: $cf_cv_xt_ice_compat" >&5
-echo "${ECHO_T}$cf_cv_xt_ice_compat" >&6
-
-       if test "$cf_cv_xt_ice_compat" = no
-       then
-               # workaround for broken ".pc" files used for X Toolkit.
-               case "x$X_PRE_LIBS" in
-               (*-lICE*)
-                       case "x$LIBS" in
-                       (*-lICE*)
-                               ;;
-                       (*)
-                               test -n "$verbose" && echo "    work around broken ICE dependency" 1>&6
 
-echo "${as_me:-configure}:11893: testing work around broken ICE dependency ..." 1>&5
-
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
-       test -n "$verbose" && echo "    found package ice" 1>&6
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
+       test -n "$verbose" && echo "    found package xt" 1>&6
 
-echo "${as_me:-configure}:11898: testing found package ice ..." 1>&5
+echo "${as_me:-configure}:12182: testing found package xt ..." 1>&5
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
-       test -n "$verbose" && echo "    package ice CFLAGS: $cf_pkgconfig_incs" 1>&6
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
+       test -n "$verbose" && echo "    package xt CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11904: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:12188: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
-       test -n "$verbose" && echo "    package ice LIBS: $cf_pkgconfig_libs" 1>&6
+       test -n "$verbose" && echo "    package xt LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11908: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:12192: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11927,10 +12211,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -11949,17 +12239,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -11972,17 +12270,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 cf_add_libs="$cf_pkgconfig_libs"
 done
 LIBS="$cf_add_libs"
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
-       test -n "$verbose" && echo "    found package sm" 1>&6
+       :
+else
+       cf_pkgconfig_incs=
+       cf_pkgconfig_libs=
+       { echo "$as_me:12312: WARNING: unable to find Xt library" >&5
+echo "$as_me: WARNING: unable to find Xt library" >&2;}
+fi
+
+fi
 
-echo "${as_me:-configure}:12007: testing found package sm ..." 1>&5
+cf_have_X_LIBS=no
 
-       cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
-       cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
-       test -n "$verbose" && echo "    package sm CFLAGS: $cf_pkgconfig_incs" 1>&6
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
+       test -n "$verbose" && echo "    found package xt" 1>&6
 
-echo "${as_me:-configure}:12013: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:12323: testing found package xt ..." 1>&5
 
-       test -n "$verbose" && echo "    package sm LIBS: $cf_pkgconfig_libs" 1>&6
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
+       test -n "$verbose" && echo "    package xt CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:12329: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package xt LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:12017: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:12333: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -12036,10 +12352,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -12058,17 +12380,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -12081,17 +12411,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 cf_add_libs="$cf_pkgconfig_libs"
 done
 LIBS="$cf_add_libs"
 
-       :
-else
-       cf_pkgconfig_incs=
-       cf_pkgconfig_libs=
-       :
-fi
-
+       case "x$LIBS" in
+       (*-lX11*)
+               ;;
+       (*)
+# we have an "xt" package, but it may omit Xt's dependency on X11
+echo "$as_me:12454: checking for usable X dependency" >&5
+echo $ECHO_N "checking for usable X dependency... $ECHO_C" >&6
+if test "${cf_cv_xt_x11_compat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-       cf_pkgconfig_incs=
-       cf_pkgconfig_libs=
 
-test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 12461 "configure"
+#include "confdefs.h"
 
-echo "${as_me:-configure}:12126: testing ...before $LIBS ..." 1>&5
+#include <X11/Xlib.h>
 
-LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s%-lXt %-lXt $X_PRE_LIBS %" -e 's%  % %g'`
-test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+int
+main (void)
+{
 
-echo "${as_me:-configure}:12131: testing ...after  $LIBS ..." 1>&5
+       int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
+       int rc2 = XClearWindow((Display*) 0, (Window) 0);
+       int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
+       int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
 
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:12480: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:12483: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:12486: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:12489: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xt_x11_compat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xt_x11_compat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
+echo "$as_me:12499: result: $cf_cv_xt_x11_compat" >&5
+echo "${ECHO_T}$cf_cv_xt_x11_compat" >&6
+               if test "$cf_cv_xt_x11_compat" = no
+               then
+                       test -n "$verbose" && echo "    work around broken X11 dependency" 1>&6
 
-                               ;;
-                       esac
-                       ;;
-               esac
-       fi
+echo "${as_me:-configure}:12505: testing work around broken X11 dependency ..." 1>&5
 
-       cf_have_X_LIBS=yes
+                       # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
 
-else
-       cf_pkgconfig_incs=
-       cf_pkgconfig_libs=
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
+       test -n "$verbose" && echo "    found package x11" 1>&6
 
-       LDFLAGS="$X_LIBS $LDFLAGS"
+echo "${as_me:-configure}:12512: testing found package x11 ..." 1>&5
 
-test -n "$verbose" && echo "   checking additions to CFLAGS" 1>&6
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
+       test -n "$verbose" && echo "    package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:12151: testing checking additions to CFLAGS ..." 1>&5
+echo "${as_me:-configure}:12518: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
-cf_check_cflags="$CFLAGS"
-cf_check_cppflags="$CPPFLAGS"
+       test -n "$verbose" && echo "    package x11 LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:12522: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $X_CFLAGS
+for cf_add_cflags in $cf_pkgconfig_incs
 do
 case $cf_fix_cppflags in
 (no)
@@ -12173,10 +12541,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -12195,17 +12569,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -12216,188 +12598,28 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 esac
 done
 
-if test -n "$cf_new_cflags" ; then
-       test -n "$verbose" && echo "    add to \$CFLAGS $cf_new_cflags" 1>&6
-
-echo "${as_me:-configure}:12222: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
-
-       CFLAGS="$CFLAGS $cf_new_cflags"
-fi
-
-if test -n "$cf_new_cppflags" ; then
-       test -n "$verbose" && echo "    add to \$CPPFLAGS $cf_new_cppflags" 1>&6
-
-echo "${as_me:-configure}:12230: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
-
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
-fi
-
-if test -n "$cf_new_extra_cppflags" ; then
-       test -n "$verbose" && echo "    add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
-
-echo "${as_me:-configure}:12238: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
-
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
-fi
-
-if test "x$cf_check_cflags" != "x$CFLAGS" ; then
-cat >conftest.$ac_ext <<_ACEOF
-#line 12245 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-int
-main ()
-{
-printf("Hello world");
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12257: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:12260: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12263: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:12266: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-test -n "$verbose" && echo "   test-compile failed.  Undoing change to \$CFLAGS" 1>&6
-
-echo "${as_me:-configure}:12274: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
-
-        if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
-                test -n "$verbose" && echo "   but keeping change to \$CPPFLAGS" 1>&6
-
-echo "${as_me:-configure}:12279: testing but keeping change to \$CPPFLAGS ..." 1>&5
-
-        fi
-        CFLAGS="$cf_check_flags"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-
-       echo "$as_me:12287: checking for XOpenDisplay" >&5
-echo $ECHO_N "checking for XOpenDisplay... $ECHO_C" >&6
-if test "${ac_cv_func_XOpenDisplay+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 12293 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char XOpenDisplay (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
-char (*f) ();
-
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay)
-choke me
-#else
-f = XOpenDisplay; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12324: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:12327: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12330: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:12333: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_XOpenDisplay=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_XOpenDisplay=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:12343: result: $ac_cv_func_XOpenDisplay" >&5
-echo "${ECHO_T}$ac_cv_func_XOpenDisplay" >&6
-if test $ac_cv_func_XOpenDisplay = yes; then
-  :
-else
-
-       echo "$as_me:12349: checking for XOpenDisplay in -lX11" >&5
-echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
-if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 12357 "configure"
-#include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
-int
-main ()
-{
-XOpenDisplay ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12376: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:12379: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12382: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:12385: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_X11_XOpenDisplay=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_X11_XOpenDisplay=no
+if test -n "$cf_new_cflags" ; then
+
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+
+if test -n "$cf_new_cppflags" ; then
+
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
-echo "$as_me:12396: result: $ac_cv_lib_X11_XOpenDisplay" >&5
-echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
-if test $ac_cv_lib_X11_XOpenDisplay = yes; then
 
-cf_add_libs="-lX11"
+if test -n "$cf_new_extra_cppflags" ; then
+
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+cf_add_libs="$cf_pkgconfig_libs"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-fi
+       :
+else
+       cf_pkgconfig_incs=
+       cf_pkgconfig_libs=
 
-fi
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
 
-       echo "$as_me:12420: checking for XtAppInitialize" >&5
-echo $ECHO_N "checking for XtAppInitialize... $ECHO_C" >&6
-if test "${ac_cv_func_XtAppInitialize+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 12426 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char XtAppInitialize (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char XtAppInitialize ();
-char (*f) ();
+echo "${as_me:-configure}:12645: testing ...before $LIBS ..." 1>&5
 
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize)
-choke me
-#else
-f = XtAppInitialize; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s%-lXt %-lXt -lX11 %" -e 's%  % %g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:12650: testing ...after  $LIBS ..." 1>&5
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12457: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:12460: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12463: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:12466: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_XtAppInitialize=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_XtAppInitialize=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:12476: result: $ac_cv_func_XtAppInitialize" >&5
-echo "${ECHO_T}$ac_cv_func_XtAppInitialize" >&6
-if test $ac_cv_func_XtAppInitialize = yes; then
-  :
-else
 
-       echo "$as_me:12482: checking for XtAppInitialize in -lXt" >&5
-echo $ECHO_N "checking for XtAppInitialize in -lXt... $ECHO_C" >&6
-if test "${ac_cv_lib_Xt_XtAppInitialize+set}" = set; then
+               fi
+               ;;
+       esac
+
+echo "$as_me:12658: checking for usable X Toolkit package" >&5
+echo $ECHO_N "checking for usable X Toolkit package... $ECHO_C" >&6
+if test "${cf_cv_xt_ice_compat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
+
 cat >conftest.$ac_ext <<_ACEOF
-#line 12490 "configure"
+#line 12665 "configure"
 #include "confdefs.h"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char XtAppInitialize ();
+#include <X11/Shell.h>
+
 int
-main ()
+main (void)
 {
-XtAppInitialize ();
+int num = IceConnectionNumber(0)
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12509: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12680: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12512: \$? = $ac_status" >&5
+  echo "$as_me:12683: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12515: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12686: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12518: \$? = $ac_status" >&5
+  echo "$as_me:12689: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_Xt_XtAppInitialize=yes
+  cf_cv_xt_ice_compat=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_Xt_XtAppInitialize=no
+cf_cv_xt_ice_compat=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:12529: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
-echo "${ECHO_T}$ac_cv_lib_Xt_XtAppInitialize" >&6
-if test $ac_cv_lib_Xt_XtAppInitialize = yes; then
+echo "$as_me:12699: result: $cf_cv_xt_ice_compat" >&5
+echo "${ECHO_T}$cf_cv_xt_ice_compat" >&6
 
-cat >>confdefs.h <<\EOF
-#define HAVE_LIBXT 1
-EOF
+       if test "$cf_cv_xt_ice_compat" = no
+       then
+               # workaround for broken ".pc" files used for X Toolkit.
+               case "x$X_PRE_LIBS" in
+               (*-lICE*)
+                       case "x$LIBS" in
+                       (*-lICE*)
+                               ;;
+                       (*)
+                               test -n "$verbose" && echo "    work around broken ICE dependency" 1>&6
 
-                cf_have_X_LIBS=Xt
-                LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
-fi
+echo "${as_me:-configure}:12713: testing work around broken ICE dependency ..." 1>&5
 
-fi
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
+       test -n "$verbose" && echo "    found package ice" 1>&6
 
-fi
+echo "${as_me:-configure}:12718: testing found package ice ..." 1>&5
 
-if test $cf_have_X_LIBS = no ; then
-       { echo "$as_me:12546: WARNING: Unable to successfully link X Toolkit library (-lXt) with
-test program.  You will have to check and add the proper libraries by hand
-to makefile." >&5
-echo "$as_me: WARNING: Unable to successfully link X Toolkit library (-lXt) with
-test program.  You will have to check and add the proper libraries by hand
-to makefile." >&2;}
-fi
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
+       test -n "$verbose" && echo "    package ice CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-cf_x_athena_root=$cf_x_athena
-cf_x_athena_inc=""
+echo "${as_me:-configure}:12724: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
-for cf_path in default \
-       /usr/contrib/X11R6 \
-       /usr/contrib/X11R5 \
-       /usr/lib/X11R5 \
-       /usr/local
+       test -n "$verbose" && echo "    package ice LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:12728: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
 do
-       if test -z "$cf_x_athena_inc" ; then
-               cf_save="$CPPFLAGS"
-               cf_test=X11/$cf_x_athena_root/SimpleMenu.h
-               if test $cf_path != default ; then
-                       CPPFLAGS="$cf_save -I$cf_path/include"
-                       echo "$as_me:12568: checking for $cf_test in $cf_path" >&5
-echo $ECHO_N "checking for $cf_test in $cf_path... $ECHO_C" >&6
-               else
-                       echo "$as_me:12571: checking for $cf_test" >&5
-echo $ECHO_N "checking for $cf_test... $ECHO_C" >&6
-               fi
-               cat >conftest.$ac_ext <<_ACEOF
-#line 12575 "configure"
-#include "confdefs.h"
+case $cf_fix_cppflags in
+(no)
+       case $cf_add_cflags in
+       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+               case $cf_add_cflags in
+               (-D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
-#include <X11/Intrinsic.h>
-#include <$cf_test>
-int
-main ()
-{
+                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:12589: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:12592: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:12595: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:12598: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-               echo "$as_me:12607: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-               if test "$cf_result" = yes ; then
-                       cf_x_athena_inc=$cf_path
-                       break
-               else
-                       CPPFLAGS="$cf_save"
-               fi
-       fi
+                       if test $cf_fix_cppflags = yes ; then
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               (*$cf_add_cflags)
+                       ;;
+               (*)
+                       case $cf_add_cflags in
+                       (-D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+                       ;;
+               esac
+               ;;
+       (*)
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+               ;;
+       esac
+       ;;
+(yes)
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
 done
 
-if test -z "$cf_x_athena_inc" ; then
-       { echo "$as_me:12619: WARNING: Unable to successfully find Athena header files with test program" >&5
-echo "$as_me: WARNING: Unable to successfully find Athena header files with test program" >&2;}
-elif test "$cf_x_athena_inc" != default ; then
-       CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
+if test -n "$cf_new_cflags" ; then
+
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
-cf_x_athena_root=$cf_x_athena
-cf_x_athena_lib=""
+if test -n "$cf_new_cppflags" ; then
 
-for cf_path in default \
-       /usr/contrib/X11R6 \
-       /usr/contrib/X11R5 \
-       /usr/lib/X11R5 \
-       /usr/local
-do
-       for cf_lib in \
-               ${cf_x_athena_root} \
-               ${cf_x_athena_root}7 \
-               ${cf_x_athena_root}6
-       do
-       for cf_libs in \
-               "-l$cf_lib -lXmu" \
-               "-l$cf_lib -lXpm -lXmu" \
-               "-l${cf_lib}_s -lXmu_s"
-       do
-               if test -z "$cf_x_athena_lib" ; then
-                       cf_save="$LIBS"
-                       cf_test=XawSimpleMenuAddGlobalActions
-                       if test $cf_path != default ; then
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
 
-cf_add_libs="-L$cf_path/lib $cf_libs"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+cf_add_libs="$cf_pkgconfig_libs"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-                               echo "$as_me:12665: checking for $cf_libs in $cf_path" >&5
-echo $ECHO_N "checking for $cf_libs in $cf_path... $ECHO_C" >&6
-                       else
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
+       test -n "$verbose" && echo "    found package sm" 1>&6
 
-cf_add_libs="$cf_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+echo "${as_me:-configure}:12847: testing found package sm ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
+       test -n "$verbose" && echo "    package sm CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:12853: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package sm LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:12857: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
 do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
+case $cf_fix_cppflags in
+(no)
+       case $cf_add_cflags in
+       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+               case $cf_add_cflags in
+               (-D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
-                               echo "$as_me:12685: checking for $cf_test in $cf_libs" >&5
-echo $ECHO_N "checking for $cf_test in $cf_libs... $ECHO_C" >&6
-                       fi
-                       cat >conftest.$ac_ext <<_ACEOF
-#line 12689 "configure"
-#include "confdefs.h"
+                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
 
-#include <X11/Intrinsic.h>
-#include <X11/$cf_x_athena_root/SimpleMenu.h>
+                       if test $cf_fix_cppflags = yes ; then
 
-int
-main ()
-{
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
-$cf_test((XtAppContext) 0)
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12705: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:12708: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12711: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:12714: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-                       echo "$as_me:12723: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-                       if test "$cf_result" = yes ; then
-                               cf_x_athena_lib="$cf_libs"
-                               break
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+                               continue
                        fi
-                       LIBS="$cf_save"
-               fi
-       done # cf_libs
-               test -n "$cf_x_athena_lib" && break
-       done # cf_lib
-done
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               (*$cf_add_cflags)
+                       ;;
+               (*)
+                       case $cf_add_cflags in
+                       (-D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
-if test -z "$cf_x_athena_lib" ; then
-       { { echo "$as_me:12737: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&5
-echo "$as_me: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&2;}
-   { (exit 1); exit 1; }; }
-fi
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
 
-cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+                               ;;
+                       esac
 
-cat >>confdefs.h <<EOF
-#define $cf_x_athena_LIBS 1
-EOF
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
 
-fi
+                       ;;
+               esac
+               ;;
+       (*)
 
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in xcurses-config
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:12755: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_XCURSES_CONFIG+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$XCURSES_CONFIG"; then
-  ac_cv_prog_XCURSES_CONFIG="$XCURSES_CONFIG" # Let the user override the test.
-else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_XCURSES_CONFIG="$ac_tool_prefix$ac_prog"
-echo "$as_me:12770: found $ac_dir/$ac_word" >&5
-break
-done
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
 
-fi
-fi
-XCURSES_CONFIG=$ac_cv_prog_XCURSES_CONFIG
-if test -n "$XCURSES_CONFIG"; then
-  echo "$as_me:12778: result: $XCURSES_CONFIG" >&5
-echo "${ECHO_T}$XCURSES_CONFIG" >&6
-else
-  echo "$as_me:12781: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
+               ;;
+       esac
+       ;;
+(yes)
 
-    test -n "$XCURSES_CONFIG" && break
-  done
-fi
-if test -z "$XCURSES_CONFIG"; then
-  ac_ct_XCURSES_CONFIG=$XCURSES_CONFIG
-  for ac_prog in xcurses-config
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:12794: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_XCURSES_CONFIG+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_XCURSES_CONFIG"; then
-  ac_cv_prog_ac_ct_XCURSES_CONFIG="$ac_ct_XCURSES_CONFIG" # Let the user override the test.
-else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_XCURSES_CONFIG="$ac_prog"
-echo "$as_me:12809: found $ac_dir/$ac_word" >&5
-break
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
 done
 
-fi
-fi
-ac_ct_XCURSES_CONFIG=$ac_cv_prog_ac_ct_XCURSES_CONFIG
-if test -n "$ac_ct_XCURSES_CONFIG"; then
-  echo "$as_me:12817: result: $ac_ct_XCURSES_CONFIG" >&5
-echo "${ECHO_T}$ac_ct_XCURSES_CONFIG" >&6
-else
-  echo "$as_me:12820: result: no" >&5
-echo "${ECHO_T}no" >&6
+if test -n "$cf_new_cflags" ; then
+
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
-  test -n "$ac_ct_XCURSES_CONFIG" && break
-done
-test -n "$ac_ct_XCURSES_CONFIG" || ac_ct_XCURSES_CONFIG="none"
+if test -n "$cf_new_cppflags" ; then
+
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
 
-  XCURSES_CONFIG=$ac_ct_XCURSES_CONFIG
 fi
 
-if test "$XCURSES_CONFIG" != none ; then
+if test -n "$cf_new_extra_cppflags" ; then
 
-CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
-cf_add_libs="`$XCURSES_CONFIG --libs`"
+fi
+
+cf_add_libs="$cf_pkgconfig_libs"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-cf_cv_lib_XCurses=yes
+       :
+else
+       cf_pkgconfig_incs=
+       cf_pkgconfig_libs=
+       :
+fi
+
+else
+       cf_pkgconfig_incs=
+       cf_pkgconfig_libs=
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:12986: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s%-lXt %-lXt $X_PRE_LIBS %" -e 's%  % %g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:12991: testing ...after  $LIBS ..." 1>&5
+
+fi
+
+                               ;;
+                       esac
+                       ;;
+               esac
+       fi
+
+       cf_have_X_LIBS=yes
 
 else
+       cf_pkgconfig_incs=
+       cf_pkgconfig_libs=
 
-LDFLAGS="$LDFLAGS $X_LIBS"
+       LDFLAGS="$X_LIBS $LDFLAGS"
 
 test -n "$verbose" && echo "   checking additions to CFLAGS" 1>&6
 
-echo "${as_me:-configure}:12859: testing checking additions to CFLAGS ..." 1>&5
+echo "${as_me:-configure}:13011: testing checking additions to CFLAGS ..." 1>&5
 
 cf_check_cflags="$CFLAGS"
 cf_check_cppflags="$CPPFLAGS"
@@ -12881,10 +13033,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -12903,17 +13061,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -12927,34 +13093,40 @@ done
 if test -n "$cf_new_cflags" ; then
        test -n "$verbose" && echo "    add to \$CFLAGS $cf_new_cflags" 1>&6
 
-echo "${as_me:-configure}:12930: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+echo "${as_me:-configure}:13096: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
 fi
 
 if test -n "$cf_new_cppflags" ; then
        test -n "$verbose" && echo "    add to \$CPPFLAGS $cf_new_cppflags" 1>&6
 
-echo "${as_me:-configure}:12938: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+echo "${as_me:-configure}:13106: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
        test -n "$verbose" && echo "    add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
 
-echo "${as_me:-configure}:12946: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+echo "${as_me:-configure}:13116: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
 fi
 
 if test "x$cf_check_cflags" != "x$CFLAGS" ; then
 cat >conftest.$ac_ext <<_ACEOF
-#line 12953 "configure"
+#line 13125 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello world");
   ;
@@ -12962,16 +13134,16 @@ printf("Hello world");
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12965: \"$ac_link\"") >&5
+if { (eval echo "$as_me:13137: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12968: \$? = $ac_status" >&5
+  echo "$as_me:13140: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12971: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13143: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12974: \$? = $ac_status" >&5
+  echo "$as_me:13146: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -12979,12 +13151,12 @@ else
 cat conftest.$ac_ext >&5
 test -n "$verbose" && echo "   test-compile failed.  Undoing change to \$CFLAGS" 1>&6
 
-echo "${as_me:-configure}:12982: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
+echo "${as_me:-configure}:13154: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
 
         if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
                 test -n "$verbose" && echo "   but keeping change to \$CPPFLAGS" 1>&6
 
-echo "${as_me:-configure}:12987: testing but keeping change to \$CPPFLAGS ..." 1>&5
+echo "${as_me:-configure}:13159: testing but keeping change to \$CPPFLAGS ..." 1>&5
 
         fi
         CFLAGS="$cf_check_flags"
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
 
-echo "$as_me:12995: checking for XOpenDisplay in -lX11" >&5
-echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
-if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 13003 "configure"
+       echo "$as_me:13167: checking for XOpenDisplay" >&5
+echo $ECHO_N "checking for XOpenDisplay... $ECHO_C" >&6
+if test "${ac_cv_func_XOpenDisplay+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 13173 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char XOpenDisplay (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+char (*f) ();
+
+int
+main (void)
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay)
+choke me
+#else
+f = XOpenDisplay; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13204: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13207: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13210: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13213: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_XOpenDisplay=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_XOpenDisplay=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:13223: result: $ac_cv_func_XOpenDisplay" >&5
+echo "${ECHO_T}$ac_cv_func_XOpenDisplay" >&6
+if test $ac_cv_func_XOpenDisplay = yes; then
+  :
+else
+
+       echo "$as_me:13229: checking for XOpenDisplay in -lX11" >&5
+echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
+if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 13237 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+int
+main (void)
+{
+XOpenDisplay ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13256: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13259: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13262: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13265: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_X11_XOpenDisplay=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_X11_XOpenDisplay=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:13276: result: $ac_cv_lib_X11_XOpenDisplay" >&5
+echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
+if test $ac_cv_lib_X11_XOpenDisplay = yes; then
+
+cf_add_libs="-lX11"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
+
+fi
+
+fi
+
+       echo "$as_me:13300: checking for XtAppInitialize" >&5
+echo $ECHO_N "checking for XtAppInitialize... $ECHO_C" >&6
+if test "${ac_cv_func_XtAppInitialize+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 13306 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char XtAppInitialize (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XtAppInitialize ();
+char (*f) ();
+
+int
+main (void)
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize)
+choke me
+#else
+f = XtAppInitialize; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13337: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13340: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13343: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13346: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_XtAppInitialize=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_XtAppInitialize=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:13356: result: $ac_cv_func_XtAppInitialize" >&5
+echo "${ECHO_T}$ac_cv_func_XtAppInitialize" >&6
+if test $ac_cv_func_XtAppInitialize = yes; then
+  :
+else
+
+       echo "$as_me:13362: checking for XtAppInitialize in -lXt" >&5
+echo $ECHO_N "checking for XtAppInitialize in -lXt... $ECHO_C" >&6
+if test "${ac_cv_lib_Xt_XtAppInitialize+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 13370 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XtAppInitialize ();
+int
+main (void)
+{
+XtAppInitialize ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13389: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13392: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13395: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13398: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_Xt_XtAppInitialize=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_Xt_XtAppInitialize=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:13409: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
+echo "${ECHO_T}$ac_cv_lib_Xt_XtAppInitialize" >&6
+if test $ac_cv_lib_Xt_XtAppInitialize = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_LIBXT 1
+EOF
+
+                cf_have_X_LIBS=Xt
+                LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
+fi
+
+fi
+
+fi
+
+if test $cf_have_X_LIBS = no ; then
+       { echo "$as_me:13426: WARNING: Unable to successfully link X Toolkit library (-lXt) with
+test program.  You will have to check and add the proper libraries by hand
+to makefile." >&5
+echo "$as_me: WARNING: Unable to successfully link X Toolkit library (-lXt) with
+test program.  You will have to check and add the proper libraries by hand
+to makefile." >&2;}
+fi
+
+cf_x_athena_root=$cf_x_athena
+cf_x_athena_inc=""
+
+for cf_path in default \
+       /usr/contrib/X11R6 \
+       /usr/contrib/X11R5 \
+       /usr/lib/X11R5 \
+       /usr/local
+do
+       if test -z "$cf_x_athena_inc" ; then
+               cf_save="$CPPFLAGS"
+               cf_test=X11/$cf_x_athena_root/SimpleMenu.h
+               if test $cf_path != default ; then
+                       CPPFLAGS="$cf_save -I$cf_path/include"
+                       echo "$as_me:13448: checking for $cf_test in $cf_path" >&5
+echo $ECHO_N "checking for $cf_test in $cf_path... $ECHO_C" >&6
+               else
+                       echo "$as_me:13451: checking for $cf_test" >&5
+echo $ECHO_N "checking for $cf_test... $ECHO_C" >&6
+               fi
+               cat >conftest.$ac_ext <<_ACEOF
+#line 13455 "configure"
 #include "confdefs.h"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
+#include <X11/Intrinsic.h>
+#include <$cf_test>
 int
-main ()
+main (void)
 {
-XOpenDisplay ();
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13022: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:13469: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13025: \$? = $ac_status" >&5
+  echo "$as_me:13472: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13028: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:13475: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13031: \$? = $ac_status" >&5
+  echo "$as_me:13478: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_X11_XOpenDisplay=yes
+  cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_X11_XOpenDisplay=no
+cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+rm -f conftest.$ac_objext conftest.$ac_ext
+               echo "$as_me:13487: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+               if test "$cf_result" = yes ; then
+                       cf_x_athena_inc=$cf_path
+                       break
+               else
+                       CPPFLAGS="$cf_save"
+               fi
+       fi
+done
+
+if test -z "$cf_x_athena_inc" ; then
+       { echo "$as_me:13499: WARNING: Unable to successfully find Athena header files with test program" >&5
+echo "$as_me: WARNING: Unable to successfully find Athena header files with test program" >&2;}
+elif test "$cf_x_athena_inc" != default ; then
+       CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
 fi
-echo "$as_me:13042: result: $ac_cv_lib_X11_XOpenDisplay" >&5
-echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
-if test $ac_cv_lib_X11_XOpenDisplay = yes; then
 
-cf_add_libs="-lX11"
+cf_x_athena_root=$cf_x_athena
+cf_x_athena_lib=""
+
+for cf_path in default \
+       /usr/contrib/X11R6 \
+       /usr/contrib/X11R5 \
+       /usr/lib/X11R5 \
+       /usr/local
+do
+       for cf_lib in \
+               ${cf_x_athena_root} \
+               ${cf_x_athena_root}7 \
+               ${cf_x_athena_root}6
+       do
+       for cf_libs in \
+               "-l$cf_lib -lXmu" \
+               "-l$cf_lib -lXpm -lXmu" \
+               "-l${cf_lib}_s -lXmu_s"
+       do
+               if test -z "$cf_x_athena_lib" ; then
+                       cf_save="$LIBS"
+                       cf_test=XawSimpleMenuAddGlobalActions
+                       if test $cf_path != default ; then
+
+cf_add_libs="-L$cf_path/lib $cf_libs"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-fi
-
-echo "$as_me:13064: checking for XCurses library" >&5
-echo $ECHO_N "checking for XCurses library... $ECHO_C" >&6
-if test "${cf_cv_lib_XCurses+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+                               echo "$as_me:13545: checking for $cf_libs in $cf_path" >&5
+echo $ECHO_N "checking for $cf_libs in $cf_path... $ECHO_C" >&6
+                       else
 
-cf_add_libs="-lXCurses"
+cf_add_libs="$cf_libs"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 13087 "configure"
+                               echo "$as_me:13565: checking for $cf_test in $cf_libs" >&5
+echo $ECHO_N "checking for $cf_test in $cf_libs... $ECHO_C" >&6
+                       fi
+                       cat >conftest.$ac_ext <<_ACEOF
+#line 13569 "configure"
 #include "confdefs.h"
 
-#include <xcurses.h>
-char *XCursesProgramName = "test";
+#include <X11/Intrinsic.h>
+#include <X11/$cf_x_athena_root/SimpleMenu.h>
 
 int
-main ()
+main (void)
 {
-XCursesExit();
+
+$cf_test((XtAppContext) 0)
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13102: \"$ac_link\"") >&5
+if { (eval echo "$as_me:13585: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13105: \$? = $ac_status" >&5
+  echo "$as_me:13588: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13108: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13591: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13111: \$? = $ac_status" >&5
+  echo "$as_me:13594: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_lib_XCurses=yes
+  cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_lib_XCurses=no
+cf_result=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+                       echo "$as_me:13603: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+                       if test "$cf_result" = yes ; then
+                               cf_x_athena_lib="$cf_libs"
+                               break
+                       fi
+                       LIBS="$cf_save"
+               fi
+       done # cf_libs
+               test -n "$cf_x_athena_lib" && break
+       done # cf_lib
+done
 
-fi
-echo "$as_me:13122: result: $cf_cv_lib_XCurses" >&5
-echo "${ECHO_T}$cf_cv_lib_XCurses" >&6
-
+if test -z "$cf_x_athena_lib" ; then
+       { { echo "$as_me:13617: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&5
+echo "$as_me: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
-if test $cf_cv_lib_XCurses = yes ; then
+cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-cat >>confdefs.h <<\EOF
-#define UNIX 1
+cat >>confdefs.h <<EOF
+#define $cf_x_athena_LIBS 1
 EOF
 
-cat >>confdefs.h <<\EOF
-#define XCURSES 1
-EOF
+fi
 
-       echo "$as_me:13137: checking for xcurses.h" >&5
-echo $ECHO_N "checking for xcurses.h... $ECHO_C" >&6
-if test "${ac_cv_header_xcurses_h+set}" = set; then
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in xcurses-config
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:13635: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_XCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13143 "configure"
-#include "confdefs.h"
-#include <xcurses.h>
-_ACEOF
-if { (eval echo "$as_me:13147: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:13153: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_cv_header_xcurses_h=yes
+  if test -n "$XCURSES_CONFIG"; then
+  ac_cv_prog_XCURSES_CONFIG="$XCURSES_CONFIG" # Let the user override the test.
 else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_cv_header_xcurses_h=no
-fi
-rm -f conftest.err conftest.$ac_ext
-fi
-echo "$as_me:13172: result: $ac_cv_header_xcurses_h" >&5
-echo "${ECHO_T}$ac_cv_header_xcurses_h" >&6
-if test $ac_cv_header_xcurses_h = yes; then
-
-cat >>confdefs.h <<\EOF
-#define HAVE_XCURSES 1
-EOF
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_XCURSES_CONFIG="$ac_tool_prefix$ac_prog"
+echo "$as_me:13650: found $ac_dir/$ac_word" >&5
+break
+done
 
 fi
-
-else
-       { { echo "$as_me:13183: error: Cannot link with XCurses" >&5
-echo "$as_me: error: Cannot link with XCurses" >&2;}
-   { (exit 1); exit 1; }; }
 fi
-
-       ;;
-(*)
-       { { echo "$as_me:13190: error: unexpected screen-value: $cf_cv_screen" >&5
-echo "$as_me: error: unexpected screen-value: $cf_cv_screen" >&2;}
-   { (exit 1); exit 1; }; }
-       ;;
-esac
-
-: ${cf_nculib_root:=$cf_cv_screen}
-as_ac_Lib=`echo "ac_cv_lib_$cf_nculib_root''__nc_init_pthreads" | $as_tr_sh`
-echo "$as_me:13198: checking for _nc_init_pthreads in -l$cf_nculib_root" >&5
-echo $ECHO_N "checking for _nc_init_pthreads in -l$cf_nculib_root... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+XCURSES_CONFIG=$ac_cv_prog_XCURSES_CONFIG
+if test -n "$XCURSES_CONFIG"; then
+  echo "$as_me:13658: result: $XCURSES_CONFIG" >&5
+echo "${ECHO_T}$XCURSES_CONFIG" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$cf_nculib_root  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 13206 "configure"
-#include "confdefs.h"
+  echo "$as_me:13661: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char _nc_init_pthreads ();
-int
-main ()
-{
-_nc_init_pthreads ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13225: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:13228: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13231: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13234: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
+    test -n "$XCURSES_CONFIG" && break
+  done
+fi
+if test -z "$XCURSES_CONFIG"; then
+  ac_ct_XCURSES_CONFIG=$XCURSES_CONFIG
+  for ac_prog in xcurses-config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:13674: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_XCURSES_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
+  if test -n "$ac_ct_XCURSES_CONFIG"; then
+  ac_cv_prog_ac_ct_XCURSES_CONFIG="$ac_ct_XCURSES_CONFIG" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_XCURSES_CONFIG="$ac_prog"
+echo "$as_me:13689: found $ac_dir/$ac_word" >&5
+break
+done
+
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:13245: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  cf_cv_ncurses_pthreads=yes
+ac_ct_XCURSES_CONFIG=$ac_cv_prog_ac_ct_XCURSES_CONFIG
+if test -n "$ac_ct_XCURSES_CONFIG"; then
+  echo "$as_me:13697: result: $ac_ct_XCURSES_CONFIG" >&5
+echo "${ECHO_T}$ac_ct_XCURSES_CONFIG" >&6
 else
-  cf_cv_ncurses_pthreads=no
+  echo "$as_me:13700: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-if test "$cf_cv_ncurses_pthreads" = yes
-then
+  test -n "$ac_ct_XCURSES_CONFIG" && break
+done
+test -n "$ac_ct_XCURSES_CONFIG" || ac_ct_XCURSES_CONFIG="none"
 
-cf_add_libs="-lpthread"
+  XCURSES_CONFIG=$ac_ct_XCURSES_CONFIG
+fi
+
+if test "$XCURSES_CONFIG" != none ; then
+
+CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
+
+cf_add_libs="`$XCURSES_CONFIG --libs`"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-fi
-
-case $cf_cv_screen in
-(ncurses*)
-       cf_cv_libtype=`echo "$cf_cv_screen" | sed -e 's/^ncurses//'`
-       ;;
-(curses|curses_*)
+cf_cv_lib_XCurses=yes
 
-echo "$as_me:13280: checking for NetBSD form.h" >&5
-echo $ECHO_N "checking for NetBSD form.h... $ECHO_C" >&6
-if test "${cf_cv_netbsd_form_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 13287 "configure"
-#include "confdefs.h"
+LDFLAGS="$LDFLAGS $X_LIBS"
 
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <form.h>
+test -n "$verbose" && echo "   checking additions to CFLAGS" 1>&6
 
-int
-main ()
-{
+echo "${as_me:-configure}:13739: testing checking additions to CFLAGS ..." 1>&5
 
-       FORM *form;
-       int y = current_field(form)->cursor_ypos;
-       int x = current_field(form)->cursor_xpos;
+cf_check_cflags="$CFLAGS"
+cf_check_cppflags="$CPPFLAGS"
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:13306: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:13309: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:13312: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13315: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_netbsd_form_h=yes
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
 
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_netbsd_form_h=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+for cf_add_cflags in $X_CFLAGS
+do
+case $cf_fix_cppflags in
+(no)
+       case $cf_add_cflags in
+       (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+               case $cf_add_cflags in
+               (-D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
-fi
-echo "$as_me:13327: result: $cf_cv_netbsd_form_h" >&5
-echo "${ECHO_T}$cf_cv_netbsd_form_h" >&6
+                       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
 
-test "$cf_cv_netbsd_form_h" = yes &&
-cat >>confdefs.h <<\EOF
-#define HAVE_NETBSD_FORM_H 1
-EOF
+                       if test $cf_fix_cppflags = yes ; then
 
-echo "$as_me:13335: checking for NetBSD menu.h" >&5
-echo $ECHO_N "checking for NetBSD menu.h... $ECHO_C" >&6
-if test "${cf_cv_netbsd_menu_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 13342 "configure"
-#include "confdefs.h"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
 
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <menu.h>
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
-int
-main ()
-{
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               (*$cf_add_cflags)
+                       ;;
+               (*)
+                       case $cf_add_cflags in
+                       (-D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
-       MENU *menu;
-       int y = menu->max_item_width;
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:13360: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:13363: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:13366: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13369: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_netbsd_menu_h=yes
+                               ;;
+                       esac
 
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_netbsd_menu_h=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
 
-fi
-echo "$as_me:13381: result: $cf_cv_netbsd_menu_h" >&5
-echo "${ECHO_T}$cf_cv_netbsd_menu_h" >&6
+                       ;;
+               esac
+               ;;
+       (*)
 
-test "$cf_cv_netbsd_menu_h" = yes &&
-cat >>confdefs.h <<\EOF
-#define HAVE_NETBSD_MENU_H 1
-EOF
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
 
+               ;;
+       esac
        ;;
-esac
+(yes)
 
-case $cf_cv_screen in
-(pdcurses)
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
        ;;
-(*)
-       # look for curses-related libraries
+esac
+done
 
-as_ac_Lib=`echo "ac_cv_lib_panel$cf_cv_libtype''_new_panel" | $as_tr_sh`
-echo "$as_me:13399: checking for new_panel in -lpanel$cf_cv_libtype" >&5
-echo $ECHO_N "checking for new_panel in -lpanel$cf_cv_libtype... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpanel$cf_cv_libtype  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 13407 "configure"
-#include "confdefs.h"
+if test -n "$cf_new_cflags" ; then
+       test -n "$verbose" && echo "    add to \$CFLAGS $cf_new_cflags" 1>&6
+
+echo "${as_me:-configure}:13824: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char new_panel ();
-int
-main ()
-{
-new_panel ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13426: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:13429: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13432: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13435: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+
+if test -n "$cf_new_cppflags" ; then
+       test -n "$verbose" && echo "    add to \$CPPFLAGS $cf_new_cppflags" 1>&6
+
+echo "${as_me:-configure}:13834: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
-echo "$as_me:13446: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
 
-cf_upper=`echo "have_libpanel" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+if test -n "$cf_new_extra_cppflags" ; then
+       test -n "$verbose" && echo "    add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
 
-cf_add_libs="-lpanel$cf_cv_libtype"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
+echo "${as_me:-configure}:13844: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
 
-cat >>confdefs.h <<EOF
-#define $cf_upper 1
-EOF
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
 fi
 
-as_ac_Lib=`echo "ac_cv_lib_menu$cf_cv_libtype''_menu_driver" | $as_tr_sh`
-echo "$as_me:13475: checking for menu_driver in -lmenu$cf_cv_libtype" >&5
-echo $ECHO_N "checking for menu_driver in -lmenu$cf_cv_libtype... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmenu$cf_cv_libtype  $LIBS"
+if test "x$cf_check_cflags" != "x$CFLAGS" ; then
 cat >conftest.$ac_ext <<_ACEOF
-#line 13483 "configure"
+#line 13853 "configure"
 #include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char menu_driver ();
+#include <stdio.h>
 int
-main ()
+main (void)
 {
-menu_driver ();
+printf("Hello world");
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13502: \"$ac_link\"") >&5
+if { (eval echo "$as_me:13865: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13505: \$? = $ac_status" >&5
+  echo "$as_me:13868: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13508: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13871: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13511: \$? = $ac_status" >&5
+  echo "$as_me:13874: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
+  :
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:13522: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+test -n "$verbose" && echo "   test-compile failed.  Undoing change to \$CFLAGS" 1>&6
 
-cf_upper=`echo "have_libmenu" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+echo "${as_me:-configure}:13882: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
 
-cf_add_libs="-lmenu$cf_cv_libtype"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
+        if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
+                test -n "$verbose" && echo "   but keeping change to \$CPPFLAGS" 1>&6
 
-cat >>confdefs.h <<EOF
-#define $cf_upper 1
-EOF
+echo "${as_me:-configure}:13887: testing but keeping change to \$CPPFLAGS ..." 1>&5
 
+        fi
+        CFLAGS="$cf_check_flags"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
 
-as_ac_Lib=`echo "ac_cv_lib_form$cf_cv_libtype''_form_driver" | $as_tr_sh`
-echo "$as_me:13551: checking for form_driver in -lform$cf_cv_libtype" >&5
-echo $ECHO_N "checking for form_driver in -lform$cf_cv_libtype... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+echo "$as_me:13895: checking for XOpenDisplay in -lX11" >&5
+echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
+if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lform$cf_cv_libtype  $LIBS"
+LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 13559 "configure"
+#line 13903 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -13565,43 +13909,41 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char form_driver ();
+char XOpenDisplay ();
 int
-main ()
+main (void)
 {
-form_driver ();
+XOpenDisplay ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13578: \"$ac_link\"") >&5
+if { (eval echo "$as_me:13922: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13581: \$? = $ac_status" >&5
+  echo "$as_me:13925: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13584: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13928: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13587: \$? = $ac_status" >&5
+  echo "$as_me:13931: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
+  ac_cv_lib_X11_XOpenDisplay=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
+ac_cv_lib_X11_XOpenDisplay=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:13598: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-
-cf_upper=`echo "have_libform" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+echo "$as_me:13942: result: $ac_cv_lib_X11_XOpenDisplay" >&5
+echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
+if test $ac_cv_lib_X11_XOpenDisplay = yes; then
 
-cf_add_libs="-lform$cf_cv_libtype"
+cf_add_libs="-lX11"
 # Filter out duplicates - this happens with badly-designed ".pc" files...
 for cf_add_1lib in $LIBS
 do
 done
 LIBS="$cf_add_libs"
 
-cat >>confdefs.h <<EOF
-#define $cf_upper 1
-EOF
-
-fi
-
-       # look for curses-related headers
-
-for ac_header in \
-               nc_alloc.h \
-               nomacros.h \
-               form.h \
-               menu.h \
-               panel.h \
-               term_entry.h \
-
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:13638: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13644 "configure"
-#include "confdefs.h"
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:13648: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:13654: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  eval "$as_ac_Header=yes"
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_ext
-fi
-echo "$as_me:13673: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-EOF
-
 fi
-done
-
-       ;;
-esac
 
-echo "$as_me:13686: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
+echo "$as_me:13964: checking for XCurses library" >&5
+echo $ECHO_N "checking for XCurses library... $ECHO_C" >&6
+if test "${cf_cv_lib_XCurses+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13692 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-_ACEOF
-if { (eval echo "$as_me:13700: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:13706: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_cv_header_stdc=yes
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13728 "configure"
-#include "confdefs.h"
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "memchr" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -rf conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13746 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "free" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -rf conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
-  :
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13767 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
-                     || ('j' <= (c) && (c) <= 'r') \
-                     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-        || toupper (i) != TOUPPER (i))
-      $ac_main_return(2);
-  $ac_main_return (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:13793: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:13796: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:13798: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13801: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_header_stdc=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:13814: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
 
-fi
+cf_add_libs="-lXCurses"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-echo "$as_me:13824: checking whether time.h and sys/time.h may both be included" >&5
-echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
-if test "${ac_cv_header_time+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13830 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 13987 "configure"
 #include "confdefs.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
+
+#include <xcurses.h>
+char *XCursesProgramName = "test";
 
 int
-main ()
+main (void)
 {
-if ((struct tm *) 0)
-return 0;
+XCursesExit();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:13846: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14002: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13849: \$? = $ac_status" >&5
+  echo "$as_me:14005: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:13852: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14008: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13855: \$? = $ac_status" >&5
+  echo "$as_me:14011: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_header_time=yes
+  cf_cv_lib_XCurses=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_header_time=no
+cf_cv_lib_XCurses=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:14022: result: $cf_cv_lib_XCurses" >&5
+echo "${ECHO_T}$cf_cv_lib_XCurses" >&6
+
 fi
-echo "$as_me:13865: result: $ac_cv_header_time" >&5
-echo "${ECHO_T}$ac_cv_header_time" >&6
-if test $ac_cv_header_time = yes; then
+
+if test $cf_cv_lib_XCurses = yes ; then
 
 cat >>confdefs.h <<\EOF
-#define TIME_WITH_SYS_TIME 1
+#define UNIX 1
 EOF
 
-fi
-
-for ac_header in \
-getopt.h \
-locale.h \
-math.h \
-stdarg.h \
-sys/ioctl.h \
-sys/select.h \
-sys/time.h \
-termios.h \
-unistd.h \
+cat >>confdefs.h <<\EOF
+#define XCURSES 1
+EOF
 
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:13888: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+       echo "$as_me:14037: checking for xcurses.h" >&5
+echo $ECHO_N "checking for xcurses.h... $ECHO_C" >&6
+if test "${ac_cv_header_xcurses_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 13894 "configure"
+#line 14043 "configure"
 #include "confdefs.h"
-#include <$ac_header>
+#include <xcurses.h>
 _ACEOF
-if { (eval echo "$as_me:13898: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:14047: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:13904: \$? = $ac_status" >&5
+  echo "$as_me:14053: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   ac_cpp_err=yes
 fi
 if test -z "$ac_cpp_err"; then
-  eval "$as_ac_Header=yes"
+  ac_cv_header_xcurses_h=yes
 else
   echo "$as_me: failed program was:" >&5
   cat conftest.$ac_ext >&5
-  eval "$as_ac_Header=no"
+  ac_cv_header_xcurses_h=no
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:13923: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+echo "$as_me:14072: result: $ac_cv_header_xcurses_h" >&5
+echo "${ECHO_T}$ac_cv_header_xcurses_h" >&6
+if test $ac_cv_header_xcurses_h = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_XCURSES 1
 EOF
 
 fi
-done
 
-for ac_header in unistd.h getopt.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:13936: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+else
+       { { echo "$as_me:14083: error: Cannot link with XCurses" >&5
+echo "$as_me: error: Cannot link with XCurses" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+       ;;
+(*)
+       { { echo "$as_me:14090: error: unexpected screen-value: $cf_cv_screen" >&5
+echo "$as_me: error: unexpected screen-value: $cf_cv_screen" >&2;}
+   { (exit 1); exit 1; }; }
+       ;;
+esac
+
+: ${cf_nculib_root:=$cf_cv_screen}
+as_ac_Lib=`echo "ac_cv_lib_$cf_nculib_root''__nc_init_pthreads" | $as_tr_sh`
+echo "$as_me:14098: checking for _nc_init_pthreads in -l$cf_nculib_root" >&5
+echo $ECHO_N "checking for _nc_init_pthreads in -l$cf_nculib_root... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13942 "configure"
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$cf_nculib_root  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 14106 "configure"
 #include "confdefs.h"
-#include <$ac_header>
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char _nc_init_pthreads ();
+int
+main (void)
+{
+_nc_init_pthreads ();
+  ;
+  return 0;
+}
 _ACEOF
-if { (eval echo "$as_me:13946: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14125: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:13952: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
+  echo "$as_me:14128: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14131: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:14134: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Lib=yes"
 else
-  ac_cpp_err=yes
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_Lib=no"
 fi
-if test -z "$ac_cpp_err"; then
-  eval "$as_ac_Header=yes"
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:14145: result: `eval echo '${'$as_ac_Lib'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+  cf_cv_ncurses_pthreads=yes
 else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  eval "$as_ac_Header=no"
+  cf_cv_ncurses_pthreads=no
 fi
-rm -f conftest.err conftest.$ac_ext
+
+if test "$cf_cv_ncurses_pthreads" = yes
+then
+
+cf_add_libs="-lpthread"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
+
 fi
-echo "$as_me:13971: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+
+case $cf_cv_screen in
+(ncurses*)
+       cf_cv_libtype=`echo "$cf_cv_screen" | sed -e 's/^ncurses//'`
+       ;;
+esac
+
+echo "$as_me:14180: checking for X11 rgb file" >&5
+echo $ECHO_N "checking for X11 rgb file... $ECHO_C" >&6
+
+# Check whether --with-x11-rgb or --without-x11-rgb was given.
+if test "${with_x11_rgb+set}" = set; then
+  withval="$with_x11_rgb"
+  RGB_PATH=$withval
+else
+  RGB_PATH=auto
+fi;
+
+if test "x$RGB_PATH" = xauto
+then
+       RGB_PATH='${exec_prefix}/lib/X11/rgb.txt'
+       for cf_path in \
+               /opt/local/share/X11/rgb.txt \
+               /opt/X11/share/X11/rgb.txt \
+               /usr/share/X11/rgb.txt \
+               /usr/X11/share/X11/rgb.txt \
+               /usr/X11/lib/X11/rgb.txt \
+               /usr/lib/X11/rgb.txt \
+               /etc/X11/rgb.txt \
+               /usr/pkg/lib/X11/rgb.txt \
+               /usr/X11R7/lib/X11/rgb.txt \
+               /usr/X11R6/lib/X11/rgb.txt \
+               /usr/X11R5/lib/X11/rgb.txt \
+               /usr/X11R4/lib/X11/rgb.txt \
+               /usr/local/lib/X11/rgb.txt \
+               /usr/local/share/X11/rgb.txt \
+               /usr/lib64/X11/rgb.txt
+       do
+               if test -f "$cf_path" ; then
+                       RGB_PATH="$cf_path"
+                       break
+               fi
+       done
+else
+       cf_path=$RGB_PATH
+
+if test "x$prefix" != xNONE; then
+       cf_path_syntax="$prefix"
+else
+       cf_path_syntax="$ac_default_prefix"
+fi
+
+case ".$cf_path" in
+(.\$\(*\)*|.\'*\'*)
+       ;;
+(..|./*|.\\*)
+       ;;
+(.[a-zA-Z]:[\\/]*) # OS/2 EMX
+       ;;
+(.\${*prefix}*|.\${*dir}*)
+       eval cf_path="$cf_path"
+       case ".$cf_path" in
+       (.NONE/*)
+               cf_path=`echo $cf_path | sed -e s%NONE%$cf_path_syntax%`
+               ;;
+       esac
+       ;;
+(.no|.NONE/*)
+       cf_path=`echo $cf_path | sed -e s%NONE%$cf_path_syntax%`
+       ;;
+(*)
+       { { echo "$as_me:14244: error: expected a pathname, not \"$cf_path\"" >&5
+echo "$as_me: error: expected a pathname, not \"$cf_path\"" >&2;}
+   { (exit 1); exit 1; }; }
+       ;;
+esac
+
+fi
+
+echo "$as_me:14252: result: $RGB_PATH" >&5
+echo "${ECHO_T}$RGB_PATH" >&6
+
+cat >>confdefs.h <<EOF
+#define RGB_PATH "$cf_path"
 EOF
 
+no_x11_rgb=
+if test "$RGB_PATH" = no
+then
+       no_x11_rgb="#"
 fi
-done
 
-echo "$as_me:13981: checking for header declaring getopt variables" >&5
-echo $ECHO_N "checking for header declaring getopt variables... $ECHO_C" >&6
-if test "${cf_cv_getopt_header+set}" = set; then
+cf_curses_headers=
+
+case $cf_cv_screen in
+(pdcurses)
+       cf_default_panel=no
+       cf_default_form=no
+       cf_default_menu=no
+       cf_default_tinfo=no
+       ;;
+(xcurses|bsdcurses)
+       cf_default_panel=no
+       cf_default_form=no
+       cf_default_menu=no
+       cf_default_tinfo=yes
+       ;;
+(*)
+       cf_default_panel=yes
+       cf_default_form=yes
+       cf_default_menu=yes
+       cf_default_tinfo=yes
+       case $cf_cv_screen in
+       (ncurses*)
+               cf_curses_headers="nc_alloc.h nomacros.h term_entry.h"
+               ;;
+       esac
+       ;;
+esac
+
+echo "$as_me:14293: checking if you want to check for panel functions" >&5
+echo $ECHO_N "checking if you want to check for panel functions... $ECHO_C" >&6
+
+# Check whether --enable-panel or --disable-panel was given.
+if test "${enable_panel+set}" = set; then
+  enableval="$enable_panel"
+  test "$enableval" != no && enableval=yes
+       if test "$enableval" != "yes" ; then
+    cf_enable_panel=no
+       else
+               cf_enable_panel=$cf_default_panel
+       fi
+else
+  enableval=yes
+       cf_enable_panel=$cf_default_panel
+
+fi;
+echo "$as_me:14310: result: $cf_enable_panel" >&5
+echo "${ECHO_T}$cf_enable_panel" >&6
+if test $cf_enable_panel = yes
+then
+
+as_ac_Lib=`echo "ac_cv_lib_panel$cf_cv_libtype''_new_panel" | $as_tr_sh`
+echo "$as_me:14316: checking for new_panel in -lpanel$cf_cv_libtype" >&5
+echo $ECHO_N "checking for new_panel in -lpanel$cf_cv_libtype... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
-cf_cv_getopt_header=none
-for cf_header in stdio.h stdlib.h unistd.h getopt.h
-do
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpanel$cf_cv_libtype  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 13991 "configure"
+#line 14324 "configure"
 #include "confdefs.h"
 
-#include <$cf_header>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char new_panel ();
 int
-main ()
+main (void)
 {
-int x = optind; char *y = optarg
+new_panel ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14004: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14343: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14007: \$? = $ac_status" >&5
+  echo "$as_me:14346: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14010: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14349: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14013: \$? = $ac_status" >&5
+  echo "$as_me:14352: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_getopt_header=$cf_header
- break
+  eval "$as_ac_Lib=yes"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+eval "$as_ac_Lib=no"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-done
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:14025: result: $cf_cv_getopt_header" >&5
-echo "${ECHO_T}$cf_cv_getopt_header" >&6
-if test $cf_cv_getopt_header != none ; then
+echo "$as_me:14363: result: `eval echo '${'$as_ac_Lib'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
 
-cat >>confdefs.h <<\EOF
-#define HAVE_GETOPT_HEADER 1
-EOF
+cf_upper=`echo "have_libpanel" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-fi
-if test $cf_cv_getopt_header = getopt.h ; then
+cf_add_libs="-lpanel$cf_cv_libtype"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
 
-cat >>confdefs.h <<\EOF
-#define NEED_GETOPT_H 1
+cat >>confdefs.h <<EOF
+#define $cf_upper 1
 EOF
 
 fi
 
-for ac_func in \
-getopt \
-gettimeofday \
+       cf_curses_headers="$cf_curses_headers panel.h"
+fi
 
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:14048: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
+echo "$as_me:14394: checking if you want to check for menu functions" >&5
+echo $ECHO_N "checking if you want to check for menu functions... $ECHO_C" >&6
+
+# Check whether --enable-menu or --disable-menu was given.
+if test "${enable_menu+set}" = set; then
+  enableval="$enable_menu"
+  test "$enableval" != no && enableval=yes
+       if test "$enableval" != "yes" ; then
+    cf_enable_menu=no
+       else
+               cf_enable_menu=$cf_default_menu
+       fi
+else
+  enableval=yes
+       cf_enable_menu=$cf_default_menu
+
+fi;
+echo "$as_me:14411: result: $cf_enable_menu" >&5
+echo "${ECHO_T}$cf_enable_menu" >&6
+if test $cf_enable_menu = yes
+then
+       case $cf_cv_screen in
+       (ncurses*)
+               ;;
+       (curses*)
+
+echo "$as_me:14420: checking for NetBSD menu.h" >&5
+echo $ECHO_N "checking for NetBSD menu.h... $ECHO_C" >&6
+if test "${cf_cv_netbsd_menu_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 14054 "configure"
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 14427 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
+
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <menu.h>
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
+
+       MENU *menu;
+       int y = menu->max_item_width;
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14085: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:14445: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14088: \$? = $ac_status" >&5
+  echo "$as_me:14448: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14091: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:14451: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14094: \$? = $ac_status" >&5
+  echo "$as_me:14454: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+  cf_cv_netbsd_menu_h=yes
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:14104: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-EOF
-
+cf_cv_netbsd_menu_h=no
 fi
-done
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-if test "x$ac_cv_func_getopt" = xno; then
-       { { echo "$as_me:14115: error: getopt is required for building programs" >&5
-echo "$as_me: error: getopt is required for building programs" >&2;}
-   { (exit 1); exit 1; }; }
 fi
+echo "$as_me:14466: result: $cf_cv_netbsd_menu_h" >&5
+echo "${ECHO_T}$cf_cv_netbsd_menu_h" >&6
 
-if test "$cf_enable_widec" = yes; then
+test "$cf_cv_netbsd_menu_h" = yes &&
+cat >>confdefs.h <<\EOF
+#define HAVE_NETBSD_MENU_H 1
+EOF
 
-for ac_func in \
-mblen \
-mbrlen \
-mbrtowc \
-mbsrtowcs \
-mbstowcs \
-mbtowc \
-wcsrtombs \
-wcstombs \
+               ;;
+       esac
 
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:14134: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
+as_ac_Lib=`echo "ac_cv_lib_menu$cf_cv_libtype''_menu_driver" | $as_tr_sh`
+echo "$as_me:14478: checking for menu_driver in -lmenu$cf_cv_libtype" >&5
+echo $ECHO_N "checking for menu_driver in -lmenu$cf_cv_libtype... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 14140 "configure"
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmenu$cf_cv_libtype  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 14486 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
+
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
-
+char menu_driver ();
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
-
+menu_driver ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14171: \"$ac_link\"") >&5
+if { (eval echo "$as_me:14505: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14174: \$? = $ac_status" >&5
+  echo "$as_me:14508: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14177: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14511: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14180: \$? = $ac_status" >&5
+  echo "$as_me:14514: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+  eval "$as_ac_Lib=yes"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+eval "$as_ac_Lib=no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:14190: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+echo "$as_me:14525: result: `eval echo '${'$as_ac_Lib'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+
+cf_upper=`echo "have_libmenu" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+cf_add_libs="-lmenu$cf_cv_libtype"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
+
+cat >>confdefs.h <<EOF
+#define $cf_upper 1
 EOF
 
 fi
-done
 
+       cf_curses_headers="$cf_curses_headers menu.h"
 fi
 
-echo "$as_me:14202: checking definition to turn on extended curses functions" >&5
-echo $ECHO_N "checking definition to turn on extended curses functions... $ECHO_C" >&6
-if test "${cf_cv_need_xopen_extension+set}" = set; then
+echo "$as_me:14556: checking if you want to check for form functions" >&5
+echo $ECHO_N "checking if you want to check for form functions... $ECHO_C" >&6
+
+# Check whether --enable-form or --disable-form was given.
+if test "${enable_form+set}" = set; then
+  enableval="$enable_form"
+  test "$enableval" != no && enableval=yes
+       if test "$enableval" != "yes" ; then
+    cf_enable_form=no
+       else
+               cf_enable_form=$cf_default_form
+       fi
+else
+  enableval=yes
+       cf_enable_form=$cf_default_form
+
+fi;
+echo "$as_me:14573: result: $cf_enable_form" >&5
+echo "${ECHO_T}$cf_enable_form" >&6
+if test $cf_enable_form = yes
+then
+       case $cf_cv_screen in
+       (ncurses*)
+               ;;
+       (curses*)
+
+echo "$as_me:14582: checking for NetBSD form.h" >&5
+echo $ECHO_N "checking for NetBSD form.h... $ECHO_C" >&6
+if test "${cf_cv_netbsd_form_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cf_cv_need_xopen_extension=unknown
 cat >conftest.$ac_ext <<_ACEOF
-#line 14210 "configure"
+#line 14589 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
+#include <form.h>
+
 int
-main ()
+main (void)
 {
 
-#if defined(NCURSES_VERSION_PATCH)
-#if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
-       make an error
-#endif
-#endif
-#ifdef NCURSES_VERSION
-       cchar_t check;
-       int check2 = curs_set((int)sizeof(check));
-#endif
-       long x = winnstr(stdscr, "", 0);
-       int x1, y1;
-       getbegyx(stdscr, y1, x1)
+       FORM *form;
+       int y = current_field(form)->cursor_ypos;
+       int x = current_field(form)->cursor_xpos;
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14236: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:14608: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14239: \$? = $ac_status" >&5
+  echo "$as_me:14611: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14242: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:14614: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14245: \$? = $ac_status" >&5
+  echo "$as_me:14617: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_need_xopen_extension=none
+  cf_cv_netbsd_form_h=yes
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+cf_cv_netbsd_form_h=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-       for cf_try_xopen_extension in _XOPEN_SOURCE_EXTENDED NCURSES_WIDECHAR
-       do
-               cat >conftest.$ac_ext <<_ACEOF
-#line 14255 "configure"
+fi
+echo "$as_me:14629: result: $cf_cv_netbsd_form_h" >&5
+echo "${ECHO_T}$cf_cv_netbsd_form_h" >&6
+
+test "$cf_cv_netbsd_form_h" = yes &&
+cat >>confdefs.h <<\EOF
+#define HAVE_NETBSD_FORM_H 1
+EOF
+
+               ;;
+       esac
+
+as_ac_Lib=`echo "ac_cv_lib_form$cf_cv_libtype''_form_driver" | $as_tr_sh`
+echo "$as_me:14641: checking for form_driver in -lform$cf_cv_libtype" >&5
+echo $ECHO_N "checking for form_driver in -lform$cf_cv_libtype... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lform$cf_cv_libtype  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 14649 "configure"
 #include "confdefs.h"
 
-#define $cf_try_xopen_extension 1
-#include <stdlib.h>
-#include <${cf_cv_ncurses_header:-curses.h}>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char form_driver ();
 int
-main ()
+main (void)
 {
-
-#ifdef NCURSES_VERSION
-               cchar_t check;
-               int check2 = curs_set((int)sizeof(check));
-#endif
-               long x = winnstr(stdscr, "", 0);
-               int x1, y1;
-               getbegyx(stdscr, y1, x1)
+form_driver ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14277: \"$ac_link\"") >&5
+if { (eval echo "$as_me:14668: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14280: \$? = $ac_status" >&5
+  echo "$as_me:14671: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14283: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14674: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14286: \$? = $ac_status" >&5
+  echo "$as_me:14677: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_need_xopen_extension=$cf_try_xopen_extension; break
+  eval "$as_ac_Lib=yes"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+eval "$as_ac_Lib=no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:14688: result: `eval echo '${'$as_ac_Lib'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+
+cf_upper=`echo "have_libform" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+cf_add_libs="-lform$cf_cv_libtype"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
        done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
+
+cat >>confdefs.h <<EOF
+#define $cf_upper 1
+EOF
 
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
+       cf_curses_headers="$cf_curses_headers form.h"
 fi
-echo "$as_me:14300: result: $cf_cv_need_xopen_extension" >&5
-echo "${ECHO_T}$cf_cv_need_xopen_extension" >&6
 
-case $cf_cv_need_xopen_extension in
-(*_*)
-       CPPFLAGS="$CPPFLAGS -D$cf_cv_need_xopen_extension"
-       ;;
-esac
+# look for curses-related headers
 
-echo "$as_me:14309: checking for term.h" >&5
-echo $ECHO_N "checking for term.h... $ECHO_C" >&6
-if test "${cf_cv_term_header+set}" = set; then
+for ac_header in $cf_curses_headers
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:14724: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14730 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:14734: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:14740: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:14759: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
 
-# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
-# for <term.h> if we do not find the variant.
-
-cf_header_list="term.h ncurses/term.h ncursesw/term.h"
-
-case ${cf_cv_ncurses_header:-curses.h} in
-(*/*)
-       cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
-       cf_header_list="$cf_header_item $cf_header_list"
-       ;;
-esac
+fi
+done
 
-for cf_header in $cf_header_list
-do
-       cat >conftest.$ac_ext <<_ACEOF
-#line 14330 "configure"
+echo "$as_me:14769: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14775 "configure"
 #include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
 
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <${cf_header}>
-int
-main ()
-{
-WINDOW *x
-  ;
-  return 0;
-}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14344: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:14347: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14350: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+if { (eval echo "$as_me:14783: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
-  echo "$as_me:14353: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_term_header=$cf_header
-        break
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:14789: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_stdc=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_term_header=no
+  cat conftest.$ac_ext >&5
+  ac_cv_header_stdc=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-done
+rm -f conftest.err conftest.$ac_ext
 
-case $cf_cv_term_header in
-(no)
-       # If curses is ncurses, some packagers still mess it up by trying to make
-       # us use GNU termcap.  This handles the most common case.
-       for cf_header in ncurses/term.h ncursesw/term.h
-       do
-               cat >conftest.$ac_ext <<_ACEOF
-#line 14372 "configure"
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14811 "configure"
 #include "confdefs.h"
+#include <string.h>
 
-#include <${cf_cv_ncurses_header:-curses.h}>
-#ifdef NCURSES_VERSION
-#include <${cf_header}>
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -rf conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14829 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -rf conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14850 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
 #else
-make an error
+# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
+                     || ('j' <= (c) && (c) <= 'r') \
+                     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
 #endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
 int
-main ()
+main (void)
 {
-WINDOW *x
-  ;
-  return 0;
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+        || toupper (i) != TOUPPER (i))
+      $ac_main_return(2);
+  $ac_main_return (0);
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14390: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:14876: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14393: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14396: \"$ac_try\"") >&5
+  echo "$as_me:14879: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:14881: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14399: \$? = $ac_status" >&5
+  echo "$as_me:14884: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_term_header=$cf_header
-                        break
+  :
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_term_header=no
+ac_cv_header_stdc=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-       done
-       ;;
-esac
-
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:14414: result: $cf_cv_term_header" >&5
-echo "${ECHO_T}$cf_cv_term_header" >&6
-
-case $cf_cv_term_header in
-(term.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_TERM_H 1
-EOF
-
-       ;;
-(ncurses/term.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSES_TERM_H 1
-EOF
-
-       ;;
-(ncursesw/term.h)
+fi
+fi
+echo "$as_me:14897: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
 
 cat >>confdefs.h <<\EOF
-#define HAVE_NCURSESW_TERM_H 1
+#define STDC_HEADERS 1
 EOF
 
-       ;;
-esac
+fi
 
-echo "$as_me:14441: checking for unctrl.h" >&5
-echo $ECHO_N "checking for unctrl.h... $ECHO_C" >&6
-if test "${cf_cv_unctrl_header+set}" = set; then
+echo "$as_me:14907: checking whether time.h and sys/time.h may both be included" >&5
+echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
+if test "${ac_cv_header_time+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
-# If we found <ncurses/curses.h>, look for <ncurses/unctrl.h>, but always look
-# for <unctrl.h> if we do not find the variant.
-
-cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
-
-case ${cf_cv_ncurses_header:-curses.h} in
-(*/*)
-       cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
-       cf_header_list="$cf_header_item $cf_header_list"
-       ;;
-esac
-
-for cf_header in $cf_header_list
-do
-       cat >conftest.$ac_ext <<_ACEOF
-#line 14462 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14913 "configure"
 #include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
 
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <${cf_header}>
 int
-main ()
+main (void)
 {
-WINDOW *x
+if ((struct tm *) 0)
+return 0;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14476: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14929: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14479: \$? = $ac_status" >&5
+  echo "$as_me:14932: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14482: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14935: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14485: \$? = $ac_status" >&5
+  echo "$as_me:14938: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_unctrl_header=$cf_header
-        break
+  ac_cv_header_time=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_unctrl_header=no
+ac_cv_header_time=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-done
-
 fi
-echo "$as_me:14498: result: $cf_cv_unctrl_header" >&5
-echo "${ECHO_T}$cf_cv_unctrl_header" >&6
-
-case $cf_cv_unctrl_header in
-(no)
-       { echo "$as_me:14503: WARNING: unctrl.h header not found" >&5
-echo "$as_me: WARNING: unctrl.h header not found" >&2;}
-       ;;
-esac
-
-case $cf_cv_unctrl_header in
-(unctrl.h)
+echo "$as_me:14948: result: $ac_cv_header_time" >&5
+echo "${ECHO_T}$ac_cv_header_time" >&6
+if test $ac_cv_header_time = yes; then
 
 cat >>confdefs.h <<\EOF
-#define HAVE_UNCTRL_H 1
+#define TIME_WITH_SYS_TIME 1
 EOF
 
-       ;;
-(ncurses/unctrl.h)
-
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSES_UNCTRL_H 1
-EOF
+fi
 
-       ;;
-(ncursesw/unctrl.h)
+for ac_header in \
+getopt.h \
+locale.h \
+math.h \
+stdarg.h \
+stdint.h \
+sys/ioctl.h \
+sys/select.h \
+sys/time.h \
+termios.h \
+unistd.h \
 
-cat >>confdefs.h <<\EOF
-#define HAVE_NCURSESW_UNCTRL_H 1
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:14972: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14978 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:14982: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:14988: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:15007: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 EOF
 
-       ;;
-esac
-
-for cf_func in \
-assume_default_colors \
-chgat \
-color_set \
-filter \
-getbegx \
-getcurx \
-getmaxx \
-getnstr \
-getparx \
-getwin \
-mvvline \
-mvwvline \
-napms \
-putwin \
-resize_term \
-resizeterm \
-restartterm \
-ripoffline \
-scr_dump \
-setupterm \
-slk_color \
-slk_init \
-termattrs \
-tgetent \
-tigetnum \
-tigetstr \
-typeahead \
-use_default_colors \
-use_env \
-use_extended_names \
-use_screen \
-use_window \
-vid_puts \
-vidputs \
-vsscanf \
-vw_printw \
-wchgat \
-winsstr \
-wresize \
-wsyncdown \
+fi
+done
 
+for ac_header in unistd.h getopt.h
 do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:15020: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 15026 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:15030: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:15036: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:15055: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
 
-cf_tr_func=`echo "$cf_func" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-       echo "$as_me:14578: checking for ${cf_func}" >&5
-echo $ECHO_N "checking for ${cf_func}... $ECHO_C" >&6
-
-echo "${as_me:-configure}:14581: testing ${cf_func} ..." 1>&5
+fi
+done
 
-       if eval "test \"\${cf_cv_func_$cf_func+set}\" = set"; then
+echo "$as_me:15065: checking for header declaring getopt variables" >&5
+echo $ECHO_N "checking for header declaring getopt variables... $ECHO_C" >&6
+if test "${cf_cv_getopt_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-               eval cf_result='$ac_cv_func_'$cf_func
-               if test ".$cf_result" != ".no"; then
-                       cat >conftest.$ac_ext <<_ACEOF
-#line 14590 "configure"
+cf_cv_getopt_header=none
+for cf_header in stdio.h stdlib.h unistd.h getopt.h
+do
+cat >conftest.$ac_ext <<_ACEOF
+#line 15075 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
-#endif
-
+#include <$cf_header>
 int
-main ()
+main (void)
 {
-
-#ifndef ${cf_func}
-long foo = (long)(&${cf_func});
-fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
-if (foo + 1234 > 5678)
-       ${cf_cv_main_return:-return}(foo);
-#endif
-
+int x = optind; char *y = optarg
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14623: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:15088: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14626: \$? = $ac_status" >&5
+  echo "$as_me:15091: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14629: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:15094: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14632: \$? = $ac_status" >&5
+  echo "$as_me:15097: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_getopt_header=$cf_header
+ break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-               fi
-               eval 'cf_cv_func_'$cf_func'=$cf_result'
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
 
 fi
+echo "$as_me:15109: result: $cf_cv_getopt_header" >&5
+echo "${ECHO_T}$cf_cv_getopt_header" >&6
+if test $cf_cv_getopt_header != none ; then
 
-       # use the computed/retrieved cache-value:
-       eval 'cf_result=$cf_cv_func_'$cf_func
-       echo "$as_me:14648: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-       if test $cf_result != no; then
-               cat >>confdefs.h <<EOF
-#define HAVE_${cf_tr_func} 1
+cat >>confdefs.h <<\EOF
+#define HAVE_GETOPT_HEADER 1
 EOF
 
-       fi
-done
-
-for cf_func in tputs
-do
+fi
+if test $cf_cv_getopt_header = getopt.h ; then
 
-cf_tr_func=`echo "$cf_func" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cat >>confdefs.h <<\EOF
+#define NEED_GETOPT_H 1
+EOF
 
-       echo "$as_me:14663: checking for ${cf_func}" >&5
-echo $ECHO_N "checking for ${cf_func}... $ECHO_C" >&6
+fi
 
-echo "${as_me:-configure}:14666: testing ${cf_func} ..." 1>&5
+for ac_func in \
+getopt \
+gettimeofday \
+tdestroy \
+tsearch \
 
-       if eval "test \"\${cf_cv_func_$cf_func+set}\" = set"; then
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:15134: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
-               eval cf_result='$ac_cv_func_'$cf_func
-               if test ".$cf_result" != ".no"; then
-                       cat >conftest.$ac_ext <<_ACEOF
-#line 14675 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 15140 "configure"
 #include "confdefs.h"
-
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
 #endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
 
 int
-main ()
+main (void)
 {
-
-#ifndef ${cf_func}
-long foo = (long)(&${cf_func});
-fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
-if (foo + 1234 > 5678)
-       ${cf_cv_main_return:-return}(foo);
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
 #endif
 
   ;
@@ -14705,1252 +15168,1376 @@ if (foo + 1234 > 5678)
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14708: \"$ac_link\"") >&5
+if { (eval echo "$as_me:15171: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14711: \$? = $ac_status" >&5
+  echo "$as_me:15174: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14714: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15177: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14717: \$? = $ac_status" >&5
+  echo "$as_me:15180: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  eval "$as_ac_var=yes"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
+eval "$as_ac_var=no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-               fi
-               eval 'cf_cv_func_'$cf_func'=$cf_result'
-
 fi
-
-       # use the computed/retrieved cache-value:
-       eval 'cf_result=$cf_cv_func_'$cf_func
-       echo "$as_me:14733: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-       if test $cf_result != no; then
-               cat >>confdefs.h <<EOF
-#define HAVE_${cf_tr_func} 1
+echo "$as_me:15190: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 EOF
 
-       fi
+fi
 done
 
-if test x$cf_cv_func_tputs = xyes
-then
-       cf_done=no
-       for cf_arg in int char
-       do
-               for cf_ret in int void
-               do
-                       if test $cf_ret = void
-                       then
-                               cf_return="/* nothing */"
-                       else
-                               cf_return="return value"
-                       fi
-                       cat >conftest.$ac_ext <<_ACEOF
-#line 14757 "configure"
-#include "confdefs.h"
+if test "x$ac_cv_func_getopt" = xno; then
+       { { echo "$as_me:15201: error: getopt is required for building programs" >&5
+echo "$as_me: error: getopt is required for building programs" >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <$cf_cv_term_header>
+if test "$cf_enable_widec" = yes; then
 
-static $cf_ret outc($cf_arg value) { $cf_return; }
+for ac_func in \
+mblen \
+mbrlen \
+mbrtowc \
+mbsrtowcs \
+mbstowcs \
+mbtowc \
+wcsrtombs \
+wcstombs \
+
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:15220: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 15226 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
 
 int
-main ()
+main (void)
 {
-
-       tputs("hello", 0, outc);
-       ${cf_cv_main_return:-return}(0);
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#endif
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14777: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:15257: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14780: \$? = $ac_status" >&5
+  echo "$as_me:15260: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14783: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:15263: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14786: \$? = $ac_status" >&5
+  echo "$as_me:15266: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-               test -n "$verbose" && echo "    prototype $cf_ret func($cf_arg value)" 1>&6
-
-echo "${as_me:-configure}:14791: testing prototype $cf_ret func($cf_arg value) ..." 1>&5
-
-               cat >>confdefs.h <<EOF
-#define TPUTS_ARG               $cf_arg
-#define TPUTS_PROTO(func,value) $cf_ret func(TPUTS_ARG value)
-#define TPUTS_RETURN(value)     $cf_return
-EOF
-               cf_done=yes
-               break
-
+  eval "$as_ac_var=yes"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-               done
-               test $cf_done = yes && break
-       done
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
+echo "$as_me:15276: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
 
-echo "$as_me:14811: checking for ncurses extended functions" >&5
-echo $ECHO_N "checking for ncurses extended functions... $ECHO_C" >&6
-if test "${cf_cv_ncurses_ext_funcs+set}" = set; then
+fi
+done
+
+fi
+
+echo "$as_me:15288: checking definition to turn on extended curses functions" >&5
+echo $ECHO_N "checking definition to turn on extended curses functions... $ECHO_C" >&6
+if test "${cf_cv_need_xopen_extension+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
+cf_cv_need_xopen_extension=unknown
 cat >conftest.$ac_ext <<_ACEOF
-#line 14818 "configure"
+#line 15296 "configure"
 #include "confdefs.h"
 
+#include <stdlib.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
-int x = NCURSES_EXT_FUNCS
-
+#if defined(NCURSES_VERSION_PATCH)
+#if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
+       make an error
+#endif
+#endif
+#ifdef NCURSES_VERSION
+       cchar_t check;
+       int check2 = curs_set((int)sizeof(check));
+#endif
+       long x = winnstr(stdscr, "", 0);
+       int x1, y1;
+       getbegyx(stdscr, y1, x1)
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14833: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:15322: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14836: \$? = $ac_status" >&5
+  echo "$as_me:15325: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14839: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:15328: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14842: \$? = $ac_status" >&5
+  echo "$as_me:15331: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_ncurses_ext_funcs=defined
+  cf_cv_need_xopen_extension=none
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 14850 "configure"
+       for cf_try_xopen_extension in _XOPEN_SOURCE_EXTENDED NCURSES_WIDECHAR
+       do
+               cat >conftest.$ac_ext <<_ACEOF
+#line 15341 "configure"
 #include "confdefs.h"
 
+#define $cf_try_xopen_extension 1
+#include <stdlib.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
-       (void) assume_default_colors (0, 0);
-       (void) curses_version ();
-       (void) define_key (0, 0);
-       (void) is_term_resized (0, 0);
-       (void) key_defined (0);
-       (void) keybound (0, 0);
-       (void) keyok (0, 0);
-       (void) resize_term (0, 0);
-       (void) resizeterm (0, 0);
-       (void) use_default_colors ();
-       (void) use_extended_names (0);
-       (void) wresize (0, 0, 0);
+#ifdef NCURSES_VERSION
+               cchar_t check;
+               int check2 = curs_set((int)sizeof(check));
+#endif
+               long x = winnstr(stdscr, "", 0);
+               int x1, y1;
+               getbegyx(stdscr, y1, x1)
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14875: \"$ac_link\"") >&5
+if { (eval echo "$as_me:15363: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14878: \$? = $ac_status" >&5
+  echo "$as_me:15366: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14881: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15369: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14884: \$? = $ac_status" >&5
+  echo "$as_me:15372: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_ncurses_ext_funcs=yes
+  cf_cv_need_xopen_extension=$cf_try_xopen_extension; break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_ncurses_ext_funcs=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       done
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 fi
-echo "$as_me:14898: result: $cf_cv_ncurses_ext_funcs" >&5
-echo "${ECHO_T}$cf_cv_ncurses_ext_funcs" >&6
-test "$cf_cv_ncurses_ext_funcs" = yes &&
-cat >>confdefs.h <<\EOF
-#define NCURSES_EXT_FUNCS 1
-EOF
+echo "$as_me:15386: result: $cf_cv_need_xopen_extension" >&5
+echo "${ECHO_T}$cf_cv_need_xopen_extension" >&6
 
-if test "$cf_enable_widec" = yes
-then
-       # workaround for systems with ncurses before 20111029, due to change of
-       # feature test macro from _XPG5 to _XOPEN_SOURCE
-       if test -n "$cf_cv_ncurses_version" && test "x$cf_cv_ncurses_version" != xno
-       then
-               cf_define_xpg5=no
-               echo "$as_me:14912: checking if _XPG5 should be defined to enable wide-characters" >&5
-echo $ECHO_N "checking if _XPG5 should be defined to enable wide-characters... $ECHO_C" >&6
+case $cf_cv_need_xopen_extension in
+(*_*)
+       CPPFLAGS="$CPPFLAGS -D$cf_cv_need_xopen_extension"
+       ;;
+esac
 
-               cat >conftest.$ac_ext <<_ACEOF
-#line 14916 "configure"
+echo "$as_me:15395: checking for term.h" >&5
+echo $ECHO_N "checking for term.h... $ECHO_C" >&6
+if test "${cf_cv_term_header+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
+# for <term.h> if we do not find the variant.
+
+cf_header_list="term.h ncurses/term.h ncursesw/term.h"
+
+case ${cf_cv_ncurses_header:-curses.h} in
+(*/*)
+       cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
+       cf_header_list="$cf_header_item $cf_header_list"
+       ;;
+esac
+
+for cf_header in $cf_header_list
+do
+       cat >conftest.$ac_ext <<_ACEOF
+#line 15416 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
+#include <${cf_header}>
 int
-main ()
+main (void)
 {
-int x = _XPG5
+WINDOW *x
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14929: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:15430: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14932: \$? = $ac_status" >&5
+  echo "$as_me:15433: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14935: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15436: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14938: \$? = $ac_status" >&5
+  echo "$as_me:15439: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+  cf_cv_term_header=$cf_header
+        break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_save_cppflags="$CPPFLAGS"
-                        CPPFLAGS="$CPPFLAGS -D_XPG5"
-                        cat >conftest.$ac_ext <<_ACEOF
-#line 14947 "configure"
+cf_cv_term_header=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+
+case $cf_cv_term_header in
+(no)
+       # If curses is ncurses, some packagers still mess it up by trying to make
+       # us use GNU termcap.  This handles the most common case.
+       for cf_header in ncurses/term.h ncursesw/term.h
+       do
+               cat >conftest.$ac_ext <<_ACEOF
+#line 15458 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
+#ifdef NCURSES_VERSION
+#include <${cf_header}>
+#else
+make an error
+#endif
 int
-main ()
+main (void)
 {
-int x = _XPG5
+WINDOW *x
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14960: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:15476: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14963: \$? = $ac_status" >&5
+  echo "$as_me:15479: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14966: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15482: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14969: \$? = $ac_status" >&5
+  echo "$as_me:15485: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_define_xpg5=yes
+  cf_cv_term_header=$cf_header
+                        break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+cf_cv_term_header=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-                        CPPFLAGS="$cf_save_cppflags"
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-               echo "$as_me:14980: result: $cf_define_xpg5" >&5
-echo "${ECHO_T}$cf_define_xpg5" >&6
-
-               if test "$cf_define_xpg5" = yes
-               then
-                       CPPFLAGS="$CPPFLAGS -D_XPG5"
-               fi
-       fi
-
-       echo "$as_me:14989: checking for wide-character functions" >&5
-echo $ECHO_N "checking for wide-character functions... $ECHO_C" >&6
-if test "${cf_cv_widechar_funcs+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-       cat >conftest.$ac_ext <<_ACEOF
-#line 14996 "configure"
-#include "confdefs.h"
-
-#include <${cf_cv_ncurses_header:-curses.h}>
-int
-main ()
-{
-
-               static wchar_t src_wchar[2];
-               static cchar_t dst_cchar;
-               setcchar(&dst_cchar, src_wchar, A_NORMAL, 0, (void *) 0);
+       done
+       ;;
+esac
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15013: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:15016: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15019: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:15022: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_widechar_funcs=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_widechar_funcs=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+echo "$as_me:15500: result: $cf_cv_term_header" >&5
+echo "${ECHO_T}$cf_cv_term_header" >&6
 
-fi
-echo "$as_me:15033: result: $cf_cv_widechar_funcs" >&5
-echo "${ECHO_T}$cf_cv_widechar_funcs" >&6
-       if test "$cf_cv_widechar_funcs" != no ; then
+case $cf_cv_term_header in
+(term.h)
 
 cat >>confdefs.h <<\EOF
-#define USE_WIDEC_SUPPORT 1
+#define HAVE_TERM_H 1
 EOF
 
-       else
-               cat >>confdefs.h <<\EOF
-#define USE_WIDEC_SUPPORT 0
-EOF
+       ;;
+(ncurses/term.h)
 
-       fi
-else
-       cat >>confdefs.h <<\EOF
-#define USE_WIDEC_SUPPORT 0
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_TERM_H 1
 EOF
 
-fi
-
-echo "$as_me:15054: checking if $cf_cv_screen library uses pthreads" >&5
-echo $ECHO_N "checking if $cf_cv_screen library uses pthreads... $ECHO_C" >&6
-if test "${cf_cv_use_pthreads+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-cat >conftest.$ac_ext <<_ACEOF
-#line 15061 "configure"
-#include "confdefs.h"
-
-#include <${cf_cv_ncurses_header:-curses.h}>
-extern void _nc_init_pthreads(void);
-
-int
-main ()
-{
-
-       initscr();
-       _nc_init_pthreads();
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15079: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:15082: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15085: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:15088: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_use_pthreads=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_use_pthreads=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       ;;
+(ncursesw/term.h)
 
-fi
-echo "$as_me:15099: result: $cf_cv_use_pthreads" >&5
-echo "${ECHO_T}$cf_cv_use_pthreads" >&6
-test $cf_cv_use_pthreads = yes && cat >>confdefs.h <<\EOF
-#define USE_PTHREADS 1
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_TERM_H 1
 EOF
 
-echo "$as_me:15105: checking if sys/time.h works with sys/select.h" >&5
-echo $ECHO_N "checking if sys/time.h works with sys/select.h... $ECHO_C" >&6
-if test "${cf_cv_sys_time_select+set}" = set; then
+       ;;
+esac
+
+echo "$as_me:15527: checking for unctrl.h" >&5
+echo $ECHO_N "checking for unctrl.h... $ECHO_C" >&6
+if test "${cf_cv_unctrl_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 15112 "configure"
-#include "confdefs.h"
+# If we found <ncurses/curses.h>, look for <ncurses/unctrl.h>, but always look
+# for <unctrl.h> if we do not find the variant.
 
-#include <sys/types.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
+cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
+
+case ${cf_cv_ncurses_header:-curses.h} in
+(*/*)
+       cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
+       cf_header_list="$cf_header_item $cf_header_list"
+       ;;
+esac
+
+for cf_header in $cf_header_list
+do
+       cat >conftest.$ac_ext <<_ACEOF
+#line 15548 "configure"
+#include "confdefs.h"
 
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <${cf_header}>
 int
-main ()
+main (void)
 {
-
+WINDOW *x
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15132: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:15562: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15135: \$? = $ac_status" >&5
+  echo "$as_me:15565: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15138: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15568: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15141: \$? = $ac_status" >&5
+  echo "$as_me:15571: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_sys_time_select=yes
+  cf_cv_unctrl_header=$cf_header
+        break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_sys_time_select=no
+cf_cv_unctrl_header=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
+done
 
 fi
+echo "$as_me:15584: result: $cf_cv_unctrl_header" >&5
+echo "${ECHO_T}$cf_cv_unctrl_header" >&6
+
+case $cf_cv_unctrl_header in
+(no)
+       { echo "$as_me:15589: WARNING: unctrl.h header not found" >&5
+echo "$as_me: WARNING: unctrl.h header not found" >&2;}
+       ;;
+esac
+
+case $cf_cv_unctrl_header in
+(unctrl.h)
 
-echo "$as_me:15153: result: $cf_cv_sys_time_select" >&5
-echo "${ECHO_T}$cf_cv_sys_time_select" >&6
-test "$cf_cv_sys_time_select" = yes &&
 cat >>confdefs.h <<\EOF
-#define HAVE_SYS_TIME_SELECT 1
+#define HAVE_UNCTRL_H 1
 EOF
 
-# special check for test/ditto.c
+       ;;
+(ncurses/unctrl.h)
 
-echo "$as_me:15162: checking for openpty in -lutil" >&5
-echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6
-if test "${ac_cv_lib_util_openpty+set}" = set; then
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_UNCTRL_H 1
+EOF
+
+       ;;
+(ncursesw/unctrl.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_UNCTRL_H 1
+EOF
+
+       ;;
+esac
+
+for cf_func in \
+alloc_pair \
+assume_default_colors \
+chgat \
+color_content \
+color_set \
+copywin \
+delscreen \
+dupwin \
+filter \
+getbegx \
+getcurx \
+getmaxx \
+getnstr \
+getparx \
+getwin \
+halfdelay \
+init_extended_color \
+mvderwin \
+mvvline \
+mvwin \
+mvwvline \
+napms \
+newpad \
+putwin \
+resize_term \
+resizeterm \
+restartterm \
+ripoffline \
+scr_dump \
+setupterm \
+slk_color \
+slk_init \
+termattrs \
+tgetent \
+tigetnum \
+tigetstr \
+tputs_sp \
+typeahead \
+use_default_colors \
+use_env \
+use_extended_names \
+use_screen \
+use_window \
+vid_puts \
+vidputs \
+vsscanf \
+vw_printw \
+wchgat \
+winsdelln \
+winsstr \
+wresize \
+wsyncdown \
+_tracef \
+
+do
+
+cf_tr_func=`echo "$cf_func" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+       echo "$as_me:15677: checking for ${cf_func}" >&5
+echo $ECHO_N "checking for ${cf_func}... $ECHO_C" >&6
+
+echo "${as_me:-configure}:15680: testing ${cf_func} ..." 1>&5
+
+       if eval "test \"\${cf_cv_func_$cf_func+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lutil  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 15170 "configure"
+
+               eval cf_result='$ac_cv_func_'$cf_func
+               if test ".$cf_result" != ".no"; then
+                       cat >conftest.$ac_ext <<_ACEOF
+#line 15689 "configure"
 #include "confdefs.h"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
+#ifdef HAVE_XCURSES
+#include <xcurses.h>
+char * XCursesProgramName = "test";
+#else
+#include <${cf_cv_ncurses_header:-curses.h}>
+#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
+#include <ncursesw/term.h>
+#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
+#include <ncurses/term.h>
+#elif defined(HAVE_TERM_H)
+#include <term.h>
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char openpty ();
+#endif
+
 int
-main ()
+main (void)
 {
-openpty ();
+
+#ifndef ${cf_func}
+long foo = (long)(&${cf_func});
+fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
+if (foo + 1234 > 5678)
+       ${cf_cv_main_return:-return}(foo);
+#endif
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15189: \"$ac_link\"") >&5
+if { (eval echo "$as_me:15722: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15192: \$? = $ac_status" >&5
+  echo "$as_me:15725: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15195: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15728: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15198: \$? = $ac_status" >&5
+  echo "$as_me:15731: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_util_openpty=yes
+  cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_lib_util_openpty=no
+cf_result=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:15209: result: $ac_cv_lib_util_openpty" >&5
-echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6
-if test $ac_cv_lib_util_openpty = yes; then
-  cf_cv_lib_util=yes
-else
-  cf_cv_lib_util=no
+               fi
+               eval 'cf_cv_func_'$cf_func'=$cf_result'
+
 fi
 
-echo "$as_me:15217: checking for openpty header" >&5
-echo $ECHO_N "checking for openpty header... $ECHO_C" >&6
-if test "${cf_cv_func_openpty+set}" = set; then
+       # use the computed/retrieved cache-value:
+       eval 'cf_result=$cf_cv_func_'$cf_func
+       echo "$as_me:15747: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+       if test $cf_result != no; then
+               cat >>confdefs.h <<EOF
+#define HAVE_${cf_tr_func} 1
+EOF
+
+       fi
+done
+
+for cf_func in tputs
+do
+
+cf_tr_func=`echo "$cf_func" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+       echo "$as_me:15762: checking for ${cf_func}" >&5
+echo $ECHO_N "checking for ${cf_func}... $ECHO_C" >&6
+
+echo "${as_me:-configure}:15765: testing ${cf_func} ..." 1>&5
+
+       if eval "test \"\${cf_cv_func_$cf_func+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-       cf_save_LIBS="$LIBS"
-       test $cf_cv_lib_util = yes && {
-cf_add_libs="-lutil"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
-               fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
- }
-       for cf_header in pty.h libutil.h util.h
-       do
-       cat >conftest.$ac_ext <<_ACEOF
-#line 15244 "configure"
+               eval cf_result='$ac_cv_func_'$cf_func
+               if test ".$cf_result" != ".no"; then
+                       cat >conftest.$ac_ext <<_ACEOF
+#line 15774 "configure"
 #include "confdefs.h"
 
-#include <$cf_header>
+#ifdef HAVE_XCURSES
+#include <xcurses.h>
+char * XCursesProgramName = "test";
+#else
+#include <${cf_cv_ncurses_header:-curses.h}>
+#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
+#include <ncursesw/term.h>
+#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
+#include <ncurses/term.h>
+#elif defined(HAVE_TERM_H)
+#include <term.h>
+#endif
+#endif
 
 int
-main ()
+main (void)
 {
 
-       int x = openpty((int *)0, (int *)0, (char *)0,
-                                  (struct termios *)0, (struct winsize *)0);
+#ifndef ${cf_func}
+long foo = (long)(&${cf_func});
+fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
+if (foo + 1234 > 5678)
+       ${cf_cv_main_return:-return}(foo);
+#endif
 
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15261: \"$ac_link\"") >&5
+if { (eval echo "$as_me:15807: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15264: \$? = $ac_status" >&5
+  echo "$as_me:15810: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15267: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15813: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15270: \$? = $ac_status" >&5
+  echo "$as_me:15816: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-               cf_cv_func_openpty=$cf_header
-               break
-
+  cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-
-               cf_cv_func_openpty=no
-
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-       done
-       LIBS="$cf_save_LIBS"
-
-fi
-echo "$as_me:15288: result: $cf_cv_func_openpty" >&5
-echo "${ECHO_T}$cf_cv_func_openpty" >&6
-
-if test "$cf_cv_func_openpty" != no ; then
-
-cat >>confdefs.h <<EOF
-#define USE_OPENPTY_HEADER <$cf_cv_func_openpty>
-EOF
-
-cat >>confdefs.h <<\EOF
-#define USE_XTERM_PTY 1
-EOF
-
-       if test "x$cf_cv_lib_util" = xyes ; then
-
-cf_add_libs="-lutil"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $TEST_LIBS
-do
-       for cf_add_2lib in $cf_add_libs
-       do
-               if test "x$cf_add_1lib" = "x$cf_add_2lib"
-               then
-                       cf_add_1lib=
-                       break
+cf_result=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
                fi
-       done
-       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-TEST_LIBS="$cf_add_libs"
+               eval 'cf_cv_func_'$cf_func'=$cf_result'
 
-       fi
 fi
 
-echo "$as_me:15322: checking for function curses_version" >&5
-echo $ECHO_N "checking for function curses_version... $ECHO_C" >&6
-if test "${cf_cv_func_curses_version+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+       # use the computed/retrieved cache-value:
+       eval 'cf_result=$cf_cv_func_'$cf_func
+       echo "$as_me:15832: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+       if test $cf_result != no; then
+               cat >>confdefs.h <<EOF
+#define HAVE_${cf_tr_func} 1
+EOF
 
-if test "$cross_compiling" = yes; then
-  cf_cv_func_curses_version=unknown
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 15332 "configure"
+       fi
+done
+
+if test x$cf_cv_func_tputs = xyes
+then
+       cf_done=no
+       for cf_arg in int char
+       do
+               for cf_ret in int void
+               do
+                       if test $cf_ret = void
+                       then
+                               cf_return="/* nothing */"
+                       else
+                               cf_return="return value"
+                       fi
+                       cat >conftest.$ac_ext <<_ACEOF
+#line 15856 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
-int main()
+#include <$cf_cv_term_header>
+
+static $cf_ret outc($cf_arg value) { $cf_return; }
+
+int
+main (void)
 {
-       char temp[1024];
-       sprintf(temp, "%s\n", curses_version());
+
+       tputs("hello", 0, outc);
        ${cf_cv_main_return:-return}(0);
-}
 
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:15345: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:15876: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15348: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:15350: \"$ac_try\"") >&5
+  echo "$as_me:15879: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:15882: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15353: \$? = $ac_status" >&5
+  echo "$as_me:15885: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_func_curses_version=yes
+
+               test -n "$verbose" && echo "    prototype $cf_ret func($cf_arg value)" 1>&6
+
+echo "${as_me:-configure}:15890: testing prototype $cf_ret func($cf_arg value) ..." 1>&5
+
+               cat >>confdefs.h <<EOF
+#define TPUTS_ARG               $cf_arg
+#define TPUTS_PROTO(func,value) $cf_ret func(TPUTS_ARG value)
+#define TPUTS_RETURN(value)     $cf_return
+EOF
+               cf_done=yes
+               break
 
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_func_curses_version=no
-
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-rm -f core
+rm -f conftest.$ac_objext conftest.$ac_ext
+               done
+               test $cf_done = yes && break
+       done
 fi
-echo "$as_me:15368: result: $cf_cv_func_curses_version" >&5
-echo "${ECHO_T}$cf_cv_func_curses_version" >&6
-test "$cf_cv_func_curses_version" = yes &&
-cat >>confdefs.h <<\EOF
-#define HAVE_CURSES_VERSION 1
-EOF
 
-echo "$as_me:15375: checking for alternate character set array" >&5
-echo $ECHO_N "checking for alternate character set array... $ECHO_C" >&6
-if test "${cf_cv_curses_acs_map+set}" = set; then
+echo "$as_me:15910: checking for ncurses extended functions" >&5
+echo $ECHO_N "checking for ncurses extended functions... $ECHO_C" >&6
+if test "${cf_cv_ncurses_ext_funcs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cf_cv_curses_acs_map=unknown
-for name in acs_map _acs_map __acs_map ${NCURSES_WRAP_PREFIX}acs_map
-do
 cat >conftest.$ac_ext <<_ACEOF
-#line 15385 "configure"
+#line 15917 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
-
 int
-main ()
+main (void)
 {
 
-$name['k'] = ACS_PLUS
+int x = NCURSES_EXT_FUNCS
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15401: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:15932: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15404: \$? = $ac_status" >&5
+  echo "$as_me:15935: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15407: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:15938: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15410: \$? = $ac_status" >&5
+  echo "$as_me:15941: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_curses_acs_map=$name; break
+  cf_cv_ncurses_ext_funcs=defined
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-done
-
-fi
-echo "$as_me:15421: result: $cf_cv_curses_acs_map" >&5
-echo "${ECHO_T}$cf_cv_curses_acs_map" >&6
-
-test "$cf_cv_curses_acs_map" != unknown &&
-cat >>confdefs.h <<EOF
-#define CURSES_ACS_ARRAY $cf_cv_curses_acs_map
-EOF
-
-if test "$cf_enable_widec" = yes; then
-
-echo "$as_me:15431: checking for wide alternate character set array" >&5
-echo $ECHO_N "checking for wide alternate character set array... $ECHO_C" >&6
-if test "${cf_cv_curses_wacs_map+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
 
-       cf_cv_curses_wacs_map=unknown
-       for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
-       do
-       cat >conftest.$ac_ext <<_ACEOF
-#line 15441 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 15949 "configure"
 #include "confdefs.h"
 
-#ifndef _XOPEN_SOURCE_EXTENDED
-#define _XOPEN_SOURCE_EXTENDED
-#endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-void *foo = &($name['k'])
+
+       (void) assume_default_colors (0, 0);
+       (void) curses_version ();
+       (void) define_key (0, 0);
+       (void) is_term_resized (0, 0);
+       (void) key_defined (0);
+       (void) keybound (0, 0);
+       (void) keyok (0, 0);
+       (void) resize_term (0, 0);
+       (void) resizeterm (0, 0);
+       (void) use_default_colors ();
+       (void) use_extended_names (0);
+       (void) wresize (0, 0, 0);
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15457: \"$ac_link\"") >&5
+if { (eval echo "$as_me:15974: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15460: \$? = $ac_status" >&5
+  echo "$as_me:15977: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15463: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15980: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15466: \$? = $ac_status" >&5
+  echo "$as_me:15983: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_curses_wacs_map=$name
-        break
+  cf_cv_ncurses_ext_funcs=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+cf_cv_ncurses_ext_funcs=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-       done
+
 fi
-echo "$as_me:15477: result: $cf_cv_curses_wacs_map" >&5
-echo "${ECHO_T}$cf_cv_curses_wacs_map" >&6
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-test "$cf_cv_curses_wacs_map" != unknown &&
-cat >>confdefs.h <<EOF
-#define CURSES_WACS_ARRAY $cf_cv_curses_wacs_map
+fi
+echo "$as_me:15997: result: $cf_cv_ncurses_ext_funcs" >&5
+echo "${ECHO_T}$cf_cv_ncurses_ext_funcs" >&6
+test "$cf_cv_ncurses_ext_funcs" = yes &&
+cat >>confdefs.h <<\EOF
+#define NCURSES_EXT_FUNCS 1
 EOF
 
-echo "$as_me:15485: checking for wide alternate character constants" >&5
-echo $ECHO_N "checking for wide alternate character constants... $ECHO_C" >&6
-if test "${cf_cv_curses_wacs_symbols+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-cf_cv_curses_wacs_symbols=no
-if test "$cf_cv_curses_wacs_map" != unknown
+if test "$cf_enable_widec" = yes
 then
-       cat >conftest.$ac_ext <<_ACEOF
-#line 15495 "configure"
+       # workaround for systems with ncurses before 20111029, due to change of
+       # feature test macro from _XPG5 to _XOPEN_SOURCE
+       if test -n "$cf_cv_ncurses_version" && test "x$cf_cv_ncurses_version" != xno
+       then
+               cf_define_xpg5=no
+               echo "$as_me:16011: checking if _XPG5 should be defined to enable wide-characters" >&5
+echo $ECHO_N "checking if _XPG5 should be defined to enable wide-characters... $ECHO_C" >&6
+
+               cat >conftest.$ac_ext <<_ACEOF
+#line 16015 "configure"
 #include "confdefs.h"
 
-#ifndef _XOPEN_SOURCE_EXTENDED
-#define _XOPEN_SOURCE_EXTENDED
-#endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-cchar_t *foo = WACS_PLUS;
-        $cf_cv_curses_wacs_map['k'] = *WACS_PLUS
+int x = _XPG5
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15512: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:16028: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15515: \$? = $ac_status" >&5
+  echo "$as_me:16031: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15518: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:16034: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15521: \$? = $ac_status" >&5
+  echo "$as_me:16037: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_curses_wacs_symbols=yes
+  :
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-else
-       cat >conftest.$ac_ext <<_ACEOF
-#line 15531 "configure"
+cf_save_cppflags="$CPPFLAGS"
+                        CPPFLAGS="$CPPFLAGS -D_XPG5"
+                        cat >conftest.$ac_ext <<_ACEOF
+#line 16046 "configure"
 #include "confdefs.h"
 
-#ifndef _XOPEN_SOURCE_EXTENDED
-#define _XOPEN_SOURCE_EXTENDED
-#endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-cchar_t *foo = WACS_PLUS
+int x = _XPG5
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15547: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:16059: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15550: \$? = $ac_status" >&5
+  echo "$as_me:16062: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15553: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:16065: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15556: \$? = $ac_status" >&5
+  echo "$as_me:16068: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_curses_wacs_symbols=yes
+  cf_define_xpg5=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-
+rm -f conftest.$ac_objext conftest.$ac_ext
+                        CPPFLAGS="$cf_save_cppflags"
 fi
-echo "$as_me:15567: result: $cf_cv_curses_wacs_symbols" >&5
-echo "${ECHO_T}$cf_cv_curses_wacs_symbols" >&6
+rm -f conftest.$ac_objext conftest.$ac_ext
+               echo "$as_me:16079: result: $cf_define_xpg5" >&5
+echo "${ECHO_T}$cf_define_xpg5" >&6
 
-test "$cf_cv_curses_wacs_symbols" != no &&
-cat >>confdefs.h <<\EOF
-#define CURSES_WACS_SYMBOLS 1
-EOF
+               if test "$cf_define_xpg5" = yes
+               then
+                       CPPFLAGS="$CPPFLAGS -D_XPG5"
+               fi
+       fi
 
-fi
+       echo "$as_me:16088: checking for wide-character functions" >&5
+echo $ECHO_N "checking for wide-character functions... $ECHO_C" >&6
+if test "${cf_cv_widechar_funcs+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-echo "$as_me:15577: checking for type attr_t in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for type attr_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 15580 "configure"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 16095 "configure"
 #include "confdefs.h"
 
-#ifndef _XOPEN_SOURCE_EXTENDED
-#define _XOPEN_SOURCE_EXTENDED
-#endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
-attr_t foo
+               static wchar_t src_wchar[2];
+               static cchar_t dst_cchar;
+               setcchar(&dst_cchar, src_wchar, A_NORMAL, 0, (void *) 0);
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15598: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:16112: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15601: \$? = $ac_status" >&5
+  echo "$as_me:16115: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15604: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:16118: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15607: \$? = $ac_status" >&5
+  echo "$as_me:16121: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_widechar_funcs=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
+cf_cv_widechar_funcs=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:15616: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-if test $cf_result = yes ; then
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
-cf_result=`echo "have_type_attr_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+fi
+echo "$as_me:16132: result: $cf_cv_widechar_funcs" >&5
+echo "${ECHO_T}$cf_cv_widechar_funcs" >&6
+       if test "$cf_cv_widechar_funcs" != no ; then
 
-cat >>confdefs.h <<EOF
-#define $cf_result 1
+cat >>confdefs.h <<\EOF
+#define USE_WIDEC_SUPPORT 1
 EOF
 
-else
+       else
+               cat >>confdefs.h <<\EOF
+#define USE_WIDEC_SUPPORT 0
+EOF
 
-cat >>confdefs.h <<EOF
-#define attr_t long
+       fi
+else
+       cat >>confdefs.h <<\EOF
+#define USE_WIDEC_SUPPORT 0
 EOF
 
 fi
 
-if test "$cf_enable_widec" = yes; then
-
-# This is needed on Tru64 5.0 to declare mbstate_t
-echo "$as_me:15637: checking if we must include wchar.h to declare mbstate_t" >&5
-echo $ECHO_N "checking if we must include wchar.h to declare mbstate_t... $ECHO_C" >&6
-if test "${cf_cv_mbstate_t+set}" = set; then
+echo "$as_me:16153: checking if $cf_cv_screen library uses pthreads" >&5
+echo $ECHO_N "checking if $cf_cv_screen library uses pthreads... $ECHO_C" >&6
+if test "${cf_cv_use_pthreads+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 15644 "configure"
+#line 16160 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
+#include <${cf_cv_ncurses_header:-curses.h}>
+extern void _nc_init_pthreads(void);
+
 int
-main ()
+main (void)
 {
-mbstate_t state
+
+       initscr();
+       _nc_init_pthreads();
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15662: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:16178: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15665: \$? = $ac_status" >&5
+  echo "$as_me:16181: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15668: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:16184: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15671: \$? = $ac_status" >&5
+  echo "$as_me:16187: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_mbstate_t=no
+  cf_cv_use_pthreads=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+cf_cv_use_pthreads=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:16198: result: $cf_cv_use_pthreads" >&5
+echo "${ECHO_T}$cf_cv_use_pthreads" >&6
+test $cf_cv_use_pthreads = yes && cat >>confdefs.h <<\EOF
+#define USE_PTHREADS 1
+EOF
+
+echo "$as_me:16204: checking if sys/time.h works with sys/select.h" >&5
+echo $ECHO_N "checking if sys/time.h works with sys/select.h... $ECHO_C" >&6
+if test "${cf_cv_sys_time_select+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
 cat >conftest.$ac_ext <<_ACEOF
-#line 15678 "configure"
+#line 16211 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
 #endif
+
 int
-main ()
+main (void)
 {
-mbstate_t value
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15697: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:16231: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15700: \$? = $ac_status" >&5
+  echo "$as_me:16234: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15703: \"$ac_try\"") >&5
+  { (eval echo "$as_me:16237: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15706: \$? = $ac_status" >&5
+  echo "$as_me:16240: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_mbstate_t=yes
+  cf_cv_sys_time_select=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_mbstate_t=unknown
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+cf_cv_sys_time_select=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:15718: result: $cf_cv_mbstate_t" >&5
-echo "${ECHO_T}$cf_cv_mbstate_t" >&6
 
-if test "$cf_cv_mbstate_t" = yes ; then
+fi
 
+echo "$as_me:16252: result: $cf_cv_sys_time_select" >&5
+echo "${ECHO_T}$cf_cv_sys_time_select" >&6
+test "$cf_cv_sys_time_select" = yes &&
 cat >>confdefs.h <<\EOF
-#define NEED_WCHAR_H 1
+#define HAVE_SYS_TIME_SELECT 1
 EOF
 
-       NEED_WCHAR_H=1
-fi
-
-# if we do not find mbstate_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_mbstate_t" = unknown ; then
-       NCURSES_MBSTATE_T=1
-fi
-
-# if we find mbstate_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_mbstate_t" != unknown ; then
-       NCURSES_OK_MBSTATE_T=1
-fi
+# special check for test/ditto.c
 
-# This is needed on Tru64 5.0 to declare wchar_t
-echo "$as_me:15741: checking if we must include wchar.h to declare wchar_t" >&5
-echo $ECHO_N "checking if we must include wchar.h to declare wchar_t... $ECHO_C" >&6
-if test "${cf_cv_wchar_t+set}" = set; then
+echo "$as_me:16261: checking for openpty in -lutil" >&5
+echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6
+if test "${ac_cv_lib_util_openpty+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lutil  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 15748 "configure"
+#line 16269 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
 #endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char openpty ();
 int
-main ()
+main (void)
 {
-wchar_t state
+openpty ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15766: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:16288: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15769: \$? = $ac_status" >&5
+  echo "$as_me:16291: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15772: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:16294: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15775: \$? = $ac_status" >&5
+  echo "$as_me:16297: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_wchar_t=no
+  ac_cv_lib_util_openpty=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 15782 "configure"
+ac_cv_lib_util_openpty=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:16308: result: $ac_cv_lib_util_openpty" >&5
+echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6
+if test $ac_cv_lib_util_openpty = yes; then
+  cf_cv_lib_util=yes
+else
+  cf_cv_lib_util=no
+fi
+
+echo "$as_me:16316: checking for openpty header" >&5
+echo $ECHO_N "checking for openpty header... $ECHO_C" >&6
+if test "${cf_cv_func_openpty+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cf_save_LIBS="$LIBS"
+       test $cf_cv_lib_util = yes && {
+cf_add_libs="-lutil"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+LIBS="$cf_add_libs"
+ }
+       for cf_header in pty.h libutil.h util.h
+       do
+       cat >conftest.$ac_ext <<_ACEOF
+#line 16343 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
+#include <$cf_header>
+
 int
-main ()
+main (void)
 {
-wchar_t value
+
+       int x = openpty((int *)0, (int *)0, (char *)0,
+                                  (struct termios *)0, (struct winsize *)0);
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15801: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:16360: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15804: \$? = $ac_status" >&5
+  echo "$as_me:16363: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15807: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:16366: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15810: \$? = $ac_status" >&5
+  echo "$as_me:16369: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_wchar_t=yes
+
+               cf_cv_func_openpty=$cf_header
+               break
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_wchar_t=unknown
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+
+               cf_cv_func_openpty=no
+
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       done
+       LIBS="$cf_save_LIBS"
+
 fi
-echo "$as_me:15822: result: $cf_cv_wchar_t" >&5
-echo "${ECHO_T}$cf_cv_wchar_t" >&6
+echo "$as_me:16387: result: $cf_cv_func_openpty" >&5
+echo "${ECHO_T}$cf_cv_func_openpty" >&6
 
-if test "$cf_cv_wchar_t" = yes ; then
+if test "$cf_cv_func_openpty" != no ; then
 
-cat >>confdefs.h <<\EOF
-#define NEED_WCHAR_H 1
+cat >>confdefs.h <<EOF
+#define USE_OPENPTY_HEADER <$cf_cv_func_openpty>
 EOF
 
-       NEED_WCHAR_H=1
-fi
+cat >>confdefs.h <<\EOF
+#define USE_XTERM_PTY 1
+EOF
 
-# if we do not find wchar_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_wchar_t" = unknown ; then
-       NCURSES_WCHAR_T=1
-fi
+       if test "x$cf_cv_lib_util" = xyes ; then
 
-# if we find wchar_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_wchar_t" != unknown ; then
-       NCURSES_OK_WCHAR_T=1
-fi
+cf_add_libs="-lutil"
+# Filter out duplicates - this happens with badly-designed ".pc" files...
+for cf_add_1lib in $TEST_LIBS
+do
+       for cf_add_2lib in $cf_add_libs
+       do
+               if test "x$cf_add_1lib" = "x$cf_add_2lib"
+               then
+                       cf_add_1lib=
+                       break
+               fi
+       done
+       test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+done
+TEST_LIBS="$cf_add_libs"
 
-# This is needed on Tru64 5.0 to declare wint_t
-echo "$as_me:15845: checking if we must include wchar.h to declare wint_t" >&5
-echo $ECHO_N "checking if we must include wchar.h to declare wint_t... $ECHO_C" >&6
-if test "${cf_cv_wint_t+set}" = set; then
+       fi
+fi
+
+echo "$as_me:16421: checking for function curses_version" >&5
+echo $ECHO_N "checking for function curses_version... $ECHO_C" >&6
+if test "${cf_cv_func_curses_version+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 15852 "configure"
+if test "$cross_compiling" = yes; then
+  cf_cv_func_curses_version=unknown
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 16431 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
-int
-main ()
+#include <${cf_cv_ncurses_header:-curses.h}>
+int main(void)
 {
-wint_t state
-  ;
-  return 0;
+       char temp[1024];
+       sprintf(temp, "%s\n", curses_version());
+       ${cf_cv_main_return:-return}(0);
 }
+
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15870: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:16444: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15873: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15876: \"$ac_try\"") >&5
+  echo "$as_me:16447: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:16449: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15879: \$? = $ac_status" >&5
+  echo "$as_me:16452: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_wint_t=no
+  cf_cv_func_curses_version=yes
+
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
+cf_cv_func_curses_version=no
+
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core
+fi
+echo "$as_me:16467: result: $cf_cv_func_curses_version" >&5
+echo "${ECHO_T}$cf_cv_func_curses_version" >&6
+test "$cf_cv_func_curses_version" = yes &&
+cat >>confdefs.h <<\EOF
+#define HAVE_CURSES_VERSION 1
+EOF
+
+echo "$as_me:16474: checking for alternate character set array" >&5
+echo $ECHO_N "checking for alternate character set array... $ECHO_C" >&6
+if test "${cf_cv_curses_acs_map+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_cv_curses_acs_map=unknown
+for name in acs_map _acs_map __acs_map ${NCURSES_WRAP_PREFIX}acs_map
+do
 cat >conftest.$ac_ext <<_ACEOF
-#line 15886 "configure"
+#line 16484 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
+#include <${cf_cv_ncurses_header:-curses.h}>
+
 int
-main ()
+main (void)
 {
-wint_t value
+
+$name['k'] = ACS_PLUS
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15905: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:16500: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15908: \$? = $ac_status" >&5
+  echo "$as_me:16503: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15911: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:16506: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15914: \$? = $ac_status" >&5
+  echo "$as_me:16509: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_wint_t=yes
+  cf_cv_curses_acs_map=$name; break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_wint_t=unknown
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:15926: result: $cf_cv_wint_t" >&5
-echo "${ECHO_T}$cf_cv_wint_t" >&6
-
-if test "$cf_cv_wint_t" = yes ; then
-
-cat >>confdefs.h <<\EOF
-#define NEED_WCHAR_H 1
-EOF
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+done
 
-       NEED_WCHAR_H=1
 fi
+echo "$as_me:16520: result: $cf_cv_curses_acs_map" >&5
+echo "${ECHO_T}$cf_cv_curses_acs_map" >&6
 
-# if we do not find wint_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_wint_t" = unknown ; then
-       NCURSES_WINT_T=1
-fi
+test "$cf_cv_curses_acs_map" != unknown &&
+cat >>confdefs.h <<EOF
+#define CURSES_ACS_ARRAY $cf_cv_curses_acs_map
+EOF
 
-# if we find wint_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_wint_t" != unknown ; then
-       NCURSES_OK_WINT_T=1
-fi
+if test "$cf_enable_widec" = yes; then
 
-       if test "$NCURSES_OK_MBSTATE_T" = 0 ; then
+echo "$as_me:16530: checking for wide alternate character set array" >&5
+echo $ECHO_N "checking for wide alternate character set array... $ECHO_C" >&6
+if test "${cf_cv_curses_wacs_map+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-echo "$as_me:15950: checking for type mbstate_t in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for type mbstate_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 15953 "configure"
+       cf_cv_curses_wacs_map=unknown
+       for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
+       do
+       cat >conftest.$ac_ext <<_ACEOF
+#line 16540 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -15958,60 +16545,53 @@ cat >conftest.$ac_ext <<_ACEOF
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-
-mbstate_t foo
-
+void *foo = &($name['k'])
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15971: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:16556: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15974: \$? = $ac_status" >&5
+  echo "$as_me:16559: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15977: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:16562: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15980: \$? = $ac_status" >&5
+  echo "$as_me:16565: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_curses_wacs_map=$name
+        break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:15989: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-if test $cf_result = yes ; then
-
-cf_result=`echo "have_type_mbstate_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       done
+fi
+echo "$as_me:16576: result: $cf_cv_curses_wacs_map" >&5
+echo "${ECHO_T}$cf_cv_curses_wacs_map" >&6
 
+test "$cf_cv_curses_wacs_map" != unknown &&
 cat >>confdefs.h <<EOF
-#define $cf_result 1
+#define CURSES_WACS_ARRAY $cf_cv_curses_wacs_map
 EOF
 
+echo "$as_me:16584: checking for wide alternate character constants" >&5
+echo $ECHO_N "checking for wide alternate character constants... $ECHO_C" >&6
+if test "${cf_cv_curses_wacs_symbols+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >>confdefs.h <<EOF
-#define mbstate_t long
-EOF
-
-fi
-
-       fi
-
-       if test "$NCURSES_OK_WCHAR_T" = 0 ; then
-
-echo "$as_me:16011: checking for type wchar_t in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for type wchar_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 16014 "configure"
+cf_cv_curses_wacs_symbols=no
+if test "$cf_cv_curses_wacs_map" != unknown
+then
+       cat >conftest.$ac_ext <<_ACEOF
+#line 16594 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -16019,60 +16599,35 @@ cat >conftest.$ac_ext <<_ACEOF
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-
-wchar_t foo
-
+cchar_t *foo = WACS_PLUS;
+        $cf_cv_curses_wacs_map['k'] = *WACS_PLUS
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16032: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:16611: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:16035: \$? = $ac_status" >&5
+  echo "$as_me:16614: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16038: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:16617: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16041: \$? = $ac_status" >&5
+  echo "$as_me:16620: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_curses_wacs_symbols=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:16050: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-if test $cf_result = yes ; then
-
-cf_result=`echo "have_type_wchar_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-cat >>confdefs.h <<EOF
-#define $cf_result 1
-EOF
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 else
-
-cat >>confdefs.h <<EOF
-#define wchar_t long
-EOF
-
-fi
-
-       fi
-
-       if test "$NCURSES_OK_WINT_T" = 0 ; then
-
-echo "$as_me:16072: checking for type wint_t in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for type wint_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 16075 "configure"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 16630 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -16080,97 +16635,75 @@ cat >conftest.$ac_ext <<_ACEOF
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-
-wint_t foo
-
+cchar_t *foo = WACS_PLUS
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16093: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:16646: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:16096: \$? = $ac_status" >&5
+  echo "$as_me:16649: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16099: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:16652: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16102: \$? = $ac_status" >&5
+  echo "$as_me:16655: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_curses_wacs_symbols=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:16111: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-if test $cf_result = yes ; then
-
-cf_result=`echo "have_type_wint_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-cat >>confdefs.h <<EOF
-#define $cf_result 1
-EOF
-
-else
-
-cat >>confdefs.h <<EOF
-#define wint_t long
-EOF
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
 
-       fi
 fi
+echo "$as_me:16666: result: $cf_cv_curses_wacs_symbols" >&5
+echo "${ECHO_T}$cf_cv_curses_wacs_symbols" >&6
 
-echo "$as_me:16132: checking for data ospeed declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for data ospeed declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-
-cat >conftest.$ac_ext <<_ACEOF
-#line 16136 "configure"
-#include "confdefs.h"
-
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
-#endif
+test "$cf_cv_curses_wacs_symbols" != no &&
+cat >>confdefs.h <<\EOF
+#define CURSES_WACS_SYMBOLS 1
+EOF
+
+fi
+
+echo "$as_me:16676: checking for type attr_t in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo $ECHO_N "checking for type attr_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 16679 "configure"
+#include "confdefs.h"
 
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
-void *foo = &(ospeed)
+attr_t foo
 
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16164: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:16697: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16167: \$? = $ac_status" >&5
+  echo "$as_me:16700: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16170: \"$ac_try\"") >&5
+  { (eval echo "$as_me:16703: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16173: \$? = $ac_status" >&5
+  echo "$as_me:16706: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_result=yes
 else
@@ -16179,360 +16712,371 @@ cat conftest.$ac_ext >&5
 cf_result=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:16182: result: $cf_result" >&5
+echo "$as_me:16715: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-
 if test $cf_result = yes ; then
 
-cf_result=`echo "have_curses_data_ospeed" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cf_result=`echo "have_type_attr_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-       cat >>confdefs.h <<EOF
+cat >>confdefs.h <<EOF
 #define $cf_result 1
 EOF
 
 else
-       echo "$as_me:16194: checking for data ospeed in library" >&5
-echo $ECHO_N "checking for data ospeed in library... $ECHO_C" >&6
-       # BSD linkers insist on making weak linkage, but resolve at runtime.
-       if test "$cross_compiling" = yes; then
 
-       # cross-compiling
-       cat >conftest.$ac_ext <<_ACEOF
-#line 16201 "configure"
+cat >>confdefs.h <<EOF
+#define attr_t long
+EOF
+
+fi
+
+if test "$cf_enable_widec" = yes; then
+
+# This is needed on Tru64 5.0 to declare mbstate_t
+echo "$as_me:16736: checking if we must include wchar.h to declare mbstate_t" >&5
+echo $ECHO_N "checking if we must include wchar.h to declare mbstate_t... $ECHO_C" >&6
+if test "${cf_cv_mbstate_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 16743 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
 #endif
-
-extern char ospeed;
 int
-main ()
+main (void)
 {
-
-       do {
-               void *foo = &(ospeed);
-               fprintf(stderr, "testing linkage of ospeed:%p\n", foo);
-               ${cf_cv_main_return:-return}(foo == 0);
-       } while (0)
-
+mbstate_t state
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:16234: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:16761: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16237: \$? = $ac_status" >&5
+  echo "$as_me:16764: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:16240: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:16767: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16243: \$? = $ac_status" >&5
+  echo "$as_me:16770: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_mbstate_t=no
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 16255 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 16777 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
 #endif
-
-extern char ospeed;
-int main(void)
+int
+main (void)
 {
-       void *foo = &(ospeed);
-       fprintf(stderr, "testing linkage of ospeed:%p\n", foo);
-       ${cf_cv_main_return:-return}(foo == 0);
+mbstate_t value
+  ;
+  return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:16281: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:16796: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16284: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:16286: \"$ac_try\"") >&5
+  echo "$as_me:16799: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:16802: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16289: \$? = $ac_status" >&5
+  echo "$as_me:16805: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_mbstate_t=yes
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
+cf_cv_mbstate_t=unknown
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-       echo "$as_me:16300: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-       if test $cf_result = yes ; then
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:16817: result: $cf_cv_mbstate_t" >&5
+echo "${ECHO_T}$cf_cv_mbstate_t" >&6
 
-cf_result=`echo "decl_curses_data_ospeed" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+if test "$cf_cv_mbstate_t" = yes ; then
 
-               cat >>confdefs.h <<EOF
-#define $cf_result 1
+cat >>confdefs.h <<\EOF
+#define NEED_WCHAR_H 1
 EOF
 
-       fi
+       NEED_WCHAR_H=1
+fi
+
+# if we do not find mbstate_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_mbstate_t" = unknown ; then
+       NCURSES_MBSTATE_T=1
+fi
+
+# if we find mbstate_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_mbstate_t" != unknown ; then
+       NCURSES_OK_MBSTATE_T=1
 fi
 
-echo "$as_me:16313: checking for data boolnames declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for data boolnames declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
+# This is needed on Tru64 5.0 to declare wchar_t
+echo "$as_me:16840: checking if we must include wchar.h to declare wchar_t" >&5
+echo $ECHO_N "checking if we must include wchar.h to declare wchar_t... $ECHO_C" >&6
+if test "${cf_cv_wchar_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 16317 "configure"
+#line 16847 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
 #endif
-
 int
-main ()
+main (void)
 {
+wchar_t state
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:16865: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:16868: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:16871: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:16874: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_wchar_t=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cat >conftest.$ac_ext <<_ACEOF
+#line 16881 "configure"
+#include "confdefs.h"
 
-void *foo = &(boolnames)
-
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
+#endif
+int
+main (void)
+{
+wchar_t value
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16345: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:16900: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16348: \$? = $ac_status" >&5
+  echo "$as_me:16903: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16351: \"$ac_try\"") >&5
+  { (eval echo "$as_me:16906: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16354: \$? = $ac_status" >&5
+  echo "$as_me:16909: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_wchar_t=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
+cf_cv_wchar_t=unknown
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:16363: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-
-if test $cf_result = yes ; then
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:16921: result: $cf_cv_wchar_t" >&5
+echo "${ECHO_T}$cf_cv_wchar_t" >&6
 
-cf_result=`echo "have_curses_data_boolnames" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+if test "$cf_cv_wchar_t" = yes ; then
 
-       cat >>confdefs.h <<EOF
-#define $cf_result 1
+cat >>confdefs.h <<\EOF
+#define NEED_WCHAR_H 1
 EOF
 
+       NEED_WCHAR_H=1
+fi
+
+# if we do not find wchar_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_wchar_t" = unknown ; then
+       NCURSES_WCHAR_T=1
+fi
+
+# if we find wchar_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_wchar_t" != unknown ; then
+       NCURSES_OK_WCHAR_T=1
+fi
+
+# This is needed on Tru64 5.0 to declare wint_t
+echo "$as_me:16944: checking if we must include wchar.h to declare wint_t" >&5
+echo $ECHO_N "checking if we must include wchar.h to declare wint_t... $ECHO_C" >&6
+if test "${cf_cv_wint_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-       echo "$as_me:16375: checking for data boolnames in library" >&5
-echo $ECHO_N "checking for data boolnames in library... $ECHO_C" >&6
-       # BSD linkers insist on making weak linkage, but resolve at runtime.
-       if test "$cross_compiling" = yes; then
 
-       # cross-compiling
-       cat >conftest.$ac_ext <<_ACEOF
-#line 16382 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 16951 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
 #endif
-
-extern char boolnames;
 int
-main ()
+main (void)
 {
-
-       do {
-               void *foo = &(boolnames);
-               fprintf(stderr, "testing linkage of boolnames:%p\n", foo);
-               ${cf_cv_main_return:-return}(foo == 0);
-       } while (0)
-
+wint_t state
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:16415: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:16969: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16418: \$? = $ac_status" >&5
+  echo "$as_me:16972: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:16421: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:16975: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16424: \$? = $ac_status" >&5
+  echo "$as_me:16978: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_wint_t=no
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 16436 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 16985 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
 #endif
-
-extern char boolnames;
-int main(void)
+int
+main (void)
 {
-       void *foo = &(boolnames);
-       fprintf(stderr, "testing linkage of boolnames:%p\n", foo);
-       ${cf_cv_main_return:-return}(foo == 0);
+wint_t value
+  ;
+  return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:16462: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:17004: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16465: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:16467: \"$ac_try\"") >&5
+  echo "$as_me:17007: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:17010: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16470: \$? = $ac_status" >&5
+  echo "$as_me:17013: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_result=yes
+  cf_cv_wint_t=yes
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_result=no
+cf_cv_wint_t=unknown
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-       echo "$as_me:16481: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-       if test $cf_result = yes ; then
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:17025: result: $cf_cv_wint_t" >&5
+echo "${ECHO_T}$cf_cv_wint_t" >&6
 
-cf_result=`echo "decl_curses_data_boolnames" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+if test "$cf_cv_wint_t" = yes ; then
 
-               cat >>confdefs.h <<EOF
-#define $cf_result 1
+cat >>confdefs.h <<\EOF
+#define NEED_WCHAR_H 1
 EOF
 
-       fi
+       NEED_WCHAR_H=1
+fi
+
+# if we do not find wint_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_wint_t" = unknown ; then
+       NCURSES_WINT_T=1
+fi
+
+# if we find wint_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_wint_t" != unknown ; then
+       NCURSES_OK_WINT_T=1
 fi
 
-echo "$as_me:16494: checking for data boolfnames declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for data boolfnames declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
+       if test "$NCURSES_OK_MBSTATE_T" = 0 ; then
 
+echo "$as_me:17049: checking for type mbstate_t in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo $ECHO_N "checking for type mbstate_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
 cat >conftest.$ac_ext <<_ACEOF
-#line 16498 "configure"
+#line 17052 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
 #endif
-
+#include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
-void *foo = &(boolfnames)
+mbstate_t foo
 
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16526: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:17070: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16529: \$? = $ac_status" >&5
+  echo "$as_me:17073: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16532: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17076: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16535: \$? = $ac_status" >&5
+  echo "$as_me:17079: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_result=yes
 else
@@ -16541,68 +17085,59 @@ cat conftest.$ac_ext >&5
 cf_result=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:16544: result: $cf_result" >&5
+echo "$as_me:17088: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-
 if test $cf_result = yes ; then
 
-cf_result=`echo "have_curses_data_boolfnames" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cf_result=`echo "have_type_mbstate_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-       cat >>confdefs.h <<EOF
+cat >>confdefs.h <<EOF
 #define $cf_result 1
 EOF
 
 else
-       echo "$as_me:16556: checking for data boolfnames in library" >&5
-echo $ECHO_N "checking for data boolfnames in library... $ECHO_C" >&6
-       # BSD linkers insist on making weak linkage, but resolve at runtime.
-       if test "$cross_compiling" = yes; then
 
-       # cross-compiling
-       cat >conftest.$ac_ext <<_ACEOF
-#line 16563 "configure"
+cat >>confdefs.h <<EOF
+#define mbstate_t long
+EOF
+
+fi
+
+       fi
+
+       if test "$NCURSES_OK_WCHAR_T" = 0 ; then
+
+echo "$as_me:17110: checking for type wchar_t in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo $ECHO_N "checking for type wchar_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 17113 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
 #endif
-
-extern char boolfnames;
+#include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
-       do {
-               void *foo = &(boolfnames);
-               fprintf(stderr, "testing linkage of boolfnames:%p\n", foo);
-               ${cf_cv_main_return:-return}(foo == 0);
-       } while (0)
+wchar_t foo
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:16596: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:17131: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16599: \$? = $ac_status" >&5
+  echo "$as_me:17134: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:16602: \"$ac_try\"") >&5
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:17137: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16605: \$? = $ac_status" >&5
+  echo "$as_me:17140: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_result=yes
 else
@@ -16610,73 +17145,101 @@ else
 cat conftest.$ac_ext >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:17149: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+if test $cf_result = yes ; then
+
+cf_result=`echo "have_type_wchar_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+cat >>confdefs.h <<EOF
+#define $cf_result 1
+EOF
 
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 16617 "configure"
+
+cat >>confdefs.h <<EOF
+#define wchar_t long
+EOF
+
+fi
+
+       fi
+
+       if test "$NCURSES_OK_WINT_T" = 0 ; then
+
+echo "$as_me:17171: checking for type wint_t in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo $ECHO_N "checking for type wint_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 17174 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
 #endif
-
-extern char boolfnames;
-int main(void)
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
 {
-       void *foo = &(boolfnames);
-       fprintf(stderr, "testing linkage of boolfnames:%p\n", foo);
-       ${cf_cv_main_return:-return}(foo == 0);
+
+wint_t foo
+
+  ;
+  return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:16643: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:17192: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16646: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:16648: \"$ac_try\"") >&5
+  echo "$as_me:17195: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:17198: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16651: \$? = $ac_status" >&5
+  echo "$as_me:17201: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_result=yes
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 cf_result=no
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-       echo "$as_me:16662: result: $cf_result" >&5
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:17210: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-       if test $cf_result = yes ; then
+if test $cf_result = yes ; then
 
-cf_result=`echo "decl_curses_data_boolfnames" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cf_result=`echo "have_type_wint_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-               cat >>confdefs.h <<EOF
+cat >>confdefs.h <<EOF
 #define $cf_result 1
 EOF
 
+else
+
+cat >>confdefs.h <<EOF
+#define wint_t long
+EOF
+
+fi
+
        fi
 fi
 
-echo "$as_me:16675: checking for data ttytype declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for data ttytype declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
+for cf_data in \
+curscr \
+ospeed \
+boolnames \
+boolfnames \
+ttytype
+do
+echo "$as_me:17238: checking for data $cf_data declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo $ECHO_N "checking for data $cf_data declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 16679 "configure"
+#line 17242 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_XCURSES
@@ -16694,54 +17257,55 @@ char * XCursesProgramName = "test";
 #endif
 
 int
-main ()
+main (void)
 {
 
-void *foo = &(ttytype)
+void *foo = &($cf_data)
 
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16707: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:17270: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16710: \$? = $ac_status" >&5
+  echo "$as_me:17273: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16713: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17276: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16716: \$? = $ac_status" >&5
+  echo "$as_me:17279: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_result=yes
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 cf_result=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:16725: result: $cf_result" >&5
+echo "$as_me:17289: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
 
 if test $cf_result = yes ; then
 
-cf_result=`echo "have_curses_data_ttytype" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cf_result=`echo "have_curses_data_$cf_data" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
        cat >>confdefs.h <<EOF
 #define $cf_result 1
 EOF
 
 else
-       echo "$as_me:16737: checking for data ttytype in library" >&5
-echo $ECHO_N "checking for data ttytype in library... $ECHO_C" >&6
+       echo "$as_me:17301: checking for data $cf_data in library" >&5
+echo $ECHO_N "checking for data $cf_data in library... $ECHO_C" >&6
        # BSD linkers insist on making weak linkage, but resolve at runtime.
        if test "$cross_compiling" = yes; then
 
        # cross-compiling
        cat >conftest.$ac_ext <<_ACEOF
-#line 16744 "configure"
+#line 17308 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_XCURSES
@@ -16758,14 +17322,14 @@ char * XCursesProgramName = "test";
 #endif
 #endif
 
-extern char ttytype;
+extern char $cf_data;
 int
-main ()
+main (void)
 {
 
        do {
-               void *foo = &(ttytype);
-               fprintf(stderr, "testing linkage of ttytype:%p\n", foo);
+               void *foo = &($cf_data);
+               fprintf(stderr, "testing linkage of $cf_data:%p\n", foo);
                ${cf_cv_main_return:-return}(foo == 0);
        } while (0)
 
@@ -16774,16 +17338,16 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:16777: \"$ac_link\"") >&5
+if { (eval echo "$as_me:17341: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:16780: \$? = $ac_status" >&5
+  echo "$as_me:17344: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:16783: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17347: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16786: \$? = $ac_status" >&5
+  echo "$as_me:17350: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_result=yes
 else
@@ -16795,7 +17359,7 @@ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 16798 "configure"
+#line 17362 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_XCURSES
@@ -16812,26 +17376,27 @@ char * XCursesProgramName = "test";
 #endif
 #endif
 
-extern char ttytype;
+extern char $cf_data;
 int main(void)
 {
-       void *foo = &(ttytype);
-       fprintf(stderr, "testing linkage of ttytype:%p\n", foo);
+       void *foo = &($cf_data);
+       fprintf(stderr, "testing linkage of $cf_data:%p\n", foo);
        ${cf_cv_main_return:-return}(foo == 0);
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:16824: \"$ac_link\"") >&5
+if { (eval echo "$as_me:17388: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:16827: \$? = $ac_status" >&5
+  echo "$as_me:17391: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:16829: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17393: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16832: \$? = $ac_status" >&5
+  echo "$as_me:17396: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_result=yes
+
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
@@ -16840,22 +17405,24 @@ cf_result=no
 fi
 rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-       echo "$as_me:16843: result: $cf_result" >&5
+       echo "$as_me:17408: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
        if test $cf_result = yes ; then
 
-cf_result=`echo "decl_curses_data_ttytype" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cf_result=`echo "decl_curses_data_$cf_data" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
                cat >>confdefs.h <<EOF
 #define $cf_result 1
 EOF
 
+               # do not exit loop here, since we prefer system's declarations
        fi
 fi
+done
 
 if ( test "$GCC" = yes || test "$GXX" = yes )
 then
-echo "$as_me:16858: checking if you want to turn on gcc warnings" >&5
+echo "$as_me:17425: checking if you want to turn on gcc warnings" >&5
 echo $ECHO_N "checking if you want to turn on gcc warnings... $ECHO_C" >&6
 
 # Check whether --enable-warnings or --disable-warnings was given.
@@ -16872,7 +17439,7 @@ else
        with_warnings=no
 
 fi;
-echo "$as_me:16875: result: $with_warnings" >&5
+echo "$as_me:17442: result: $with_warnings" >&5
 echo "${ECHO_T}$with_warnings" >&6
 if test "$with_warnings" = "yes"
 then
@@ -16895,10 +17462,10 @@ cat > conftest.i <<EOF
 EOF
 if test "$GCC" = yes
 then
-       { echo "$as_me:16898: checking for $CC __attribute__ directives..." >&5
+       { echo "$as_me:17465: checking for $CC __attribute__ directives..." >&5
 echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
 cat > conftest.$ac_ext <<EOF
-#line 16901 "${as_me:-configure}"
+#line 17468 "${as_me:-configure}"
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -16947,12 +17514,12 @@ EOF
                        ;;
                esac
 
-               if { (eval echo "$as_me:16950: \"$ac_compile\"") >&5
+               if { (eval echo "$as_me:17517: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16953: \$? = $ac_status" >&5
+  echo "$as_me:17520: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-                       test -n "$verbose" && echo "$as_me:16955: result: ... $cf_attribute" >&5
+                       test -n "$verbose" && echo "$as_me:17522: result: ... $cf_attribute" >&5
 echo "${ECHO_T}... $cf_attribute" >&6
                        cat conftest.h >>confdefs.h
                        case $cf_attribute in
@@ -17016,16 +17583,16 @@ INTEL_COMPILER=no
 if test "$GCC" = yes ; then
        case $host_os in
        (linux*|gnu*)
-               echo "$as_me:17019: checking if this is really Intel C compiler" >&5
+               echo "$as_me:17586: checking if this is really Intel C compiler" >&5
 echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6
                cf_save_CFLAGS="$CFLAGS"
                CFLAGS="$CFLAGS -no-gcc"
                cat >conftest.$ac_ext <<_ACEOF
-#line 17024 "configure"
+#line 17591 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
 #ifdef __INTEL_COMPILER
@@ -17038,16 +17605,16 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:17041: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:17608: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:17044: \$? = $ac_status" >&5
+  echo "$as_me:17611: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:17047: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17614: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17050: \$? = $ac_status" >&5
+  echo "$as_me:17617: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   INTEL_COMPILER=yes
 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
@@ -17058,7 +17625,7 @@ cat conftest.$ac_ext >&5
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
                CFLAGS="$cf_save_CFLAGS"
-               echo "$as_me:17061: result: $INTEL_COMPILER" >&5
+               echo "$as_me:17628: result: $INTEL_COMPILER" >&5
 echo "${ECHO_T}$INTEL_COMPILER" >&6
                ;;
        esac
 CLANG_COMPILER=no
 
 if test "$GCC" = yes ; then
-       echo "$as_me:17070: checking if this is really Clang C compiler" >&5
+       echo "$as_me:17637: checking if this is really Clang C compiler" >&5
 echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6
        cf_save_CFLAGS="$CFLAGS"
        CFLAGS="$CFLAGS -Qunused-arguments"
        cat >conftest.$ac_ext <<_ACEOF
-#line 17075 "configure"
+#line 17642 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
 #ifdef __clang__
@@ -17089,16 +17656,16 @@ make an error
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:17092: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:17659: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:17095: \$? = $ac_status" >&5
+  echo "$as_me:17662: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:17098: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17665: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17101: \$? = $ac_status" >&5
+  echo "$as_me:17668: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   CLANG_COMPILER=yes
 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
@@ -17109,12 +17676,12 @@ cat conftest.$ac_ext >&5
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
        CFLAGS="$cf_save_CFLAGS"
-       echo "$as_me:17112: result: $CLANG_COMPILER" >&5
+       echo "$as_me:17679: result: $CLANG_COMPILER" >&5
 echo "${ECHO_T}$CLANG_COMPILER" >&6
 fi
 
 cat > conftest.$ac_ext <<EOF
-#line 17117 "${as_me:-configure}"
+#line 17684 "${as_me:-configure}"
 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
 EOF
 
@@ -17131,7 +17698,7 @@ then
 # remark #981: operands are evaluated in unspecified order
 # warning #279: controlling expression is constant
 
-       { echo "$as_me:17134: checking for $CC warning options..." >&5
+       { echo "$as_me:17701: checking for $CC warning options..." >&5
 echo "$as_me: checking for $CC warning options..." >&6;}
        cf_save_CFLAGS="$CFLAGS"
        EXTRA_CFLAGS="-Wall"
@@ -17147,12 +17714,12 @@ echo "$as_me: checking for $CC warning options..." >&6;}
                wd981
        do
                CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-               if { (eval echo "$as_me:17150: \"$ac_compile\"") >&5
+               if { (eval echo "$as_me:17717: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:17153: \$? = $ac_status" >&5
+  echo "$as_me:17720: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-                       test -n "$verbose" && echo "$as_me:17155: result: ... -$cf_opt" >&5
+                       test -n "$verbose" && echo "$as_me:17722: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
                        EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
                fi
@@ -17161,7 +17728,7 @@ echo "${ECHO_T}... -$cf_opt" >&6
 
 elif test "$GCC" = yes
 then
-       { echo "$as_me:17164: checking for $CC warning options..." >&5
+       { echo "$as_me:17731: checking for $CC warning options..." >&5
 echo "$as_me: checking for $CC warning options..." >&6;}
        cf_save_CFLAGS="$CFLAGS"
        EXTRA_CFLAGS=
@@ -17182,15 +17749,15 @@ echo "$as_me: checking for $CC warning options..." >&6;}
                Wpointer-arith \
                Wshadow \
                Wstrict-prototypes \
-               Wundef $cf_gcc_warnings $cf_warn_CONST
+               Wundef $cf_gcc_warnings $cf_warn_CONST Wno-unknown-pragmas
        do
                CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-               if { (eval echo "$as_me:17188: \"$ac_compile\"") >&5
+               if { (eval echo "$as_me:17755: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:17191: \$? = $ac_status" >&5
+  echo "$as_me:17758: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-                       test -n "$verbose" && echo "$as_me:17193: result: ... -$cf_opt" >&5
+                       test -n "$verbose" && echo "$as_me:17760: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
                        case $cf_opt in
                        (Wcast-qual)
@@ -17201,7 +17768,7 @@ echo "${ECHO_T}... -$cf_opt" >&6
                                ([34].*)
                                        test -n "$verbose" && echo "    feature is broken in gcc $GCC_VERSION" 1>&6
 
-echo "${as_me:-configure}:17204: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
+echo "${as_me:-configure}:17771: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
 
                                        continue;;
                                esac
@@ -17211,7 +17778,7 @@ echo "${as_me:-configure}:17204: testing feature is broken in gcc $GCC_VERSION .
                                ([12].*)
                                        test -n "$verbose" && echo "    feature is broken in gcc $GCC_VERSION" 1>&6
 
-echo "${as_me:-configure}:17214: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
+echo "${as_me:-configure}:17781: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
 
                                        continue;;
                                esac
@@ -17227,7 +17794,7 @@ rm -rf conftest*
 fi
 fi
 
-echo "$as_me:17230: checking if you want to use dmalloc for testing" >&5
+echo "$as_me:17797: checking if you want to use dmalloc for testing" >&5
 echo $ECHO_N "checking if you want to use dmalloc for testing... $ECHO_C" >&6
 
 # Check whether --with-dmalloc or --without-dmalloc was given.
@@ -17244,7 +17811,7 @@ EOF
 else
   with_dmalloc=
 fi;
-echo "$as_me:17247: result: ${with_dmalloc:-no}" >&5
+echo "$as_me:17814: result: ${with_dmalloc:-no}" >&5
 echo "${ECHO_T}${with_dmalloc:-no}" >&6
 
 case .$with_cflags in
@@ -17274,10 +17841,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -17296,17 +17869,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -17319,17 +17900,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
                ;;
 esac
 
 if test "$with_dmalloc" = yes ; then
-       echo "$as_me:17341: checking for dmalloc.h" >&5
+       echo "$as_me:17928: checking for dmalloc.h" >&5
 echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
 if test "${ac_cv_header_dmalloc_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 17347 "configure"
+#line 17934 "configure"
 #include "confdefs.h"
 #include <dmalloc.h>
 _ACEOF
-if { (eval echo "$as_me:17351: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:17938: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:17357: \$? = $ac_status" >&5
+  echo "$as_me:17944: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -17373,11 +17960,11 @@ else
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:17376: result: $ac_cv_header_dmalloc_h" >&5
+echo "$as_me:17963: result: $ac_cv_header_dmalloc_h" >&5
 echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
 if test $ac_cv_header_dmalloc_h = yes; then
 
-echo "$as_me:17380: checking for dmalloc_debug in -ldmalloc" >&5
+echo "$as_me:17967: checking for dmalloc_debug in -ldmalloc" >&5
 echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6
 if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -17385,7 +17972,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldmalloc  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 17388 "configure"
+#line 17975 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -17396,7 +17983,7 @@ extern "C"
    builtin and then its argument prototype would still apply.  */
 char dmalloc_debug ();
 int
-main ()
+main (void)
 {
 dmalloc_debug ();
   ;
@@ -17404,16 +17991,16 @@ dmalloc_debug ();
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:17407: \"$ac_link\"") >&5
+if { (eval echo "$as_me:17994: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17410: \$? = $ac_status" >&5
+  echo "$as_me:17997: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:17413: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18000: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17416: \$? = $ac_status" >&5
+  echo "$as_me:18003: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_dmalloc_dmalloc_debug=yes
 else
@@ -17424,7 +18011,7 @@ fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:17427: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
+echo "$as_me:18014: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
 echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6
 if test $ac_cv_lib_dmalloc_dmalloc_debug = yes; then
   cat >>confdefs.h <<EOF
@@ -17439,7 +18026,7 @@ fi
 
 fi
 
-echo "$as_me:17442: checking if you want to use dbmalloc for testing" >&5
+echo "$as_me:18029: checking if you want to use dbmalloc for testing" >&5
 echo $ECHO_N "checking if you want to use dbmalloc for testing... $ECHO_C" >&6
 
 # Check whether --with-dbmalloc or --without-dbmalloc was given.
@@ -17456,7 +18043,7 @@ EOF
 else
   with_dbmalloc=
 fi;
-echo "$as_me:17459: result: ${with_dbmalloc:-no}" >&5
+echo "$as_me:18046: result: ${with_dbmalloc:-no}" >&5
 echo "${ECHO_T}${with_dbmalloc:-no}" >&6
 
 case .$with_cflags in
@@ -17486,10 +18073,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -17508,17 +18101,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -17531,17 +18132,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
                ;;
 esac
 
 if test "$with_dbmalloc" = yes ; then
-       echo "$as_me:17553: checking for dbmalloc.h" >&5
+       echo "$as_me:18160: checking for dbmalloc.h" >&5
 echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6
 if test "${ac_cv_header_dbmalloc_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 17559 "configure"
+#line 18166 "configure"
 #include "confdefs.h"
 #include <dbmalloc.h>
 _ACEOF
-if { (eval echo "$as_me:17563: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:18170: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:17569: \$? = $ac_status" >&5
+  echo "$as_me:18176: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -17585,11 +18192,11 @@ else
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:17588: result: $ac_cv_header_dbmalloc_h" >&5
+echo "$as_me:18195: result: $ac_cv_header_dbmalloc_h" >&5
 echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6
 if test $ac_cv_header_dbmalloc_h = yes; then
 
-echo "$as_me:17592: checking for debug_malloc in -ldbmalloc" >&5
+echo "$as_me:18199: checking for debug_malloc in -ldbmalloc" >&5
 echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6
 if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -17597,7 +18204,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldbmalloc  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 17600 "configure"
+#line 18207 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -17608,7 +18215,7 @@ extern "C"
    builtin and then its argument prototype would still apply.  */
 char debug_malloc ();
 int
-main ()
+main (void)
 {
 debug_malloc ();
   ;
@@ -17616,16 +18223,16 @@ debug_malloc ();
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:17619: \"$ac_link\"") >&5
+if { (eval echo "$as_me:18226: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17622: \$? = $ac_status" >&5
+  echo "$as_me:18229: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:17625: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18232: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17628: \$? = $ac_status" >&5
+  echo "$as_me:18235: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_dbmalloc_debug_malloc=yes
 else
@@ -17636,7 +18243,7 @@ fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:17639: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
+echo "$as_me:18246: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
 echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6
 if test $ac_cv_lib_dbmalloc_debug_malloc = yes; then
   cat >>confdefs.h <<EOF
@@ -17651,7 +18258,7 @@ fi
 
 fi
 
-echo "$as_me:17654: checking if you want to use valgrind for testing" >&5
+echo "$as_me:18261: checking if you want to use valgrind for testing" >&5
 echo $ECHO_N "checking if you want to use valgrind for testing... $ECHO_C" >&6
 
 # Check whether --with-valgrind or --without-valgrind was given.
@@ -17668,7 +18275,7 @@ EOF
 else
   with_valgrind=
 fi;
-echo "$as_me:17671: result: ${with_valgrind:-no}" >&5
+echo "$as_me:18278: result: ${with_valgrind:-no}" >&5
 echo "${ECHO_T}${with_valgrind:-no}" >&6
 
 case .$with_cflags in
@@ -17698,10 +18305,16 @@ case $cf_fix_cppflags in
                                && cf_fix_cppflags=yes
 
                        if test $cf_fix_cppflags = yes ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        elif test "${cf_tst_cflags}" = "\"'" ; then
-                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
                                continue
                        fi
                        ;;
@@ -17720,17 +18333,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
                                ;;
                        esac
-                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+       cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
                        ;;
                esac
                ;;
        (*)
-               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+       test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+       cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
                ;;
        esac
        ;;
 (yes)
-       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+       cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
 
        cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
 
@@ -17743,17 +18364,23 @@ done
 
 if test -n "$cf_new_cflags" ; then
 
-       CFLAGS="$CFLAGS $cf_new_cflags"
+       test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+       CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+       test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+       CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+       test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+       EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
                ;;
@@ -17761,7 +18388,7 @@ fi
        ;;
 esac
 
-echo "$as_me:17764: checking if you want to perform memory-leak testing" >&5
+echo "$as_me:18391: checking if you want to perform memory-leak testing" >&5
 echo $ECHO_N "checking if you want to perform memory-leak testing... $ECHO_C" >&6
 
 # Check whether --enable-leaks or --disable-leaks was given.
@@ -17771,7 +18398,7 @@ if test "${enable_leaks+set}" = set; then
 else
   : ${with_no_leaks:=no}
 fi;
-echo "$as_me:17774: result: $with_no_leaks" >&5
+echo "$as_me:18401: result: $with_no_leaks" >&5
 echo "${ECHO_T}$with_no_leaks" >&6
 
 if test "$with_no_leaks" = yes ; then
@@ -17787,7 +18414,7 @@ EOF
 fi
 
 LD_RPATH_OPT=
-echo "$as_me:17790: checking for an rpath option" >&5
+echo "$as_me:18417: checking for an rpath option" >&5
 echo $ECHO_N "checking for an rpath option... $ECHO_C" >&6
 case $cf_cv_system_name in
 (irix*)
@@ -17818,12 +18445,12 @@ case $cf_cv_system_name in
 (*)
        ;;
 esac
-echo "$as_me:17821: result: $LD_RPATH_OPT" >&5
+echo "$as_me:18448: result: $LD_RPATH_OPT" >&5
 echo "${ECHO_T}$LD_RPATH_OPT" >&6
 
 case "x$LD_RPATH_OPT" in
 (x-R*)
-       echo "$as_me:17826: checking if we need a space after rpath option" >&5
+       echo "$as_me:18453: checking if we need a space after rpath option" >&5
 echo $ECHO_N "checking if we need a space after rpath option... $ECHO_C" >&6
        cf_save_LIBS="$LIBS"
 
@@ -17844,11 +18471,11 @@ done
 LIBS="$cf_add_libs"
 
        cat >conftest.$ac_ext <<_ACEOF
-#line 17847 "configure"
+#line 18474 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -17856,16 +18483,16 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:17859: \"$ac_link\"") >&5
+if { (eval echo "$as_me:18486: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17862: \$? = $ac_status" >&5
+  echo "$as_me:18489: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:17865: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18492: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17868: \$? = $ac_status" >&5
+  echo "$as_me:18495: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_rpath_space=no
 else
@@ -17875,13 +18502,13 @@ cf_rpath_space=yes
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
        LIBS="$cf_save_LIBS"
-       echo "$as_me:17878: result: $cf_rpath_space" >&5
+       echo "$as_me:18505: result: $cf_rpath_space" >&5
 echo "${ECHO_T}$cf_rpath_space" >&6
        test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
        ;;
 esac
 
-echo "$as_me:17884: checking if rpath-hack should be disabled" >&5
+echo "$as_me:18511: checking if rpath-hack should be disabled" >&5
 echo $ECHO_N "checking if rpath-hack should be disabled... $ECHO_C" >&6
 
 # Check whether --enable-rpath-hack or --disable-rpath-hack was given.
@@ -17898,21 +18525,21 @@ else
        cf_disable_rpath_hack=no
 
 fi;
-echo "$as_me:17901: result: $cf_disable_rpath_hack" >&5
+echo "$as_me:18528: result: $cf_disable_rpath_hack" >&5
 echo "${ECHO_T}$cf_disable_rpath_hack" >&6
 if test "$cf_disable_rpath_hack" = no ; then
 
-echo "$as_me:17905: checking for updated LDFLAGS" >&5
+echo "$as_me:18532: checking for updated LDFLAGS" >&5
 echo $ECHO_N "checking for updated LDFLAGS... $ECHO_C" >&6
 if test -n "$LD_RPATH_OPT" ; then
-       echo "$as_me:17908: result: maybe" >&5
+       echo "$as_me:18535: result: maybe" >&5
 echo "${ECHO_T}maybe" >&6
 
        for ac_prog in ldd
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:17915: checking for $ac_word" >&5
+echo "$as_me:18542: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_cf_ldd_prog+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -17927,7 +18554,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_cf_ldd_prog="$ac_prog"
-echo "$as_me:17930: found $ac_dir/$ac_word" >&5
+echo "$as_me:18557: found $ac_dir/$ac_word" >&5
 break
 done
 
 fi
 cf_ldd_prog=$ac_cv_prog_cf_ldd_prog
 if test -n "$cf_ldd_prog"; then
-  echo "$as_me:17938: result: $cf_ldd_prog" >&5
+  echo "$as_me:18565: result: $cf_ldd_prog" >&5
 echo "${ECHO_T}$cf_ldd_prog" >&6
 else
-  echo "$as_me:17941: result: no" >&5
+  echo "$as_me:18568: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -17952,11 +18579,11 @@ test -n "$cf_ldd_prog" || cf_ldd_prog="no"
                cf_rpath_oops=
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 17955 "configure"
+#line 18582 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello");
   ;
@@ -17964,16 +18591,16 @@ printf("Hello");
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:17967: \"$ac_link\"") >&5
+if { (eval echo "$as_me:18594: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17970: \$? = $ac_status" >&5
+  echo "$as_me:18597: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:17973: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18600: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17976: \$? = $ac_status" >&5
+  echo "$as_me:18603: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
                 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[      ]/%/%' -e 's%/[^/][^/]*$%%' |sort | uniq`
@@ -18001,7 +18628,7 @@ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
                                        then
                                                test -n "$verbose" && echo "    ...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src" 1>&6
 
-echo "${as_me:-configure}:18004: testing ...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src ..." 1>&5
+echo "${as_me:-configure}:18631: testing ...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src ..." 1>&5
 
                                                LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
                                                break
@@ -18013,11 +18640,11 @@ echo "${as_me:-configure}:18004: testing ...adding -L$cf_rpath_dir/lib to LDFLAG
 
        test -n "$verbose" && echo "    ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:18016: testing ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:18643: testing ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
 
 test -n "$verbose" && echo "   ...checking LDFLAGS $LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:18020: testing ...checking LDFLAGS $LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:18647: testing ...checking LDFLAGS $LDFLAGS ..." 1>&5
 
 cf_rpath_dst=
 for cf_rpath_src in $LDFLAGS
@@ -18054,7 +18681,7 @@ do
                        then
                                test -n "$verbose" && echo "    ...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6
 
-echo "${as_me:-configure}:18057: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
+echo "${as_me:-configure}:18684: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
 
                                EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
                        fi
@@ -18067,11 +18694,11 @@ LDFLAGS=$cf_rpath_dst
 
 test -n "$verbose" && echo "   ...checked LDFLAGS $LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:18070: testing ...checked LDFLAGS $LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:18697: testing ...checked LDFLAGS $LDFLAGS ..." 1>&5
 
 test -n "$verbose" && echo "   ...checking LIBS $LIBS" 1>&6
 
-echo "${as_me:-configure}:18074: testing ...checking LIBS $LIBS ..." 1>&5
+echo "${as_me:-configure}:18701: testing ...checking LIBS $LIBS ..." 1>&5
 
 cf_rpath_dst=
 for cf_rpath_src in $LIBS
@@ -18108,7 +18735,7 @@ do
                        then
                                test -n "$verbose" && echo "    ...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6
 
-echo "${as_me:-configure}:18111: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
+echo "${as_me:-configure}:18738: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
 
                                EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
                        fi
@@ -18121,14 +18748,14 @@ LIBS=$cf_rpath_dst
 
 test -n "$verbose" && echo "   ...checked LIBS $LIBS" 1>&6
 
-echo "${as_me:-configure}:18124: testing ...checked LIBS $LIBS ..." 1>&5
+echo "${as_me:-configure}:18751: testing ...checked LIBS $LIBS ..." 1>&5
 
        test -n "$verbose" && echo "    ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:18128: testing ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:18755: testing ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
 
 else
-       echo "$as_me:18131: result: no" >&5
+       echo "$as_me:18758: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -18218,7 +18845,7 @@ DEFS=-DHAVE_CONFIG_H
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:18221: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:18848: creating $CONFIG_STATUS" >&5
 echo "$as_me: creating $CONFIG_STATUS" >&6;}
 cat >$CONFIG_STATUS <<_ACEOF
 #! $SHELL
@@ -18350,7 +18977,7 @@ EOF
 cat >>$CONFIG_STATUS <<EOF
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.52.20150926,
+configured by $0, generated by GNU Autoconf 2.52.20170501,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
@@ -18394,7 +19021,7 @@ cat >>$CONFIG_STATUS <<\EOF
     echo "$ac_cs_version"; exit 0 ;;
   --he | --h)
     # Conflict between --help and --header
-    { { echo "$as_me:18397: error: ambiguous option: $1
+    { { echo "$as_me:19024: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -18413,7 +19040,7 @@ Try \`$0 --help' for more information." >&2;}
     ac_need_defaults=false;;
 
   # This is an error.
-  -*) { { echo "$as_me:18416: error: unrecognized option: $1
+  -*) { { echo "$as_me:19043: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -18432,7 +19059,7 @@ cat >&5 << _ACEOF
 ## Running config.status.  ##
 ## ----------------------- ##
 
-This file was extended by $as_me 2.52.20150926, executed with
+This file was extended by $as_me 2.52.20170501, executed with
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
   CONFIG_LINKS    = $CONFIG_LINKS
@@ -18463,7 +19090,7 @@ do
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
   "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
   "ncurses_cfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS ncurses_cfg.h:ncurses_tst.hin" ;;
-  *) { { echo "$as_me:18466: error: invalid argument: $ac_config_target" >&5
+  *) { { echo "$as_me:19093: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
@@ -18619,6 +19246,8 @@ s,@X_LIBS@,$X_LIBS,;t t
 s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t
 s,@XCURSES_CONFIG@,$XCURSES_CONFIG,;t t
 s,@ac_ct_XCURSES_CONFIG@,$ac_ct_XCURSES_CONFIG,;t t
+s,@RGB_PATH@,$RGB_PATH,;t t
+s,@no_x11_rgb@,$no_x11_rgb,;t t
 s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t
 s,@cf_ldd_prog@,$cf_ldd_prog,;t t
 s,@EXTRA_LDFLAGS@,$EXTRA_LDFLAGS,;t t
@@ -18754,7 +19383,7 @@ done; }
   esac
 
   if test x"$ac_file" != x-; then
-    { echo "$as_me:18757: creating $ac_file" >&5
+    { echo "$as_me:19386: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
     rm -f "$ac_file"
   fi
@@ -18772,7 +19401,7 @@ echo "$as_me: creating $ac_file" >&6;}
       -) echo $tmp/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:18775: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:19404: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -18785,7 +19414,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
            echo $srcdir/$f
          else
            # /dev/null tree
-           { { echo "$as_me:18788: error: cannot find input file: $f" >&5
+           { { echo "$as_me:19417: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -18801,7 +19430,7 @@ cat >>$CONFIG_STATUS <<\EOF
       if test -n "$ac_seen"; then
         ac_used=`grep '@datarootdir@' $ac_item`
         if test -z "$ac_used"; then
-          { echo "$as_me:18804: WARNING: datarootdir was used implicitly but not set:
+          { echo "$as_me:19433: WARNING: datarootdir was used implicitly but not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: datarootdir was used implicitly but not set:
 $ac_seen" >&2;}
@@ -18810,7 +19439,7 @@ $ac_seen" >&2;}
       fi
       ac_seen=`grep '${datarootdir}' $ac_item`
       if test -n "$ac_seen"; then
-        { echo "$as_me:18813: WARNING: datarootdir was used explicitly but not set:
+        { echo "$as_me:19442: WARNING: datarootdir was used explicitly but not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: datarootdir was used explicitly but not set:
 $ac_seen" >&2;}
@@ -18847,7 +19476,7 @@ s,@INSTALL@,$ac_INSTALL,;t t
             ac_init=`egrep '[  ]*'$ac_name'[   ]*=' $ac_file`
             if test -z "$ac_init"; then
               ac_seen=`echo "$ac_seen" |sed -e 's,^,'$ac_file':,'`
-              { echo "$as_me:18850: WARNING: Variable $ac_name is used but was not set:
+              { echo "$as_me:19479: WARNING: Variable $ac_name is used but was not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: Variable $ac_name is used but was not set:
 $ac_seen" >&2;}
@@ -18858,7 +19487,7 @@ $ac_seen" >&2;}
     egrep -n '@[A-Z_][A-Z_0-9]+@' $ac_file >>$tmp/out
     if test -s $tmp/out; then
       ac_seen=`sed -e 's,^,'$ac_file':,' < $tmp/out`
-      { echo "$as_me:18861: WARNING: Some variables may not be substituted:
+      { echo "$as_me:19490: WARNING: Some variables may not be substituted:
 $ac_seen" >&5
 echo "$as_me: WARNING: Some variables may not be substituted:
 $ac_seen" >&2;}
@@ -18907,7 +19536,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
   * )   ac_file_in=$ac_file.in ;;
   esac
 
-  test x"$ac_file" != x- && { echo "$as_me:18910: creating $ac_file" >&5
+  test x"$ac_file" != x- && { echo "$as_me:19539: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
 
   # First look for the input files in the build tree, otherwise in the
@@ -18918,7 +19547,7 @@ echo "$as_me: creating $ac_file" >&6;}
       -) echo $tmp/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:18921: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:19550: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -18931,7 +19560,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
            echo $srcdir/$f
          else
            # /dev/null tree
-           { { echo "$as_me:18934: error: cannot find input file: $f" >&5
+           { { echo "$as_me:19563: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -18989,7 +19618,7 @@ cat >>$CONFIG_STATUS <<\EOF
   rm -f $tmp/in
   if test x"$ac_file" != x-; then
     if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
-      { echo "$as_me:18992: $ac_file is unchanged" >&5
+      { echo "$as_me:19621: $ac_file is unchanged" >&5
 echo "$as_me: $ac_file is unchanged" >&6;}
     else
       ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
@@ -19066,7 +19695,7 @@ do
        \$(srcdir)/test.priv.h \\
        ncurses_cfg.h
        $SHOW_CC
-       $ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) \$(srcdir)/$N.c
+       $ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) -DMODULE_NAME="$N" \$(srcdir)/$N.c
 TEST_EOF
 done