http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.01.tar.gz
[xscreensaver] / configure
index 135f8a3d0ca03eab4a27918a0a7cb6ffbbcfeabd..14fcbb0430ba27d5ebb2f799c738da193dd0ec55 100755 (executable)
--- a/configure
+++ b/configure
@@ -15,15 +15,17 @@ ac_help="$ac_help"
 ac_help="$ac_help
 Installation options:
 
-  --enable-subdir=DIR     Put the demo programs in a subdirectory of \`bindir',
-                          instead of putting them in bindir itself.  You can
-                          specify the name of the subdirectory.  For example,
-                          \`--exec-prefix=/usr/local --enable-subdir=demos'
-                          would put xscreensaver in /usr/local/bin/, and would
-                          put the demos in /usr/local/bin/demos/.  (If DIR
-                          begins with /, then bindir will not be prepended.)
-
-  --disable-subdir        Just put the demos in \`bindir' (this is the default.)
+  --with-hackdir=DIR      Where to install the hundreds of demo executables.
+                          Default: \`PREFIX/lib/xscreensaver/'
+"
+ac_help="$ac_help
+"
+ac_help="$ac_help
+  --with-configdir=DIR    Where to install the data files that describe each
+                          of the display modes to the GUI.
+                          Default: \`GNOMEPREFIX/control-center/screensavers/'
+                          or \`PREFIX/lib/xscreensaver/config/', depending on
+                          whether GNOME is available.
 "
 ac_help="$ac_help
 Except where noted, all of the --with options below can also take a
@@ -48,8 +50,12 @@ ac_help="$ac_help
   --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL extension."
 ac_help="$ac_help
   --with-dpms-ext         Include support for the DPMS extension."
+ac_help="$ac_help
+  --with-xinerama-ext     Include support for the XINERAMA extension."
 ac_help="$ac_help
   --with-xf86vmode-ext    Include support for XFree86 virtual screens."
+ac_help="$ac_help
+  --with-xf86gamma-ext    Include support for XFree86 gamma fading."
 ac_help="$ac_help
   --with-proc-interrupts  Include support for consulting the /proc/interrupts
                           file to notice keyboard activity."
@@ -74,7 +80,10 @@ User interface options:
 ac_help="$ac_help
   --with-gtk              Use the Gtk toolkit for the user interface."
 ac_help="$ac_help
-  --with-athena           Use the Athena toolkit for the user interface."
+  --with-gnome            Include support for the Gnome Control Center."
+ac_help="$ac_help
+  --with-xml              The XML toolkit is needed for some parts of
+                          the Gtk interface."
 ac_help="$ac_help
 
 Graphics options:
@@ -86,21 +95,28 @@ ac_help="$ac_help
 ac_help="$ac_help
   --with-xpm              Include support for XPM files in some demos."
 ac_help="$ac_help
-  --with-xshm-ext         Include support for the XSHM extension."
+  --with-pixbuf           Include support for the GDK-Pixbuf library in some
+                          demos, which will make it possible for them to read
+                          GIF, JPEG, and PNG files as well."
+ac_help="$ac_help
+  --with-jpeg             Include support for the JPEG library in some demos,
+                          which will make it possible for them to read JPEG
+                          files as well."
+ac_help="$ac_help
+  --with-xshm-ext         Include support for the Shared Memory extension."
 ac_help="$ac_help
   --with-xdbe-ext         Include support for the DOUBLE-BUFFER extension."
 ac_help="$ac_help
   --with-readdisplay      Include support for the XReadDisplay extension."
 ac_help="$ac_help
-  --with-sgivideo         Include support for SGI's Iris Video Library."
-ac_help="$ac_help
 
-  --with-zippy=PROGRAM    Some demos are able to run an external program and
+  --with-fortune=PROGRAM  Some demos are able to run an external program and
                           display its text; this names the program to use by
                           default (though it can be overridden with X
-                          resources.)  If you don't specify this, the default
-                          is to use \"yow\" from the Emacs distribution (if you
-                          have it) or else to use \"fortune\".
+                          resources.)  Default is \"/usr/games/fortune\"."
+ac_help="$ac_help
+  --with-setuid-hacks     Allow some demos to be installed \`setuid root'
+                          (which is needed in order to ping other hosts.)
 "
 
 # Initialize some variables set by options.
@@ -634,6 +650,22 @@ done
 
 
 
+###############################################################################
+#
+#       Functions to figure out how to disable // comments in ANSI C code.
+#
+#       (With recent gcc, this is done with "-std=c89".  With older gcc, this
+#       is done by passing "-lang-c89" to cpp, by passing "-Wp,-lang-c89" to
+#       gcc.  Old gcc doesn't support -std, and new gcc doesn't support -lang.
+#       so much for compatibility!)
+#
+###############################################################################
+
+
+
+
+
+
 ###############################################################################
 #
 #       Function to figure out how to create directory trees.
@@ -667,6 +699,14 @@ perl_version_cmd='print $]'
 
 
 
+###############################################################################
+#
+#       Function to demand "bc".  Losers.
+#
+###############################################################################
+
+
+
 ###############################################################################
 #
 #       Functions to check how to do ICMP PING requests.
@@ -789,7 +829,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:804: checking host system type" >&5
+echo "configure:844: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -812,7 +852,7 @@ echo "$ac_t""$host" 1>&6
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:827: checking for $ac_word" >&5
+echo "configure:867: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -842,7 +882,7 @@ 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:857: checking for $ac_word" >&5
+echo "configure:897: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -893,7 +933,7 @@ fi
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:908: checking for $ac_word" >&5
+echo "configure:948: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -925,7 +965,7 @@ fi
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:940: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:980: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -936,12 +976,12 @@ cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 951 "configure"
+#line 991 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:996: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -967,12 +1007,12 @@ if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:982: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1022: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:987: checking whether we are using GNU C" >&5
+echo "configure:1027: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -981,7 +1021,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:996: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1036: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -1000,7 +1040,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1015: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1055: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1034,7 +1074,7 @@ fi
 
   if test -z "$GCC"; then
     echo $ac_n "checking how to request ANSI compilation""... $ac_c" 1>&6
-echo "configure:1049: checking how to request ANSI compilation" >&5
+echo "configure:1089: checking how to request ANSI compilation" >&5
     case "$host" in
       *-hpux* )
         echo "$ac_t""HPUX: adding -Ae" 1>&6
@@ -1046,7 +1086,7 @@ echo "configure:1049: checking how to request ANSI compilation" >&5
       ;;
 
       *-dec-* )
-        echo "$ac_t""DEC: adding -std1" 1>&6
+        echo "$ac_t""DEC: adding -std1 -ieee" 1>&6
         CC="$CC -std1"
       ;;
 
@@ -1057,16 +1097,16 @@ echo "configure:1049: checking how to request ANSI compilation" >&5
   fi
 
   echo $ac_n "checking whether the compiler works on ANSI C""... $ac_c" 1>&6
-echo "configure:1072: checking whether the compiler works on ANSI C" >&5
+echo "configure:1112: checking whether the compiler works on ANSI C" >&5
   if test "$cross_compiling" = yes; then
   { echo "configure: error: Couldn't build even a trivial ANSI C program: check CC." 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 1077 "configure"
+#line 1117 "configure"
 #include "confdefs.h"
  main(int ac, char **av) { return 0; } 
 EOF
-if { (eval echo configure:1081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1121: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""yes" 1>&6
 else
@@ -1098,8 +1138,54 @@ fi
     esac
   fi
 
+if test -n "$GCC"; then
+   if test -n "$GCC"; then
+   echo $ac_n "checking whether gcc accepts -std""... $ac_c" 1>&6
+echo "configure:1156: checking whether gcc accepts -std" >&5
+if eval "test \"`echo '$''{'ac_cv_gcc_accepts_std'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if ( gcc -E -std=c89 - </dev/null 2>&1 >/dev/null | \
+          grep unrecognized >/dev/null ); then
+       ac_cv_gcc_accepts_std=no
+     else
+       ac_cv_gcc_accepts_std=yes
+     fi
+fi
+
+echo "$ac_t""$ac_cv_gcc_accepts_std" 1>&6
+   ac_gcc_accepts_std="$ac_cv_gcc_accepts_std"
+  fi
+
+   echo "$ac_t""Disabling C++ comments in ANSI C code." 1>&6
+   #
+   # The reason that // comments are banned from xscreensaver is that gcc is
+   # basically the only compiler in the world that supports them in C code.
+   # All other vendors support them only in their C++ compilers, not in their
+   # ANSI C compilers.  This means that it's a portability problem: every time
+   # these comments have snuck into the xscreensaver source code, I've gotten
+   # complaints about it the next day.  So we turn off support for them in gcc
+   # as well to prevent them from accidentially slipping in.
+   #
+   if test "$ac_gcc_accepts_std" = yes ; then
+     #
+     # -std=c89 defines __STRICT_ANSI__, which we don't want.
+     # (That appears to be the only additional preprocessor symbol
+     # it defines, in addition to the syntax changes it makes.)
+     #
+     # -std=gnu89 is no good, because // comments were a GNU extension
+     # before they were in the ANSI C 99 spec...  (gcc 2.96 permits //
+     # with -std=gnu89 but not with -std=c89.)
+     #
+     CC="$CC -std=c89 -U__STRICT_ANSI__"
+   else
+     # The old way:
+     CC="$CC -Wp,-lang-c89"
+   fi
+  fi
+
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1114: checking how to run the C preprocessor" >&5
+echo "configure:1200: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1114,13 +1200,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1129 "configure"
+#line 1215 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1135: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1221: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1131,13 +1217,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1146 "configure"
+#line 1232 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1152: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1148,13 +1234,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 1163 "configure"
+#line 1249 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1169: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1255: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1179,12 +1265,12 @@ fi
 echo "$ac_t""$CPP" 1>&6
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1194: checking for working const" >&5
+echo "configure:1280: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1199 "configure"
+#line 1285 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1233,7 +1319,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:1248: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1334: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1254,21 +1340,21 @@ EOF
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1269: checking for inline" >&5
+echo "configure:1355: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 1276 "configure"
+#line 1362 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:1283: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -1293,6 +1379,19 @@ EOF
  ;;
 esac
 
+ac_bc_result=`echo 6+9 | bc 2>/dev/null`
+  echo $ac_n "checking for bc""... $ac_c" 1>&6
+echo "configure:1396: checking for bc" >&5
+  if test "$ac_bc_result" = "15" ; then
+    echo "$ac_t""yes" 1>&6
+  else
+    echo "$ac_t""no" 1>&6
+    echo ''
+    { echo "configure: error: Your system doesn't have \"bc\", which has been a standard
+                  part of Unix since the 1970s.  Come back when your vendor
+                  has grown a clue." 1>&2; exit 1; }
+  fi
 
 # stuff for Makefiles
 # Find a good install program.  We prefer a C program (faster),
@@ -1307,7 +1406,7 @@ esac
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1322: checking for a BSD compatible install" >&5
+echo "configure:1421: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1360,7 +1459,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 echo $ac_n "checking whether \"\${INSTALL} -d\" creates intermediate directories""... $ac_c" 1>&6
-echo "configure:1375: checking whether \"\${INSTALL} -d\" creates intermediate directories" >&5
+echo "configure:1474: checking whether \"\${INSTALL} -d\" creates intermediate directories" >&5
 if eval "test \"`echo '$''{'ac_cv_install_d_creates_dirs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1382,7 +1481,7 @@ echo "$ac_t""$ac_cv_install_d_creates_dirs" 1>&6
 
   if test "$ac_cv_install_d_creates_dirs" = no ; then
     echo $ac_n "checking whether \"mkdir -p\" creates intermediate directories""... $ac_c" 1>&6
-echo "configure:1397: checking whether \"mkdir -p\" creates intermediate directories" >&5
+echo "configure:1496: checking whether \"mkdir -p\" creates intermediate directories" >&5
 if eval "test \"`echo '$''{'ac_cv_mkdir_p_creates_dirs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1413,7 +1512,7 @@ echo "$ac_t""$ac_cv_mkdir_p_creates_dirs" 1>&6
   fi
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1428: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1527: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1440,14 +1539,21 @@ else
 fi
 
 
+# By default, autoconf sets INSTALL_SCRIPT to '${INSTALL_PROGRAM}'.
+# That's wrong: it should be set to '${INSTALL}', so that one can
+# implement the "install-strip" target properly (strip executables,
+# but do not try to strip scripts.)
+#
+INSTALL_SCRIPT='${INSTALL}'
+
 # random libc stuff
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1457: checking for ANSI C header files" >&5
+echo "configure:1563: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1462 "configure"
+#line 1568 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1455,7 +1561,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1470: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1576: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1472,7 +1578,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1487 "configure"
+#line 1593 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1490,7 +1596,7 @@ 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 <<EOF
-#line 1505 "configure"
+#line 1611 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1511,7 +1617,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1526 "configure"
+#line 1632 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1522,7 +1628,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:1537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1549,17 +1655,17 @@ for ac_hdr in unistd.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1564: checking for $ac_hdr" >&5
+echo "configure:1670: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1569 "configure"
+#line 1675 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1574: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1586,12 +1692,12 @@ fi
 done
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:1601: checking for mode_t" >&5
+echo "configure:1707: checking for mode_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1606 "configure"
+#line 1712 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1619,12 +1725,12 @@ EOF
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:1634: checking for pid_t" >&5
+echo "configure:1740: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1639 "configure"
+#line 1745 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1652,12 +1758,12 @@ EOF
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1667: checking for size_t" >&5
+echo "configure:1773: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1672 "configure"
+#line 1778 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1685,12 +1791,12 @@ EOF
 fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1700: checking return type of signal handlers" >&5
+echo "configure:1806: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1705 "configure"
+#line 1811 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -1707,7 +1813,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:1722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1828: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -1726,12 +1832,12 @@ EOF
 
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1741: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1847: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1746 "configure"
+#line 1852 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -1740,7 +1846,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:1755: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1861: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -1761,12 +1867,12 @@ EOF
 fi
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1776: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:1882: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1781 "configure"
+#line 1887 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -1782,7 +1888,7 @@ wait (&s);
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:1797: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1903: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -1807,12 +1913,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:1822: checking for $ac_hdr that defines DIR" >&5
+echo "configure:1928: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1827 "configure"
+#line 1933 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -1820,7 +1926,7 @@ int main() {
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:1835: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1941: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -1845,7 +1951,7 @@ done
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:1860: checking for opendir in -ldir" >&5
+echo "configure:1966: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1853,7 +1959,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1868 "configure"
+#line 1974 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1864,7 +1970,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1879: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1886,7 +1992,7 @@ fi
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1901: checking for opendir in -lx" >&5
+echo "configure:2007: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1894,7 +2000,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1909 "configure"
+#line 2015 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1905,7 +2011,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1928,12 +2034,12 @@ fi
 fi
 
 echo $ac_n "checking how to call gettimeofday""... $ac_c" 1>&6
-echo "configure:1943: checking how to call gettimeofday" >&5
+echo "configure:2049: checking how to call gettimeofday" >&5
   if eval "test \"`echo '$''{'ac_cv_gettimeofday_args'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1948 "configure"
+#line 2054 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                     #include <sys/time.h>
@@ -1942,7 +2048,7 @@ struct timeval tv; struct timezone tzp;
                     gettimeofday(&tv, &tzp);
 ; return 0; }
 EOF
