+# 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
+
+
+###############################################################################
+#
+# 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.
+#
+###############################################################################
+
+if test "$with_shadow" = yes ; then
+ AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
+ [if test -f /etc/master.passwd ; then
+ ac_cv_master_passwd=yes
+ else
+ ac_cv_master_passwd=no
+ fi])
+ if test "$ac_cv_master_passwd" = yes; then
+ need_setuid=yes
+ fi
+fi
+
+
+###############################################################################
+#
+# Check for traditional (ha!) shadow passwords.
+#
+###############################################################################
+
+if test "$with_shadow" = yes ; then
+ AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
+ [AC_TRY_X_COMPILE([#include <stdlib.h>
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <pwd.h>
+ #include <shadow.h>],
+ [struct spwd *p = getspnam("nobody");
+ const char *pw = p->sp_pwdp;],
+ [ac_cv_shadow=yes],
+ [ac_cv_shadow=no])])
+ 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
+ AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
+ if test "$have_getspnam" = no ; then
+ AC_CHECK_LIB(gen, getspnam,
+ [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
+ fi
+ fi
+fi
+
+
+###############################################################################
+#
+# Check for other libraries needed for non-shadow passwords.
+#
+###############################################################################
+
+if test "$enable_locking" = yes ; then
+
+ # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
+ have_crypt=no
+ AC_CHECK_LIB(c, crypt, [have_crypt=yes])
+ if test "$have_crypt" = no ; then
+ AC_CHECK_LIB(crypt, crypt,
+ [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
+ 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
+ AC_DEFINE(HAVE_ADJUNCT_PASSWD)
+elif test "$have_shadow_enhanced" = yes ; then
+ AC_DEFINE(HAVE_ENHANCED_PASSWD)
+elif test "$have_shadow_hpux" = yes ; then
+ AC_DEFINE(HAVE_HPUX_PASSWD)
+elif test "$have_shadow" = yes ; then
+ AC_DEFINE(HAVE_SHADOW_PASSWD)
+fi
+
+
+###############################################################################
+#
+# Check for external password helper
+# On SuSE, instead of having xscreensaver be a setuid program, they
+# fork an external program that takes the password on stdin, and
+# returns true if that password is a valid one. Then only that
+# smaller program needs to be setuid.
+#
+# (Note that this external program is not a GUI: the GUI is still
+# all in xscreensaver itself; the external program just does auth.)
+#
+###############################################################################
+
+have_passwd_helper=no
+with_passwd_helper_req=unspecified
+
+AC_ARG_WITH(passwd-helper,
+[ --with-passwd-helper Include support for an external password
+ verification helper program.],
+ [with_passwd_helper="$withval"; with_passwd_helper_req="$withval"],[with_passwd_helper=no])
+# no HANDLE_X_PATH_ARG for this one
+
+if test "$enable_locking" = no ; then
+ with_passwd_helper_req=no
+ with_passwd_helper=no
+fi
+
+case "$with_passwd_helper" in
+ ""|no) : ;;
+ /*)
+ AC_DEFINE_UNQUOTED(PASSWD_HELPER_PROGRAM, "$with_passwd_helper")
+ have_passwd_helper=yes;;
+ *)
+ echo "error: --with-passwd-helper needs full pathname of helper (not '$with_passwd_helper')." >&2
+ exit 1
+esac
+
+
+###############################################################################
+#
+# Check for a login manager for a "New Login" button on the lock dialog.
+# Usually this will be "/usr/bin/gdmflexiserver".
+#
+###############################################################################
+
+with_login_manager_req=unspecified
+default_login_manager_1='gdmflexiserver -ls'
+default_login_manager_2='kdmctl reserve'
+default_login_manager_3='lxdm -c USER_SWITCH'
+default_login_manager_4='dm-tool switch-to-greeter'
+
+AC_ARG_WITH(login-manager,
+[ --with-login-manager Put a "New Login" button on the unlock dialog that
+ runs a login manager like gdmflexiserver or kdmctl.],
+ [with_login_manager="$withval"; with_login_manager_req="$withval"],
+ [with_login_manager=yes])
+# no HANDLE_X_PATH_ARG for this one
+
+if test "$enable_locking" = no ; then
+ with_login_manager_req=no
+ with_login_manager=no
+fi
+
+case "$with_login_manager_req" in
+ no)
+ with_login_manager=""
+ ;;
+
+ yes|unspecified)
+ # Try various defaults, use the first one that exists.
+
+ with_login_manager=""
+
+ if test -z "$with_login_manager" ; then
+ set dummy $default_login_manager_1 ; login_manager_tmp=$2
+ unset ac_cv_path_login_manager_tmp # don't cache
+ AC_PATH_PROG(login_manager_tmp, $login_manager_tmp, [])
+ if test ! -z "$login_manager_tmp" ; then
+ with_login_manager="$default_login_manager_1"
+ fi
+ fi
+
+ if test -z "$with_login_manager" ; then
+ set dummy $default_login_manager_2 ; login_manager_tmp=$2
+ unset ac_cv_path_login_manager_tmp # don't cache
+ AC_PATH_PROG(login_manager_tmp, $login_manager_tmp, [])
+ if test ! -z "$login_manager_tmp" ; then
+ with_login_manager="$default_login_manager_2"
+ fi
+ fi
+
+ if test -z "$with_login_manager" ; then
+ set dummy $default_login_manager_3 ; login_manager_tmp=$2
+ unset ac_cv_path_login_manager_tmp # don't cache
+ AC_PATH_PROG(login_manager_tmp, $login_manager_tmp, [])
+ if test ! -z "$login_manager_tmp" ; then
+ with_login_manager="$default_login_manager_3"
+ fi
+ fi
+
+ if test -z "$with_login_manager" ; then
+ set dummy $default_login_manager_4 ; login_manager_tmp=$2
+ unset ac_cv_path_login_manager_tmp # don't cache
+ AC_PATH_PROG(login_manager_tmp, $login_manager_tmp, [])
+ if test ! -z "$login_manager_tmp" ; then
+ with_login_manager="$default_login_manager_4"
+ fi
+ fi
+
+ ;;
+
+ /*)
+ # absolute path specified on cmd line
+ set dummy $with_login_manager_req ; login_manager_tmp=$2
+ AC_MSG_CHECKING([for $login_manager_tmp])
+ if test -x "$login_manager_tmp" ; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ with_login_manager=""
+ fi
+ ;;
+
+ *)
+ # relative path specified on cmd line
+ set dummy $with_login_manager_req ; login_manager_tmp=$2
+ unset ac_cv_path_login_manager_tmp # don't cache
+ AC_PATH_PROG(login_manager_tmp, $login_manager_tmp, [])
+ if test -z "$login_manager_tmp" ; then
+ with_login_manager=""
+ else
+ with_login_manager="$login_manager_tmp"
+ fi
+ ;;
+esac
+ac_cv_login_manager_program="$with_login_manager"
+
+NEW_LOGIN_COMMAND_P=''
+NEW_LOGIN_COMMAND="$ac_cv_login_manager_program"
+
+AC_MSG_CHECKING(for login manager)
+if test -z "$NEW_LOGIN_COMMAND" ; then
+ NEW_LOGIN_COMMAND="$default_login_manager_1"
+ NEW_LOGIN_COMMAND_P='! '
+ AC_MSG_RESULT($NEW_LOGIN_COMMAND (disabled))
+else
+ AC_MSG_RESULT($NEW_LOGIN_COMMAND)
+fi
+
+
+###############################################################################
+#
+# Check for -lgtk (and Gnome stuff)
+#
+###############################################################################
+
+have_gtk=no
+with_gtk_req=unspecified
+AC_ARG_WITH(gtk,[
+User interface options:
+
+ --with-gtk Use the Gtk toolkit for the user interface.],
+ [with_gtk="$withval"; with_gtk_req="$withval"],[with_gtk=yes])
+
+# 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
+
+HANDLE_X_PATH_ARG(with_gtk, --with-gtk, Gtk)
+
+if test "$with_gtk" != yes -a "$with_gtk" != no ; then
+ echo "error: must be yes or no: --with-gtk=$with_gtk"
+ exit 1
+fi
+
+
+parse_gtk_version_string() {
+ # M4 sucks!!
+ changequote(X,Y)
+ maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
+ min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
+ changequote([,])
+ 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
+}
+
+# Find pkg-config... (need this for both gtk and gdk_pixbuf.)
+# if the user specified --with-gtk=/foo/ then look there.
+#
+gtk_path="$PATH"
+if test ! -z "$gtk_dir"; then
+ # canonicalize slashes.
+ foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
+ gtk_path="$foo:$gtk_path"
+fi
+
+AC_PATH_PROGS(pkg_config, pkg-config,, $gtk_path)
+
+if test -z "$pkg_config" ; then
+ AC_MSG_WARN([pkg-config not found!])
+ pkg_config="false"
+fi
+
+
+# Utility function for running pkg-config-based tests...
+#
+pkgs=''
+pkg_check_version() {
+ if test "$ok" = yes ; then
+ req="$1"
+ min="$2"
+ AC_MSG_CHECKING(for $req)
+ if $pkg_config --exists "$req" ; then
+ vers=`$pkg_config --modversion "$req"`
+ if $pkg_config --exists "$req >= $min" ; then
+ AC_MSG_RESULT($vers)
+ pkgs="$pkgs $req"
+ return 1
+ else
+ AC_MSG_RESULT($vers (wanted >= $min))
+ ok=no
+ return 0
+ fi
+ else
+ AC_MSG_RESULT(no)
+ ok=no
+ return 0
+ fi
+ fi
+}
+
+
+jurassic_gtk=no
+gtk_halfassed=no
+have_gtk_2_22_or_higher=no
+COMMENT_DEMO_GLADE2_GTK_2_22_HEAD=""
+COMMENT_DEMO_GLADE2_GTK_2_22_TAIL=""
+
+if test "$with_gtk" = yes; then
+ have_gtk=no
+
+ ok="yes"
+ pkg_check_version gtk+-2.0 2.0.1 ; ac_gtk_version_string="$vers"
+ pkg_check_version gmodule-2.0 2.0.0
+ pkg_check_version libxml-2.0 2.4.6
+ pkg_check_version libglade-2.0 1.99.0
+ pkg_check_version gdk-pixbuf-2.0 2.0.0
+ pkg_check_version gdk-pixbuf-xlib-2.0 2.0.0
+ have_gtk="$ok"
+
+ if test "$have_gtk" = no; then
+ if test -n "$ac_gtk_version_string" ; then
+ gtk_halfassed="$ac_gtk_version_string"
+ gtk_halfassed_lib="$req"
+ fi
+ fi
+
+ if test "$have_gtk" = yes; then
+ parse_gtk_version_string
+ jurassic_gtk=no
+ fi
+
+ if test "$have_gtk" = yes; then
+ AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
+ [ac_cv_gtk_config_cflags=`$pkg_config --cflags $pkgs`])
+ AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
+ [ac_cv_gtk_config_libs=`$pkg_config --libs $pkgs`])
+ fi
+
+ ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
+ ac_gtk_config_libs=$ac_cv_gtk_config_libs
+
+ GTK_EXTRA_OBJS=""
+ GTK_DATADIR=""
+ if test "$have_gtk" = yes; then
+ GTK_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
+ GTK_DATADIR="$GTK_DATADIR/share"
+ fi
+
+ if test "$have_gtk" = yes; then
+ INCLUDES="$INCLUDES $ac_gtk_config_cflags"
+ GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
+ AC_DEFINE(HAVE_GTK)
+ AC_DEFINE(HAVE_GTK2)
+ AC_DEFINE(HAVE_XML)
+ fi
+
+ if test "$have_gtk" = yes; then
+ ok="yes"
+ pkg_check_version gtk+-2.0 2.22
+ have_gtk_2_22_or_higher="$ok"
+ if test "$have_gtk_2_22_or_higher" = yes; then
+ COMMENT_DEMO_GLADE2_GTK_2_22_HEAD="<!-- comment>"
+ COMMENT_DEMO_GLADE2_GTK_2_22_TAIL="</comment -->"
+ fi
+ fi
+fi
+
+
+# Check for the various Gnome help and URL loading programs.
+#
+WITH_BROWSER=gnome-open
+if test "$have_gtk" = yes; then
+ AC_CHECK_PROGS(gnome_open_program, gnome-open)
+ AC_CHECK_PROGS(gnome_url_show_program, gnome-url-show)
+fi
+
+
+###############################################################################
+#
+# Check for -lXm.
+#
+###############################################################################
+
+have_motif=no
+with_motif_req=unspecified
+AC_ARG_WITH(motif,[ --with-motif Use the Motif toolkit for the user interface
+ (no longer supported.)],
+ [with_motif="$withval"; with_motif_req="$withval"],[with_motif=no])
+
+HANDLE_X_PATH_ARG(with_motif, --with-motif, Motif)
+
+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_CHECK_X_HEADER(Xm/Xm.h,
+ [have_motif=yes
+ AC_DEFINE(HAVE_MOTIF)
+ MOTIF_LIBS="$MOTIF_LIBS -lXm"],,
+ [#include <stdlib.h>
+ #include <stdio.h>
+ #include <X11/Intrinsic.h>])
+fi
+
+
+if test "$have_motif" = yes; then
+ AC_CHECK_X_HEADER(Xm/ComboBox.h, [AC_DEFINE(HAVE_XMCOMBOBOX)],,
+ [#include <stdlib.h>
+ #include <stdio.h>
+ #include <X11/Intrinsic.h>])
+fi
+
+
+###############################################################################
+#
+# Checking whether Motif is really Lesstif.
+#
+###############################################################################
+
+have_lesstif=no
+if test "$have_motif" = yes ; then