+###############################################################################
+#
+# Check for the XINERAMA server extension.
+#
+###############################################################################
+
+have_xinerama=no
+with_xinerama_req=unspecified
+AC_ARG_WITH(xinerama-ext,
+[ --with-xinerama-ext Include support for the XINERAMA extension.],
+ [with_xinerama="$withval"; with_xinerama_req="$withval"],[with_xinerama=yes])
+
+HANDLE_X_PATH_ARG(with_xinerama, --with-xinerama-ext, XINERAMA)
+
+if test "$with_xinerama" = yes; then
+
+ # first check for Xinerama.h
+ AC_CHECK_X_HEADER(X11/extensions/Xinerama.h, [have_xinerama=yes],,
+ [#include <X11/Xlib.h>])
+
+ # 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_CHECK_X_LIB(Xext, XineramaQueryExtension, [have_xinerama=yes], [true],
+ -lXext -lX11)
+
+ # if that failed, look in -lXinerama (this is where it is in XFree86 4.1.)
+ if test "$have_xinerama" = no; then
+ AC_CHECK_X_LIB(Xinerama, XineramaQueryExtension,
+ [have_xinerama=yes; SAVER_LIBS="$SAVER_LIBS -lXinerama"],
+ [true], -lXext -lX11)
+ fi
+ fi
+
+ # if that succeeded, then we've really got it.
+ if test "$have_xinerama" = yes; then
+ AC_DEFINE(HAVE_XINERAMA)
+ fi
+
+elif test "$with_xinerama" != no; then
+ echo "error: must be yes or no: --with-xinerama-ext=$with_xinerama"
+ exit 1
+fi
+
+
+###############################################################################
+#
+# Check for the XF86VMODE server extension (for virtual screens.)
+#
+###############################################################################
+
+have_xf86vmode=no
+with_xf86vmode_req=unspecified
+AC_ARG_WITH(xf86vmode-ext,
+[ --with-xf86vmode-ext Include support for XFree86 virtual screens.],
+ [with_xf86vmode="$withval"; with_xf86vmode_req="$withval"],
+ [with_xf86vmode=yes])
+
+HANDLE_X_PATH_ARG(with_xf86vmode, --with-xf86vmode-ext, xf86vmode)
+
+if test "$with_xf86vmode" = yes; then
+
+ # first check for xf86vmode.h
+ AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86vmode=yes],,
+ [#include <X11/Xlib.h>])
+
+ # if that succeeded, then check for the -lXxf86vm
+ if test "$have_xf86vmode" = yes; then
+ have_xf86vmode=no
+ AC_CHECK_X_LIB(Xxf86vm, XF86VidModeGetViewPort,
+ [have_xf86vmode=yes; SAVER_LIBS="$SAVER_LIBS -lXxf86vm"],
+ [true], -lXext -lX11)
+ fi
+
+ # if that succeeded, then we've really got it.
+ if test "$have_xf86vmode" = yes; then
+ AC_DEFINE(HAVE_XF86VMODE)
+ fi
+
+elif test "$with_xf86vmode" != no; then
+ echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
+ exit 1
+fi
+
+
+###############################################################################
+#
+# Check for the XF86VMODE server extension (for gamma fading.)
+#
+###############################################################################
+
+have_xf86gamma=no
+have_xf86gamma_ramp=no
+with_xf86gamma_req=unspecified
+AC_ARG_WITH(xf86gamma-ext,
+[ --with-xf86gamma-ext Include support for XFree86 gamma fading.],
+ [with_xf86gamma="$withval"; with_xf86gamma_req="$withval"],
+ [with_xf86gamma=yes])
+
+HANDLE_X_PATH_ARG(with_xf86gamma, --with-xf86gamma-ext, xf86gamma)
+
+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_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86gamma=yes],,
+ [#include <X11/Xlib.h>])
+ fi
+
+ # if that succeeded, then check for the -lXxf86vm
+ if test "$have_xf86gamma" = yes; then
+ have_xf86gamma=no
+ AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGamma,
+ [have_xf86gamma=yes],
+ [true], -lXext -lX11)
+ fi
+
+ # check for the Ramp versions of the functions too.
+ if test "$have_xf86gamma" = yes; then
+ have_xf86gamma_ramp=no
+ AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGammaRamp,
+ [have_xf86gamma_ramp=yes],
+ [true], -lXext -lX11)
+ fi
+
+ # if those tests succeeded, then we've really got the functions.
+ if test "$have_xf86gamma" = yes; then
+ AC_DEFINE(HAVE_XF86VMODE_GAMMA)
+ fi
+
+ if test "$have_xf86gamma_ramp" = yes; then
+ AC_DEFINE(HAVE_XF86VMODE_GAMMA_RAMP)
+ 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 HP XHPDisableReset and XHPEnableReset.
+#
+###############################################################################
+
+AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
+ [AC_DEFINE(HAVE_XHPDISABLERESET)
+ SAVER_LIBS="-lXhp11 $SAVER_LIBS"])
+
+
+###############################################################################
+#
+# Check for /proc/interrupts.
+#
+###############################################################################
+
+have_proc_interrupts=no
+with_proc_interrupts_req=unspecified
+AC_ARG_WITH(proc-interrupts,
+[ --with-proc-interrupts Include support for consulting the /proc/interrupts
+ file to notice keyboard activity.],
+ [with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"],
+ [with_proc_interrupts=yes])
+
+if test "$with_proc_interrupts" = yes; then
+
+ AC_CACHE_CHECK([whether /proc/interrupts contains keyboard data],
+ ac_cv_have_proc_interrupts,
+ [ac_cv_have_proc_interrupts=no
+ if grep keyboard /proc/interrupts >/dev/null 2>&1 ; then
+ ac_cv_have_proc_interrupts=yes
+ fi
+ ])
+ have_proc_interrupts=$ac_cv_have_proc_interrupts
+
+ if test "$have_proc_interrupts" = yes; then
+ AC_DEFINE(HAVE_PROC_INTERRUPTS)
+ 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
+#
+###############################################################################
+
+AC_ARG_ENABLE(locking,[
+Screen locking options:
+
+ --enable-locking Compile in support for locking the display.
+ --disable-locking Do not allow locking at all.],
+ [enable_locking="$enableval"],[enable_locking=yes])
+if test "$enable_locking" = yes; then
+ true
+elif test "$enable_locking" = no; then
+ AC_DEFINE(NO_LOCKING)
+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
+
+AC_ARG_WITH(pam,
+[ --with-pam Include support for PAM (Pluggable Auth Modules.)],
+ [with_pam="$withval"; with_pam_req="$withval"],[with_pam=$with_pam_default])
+
+HANDLE_X_PATH_ARG(with_pam, --with-pam, PAM)
+
+if test "$enable_locking" = yes -a "$with_pam" = yes; then
+ AC_CACHE_CHECK([for PAM], ac_cv_pam,
+ [AC_TRY_X_COMPILE([#include <security/pam_appl.h>],,
+ [ac_cv_pam=yes],
+ [ac_cv_pam=no])])
+ if test "$ac_cv_pam" = yes ; then
+ have_pam=yes
+ AC_DEFINE(HAVE_PAM)
+ 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.
+ AC_CHECK_LIB(dl, dlopen, [PASSWD_LIBS="${PASSWD_LIBS} -ldl"])
+
+ AC_MSG_CHECKING(how to call pam_strerror)
+ AC_CACHE_VAL(ac_cv_pam_strerror_args,
+ [AC_TRY_COMPILE([#include <stdio.h>
+ #include <stdlib.h>
+ #include <security/pam_appl.h>],
+ [pam_handle_t *pamh = 0;
+ char *s = pam_strerror(pamh, PAM_SUCCESS);],
+ [ac_pam_strerror_args=2],
+ [AC_TRY_COMPILE([#include <stdio.h>
+ #include <stdlib.h>
+ #include <security/pam_appl.h>],
+ [char *s =
+ pam_strerror(PAM_SUCCESS);],
+ [ac_pam_strerror_args=1],
+ [ac_pam_strerror_args=0])])
+ ac_cv_pam_strerror_args=$ac_pam_strerror_args])
+ ac_pam_strerror_args=$ac_cv_pam_strerror_args
+ if test "$ac_pam_strerror_args" = 1 ; then
+ AC_MSG_RESULT(one argument)
+ elif test "$ac_pam_strerror_args" = 2 ; then
+ AC_DEFINE(PAM_STRERROR_TWO_ARGS)
+ AC_MSG_RESULT(two arguments)
+ else
+ AC_MSG_RESULT(unknown)
+ fi
+ fi
+fi
+
+
+###############################################################################
+#
+# Check for Kerberos.
+#
+###############################################################################
+
+have_kerberos=no
+have_kerberos5=no
+with_kerberos_req=unspecified
+
+AC_ARG_WITH(kerberos,
+[ --with-kerberos Include support for Kerberos authentication.],
+ [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
+
+HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
+
+if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
+ AC_CACHE_CHECK([for Kerberos 4], ac_cv_kerberos,
+ [AC_TRY_X_COMPILE([#include <krb.h>],,
+ [ac_cv_kerberos=yes],
+ [ac_cv_kerberos=no])])
+ AC_CACHE_CHECK([for Kerberos 5], ac_cv_kerberos5,
+ [AC_TRY_X_COMPILE([#include <kerberosIV/krb.h>],,
+ [ac_cv_kerberos5=yes],
+ [ac_cv_kerberos5=no])])
+
+ if test "$ac_cv_kerberos" = yes ; then
+ have_kerberos=yes
+ AC_DEFINE(HAVE_KERBEROS)
+ fi
+
+ if test "$ac_cv_kerberos5" = yes ; then
+ have_kerberos=yes
+ have_kerberos5=yes
+ AC_DEFINE(HAVE_KERBEROS)
+ AC_DEFINE(HAVE_KERBEROS5)
+ 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
+ AC_CHECK_FUNC(res_search,,
+ AC_CHECK_LIB(resolv,res_search,PASSWD_LIBS="${PASSWD_LIBS} -lresolv",
+ AC_MSG_WARN([Can't find DNS resolver libraries needed for Kerberos])
+ ))
+ fi
+fi
+
+
+###############################################################################
+#
+# Check for the nine billion variants of shadow passwords...
+#
+###############################################################################
+
+need_setuid=no
+
+have_shadow=no
+with_shadow_req=unspecified
+
+AC_ARG_WITH(shadow,
+[ --with-shadow Include support for shadow password authentication.],
+ [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
+
+HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
+
+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
+ AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
+ [AC_TRY_X_COMPILE([#include <stdlib.h>
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/label.h>
+ #include <sys/audit.h>
+ #include <pwdadj.h>],
+ [struct passwd_adjunct *p = getpwanam("nobody");
+ const char *pw = p->pwa_passwd;],
+ [ac_cv_sun_adjunct=yes],
+ [ac_cv_sun_adjunct=no])])
+ 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.
+#
+###############################################################################
+
+if test "$with_shadow" = yes ; then
+ AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
+ [AC_TRY_X_COMPILE([#include <stdlib.h>
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <pwd.h>
+ #include <sys/security.h>
+ #include <prot.h>],
+ [struct pr_passwd *p;
+ const char *pw;
+ set_auth_parameters(0, 0);
+ check_auth_parameters();
+ p = getprpwnam("nobody");
+ pw = p->ufld.fd_encrypt;],
+ [ac_cv_enhanced_passwd=yes],
+ [ac_cv_enhanced_passwd=no])])
+ if test $ac_cv_enhanced_passwd = yes; then
+ have_shadow_enhanced=yes
+ have_shadow=yes
+ need_setuid=yes
+
+ # 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.
+ #
+ AC_CHECK_LIB(prot, getprpwnam,
+ [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
+ [AC_CHECK_LIB(security, getprpwnam,
+ [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
+ [-lx])
+ fi
+fi
+
+###############################################################################
+#
+# Check for HP's entry in the "Not Invented Here" Sweepstakes.
+#
+###############################################################################
+
+if test "$with_shadow" = yes ; then
+ AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
+ [AC_TRY_X_COMPILE([#include <stdlib.h>
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <pwd.h>
+ #include <hpsecurity.h>
+ #include <prot.h>],
+ [struct s_passwd *p = getspwnam("nobody");
+ const char *pw = p->pw_passwd;],
+ [ac_cv_hpux_passwd=yes],
+ [ac_cv_hpux_passwd=no])])
+ if test "$ac_cv_hpux_passwd" = yes; then
+ have_shadow_hpux=yes
+ have_shadow=yes
+ need_setuid=yes
+
+ # on HPUX, bigcrypt is in -lsec
+ AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
+ fi
+fi
+