-if { (eval echo configure:1957: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_gettimeofday_args=2
 else
@@ -1950,7 +2056,7 @@ else
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 1965 "configure"
+#line 2071 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                     #include <sys/time.h>
@@ -1958,7 +2064,7 @@ int main() {
 struct timeval tv; gettimeofday(&tv);
 ; return 0; }
 EOF
-if { (eval echo configure:1973: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2079: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_gettimeofday_args=1
 else
@@ -1997,12 +2103,12 @@ EOF
 for ac_func in select fcntl uname nice setpriority getcwd getwd putenv
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2012: checking for $ac_func" >&5
+echo "configure:2118: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2017 "configure"
+#line 2123 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2025,7 +2131,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2040: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2146: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2050,15 +2156,15 @@ fi
 done
 
 
-for ac_func in sigaction syslog realpath
+for ac_func in sigaction syslog realpath setrlimit
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2068: checking for $ac_func" >&5
+echo "configure:2174: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2073 "configure"
+#line 2179 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2081,7 +2187,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2106,12 +2212,12 @@ fi
 done
 
 echo $ac_n "checking for struct icmp""... $ac_c" 1>&6
-echo "configure:2121: checking for struct icmp" >&5
+echo "configure:2227: checking for struct icmp" >&5
 if eval "test \"`echo '$''{'ac_cv_have_icmp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2126 "configure"
+#line 2232 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                    #include <stdio.h>
@@ -2143,10 +2249,15 @@ struct icmp i;
                    i.icmp_id = 0;
                    i.icmp_seq = 0;
                    si.sin_family = AF_INET;
+                   #if defined(__DECC) || defined(_IP_VHL)
+                   ip.ip_vhl = 0;
+                   #else
                    ip.ip_hl = 0;
+                   #endif
+                   
 ; return 0; }
 EOF
-if { (eval echo configure:2161: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_have_icmp=yes
 else
@@ -2166,12 +2277,12 @@ EOF
 
  fi
 echo $ac_n "checking for struct icmphdr""... $ac_c" 1>&6
-echo "configure:2181: checking for struct icmphdr" >&5
+echo "configure:2292: checking for struct icmphdr" >&5
 if eval "test \"`echo '$''{'ac_cv_have_icmphdr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2186 "configure"
+#line 2297 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                    #include <stdio.h>
@@ -2199,14 +2310,14 @@ struct icmphdr i;
                    struct ip ip;
                    i.type = ICMP_ECHO;
                    i.code = 0;
-                   i.cksum = 0;
+                   i.checksum = 0;
                    i.un.echo.id = 0;
                    i.un.echo.sequence = 0;
                    si.sin_family = AF_INET;
                    ip.ip_hl = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:2221: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2332: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_have_icmphdr=yes
 else
@@ -2229,17 +2340,17 @@ for ac_hdr in crypt.h sys/select.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2244: checking for $ac_hdr" >&5
+echo "configure:2355: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2249 "configure"
+#line 2360 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2254: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2365: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2270,7 +2381,7 @@ 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2285: checking for $ac_word" >&5
+echo "configure:2396: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2309,7 +2420,7 @@ done
     PERL_VERSION=0
   else
     echo $ac_n "checking perl version""... $ac_c" 1>&6
-echo "configure:2324: checking perl version" >&5
+echo "configure:2435: checking perl version" >&5
 if eval "test \"`echo '$''{'ac_cv_perl_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2323,7 +2434,7 @@ echo "$ac_t""$ac_cv_perl_version" 1>&6
 
 if test -z "$PERL" ; then
   # don't let it be blank...
-  PERL=/usr/local/bin/perl5
+  PERL=/usr/bin/perl
 fi
 
 # If we find X, set shell vars x_includes and x_libraries to the
@@ -2331,7 +2442,7 @@ fi
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:2346: checking for X" >&5
+echo "configure:2457: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -2393,12 +2504,12 @@ if test "$ac_x_includes" = NO; then
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 2408 "configure"
+#line 2519 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2413: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2524: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2467,14 +2578,14 @@ if test "$ac_x_libraries" = NO; then
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2482 "configure"
+#line 2593 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:2489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -2580,17 +2691,17 @@ else
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:2595: checking whether -R must be followed by a space" >&5
+echo "configure:2706: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 2598 "configure"
+#line 2709 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -2606,14 +2717,14 @@ rm -f conftest*
       else
        LIBS="$ac_xsave_LIBS -R $x_libraries"
        cat > conftest.$ac_ext <<EOF
-#line 2621 "configure"
+#line 2732 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -2645,7 +2756,7 @@ rm -f conftest*
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:2660: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:2771: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2653,7 +2764,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2668 "configure"
+#line 2779 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2664,7 +2775,7 @@ int main() {
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:2679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2686,7 +2797,7 @@ fi
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:2701: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:2812: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2694,7 +2805,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2709 "configure"
+#line 2820 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2705,7 +2816,7 @@ int main() {
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:2720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2734,12 +2845,12 @@ fi
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:2749: checking for gethostbyname" >&5
+echo "configure:2860: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2754 "configure"
+#line 2865 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -2762,7 +2873,7 @@ gethostbyname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -2783,7 +2894,7 @@ fi
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2798: checking for gethostbyname in -lnsl" >&5
+echo "configure:2909: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2791,7 +2902,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2806 "configure"
+#line 2917 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2802,7 +2913,7 @@ int main() {
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:2817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2832,12 +2943,12 @@ fi
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:2847: checking for connect" >&5
+echo "configure:2958: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2852 "configure"
+#line 2963 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -2860,7 +2971,7 @@ connect();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -2881,7 +2992,7 @@ fi
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:2896: checking for connect in -lsocket" >&5
+echo "configure:3007: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2889,7 +3000,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2904 "configure"
+#line 3015 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2900,7 +3011,7 @@ int main() {
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:2915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2924,12 +3035,12 @@ fi
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:2939: checking for remove" >&5
+echo "configure:3050: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2944 "configure"
+#line 3055 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -2952,7 +3063,7 @@ remove();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2967: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3078: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -2973,7 +3084,7 @@ fi
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:2988: checking for remove in -lposix" >&5
+echo "configure:3099: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2981,7 +3092,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2996 "configure"
+#line 3107 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2992,7 +3103,7 @@ int main() {
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:3007: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3016,12 +3127,12 @@ fi
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:3031: checking for shmat" >&5
+echo "configure:3142: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3036 "configure"
+#line 3147 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -3044,7 +3155,7 @@ shmat();
 
 ; return 0; }
 EOF
-if { (eval echo configure:3059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -3065,7 +3176,7 @@ fi
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:3080: checking for shmat in -lipc" >&5
+echo "configure:3191: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3073,7 +3184,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3088 "configure"
+#line 3199 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3084,7 +3195,7 @@ int main() {
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:3099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3117,7 +3228,7 @@ fi
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:3132: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:3243: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3125,7 +3236,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lICE $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3140 "configure"
+#line 3251 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3136,7 +3247,7 @@ int main() {
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:3151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3167,7 +3278,7 @@ fi
 
 
     echo $ac_n "checking for X app-defaults directory""... $ac_c" 1>&6
-echo "configure:3182: checking for X app-defaults directory" >&5
+echo "configure:3293: checking for X app-defaults directory" >&5
 if eval "test \"`echo '$''{'ac_cv_x_app_defaults'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3301,15 +3412,15 @@ case "$host" in
       #
       for version in X11R6 X11R5 X11R4 ; do
         # if either pair of directories exists...
-        if test -d /usr/lib/$version || test -d /usr/contrib/$version/lib
+        if test -d /usr/include/$version || test -d /usr/contrib/$version/include
         then
            # if contrib exists, use it...
-           if test -d /usr/contrib/$version/lib ; then
+           if test -d /usr/contrib/$version/include ; then
              X_CFLAGS="$X_CFLAGS -I/usr/contrib/$version/include"
              X_LIBS="$X_LIBS -L/usr/contrib/$version/lib"
            fi
            # if the "standard" one exists, use it.
-           if test -d /usr/lib/$version ; then
+           if test -d /usr/include/$version ; then
              X_CFLAGS="$X_CFLAGS -I/usr/include/$version"
              X_LIBS="$X_LIBS -L/usr/lib/$version"
            fi
@@ -3321,21 +3432,29 @@ case "$host" in
       # Now find Motif.  Thanks for not making xmkmf find this by
       # default, you losers.
       #
-      if test -d /usr/lib/Motif1.2 ; then
+      if test -d /usr/include/Motif2.1 ; then
+        X_CFLAGS="$X_CFLAGS -I/usr/include/Motif2.1"
+        X_LIBS="$X_LIBS -L/usr/lib/Motif2.1"
+      elif test -d /usr/include/Motif1.2 ; then
         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.2"
         X_LIBS="$X_LIBS -L/usr/lib/Motif1.2"
-      elif test -d /usr/lib/Motif1.1 ; then
+      elif test -d /usr/include/Motif1.1 ; then
         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.1"
         X_LIBS="$X_LIBS -L/usr/lib/Motif1.1"
       fi
 
       # Now let's check for the pseudo-standard locations for OpenGL and XPM.
       #
-      if test -d /opt/Mesa/lib ; then
+      if test -d /opt/graphics/OpenGL/include ; then
+        # HP-UX 10.20 puts it here
+        X_CFLAGS="-I/opt/graphics/OpenGL/include $X_CFLAGS"
+        X_LIBS="-L/opt/graphics/OpenGL/lib $X_LIBS"
+      elif test -d /opt/Mesa/lib ; then
         X_CFLAGS="-I/opt/Mesa/include $X_CFLAGS"
         X_LIBS="-L/opt/Mesa/lib $X_LIBS"
       fi
 
+
       if test -d /opt/xpm/lib/X11 ; then
         X_CFLAGS="-I/opt/xpm/include $X_CFLAGS"
         X_LIBS="-L/opt/xpm/lib/X11 $X_LIBS"
@@ -3366,7 +3485,7 @@ case "$host" in
 
         # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
         echo $ac_n "checking for regcmp in -lgen""... $ac_c" 1>&6
-echo "configure:3381: checking for regcmp in -lgen" >&5
+echo "configure:3500: checking for regcmp in -lgen" >&5
 ac_lib_var=`echo gen'_'regcmp | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3374,7 +3493,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgen  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3389 "configure"
+#line 3508 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3385,7 +3504,7 @@ int main() {
 regcmp()
 ; return 0; }
 EOF
-if { (eval echo configure:3400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3519: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3409,7 +3528,7 @@ fi
     ;;
   esac
 echo $ac_n "checking for XPointer""... $ac_c" 1>&6
-echo "configure:3424: checking for XPointer" >&5
+echo "configure:3543: checking for XPointer" >&5
 if eval "test \"`echo '$''{'ac_cv_xpointer'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3420,14 +3539,14 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 3435 "configure"
+#line 3554 "configure"
 #include "confdefs.h"
 #include <X11/Xlib.h>
 int main() {
 XPointer foo = (XPointer) 0;
 ; return 0; }
 EOF
-if { (eval echo configure:3442: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3561: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_xpointer=yes
 else
@@ -3465,17 +3584,17 @@ have_xmu=no
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/Xmu/Error.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xmu/Error.h""... $ac_c" 1>&6
-echo "configure:3480: checking for X11/Xmu/Error.h" >&5
+echo "configure:3599: checking for X11/Xmu/Error.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3485 "configure"
+#line 3604 "configure"
 #include "confdefs.h"
 #include <X11/Xmu/Error.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3490: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3609: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3500,15 +3619,11 @@ fi
 if test "$have_xmu" = no ; then
   XMU_SRCS='$(UTILS_SRC)/xmu.c'
   XMU_OBJS='$(UTILS_BIN)/xmu.o'
+  XMU_LIBS=''
 else
   XMU_SRCS=''
   XMU_OBJS=''
-  SAVER_LIBS="-lXmu $SAVER_LIBS"
-  HACK_LIBS="-lXmu $HACK_LIBS"
-  MOTIF_LIBS="-lXmu $MOTIF_LIBS"
-  GTK_LIBS="-lXmu $GTK_LIBS"
-  ATHENA_LIBS="-lXmu $ATHENA_LIBS"
-  ATHENA3D_LIBS="-lXmu $ATHENA3D_LIBS"
+  XMU_LIBS='-lXmu'
   cat >> confdefs.h <<\EOF
 #define HAVE_XMU 1
 EOF
@@ -3528,7 +3643,7 @@ if test "$have_xmu" = yes ; then
   case "$host" in
     *-sunos4*)
     echo $ac_n "checking for the SunOS 4.1.x _get_wmShellWidgetClass bug""... $ac_c" 1>&6
-echo "configure:3543: checking for the SunOS 4.1.x _get_wmShellWidgetClass bug" >&5
+echo "configure:3658: checking for the SunOS 4.1.x _get_wmShellWidgetClass bug" >&5
 if eval "test \"`echo '$''{'ac_cv_sunos_xmu_bug'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3541,14 +3656,14 @@ else
                     # with X libraries because we know it's SunOS.
                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
                     cat > conftest.$ac_ext <<EOF
-#line 3556 "configure"
+#line 3671 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_sunos_xmu_bug=no
 else
@@ -3564,21 +3679,21 @@ fi
 echo "$ac_t""$ac_cv_sunos_xmu_bug" 1>&6
     if test "$ac_cv_sunos_xmu_bug" = yes ; then
       echo $ac_n "checking whether the compiler understands -static""... $ac_c" 1>&6
-echo "configure:3579: checking whether the compiler understands -static" >&5
+echo "configure:3694: checking whether the compiler understands -static" >&5
 if eval "test \"`echo '$''{'ac_cv_ld_static'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LDFLAGS="$LDFLAGS"
                       LDFLAGS="$LDFLAGS -static"
                       cat > conftest.$ac_ext <<EOF
-#line 3586 "configure"
+#line 3701 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_ld_static=yes
 else
@@ -3605,36 +3720,92 @@ fi
 
 ###############################################################################
 #
-#       Handle the --enable-subdir option
+#       Handle the --with-hackdir option
 #
 ###############################################################################
 
+have_hackdir=yes
+with_hackdir_req=unspecified
+# Check whether --with-hackdir or --without-hackdir was given.
+if test "${with_hackdir+set}" = set; then
+  withval="$with_hackdir"
+  with_hackdir="$withval"; with_hackdir_req="$withval"
+else
+  with_hackdir=yes
+fi
+
+
+if test x"$with_hackdir" = xyes; then
+  HACKDIR='${exec_prefix}/lib/xscreensaver'
+elif test x"$with_hackdir" = xno; then
+  HACKDIR='${bindir}'
+else
+  # there must be a better way than this...
+  if test -z "`echo $with_hackdir | sed 's@^/.*@@'`" ; then
+    # absolute path
+    HACKDIR=$with_hackdir
+  else
+    # relative path
+    HACKDIR="\${exec_prefix}$with_hackdir"
+  fi
+fi
+
+# canonicalize slashes.
+HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
+
+# This option used to be called --enable-subdir; make sure that is no longer
+# used, since configure brain-damagedly ignores unknown --enable options.
+
+obsolete_enable=
 # Check whether --enable-subdir or --disable-subdir was given.
 if test "${enable_subdir+set}" = set; then
   enableval="$enable_subdir"
-  enable_subdir="$enableval"
+  obsolete_enable=yes
+fi
+
+if test -n "$obsolete_enable"; then
+  echo "error: the --enable-subdir option has been replaced with"
+  echo "       the new --with-hackdir option; see \`configure --help'"
+  echo "       for more information."
+  exit 1
+fi
+
+
+###############################################################################
+#
+#       Handle the --with-configdir option
+#
+###############################################################################
+
+have_configdir=yes
+with_configdir_req=unspecified
+# Check whether --with-configdir or --without-configdir was given.
+if test "${with_configdir+set}" = set; then
+  withval="$with_configdir"
+  with_configdir="$withval"; with_configdir_req="$withval"
 else
-  enable_subdir=no
+  with_configdir=yes
 fi
 
-if test x"$enable_subdir" = xno; then
-  HACKDIR='${bindir}'
-elif test x"$enable_subdir" = xyes -o x"$enable_subdir" = x ; then
-  echo "error: must be a subdirectory name: --enable-subdir=$enable_subdir"
+
+if test x"$with_configdir" = xyes; then
+  # filled in later...
+  HACK_CONF_DIR=''
+elif test x"$with_configdir" = xno; then
+  echo "error: must be yes, or a pathname: --with-configdir=$with_configdir"
   exit 1
 else
   # there must be a better way than this...
-  if test -z "`echo $enable_subdir | sed 's@^/.*@@'`" ; then
+  if test -z "`echo $with_configdir | sed 's@^/.*@@'`" ; then
     # absolute path
-    HACKDIR=$enable_subdir
+    HACK_CONF_DIR=$with_configdir
   else
     # relative path
-    HACKDIR='${bindir}/'$enable_subdir
+    HACK_CONF_DIR="\${exec_prefix}$with_configdir"
   fi
 fi
 
-# canonicalize slashes.
-HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
+
 
 
 ###############################################################################
@@ -3661,7 +3832,7 @@ fi
 
     /*)
      echo $ac_n "checking for SGI SCREEN_SAVER headers""... $ac_c" 1>&6
-echo "configure:3676: checking for SGI SCREEN_SAVER headers" >&5
+echo "configure:3847: checking for SGI SCREEN_SAVER headers" >&5
      d=$with_sgi/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3671,7 +3842,7 @@ echo "configure:3676: checking for SGI SCREEN_SAVER headers" >&5
      fi
 
      echo $ac_n "checking for SGI SCREEN_SAVER libs""... $ac_c" 1>&6
-echo "configure:3686: checking for SGI SCREEN_SAVER libs" >&5
+echo "configure:3857: checking for SGI SCREEN_SAVER libs" >&5
      d=$with_sgi/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3704,17 +3875,17 @@ if test "$with_sgi" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XScreenSaver.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XScreenSaver.h""... $ac_c" 1>&6
-echo "configure:3719: checking for X11/extensions/XScreenSaver.h" >&5
+echo "configure:3890: checking for X11/extensions/XScreenSaver.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3724 "configure"
+#line 3895 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XScreenSaver.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3729: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3900: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3771,7 +3942,7 @@ fi
 
     /*)
      echo $ac_n "checking for MIT-SCREEN-SAVER headers""... $ac_c" 1>&6
-echo "configure:3786: checking for MIT-SCREEN-SAVER headers" >&5
+echo "configure:3957: checking for MIT-SCREEN-SAVER headers" >&5
      d=$with_mit/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3781,7 +3952,7 @@ echo "configure:3786: checking for MIT-SCREEN-SAVER headers" >&5
      fi
 
      echo $ac_n "checking for MIT-SCREEN-SAVER libs""... $ac_c" 1>&6
-echo "configure:3796: checking for MIT-SCREEN-SAVER libs" >&5
+echo "configure:3967: checking for MIT-SCREEN-SAVER libs" >&5
      d=$with_mit/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3814,17 +3985,17 @@ if test "$with_mit" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/scrnsaver.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/scrnsaver.h""... $ac_c" 1>&6
-echo "configure:3829: checking for X11/extensions/scrnsaver.h" >&5
+echo "configure:4000: checking for X11/extensions/scrnsaver.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3834 "configure"
+#line 4005 "configure"
 #include "confdefs.h"
 #include <X11/extensions/scrnsaver.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3839: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4010: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3866,10 +4037,10 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
   echo $ac_n "checking for XScreenSaverRegister in -lXext""... $ac_c" 1>&6
-echo "configure:3884: checking for XScreenSaverRegister in -lXext" >&5
+echo "configure:4055: checking for XScreenSaverRegister in -lXext" >&5
 ac_lib_var=`echo Xext'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3877,7 +4048,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3892 "configure"
+#line 4063 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3888,7 +4059,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:3903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4074: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3932,10 +4103,10 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
   echo $ac_n "checking for XScreenSaverRegister in -lXExExt""... $ac_c" 1>&6
-echo "configure:3950: checking for XScreenSaverRegister in -lXExExt" >&5
+echo "configure:4121: checking for XScreenSaverRegister in -lXExExt" >&5
 ac_lib_var=`echo XExExt'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3943,7 +4114,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXExExt -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3958 "configure"
+#line 4129 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3954,7 +4125,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:3969: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4001,10 +4172,10 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
   echo $ac_n "checking for XScreenSaverRegister in -lXss""... $ac_c" 1>&6
-echo "configure:4019: checking for XScreenSaverRegister in -lXss" >&5
+echo "configure:4190: checking for XScreenSaverRegister in -lXss" >&5
 ac_lib_var=`echo Xss'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4012,7 +4183,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXss -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4027 "configure"
+#line 4198 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4023,7 +4194,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:4038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4089,7 +4260,7 @@ fi
 
     /*)
      echo $ac_n "checking for XIDLE headers""... $ac_c" 1>&6
-echo "configure:4104: checking for XIDLE headers" >&5
+echo "configure:4275: checking for XIDLE headers" >&5
      d=$with_xidle/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4099,7 +4270,7 @@ echo "configure:4104: checking for XIDLE headers" >&5
      fi
 
      echo $ac_n "checking for XIDLE libs""... $ac_c" 1>&6
-echo "configure:4114: checking for XIDLE libs" >&5
+echo "configure:4285: checking for XIDLE libs" >&5
      d=$with_xidle/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4132,17 +4303,17 @@ if test "$with_xidle" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/xidle.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/xidle.h""... $ac_c" 1>&6
-echo "configure:4147: checking for X11/extensions/xidle.h" >&5
+echo "configure:4318: checking for X11/extensions/xidle.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4152 "configure"
+#line 4323 "configure"
 #include "confdefs.h"
 #include <X11/extensions/xidle.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4157: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4328: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4198,7 +4369,7 @@ fi
 
     /*)
      echo $ac_n "checking for SGI-VIDEO-CONTROL headers""... $ac_c" 1>&6
-echo "configure:4213: checking for SGI-VIDEO-CONTROL headers" >&5
+echo "configure:4384: checking for SGI-VIDEO-CONTROL headers" >&5
      d=$with_sgivc/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4208,7 +4379,7 @@ echo "configure:4213: checking for SGI-VIDEO-CONTROL headers" >&5
      fi
 
      echo $ac_n "checking for SGI-VIDEO-CONTROL libs""... $ac_c" 1>&6
-echo "configure:4223: checking for SGI-VIDEO-CONTROL libs" >&5
+echo "configure:4394: checking for SGI-VIDEO-CONTROL libs" >&5
      d=$with_sgivc/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4243,17 +4414,17 @@ if test "$with_sgivc" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XSGIvc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XSGIvc.h""... $ac_c" 1>&6
-echo "configure:4258: checking for X11/extensions/XSGIvc.h" >&5
+echo "configure:4429: checking for X11/extensions/XSGIvc.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4263 "configure"
+#line 4434 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XSGIvc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4268: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4439: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4294,10 +4465,10 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
   echo $ac_n "checking for XSGIvcQueryGammaMap in -lXsgivc""... $ac_c" 1>&6
-echo "configure:4312: checking for XSGIvcQueryGammaMap in -lXsgivc" >&5
+echo "configure:4483: checking for XSGIvcQueryGammaMap in -lXsgivc" >&5
 ac_lib_var=`echo Xsgivc'_'XSGIvcQueryGammaMap | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4305,7 +4476,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXsgivc -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4320 "configure"
+#line 4491 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4316,7 +4487,7 @@ int main() {
 XSGIvcQueryGammaMap()
 ; return 0; }
 EOF
-if { (eval echo configure:4331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4381,7 +4552,7 @@ fi
 
     /*)
      echo $ac_n "checking for DPMS headers""... $ac_c" 1>&6
-echo "configure:4396: checking for DPMS headers" >&5
+echo "configure:4567: checking for DPMS headers" >&5
      d=$with_dpms/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4391,7 +4562,7 @@ echo "configure:4396: checking for DPMS headers" >&5
      fi
 
      echo $ac_n "checking for DPMS libs""... $ac_c" 1>&6
-echo "configure:4406: checking for DPMS libs" >&5
+echo "configure:4577: checking for DPMS libs" >&5
      d=$with_dpms/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4426,17 +4597,17 @@ if test "$with_dpms" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/dpms.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/dpms.h""... $ac_c" 1>&6
-echo "configure:4441: checking for X11/extensions/dpms.h" >&5
+echo "configure:4612: checking for X11/extensions/dpms.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4446 "configure"
+#line 4617 "configure"
 #include "confdefs.h"
 #include <X11/extensions/dpms.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4451: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4622: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4459,8 +4630,10 @@ fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
 
-  # if that succeeded, then check for the -lXdpms
+  # if that succeeded, then check for the DPMS code in the libraries
   if test "$have_dpms" = yes; then
+
+    # first look in -lXext (this is where it is with XFree86 4.0)
     have_dpms=no
     
   ac_save_CPPFLAGS="$CPPFLAGS"
@@ -4477,10 +4650,75 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for DPMSInfo in -lXext""... $ac_c" 1>&6
+echo "configure:4668: checking for DPMSInfo in -lXext" >&5
+ac_lib_var=`echo Xext'_'DPMSInfo | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lXext -lXext -lX11 $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 4676 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char DPMSInfo();
+
+int main() {
+DPMSInfo()
+; return 0; }
+EOF
+if { (eval echo configure:4687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_dpms=yes
+else
+  echo "$ac_t""no" 1>&6
+true
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+
+    # if that failed, look in -lXdpms (this is where it was in XFree86 3.x)
+    if test "$have_dpms" = no; then
+      
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
   echo $ac_n "checking for DPMSInfo in -lXdpms""... $ac_c" 1>&6
-echo "configure:4495: checking for DPMSInfo in -lXdpms" >&5
+echo "configure:4733: checking for DPMSInfo in -lXdpms" >&5
 ac_lib_var=`echo Xdpms'_'DPMSInfo | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4488,7 +4726,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXdpms -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4503 "configure"
+#line 4741 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4499,7 +4737,7 @@ int main() {
 DPMSInfo()
 ; return 0; }
 EOF
-if { (eval echo configure:4514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4514,7 +4752,7 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_dpms=yes; SAVER_LIBS="$SAVER_LIBS -lXdpms"
+  have_dpms=yes; XDPMS_LIBS="-lXdpms"
 else
   echo "$ac_t""no" 1>&6
 true
@@ -4524,8 +4762,10 @@ fi
   LDFLAGS="$ac_save_LDFLAGS"
 #  LIBS="$ac_save_LIBS"
   
+    fi
   fi
 
+
   # if that succeeded, then we've really got it.
   if test "$have_dpms" = yes; then
     cat >> confdefs.h <<\EOF
@@ -4542,30 +4782,30 @@ fi
 
 ###############################################################################
 #
-#       Check for the XF86VMODE server extension.
+#       Check for the XINERAMA server extension.
 #
 ###############################################################################
 
-have_xf86vmode=no
-with_xf86vmode_req=unspecified
-# Check whether --with-xf86vmode-ext or --without-xf86vmode-ext was given.
-if test "${with_xf86vmode_ext+set}" = set; then
-  withval="$with_xf86vmode_ext"
-  with_xf86vmode="$withval"; with_xf86vmode_req="$withval"
+have_xinerama=no
+with_xinerama_req=unspecified
+# Check whether --with-xinerama-ext or --without-xinerama-ext was given.
+if test "${with_xinerama_ext+set}" = set; then
+  withval="$with_xinerama_ext"
+  with_xinerama="$withval"; with_xinerama_req="$withval"
 else
-  with_xf86vmode=yes
+  with_xinerama=yes
 fi
 
 
 
-   case "$with_xf86vmode" in
+   case "$with_xinerama" in
     yes) ;;
     no)  ;;
 
     /*)
-     echo $ac_n "checking for xf86vmode headers""... $ac_c" 1>&6
-echo "configure:4579: checking for xf86vmode headers" >&5
-     d=$with_xf86vmode/include
+     echo $ac_n "checking for XINERAMA headers""... $ac_c" 1>&6
+echo "configure:4819: checking for XINERAMA headers" >&5
+     d=$with_xinerama/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
        echo "$ac_t""$d" 1>&6
@@ -4573,9 +4813,9 @@ echo "configure:4579: checking for xf86vmode headers" >&5
        echo "$ac_t""not found ($d: no such directory)" 1>&6
      fi
 
-     echo $ac_n "checking for xf86vmode libs""... $ac_c" 1>&6
-echo "configure:4589: checking for xf86vmode libs" >&5
-     d=$with_xf86vmode/lib
+     echo $ac_n "checking for XINERAMA libs""... $ac_c" 1>&6
+echo "configure:4829: checking for XINERAMA libs" >&5
+     d=$with_xinerama/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
        echo "$ac_t""$d" 1>&6
@@ -4584,13 +4824,13 @@ echo "configure:4589: checking for xf86vmode libs" >&5
      fi
 
      # replace the directory string with "yes".
-     with_xf86vmode_req="yes"
-     with_xf86vmode=$with_xf86vmode_req
+     with_xinerama_req="yes"
+     with_xinerama=$with_xinerama_req
      ;;
 
     *)
      echo ""
-     echo "error: argument to --with-xf86vmode-ext must be \"yes\", \"no\", or a directory."
+     echo "error: argument to --with-xinerama-ext must be \"yes\", \"no\", or a directory."
      echo "       If it is a directory, then \`DIR/include' will be added to"
      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
      exit 1
@@ -4598,28 +4838,28 @@ echo "configure:4589: checking for xf86vmode libs" >&5
    esac
   
 
-if test "$with_xf86vmode" = yes; then
+if test "$with_xinerama" = yes; then
 
-  # first check for xf86vmode.h
+  # first check for Xinerama.h
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "X11/extensions/xf86vmode.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for X11/extensions/xf86vmode.h""... $ac_c" 1>&6
-echo "configure:4624: checking for X11/extensions/xf86vmode.h" >&5
+  ac_safe=`echo "X11/extensions/Xinerama.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for X11/extensions/Xinerama.h""... $ac_c" 1>&6
+echo "configure:4864: checking for X11/extensions/Xinerama.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4629 "configure"
+#line 4869 "configure"
 #include "confdefs.h"
-#include <X11/extensions/xf86vmode.h>
+#include <X11/extensions/Xinerama.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4634: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4874: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4635,16 +4875,18 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_xf86vmode=yes
+  have_xinerama=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
 
-  # if that succeeded, then check for the -lXxf86vm
-  if test "$have_xf86vmode" = yes; then
-    have_xf86vmode=no
+  # if that succeeded, then check for the XINERAMA code in the libraries
+  if test "$have_xinerama" = yes; then
+
+    # first look in -lXext
+    have_xinerama=no
     
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
@@ -4660,29 +4902,29 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
-  echo $ac_n "checking for XF86VidModeGetViewPort in -lXxf86vm""... $ac_c" 1>&6
-echo "configure:4678: checking for XF86VidModeGetViewPort in -lXxf86vm" >&5
-ac_lib_var=`echo Xxf86vm'_'XF86VidModeGetViewPort | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for XineramaQueryExtension in -lXext""... $ac_c" 1>&6
+echo "configure:4920: checking for XineramaQueryExtension in -lXext" >&5
+ac_lib_var=`echo Xext'_'XineramaQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lXxf86vm -lXext -lX11 $LIBS"
+LIBS="-lXext -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4686 "configure"
+#line 4928 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char XF86VidModeGetViewPort();
+char XineramaQueryExtension();
 
 int main() {
-XF86VidModeGetViewPort()
+XineramaQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:4697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4939: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4697,7 +4939,7 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_xf86vmode=yes; SAVER_LIBS="$SAVER_LIBS -lXxf86vm"
+  have_xinerama=yes
 else
   echo "$ac_t""no" 1>&6
 true
   LDFLAGS="$ac_save_LDFLAGS"
 #  LIBS="$ac_save_LIBS"
   
-  fi
-
-  # if that succeeded, then we've really got it.
-  if test "$have_xf86vmode" = yes; then
-    cat >> confdefs.h <<\EOF
-#define HAVE_XF86VMODE 1
-EOF
-
-  fi
-
-elif test "$with_xf86vmode" != no; then
-  echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
-  exit 1
-fi
-
-
-###############################################################################
-#
-#       Check for HP XHPDisableReset and XHPEnableReset.
-#
-###############################################################################
-
 
+    # if that failed, look in -lXinerama (this is where it is in XFree86 4.1.)
+    if test "$have_xinerama" = no; then
+      
   ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
+  # note: $X_CFLAGS includes $x_includes
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  cat > conftest.$ac_ext <<EOF
-#line 4751 "configure"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for XineramaQueryExtension in -lXinerama""... $ac_c" 1>&6
+echo "configure:4985: checking for XineramaQueryExtension in -lXinerama" >&5
+ac_lib_var=`echo Xinerama'_'XineramaQueryExtension | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lXinerama -lXext -lX11 $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 4993 "configure"
 #include "confdefs.h"
-#include <X11/XHPlib.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char XineramaQueryExtension();
+
+int main() {
+XineramaQueryExtension()
+; return 0; }
 EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "XHPDisableReset" >/dev/null 2>&1; then
+if { (eval echo configure:5004: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
-  cat >> confdefs.h <<\EOF
-#define HAVE_XHPDISABLERESET 1
-EOF
-
-                   SAVER_LIBS="-lXhp11 $SAVER_LIBS"
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_xinerama=yes; SAVER_LIBS="$SAVER_LIBS -lXinerama"
+else
+  echo "$ac_t""no" 1>&6
+true
+fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+    fi
+  fi
+
+  # if that succeeded, then we've really got it.
+  if test "$have_xinerama" = yes; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_XINERAMA 1
+EOF
+
+  fi
+
+elif test "$with_xinerama" != no; then
+  echo "error: must be yes or no: --with-xinerama-ext=$with_xinerama"
+  exit 1
+fi
 
 
 ###############################################################################
 #
-#       Check for /proc/interrupts.
+#       Check for the XF86VMODE server extension (for virtual screens.)
 #
 ###############################################################################
 
-have_proc_interrupts=no
-with_proc_interrupts_req=unspecified
-# Check whether --with-proc-interrupts or --without-proc-interrupts was given.
-if test "${with_proc_interrupts+set}" = set; then
-  withval="$with_proc_interrupts"
-  with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"
-else
-  with_proc_interrupts=yes
-fi
-
-
-if test "$with_proc_interrupts" = yes; then
-
-   echo $ac_n "checking whether /proc/interrupts contains keyboard data""... $ac_c" 1>&6
-echo "configure:4789: checking whether /proc/interrupts contains keyboard data" >&5
-if eval "test \"`echo '$''{'ac_cv_have_proc_interrupts'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_cv_have_proc_interrupts=no
-     if grep keyboard /proc/interrupts >/dev/null 2>&1 ; then
-       ac_cv_have_proc_interrupts=yes
-     fi
-    
-fi
-
-echo "$ac_t""$ac_cv_have_proc_interrupts" 1>&6
-   have_proc_interrupts=$ac_cv_have_proc_interrupts
-
-  if test "$have_proc_interrupts" = yes; then
-    cat >> confdefs.h <<\EOF
-#define HAVE_PROC_INTERRUPTS 1
-EOF
-
-  fi
-
-elif test "$with_proc_interrupts" != no; then
-  echo "error: must be yes or no: --with-proc-interrupts=$with_proc_interrupts"
-  exit 1
-fi
-
-
-###############################################################################
-#
-#       The --enable-locking option
-#
-###############################################################################
-
-# Check whether --enable-locking or --disable-locking was given.
-if test "${enable_locking+set}" = set; then
-  enableval="$enable_locking"
-  enable_locking="$enableval"
-else
-  enable_locking=yes
-fi
-
-if test "$enable_locking" = yes; then
-  true
-elif test "$enable_locking" = no; then
-  cat >> confdefs.h <<\EOF
-#define NO_LOCKING 1
-EOF
-
-else
-  echo "error: must be yes or no: --enable-locking=$enable_locking"
-  exit 1
-fi
-
-
-
-###############################################################################
-#
-#       The --enable-vt-locking option
-#
-###############################################################################
-
-#ac_vt_lockswitch=no
-#AC_ARG_ENABLE(vt-locking,[
-#  --enable-vt-locking     Compile in support for locking Virtual Terminals.
-#                          This is the default if the system supports it, and
-#                          if locking support is included (--enable-locking.)
-#  --disable-vt-locking    Do not allow locking of VTs, even if locking is
-#                          enabled.],
-#  [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
-#if test "$enable_vt_locking" = yes; then
-#
-#  AC_CACHE_CHECK([for the VT_LOCKSWITCH ioctl], ac_cv_vt_lockswitch,
-#   [AC_TRY_COMPILE([#include <fcntl.h>
-#                   #include <sys/ioctl.h>
-#                   #include <sys/vt.h>],
-#                  [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
-#                  [ac_cv_vt_lockswitch=yes],
-#                  [ac_cv_vt_lockswitch=no])])
-#  ac_vt_lockswitch=$ac_cv_vt_lockswitch
-#
-#elif test "$enable_vt_locking" = no; then
-#  true
-#else
-#  echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
-#  exit 1
-#fi
-#
-#if test "$ac_vt_lockswitch" = yes; then
-#  AC_DEFINE(HAVE_VT_LOCKSWITCH)
-#  # the VT_LOCKSWITCH ioctl can only be used when running as root.
-#  # #### but it doesn't work yet, so don't worry about that for now.
-##  need_setuid=yes
-#fi
-
-
-
-###############################################################################
-#
-#       Check for PAM.
-#
-###############################################################################
-
-case "$host" in
-  *-solaris*)
-   # Solaris systems tend to come with PAM misconfigured.
-   #  Don't build it by default, even if the headers exist.
-   with_pam_default=no
-   ;;
-  *)
-   # Default to building PAM support on all other systems, if it exists.
-   with_pam_default=yes
-  ;;
-esac
-
-have_pam=no
-with_pam_req=unspecified
-
-# Check whether --with-pam or --without-pam was given.
-if test "${with_pam+set}" = set; then
-  withval="$with_pam"
-  with_pam="$withval"; with_pam_req="$withval"
+have_xf86vmode=no
+with_xf86vmode_req=unspecified
+# Check whether --with-xf86vmode-ext or --without-xf86vmode-ext was given.
+if test "${with_xf86vmode_ext+set}" = set; then
+  withval="$with_xf86vmode_ext"
+  with_xf86vmode="$withval"; with_xf86vmode_req="$withval"
 else
-  with_pam=$with_pam_default
+  with_xf86vmode=yes
 fi
 
 
 
-   case "$with_pam" in
+   case "$with_xf86vmode" in
     yes) ;;
     no)  ;;
 
     /*)
-     echo $ac_n "checking for PAM headers""... $ac_c" 1>&6
-echo "configure:4922: checking for PAM headers" >&5
-     d=$with_pam/include
+     echo $ac_n "checking for xf86vmode headers""... $ac_c" 1>&6
+echo "configure:5070: checking for xf86vmode headers" >&5
+     d=$with_xf86vmode/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
        echo "$ac_t""$d" 1>&6
@@ -4916,9 +5064,9 @@ echo "configure:4922: checking for PAM headers" >&5
        echo "$ac_t""not found ($d: no such directory)" 1>&6
      fi
 
-     echo $ac_n "checking for PAM libs""... $ac_c" 1>&6
-echo "configure:4932: checking for PAM libs" >&5
-     d=$with_pam/lib
+     echo $ac_n "checking for xf86vmode libs""... $ac_c" 1>&6
+echo "configure:5080: checking for xf86vmode libs" >&5
+     d=$with_xf86vmode/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
        echo "$ac_t""$d" 1>&6
@@ -4927,13 +5075,13 @@ echo "configure:4932: checking for PAM libs" >&5
      fi
 
      # replace the directory string with "yes".
-     with_pam_req="yes"
-     with_pam=$with_pam_req
+     with_xf86vmode_req="yes"
+     with_xf86vmode=$with_xf86vmode_req
      ;;
 
     *)
      echo ""
-     echo "error: argument to --with-pam must be \"yes\", \"no\", or a directory."
+     echo "error: argument to --with-xf86vmode-ext must be \"yes\", \"no\", or a directory."
      echo "       If it is a directory, then \`DIR/include' will be added to"
      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
      exit 1
@@ -4941,71 +5089,91 @@ echo "configure:4932: checking for PAM libs" >&5
    esac
   
 
-if test "$enable_locking" = yes -a "$with_pam" = yes; then
-  echo $ac_n "checking for PAM""... $ac_c" 1>&6
-echo "configure:4958: checking for PAM" >&5
-if eval "test \"`echo '$''{'ac_cv_pam'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
+if test "$with_xf86vmode" = yes; then
+
+  # first check for xf86vmode.h
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  ac_safe=`echo "X11/extensions/xf86vmode.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for X11/extensions/xf86vmode.h""... $ac_c" 1>&6
+echo "configure:5115: checking for X11/extensions/xf86vmode.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
   cat > conftest.$ac_ext <<EOF
-#line 4969 "configure"
+#line 5120 "configure"
 #include "confdefs.h"
-#include <security/pam_appl.h>
-int main() {
-
-; return 0; }
+#include <X11/extensions/xf86vmode.h>
 EOF
-if { (eval echo configure:4976: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:5125: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
   rm -rf conftest*
-  ac_cv_pam=yes
+  eval "ac_cv_header_$ac_safe=yes"
 else
+  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  ac_cv_pam=no
+  eval "ac_cv_header_$ac_safe=no"
 fi
 rm -f conftest*
-  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_xf86vmode=yes
+else
+  echo "$ac_t""no" 1>&6
 fi
 
-echo "$ac_t""$ac_cv_pam" 1>&6
-  if test "$ac_cv_pam" = yes ; then
-    have_pam=yes
-    cat >> confdefs.h <<\EOF
-#define HAVE_PAM 1
-EOF
+  CPPFLAGS="$ac_save_CPPFLAGS"
 
-    PASSWD_LIBS="${PASSWD_LIBS} -lpam"
+  # if that succeeded, then check for the -lXxf86vm
+  if test "$have_xf86vmode" = yes; then
+    have_xf86vmode=no
+    
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
 
-    # libpam typically requires dlopen and dlsym.  On FreeBSD,
-    # those are in libc.  On Linux and Solaris, they're in libdl.
-    echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:5001: checking for dlopen in -ldl" >&5
-ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for XF86VidModeGetViewPort in -lXxf86vm""... $ac_c" 1>&6
+echo "configure:5169: checking for XF86VidModeGetViewPort in -lXxf86vm" >&5
+ac_lib_var=`echo Xxf86vm'_'XF86VidModeGetViewPort | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-ldl  $LIBS"
+LIBS="-lXxf86vm -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5009 "configure"
+#line 5177 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char dlopen();
+char XF86VidModeGetViewPort();
 
 int main() {
-dlopen()
+XF86VidModeGetViewPort()
 ; return 0; }
 EOF
-if { (eval echo configure:5020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5020,104 +5188,59 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  PASSWD_LIBS="${PASSWD_LIBS} -ldl"
+  have_xf86vmode=yes; SAVER_LIBS="$SAVER_LIBS -lXxf86vm"
 else
   echo "$ac_t""no" 1>&6
+true
 fi
 
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+  fi
 
-    echo $ac_n "checking how to call pam_strerror""... $ac_c" 1>&6
-echo "configure:5042: checking how to call pam_strerror" >&5
-    if eval "test \"`echo '$''{'ac_cv_pam_strerror_args'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 5047 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-                      #include <stdlib.h>
-                      #include <security/pam_appl.h>
-int main() {
-pam_handle_t *pamh = 0;
-                      char *s = pam_strerror(pamh, PAM_SUCCESS);
-; return 0; }
-EOF
-if { (eval echo configure:5057: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  ac_pam_strerror_args=2
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  cat > conftest.$ac_ext <<EOF
-#line 5065 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-                                      #include <stdlib.h>
-                                      #include <security/pam_appl.h>
-int main() {
-char *s =
-                                       pam_strerror(PAM_SUCCESS);
-; return 0; }
-EOF
-if { (eval echo configure:5075: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  ac_pam_strerror_args=1
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_pam_strerror_args=0
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-      ac_cv_pam_strerror_args=$ac_pam_strerror_args
-fi
-
-    ac_pam_strerror_args=$ac_cv_pam_strerror_args
-    if test "$ac_pam_strerror_args" = 1 ; then
-      echo "$ac_t""one argument" 1>&6
-    elif test "$ac_pam_strerror_args" = 2 ; then
-      cat >> confdefs.h <<\EOF
-#define PAM_STRERROR_TWO_ARGS 1
+  # if that succeeded, then we've really got it.
+  if test "$have_xf86vmode" = yes; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_XF86VMODE 1
 EOF
 
-      echo "$ac_t""two arguments" 1>&6
-    else
-      echo "$ac_t""unknown" 1>&6
-    fi
   fi
+
+elif test "$with_xf86vmode" != no; then
+  echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
+  exit 1
 fi
 
 
 ###############################################################################
 #
-#       Check for Kerberos.
+#       Check for the XF86VMODE server extension (for gamma fading.)
 #
 ###############################################################################
 
-have_kerberos=no
-with_kerberos_req=unspecified
-
-# Check whether --with-kerberos or --without-kerberos was given.
-if test "${with_kerberos+set}" = set; then
-  withval="$with_kerberos"
-  with_kerberos="$withval"; with_kerberos_req="$withval"
+have_xf86gamma=no
+have_xf86gamma_ramp=no
+with_xf86gamma_req=unspecified
+# Check whether --with-xf86gamma-ext or --without-xf86gamma-ext was given.
+if test "${with_xf86gamma_ext+set}" = set; then
+  withval="$with_xf86gamma_ext"
+  with_xf86gamma="$withval"; with_xf86gamma_req="$withval"
 else
-  with_kerberos=yes
+  with_xf86gamma=yes
 fi
 
 
 
-   case "$with_kerberos" in
+   case "$with_xf86gamma" in
     yes) ;;
     no)  ;;
 
     /*)
-     echo $ac_n "checking for Kerberos headers""... $ac_c" 1>&6
-echo "configure:5131: checking for Kerberos headers" >&5
-     d=$with_kerberos/include
+     echo $ac_n "checking for xf86gamma headers""... $ac_c" 1>&6
+echo "configure:5254: checking for xf86gamma headers" >&5
+     d=$with_xf86gamma/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
        echo "$ac_t""$d" 1>&6
@@ -5125,9 +5248,9 @@ echo "configure:5131: checking for Kerberos headers" >&5
        echo "$ac_t""not found ($d: no such directory)" 1>&6
      fi
 
-     echo $ac_n "checking for Kerberos libs""... $ac_c" 1>&6
-echo "configure:5141: checking for Kerberos libs" >&5
-     d=$with_kerberos/lib
+     echo $ac_n "checking for xf86gamma libs""... $ac_c" 1>&6
+echo "configure:5264: checking for xf86gamma libs" >&5
+     d=$with_xf86gamma/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
        echo "$ac_t""$d" 1>&6
@@ -5136,13 +5259,13 @@ echo "configure:5141: checking for Kerberos libs" >&5
      fi
 
      # replace the directory string with "yes".
-     with_kerberos_req="yes"
-     with_kerberos=$with_kerberos_req
+     with_xf86gamma_req="yes"
+     with_xf86gamma=$with_xf86gamma_req
      ;;
 
     *)
      echo ""
-     echo "error: argument to --with-kerberos must be \"yes\", \"no\", or a directory."
+     echo "error: argument to --with-xf86gamma-ext must be \"yes\", \"no\", or a directory."
      echo "       If it is a directory, then \`DIR/include' will be added to"
      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
      exit 1
@@ -5150,116 +5273,162 @@ echo "configure:5141: checking for Kerberos libs" >&5
    esac
   
 
-if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
-  echo $ac_n "checking for Kerberos""... $ac_c" 1>&6
-echo "configure:5167: checking for Kerberos" >&5
-if eval "test \"`echo '$''{'ac_cv_kerberos'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  
+if test "$with_xf86gamma" = yes; then
+
+  # first check for xf86vmode.h, if we haven't already
+  if test "$have_xf86vmode" = yes; then
+    have_xf86gamma=yes
+  else
+    
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  ac_safe=`echo "X11/extensions/xf86vmode.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for X11/extensions/xf86vmode.h""... $ac_c" 1>&6
+echo "configure:5302: checking for X11/extensions/xf86vmode.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
   cat > conftest.$ac_ext <<EOF
-#line 5178 "configure"
+#line 5307 "configure"
 #include "confdefs.h"
-#include <krb.h>
-int main() {
-
-; return 0; }
+#include <X11/extensions/xf86vmode.h>
 EOF
-if { (eval echo configure:5185: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:5312: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
   rm -rf conftest*
-  ac_cv_kerberos=yes
+  eval "ac_cv_header_$ac_safe=yes"
 else
+  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  ac_cv_kerberos=no
+  eval "ac_cv_header_$ac_safe=no"
 fi
 rm -f conftest*
-  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_xf86gamma=yes
+else
+  echo "$ac_t""no" 1>&6
 fi
 
-echo "$ac_t""$ac_cv_kerberos" 1>&6
-  if test "$ac_cv_kerberos" = yes ; then
-    have_kerberos=yes
-    cat >> confdefs.h <<\EOF
-#define HAVE_KERBEROS 1
-EOF
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  fi
 
+  # if that succeeded, then check for the -lXxf86vm
+  if test "$have_xf86gamma" = yes; then
+    have_xf86gamma=no
+    
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
 
-    # from Tim Showalter <tjs+@andrew.cmu.edu>
-    PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes"
-    echo $ac_n "checking for res_search""... $ac_c" 1>&6
-echo "configure:5209: checking for res_search" >&5
-if eval "test \"`echo '$''{'ac_cv_func_res_search'+set}'`\" = set"; then
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for XF86VidModeSetGamma in -lXxf86vm""... $ac_c" 1>&6
+echo "configure:5357: checking for XF86VidModeSetGamma in -lXxf86vm" >&5
+ac_lib_var=`echo Xxf86vm'_'XF86VidModeSetGamma | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 5214 "configure"
+  ac_save_LIBS="$LIBS"
+LIBS="-lXxf86vm -lXext -lX11 $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 5365 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char res_search(); below.  */
-#include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char res_search();
+char XF86VidModeSetGamma();
 
 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_res_search) || defined (__stub___res_search)
-choke me
-#else
-res_search();
-#endif
-
+XF86VidModeSetGamma()
 ; return 0; }
 EOF
-if { (eval echo configure:5237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5376: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
-  eval "ac_cv_func_res_search=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_func_res_search=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
-fi
+LIBS="$ac_save_LIBS"
 
-if eval "test \"`echo '$ac_cv_func_'res_search`\" = yes"; then
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  :
+  have_xf86gamma=yes
 else
   echo "$ac_t""no" 1>&6
-echo $ac_n "checking for res_search in -lresolv""... $ac_c" 1>&6
-echo "configure:5255: checking for res_search in -lresolv" >&5
-ac_lib_var=`echo resolv'_'res_search | sed 'y%./+-%__p_%'`
+true
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+  fi
+
+  # check for the Ramp versions of the functions too.
+  if test "$have_xf86gamma" = yes; then
+    have_xf86gamma_ramp=no
+    
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for XF86VidModeSetGammaRamp in -lXxf86vm""... $ac_c" 1>&6
+echo "configure:5424: checking for XF86VidModeSetGammaRamp in -lXxf86vm" >&5
+ac_lib_var=`echo Xxf86vm'_'XF86VidModeSetGammaRamp | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lresolv  $LIBS"
+LIBS="-lXxf86vm -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5263 "configure"
+#line 5432 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char res_search();
+char XF86VidModeSetGammaRamp();
 
 int main() {
-res_search()
+XF86VidModeSetGammaRamp()
 ; return 0; }
 EOF
-if { (eval echo configure:5274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5274,151 +5443,266 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  PASSWD_LIBS="${PASSWD_LIBS} -lresolv"
+  have_xf86gamma_ramp=yes
 else
   echo "$ac_t""no" 1>&6
-echo "configure: warning: Can't find DNS resolver libraries needed for Kerberos" 1>&2
-      
+true
 fi
 
-fi
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+  fi
+
+  # if those tests succeeded, then we've really got the functions.
+  if test "$have_xf86gamma" = yes; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_XF86VMODE_GAMMA 1
+EOF
+
+  fi
+
+  if test "$have_xf86gamma_ramp" = yes; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_XF86VMODE_GAMMA_RAMP 1
+EOF
 
+  fi
 
+  # pull in the lib, if we haven't already
+  if test "$have_xf86gamma" = yes -a "$have_xf86vmode" = no; then
+    SAVER_LIBS="$SAVER_LIBS -lXxf86vm"
   fi
+
+elif test "$with_xf86gamma" != no; then
+  echo "error: must be yes or no: --with-xf86gamma-ext=$with_xf86vmode"
+  exit 1
 fi
 
 
 ###############################################################################
 #
-#       Check for the nine billion variants of shadow passwords...
+#       Check for HP XHPDisableReset and XHPEnableReset.
 #
 ###############################################################################
 
-need_setuid=no
 
-have_shadow=no
-with_shadow_req=unspecified
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  cat > conftest.$ac_ext <<EOF
+#line 5509 "configure"
+#include "confdefs.h"
+#include <X11/XHPlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "XHPDisableReset" >/dev/null 2>&1; then
+  rm -rf conftest*
+  cat >> confdefs.h <<\EOF
+#define HAVE_XHPDISABLERESET 1
+EOF
 
-# Check whether --with-shadow or --without-shadow was given.
-if test "${with_shadow+set}" = set; then
-  withval="$with_shadow"
-  with_shadow="$withval"; with_shadow_req="$withval"
-else
-  with_shadow=yes
+                   SAVER_LIBS="-lXhp11 $SAVER_LIBS"
 fi
+rm -f conftest*
 
+  CPPFLAGS="$ac_save_CPPFLAGS"
 
 
-   case "$with_shadow" in
-    yes) ;;
-    no)  ;;
+###############################################################################
+#
+#       Check for /proc/interrupts.
+#
+###############################################################################
 
-    /*)
-     echo $ac_n "checking for shadow password headers""... $ac_c" 1>&6
-echo "configure:5330: checking for shadow password headers" >&5
-     d=$with_shadow/include
-     if test -d $d; then
-       X_CFLAGS="-I$d $X_CFLAGS"
-       echo "$ac_t""$d" 1>&6
-     else
-       echo "$ac_t""not found ($d: no such directory)" 1>&6
-     fi
+have_proc_interrupts=no
+with_proc_interrupts_req=unspecified
+# Check whether --with-proc-interrupts or --without-proc-interrupts was given.
+if test "${with_proc_interrupts+set}" = set; then
+  withval="$with_proc_interrupts"
+  with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"
+else
+  with_proc_interrupts=yes
+fi
 
-     echo $ac_n "checking for shadow password libs""... $ac_c" 1>&6
-echo "configure:5340: checking for shadow password libs" >&5
-     d=$with_shadow/lib
-     if test -d $d; then
-       X_LIBS="-L$d $X_LIBS"
-       echo "$ac_t""$d" 1>&6
-     else
-       echo "$ac_t""not found ($d: no such directory)" 1>&6
+
+if test "$with_proc_interrupts" = yes; then
+
+   echo $ac_n "checking whether /proc/interrupts contains keyboard data""... $ac_c" 1>&6
+echo "configure:5547: checking whether /proc/interrupts contains keyboard data" >&5
+if eval "test \"`echo '$''{'ac_cv_have_proc_interrupts'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_have_proc_interrupts=no
+     if grep keyboard /proc/interrupts >/dev/null 2>&1 ; then
+       ac_cv_have_proc_interrupts=yes
      fi
+    
+fi
 
-     # replace the directory string with "yes".
-     with_shadow_req="yes"
-     with_shadow=$with_shadow_req
-     ;;
+echo "$ac_t""$ac_cv_have_proc_interrupts" 1>&6
+   have_proc_interrupts=$ac_cv_have_proc_interrupts
 
-    *)
-     echo ""
-     echo "error: argument to --with-shadow must be \"yes\", \"no\", or a directory."
-     echo "       If it is a directory, then \`DIR/include' will be added to"
-     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
-     exit 1
-     ;;
-   esac
-  
+  if test "$have_proc_interrupts" = yes; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_PROC_INTERRUPTS 1
+EOF
 
-if test "$enable_locking" = no ; then
-  with_shadow_req=no
-  with_shadow=no
+  fi
+
+elif test "$with_proc_interrupts" != no; then
+  echo "error: must be yes or no: --with-proc-interrupts=$with_proc_interrupts"
+  exit 1
 fi
 
 
 ###############################################################################
 #
-#       Check for Sun "adjunct" passwords.
+#       The --enable-locking option
 #
 ###############################################################################
 
-if test "$with_shadow" = yes ; then
-  echo $ac_n "checking for Sun-style shadow passwords""... $ac_c" 1>&6
-echo "configure:5378: checking for Sun-style shadow passwords" >&5
-if eval "test \"`echo '$''{'ac_cv_sun_adjunct'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+# Check whether --enable-locking or --disable-locking was given.
+if test "${enable_locking+set}" = set; then
+  enableval="$enable_locking"
+  enable_locking="$enableval"
 else
-  
-  ac_save_CPPFLAGS="$CPPFLAGS"
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  cat > conftest.$ac_ext <<EOF
-#line 5389 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-                                    #include <unistd.h>
-                                    #include <sys/types.h>
-                                    #include <sys/label.h>
-                                    #include <sys/audit.h>
-                                    #include <pwdadj.h>
-int main() {
-struct passwd_adjunct *p = getpwanam("nobody");
-                       const char *pw = p->pwa_passwd;
-; return 0; }
+  enable_locking=yes
+fi
+
+if test "$enable_locking" = yes; then
+  true
+elif test "$enable_locking" = no; then
+  cat >> confdefs.h <<\EOF
+#define NO_LOCKING 1
 EOF
-if { (eval echo configure:5402: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  ac_cv_sun_adjunct=yes
+
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_sun_adjunct=no
-fi
-rm -f conftest*
-  CPPFLAGS="$ac_save_CPPFLAGS"
+  echo "error: must be yes or no: --enable-locking=$enable_locking"
+  exit 1
 fi
 
-echo "$ac_t""$ac_cv_sun_adjunct" 1>&6
-  if test "$ac_cv_sun_adjunct" = yes; then
-    have_shadow_adjunct=yes
-    have_shadow=yes
-    need_setuid=yes
-  fi
-fi
 
 
 ###############################################################################
 #
-#       Check for DEC and SCO so-called "enhanced" security.
+#       The --enable-vt-locking option
 #
 ###############################################################################
 
-if test "$with_shadow" = yes ; then
-  echo $ac_n "checking for DEC-style shadow passwords""... $ac_c" 1>&6
-echo "configure:5432: checking for DEC-style shadow passwords" >&5
-if eval "test \"`echo '$''{'ac_cv_enhanced_passwd'+set}'`\" = set"; then
+#ac_vt_lockswitch=no
+#AC_ARG_ENABLE(vt-locking,[
+#  --enable-vt-locking     Compile in support for locking Virtual Terminals.
+#                          This is the default if the system supports it, and
+#                          if locking support is included (--enable-locking.)
+#  --disable-vt-locking    Do not allow locking of VTs, even if locking is
+#                          enabled.],
+#  [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
+#if test "$enable_vt_locking" = yes; then
+#
+#  AC_CACHE_CHECK([for the VT_LOCKSWITCH ioctl], ac_cv_vt_lockswitch,
+#   [AC_TRY_COMPILE([#include <fcntl.h>
+#                   #include <sys/ioctl.h>
+#                   #include <sys/vt.h>],
+#                  [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
+#                  [ac_cv_vt_lockswitch=yes],
+#                  [ac_cv_vt_lockswitch=no])])
+#  ac_vt_lockswitch=$ac_cv_vt_lockswitch
+#
+#elif test "$enable_vt_locking" = no; then
+#  true
+#else
+#  echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
+#  exit 1
+#fi
+#
+#if test "$ac_vt_lockswitch" = yes; then
+#  AC_DEFINE(HAVE_VT_LOCKSWITCH)
+#  # the VT_LOCKSWITCH ioctl can only be used when running as root.
+#  # #### but it doesn't work yet, so don't worry about that for now.
+##  need_setuid=yes
+#fi
+
+
+
+###############################################################################
+#
+#       Check for PAM.
+#
+###############################################################################
+
+case "$host" in
+  *-solaris*)
+   # Solaris systems tend to come with PAM misconfigured.
+   #  Don't build it by default, even if the headers exist.
+   with_pam_default=no
+   ;;
+  *)
+   # Default to building PAM support on all other systems, if it exists.
+   with_pam_default=yes
+  ;;
+esac
+
+have_pam=no
+with_pam_req=unspecified
+
+# Check whether --with-pam or --without-pam was given.
+if test "${with_pam+set}" = set; then
+  withval="$with_pam"
+  with_pam="$withval"; with_pam_req="$withval"
+else
+  with_pam=$with_pam_default
+fi
+
+
+
+   case "$with_pam" in
+    yes) ;;
+    no)  ;;
+
+    /*)
+     echo $ac_n "checking for PAM headers""... $ac_c" 1>&6
+echo "configure:5680: checking for PAM headers" >&5
+     d=$with_pam/include
+     if test -d $d; then
+       X_CFLAGS="-I$d $X_CFLAGS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     echo $ac_n "checking for PAM libs""... $ac_c" 1>&6
+echo "configure:5690: checking for PAM libs" >&5
+     d=$with_pam/lib
+     if test -d $d; then
+       X_LIBS="-L$d $X_LIBS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     # replace the directory string with "yes".
+     with_pam_req="yes"
+     with_pam=$with_pam_req
+     ;;
+
+    *)
+     echo ""
+     echo "error: argument to --with-pam must be \"yes\", \"no\", or a directory."
+     echo "       If it is a directory, then \`DIR/include' will be added to"
+     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
+     exit 1
+     ;;
+   esac
+  
+
+if test "$enable_locking" = yes -a "$with_pam" = yes; then
+  echo $ac_n "checking for PAM""... $ac_c" 1>&6
+echo "configure:5716: checking for PAM" >&5
+if eval "test \"`echo '$''{'ac_cv_pam'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
@@ -5428,67 +5712,58 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 5443 "configure"
+#line 5727 "configure"
 #include "confdefs.h"
-#include <stdlib.h>
-                                    #include <unistd.h>
-                                    #include <sys/types.h>
-                                    #include <pwd.h>
-                                    #include <sys/security.h>
-                                    #include <prot.h>
+#include <security/pam_appl.h>
 int main() {
-struct pr_passwd *p;
-                       const char *pw;
-                       set_auth_parameters(0, 0);
-                       check_auth_parameters();
-                       p = getprpwnam("nobody");
-                       pw = p->ufld.fd_encrypt;
+
 ; return 0; }
 EOF
-if { (eval echo configure:5460: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5734: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
-  ac_cv_enhanced_passwd=yes
+  ac_cv_pam=yes
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  ac_cv_enhanced_passwd=no
+  ac_cv_pam=no
 fi
 rm -f conftest*
   CPPFLAGS="$ac_save_CPPFLAGS"
 fi
 
-echo "$ac_t""$ac_cv_enhanced_passwd" 1>&6
-  if test $ac_cv_enhanced_passwd = yes; then
-    have_shadow_enhanced=yes
-    have_shadow=yes
-    need_setuid=yes
+echo "$ac_t""$ac_cv_pam" 1>&6
+  if test "$ac_cv_pam" = yes ; then
+    have_pam=yes
+    cat >> confdefs.h <<\EOF
+#define HAVE_PAM 1
+EOF
 
-    # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
-    # (I'm told it needs -lcurses too, but I don't understand why.)
-    # But on DEC, it's in -lsecurity.
-    #
-    echo $ac_n "checking for getprpwnam in -lprot""... $ac_c" 1>&6
-echo "configure:5484: checking for getprpwnam in -lprot" >&5
-ac_lib_var=`echo prot'_'getprpwnam | sed 'y%./+-%__p_%'`
+    PASSWD_LIBS="${PASSWD_LIBS} -lpam"
+
+    # libpam typically requires dlopen and dlsym.  On FreeBSD,
+    # those are in libc.  On Linux and Solaris, they're in libdl.
+    echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+echo "configure:5759: checking for dlopen in -ldl" >&5
+ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lprot -lx $LIBS"
+LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5492 "configure"
+#line 5767 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char getprpwnam();
+char dlopen();
 
 int main() {
-getprpwnam()
+dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:5503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5503,64 +5778,141 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"
+  PASSWD_LIBS="${PASSWD_LIBS} -ldl"
 else
   echo "$ac_t""no" 1>&6
-echo $ac_n "checking for getprpwnam in -lsecurity""... $ac_c" 1>&6
-echo "configure:5522: checking for getprpwnam in -lsecurity" >&5
-ac_lib_var=`echo security'_'getprpwnam | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+fi
+
+
+    echo $ac_n "checking how to call pam_strerror""... $ac_c" 1>&6
+echo "configure:5800: checking how to call pam_strerror" >&5
+    if eval "test \"`echo '$''{'ac_cv_pam_strerror_args'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_save_LIBS="$LIBS"
-LIBS="-lsecurity  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 5530 "configure"
+  cat > conftest.$ac_ext <<EOF
+#line 5805 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char getprpwnam();
-
+#include <stdio.h>
+                      #include <stdlib.h>
+                      #include <security/pam_appl.h>
 int main() {
-getprpwnam()
+pam_handle_t *pamh = 0;
+                      char *s = pam_strerror(pamh, PAM_SUCCESS);
 ; return 0; }
 EOF
-if { (eval echo configure:5541: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5815: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  ac_pam_strerror_args=2
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  cat > conftest.$ac_ext <<EOF
+#line 5823 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+                                      #include <stdlib.h>
+                                      #include <security/pam_appl.h>
+int main() {
+char *s =
+                                       pam_strerror(PAM_SUCCESS);
+; return 0; }
+EOF
+if { (eval echo configure:5833: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_pam_strerror_args=1
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_pam_strerror_args=0
 fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
-
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  PASSWD_LIBS="$PASSWD_LIBS -lsecurity"
-else
-  echo "$ac_t""no" 1>&6
+rm -f conftest*
+      ac_cv_pam_strerror_args=$ac_pam_strerror_args
 fi
 
-fi
+    ac_pam_strerror_args=$ac_cv_pam_strerror_args
+    if test "$ac_pam_strerror_args" = 1 ; then
+      echo "$ac_t""one argument" 1>&6
+    elif test "$ac_pam_strerror_args" = 2 ; then
+      cat >> confdefs.h <<\EOF
+#define PAM_STRERROR_TWO_ARGS 1
+EOF
 
+      echo "$ac_t""two arguments" 1>&6
+    else
+      echo "$ac_t""unknown" 1>&6
+    fi
   fi
 fi
 
+
 ###############################################################################
 #
-#       Check for HP's entry in the "Not Invented Here" Sweepstakes.
+#       Check for Kerberos.
 #
 ###############################################################################
 
-if test "$with_shadow" = yes ; then
-  echo $ac_n "checking for HP-style shadow passwords""... $ac_c" 1>&6
-echo "configure:5574: checking for HP-style shadow passwords" >&5
-if eval "test \"`echo '$''{'ac_cv_hpux_passwd'+set}'`\" = set"; then
+have_kerberos=no
+have_kerberos5=no
+with_kerberos_req=unspecified
+
+# Check whether --with-kerberos or --without-kerberos was given.
+if test "${with_kerberos+set}" = set; then
+  withval="$with_kerberos"
+  with_kerberos="$withval"; with_kerberos_req="$withval"
+else
+  with_kerberos=yes
+fi
+
+
+
+   case "$with_kerberos" in
+    yes) ;;
+    no)  ;;
+
+    /*)
+     echo $ac_n "checking for Kerberos headers""... $ac_c" 1>&6
+echo "configure:5890: checking for Kerberos headers" >&5
+     d=$with_kerberos/include
+     if test -d $d; then
+       X_CFLAGS="-I$d $X_CFLAGS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     echo $ac_n "checking for Kerberos libs""... $ac_c" 1>&6
+echo "configure:5900: checking for Kerberos libs" >&5
+     d=$with_kerberos/lib
+     if test -d $d; then
+       X_LIBS="-L$d $X_LIBS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     # replace the directory string with "yes".
+     with_kerberos_req="yes"
+     with_kerberos=$with_kerberos_req
+     ;;
+
+    *)
+     echo ""
+     echo "error: argument to --with-kerberos must be \"yes\", \"no\", or a directory."
+     echo "       If it is a directory, then \`DIR/include' will be added to"
+     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
+     exit 1
+     ;;
+   esac
+  
+
+if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
+  echo $ac_n "checking for Kerberos 4""... $ac_c" 1>&6
+echo "configure:5926: checking for Kerberos 4" >&5
+if eval "test \"`echo '$''{'ac_cv_kerberos'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
@@ -5570,60 +5922,159 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 5585 "configure"
+#line 5937 "configure"
 #include "confdefs.h"
-#include <stdlib.h>
-                                    #include <unistd.h>
-                                    #include <sys/types.h>
-                                    #include <pwd.h>
-                                    #include <hpsecurity.h>
-                                    #include <prot.h>
+#include <krb.h>
 int main() {
-struct s_passwd *p = getspwnam("nobody");
-                       const char *pw = p->pw_passwd;
+
 ; return 0; }
 EOF
-if { (eval echo configure:5598: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5944: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
-  ac_cv_hpux_passwd=yes
+  ac_cv_kerberos=yes
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  ac_cv_hpux_passwd=no
+  ac_cv_kerberos=no
 fi
 rm -f conftest*
   CPPFLAGS="$ac_save_CPPFLAGS"
 fi
 
-echo "$ac_t""$ac_cv_hpux_passwd" 1>&6
-  if test "$ac_cv_hpux_passwd" = yes; then
-    have_shadow_hpux=yes
-    have_shadow=yes
-    need_setuid=yes
+echo "$ac_t""$ac_cv_kerberos" 1>&6
+  echo $ac_n "checking for Kerberos 5""... $ac_c" 1>&6
+echo "configure:5959: checking for Kerberos 5" >&5
+if eval "test \"`echo '$''{'ac_cv_kerberos5'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  cat > conftest.$ac_ext <<EOF
+#line 5970 "configure"
+#include "confdefs.h"
+#include <kerberosIV/krb.h>
+int main() {
 
-    # on HPUX, bigcrypt is in -lsec
-    echo $ac_n "checking for bigcrypt in -lsec""... $ac_c" 1>&6
-echo "configure:5619: checking for bigcrypt in -lsec" >&5
-ac_lib_var=`echo sec'_'bigcrypt | sed 'y%./+-%__p_%'`
+; return 0; }
+EOF
+if { (eval echo configure:5977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_kerberos5=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_kerberos5=no
+fi
+rm -f conftest*
+  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+
+echo "$ac_t""$ac_cv_kerberos5" 1>&6
+
+  if test "$ac_cv_kerberos" = yes ; then
+    have_kerberos=yes
+    cat >> confdefs.h <<\EOF
+#define HAVE_KERBEROS 1
+EOF
+
+  fi
+
+  if test "$ac_cv_kerberos5" = yes ; then
+    have_kerberos=yes
+    have_kerberos5=yes
+    cat >> confdefs.h <<\EOF
+#define HAVE_KERBEROS 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_KERBEROS5 1
+EOF
+
+  fi
+
+  if test "$have_kerberos5" = yes ; then
+    # from Matt Knopp <mhat@infocalypse.netlag.com>
+    # (who got it from amu@mit.edu)
+    PASSWD_LIBS="$PASSWD_LIBS -lkrb4 -ldes425 -lkrb5 -lk5crypto -lcrypt -lcom_err"
+  elif test "$have_kerberos" = yes ; then
+    # from Tim Showalter <tjs@psaux.com> for FreeBSD 4.2
+    PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes -lcom_err"
+  fi
+
+  if test "$have_kerberos" = yes ; then
+    echo $ac_n "checking for res_search""... $ac_c" 1>&6
+echo "configure:6024: checking for res_search" >&5
+if eval "test \"`echo '$''{'ac_cv_func_res_search'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 6029 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char res_search(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char res_search();
+
+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_res_search) || defined (__stub___res_search)
+choke me
+#else
+res_search();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:6052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_res_search=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_res_search=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'res_search`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  :
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for res_search in -lresolv""... $ac_c" 1>&6
+echo "configure:6070: checking for res_search in -lresolv" >&5
+ac_lib_var=`echo resolv'_'res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lsec  $LIBS"
+LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5627 "configure"
+#line 6078 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char bigcrypt();
+char res_search();
 
 int main() {
-bigcrypt()
+res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:5638: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5638,9 +6089,13 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  PASSWD_LIBS="$PASSWD_LIBS -lsec"
+  PASSWD_LIBS="${PASSWD_LIBS} -lresolv"
 else
   echo "$ac_t""no" 1>&6
+echo "configure: warning: Can't find DNS resolver libraries needed for Kerberos" 1>&2
+      
+fi
+
 fi
 
   fi
 
 ###############################################################################
 #
-#       Check for FreeBSD-style shadow passwords.
+#       Check for the nine billion variants of shadow passwords...
 #
-#       On FreeBSD, getpwnam() and friends work just like on non-shadow-
-#       password systems -- except you only get stuff in the pw_passwd field
-#       if the running program is setuid.  So, guess that we've got this
-#       lossage to contend with if /etc/master.passwd exists, and default to
-#       a setuid installation.
+###############################################################################
+
+need_setuid=no
+
+have_shadow=no
+with_shadow_req=unspecified
+
+# Check whether --with-shadow or --without-shadow was given.
+if test "${with_shadow+set}" = set; then
+  withval="$with_shadow"
+  with_shadow="$withval"; with_shadow_req="$withval"
+else
+  with_shadow=yes
+fi
+
+
+
+   case "$with_shadow" in
+    yes) ;;
+    no)  ;;
+
+    /*)
+     echo $ac_n "checking for shadow password headers""... $ac_c" 1>&6
+echo "configure:6144: checking for shadow password headers" >&5
+     d=$with_shadow/include
+     if test -d $d; then
+       X_CFLAGS="-I$d $X_CFLAGS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     echo $ac_n "checking for shadow password libs""... $ac_c" 1>&6
+echo "configure:6154: checking for shadow password libs" >&5
+     d=$with_shadow/lib
+     if test -d $d; then
+       X_LIBS="-L$d $X_LIBS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     # replace the directory string with "yes".
+     with_shadow_req="yes"
+     with_shadow=$with_shadow_req
+     ;;
+
+    *)
+     echo ""
+     echo "error: argument to --with-shadow must be \"yes\", \"no\", or a directory."
+     echo "       If it is a directory, then \`DIR/include' will be added to"
+     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
+     exit 1
+     ;;
+   esac
+  
+
+if test "$enable_locking" = no ; then
+  with_shadow_req=no
+  with_shadow=no
+fi
+
+
+###############################################################################
+#
+#       Check for Sun "adjunct" passwords.
 #
 ###############################################################################
 
 if test "$with_shadow" = yes ; then
-  echo $ac_n "checking for FreeBSD-style shadow passwords""... $ac_c" 1>&6
-echo "configure:5676: checking for FreeBSD-style shadow passwords" >&5
-if eval "test \"`echo '$''{'ac_cv_master_passwd'+set}'`\" = set"; then
+  echo $ac_n "checking for Sun-style shadow passwords""... $ac_c" 1>&6
+echo "configure:6192: checking for Sun-style shadow passwords" >&5
+if eval "test \"`echo '$''{'ac_cv_sun_adjunct'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  if test -f /etc/master.passwd ; then
-                    ac_cv_master_passwd=yes
-                  else
-                    ac_cv_master_passwd=no
-                  fi
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  cat > conftest.$ac_ext <<EOF
+#line 6203 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+                                    #include <unistd.h>
+                                    #include <sys/types.h>
+                                    #include <sys/label.h>
+                                    #include <sys/audit.h>
+                                    #include <pwdadj.h>
+int main() {
+struct passwd_adjunct *p = getpwanam("nobody");
+                       const char *pw = p->pwa_passwd;
+; return 0; }
+EOF
+if { (eval echo configure:6216: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_sun_adjunct=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_sun_adjunct=no
+fi
+rm -f conftest*
+  CPPFLAGS="$ac_save_CPPFLAGS"
 fi
 
-echo "$ac_t""$ac_cv_master_passwd" 1>&6
-  if test "$ac_cv_master_passwd" = yes; then
+echo "$ac_t""$ac_cv_sun_adjunct" 1>&6
+  if test "$ac_cv_sun_adjunct" = yes; then
+    have_shadow_adjunct=yes
+    have_shadow=yes
     need_setuid=yes
   fi
 fi
@@ -5681,14 +6225,14 @@ fi
 
 ###############################################################################
 #
-#       Check for traditional (ha!) shadow passwords.
+#       Check for DEC and SCO so-called "enhanced" security.
 #
 ###############################################################################
 
 if test "$with_shadow" = yes ; then
-  echo $ac_n "checking for generic shadow passwords""... $ac_c" 1>&6
-echo "configure:5702: checking for generic shadow passwords" >&5
-if eval "test \"`echo '$''{'ac_cv_shadow'+set}'`\" = set"; then
+  echo $ac_n "checking for DEC-style shadow passwords""... $ac_c" 1>&6
+echo "configure:6246: checking for DEC-style shadow passwords" >&5
+if eval "test \"`echo '$''{'ac_cv_enhanced_passwd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
@@ -5698,59 +6242,67 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 5713 "configure"
+#line 6257 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                     #include <unistd.h>
                                     #include <sys/types.h>
                                     #include <pwd.h>
-                                    #include <shadow.h>
+                                    #include <sys/security.h>
+                                    #include <prot.h>
 int main() {
-struct spwd *p = getspnam("nobody");
-                       const char *pw = p->sp_pwdp;
+struct pr_passwd *p;
+                       const char *pw;
+                       set_auth_parameters(0, 0);
+                       check_auth_parameters();
+                       p = getprpwnam("nobody");
+                       pw = p->ufld.fd_encrypt;
 ; return 0; }
 EOF
-if { (eval echo configure:5725: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6274: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
-  ac_cv_shadow=yes
+  ac_cv_enhanced_passwd=yes
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  ac_cv_shadow=no
+  ac_cv_enhanced_passwd=no
 fi
 rm -f conftest*
   CPPFLAGS="$ac_save_CPPFLAGS"
 fi
 
-echo "$ac_t""$ac_cv_shadow" 1>&6
-  if test "$ac_cv_shadow" = yes; then
+echo "$ac_t""$ac_cv_enhanced_passwd" 1>&6
+  if test $ac_cv_enhanced_passwd = yes; then
+    have_shadow_enhanced=yes
     have_shadow=yes
     need_setuid=yes
 
-    # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
-    have_getspnam=no
-    echo $ac_n "checking for getspnam in -lc""... $ac_c" 1>&6
-echo "configure:5746: checking for getspnam in -lc" >&5
-ac_lib_var=`echo c'_'getspnam | sed 'y%./+-%__p_%'`
+    # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
+    # (I'm told it needs -lcurses too, but I don't understand why.)
+    # But on DEC, it's in -lsecurity.
+    #
+    echo $ac_n "checking for getprpwnam in -lprot""... $ac_c" 1>&6
+echo "configure:6298: checking for getprpwnam in -lprot" >&5
+ac_lib_var=`echo prot'_'getprpwnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-l $LIBS"
+LIBS="-lprot -lx $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5754 "configure"
+#line 6306 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char getspnam();
+char getprpwnam();
 
 int main() {
-getspnam()
+getprpwnam()
 ; return 0; }
 EOF
-if { (eval echo configure:5765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6317: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5765,33 +6317,30 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_getspnam=yes
+  PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"
 else
   echo "$ac_t""no" 1>&6
-fi
-
-    if test "$have_getspnam" = no ; then
-      echo $ac_n "checking for getspnam in -lgen""... $ac_c" 1>&6
-echo "configure:5787: checking for getspnam in -lgen" >&5
-ac_lib_var=`echo gen'_'getspnam | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for getprpwnam in -lsecurity""... $ac_c" 1>&6
+echo "configure:6336: checking for getprpwnam in -lsecurity" >&5
+ac_lib_var=`echo security'_'getprpwnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lgen  $LIBS"
+LIBS="-lsecurity  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5795 "configure"
+#line 6344 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char getspnam();
+char getprpwnam();
 
 int main() {
-getspnam()
+getprpwnam()
 ; return 0; }
 EOF
-if { (eval echo configure:5806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6355: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5806,88 +6355,89 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"
+  PASSWD_LIBS="$PASSWD_LIBS -lsecurity"
 else
   echo "$ac_t""no" 1>&6
 fi
 
-    fi
-  fi
 fi
 
+  fi
+fi
 
 ###############################################################################
 #
-#       Check for other libraries needed for non-shadow passwords.
+#       Check for HP's entry in the "Not Invented Here" Sweepstakes.
 #
 ###############################################################################
 
-if test "$enable_locking" = yes ; then
-
-  # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
-  have_crypt=no
-  echo $ac_n "checking for crypt in -lc""... $ac_c" 1>&6
-echo "configure:5842: checking for crypt in -lc" >&5
-ac_lib_var=`echo c'_'crypt | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+if test "$with_shadow" = yes ; then
+  echo $ac_n "checking for HP-style shadow passwords""... $ac_c" 1>&6
+echo "configure:6388: checking for HP-style shadow passwords" >&5
+if eval "test \"`echo '$''{'ac_cv_hpux_passwd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_save_LIBS="$LIBS"
-LIBS="-lc  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 5850 "configure"
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  cat > conftest.$ac_ext <<EOF
+#line 6399 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char crypt();
-
+#include <stdlib.h>
+                                    #include <unistd.h>
+                                    #include <sys/types.h>
+                                    #include <pwd.h>
+                                    #include <hpsecurity.h>
+                                    #include <prot.h>
 int main() {
-crypt()
+struct s_passwd *p = getspwnam("nobody");
+                       const char *pw = p->pw_passwd;
 ; return 0; }
 EOF
-if { (eval echo configure:5861: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6412: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  ac_cv_hpux_passwd=yes
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  ac_cv_hpux_passwd=no
 fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  have_crypt=yes
-else
-  echo "$ac_t""no" 1>&6
+  CPPFLAGS="$ac_save_CPPFLAGS"
 fi
 
-  if test "$have_crypt" = no ; then
-    echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:5883: checking for crypt in -lcrypt" >&5
-ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
+echo "$ac_t""$ac_cv_hpux_passwd" 1>&6
+  if test "$ac_cv_hpux_passwd" = yes; then
+    have_shadow_hpux=yes
+    have_shadow=yes
+    need_setuid=yes
+
+    # on HPUX, bigcrypt is in -lsec
+    echo $ac_n "checking for bigcrypt in -lsec""... $ac_c" 1>&6
+echo "configure:6433: checking for bigcrypt in -lsec" >&5
+ac_lib_var=`echo sec'_'bigcrypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lcrypt  $LIBS"
+LIBS="-lsec  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5891 "configure"
+#line 6441 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char crypt();
+char bigcrypt();
 
 int main() {
-crypt()
+bigcrypt()
 ; return 0; }
 EOF
-if { (eval echo configure:5902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5902,7 +6452,7 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"
+  PASSWD_LIBS="$PASSWD_LIBS -lsec"
 else
   echo "$ac_t""no" 1>&6
 fi
 fi
 
 
-# Most of the above shadow mechanisms will have set need_setuid to yes,
-# if they were found.  But, on some systems, we need setuid even when
-# using plain old vanilla passwords.
+###############################################################################
 #
-if test "$enable_locking" = yes ; then
-  case "$host" in
-    *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
-      need_setuid=yes
-    ;;
-  esac
-fi
-
-
-if test "$have_shadow_adjunct" = yes ; then
-  cat >> confdefs.h <<\EOF
-#define HAVE_ADJUNCT_PASSWD 1
-EOF
-
-elif test "$have_shadow_enhanced" = yes ; then
-  cat >> confdefs.h <<\EOF
-#define HAVE_ENHANCED_PASSWD 1
-EOF
-
-elif test "$have_shadow_hpux" = yes ; then
-  cat >> confdefs.h <<\EOF
-#define HAVE_HPUX_PASSWD 1
-EOF
+#       Check for FreeBSD-style shadow passwords.
+#
+#       On FreeBSD, getpwnam() and friends work just like on non-shadow-
+#       password systems -- except you only get stuff in the pw_passwd field
+#       if the running program is setuid.  So, guess that we've got this
+#       lossage to contend with if /etc/master.passwd exists, and default to
+#       a setuid installation.
+#
+###############################################################################
 
-elif test "$have_shadow" = yes ; then
-  cat >> confdefs.h <<\EOF
-#define HAVE_SHADOW_PASSWD 1
-EOF
+if test "$with_shadow" = yes ; then
+  echo $ac_n "checking for FreeBSD-style shadow passwords""... $ac_c" 1>&6
+echo "configure:6490: checking for FreeBSD-style shadow passwords" >&5
+if eval "test \"`echo '$''{'ac_cv_master_passwd'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -f /etc/master.passwd ; then
+                    ac_cv_master_passwd=yes
+                  else
+                    ac_cv_master_passwd=no
+                  fi
+fi
 
+echo "$ac_t""$ac_cv_master_passwd" 1>&6
+  if test "$ac_cv_master_passwd" = yes; then
+    need_setuid=yes
+  fi
 fi
 
 
 ###############################################################################
 #
-#       Check for -lXm.
+#       Check for traditional (ha!) shadow passwords.
 #
 ###############################################################################
 
-have_motif=no
-with_motif_req=unspecified
-# Check whether --with-motif or --without-motif was given.
-if test "${with_motif+set}" = set; then
-  withval="$with_motif"
-  with_motif="$withval"; with_motif_req="$withval"
+if test "$with_shadow" = yes ; then
+  echo $ac_n "checking for generic shadow passwords""... $ac_c" 1>&6
+echo "configure:6516: checking for generic shadow passwords" >&5
+if eval "test \"`echo '$''{'ac_cv_shadow'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
-  with_motif=yes
-fi
-
-
-
-   case "$with_motif" in
-    yes) ;;
-    no)  ;;
-
-    /*)
-     echo $ac_n "checking for Motif headers""... $ac_c" 1>&6
-echo "configure:5986: checking for Motif headers" >&5
-     d=$with_motif/include
-     if test -d $d; then
-       X_CFLAGS="-I$d $X_CFLAGS"
-       echo "$ac_t""$d" 1>&6
-     else
-       echo "$ac_t""not found ($d: no such directory)" 1>&6
-     fi
-
-     echo $ac_n "checking for Motif libs""... $ac_c" 1>&6
-echo "configure:5996: checking for Motif libs" >&5
-     d=$with_motif/lib
-     if test -d $d; then
-       X_LIBS="-L$d $X_LIBS"
-       echo "$ac_t""$d" 1>&6
-     else
-       echo "$ac_t""not found ($d: no such directory)" 1>&6
-     fi
-
-     # replace the directory string with "yes".
-     with_motif_req="yes"
-     with_motif=$with_motif_req
-     ;;
-
-    *)
-     echo ""
-     echo "error: argument to --with-motif must be \"yes\", \"no\", or a directory."
-     echo "       If it is a directory, then \`DIR/include' will be added to"
-     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
-     exit 1
-     ;;
-   esac
-  
-
-if test "$with_motif" != yes -a "$with_motif" != no ; then
-  echo "error: must be yes or no: --with-motif=$with_motif"
-  exit 1
-fi
-
-if test "$with_motif" = yes; then
-  have_motif=no
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:6035: checking for Xm/Xm.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  cat > conftest.$ac_ext <<EOF
+#line 6527 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+                                    #include <unistd.h>
+                                    #include <sys/types.h>
+                                    #include <pwd.h>
+                                    #include <shadow.h>
+int main() {
+struct spwd *p = getspnam("nobody");
+                       const char *pw = p->sp_pwdp;
+; return 0; }
+EOF
+if { (eval echo configure:6539: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_shadow=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_shadow=no
+fi
+rm -f conftest*
+  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+
+echo "$ac_t""$ac_cv_shadow" 1>&6
+  if test "$ac_cv_shadow" = yes; then
+    have_shadow=yes
+    need_setuid=yes
+
+    # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
+    have_getspnam=no
+    echo $ac_n "checking for getspnam in -lc""... $ac_c" 1>&6
+echo "configure:6560: checking for getspnam in -lc" >&5
+ac_lib_var=`echo c'_'getspnam | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 6040 "configure"
+  ac_save_LIBS="$LIBS"
+LIBS="-lc  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 6568 "configure"
 #include "confdefs.h"
-#include <Xm/Xm.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char getspnam();
+
+int main() {
+getspnam()
+; return 0; }
 EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6045: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
+if { (eval echo configure:6579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
-  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
+LIBS="$ac_save_LIBS"
+
 fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_motif=yes
-                     cat >> confdefs.h <<\EOF
-#define HAVE_MOTIF 1
+  have_getspnam=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+    if test "$have_getspnam" = no ; then
+      echo $ac_n "checking for getspnam in -lgen""... $ac_c" 1>&6
+echo "configure:6601: checking for getspnam in -lgen" >&5
+ac_lib_var=`echo gen'_'getspnam | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lgen  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 6609 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char getspnam();
+
+int main() {
+getspnam()
+; return 0; }
 EOF
+if { (eval echo configure:6620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
 
-                     MOTIF_LIBS="$MOTIF_LIBS -lXm"
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"
 else
   echo "$ac_t""no" 1>&6
 fi
 
-  CPPFLAGS="$ac_save_CPPFLAGS"
+    fi
+  fi
 fi
 
 
 ###############################################################################
 #
-#       Check for -lgtk.
+#       Check for other libraries needed for non-shadow passwords.
 #
 ###############################################################################
 
-have_gtk=no
-with_gtk_req=unspecified
-# Check whether --with-gtk or --without-gtk was given.
-if test "${with_gtk+set}" = set; then
-  withval="$with_gtk"
-  with_gtk="$withval"; with_gtk_req="$withval"
+if test "$enable_locking" = yes ; then
+
+  # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
+  have_crypt=no
+  echo $ac_n "checking for crypt in -lc""... $ac_c" 1>&6
+echo "configure:6656: checking for crypt in -lc" >&5
+ac_lib_var=`echo c'_'crypt | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
-  with_gtk=yes
+  ac_save_LIBS="$LIBS"
+LIBS="-lc  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 6664 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char crypt();
+
+int main() {
+crypt()
+; return 0; }
+EOF
+if { (eval echo configure:6675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
 
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_crypt=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
 
-# if --with-gtk=/directory/ was specified, remember that directory so that
-# we can also look for the `gtk-config' program in that directory.
-case "$with_gtk" in
-  /*)
-    gtk_dir="$with_gtk"
-    ;;
-  *)
-    gtk_dir=""
+  if test "$have_crypt" = no ; then
+    echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
+echo "configure:6697: checking for crypt in -lcrypt" >&5
+ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lcrypt  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 6705 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char crypt();
+
+int main() {
+crypt()
+; return 0; }
+EOF
+if { (eval echo configure:6716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  fi
+fi
+
+
+# Most of the above shadow mechanisms will have set need_setuid to yes,
+# if they were found.  But, on some systems, we need setuid even when
+# using plain old vanilla passwords.
+#
+if test "$enable_locking" = yes ; then
+  case "$host" in
+    *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
+      need_setuid=yes
     ;;
-esac
+  esac
+fi
 
 
-   case "$with_gtk" in
+if test "$have_shadow_adjunct" = yes ; then
+  cat >> confdefs.h <<\EOF
+#define HAVE_ADJUNCT_PASSWD 1
+EOF
+
+elif test "$have_shadow_enhanced" = yes ; then
+  cat >> confdefs.h <<\EOF
+#define HAVE_ENHANCED_PASSWD 1
+EOF
+
+elif test "$have_shadow_hpux" = yes ; then
+  cat >> confdefs.h <<\EOF
+#define HAVE_HPUX_PASSWD 1
+EOF
+
+elif test "$have_shadow" = yes ; then
+  cat >> confdefs.h <<\EOF
+#define HAVE_SHADOW_PASSWD 1
+EOF
+
+fi
+
+
+###############################################################################
+#
+#       Check for -lXm.
+#
+###############################################################################
+
+have_motif=no
+with_motif_req=unspecified
+# Check whether --with-motif or --without-motif was given.
+if test "${with_motif+set}" = set; then
+  withval="$with_motif"
+  with_motif="$withval"; with_motif_req="$withval"
+else
+  with_motif=yes
+fi
+
+
+
+   case "$with_motif" in
     yes) ;;
     no)  ;;
 
     /*)
-     echo $ac_n "checking for Gtk headers""... $ac_c" 1>&6
-echo "configure:6110: checking for Gtk headers" >&5
-     d=$with_gtk/include
+     echo $ac_n "checking for Motif headers""... $ac_c" 1>&6
+echo "configure:6800: checking for Motif headers" >&5
+     d=$with_motif/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
        echo "$ac_t""$d" 1>&6
@@ -6104,9 +6794,9 @@ echo "configure:6110: checking for Gtk headers" >&5
        echo "$ac_t""not found ($d: no such directory)" 1>&6
      fi
 
-     echo $ac_n "checking for Gtk libs""... $ac_c" 1>&6
-echo "configure:6120: checking for Gtk libs" >&5
-     d=$with_gtk/lib
+     echo $ac_n "checking for Motif libs""... $ac_c" 1>&6
+echo "configure:6810: checking for Motif libs" >&5
+     d=$with_motif/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
        echo "$ac_t""$d" 1>&6
@@ -6115,13 +6805,13 @@ echo "configure:6120: checking for Gtk libs" >&5
      fi
 
      # replace the directory string with "yes".
-     with_gtk_req="yes"
-     with_gtk=$with_gtk_req
+     with_motif_req="yes"
+     with_motif=$with_motif_req
      ;;
 
     *)
      echo ""
-     echo "error: argument to --with-gtk must be \"yes\", \"no\", or a directory."
+     echo "error: argument to --with-motif must be \"yes\", \"no\", or a directory."
      echo "       If it is a directory, then \`DIR/include' will be added to"
      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
      exit 1
@@ -6129,193 +6819,1213 @@ echo "configure:6120: checking for Gtk libs" >&5
    esac
   
 
-if test "$with_gtk" != yes -a "$with_gtk" != no ; then
-  echo "error: must be yes or no: --with-gtk=$with_gtk"
+if test "$with_motif" != yes -a "$with_motif" != no ; then
+  echo "error: must be yes or no: --with-motif=$with_motif"
   exit 1
 fi
 
-jurassic_gtk=no
-if test "$with_gtk" = yes; then
-  have_gtk=no
+if test "$with_motif" = yes; then
+  have_motif=no
   
-  # if the user specified --with-gtk=/foo/ then look in /foo/bin/
-  # for glib-config and gtk-config.
-  #
-  gtk_path="$PATH"
-
-  if test ! -z "$gtk_dir"; then
-    # canonicalize slashes.
-    gtk_dir=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
-    gtk_path="$gtk_dir:$gtk_dir:$gtk_path"
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-
-  for ac_prog in glib-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:6169: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_glib_config'+set}'`\" = set"; then
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
+echo "configure:6849: checking for Xm/Xm.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  case "$glib_config" in
-  /*)
-  ac_cv_path_glib_config="$glib_config" # Let the user override the test with a path.
-  ;;
-  ?:/*)                         
-  ac_cv_path_glib_config="$glib_config" # Let the user override the test with a dos path.
-  ;;
-  *)
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$gtk_path"
-  for ac_dir in $ac_dummy; do 
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_path_glib_config="$ac_dir/$ac_word"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-  ;;
-esac
-fi
-glib_config="$ac_cv_path_glib_config"
-if test -n "$glib_config"; then
-  echo "$ac_t""$glib_config" 1>&6
+  cat > conftest.$ac_ext <<EOF
+#line 6854 "configure"
+#include "confdefs.h"
+#include <Xm/Xm.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:6859: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
 else
-  echo "$ac_t""no" 1>&6
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
 fi
-
-test -n "$glib_config" && break
-done
-
-  for ac_prog in gtk-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:6209: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_gtk_config'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  case "$gtk_config" in
-  /*)
-  ac_cv_path_gtk_config="$gtk_config" # Let the user override the test with a path.
-  ;;
-  ?:/*)                         
-  ac_cv_path_gtk_config="$gtk_config" # Let the user override the test with a dos path.
-  ;;
-  *)
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$gtk_path"
-  for ac_dir in $ac_dummy; do 
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_path_gtk_config="$ac_dir/$ac_word"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-  ;;
-esac
+rm -f conftest*
 fi
-gtk_config="$ac_cv_path_gtk_config"
-if test -n "$gtk_config"; then
-  echo "$ac_t""$gtk_config" 1>&6
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_motif=yes
+                     cat >> confdefs.h <<\EOF
+#define HAVE_MOTIF 1
+EOF
+
+                     MOTIF_LIBS="$MOTIF_LIBS -lXm"
 else
   echo "$ac_t""no" 1>&6
 fi
 
-test -n "$gtk_config" && break
-done
+  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
 
 
-  if test -n "$glib_config" -a  -n "gtk_config" ; then
-    have_gtk=yes
+if test "$have_motif" = yes; then
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test "$have_gtk" = yes; then
-    echo $ac_n "checking Gtk version number""... $ac_c" 1>&6
-echo "configure:6250: checking Gtk version number" >&5
-if eval "test \"`echo '$''{'ac_cv_gtk_version_string'+set}'`\" = set"; then
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  ac_safe=`echo "Xm/ComboBox.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for Xm/ComboBox.h""... $ac_c" 1>&6
+echo "configure:6898: checking for Xm/ComboBox.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_cv_gtk_version_string=`$glib_config --version`
+  cat > conftest.$ac_ext <<EOF
+#line 6903 "configure"
+#include "confdefs.h"
+#include <Xm/ComboBox.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:6908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
 fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<\EOF
+#define HAVE_XMCOMBOBOX 1
+EOF
 
-echo "$ac_t""$ac_cv_gtk_version_string" 1>&6
-    ac_gtk_version_string=$ac_cv_gtk_version_string
-    # M4 sucks!!
-    
-    maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
-    min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
-    
-    ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
-    if test -z "$ac_gtk_version"; then
-      ac_gtk_version=unknown
-      ac_gtk_version_string=unknown
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+
+
+###############################################################################
+#
+#       Check for -lgtk (and Gnome stuff)
+#
+###############################################################################
+
+have_gtk=no
+with_gtk_req=unspecified
+# Check whether --with-gtk or --without-gtk was given.
+if test "${with_gtk+set}" = set; then
+  withval="$with_gtk"
+  with_gtk="$withval"; with_gtk_req="$withval"
+else
+  with_gtk=yes
+fi
+
+
+# if --with-gtk=/directory/ was specified, remember that directory so that
+# we can also look for the `gtk-config' program in that directory.
+case "$with_gtk" in
+  /*)
+    gtk_dir="$with_gtk"
+    ;;
+  *)
+    gtk_dir=""
+    ;;
+esac
+
+
+   case "$with_gtk" in
+    yes) ;;
+    no)  ;;
+
+    /*)
+     echo $ac_n "checking for Gtk headers""... $ac_c" 1>&6
+echo "configure:6971: checking for Gtk headers" >&5
+     d=$with_gtk/include
+     if test -d $d; then
+       X_CFLAGS="-I$d $X_CFLAGS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     echo $ac_n "checking for Gtk libs""... $ac_c" 1>&6
+echo "configure:6981: checking for Gtk libs" >&5
+     d=$with_gtk/lib
+     if test -d $d; then
+       X_LIBS="-L$d $X_LIBS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     # replace the directory string with "yes".
+     with_gtk_req="yes"
+     with_gtk=$with_gtk_req
+     ;;
+
+    *)
+     echo ""
+     echo "error: argument to --with-gtk must be \"yes\", \"no\", or a directory."
+     echo "       If it is a directory, then \`DIR/include' will be added to"
+     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
+     exit 1
+     ;;
+   esac
+  
+
+if test "$with_gtk" != yes -a "$with_gtk" != no ; then
+  echo "error: must be yes or no: --with-gtk=$with_gtk"
+  exit 1
+fi
+
+have_gnome=no
+with_gnome_req=unspecified
+# Check whether --with-gnome or --without-gnome was given.
+if test "${with_gnome+set}" = set; then
+  withval="$with_gnome"
+  with_gnome="$withval"; with_gnome_req="$withval"
+else
+  with_gnome=yes
+fi
+
+
+# if --with-gnome=/directory/ was specified, remember that directory so that
+# we can also look for the `gnome-config' program in that directory.
+case "$with_gnome" in
+  /*)
+    gnome_dir="$with_gnome"
+    ;;
+  *)
+    gnome_dir=""
+    ;;
+esac
+
+
+   case "$with_gnome" in
+    yes) ;;
+    no)  ;;
+
+    /*)
+     echo $ac_n "checking for Gnome headers""... $ac_c" 1>&6
+echo "configure:7039: checking for Gnome headers" >&5
+     d=$with_gnome/include
+     if test -d $d; then
+       X_CFLAGS="-I$d $X_CFLAGS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     echo $ac_n "checking for Gnome libs""... $ac_c" 1>&6
+echo "configure:7049: checking for Gnome libs" >&5
+     d=$with_gnome/lib
+     if test -d $d; then
+       X_LIBS="-L$d $X_LIBS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     # replace the directory string with "yes".
+     with_gnome_req="yes"
+     with_gnome=$with_gnome_req
+     ;;
+
+    *)
+     echo ""
+     echo "error: argument to --with-gnome must be \"yes\", \"no\", or a directory."
+     echo "       If it is a directory, then \`DIR/include' will be added to"
+     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
+     exit 1
+     ;;
+   esac
+  
+
+if test "$with_gnome" != yes -a "$with_gnome" != no ; then
+  echo "error: must be yes or no: --with-gnome=$with_gnome"
+  exit 1
+fi
+
+
+jurassic_gtk=no
+if test "$with_gtk" = yes; then
+  have_gtk=no
+  
+  # if the user specified --with-gtk=/foo/ then look in /foo/bin/
+  # for glib-config and gtk-config.
+  #
+  gtk_path="$PATH"
+
+  if test ! -z "$gtk_dir"; then
+    # canonicalize slashes.
+    gtk_dir=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
+    gtk_path="$gtk_dir:$gtk_path"
+  fi
+
+  if test ! -z "gnome_dir"; then
+    # canonicalize slashes.
+    gnome_dir=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
+    gtk_path="$gnome_dir:$gtk_path"
+  fi
+
+  for ac_prog in glib12-config glib-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:7105: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_glib_config'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  case "$glib_config" in
+  /*)
+  ac_cv_path_glib_config="$glib_config" # Let the user override the test with a path.
+  ;;
+  ?:/*)                         
+  ac_cv_path_glib_config="$glib_config" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$gtk_path"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_glib_config="$ac_dir/$ac_word"
+      break
     fi
-    if test "$ac_gtk_version" = "unknown" || test "$ac_gtk_version" -lt 1002
-    then
-      have_gtk=no
-      jurassic_gtk=yes
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+fi
+glib_config="$ac_cv_path_glib_config"
+if test -n "$glib_config"; then
+  echo "$ac_t""$glib_config" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$glib_config" && break
+done
+
+  for ac_prog in gtk12-config  gtk-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:7145: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_gtk_config'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  case "$gtk_config" in
+  /*)
+  ac_cv_path_gtk_config="$gtk_config" # Let the user override the test with a path.
+  ;;
+  ?:/*)                         
+  ac_cv_path_gtk_config="$gtk_config" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$gtk_path"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_gtk_config="$ac_dir/$ac_word"
+      break
     fi
-  fi
-  if test "$have_gtk" = yes; then
-    echo $ac_n "checking for Gtk includes""... $ac_c" 1>&6
-echo "configure:6277: checking for Gtk includes" >&5
-if eval "test \"`echo '$''{'ac_cv_gtk_config_cflags'+set}'`\" = set"; then
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+fi
+gtk_config="$ac_cv_path_gtk_config"
+if test -n "$gtk_config"; then
+  echo "$ac_t""$gtk_config" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$gtk_config" && break
+done
+
+
+  if test "$with_gnome" = yes; then
+    for ac_prog in gnome-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:7187: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_gnome_config'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_cv_gtk_config_cflags=`$gtk_config --cflags`
+  case "$gnome_config" in
+  /*)
+  ac_cv_path_gnome_config="$gnome_config" # Let the user override the test with a path.
+  ;;
+  ?:/*)                         
+  ac_cv_path_gnome_config="$gnome_config" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$gtk_path"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_gnome_config="$ac_dir/$ac_word"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+fi
+gnome_config="$ac_cv_path_gnome_config"
+if test -n "$gnome_config"; then
+  echo "$ac_t""$gnome_config" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$gnome_config" && break
+done
+
+  fi
+
+  if test -n "$glib_config" -a  -n "gtk_config" ; then
+    have_gtk=yes
+    if test "$with_gnome" = yes -a -n "$gnome_config" ; then
+      have_gnome=yes
+    fi
+  fi
+
+  if test "$have_gtk" = yes; then
+    echo $ac_n "checking Gtk version number""... $ac_c" 1>&6
+echo "configure:7233: checking Gtk version number" >&5
+if eval "test \"`echo '$''{'ac_cv_gtk_version_string'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_gtk_version_string=`$gtk_config --version`
+fi
+
+echo "$ac_t""$ac_cv_gtk_version_string" 1>&6
+    ac_gtk_version_string=$ac_cv_gtk_version_string
+    # M4 sucks!!
+    
+    maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
+    min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
+    
+    ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
+    if test -z "$ac_gtk_version"; then
+      ac_gtk_version=unknown
+      ac_gtk_version_string=unknown
+    fi
+    if test "$ac_gtk_version" = "unknown" || test "$ac_gtk_version" -lt 1002
+    then
+      have_gtk=no
+      have_gnome=no
+      jurassic_gtk=yes
+    fi
+  fi
+
+  if test "$have_gtk" = yes; then
+    echo $ac_n "checking for Gtk includes""... $ac_c" 1>&6
+echo "configure:7262: checking for Gtk includes" >&5
+if eval "test \"`echo '$''{'ac_cv_gtk_config_cflags'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_gtk_config_cflags=`$gtk_config --cflags`
+fi
+
+echo "$ac_t""$ac_cv_gtk_config_cflags" 1>&6
+    echo $ac_n "checking for Gtk libs""... $ac_c" 1>&6
+echo "configure:7271: checking for Gtk libs" >&5
+if eval "test \"`echo '$''{'ac_cv_gtk_config_libs'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_gtk_config_libs=`$gtk_config --libs`
+fi
+
+echo "$ac_t""$ac_cv_gtk_config_libs" 1>&6
+  fi
+  ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
+  ac_gtk_config_libs=$ac_cv_gtk_config_libs
+
+  # Check for Gnome Capplet support.
+  #
+  if test "$have_gnome" = yes -a "$have_gtk" = yes; then
+    gnome_config_libs="gtk capplet gnomeui xml gdk_pixbuf"
+    echo $ac_n "checking for Gnome capplet includes""... $ac_c" 1>&6
+echo "configure:7288: checking for Gnome capplet includes" >&5
+    if eval "test \"`echo '$''{'ac_cv_gnome_config_cflags'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if ( $gnome_config --cflags $gnome_config_libs 2>&1 >/dev/null | \
+            grep Unknown >/dev/null ) ; then
+         ac_cv_gnome_config_cflags=''
+       else
+         ac_cv_gnome_config_cflags=`$gnome_config --cflags $gnome_config_libs`
+       fi
+fi
+
+    ac_gnome_config_cflags=$ac_cv_gnome_config_cflags
+    if test "$ac_gnome_config_cflags" = "" ; then
+      have_gnome=no
+      echo "$ac_t""no" 1>&6
+    else
+      echo "$ac_t""$ac_gnome_config_cflags" 1>&6
+    fi
+  fi
+
+  if test "$have_gnome" = yes -a "$have_gtk" = yes; then
+    echo $ac_n "checking for Gnome capplet libs""... $ac_c" 1>&6
+echo "configure:7311: checking for Gnome capplet libs" >&5
+    if eval "test \"`echo '$''{'ac_cv_gnome_config_libs'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if ( $gnome_config --libs $gnome_config_libs 2>&1 >/dev/null |
+            grep Unknown >/dev/null ) ; then
+         ac_cv_gnome_config_libs=''
+       else
+         ac_cv_gnome_config_libs=`$gnome_config --libs $gnome_config_libs`
+       fi
+fi
+
+    ac_gnome_config_libs=$ac_cv_gnome_config_libs
+    if test "$ac_gnome_config_libs" = "" ; then
+      have_gnome=no
+      echo "$ac_t""no" 1>&6
+    else
+      echo "$ac_t""$ac_gnome_config_libs" 1>&6
+    fi
+  fi
+
+  GNOME_DATADIR=""
+  if test "$have_gnome" = yes -a "$have_gtk" = yes; then
+    GNOME_DATADIR=`$gnome_config --datadir`
+  fi
+
+
+  # If we have Gnome, then override the gtk-config values with 
+  # the gnome-config values.
+  #
+  if test "$have_gnome" = yes -a "$have_gtk" = yes; then
+    ac_gtk_config_cflags=$ac_gnome_config_cflags
+    ac_gtk_config_libs=$ac_gnome_config_libs
+    cat >> confdefs.h <<\EOF
+#define HAVE_CRAPPLET 1
+EOF
+
+
+    # check for this function that was not in libcapplet 1.2.
+    
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for capplet_widget_changes_are_immediate in -lcapplet""... $ac_c" 1>&6
+echo "configure:7368: checking for capplet_widget_changes_are_immediate in -lcapplet" >&5
+ac_lib_var=`echo capplet'_'capplet_widget_changes_are_immediate | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lcapplet $ac_gnome_config_libs $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 7376 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char capplet_widget_changes_are_immediate();
+
+int main() {
+capplet_widget_changes_are_immediate()
+; return 0; }
+EOF
+if { (eval echo configure:7387: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<\EOF
+#define HAVE_CRAPPLET_IMMEDIATE 1
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+true
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+  fi
+
+
+  if test "$have_gtk" = yes; then
+    INCLUDES="$INCLUDES $ac_gtk_config_cflags"
+    GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
+    cat >> confdefs.h <<\EOF
+#define HAVE_GTK 1
+EOF
+
+  fi
+
+fi
+
+
+# Check for the Gnome Help Browser.
+#
+if test "$have_gnome" = yes; then
+  # Extract the first word of "gnome-help-browser", so it can be a program name with args.
+set dummy gnome-help-browser; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:7436: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_have_gnome_help'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$have_gnome_help"; then
+  ac_cv_prog_have_gnome_help="$have_gnome_help" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_have_gnome_help="yes"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_prog_have_gnome_help" && ac_cv_prog_have_gnome_help="no"
+fi
+fi
+have_gnome_help="$ac_cv_prog_have_gnome_help"
+if test -n "$have_gnome_help"; then
+  echo "$ac_t""$have_gnome_help" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+else
+  have_gnome_help=no
+fi
+
+
+###############################################################################
+#
+#       Check for -lxml (if we have Gtk)
+#
+###############################################################################
+
+have_xml=no
+with_xml_req=unspecified
+xml_halfassed=no
+# Check whether --with-xml or --without-xml was given.
+if test "${with_xml+set}" = set; then
+  withval="$with_xml"
+  with_xml="$withval"; with_xml_req="$withval"
+else
+  with_xml=yes
+fi
+
+
+
+   case "$with_xml" in
+    yes) ;;
+    no)  ;;
+
+    /*)
+     echo $ac_n "checking for XML headers""... $ac_c" 1>&6
+echo "configure:7493: checking for XML headers" >&5
+     d=$with_xml/include
+     if test -d $d; then
+       X_CFLAGS="-I$d $X_CFLAGS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     echo $ac_n "checking for XML libs""... $ac_c" 1>&6
+echo "configure:7503: checking for XML libs" >&5
+     d=$with_xml/lib
+     if test -d $d; then
+       X_LIBS="-L$d $X_LIBS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     # replace the directory string with "yes".
+     with_xml_req="yes"
+     with_xml=$with_xml_req
+     ;;
+
+    *)
+     echo ""
+     echo "error: argument to --with-xml must be \"yes\", \"no\", or a directory."
+     echo "       If it is a directory, then \`DIR/include' will be added to"
+     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
+     exit 1
+     ;;
+   esac
+  
+
+if test "$with_xml" != yes -a "$with_xml" != no ; then
+  echo "error: must be yes or no: --with-xml=$with_xml"
+  exit 1
+fi
+
+if test "$have_gtk" != yes; then
+  # don't bother if no GTK
+  with_xml=no
+fi
+
+if test "$with_xml" = yes; then
+  have_xml=no
+
+  # the XML stuff is likely to be in GTK paths.
+  ac_save_X_CFLAGS="$X_CFLAGS"
+  ac_save_X_LIBS="$X_LIBS"
+  X_CFLAGS="$X_CFLAGS $ac_gtk_config_cflags"
+  X_LIBS="$X_LIBS $ac_gtk_config_libs"
+
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  ac_safe=`echo "xmlIO.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for xmlIO.h""... $ac_c" 1>&6
+echo "configure:7554: checking for xmlIO.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 7559 "configure"
+#include "confdefs.h"
+#include <xmlIO.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:7564: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_xml=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+
+  if test "$have_xml" = yes; then
+    # we have the header, now check for the library
+    have_xml=no
+    xml_halfassed=yes
+    
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for xmlParseChunk in -lxml""... $ac_c" 1>&6
+echo "configure:7609: checking for xmlParseChunk in -lxml" >&5
+ac_lib_var=`echo xml'_'xmlParseChunk | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lxml  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 7617 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char xmlParseChunk();
+
+int main() {
+xmlParseChunk()
+; return 0; }
+EOF
+if { (eval echo configure:7628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_xml=yes
+                    xml_halfassed=no
+                    XML_LIBS="-lxml"
+                    cat >> confdefs.h <<\EOF
+#define HAVE_XML 1
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+  fi
+
+  X_CFLAGS="$ac_save_X_CFLAGS"
+  X_LIBS="$ac_save_X_LIBS"
+
+fi
+
+
+###############################################################################
+#
+#       Checking whether Motif is really Lesstif.
+#
+###############################################################################
+
+have_lesstif=no
+if test "$have_motif" = yes ; then
+  echo $ac_n "checking whether Motif is really LessTif""... $ac_c" 1>&6
+echo "configure:7675: checking whether Motif is really LessTif" >&5
+if eval "test \"`echo '$''{'ac_cv_have_lesstif'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  cat > conftest.$ac_ext <<EOF
+#line 7686 "configure"
+#include "confdefs.h"
+#include <Xm/Xm.h>
+int main() {
+long vers = LesstifVersion;
+; return 0; }
+EOF
+if { (eval echo configure:7693: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_have_lesstif=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_have_lesstif=no
+fi
+rm -f conftest*
+  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+
+echo "$ac_t""$ac_cv_have_lesstif" 1>&6
+  have_lesstif=$ac_cv_have_lesstif
+fi
+
+
+lesstif_version=unknown
+lesstif_version_string=unknown
+
+if test "$have_lesstif" = yes ; then
+  ltv=unknown
+  echo unknown > conftest-lt
+  echo $ac_n "checking LessTif version number""... $ac_c" 1>&6
+echo "configure:7718: checking LessTif version number" >&5
+if eval "test \"`echo '$''{'ac_cv_lesstif_version_string'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  if test "$cross_compiling" = yes; then
+  ac_cv_lesstif_version=unknown
+                     ac_cv_lesstif_version_string=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 7733 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+                     #include <Xm/Xm.h>
+                     int main() {
+                       FILE *f = fopen("conftest-lt", "w");
+                       if (!f) exit(1);
+                       fprintf(f, "%d %d.%d\n", LesstifVersion,
+                          LESSTIF_VERSION, LESSTIF_REVISION);
+                       fclose(f);
+                       exit(0);
+                     }
+EOF
+if { (eval echo configure:7746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ltv=`cat conftest-lt`
+                     ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
+                     ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  ac_cv_lesstif_version=unknown
+                     ac_cv_lesstif_version_string=unknown
+fi
+rm -fr conftest*
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+
+echo "$ac_t""$ac_cv_lesstif_version_string" 1>&6
+  rm -f conftest-lt
+  lesstif_version=$ac_cv_lesstif_version
+  lesstif_version_string=$ac_cv_lesstif_version_string
+
+fi
+
+
+if test "$have_motif" = yes ; then
+  mtv=unknown
+  echo unknown > conftest-mt
+  echo $ac_n "checking Motif version number""... $ac_c" 1>&6
+echo "configure:7776: checking Motif version number" >&5
+if eval "test \"`echo '$''{'ac_cv_motif_version_string'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  if test "$cross_compiling" = yes; then
+  ac_cv_motif_version=unknown
+                     ac_cv_motif_version_string=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 7791 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+                     #include <Xm/Xm.h>
+                     int main() {
+                       FILE *f = fopen("conftest-mt", "w");
+                       if (!f) exit(1);
+                       fprintf(f, "%d %d.%d\n", XmVersion,
+                          XmVERSION, XmREVISION);
+                       fclose(f);
+                       exit(0);
+                     }
+EOF
+if { (eval echo configure:7804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  mtv=`cat conftest-mt`
+                     ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
+                     ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  ac_cv_motif_version=unknown
+                     ac_cv_motif_version_string=unknown
+fi
+rm -fr conftest*
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+
+echo "$ac_t""$ac_cv_motif_version_string" 1>&6
+  rm -f conftest-mt
+  motif_version=$ac_cv_motif_version
+  motif_version_string=$ac_cv_motif_version_string
+
+fi
+
+
+###############################################################################
+#
+#       Checking whether Motif requires -lXpm.
+#
+#       If this is Motif 2.x, and we have XPM, then link against XPM as well.
+#       The deal is, Motif 2.x requires XPM -- but it's a compilation option
+#       of the library whether to build the XPM code into libXm, or whether
+#       to rely on an external libXm.  So the only way to tell whether XPM is
+#       a link-time requirement is to examine libXm.a, which is very
+#       difficult to do in an autoconf script.  So... if it's Motif 2.x, we
+#       always link against XPM if the XPM lib exists (and this will be a
+#       no-op if libXm happens to already have the XPM code in it.)
+#
+###############################################################################
+
+motif_requires_xpm=no
+if test "$have_motif" = yes ; then
+   echo $ac_n "checking whether Motif requires XPM""... $ac_c" 1>&6
+echo "configure:7848: checking whether Motif requires XPM" >&5
+   if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
+   then
+     motif_requires_xpm=yes
+     echo "$ac_t""maybe" 1>&6
+   else
+     echo "$ac_t""no" 1>&6
+   fi
+fi
+
+
+###############################################################################
+#
+#       Checking whether Motif requires -lXp.
+#
+#       Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
+#       Extension".   Why this extension isn't in -lXext with all the others,
+#       I have no idea.
+#
+###############################################################################
+
+have_xp_ext=no
+if test "$have_motif" = yes ; then
+   have_xp_ext=no
+   
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for XpQueryExtension in -lXp""... $ac_c" 1>&6
+echo "configure:7890: checking for XpQueryExtension in -lXp" >&5
+ac_lib_var=`echo Xp'_'XpQueryExtension | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lXp -lX11 -lXext -lm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 7898 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char XpQueryExtension();
+
+int main() {
+XpQueryExtension()
+; return 0; }
+EOF
+if { (eval echo configure:7909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"
+else
+  echo "$ac_t""no" 1>&6
+true
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+fi
+
+
+###############################################################################
+#
+#       Checking whether Motif requires -lXintl (for _Xsetlocale.)
+#
+###############################################################################
+
+have_xintl=no
+if test "$have_motif" = yes ; then
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for _Xsetlocale in -lXintl""... $ac_c" 1>&6
+echo "configure:7963: checking for _Xsetlocale in -lXintl" >&5
+ac_lib_var=`echo Xintl'_'_Xsetlocale | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lXintl -lX11 -lXext -lm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 7971 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char _Xsetlocale();
+
+int main() {
+_Xsetlocale()
+; return 0; }
+EOF
+if { (eval echo configure:7982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
 
-echo "$ac_t""$ac_cv_gtk_config_cflags" 1>&6
-    echo $ac_n "checking for Gtk libs""... $ac_c" 1>&6
-echo "configure:6286: checking for Gtk libs" >&5
-if eval "test \"`echo '$''{'ac_cv_gtk_config_libs'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_xintl=yes
 else
-  ac_cv_gtk_config_libs=`$gtk_config --libs`
+  echo "$ac_t""no" 1>&6
+have_xintl=no
 fi
 
-echo "$ac_t""$ac_cv_gtk_config_libs" 1>&6
-    INCLUDES="$INCLUDES $ac_cv_gtk_config_cflags"
-    GTK_LIBS="$GTK_LIBS $ac_cv_gtk_config_libs"
-    cat >> confdefs.h <<\EOF
-#define HAVE_GTK 1
-EOF
-
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+  if test "$have_xintl" = yes; then
+    MOTIF_LIBS="$MOTIF_LIBS -lXintl"
   fi
 fi
 
 
 ###############################################################################
 #
-#       Check for -lXaw and -lXaw3d.
+#       Check for -lGL or -lMesaGL.
 #
 ###############################################################################
 
-have_athena=no
-have_athena3d=no
-with_athena_req=unspecified
-# Check whether --with-athena or --without-athena was given.
-if test "${with_athena+set}" = set; then
-  withval="$with_athena"
-  with_athena="$withval"; with_athena_req="$withval"
+have_gl=no
+ac_have_mesa_gl=no
+with_gl_req=unspecified
+gl_halfassed=no
+# Check whether --with-gl or --without-gl was given.
+if test "${with_gl+set}" = set; then
+  withval="$with_gl"
+  with_gl="$withval"; with_gl_req="$withval"
 else
-  with_athena=yes
+  with_gl=yes
 fi
 
 
 
-   case "$with_athena" in
+   case "$with_gl" in
     yes) ;;
     no)  ;;
 
     /*)
-     echo $ac_n "checking for Athena headers""... $ac_c" 1>&6
-echo "configure:6329: checking for Athena headers" >&5
-     d=$with_athena/include
+     echo $ac_n "checking for GL headers""... $ac_c" 1>&6
+echo "configure:8039: checking for GL headers" >&5
+     d=$with_gl/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
        echo "$ac_t""$d" 1>&6
@@ -6323,9 +8033,9 @@ echo "configure:6329: checking for Athena headers" >&5
        echo "$ac_t""not found ($d: no such directory)" 1>&6
      fi
 
-     echo $ac_n "checking for Athena libs""... $ac_c" 1>&6
-echo "configure:6339: checking for Athena libs" >&5
-     d=$with_athena/lib
+     echo $ac_n "checking for GL libs""... $ac_c" 1>&6
+echo "configure:8049: checking for GL libs" >&5
+     d=$with_gl/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
        echo "$ac_t""$d" 1>&6
@@ -6334,13 +8044,13 @@ echo "configure:6339: checking for Athena libs" >&5
      fi
 
      # replace the directory string with "yes".
-     with_athena_req="yes"
-     with_athena=$with_athena_req
+     with_gl_req="yes"
+     with_gl=$with_gl_req
      ;;
 
     *)
      echo ""
-     echo "error: argument to --with-athena must be \"yes\", \"no\", or a directory."
+     echo "error: argument to --with-gl must be \"yes\", \"no\", or a directory."
      echo "       If it is a directory, then \`DIR/include' will be added to"
      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
      exit 1
@@ -6348,34 +8058,29 @@ echo "configure:6339: checking for Athena libs" >&5
    esac
   
 
+ac_mesagl_version=unknown
+ac_mesagl_version_string=unknown
 
-if test "$with_athena" != yes -a "$with_athena" != no ; then
-  echo "error: must be yes or no: --with-athena=$with_athena"
-  exit 1
-fi
-
-
-if test "$with_athena" = yes; then
-  have_athena=no
+if test "$with_gl" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "X11/Xaw/Dialog.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for X11/Xaw/Dialog.h""... $ac_c" 1>&6
-echo "configure:6380: checking for X11/Xaw/Dialog.h" >&5
+  ac_safe=`echo "GL/gl.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for GL/gl.h""... $ac_c" 1>&6
+echo "configure:8085: checking for GL/gl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6385 "configure"
+#line 8090 "configure"
 #include "confdefs.h"
-#include <X11/Xaw/Dialog.h>
+#include <GL/gl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6390: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8095: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6391,338 +8096,218 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_athena=yes
+  have_gl=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  if test "$have_athena" = yes; then
+  if test "$have_gl" = yes ; then
     
   ac_save_CPPFLAGS="$CPPFLAGS"
-  ac_save_LDFLAGS="$LDFLAGS"
-#  ac_save_LIBS="$LIBS"
-
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  # note: $X_CFLAGS includes $x_includes
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-
-  if test \! -z "$libdir" ; then
-    LDFLAGS="$LDFLAGS -L$libdir"
-  fi
-  # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
-
-  echo $ac_n "checking for Xaw3dComputeTopShadowRGB in -lXaw3d""... $ac_c" 1>&6
-echo "configure:6431: checking for Xaw3dComputeTopShadowRGB in -lXaw3d" >&5
-ac_lib_var=`echo Xaw3d'_'Xaw3dComputeTopShadowRGB | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  ac_safe=`echo "GL/glx.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for GL/glx.h""... $ac_c" 1>&6
+echo "configure:8126: checking for GL/glx.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_save_LIBS="$LIBS"
-LIBS="-lXaw3d -lXt -lXmu -lXext -lX11 $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 6439 "configure"
+  cat > conftest.$ac_ext <<EOF
+#line 8131 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char Xaw3dComputeTopShadowRGB();
-
-int main() {
-Xaw3dComputeTopShadowRGB()
-; return 0; }
+#include <GL/glx.h>
 EOF
-if { (eval echo configure:6450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:8136: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  eval "ac_cv_header_$ac_safe=yes"
 else
+  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  eval "ac_cv_header_$ac_safe=no"
 fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
-
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_athena=yes; have_athena3d=yes
+  have_gl=yes
 else
   echo "$ac_t""no" 1>&6
-true
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  LDFLAGS="$ac_save_LDFLAGS"
-#  LIBS="$ac_save_LIBS"
-  
   fi
-fi
-
-if test "$have_athena" = yes; then
-  cat >> confdefs.h <<\EOF
-#define HAVE_ATHENA 1
-EOF
-
-  ATHENA_LIBS="-lXaw $ATHENA_LIBS"
-fi
-
-if test "$have_athena3d" = yes; then
-  ATHENA3D_LIBS="-lXaw3d $ATHENA3D_LIBS"
-fi
 
+  # If we have the headers, try and figure out which vendor it's from.
+  #
+  if test "$have_gl" = yes ; then
 
-# If we have Athena, check whether it's a version that includes
-# XawViewportSetCoordinates in Viewport.h (R3 (or R4?) don't.)
-if test "$have_athena" = yes ; then
-  echo $ac_n "checking for XawViewportSetCoordinates in Viewport.h""... $ac_c" 1>&6
-echo "configure:6495: checking for XawViewportSetCoordinates in Viewport.h" >&5
-if eval "test \"`echo '$''{'ac_cv_have_XawViewportSetCoordinates'+set}'`\" = set"; then
+    # We need to know whether it's MesaGL so that we know which libraries
+    # to link against.
+    #
+    echo $ac_n "checking whether GL is really MesaGL""... $ac_c" 1>&6
+echo "configure:8168: checking whether GL is really MesaGL" >&5
+if eval "test \"`echo '$''{'ac_cv_have_mesa_gl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_cv_have_XawViewportSetCoordinates=no
-                  
+  ac_cv_have_mesa_gl=no
+       
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6507 "configure"
+#line 8180 "configure"
 #include "confdefs.h"
-#include <X11/Xaw/Viewport.h>
+#include <GL/glx.h>
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "XawViewportSetCoordinates" >/dev/null 2>&1; then
+  egrep "Mesa|MESA" >/dev/null 2>&1; then
   rm -rf conftest*
-  ac_cv_have_XawViewportSetCoordinates=yes
+  ac_cv_have_mesa_gl=yes
 fi
 rm -f conftest*
 
   CPPFLAGS="$ac_save_CPPFLAGS"
+      
 fi
 
-echo "$ac_t""$ac_cv_have_XawViewportSetCoordinates" 1>&6
-  if test "$ac_cv_have_XawViewportSetCoordinates" = yes ; then
-    cat >> confdefs.h <<\EOF
-#define HAVE_XawViewportSetCoordinates 1
-EOF
-
-  fi
-fi
+echo "$ac_t""$ac_cv_have_mesa_gl" 1>&6
+    ac_have_mesa_gl=$ac_cv_have_mesa_gl
 
+    gl_lib_1=""
+    GL_LIBS=""
 
-###############################################################################
-#
-#       Checking whether Motif is really Lesstif.
-#
-###############################################################################
 
-have_lesstif=no
-if test "$have_motif" = yes ; then
-  echo $ac_n "checking whether Motif is really LessTif""... $ac_c" 1>&6
-echo "configure:6540: checking whether Motif is really LessTif" >&5
-if eval "test \"`echo '$''{'ac_cv_have_lesstif'+set}'`\" = set"; then
+    # Some versions of MesaGL are compiled to require -lpthread.
+    # So if the Mesa headers exist, and -lpthread exists, then always
+    # link -lpthread after the Mesa libs (be they named -lGL or -lMesaGL.)
+    #
+    if test "$ac_have_mesa_gl" = yes; then
+      echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+echo "configure:8209: checking for pthread_create in -lpthread" >&5
+ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  
-  ac_save_CPPFLAGS="$CPPFLAGS"
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  cat > conftest.$ac_ext <<EOF
-#line 6551 "configure"
+  ac_save_LIBS="$LIBS"
+LIBS="-lpthread  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 8217 "configure"
 #include "confdefs.h"
-#include <Xm/Xm.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char pthread_create();
+
 int main() {
-long vers = LesstifVersion;
+pthread_create()
 ; return 0; }
 EOF
-if { (eval echo configure:6558: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
-  ac_cv_have_lesstif=yes
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  ac_cv_have_lesstif=no
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
-  CPPFLAGS="$ac_save_CPPFLAGS"
-fi
+LIBS="$ac_save_LIBS"
 
-echo "$ac_t""$ac_cv_have_lesstif" 1>&6
-  have_lesstif=$ac_cv_have_lesstif
 fi
-
-
-lesstif_version=unknown
-lesstif_version_string=unknown
-
-if test "$have_lesstif" = yes ; then
-  ltv=unknown
-  echo unknown > conftest-lt
-  echo $ac_n "checking LessTif version number""... $ac_c" 1>&6
-echo "configure:6583: checking LessTif version number" >&5
-if eval "test \"`echo '$''{'ac_cv_lesstif_version_string'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  
-  ac_save_CPPFLAGS="$CPPFLAGS"
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test "$cross_compiling" = yes; then
-  ac_cv_lesstif_version=unknown
-                     ac_cv_lesstif_version_string=unknown
-else
-  cat > conftest.$ac_ext <<EOF
-#line 6598 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-                     #include <Xm/Xm.h>
-                     int main() {
-                       FILE *f = fopen("conftest-lt", "w");
-                       if (!f) exit(1);
-                       fprintf(f, "%d %d.%d\n", LesstifVersion,
-                          LESSTIF_VERSION, LESSTIF_REVISION);
-                       fclose(f);
-                       exit(0);
-                     }
-EOF
-if { (eval echo configure:6611: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
-  ltv=`cat conftest-lt`
-                     ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
-                     ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  GL_LIBS="-lpthread"
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  ac_cv_lesstif_version=unknown
-                     ac_cv_lesstif_version_string=unknown
-fi
-rm -fr conftest*
-fi
-
-  CPPFLAGS="$ac_save_CPPFLAGS"
+  echo "$ac_t""no" 1>&6
 fi
 
-echo "$ac_t""$ac_cv_lesstif_version_string" 1>&6
-  rm -f conftest-lt
-  lesstif_version=$ac_cv_lesstif_version
-  lesstif_version_string=$ac_cv_lesstif_version_string
+    fi
 
-fi
 
+    # If we have Mesa headers, check to see if we can link against -lMesaGL.
+    # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
+    # Else, warn that GL is busted.  (We have the headers, but no libs.)
+    #
 
-if test "$have_motif" = yes ; then
-  mtv=unknown
-  echo unknown > conftest-mt
-  echo $ac_n "checking Motif version number""... $ac_c" 1>&6
-echo "configure:6641: checking Motif version number" >&5
-if eval "test \"`echo '$''{'ac_cv_motif_version_string'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  
+    if test "$ac_have_mesa_gl" = yes ; then
+      
   ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
+  # note: $X_CFLAGS includes $x_includes
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test "$cross_compiling" = yes; then
-  ac_cv_motif_version=unknown
-                     ac_cv_motif_version_string=unknown
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for glXCreateContext in -lMesaGL""... $ac_c" 1>&6
+echo "configure:8275: checking for glXCreateContext in -lMesaGL" >&5
+ac_lib_var=`echo MesaGL'_'glXCreateContext | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 6656 "configure"
+  ac_save_LIBS="$LIBS"
+LIBS="-lMesaGL -lMesaGLU $GL_LIBS -lX11 -lXext -lm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 8283 "configure"
 #include "confdefs.h"
-#include <stdio.h>
-                     #include <Xm/Xm.h>
-                     int main() {
-                       FILE *f = fopen("conftest-mt", "w");
-                       if (!f) exit(1);
-                       fprintf(f, "%d %d.%d\n", XmVersion,
-                          XmVERSION, XmREVISION);
-                       fclose(f);
-                       exit(0);
-                     }
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char glXCreateContext();
+
+int main() {
+glXCreateContext()
+; return 0; }
 EOF
-if { (eval echo configure:6669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
-  mtv=`cat conftest-mt`
-                     ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
-                     ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`
+if { (eval echo configure:8294: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  ac_cv_motif_version=unknown
-                     ac_cv_motif_version_string=unknown
-fi
-rm -fr conftest*
-fi
-
-  CPPFLAGS="$ac_save_CPPFLAGS"
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
-
-echo "$ac_t""$ac_cv_motif_version_string" 1>&6
-  rm -f conftest-mt
-  motif_version=$ac_cv_motif_version
-  motif_version_string=$ac_cv_motif_version_string
+rm -f conftest*
+LIBS="$ac_save_LIBS"
 
 fi
-
-
-###############################################################################
-#
-#       Checking whether Motif requires -lXpm.
-#
-#       If this is Motif 2.x, and we have XPM, then link against XPM as well.
-#       The deal is, Motif 2.x requires XPM -- but it's a compilation option
-#       of the library whether to build the XPM code into libXm, or whether
-#       to rely on an external libXm.  So the only way to tell whether XPM is
-#       a link-time requirement is to examine libXm.a, which is very
-#       difficult to do in an autoconf script.  So... if it's Motif 2.x, we
-#       always link against XPM if the XPM lib exists (and this will be a
-#       no-op if libXm happens to already have the XPM code in it.)
-#
-###############################################################################
-
-motif_requires_xpm=no
-if test "$have_motif" = yes ; then
-   echo $ac_n "checking whether Motif requires XPM""... $ac_c" 1>&6
-echo "configure:6713: checking whether Motif requires XPM" >&5
-   if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
-   then
-     motif_requires_xpm=yes
-     echo "$ac_t""maybe" 1>&6
-   else
-     echo "$ac_t""no" 1>&6
-   fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  gl_lib_1="MesaGL"
+                      GL_LIBS="-lMesaGL -lMesaGLU $GL_LIBS"
+else
+  echo "$ac_t""no" 1>&6
 fi
 
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+    fi
 
-###############################################################################
-#
-#       Checking whether Motif requires -lXp.
-#
-#       Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
-#       Extension".   Why this extension isn't in -lXext with all the others,
-#       I have no idea.
-#
-###############################################################################
-
-have_xp_ext=no
-if test "$have_motif" = yes ; then
-   have_xp_ext=no
-   
+    if test "$gl_lib_1" = "" ; then
+      
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
 #  ac_save_LIBS="$LIBS"
@@ -6737,29 +8322,29 @@ if test "$have_motif" = yes ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
-  echo $ac_n "checking for XpQueryExtension in -lXp""... $ac_c" 1>&6
-echo "configure:6755: checking for XpQueryExtension in -lXp" >&5
-ac_lib_var=`echo Xp'_'XpQueryExtension | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for glXCreateContext in -lGL""... $ac_c" 1>&6
+echo "configure:8340: checking for glXCreateContext in -lGL" >&5
+ac_lib_var=`echo GL'_'glXCreateContext | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lXp -lX11 -lXext -lm $LIBS"
+LIBS="-lGL -lGLU $GL_LIBS -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6763 "configure"
+#line 8348 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char XpQueryExtension();
+char glXCreateContext();
 
 int main() {
-XpQueryExtension()
+glXCreateContext()
 ; return 0; }
 EOF
-if { (eval echo configure:6774: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6774,28 +8359,108 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"
+  gl_lib_1="GL"
+                      GL_LIBS="-lGL -lGLU $GL_LIBS"
 else
   echo "$ac_t""no" 1>&6
-true
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
   LDFLAGS="$ac_save_LDFLAGS"
 #  LIBS="$ac_save_LIBS"
   
+    fi
+
+    if test "$gl_lib_1" = "" ; then
+      # we have headers, but no libs -- bail.
+      have_gl=no
+      ac_have_mesa_gl=no
+      gl_halfassed=yes
+    else
+      # linking works -- we can build the GL hacks.
+      cat >> confdefs.h <<\EOF
+#define HAVE_GL 1
+EOF
+
+      if test "$ac_have_mesa_gl" = yes ; then
+        cat >> confdefs.h <<\EOF
+#define HAVE_MESA_GL 1
+EOF
+
+      fi
+    fi
+  fi
+
+
+  # Now that we know we have GL headers and libs, do some more GL testing.
+  #
+
+  if test "$have_gl" = yes ; then
+    # If it's MesaGL, we'd like to issue a warning if the version number
+    # is less than or equal to 2.6, because that version had a security bug.
+    #
+    if test "$ac_have_mesa_gl" = yes; then
+
+      echo $ac_n "checking MesaGL version number""... $ac_c" 1>&6
+echo "configure:8417: checking MesaGL version number" >&5
+if eval "test \"`echo '$''{'ac_cv_mesagl_version_string'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 8422 "configure"
+#include "confdefs.h"
+#include <GL/gl.h>
+#ifndef MESA_MAJOR_VERSION
+# include <GL/xmesa.h>
+# define MESA_MAJOR_VERSION XMESA_MAJOR_VERSION
+# define MESA_MINOR_VERSION XMESA_MINOR_VERSION
+#endif
+configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
+EOF
+
+         ac_save_CPPFLAGS="$CPPFLAGS"
+         if test \! -z "$includedir" ; then 
+           CPPFLAGS="$CPPFLAGS -I$includedir"
+         fi
+         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+          # M4 sucks!!
+         
+         mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | sed -n \
+              's/^configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
+         
+
+         rm -f conftest.$ac_ext
+
+         CPPFLAGS="$ac_save_CPPFLAGS"
+
+         if test "$mglv" = ""; then
+           ac_mesagl_version=unknown
+           ac_mesagl_version_string=unknown
+         else
+           ac_mesagl_version_string=$mglv
+           maj=`echo $mglv | sed -n 's/\..*//p'`
+           min=`echo $mglv | sed -n 's/.*\.//p'`
+           ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
+           if test -z "$ac_mesagl_version"; then
+             ac_mesagl_version=unknown
+             ac_mesagl_version_string=unknown
+           fi
+         fi
+         ac_cv_mesagl_version=$ac_mesagl_version
+         ac_cv_mesagl_version_string=$ac_mesagl_version_string
+      
 fi
 
+echo "$ac_t""$ac_cv_mesagl_version_string" 1>&6
+      ac_mesagl_version=$ac_cv_mesagl_version
+      ac_mesagl_version_string=$ac_cv_mesagl_version_string
+    fi
 
-###############################################################################
-#
-#       Checking whether Motif requires -lXintl (for _Xsetlocale.)
-#
-###############################################################################
 
-have_xintl=no
-if test "$have_motif" = yes ; then
-  
+    # Check for OpenGL 1.1 features.
+    #
+    
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
 #  ac_save_LIBS="$LIBS"
@@ -6810,29 +8475,29 @@ if test "$have_motif" = yes ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
-  echo $ac_n "checking for _Xsetlocale in -lXintl""... $ac_c" 1>&6
-echo "configure:6828: checking for _Xsetlocale in -lXintl" >&5
-ac_lib_var=`echo Xintl'_'_Xsetlocale | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for glBindTexture in -l$gl_lib_1""... $ac_c" 1>&6
+echo "configure:8493: checking for glBindTexture in -l$gl_lib_1" >&5
+ac_lib_var=`echo $gl_lib_1'_'glBindTexture | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lXintl -lX11 -lXext -lm $LIBS"
+LIBS="-l$gl_lib_1 $GL_LIBS -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6836 "configure"
+#line 8501 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char _Xsetlocale();
+char glBindTexture();
 
 int main() {
-_Xsetlocale()
+glBindTexture()
 ; return 0; }
 EOF
-if { (eval echo configure:6847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8512: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6847,49 +8512,54 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_xintl=yes
+  cat >> confdefs.h <<\EOF
+#define HAVE_GLBINDTEXTURE 1
+EOF
+
 else
   echo "$ac_t""no" 1>&6
-have_xintl=no
+true
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
   LDFLAGS="$ac_save_LDFLAGS"
 #  LIBS="$ac_save_LIBS"
   
-  if test "$have_xintl" = yes; then
-    MOTIF_LIBS="$MOTIF_LIBS -lXintl"
   fi
+
+elif test "$with_gl" != no; then
+  echo "error: must be yes or no: --with-gl=$with_gl"
+  exit 1
 fi
 
 
 ###############################################################################
 #
-#       Check for -lGL or -lMesaGL.
+#       Check for -lgle.
 #
 ###############################################################################
 
-have_gl=no
-ac_have_mesa_gl=no
-with_gl_req=unspecified
-# Check whether --with-gl or --without-gl was given.
-if test "${with_gl+set}" = set; then
-  withval="$with_gl"
-  with_gl="$withval"; with_gl_req="$withval"
+have_gle=no
+with_gle_req=unspecified
+gle_halfassed=no
+# Check whether --with-gle or --without-gle was given.
+if test "${with_gle+set}" = set; then
+  withval="$with_gle"
+  with_gle="$withval"; with_gle_req="$withval"
 else
-  with_gl=yes
+  with_gle=yes
 fi
 
 
 
-   case "$with_gl" in
+   case "$with_gle" in
     yes) ;;
     no)  ;;
 
     /*)
-     echo $ac_n "checking for GL headers""... $ac_c" 1>&6
-echo "configure:6903: checking for GL headers" >&5
-     d=$with_gl/include
+     echo $ac_n "checking for GLE headers""... $ac_c" 1>&6
+echo "configure:8573: checking for GLE headers" >&5
+     d=$with_gle/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
        echo "$ac_t""$d" 1>&6
@@ -6897,9 +8567,9 @@ echo "configure:6903: checking for GL headers" >&5
        echo "$ac_t""not found ($d: no such directory)" 1>&6
      fi
 
-     echo $ac_n "checking for GL libs""... $ac_c" 1>&6
-echo "configure:6913: checking for GL libs" >&5
-     d=$with_gl/lib
+     echo $ac_n "checking for GLE libs""... $ac_c" 1>&6
+echo "configure:8583: checking for GLE libs" >&5
+     d=$with_gle/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
        echo "$ac_t""$d" 1>&6
@@ -6908,13 +8578,13 @@ echo "configure:6913: checking for GL libs" >&5
      fi
 
      # replace the directory string with "yes".
-     with_gl_req="yes"
-     with_gl=$with_gl_req
+     with_gle_req="yes"
+     with_gle=$with_gle_req
      ;;
 
     *)
      echo ""
-     echo "error: argument to --with-gl must be \"yes\", \"no\", or a directory."
+     echo "error: argument to --with-gle must be \"yes\", \"no\", or a directory."
      echo "       If it is a directory, then \`DIR/include' will be added to"
      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
      exit 1
@@ -6922,29 +8592,29 @@ echo "configure:6913: checking for GL libs" >&5
    esac
   
 
-ac_mesagl_version=unknown
-ac_mesagl_version_string=unknown
+GLE_LIBS=""
+
+if test "$with_gle" = yes; then
 
-if test "$with_gl" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "GL/gl.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for GL/gl.h""... $ac_c" 1>&6
-echo "configure:6949: checking for GL/gl.h" >&5
+  ac_safe=`echo "GL/gle.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for GL/gle.h""... $ac_c" 1>&6
+echo "configure:8619: checking for GL/gle.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6954 "configure"
+#line 8624 "configure"
 #include "confdefs.h"
-#include <GL/gl.h>
+#include <GL/gle.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6959: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8629: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6960,32 +8630,34 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_gl=yes
+  have_gle3=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  if test "$have_gl" = yes ; then
+  if test "$have_gle3" = yes ; then
+    have_gle=yes;
+  else
     
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "GL/glx.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for GL/glx.h""... $ac_c" 1>&6
-echo "configure:6990: checking for GL/glx.h" >&5
+  ac_safe=`echo "GL/gutil.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for GL/gutil.h""... $ac_c" 1>&6
+echo "configure:8662: checking for GL/gutil.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6995 "configure"
+#line 8667 "configure"
 #include "confdefs.h"
-#include <GL/glx.h>
+#include <GL/gutil.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8672: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7001,127 +8673,60 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_gl=yes
+  have_gle=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  fi
-
-  # If we have the headers, try and figure out which vendor it's from.
-  #
-  if test "$have_gl" = yes ; then
-
-    # We need to know whether it's MesaGL so that we know which libraries
-    # to link against.
-    #
-    echo $ac_n "checking whether GL is really MesaGL""... $ac_c" 1>&6
-echo "configure:7032: checking whether GL is really MesaGL" >&5
-if eval "test \"`echo '$''{'ac_cv_have_mesa_gl'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_cv_have_mesa_gl=no
-       
-  ac_save_CPPFLAGS="$CPPFLAGS"
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  cat > conftest.$ac_ext <<EOF
-#line 7044 "configure"
-#include "confdefs.h"
-#include <GL/glx.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "Mesa" >/dev/null 2>&1; then
-  rm -rf conftest*
-  ac_cv_have_mesa_gl=yes
-fi
-rm -f conftest*
-
-  CPPFLAGS="$ac_save_CPPFLAGS"
-      
-fi
-
-echo "$ac_t""$ac_cv_have_mesa_gl" 1>&6
-    ac_have_mesa_gl=$ac_cv_have_mesa_gl
-
-    # If we have Mesa headers, check to see if we can link against -lMesaGL.
-    # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
-    # Else, warn that GL is busted.  (We have the headers, but no libs.)
-    #
-    gl_lib_1=""
-    GL_LIBS=""
-
-    if test "$ac_have_mesa_gl" = yes ; then
+    if test "$have_gle" = yes ; then
       
   ac_save_CPPFLAGS="$CPPFLAGS"
-  ac_save_LDFLAGS="$LDFLAGS"
-#  ac_save_LIBS="$LIBS"
-
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  # note: $X_CFLAGS includes $x_includes
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-
-  if test \! -z "$libdir" ; then
-    LDFLAGS="$LDFLAGS -L$libdir"
-  fi
-  # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
-
-  echo $ac_n "checking for glXCreateContext in -lMesaGL""... $ac_c" 1>&6
-echo "configure:7089: checking for glXCreateContext in -lMesaGL" >&5
-ac_lib_var=`echo MesaGL'_'glXCreateContext | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  ac_safe=`echo "GL/tube.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for GL/tube.h""... $ac_c" 1>&6
+echo "configure:8703: checking for GL/tube.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_save_LIBS="$LIBS"
-LIBS="-lMesaGL -lMesaGLU -lX11 -lXext -lm $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 7097 "configure"
+  cat > conftest.$ac_ext <<EOF
+#line 8708 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char glXCreateContext();
-
-int main() {
-glXCreateContext()
-; return 0; }
+#include <GL/tube.h>
 EOF
-if { (eval echo configure:7108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:8713: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  eval "ac_cv_header_$ac_safe=yes"
 else
+  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  eval "ac_cv_header_$ac_safe=no"
 fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
-
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  gl_lib_1="MesaGL"
-                      GL_LIBS="-lMesaGL -lMesaGLU"
+  have_gle=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  LDFLAGS="$ac_save_LDFLAGS"
-#  LIBS="$ac_save_LIBS"
-  
     fi
+  fi
 
-    if test "$gl_lib_1" = "" ; then
-      
+  if test "$have_gle" = yes ; then
+    have_gle=no
+    gle_halfassed=yes
+    
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
 #  ac_save_LIBS="$LIBS"
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
-  echo $ac_n "checking for glXCreateContext in -lGL""... $ac_c" 1>&6
-echo "configure:7154: checking for glXCreateContext in -lGL" >&5
-ac_lib_var=`echo GL'_'glXCreateContext | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lGL -lGLU -lX11 -lXext -lm $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 7162 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char glXCreateContext();
-
-int main() {
-glXCreateContext()
-; return 0; }
-EOF
-if { (eval echo configure:7173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  gl_lib_1="GL"
-                      GL_LIBS="-lGL -lGLU"
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-  CPPFLAGS="$ac_save_CPPFLAGS"
-  LDFLAGS="$ac_save_LDFLAGS"
-#  LIBS="$ac_save_LIBS"
-  
-    fi
-
-    if test "$gl_lib_1" = "" ; then
-      # we have headers, but no libs -- bail.
-      have_gl=no
-      ac_have_mesa_gl=no
-    else
-      # linking works -- we can build the GL hacks.
-      cat >> confdefs.h <<\EOF
-#define HAVE_GL 1
-EOF
-
-      if test "$ac_have_mesa_gl" = yes ; then
-        cat >> confdefs.h <<\EOF
-#define HAVE_MESA_GL 1
-EOF
-
-      fi
-    fi
-  fi
-
-
-  # Now that we know we have GL headers and libs, do some more GL testing.
-  #
-
-  if test "$have_gl" = yes ; then
-    # If it's MesaGL, we'd like to issue a warning if the version number
-    # is less than or equal to 2.6, because that version had a security bug.
-    #
-    if test "$ac_have_mesa_gl" = yes; then
-
-      echo $ac_n "checking MesaGL version number""... $ac_c" 1>&6
-echo "configure:7230: checking MesaGL version number" >&5
-if eval "test \"`echo '$''{'ac_cv_mesagl_version_string'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 7235 "configure"
-#include "confdefs.h"
-#include <GL/gl.h>
-configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
-EOF
-
-         ac_save_CPPFLAGS="$CPPFLAGS"
-         if test \! -z "$includedir" ; then 
-           CPPFLAGS="$CPPFLAGS -I$includedir"
-         fi
-         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-
-          # M4 sucks!!
-         
-         mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | sed -n \
-              's/^configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
-         
-
-         rm -f conftest.$ac_ext
-
-         CPPFLAGS="$ac_save_CPPFLAGS"
-
-         if test "$mglv" = ""; then
-           ac_mesagl_version=unknown
-           ac_mesagl_version_string=unknown
-         else
-           ac_mesagl_version_string=$mglv
-           maj=`echo $mglv | sed -n 's/\..*//p'`
-           min=`echo $mglv | sed -n 's/.*\.//p'`
-           ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
-           if test -z "$ac_mesagl_version"; then
-             ac_mesagl_version=unknown
-             ac_mesagl_version_string=unknown
-           fi
-         fi
-         ac_cv_mesagl_version=$ac_mesagl_version
-         ac_cv_mesagl_version_string=$ac_mesagl_version_string
-      
-fi
-
-echo "$ac_t""$ac_cv_mesagl_version_string" 1>&6
-      ac_mesagl_version=$ac_cv_mesagl_version
-      ac_mesagl_version_string=$ac_cv_mesagl_version_string
-    fi
-
-
-    # If it's MesaGL, check to see if it requires -lpthread.
-    #
-    have_pthread=no
-    mesa_requires_pthread=no
-    if test "$ac_have_mesa_gl" = yes; then
-
-      echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:7288: checking for pthread_create in -lpthread" >&5
-ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for gleCreateGC in -lgle""... $ac_c" 1>&6
+echo "configure:8759: checking for gleCreateGC in -lgle" >&5
+ac_lib_var=`echo gle'_'gleCreateGC | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lpthread  $LIBS"
+LIBS="-lgle $GL_LIBS -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7296 "configure"
+#line 8767 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char pthread_create();
+char gleCreateGC();
 
 int main() {
-pthread_create()
+gleCreateGC()
 ; return 0; }
 EOF
-if { (eval echo configure:7307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7307,13 +8778,34 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_pthread=yes
+  have_gle=yes; gle_halfassed=no; GLE_LIBS="-lgle"
 else
   echo "$ac_t""no" 1>&6
 fi
 
-      if test "$have_pthread" = yes; then
-        
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
+  fi
+  if test "$have_gle" = yes ; then
+    have_gle=no
+    gle_halfassed=yes
+
+    # sometimes the libmatrix stuff is included in libgle.  look there first.
+#
+# I don't get it.  For some reason, this test passes on SGI, as if
+# uview_direction_d() was in libgle -- but it's not, it's in libmatrix.
+# Yet the link is succeeding.  Why???
+#
+#    AC_CHECK_X_LIB(gle, uview_direction_d, 
+#                   [have_gle=yes; gle_halfassed=no],
+#                   [], $GL_LIBS -lX11 -lXext -lm)
+
+    # As of GLE 3 this is in libgle, and has changed name to uview_direction!
+    # *sigh*
+    if test "$have_gle3" = yes ; then
+      
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
 #  ac_save_LIBS="$LIBS"
@@ -7328,29 +8820,29 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
-  echo $ac_n "checking for gl_get_thread_context in -l$gl_lib_1""... $ac_c" 1>&6
-echo "configure:7346: checking for gl_get_thread_context in -l$gl_lib_1" >&5
-ac_lib_var=`echo $gl_lib_1'_'gl_get_thread_context | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for uview_direction in -lgle""... $ac_c" 1>&6
+echo "configure:8838: checking for uview_direction in -lgle" >&5
+ac_lib_var=`echo gle'_'uview_direction | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-l$gl_lib_1 $GL_LIBS -lpthread -lX11 -lXext -lm $LIBS"
+LIBS="-lgle $GL_LIBS -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7354 "configure"
+#line 8846 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char gl_get_thread_context();
+char uview_direction();
 
 int main() {
-gl_get_thread_context()
+uview_direction()
 ; return 0; }
 EOF
-if { (eval echo configure:7365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7365,26 +8857,19 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  mesa_requires_pthread=yes
+  have_gle=yes; gle_halfassed=no
 else
   echo "$ac_t""no" 1>&6
-true
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
   LDFLAGS="$ac_save_LDFLAGS"
 #  LIBS="$ac_save_LIBS"
   
-      fi
-
-      if test "$mesa_requires_pthread" = yes; then
-        GL_LIBS="$GL_LIBS -lpthread"
-      fi
     fi
-
-    # Check for OpenGL 1.1 features.
-    #
-    
+    # if it wasn't in libgle, then look in libmatrix.
+    if test "$have_gle" = no ; then
+      
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
 #  ac_save_LIBS="$LIBS"
@@ -7399,29 +8884,29 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
-  echo $ac_n "checking for glBindTexture in -l$gl_lib_1""... $ac_c" 1>&6
-echo "configure:7417: checking for glBindTexture in -l$gl_lib_1" >&5
-ac_lib_var=`echo $gl_lib_1'_'glBindTexture | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for uview_direction_d in -lmatrix""... $ac_c" 1>&6
+echo "configure:8902: checking for uview_direction_d in -lmatrix" >&5
+ac_lib_var=`echo matrix'_'uview_direction_d | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-l$gl_lib_1 $GL_LIBS -lX11 -lXext -lm $LIBS"
+LIBS="-lmatrix $GL_LIBS -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7425 "configure"
+#line 8910 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char glBindTexture();
+char uview_direction_d();
 
 int main() {
-glBindTexture()
+uview_direction_d()
 ; return 0; }
 EOF
-if { (eval echo configure:7436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8921: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7436,79 +8921,66 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  cat >> confdefs.h <<\EOF
-#define HAVE_GLBINDTEXTURE 1
-EOF
-
+  have_gle=yes; gle_halfassed=no;
+                      GLE_LIBS="$GLE_LIBS -lmatrix"
 else
   echo "$ac_t""no" 1>&6
-true
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
   LDFLAGS="$ac_save_LDFLAGS"
 #  LIBS="$ac_save_LIBS"
   
+    fi
+  fi
 
-
-    # Check whether the `xscreensaver' executable should link against GL.
-    # See comments in utils/visual-gl.c for why this is sometimes necessary.
-    #
-    echo $ac_n "checking whether drastic GL measures must be taken""... $ac_c" 1>&6
-echo "configure:7470: checking whether drastic GL measures must be taken" >&5
-    case "$host" in
-      *-sgi*)
-        echo "$ac_t""yes -- hello, SGI." 1>&6
-        cat >> confdefs.h <<\EOF
-#define DAEMON_USE_GL 1
+  if test "$have_gle" = yes ; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_GLE 1
 EOF
 
-        SAVER_GL_SRCS='$(UTILS_SRC)/visual-gl.c'
-        SAVER_GL_OBJS='$(UTILS_BIN)/visual-gl.o'
-        SAVER_GL_LIBS="$GL_LIBS"
-      ;;
-      *)
-        echo "$ac_t""no -- non-SGI." 1>&6
-        SAVER_GL_SRCS=''
-        SAVER_GL_OBJS=''
-        SAVER_GL_LIBS=''
-      ;;
-    esac
+    if test "$have_gle3" = yes ; then
+      cat >> confdefs.h <<\EOF
+#define HAVE_GLE3 1
+EOF
 
+    fi
   fi
 
-elif test "$with_gl" != no; then
-  echo "error: must be yes or no: --with-gl=$with_gl"
+elif test "$with_gle" != no; then
+  echo "error: must be yes or no: --with-gle=$with_gle"
   exit 1
+
 fi
 
 
+
 ###############################################################################
 #
-#       Check for -lgle.
+#       Check for -lXpm.
 #
 ###############################################################################
 
-have_gle=no
-with_gle_req=unspecified
-# Check whether --with-gle or --without-gle was given.
-if test "${with_gle+set}" = set; then
-  withval="$with_gle"
-  with_gle="$withval"; with_gle_req="$withval"
+have_xpm=no
+with_xpm_req=unspecified
+# Check whether --with-xpm or --without-xpm was given.
+if test "${with_xpm+set}" = set; then
+  withval="$with_xpm"
+  with_xpm="$withval"; with_xpm_req="$withval"
 else
-  with_gle=yes
+  with_xpm=yes
 fi
 
 
 
-   case "$with_gle" in
+   case "$with_xpm" in
     yes) ;;
     no)  ;;
 
     /*)
-     echo $ac_n "checking for GLE headers""... $ac_c" 1>&6
-echo "configure:7522: checking for GLE headers" >&5
-     d=$with_gle/include
+     echo $ac_n "checking for XPM headers""... $ac_c" 1>&6
+echo "configure:8994: checking for XPM headers" >&5
+     d=$with_xpm/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
        echo "$ac_t""$d" 1>&6
@@ -7516,9 +8988,9 @@ echo "configure:7522: checking for GLE headers" >&5
        echo "$ac_t""not found ($d: no such directory)" 1>&6
      fi
 
-     echo $ac_n "checking for GLE libs""... $ac_c" 1>&6
-echo "configure:7532: checking for GLE libs" >&5
-     d=$with_gle/lib
+     echo $ac_n "checking for XPM libs""... $ac_c" 1>&6
+echo "configure:9004: checking for XPM libs" >&5
+     d=$with_xpm/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
        echo "$ac_t""$d" 1>&6
@@ -7527,13 +8999,13 @@ echo "configure:7532: checking for GLE libs" >&5
      fi
 
      # replace the directory string with "yes".
-     with_gle_req="yes"
-     with_gle=$with_gle_req
+     with_xpm_req="yes"
+     with_xpm=$with_xpm_req
      ;;
 
     *)
      echo ""
-     echo "error: argument to --with-gle must be \"yes\", \"no\", or a directory."
+     echo "error: argument to --with-xpm must be \"yes\", \"no\", or a directory."
      echo "       If it is a directory, then \`DIR/include' will be added to"
      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
      exit 1
@@ -7541,29 +9013,26 @@ echo "configure:7532: checking for GLE libs" >&5
    esac
   
 
-GLE_LIBS=""
-
-if test "$with_gle" = yes; then
-
+if test "$with_xpm" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "GL/gutil.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for GL/gutil.h""... $ac_c" 1>&6
-echo "configure:7568: checking for GL/gutil.h" >&5
+  ac_safe=`echo "X11/xpm.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for X11/xpm.h""... $ac_c" 1>&6
+echo "configure:9037: checking for X11/xpm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7573 "configure"
+#line 9042 "configure"
 #include "confdefs.h"
-#include <GL/gutil.h>
+#include <X11/xpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7578: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9047: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7579,32 +9048,117 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_gle=yes
+  have_xpm=yes
+                    cat >> confdefs.h <<\EOF
+#define HAVE_XPM 1
+EOF
+
+                    XPM_LIBS="-lXpm"
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  if test "$have_gle" = yes ; then
+elif test "$with_xpm" != no; then
+  echo "error: must be yes or no: --with-xpm=$with_xpm"
+  exit 1
+fi
+
+# See comment near $motif_requires_xpm, above.
+# Need to do this here, after both Motif and XPM have been checked for.
+#
+if test "$have_motif" = yes -a "$have_xpm" = yes ; then
+  if test "$motif_requires_xpm" = yes ; then
+    MOTIF_LIBS="$MOTIF_LIBS $XPM_LIBS"
+  fi
+fi
+
+
+###############################################################################
+#
+#       Check for -lgdk_pixbuf.
+#
+###############################################################################
+
+have_gdk_pixbuf=no
+with_gdk_pixbuf_req=unspecified
+# Check whether --with-pixbuf or --without-pixbuf was given.
+if test "${with_pixbuf+set}" = set; then
+  withval="$with_pixbuf"
+  with_gdk_pixbuf="$withval"; with_gdk_pixbuf_req="$withval"
+else
+  with_gdk_pixbuf=yes
+fi
+
+
+
+   case "$with_gdk_pixbuf" in
+    yes) ;;
+    no)  ;;
+
+    /*)
+     echo $ac_n "checking for GDK_PIXBUF headers""... $ac_c" 1>&6
+echo "configure:9113: checking for GDK_PIXBUF headers" >&5
+     d=$with_gdk_pixbuf/include
+     if test -d $d; then
+       X_CFLAGS="-I$d $X_CFLAGS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     echo $ac_n "checking for GDK_PIXBUF libs""... $ac_c" 1>&6
+echo "configure:9123: checking for GDK_PIXBUF libs" >&5
+     d=$with_gdk_pixbuf/lib
+     if test -d $d; then
+       X_LIBS="-L$d $X_LIBS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     # replace the directory string with "yes".
+     with_gdk_pixbuf_req="yes"
+     with_gdk_pixbuf=$with_gdk_pixbuf_req
+     ;;
+
+    *)
+     echo ""
+     echo "error: argument to --with-pixbuf must be \"yes\", \"no\", or a directory."
+     echo "       If it is a directory, then \`DIR/include' will be added to"
+     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
+     exit 1
+     ;;
+   esac
+  
+
+if test "$with_gdk_pixbuf" = yes; then
+
+  if test "$have_gtk" = yes; then
+
+    ac_save_gdk_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $ac_gtk_config_cflags"
+
+    have_gdk_pixbuf=no
     
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "GL/tube.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for GL/tube.h""... $ac_c" 1>&6
-echo "configure:7609: checking for GL/tube.h" >&5
+  ac_safe=`echo "gdk-pixbuf/gdk-pixbuf.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for gdk-pixbuf/gdk-pixbuf.h""... $ac_c" 1>&6
+echo "configure:9163: checking for gdk-pixbuf/gdk-pixbuf.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7614 "configure"
+#line 9168 "configure"
 #include "confdefs.h"
-#include <GL/tube.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7619: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9173: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7620,187 +9174,100 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_gle=yes
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-  CPPFLAGS="$ac_save_CPPFLAGS"
-  fi
-
-#          /usr/local/lib/GL/libgle.a
-#          /usr/local/lib/GL/libmatrix.a
-
-  if test "$have_gle" = yes ; then
-    have_gle=no
-    
-  ac_save_CPPFLAGS="$CPPFLAGS"
-  ac_save_LDFLAGS="$LDFLAGS"
-#  ac_save_LIBS="$LIBS"
-
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
-  # note: $X_CFLAGS includes $x_includes
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-
-  if test \! -z "$libdir" ; then
-    LDFLAGS="$LDFLAGS -L$libdir"
-  fi
-  # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
-
-  echo $ac_n "checking for gleCreateGC in -lgle""... $ac_c" 1>&6
-echo "configure:7666: checking for gleCreateGC in -lgle" >&5
-ac_lib_var=`echo gle'_'gleCreateGC | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lgle $GL_LIBS -lX11 -lXext -lm $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 7674 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char gleCreateGC();
-
-int main() {
-gleCreateGC()
-; return 0; }
-EOF
-if { (eval echo configure:7685: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  have_gle=yes; GLE_LIBS="-lgle"
+  have_gdk_pixbuf=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  LDFLAGS="$ac_save_LDFLAGS"
-#  LIBS="$ac_save_LIBS"
-  
-  fi
-  if test "$have_gle" = yes ; then
-    have_gle=no
-    
+    if test "$have_gdk_pixbuf" = yes; then
+      have_gdk_pixbuf=no
+      
   ac_save_CPPFLAGS="$CPPFLAGS"
-  ac_save_LDFLAGS="$LDFLAGS"
-#  ac_save_LIBS="$LIBS"
-
   if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
-  # note: $X_CFLAGS includes $x_includes
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-
-  if test \! -z "$libdir" ; then
-    LDFLAGS="$LDFLAGS -L$libdir"
+    CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
-
-  echo $ac_n "checking for uview_direction_d in -lmatrix""... $ac_c" 1>&6
-echo "configure:7730: checking for uview_direction_d in -lmatrix" >&5
-ac_lib_var=`echo matrix'_'uview_direction_d | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  ac_safe=`echo "gdk-pixbuf/gdk-pixbuf-xlib.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for gdk-pixbuf/gdk-pixbuf-xlib.h""... $ac_c" 1>&6
+echo "configure:9205: checking for gdk-pixbuf/gdk-pixbuf-xlib.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_save_LIBS="$LIBS"
-LIBS="-lmatrix $GL_LIBS -lX11 -lXext -lm $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 7738 "configure"
+  cat > conftest.$ac_ext <<EOF
+#line 9210 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char uview_direction_d();
-
-int main() {
-uview_direction_d()
-; return 0; }
+#include <gdk-pixbuf/gdk-pixbuf-xlib.h>
 EOF
-if { (eval echo configure:7749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:9215: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  eval "ac_cv_header_$ac_safe=yes"
 else
+  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  eval "ac_cv_header_$ac_safe=no"
 fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
-
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_gle=yes; GLE_LIBS="$GLE_LIBS -lmatrix"
+  have_gdk_pixbuf=yes
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  LDFLAGS="$ac_save_LDFLAGS"
-#  LIBS="$ac_save_LIBS"
-  
-  fi
+    fi
 
-  if test "$have_gle" = yes ; then
-    cat >> confdefs.h <<\EOF
-#define HAVE_GLE 1
+    CPPFLAGS="$ac_save_gdk_CPPFLAGS"
+
+    if test "$have_gdk_pixbuf" = yes; then
+      cat >> confdefs.h <<\EOF
+#define HAVE_GDK_PIXBUF 1
 EOF
 
+      XPM_LIBS="-lgdk_pixbuf -lgdk_pixbuf_xlib"
+    fi
   fi
 
-elif test "$with_gle" != no; then
-  echo "error: must be yes or no: --with-gle=$with_gle"
+elif test "$with_gdk_pixbuf" != no; then
+  echo "error: must be yes or no: --with-pixbuf=$with_gdk_pixbuf"
   exit 1
-
 fi
 
 
-
 ###############################################################################
 #
-#       Check for -lXpm.
+#       Check for -ljpeg
 #
 ###############################################################################
 
-have_xpm=no
-with_xpm_req=unspecified
-# Check whether --with-xpm or --without-xpm was given.
-if test "${with_xpm+set}" = set; then
-  withval="$with_xpm"
-  with_xpm="$withval"; with_xpm_req="$withval"
+have_jpeg=no
+with_jpeg_req=unspecified
+jpeg_halfassed=no
+# Check whether --with-jpeg or --without-jpeg was given.
+if test "${with_jpeg+set}" = set; then
+  withval="$with_jpeg"
+  with_jpeg="$withval"; with_jpeg_req="$withval"
 else
-  with_xpm=yes
+  with_jpeg=yes
 fi
 
 
 
-   case "$with_xpm" in
+   case "$with_jpeg" in
     yes) ;;
     no)  ;;
 
     /*)
-     echo $ac_n "checking for XPM headers""... $ac_c" 1>&6
-echo "configure:7814: checking for XPM headers" >&5
-     d=$with_xpm/include
+     echo $ac_n "checking for JPEG headers""... $ac_c" 1>&6
+echo "configure:9281: checking for JPEG headers" >&5
+     d=$with_jpeg/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
        echo "$ac_t""$d" 1>&6
@@ -7808,9 +9275,9 @@ echo "configure:7814: checking for XPM headers" >&5
        echo "$ac_t""not found ($d: no such directory)" 1>&6
      fi
 
-     echo $ac_n "checking for XPM libs""... $ac_c" 1>&6
-echo "configure:7824: checking for XPM libs" >&5
-     d=$with_xpm/lib
+     echo $ac_n "checking for JPEG libs""... $ac_c" 1>&6
+echo "configure:9291: checking for JPEG libs" >&5
+     d=$with_jpeg/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
        echo "$ac_t""$d" 1>&6
@@ -7819,13 +9286,13 @@ echo "configure:7824: checking for XPM libs" >&5
      fi
 
      # replace the directory string with "yes".
-     with_xpm_req="yes"
-     with_xpm=$with_xpm_req
+     with_jpeg_req="yes"
+     with_jpeg=$with_jpeg_req
      ;;
 
     *)
      echo ""
-     echo "error: argument to --with-xpm must be \"yes\", \"no\", or a directory."
+     echo "error: argument to --with-jpeg must be \"yes\", \"no\", or a directory."
      echo "       If it is a directory, then \`DIR/include' will be added to"
      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
      exit 1
@@ -7833,26 +9300,33 @@ echo "configure:7824: checking for XPM libs" >&5
    esac
   
 
-if test "$with_xpm" = yes; then
+if test "$with_jpeg" != yes -a "$with_jpeg" != no ; then
+  echo "error: must be yes or no: --with-jpeg=$with_jpeg"
+  exit 1
+fi
+
+if test "$with_jpeg" = yes; then
+
+  have_jpeg=no
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "X11/xpm.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for X11/xpm.h""... $ac_c" 1>&6
-echo "configure:7857: checking for X11/xpm.h" >&5
+  ac_safe=`echo "jpeglib.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for jpeglib.h""... $ac_c" 1>&6
+echo "configure:9331: checking for jpeglib.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7862 "configure"
+#line 9336 "configure"
 #include "confdefs.h"
-#include <X11/xpm.h>
+#include <jpeglib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7867: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9341: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7868,28 +9342,84 @@ rm -f conftest*
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_xpm=yes
+  have_jpeg=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+
+  if test "$have_jpeg" = yes; then
+    # we have the header, now check for the library
+    have_jpeg=no
+    jpeg_halfassed=yes
+    
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+#  ac_save_LIBS="$LIBS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
+
+  echo $ac_n "checking for jpeg_start_compress in -ljpeg""... $ac_c" 1>&6
+echo "configure:9386: checking for jpeg_start_compress in -ljpeg" >&5
+ac_lib_var=`echo jpeg'_'jpeg_start_compress | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ljpeg  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 9394 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char jpeg_start_compress();
+
+int main() {
+jpeg_start_compress()
+; return 0; }
+EOF
+if { (eval echo configure:9405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_jpeg=yes
+                    jpeg_halfassed=no
+                    JPEG_LIBS="-ljpeg"
                     cat >> confdefs.h <<\EOF
-#define HAVE_XPM 1
+#define HAVE_JPEGLIB 1
 EOF
 
-                    XPM_LIBS="-lXpm"
 else
   echo "$ac_t""no" 1>&6
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-elif test "$with_xpm" != no; then
-  echo "error: must be yes or no: --with-xpm=$with_xpm"
-  exit 1
-fi
-
-# See comment near $motif_requires_xpm, above.
-# Need to do this here, after both Motif and XPM have been checked for.
-#
-if test "$have_motif" = yes -a "$have_xpm" = yes ; then
-  if test "$motif_requires_xpm" = yes ; then
-    MOTIF_LIBS="$MOTIF_LIBS $XPM_LIBS"
+  LDFLAGS="$ac_save_LDFLAGS"
+#  LIBS="$ac_save_LIBS"
+  
   fi
 fi
 
@@ -7918,7 +9448,7 @@ fi
 
     /*)
      echo $ac_n "checking for XSHM headers""... $ac_c" 1>&6
-echo "configure:7933: checking for XSHM headers" >&5
+echo "configure:9463: checking for XSHM headers" >&5
      d=$with_xshm/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -7928,7 +9458,7 @@ echo "configure:7933: checking for XSHM headers" >&5
      fi
 
      echo $ac_n "checking for XSHM libs""... $ac_c" 1>&6
-echo "configure:7943: checking for XSHM libs" >&5
+echo "configure:9473: checking for XSHM libs" >&5
      d=$with_xshm/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -7963,17 +9493,17 @@ if test "$with_xshm" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XShm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XShm.h""... $ac_c" 1>&6
-echo "configure:7978: checking for X11/extensions/XShm.h" >&5
+echo "configure:9508: checking for X11/extensions/XShm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7983 "configure"
+#line 9513 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XShm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7988: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9518: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8007,17 +9537,17 @@ fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "sys/ipc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/ipc.h""... $ac_c" 1>&6
-echo "configure:8022: checking for sys/ipc.h" >&5
+echo "configure:9552: checking for sys/ipc.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8027 "configure"
+#line 9557 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8032: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9562: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8052,17 +9582,17 @@ fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "sys/shm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/shm.h""... $ac_c" 1>&6
-echo "configure:8067: checking for sys/shm.h" >&5
+echo "configure:9597: checking for sys/shm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8072 "configure"
+#line 9602 "configure"
 #include "confdefs.h"
 #include <sys/shm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8077: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9607: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8094,8 +9624,9 @@ fi
   #
   case "$host" in
     *-aix*)
-      have_xshm=no
-      
+      if  `uname -v` -eq 3 ; then
+        have_xshm=no
+        
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
 #  ac_save_LIBS="$LIBS"
@@ -8110,10 +9641,10 @@ fi
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
   # note: $X_LIBS includes $x_libraries
-  LDFLAGS="$LDFLAGS $X_LIBS"
+  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
 
   echo $ac_n "checking for XShmQueryExtension in -lXextSam""... $ac_c" 1>&6
-echo "configure:8128: checking for XShmQueryExtension in -lXextSam" >&5
+echo "configure:9659: checking for XShmQueryExtension in -lXextSam" >&5
 ac_lib_var=`echo XextSam'_'XShmQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -8121,7 +9652,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXextSam -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 8136 "configure"
+#line 9667 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -8132,7 +9663,7 @@ int main() {
 XShmQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:8147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8157,6 +9688,7 @@ fi
   LDFLAGS="$ac_save_LDFLAGS"
 #  LIBS="$ac_save_LIBS"
   
+      fi
     ;;
   esac
 
@@ -8198,7 +9730,7 @@ fi
 
     /*)
      echo $ac_n "checking for DOUBLE-BUFFER headers""... $ac_c" 1>&6
-echo "configure:8213: checking for DOUBLE-BUFFER headers" >&5
+echo "configure:9745: checking for DOUBLE-BUFFER headers" >&5
      d=$with_xdbe/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -8208,7 +9740,7 @@ echo "configure:8213: checking for DOUBLE-BUFFER headers" >&5
      fi
 
      echo $ac_n "checking for DOUBLE-BUFFER libs""... $ac_c" 1>&6
-echo "configure:8223: checking for DOUBLE-BUFFER libs" >&5
+echo "configure:9755: checking for DOUBLE-BUFFER libs" >&5
      d=$with_xdbe/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -8242,17 +9774,17 @@ if test "$with_xdbe" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/Xdbe.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/Xdbe.h""... $ac_c" 1>&6
-echo "configure:8257: checking for X11/extensions/Xdbe.h" >&5
+echo "configure:9789: checking for X11/extensions/Xdbe.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8262 "configure"
+#line 9794 "configure"
 #include "confdefs.h"
 #include <X11/extensions/Xdbe.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8267: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9799: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8315,7 +9847,7 @@ fi
 
     /*)
      echo $ac_n "checking for XReadDisplay headers""... $ac_c" 1>&6
-echo "configure:8330: checking for XReadDisplay headers" >&5
+echo "configure:9862: checking for XReadDisplay headers" >&5
      d=$with_readdisplay/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -8325,7 +9857,7 @@ echo "configure:8330: checking for XReadDisplay headers" >&5
      fi
 
      echo $ac_n "checking for XReadDisplay libs""... $ac_c" 1>&6
-echo "configure:8340: checking for XReadDisplay libs" >&5
+echo "configure:9872: checking for XReadDisplay libs" >&5
      d=$with_readdisplay/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -8354,203 +9886,47 @@ if test "$with_readdisplay" = yes; then
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "X11/extensions/readdisplay.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for X11/extensions/readdisplay.h""... $ac_c" 1>&6
-echo "configure:8373: checking for X11/extensions/readdisplay.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 8378 "configure"
-#include "confdefs.h"
-#include <X11/extensions/readdisplay.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8383: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  cat >> confdefs.h <<\EOF
-#define HAVE_READ_DISPLAY_EXTENSION 1
-EOF
-
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-  CPPFLAGS="$ac_save_CPPFLAGS"
-elif test "$with_readdisplay" != no; then
-  echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
-  exit 1
-fi
-
-
-###############################################################################
-#
-#       Check for the SGI Iris Video Library.
-#
-###############################################################################
-
-have_sgivideo=no
-with_sgivideo_req=unspecified
-# Check whether --with-sgivideo or --without-sgivideo was given.
-if test "${with_sgivideo+set}" = set; then
-  withval="$with_sgivideo"
-  with_sgivideo="$withval"; with_sgivideo_req="$withval"
-else
-  with_sgivideo=yes
-fi
-
-
-
-   case "$with_sgivideo" in
-    yes) ;;
-    no)  ;;
-
-    /*)
-     echo $ac_n "checking for Iris Video headers""... $ac_c" 1>&6
-echo "configure:8438: checking for Iris Video headers" >&5
-     d=$with_sgivideo/include
-     if test -d $d; then
-       X_CFLAGS="-I$d $X_CFLAGS"
-       echo "$ac_t""$d" 1>&6
-     else
-       echo "$ac_t""not found ($d: no such directory)" 1>&6
-     fi
-
-     echo $ac_n "checking for Iris Video libs""... $ac_c" 1>&6
-echo "configure:8448: checking for Iris Video libs" >&5
-     d=$with_sgivideo/lib
-     if test -d $d; then
-       X_LIBS="-L$d $X_LIBS"
-       echo "$ac_t""$d" 1>&6
-     else
-       echo "$ac_t""not found ($d: no such directory)" 1>&6
-     fi
-
-     # replace the directory string with "yes".
-     with_sgivideo_req="yes"
-     with_sgivideo=$with_sgivideo_req
-     ;;
-
-    *)
-     echo ""
-     echo "error: argument to --with-sgivideo must be \"yes\", \"no\", or a directory."
-     echo "       If it is a directory, then \`DIR/include' will be added to"
-     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
-     exit 1
-     ;;
-   esac
-  
-
-if test "$with_sgivideo" = yes; then
-  
-  ac_save_CPPFLAGS="$CPPFLAGS"
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  ac_safe=`echo "dmedia/vl.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for dmedia/vl.h""... $ac_c" 1>&6
-echo "configure:8481: checking for dmedia/vl.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 8486 "configure"
-#include "confdefs.h"
-#include <dmedia/vl.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8491: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  have_sgivideo=yes
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-  CPPFLAGS="$ac_save_CPPFLAGS"
-  if test "$have_sgivideo" = yes; then
-    have_sgivideo=no
-    echo $ac_n "checking for vlOpenVideo in -lvl""... $ac_c" 1>&6
-echo "configure:8516: checking for vlOpenVideo in -lvl" >&5
-ac_lib_var=`echo vl'_'vlOpenVideo | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  fi
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+  ac_safe=`echo "X11/extensions/readdisplay.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for X11/extensions/readdisplay.h""... $ac_c" 1>&6
+echo "configure:9905: checking for X11/extensions/readdisplay.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  ac_save_LIBS="$LIBS"
-LIBS="-lvl  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 8524 "configure"
+  cat > conftest.$ac_ext <<EOF
+#line 9910 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char vlOpenVideo();
-
-int main() {
-vlOpenVideo()
-; return 0; }
+#include <X11/extensions/readdisplay.h>
 EOF
-if { (eval echo configure:8535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:9915: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  eval "ac_cv_header_$ac_safe=yes"
 else
+  echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  eval "ac_cv_header_$ac_safe=no"
 fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
-
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_sgivideo=yes
+  cat >> confdefs.h <<\EOF
+#define HAVE_READ_DISPLAY_EXTENSION 1
+EOF
+
 else
   echo "$ac_t""no" 1>&6
 fi
 
-    if test "$have_sgivideo" = yes; then
-      SGI_VIDEO_OBJS="$(UTILS_BIN)/sgivideo.o"
-      SGI_VIDEO_LIBS="-lvl"
-      cat >> confdefs.h <<\EOF
-#define HAVE_SGI_VIDEO 1
-EOF
-
-    fi
-  fi
-elif test "$with_sgivideo" != no; then
-  echo "error: must be yes or no: --with-sgivideo=$with_sgivideo"
+  CPPFLAGS="$ac_save_CPPFLAGS"
+elif test "$with_readdisplay" != no; then
+  echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
   exit 1
 fi
 
@@ -8560,61 +9936,60 @@ fi
 #       Check for a program to generate random text.
 #
 #       Zippy is funnier than the idiocy generally spat out by `fortune',
-#       so try to find that, by invoking Emacs and asking it where its 
-#       libexec directory is ("yow" lives in there.)
-#
-#       If that doesn't work, see if fortune, zippy, or yow are on $PATH,
-#       and if so, use them.
+#       so first see if "fortune zippy" works.  Else, use plain "fortune".
 #
-#       If that doesn't work, look in /usr/games, and if it's there, use
-#       the full pathname.
+#       We used to dig around in Emacs to look for the "yow" program, but
+#       most people who have Emacs also have "fortune zippy", so nevermind.
 #
 ###############################################################################
 
-with_zippy_req=""
-# Check whether --with-zippy or --without-zippy was given.
-if test "${with_zippy+set}" = set; then
-  withval="$with_zippy"
-  with_zippy_req="$withval"; with_zippy="$withval"
+with_fortune_req=""
+# Check whether --with-fortune or --without-fortune was given.
+if test "${with_fortune+set}" = set; then
+  withval="$with_fortune"
+  with_fortune_req="$withval"; with_fortune="$withval"
 else
-  with_zippy=yes
+  with_fortune=yes
 fi
 
 
-if test "$with_zippy" = no || test "$with_zippy" = yes ; then
-  with_zippy=""
-  with_zippy_req=""
+if test "$with_fortune" = no || test "$with_fortune" = yes ; then
+  with_fortune=""
+  with_fortune_req=""
 fi
 
-if test -n "$with_zippy_req" ; then
-  ac_cv_zippy_program=""
-  case "$with_zippy_req" in
+if test -n "$with_fortune_req" ; then
+  ac_cv_fortune_program=""
+  case "$with_fortune_req" in
     /*)
-      echo $ac_n "checking for $with_zippy_req""... $ac_c" 1>&6
-echo "configure:8606: checking for $with_zippy_req" >&5
-      if test -x "$with_zippy_req" ; then
+
+      set dummy $with_fortune_req ; fortune_tmp=$2
+      echo $ac_n "checking for $fortune_tmp""... $ac_c" 1>&6
+echo "configure:9980: checking for $fortune_tmp" >&5
+      if test -x "$fortune_tmp" ; then
         echo "$ac_t""yes" 1>&6
       else
         echo "$ac_t""no" 1>&6
-        with_zippy=""
+        with_fortune=""
       fi
     ;;
     *)
+      set dummy $with_fortune_req ; fortune_tmp=$2
       # don't cache
-      unset ac_cv_path_zip2
-      # Extract the first word of "$with_zippy_req", so it can be a program name with args.
-set dummy $with_zippy_req; ac_word=$2
+      unset ac_cv_path_fortune_tmp
+      # Extract the first word of "$fortune_tmp", so it can be a program name with args.
+set dummy $fortune_tmp; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:8620: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_zip2'+set}'`\" = set"; then
+echo "configure:9995: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_fortune_tmp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  case "$zip2" in
+  case "$fortune_tmp" in
   /*)
-  ac_cv_path_zip2="$zip2" # Let the user override the test with a path.
+  ac_cv_path_fortune_tmp="$fortune_tmp" # Let the user override the test with a path.
   ;;
   ?:/*)                         
-  ac_cv_path_zip2="$zip2" # Let the user override the test with a dos path.
+  ac_cv_path_fortune_tmp="$fortune_tmp" # Let the user override the test with a dos path.
   ;;
   *)
   IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
@@ -8622,7 +9997,7 @@ else
   for ac_dir in $ac_dummy; do 
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
-      ac_cv_path_zip2="$ac_dir/$ac_word"
+      ac_cv_path_fortune_tmp="$ac_dir/$ac_word"
       break
     fi
   done
@@ -8630,265 +10005,204 @@ else
   ;;
 esac
 fi
-zip2="$ac_cv_path_zip2"
-if test -n "$zip2"; then
-  echo "$ac_t""$zip2" 1>&6
+fortune_tmp="$ac_cv_path_fortune_tmp"
+if test -n "$fortune_tmp"; then
+  echo "$ac_t""$fortune_tmp" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
-      if test "$zip2" = ""; then
-        with_zippy=""
+      if test -z "$fortune_tmp" ; then
+        with_fortune=""
       fi
     ;;
   esac
-  ac_cv_zippy_program="$with_zippy"
+  ac_cv_fortune_program="$with_fortune"
 
-elif test -n "$ac_cv_zippy_program"; then
-  echo "$ac_t""checking for zippy... (cached) $ac_cv_zippy_program" 1>&6
+elif test -n "$ac_cv_fortune_program"; then
+  echo "$ac_t""checking for fortune... (cached) $ac_cv_fortune_program" 1>&6
 fi
 
-if test ! -n "$ac_cv_zippy_program"; then
+unset ac_cv_path_fortune_tmp
+unset fortune_tmp
+
+if test -z "$ac_cv_fortune_program" ; then
 
-  for ac_prog in emacs
+  # first look for fortune in /usr/games/ (and use absolute path)
+  for ac_prog in fortune
 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:8670: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_emacs_exe'+set}'`\" = set"; then
+echo "configure:10049: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_fortune_tmp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  if test -n "$emacs_exe"; then
-  ac_cv_prog_emacs_exe="$emacs_exe" # Let the user override the test.
-else
+  case "$fortune_tmp" in
+  /*)
+  ac_cv_path_fortune_tmp="$fortune_tmp" # Let the user override the test with a path.
+  ;;
+  ?:/*)                         
+  ac_cv_path_fortune_tmp="$fortune_tmp" # Let the user override the test with a dos path.
+  ;;
+  *)
   IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
+  ac_dummy=""/usr/games""
+  for ac_dir in $ac_dummy; do 
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_emacs_exe="$ac_prog"
+      ac_cv_path_fortune_tmp="$ac_dir/$ac_word"
       break
     fi
   done
   IFS="$ac_save_ifs"
+  ;;
+esac
 fi
-fi
-emacs_exe="$ac_cv_prog_emacs_exe"
-if test -n "$emacs_exe"; then
-  echo "$ac_t""$emacs_exe" 1>&6
+fortune_tmp="$ac_cv_path_fortune_tmp"
+if test -n "$fortune_tmp"; then
+  echo "$ac_t""$fortune_tmp" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
-test -n "$emacs_exe" && break
+test -n "$fortune_tmp" && break
 done
 
-  for ac_prog in xemacs
+
+  # if it's not there, look on $PATH (and don't use absolute path)
+  if test -z "$fortune_tmp" ; then
+     for ac_prog in fortune
 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:8704: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_xemacs_exe'+set}'`\" = set"; then
+echo "configure:10092: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_fortune_tmp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-  if test -n "$xemacs_exe"; then
-  ac_cv_prog_xemacs_exe="$xemacs_exe" # Let the user override the test.
+  if test -n "$fortune_tmp"; then
+  ac_cv_prog_fortune_tmp="$fortune_tmp" # Let the user override the test.
 else
   IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_xemacs_exe="$ac_prog"
+      ac_cv_prog_fortune_tmp="$ac_prog"
       break
     fi
   done
   IFS="$ac_save_ifs"
 fi
 fi
-xemacs_exe="$ac_cv_prog_xemacs_exe"
-if test -n "$xemacs_exe"; then
-  echo "$ac_t""$xemacs_exe" 1>&6
+fortune_tmp="$ac_cv_prog_fortune_tmp"
+if test -n "$fortune_tmp"; then
+  echo "$ac_t""$fortune_tmp" 1>&6
 else
   echo "$ac_t""no" 1>&6
 fi
 
-test -n "$xemacs_exe" && break
+test -n "$fortune_tmp" && break
 done
 
+  fi
 
-  ac_cv_zippy_program=""
-  eargs='-batch -q -nw --eval'
-
-  if test -n "$emacs_exe" ; then
-    echo $ac_n "checking for emacs yow""... $ac_c" 1>&6
-echo "configure:8739: checking for emacs yow" >&5
-    #
-    # get emacs to tell us where the libexec directory is.
-    #
-    dir=`$emacs_exe $eargs '(princ (concat exec-directory "\n"))' \
-         2>/dev/null | tail -1`
-    dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
-    #
-    # try running libexec/yow and see if it exits without error.
-    #
-    if test x"$dir" != x -a -x "$dir/yow" ; then
-      if $dir/yow >&- 2>&- ; then
-        ac_cv_zippy_program="$dir/yow"
-        echo "$ac_t""$ac_cv_zippy_program" 1>&6
-      else
-        echo "$ac_t""no" 1>&6
-      fi
-    fi
+  # if we didn't find anything, then just assume /usr/games/
+  if test -z "$fortune_tmp" ; then
+     fortune_tmp="/usr/games/fortune"
   fi
 
-  if test -z "$ac_cv_zippy_program" ; then
-    echo $ac_n "checking for xemacs yow""... $ac_c" 1>&6
-echo "configure:8761: checking for xemacs yow" >&5
-    if test -n "$xemacs_exe" ; then
-      #
-      # get xemacs to tell us where the libexec directory is.
-      #
-      dir=`$xemacs_exe $eargs '(princ (concat exec-directory "\n"))' \
-           2>/dev/null | tail -1`
-      dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
-      #
-      # try running libexec/yow and see if it exits without error.
-      #
-      if test x"$dir" != x -a -x "$dir/yow" ; then
-        if $dir/yow >&- 2>&- ; then
-          ac_cv_zippy_program="$dir/yow"
-          echo "$ac_t""$ac_cv_zippy_program" 1>&6
-        else
-          #
-          # in some xemacs installations, the pathname of the yow.lines file
-          # isn't hardcoded into the yow executable, and must be passed on 
-          # the command line.  See if it's in libexec/../etc/.
+  ac_cv_fortune_program="$fortune_tmp"
 
-          # M4 sucks!!
-          
-          dir_up=`echo "$dir" | sed 's@/[^/]*$@@'`
-          
-
-          yowlines="$dir_up/etc/yow.lines"
-          if $dir/yow -f $yowlines >&- 2>&- ; then
-            ac_cv_zippy_program="$dir/yow -f $yowlines"
-            echo "$ac_t""$ac_cv_zippy_program" 1>&6
-          else
-            #
-            # In newer XEmacs releases, yow.lines is in a different place,
-            # and the easiest way to get it is by calling the new function
-            # `locate-data-file'.
-            #
-            yowlines=`$xemacs_exe $eargs \
-              '(princ (concat (locate-data-file "yow.lines") "\n"))' \
-              2>/dev/null | tail -1`
-            if $dir/yow -f $yowlines >&- 2>&- ; then
-              ac_cv_zippy_program="$dir/yow -f $yowlines"
-              echo "$ac_t""$ac_cv_zippy_program" 1>&6
-            else
-              echo "$ac_t""no" 1>&6
-            fi
-          fi
-        fi
-      fi
-    fi
+  # now check to see whether "fortune zippy" works.
+  #
+  fortune_tmp="$fortune_tmp zippy"
+  echo $ac_n "checking for zippy quotes""... $ac_c" 1>&6
+echo "configure:10134: checking for zippy quotes" >&5
+  if ( $fortune_tmp >/dev/null 2>&1 ); then
+    ac_cv_fortune_program="$fortune_tmp"
+    echo "$ac_t""$fortune_tmp" 1>&6
+  else
+    echo "$ac_t""no" 1>&6
   fi
 
-  # if that didn't work, try for some other programs...
-  if test -z "$ac_cv_zippy_program" ; then
-    fortune=''
-    for ac_prog in fortune zippy yow
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:8820: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_fortune'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$fortune"; then
-  ac_cv_prog_fortune="$fortune" # Let the user override the test.
-else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_fortune="$ac_prog"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-fortune="$ac_cv_prog_fortune"
-if test -n "$fortune"; then
-  echo "$ac_t""$fortune" 1>&6
-else
-  echo "$ac_t""no" 1>&6
 fi
 
-test -n "$fortune" && break
-done
+unset ac_cv_path_fortune_tmp
+unset fortune_tmp
 
-    # if that didn't work, try for those programs in /usr/games...
-    if test -z "$fortune" ; then
-      for ac_prog in fortune zippy yow
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:8856: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_fortune'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  case "$fortune" in
-  /*)
-  ac_cv_path_fortune="$fortune" # Let the user override the test with a path.
-  ;;
-  ?:/*)                         
-  ac_cv_path_fortune="$fortune" # Let the user override the test with a dos path.
-  ;;
-  *)
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="/usr/games:/usr/local/games:$PATH"
-  for ac_dir in $ac_dummy; do 
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_path_fortune="$ac_dir/$ac_word"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-  ;;
-esac
-fi
-fortune="$ac_cv_path_fortune"
-if test -n "$fortune"; then
-  echo "$ac_t""$fortune" 1>&6
+cat >> confdefs.h <<EOF
+#define FORTUNE_PROGRAM "$ac_cv_fortune_program"
+EOF
+
+
+
+###############################################################################
+#
+#       Check whether it's ok to install some hacks as setuid (e.g., "sonar")
+#       This should be safe, but let's give people the option.
+#
+###############################################################################
+
+setuid_hacks_default=no
+setuid_hacks="$setuid_hacks_default"
+# Check whether --with-setuid-hacks or --without-setuid-hacks was given.
+if test "${with_setuid_hacks+set}" = set; then
+  withval="$with_setuid_hacks"
+  setuid_hacks="$withval"
 else
-  echo "$ac_t""no" 1>&6
+  setuid_hacks="$setuid_hacks_default"
 fi
 
-test -n "$fortune" && break
-done
-test -n "$fortune" || fortune="fortune"
 
-    fi
-  fi
-fi
 
-if test -z "$ac_cv_zippy_program" ; then
-  ac_cv_zippy_program=fortune
-fi
+   case "$setuid_hacks" in
+    yes) ;;
+    no)  ;;
 
-cat >> confdefs.h <<EOF
-#define ZIPPY_PROGRAM "$ac_cv_zippy_program"
-EOF
+    /*)
+     echo $ac_n "checking for setuid hacks headers""... $ac_c" 1>&6
+echo "configure:10178: checking for setuid hacks headers" >&5
+     d=$setuid_hacks/include
+     if test -d $d; then
+       X_CFLAGS="-I$d $X_CFLAGS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     echo $ac_n "checking for setuid hacks libs""... $ac_c" 1>&6
+echo "configure:10188: checking for setuid hacks libs" >&5
+     d=$setuid_hacks/lib
+     if test -d $d; then
+       X_LIBS="-L$d $X_LIBS"
+       echo "$ac_t""$d" 1>&6
+     else
+       echo "$ac_t""not found ($d: no such directory)" 1>&6
+     fi
+
+     # replace the directory string with "yes".
+     setuid_hacks_req="yes"
+     setuid_hacks=$setuid_hacks_req
+     ;;
+
+    *)
+     echo ""
+     echo "error: argument to --with-setuid-hacks must be \"yes\", \"no\", or a directory."
+     echo "       If it is a directory, then \`DIR/include' will be added to"
+     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
+     exit 1
+     ;;
+   esac
+  
 
+if test "$setuid_hacks" = yes; then
+  true
+elif test "$setuid_hacks" != no; then
+  echo "error: must be yes or no: --with-setuid-hacks=$setuid_hacks"
+  exit 1
+fi
 
 
 ###############################################################################
@@ -8912,23 +10226,16 @@ if test \! -z "$libdir" ; then
 fi
 
 
+PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
 ALL_DEMO_PROGRAMS=
-if test "$have_athena3d" = yes; then
-  PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xaw3d
-  ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
-fi
-if test "$have_athena" = yes; then
-  PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xaw
+if test "$have_motif" = yes; then
+  PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
 fi
 if test "$have_gtk" = yes; then
   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
 fi
-if test "$have_motif" = yes; then
-  PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
-  ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
-fi
 
 
 if test "$have_kerberos" = yes; then
@@ -8949,34 +10256,71 @@ if test "$enable_locking" = yes; then
   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
 else
   LOCK_SRCS='$(NOLOCK_SRCS_1)'
-  LOCK_OBJS='$(NOLOCK_SRCS_1)'
+  LOCK_OBJS='$(NOLOCK_OBJS_1)'
 fi
 
+INSTALL_SETUID='$(INSTALL_PROGRAM) $(SUID_FLAGS)'
+
 if test "$need_setuid" = yes; then
   NEED_SETUID=yes
-  INSTALL_SETUID='$(INSTALL) $(SUID_FLAGS)'
 else
   NEED_SETUID=no
-  INSTALL_SETUID='$(INSTALL_PROGRAM)'
+fi
+
+if test "$setuid_hacks" = yes; then
+  SETUID_HACKS=yes
+else
+  SETUID_HACKS=no
 fi
 
 tab='  '
 if test "$have_gl" = yes; then
   GL_EXES='$(GL_EXES)'
+  GL_UTIL_EXES='$(GL_UTIL_EXES)'
   GL_MEN='$(GL_MEN)'
   GL_KLUDGE="${tab}  "
 else
-  GL_KLUDGE="  -${tab}  "
+  GL_KLUDGE="-${tab}  "
 fi
 
 if test "$have_gle" = yes; then
   GLE_EXES='$(GLE_EXES)'
   GLE_MEN='$(GLE_MEN)'
-  GLE_KLUDGE="${tab}  "
+  GLE_KLUDGE="${tab}   "
+else
+  GLE_KLUDGE="-${tab}   "
+fi
+
+if test "$have_jpeg" = yes -a "$have_gdk_pixbuf" = yes; then
+ JPEG_EXES='$(JPEG_EXES)'
+fi
+
+
+# Another substitution in the XScreenSaver.ad.in file:
+#
+if test "$have_gnome_help" = yes; then
+  GNOMEHELP_Y=''
+  GNOMEHELP_N='!    '
 else
-  GLE_KLUDGE="  -${tab}  "
+  GNOMEHELP_Y='!    '
+  GNOMEHELP_N=''
+fi
+
+
+# Now that we know whether we have Gnome, we can decide where the XML
+# config files get installed.
+if test -z "$HACK_CONF_DIR" ; then
+  if test -n "$GNOME_DATADIR" ; then
+    HACK_CONF_DIR='${GNOME_DATADIR}/control-center/screensavers'
+  else
+    HACK_CONF_DIR='${prefix}/lib/xscreensaver/config'
+  fi
 fi
 
+# canonicalize slashes.
+HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
+
+
 
 ###############################################################################
 #
@@ -9014,6 +10358,13 @@ fi
 
 
 
+
+
+
+
+
+
+
 
 
 
@@ -9186,45 +10537,51 @@ s%@X_LIBS@%$X_LIBS%g
 s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
 s%@glib_config@%$glib_config%g
 s%@gtk_config@%$gtk_config%g
-s%@zip2@%$zip2%g
-s%@emacs_exe@%$emacs_exe%g
-s%@xemacs_exe@%$xemacs_exe%g
-s%@fortune@%$fortune%g
+s%@gnome_config@%$gnome_config%g
+s%@have_gnome_help@%$have_gnome_help%g
+s%@fortune_tmp@%$fortune_tmp%g
 s%@INCLUDES@%$INCLUDES%g
 s%@PREFERRED_DEMO_PROGRAM@%$PREFERRED_DEMO_PROGRAM%g
 s%@ALL_DEMO_PROGRAMS@%$ALL_DEMO_PROGRAMS%g
 s%@SAVER_LIBS@%$SAVER_LIBS%g
 s%@MOTIF_LIBS@%$MOTIF_LIBS%g
 s%@GTK_LIBS@%$GTK_LIBS%g
-s%@ATHENA_LIBS@%$ATHENA_LIBS%g
-s%@ATHENA3D_LIBS@%$ATHENA3D_LIBS%g
+s%@XML_LIBS@%$XML_LIBS%g
+s%@JPEG_LIBS@%$JPEG_LIBS%g
 s%@HACK_LIBS@%$HACK_LIBS%g
 s%@XPM_LIBS@%$XPM_LIBS%g
 s%@GL_LIBS@%$GL_LIBS%g
 s%@GLE_LIBS@%$GLE_LIBS%g
+s%@XDPMS_LIBS@%$XDPMS_LIBS%g
 s%@PASSWD_LIBS@%$PASSWD_LIBS%g
 s%@INSTALL_SETUID@%$INSTALL_SETUID%g
+s%@SETUID_HACKS@%$SETUID_HACKS%g
 s%@INSTALL_DIRS@%$INSTALL_DIRS%g
 s%@NEED_SETUID@%$NEED_SETUID%g
 s%@INSTALL_PAM@%$INSTALL_PAM%g
-s%@SGI_VIDEO_OBJS@%$SGI_VIDEO_OBJS%g
-s%@SGI_VIDEO_LIBS@%$SGI_VIDEO_LIBS%g
 s%@PASSWD_SRCS@%$PASSWD_SRCS%g
 s%@PASSWD_OBJS@%$PASSWD_OBJS%g
 s%@XMU_SRCS@%$XMU_SRCS%g
 s%@XMU_OBJS@%$XMU_OBJS%g
+s%@XMU_LIBS@%$XMU_LIBS%g
 s%@SAVER_GL_SRCS@%$SAVER_GL_SRCS%g
 s%@SAVER_GL_OBJS@%$SAVER_GL_OBJS%g
 s%@SAVER_GL_LIBS@%$SAVER_GL_LIBS%g
 s%@LOCK_SRCS@%$LOCK_SRCS%g
 s%@LOCK_OBJS@%$LOCK_OBJS%g
+s%@JPEG_EXES@%$JPEG_EXES%g
 s%@GL_EXES@%$GL_EXES%g
+s%@GL_UTIL_EXES@%$GL_UTIL_EXES%g
 s%@GL_MEN@%$GL_MEN%g
 s%@GL_KLUDGE@%$GL_KLUDGE%g
 s%@GLE_EXES@%$GLE_EXES%g
 s%@GLE_MEN@%$GLE_MEN%g
 s%@GLE_KLUDGE@%$GLE_KLUDGE%g
+s%@GNOMEHELP_Y@%$GNOMEHELP_Y%g
+s%@GNOMEHELP_N@%$GNOMEHELP_N%g
 s%@HACKDIR@%$HACKDIR%g
+s%@GNOME_DATADIR@%$GNOME_DATADIR%g
+s%@HACK_CONF_DIR@%$HACK_CONF_DIR%g
 s%@APPDEFAULTS@%$APPDEFAULTS%g
 s%@DEPEND@%$DEPEND%g
 s%@DEPEND_FLAGS@%$DEPEND_FLAGS%g
@@ -9478,7 +10835,8 @@ warn() {
   warnpre
   if test "$warning" = long ; then echo '' ; fi
   warning=yes
-  echo "$warn_prefix $@"
+  rest="$@"
+  echo "$warn_prefix $rest"
 }
 
 warnL() {
@@ -9486,11 +10844,13 @@ warnL() {
   warnpre
   warning=yes
   if test "$was" != no ; then echo '' ; fi
-  echo "$warn_prefix $@"
+  rest="$@"
+  echo "$warn_prefix $rest"
 }
 
 warn2() {
-  echo "             $@"
+  rest="$@"
+  echo "             $rest"
   warning=long
 }
 
@@ -9535,6 +10895,10 @@ if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
   warn 'The DPMS extension was requested, but was not found.'
 fi
 
+if test "$with_xinerama_req" = yes -a "$have_xinerama" = no ; then
+  warn 'The Xinerama extension was requested, but was not found.'
+fi
+
 if test "$with_xf86vmode_req" = yes -a "$have_xf86vmode" = no ; then
   warn 'The XF86VMODE extension was requested, but was not found.'
 fi
@@ -9544,17 +10908,13 @@ if test "$with_proc_interrupts_req" = yes -a "$have_proc_interrupts" = no; then
 fi
 
 
-if test "$have_motif" = no -a "$have_gtk" = no -a "$have_athena" = no ; then
-  warnL "None of Motif, Gtk, or Athena widgets seem to be available;"
+if test "$have_motif" = no -a "$have_gtk" = no; then
+  warnL "Neither Motif nor Gtk seem to be available;"
   warn2 "the \`xscreensaver-demo' program requires one of these."
 
 elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
   warnL "Use of Motif was requested, but it wasn't found;"
-  if test "$have_gtk" = yes; then
-    warn2 "Gtk will be used instead."
-  else
-    warn2 "Athena will be used instead."
-  fi
+  warn2 "Gtk will be used instead."
 
 elif test "$jurassic_gtk" = yes ; then
 
@@ -9569,35 +10929,47 @@ elif test "$jurassic_gtk" = yes ; then
     warnL "Gtk was found on this system, but it is version $v;"
   fi
 
-  if test "$have_motif" = yes; then
-    which="Motif"
-  else
-    which="Athena"
-  fi
-
-  warn2 "Gtk $pref_gtk or newer is required.  $which will be used instead."
+  warn2 "Gtk $pref_gtk or newer is required.  Motif will be used instead."
 
 elif test "$with_gtk_req" = yes -a "$have_gtk" = no ; then
   warnL "Use of Gtk was requested, but it wasn't found;"
-  if test "$have_motif" = yes; then
-    warn2 "Motif will be used instead."
-  else
-    warn2 "Athena will be used instead."
-  fi
+  warn2 "Motif will be used instead."
 
-elif test "$with_athena_req" = yes -a "$have_athena" = no ; then
-  warnL "Use of Athena was requested, but it wasn't found;"
-  if test "$have_gtk" = yes; then
-    warn2 "Gtk will be used instead."
-  else
-    warn2 "Motif will be used instead."
-  fi
 fi
 
 
+if test "$with_gnome_req" = yes -a "$have_gnome" = no ; then
+  warn  'Use of the Gnome Control Panel was requested, but the necessary'
+  warn2 'headers and/or libraries were not found.'
+fi
+
+if test "$have_gtk" = yes ; then
+  if test "$have_xml" = no ; then
+    if test "$with_xml_req" = yes ; then
+      warn  'Use of the XML library was requested, but the necessary'
+      warn2 'headers and/or libraries were not found.'
+    else
+      warn  'GTK is being used, but the XML library was not found.'
+    fi
+
+    if test "$xml_halfassed" = yes ; then
+      echo ''
+      warn2 'More specifically, we found the headers, but not the'
+      warn2 'libraries; so either XML is half-installed on this'
+      warn2 "system, or something else went wrong.  The \`config.log'"
+      warn2 'file might contain some clues.'
+    fi
+
+    echo ''
+    warn2 "Without XML, the per-display-mode \`Settings' dialogs"
+    warn2 'will not be available.  Specify the location of the XML'
+    warn2 'library through the --with-xml option to configure.'
+  fi
+fi
+
 if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
 
-  preferred_lesstif=0.86
+  preferred_lesstif=0.92
 
   if test "$lesstif_version" = unknown; then
     warnL "Unable to determine the LessTif version number!"
@@ -9613,51 +10985,101 @@ if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
   fi
 fi
 
-if test "$have_athena" = yes -a "$have_motif" = no -a "$have_gtk" = no; then
-    warnL "Athena widgets are being used instead of Motif or Gtk."
-    warn2 "The \`xscreensaver-demo' program looks much better"
-    warn2 "with Motif or Gtk.  Wouldn't you rather be using Motif?"
-    warn2 "Motif is shipped by every commercial Unix vendor,"
-    warn2 "and there is a free implementation available as"
-    warn2 "well: see <http://www.lesstif.org/>.  Gtk is shipped"
-    warn2 "with most Linux and BSD distributions."
+
+if test "$have_motif" = yes -a "$have_gtk" = no ; then
+  warn  'Motif is being used, and GTK is not.'
+  echo  ''
+  warn2 'Though the Motif front-end to xscreensaver is still'
+  warn2 'maintained, it is no longer being updated with new'
+  warn2 'features: all new development on the xscreensaver-demo'
+  warn2 'program is happening in the GTK version, and not in the'
+  warn2 'Motif version.  It is recommended that you build against'
+  warn2 'GTK instead of Motif.  See <http://www.gtk.org/>.'
+fi
+
+
+if test "$with_xpm_req" = yes ; then
+  warnL 'Use of XPM was requested, but it was not found.'
 fi
 
+if test "$with_gdk_pixbuf_req" = yes ; then
+  warnL 'Use of GDK-Pixbuf was requested, but it was not found.'
+fi
+
+if test "$have_xpm" = no -a "$have_gdk_pixbuf" = no; then
 
-if test "$have_xpm" = no ; then
   if test "$with_xpm_req" = yes ; then
-    warnL 'Use of XPM was requested, but it was not found.'
+    true
   elif test "$with_xpm_req" = no ; then
-    noteL 'The XPM library is not being used.'
+    warnL 'The XPM library is not being used.'
+  else
+    warnL 'The XPM library was not found.'
+  fi
+
+  if test "$with_gdk_pixbuf_req" = yes ; then
+    true
+  elif test "$with_gdk_pixbuf_req" = no ; then
+    warnL 'The GDK-Pixbuf library is not being used.'
   else
-    noteL 'The XPM library was not found.'
+    warnL 'The GDK-Pixbuf library was not found.'
   fi
 
   echo ''
   warn2 'Some of the demos will not be as colorful as they'
-  warn2 'could be.  You might want to consider installing XPM'
-  warn2 'and re-running configure.  (Remember to delete the'
-  warn2 'config.cache file first.)  You can find XPM at most'
-  warn2 'X11 archive sites, such as <http://sunsite.unc.edu/>.'
+  warn2 'could be.  You should consider installing Pixbuf or'
+  warn2 'XPM and re-running configure.  (Remember to delete'
+  warn2 'the config.cache file first.)  The Pixbuf library is'
+  warn2 'a part of GNOME.  The XPM library comes with most'
+  warn2 'X11 installations; you can also find it at the X11'
+  warn2 'archive sites, such as <http://sunsite.unc.edu/>.'
+  echo  ''
+  warn2 'GDK-Pixbuf is recommended over XPM, as it provides'
+  warn2 'support for more image formats.'
+fi
+
+
+if test "$have_jpeg" = no ; then
+  if test "$with_jpeg_req" = yes ; then
+    warnL 'Use of libjpeg was requested, but it was not found.'
+  elif test "$with_jpeg_req" = no ; then
+    noteL 'The JPEG library is not being used.'
+  else
+    noteL 'The JPEG library was not found.'
+  fi
+
+  if test "$jpeg_halfassed" = yes ; then
+    echo ''
+    warn2 'More specifically, we found the headers, but not the'
+    warn2 'library; so either JPEG is half-installed on this'
+    warn2 "system, or something else went wrong.  The \`config.log'"
+    warn2 'file might contain some clues.'
+    echo ''
+  fi
+
+  warn2 "This means the \`webcollage' program will be much slower."
 fi
 
 
 if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
-  preferred_mesagl=3.0
+  preferred_mesagl=3.4
+  mgv="$ac_mesagl_version_string"
+  pgl="$preferred_mesagl"
 
   if test "$ac_mesagl_version" = unknown; then
     warnL "Unable to determine the MesaGL version number!"
     warn2 "Make sure you are using version $preferred_mesagl or newer."
 
   elif test \! "$ac_mesagl_version" -gt 2006; then
-    warnL "MesaGL version $ac_mesagl_version_string is being used."
-    warn2 "MesaGL versions 2.6 and earlier have a security bug."
-    warn2 "It is strongly recommended that you upgrade to at"
-    warn2 "least version $preferred_mesagl."
+    warnL "MesaGL version $mgv is being used.  MesaGL 2.6 and earlier"
+    warn2 "have a security bug.  It is strongly recommended that you"
+    warn2 "upgrade to at least version $preferred_mesagl."
+
+  elif test \! "$ac_mesagl_version" -gt 3003; then
+    warnL "MesaGL version $mgv is being used.  That version has some"
+    warn2 "bugs; it is recommended that you upgrade to $pgl or newer."
   fi
 fi
 
-
 if test "$have_gl" = no ; then
   if test "$with_gl_req" = yes ; then
     warnL 'Use of GL was requested, but it was not found.'
@@ -9667,6 +11089,14 @@ if test "$have_gl" = no ; then
     noteL 'The OpenGL 3D library was not found.'
   fi
 
+  if test "$gl_halfassed" = yes ; then
+    echo ''
+    warn2 'More specifically, we found the headers, but not the'
+    warn2 'libraries; so either GL is half-installed on this'
+    warn2 "system, or something else went wrong.  The \`config.log'"
+    warn2 'file might contain some clues.'
+  fi
+
   echo ''
   warn2 'Those demos which use 3D will not be built or installed.'
   warn2 'You might want to consider installing OpenGL and'
 
 if test "$have_gl" = yes -a "$have_gle" = no ; then
   if test "$with_gle_req" = yes ; then
-    warnL 'Use of GLE was requested, but it was not found.'
+    noteL 'Use of the GLE (GL Extrusion) library was requested, but'
+    warn2 'it was not found (though the OpenGL library was found, and'
+    warn2 'is being used.)'
   elif test "$with_gle_req" = no ; then
-    noteL 'The GLE (GL Extrusion) library is not being used.'
+    noteL 'The OpenGL Library is being used, but the GLE (GL Extrusion)'
+    warn2 'library is not.'
   else
-    noteL 'The GLE (GL Extrusion) library was not found.'
+    noteL 'The OpenGL Library was found, but the GLE (GL Extrusion)'
+    warn2 'was not.'
+  fi
+
+  if test "$gle_halfassed" = yes ; then
+    echo ''
+    warn2 'More specifically, we found the headers, but not the'
+    warn2 'libraries; so either GLE is half-installed on this'
+    warn2 "system, or something else went wrong.  The \`config.log'"
+    warn2 'file might contain some clues.'
   fi
 
   echo ''
-  warn2 'Some of the OpenGL (3D) demos will not be built or installed.'
-  warn2 'You might want to consider installing GLE and re-running'
-  warn2 'configure.  (Remember to delete the config.cache file first.)'
-  warn2 'You can find the GLE library at <http://www.linas.org/gle/>.'
-  warn2 'For general OpenGL info, see <http://www.opengl.org/>.'
+  warn2 'Some of the OpenGL (3D) demos (those that depend on GLE)'
+  warn2 'will not be built or installed.  You might want to consider'
+  warn2 'installing GLE and re-running configure.  (Remember to delete'
+  warn2 'the config.cache file first.)  You can find the GLE library'
+  warn2 'at <http://www.linas.org/gle/>.  For general OpenGL info,'
+  warn2 'see <http://www.opengl.org/>.'
 
 fi
 
@@ -9702,13 +11145,9 @@ if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
   warn 'Use of XReadDisplay was requested, but it was not found.'
 fi
 
-if test "$with_sgivideo_req" = yes -a "$have_sgivideo" = no ; then
-  warn 'Use of the Iris Video Library was requested, but it was not found.'
-fi
-
-if test -n "$with_zippy_req"; then
-  if test "$with_zippy_req" != "$ac_cv_zippy_program" ; then
-    warnL "$with_zippy_req was requested as the Zippy program,"
+if test -n "$with_fortune_req"; then
+  if test "$with_fortune_req" != "$ac_cv_fortune_program" ; then
+    warnL "$with_fortune_req was requested as the Fortune program,"
     warn2 "but was not found.  The default will be used instead."
   fi
 fi
@@ -9741,17 +11180,24 @@ eval HACKDIR=${HACKDIR}
 eval HACKDIR=${HACKDIR}
 eval HACKDIR=${HACKDIR}
 eval HACKDIR=${HACKDIR}
+eval HACK_CONF_DIR=${HACK_CONF_DIR}
+eval HACK_CONF_DIR=${HACK_CONF_DIR}
+eval HACK_CONF_DIR=${HACK_CONF_DIR}
+eval HACK_CONF_DIR=${HACK_CONF_DIR}
+eval HACK_CONF_DIR=${HACK_CONF_DIR}
+eval HACK_CONF_DIR=${HACK_CONF_DIR}
 
 # canonicalize slashes.
-bindir=`echo  "${bindir}"  | sed 's@/$@@;s@//*@/@g'`
-HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
+bindir=`echo  "${bindir}"              | sed 's@/$@@;s@//*@/@g'`
+HACKDIR=`echo "${HACKDIR}"             | sed 's@/$@@;s@//*@/@g'`
+HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
 
 
-# Sanity check the subdir
+# Sanity check the hackdir
 for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
   if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
     echo ""
-    { echo "configure: error: \"--enable-subdir=${bindir}/${bad_choice}\" won't work.
+    { echo "configure: error: \"--with-hackdir=${bindir}/${bad_choice}\" won't work.
                    There will be an executable installed with that name, so
                    that can't be the name of a directory as well.  Please
                    re-configure with a different directory name." 1>&2; exit 1; }
@@ -9766,7 +11212,7 @@ do_dir_warning=no
 # M4 sucks!!
 
 rpmv=`(rpm -qv xscreensaver) 2>&- | \
-      sed 's/^xscreensaver-\([0-9][0-9]*[.][0-9][0-9]*\)-[0-9][0-9]*$/\1/'`
+      sed -n 's/^xscreensaver-\([0-9][0-9]*[.][0-9][0-9]*\)-.*$/\1/p'`
 
 
 if test \! -z "$rpmv" ; then
@@ -9785,29 +11231,16 @@ if test \! -z "$rpmv" ; then
   echo ""
 
   if test "$rpmbdir" = "$rpmhdir" ; then
-    warn2 "The RPM version was installed in $rpmbdir."
+    warn2 "The RPM version was installed in $rpmbdir/."
   else
-    warn2 "The RPM version was installed in $rpmbdir,"
-    warn2 "with demos in $rpmhdir."
+    warn2 "The RPM version was installed in $rpmbdir/,"
+    warn2 "with demos in $rpmhdir/."
   fi
 
   do_dir_warning=yes
 fi
 
 
-# Warn about egregious GNOME bogosity.
-#
-if (rpm -qv control-center) >&- 2>&- ; then
-  warning=no
-  warnL "The Gnome Control Center seems to be installed."
-  echo  ""
-  warn2 "Note that simply installing this version of xscreensaver"
-  warn2 "will not cause GNOME to know about the newly-added display"
-  warn2 "modes -- GNOME is just lame that way.  Instead of using the"
-  warn2 "Control Center, try using the \`xscreensaver-demo' command."
-fi
-
-
 if test "${bindir}" = "${HACKDIR}" ; then
   do_dir_warning=yes
 fi
@@ -9818,14 +11251,14 @@ if test "$do_dir_warning" = yes; then
   echo ""
   echo '      When you run "make install", the "xscreensaver",'
   echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
-  echo "      will be installed in ${bindir}."
+  echo "      will be installed in ${bindir}/."
   echo ""
-  echo "      The various graphics demos (100+ different executables) will"
-  echo "      also be installed in ${HACKDIR}."
+  echo "      The various graphics demos (140+ different executables) will"
+  echo "      also be installed in ${HACKDIR}/."
   echo ""
   echo "      If you would prefer the demos to be installed elsewhere"
   echo "      (for example, in a dedicated directory) you should re-run"
-  echo "      configure with the --enable-subdir=DIR option.  For more"
+  echo "      configure with the --with-hackdir=DIR option.  For more"
   echo "      information, run $0 --help."
   warning=yes
 fi
@@ -9833,3 +11266,13 @@ fi
 if test "$warning" != no; then
   echo '' ; echo "$warnsep" ; echo ''
 fi
+
+if test "$do_dir_warning" = no; then
+  if test "$warning" = no; then
+    echo ''
+  fi
+  echo "User programs will be installed in ${bindir}/"
+  echo "Screen savers will be installed in ${HACKDIR}/"
+  echo "Configuration will be installed in ${HACK_CONF_DIR}/"
+  echo ''
+fi