+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"])
+
+ # On Linux, sigtimedwait() is in libc; on Solaris, it's in librt.
+ have_timedwait=no
+ AC_CHECK_LIB(c, sigtimedwait, [have_timedwait=yes])
+ if test "$have_timedwait" = no ; then
+ AC_CHECK_LIB(rt, sigtimedwait, [PASSWD_LIBS="${PASSWD_LIBS} -lrt"])
+ fi
+
+ 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
+
+ # Andrew Snare <ajs@pigpond.com> wrote:
+ #
+ # You were assuming that if kerberosV (krb5) was found, then kerberosIV
+ # (krb4) was also available. This turns out not to be the case with
+ # mit-krb-1.2.7; apparently backwards-compatibility with KerberosIV
+ # is optional.
+ #
+ # So, disable kerberosV support if libkrb4 can't be found.
+ # This is not the best solution, but it makes the compile not fail.
+ #
+ AC_CHECK_X_LIB(krb4, krb_get_tf_realm,
+ [have_kerberos=yes],
+ [have_kerberos=no])
+ if test "$have_kerberos" = yes ; then
+ have_kerberos5=yes
+ AC_DEFINE(HAVE_KERBEROS)
+ AC_DEFINE(HAVE_KERBEROS5)
+ else
+ have_kerberos5=no
+ AC_MSG_WARN([Cannot find compat lib (libkrb4) needed to use Kerberos 5])
+ fi
+
+ 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 -lcom_err"
+
+ # jwz: MacOS X uses -lkrb5, but not -lcrypt
+ AC_CHECK_X_LIB(crypt, crypt, [PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
+
+ 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
+
+
+###############################################################################
+#
+# 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 -lXm.
+#
+###############################################################################
+
+have_motif=no
+with_motif_req=unspecified
+AC_ARG_WITH(motif,[
+User interface options:
+
+ --with-motif Use the Motif toolkit for the user interface
+ (not recommended.)],
+ [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
+
+
+###############################################################################
+#
+# Check for -lgtk (and Gnome stuff)
+#
+###############################################################################
+
+have_gtk=no
+have_gtk2=no
+with_gtk_req=unspecified
+AC_ARG_WITH(gtk,
+[ --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
+
+have_gnome=no
+with_gnome_req=unspecified
+AC_ARG_WITH(gnome,
+[ --with-gnome Include support for the Gnome 1.x Control Center.
+ (This option is not needed with GTK 2.x / Gnome 2.x.)
+],
+ [with_gnome="$withval"; with_gnome_req="$withval"],[with_gnome=yes])
+
+# 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
+
+HANDLE_X_PATH_ARG(with_gnome, --with-gnome, Gnome)
+
+if test "$with_gnome" != yes -a "$with_gnome" != no ; then
+ echo "error: must be yes or no: --with-gnome=$with_gnome"
+ 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
+}
+
+
+jurassic_gtk=no
+gtk2_halfassed=no
+
+if test "$with_gtk" = yes; then
+ have_gtk=no
+
+ # if the user specified --with-gtk=/foo/ or --with-gnome=/foo/ then
+ # look in /foo/bin/ for glib-config, gtk-config, and gnome-config.
+ #
+ 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
+
+ if test ! -z "$gnome_dir"; then
+ # canonicalize slashes.
+ foo=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
+ gtk_path="$foo:$gtk_path"
+ fi
+
+ AC_PATH_PROGS(pkg_config, pkg-config,, $gtk_path)
+
+ if test -n "$pkg_config" ; then
+ #
+ # the new way...
+ # run 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
+ }
+
+ AC_MSG_RESULT(checking for GTK 2.x with pkg-config based tests...)
+
+ 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 0.1
+ have_gtk="$ok"
+
+ if test "$have_gtk" = yes; then
+ have_gtk2=yes
+ AC_DEFINE(HAVE_GTK2)
+ else
+ if test -n "$ac_gtk_version_string" ; then
+ gtk2_halfassed="$ac_gtk_version_string"
+ gtk2_halfassed_lib="$req"
+ fi
+ fi
+
+ if test "$have_gtk" = no; then
+ #
+ # we don't have GTK 2. Let's look for GTK 1.
+ #
+ AC_MSG_RESULT(checking for GTK 1.x with pkg-config based tests...)
+
+ pkgs=''
+ ok="yes"
+ pkg_check_version gtk+ 1.2 ; ac_gtk_version_string="$vers"
+ pkg_check_version glib 1.0
+ pkg_check_version gdk_pixbuf 0.1
+ have_gtk="$ok"
+
+ # Now check for Gnome...
+ #
+ if test "$have_gtk" = yes -a "$with_gnome" = yes; then
+ old_pkgs="$pkgs"
+ ok=yes
+ pkg_check_version capplet 1.0
+ pkg_check_version gnomeui 1.0
+ pkg_check_version gdk_pixbuf 0.1
+ have_gnome="$ok"
+
+ if test "$have_gnome" = no; then
+ pkgs="$old_pkgs"
+ else
+ AC_DEFINE(HAVE_CRAPPLET)
+ fi
+ fi
+ fi
+
+ if test "$have_gtk" = yes; then
+ parse_gtk_version_string
+ jurassic_gtk=no
+ else
+ have_gnome=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
+
+ ac_gnome_config_cflags=$ac_gtk_config_cflags
+ ac_gnome_config_libs=$ac_gtk_config_libs
+
+ else
+ #
+ # the old way...
+ # run {gnome,gtk}-config based tests.
+ #
+ AC_MSG_RESULT(checking for GTK 1.x with gtk-config based tests...)
+
+ AC_PATH_PROGS(glib_config, glib12-config glib-config,, $gtk_path)
+ AC_PATH_PROGS(gtk_config, gtk12-config gtk-config,, $gtk_path)
+
+ if test "$with_gnome" = yes; then
+ AC_PATH_PROGS(gnome_config, gnome-config,, $gtk_path)
+ 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
+ AC_CACHE_CHECK([Gtk version number], ac_cv_gtk_version_string,
+ [ac_cv_gtk_version_string=`$gtk_config --version`])
+ ac_gtk_version_string=$ac_cv_gtk_version_string
+ parse_gtk_version_string
+ fi
+
+ if test "$have_gtk" = yes; then
+ 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
+ AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
+ [ac_cv_gtk_config_cflags=`$gtk_config --cflags`])
+ AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
+ [ac_cv_gtk_config_libs=`$gtk_config --libs`])
+ fi
+ ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
+ ac_gtk_config_libs=$ac_cv_gtk_config_libs
+
+ # Check for Gnome Capplet support.
+ # Note that this is only needed with Gnome 1.x, not Gnome 2.x.
+ # In a Gnome 2.x world, libcapplet will not exist.
+ # (In fact, this likely won't even be checked, since in a Gnome 2.x
+ # world, we will probably be up in the "$pkg_config" branch instead
+ # of here in the "$gnome_config" branch.)
+ #
+ if test "$have_gnome" = yes -a "$have_gtk" = yes; then
+ gnome_config_libs="gtk capplet gnomeui gdk_pixbuf"
+ AC_MSG_CHECKING(for Gnome capplet includes)
+ AC_CACHE_VAL(ac_cv_gnome_config_cflags,
+ [if ( $gnome_config --cflags $gnome_config_libs 2>&1 | \
+ grep Unknown >/dev/null ) ; then
+ ac_cv_gnome_config_cflags=''
+ else
+ ac_cv_gnome_config_cflags=`$gnome_config --cflags $gnome_config_libs`
+ fi])
+ ac_gnome_config_cflags=$ac_cv_gnome_config_cflags
+ if test "$ac_gnome_config_cflags" = "" ; then
+ have_gnome=no
+ AC_MSG_RESULT(no)
+ else
+ AC_MSG_RESULT($ac_gnome_config_cflags)
+ fi
+ fi
+
+ if test "$have_gnome" = yes -a "$have_gtk" = yes; then
+ AC_MSG_CHECKING(for Gnome capplet libs)
+ AC_CACHE_VAL(ac_cv_gnome_config_libs,
+ [if ( $gnome_config --libs $gnome_config_libs 2>&1 |
+ grep Unknown >/dev/null ) ; then
+ ac_cv_gnome_config_libs=''
+ else
+ ac_cv_gnome_config_libs=`$gnome_config --libs $gnome_config_libs`
+ fi])
+ ac_gnome_config_libs=$ac_cv_gnome_config_libs
+ if test "$ac_gnome_config_libs" = "" ; then
+ have_gnome=no
+ AC_MSG_RESULT(no)
+ else
+ AC_MSG_RESULT($ac_gnome_config_libs)
+ fi
+ 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
+ AC_DEFINE(HAVE_CRAPPLET)
+ fi
+
+ fi # end of {gnome,gtk}-config based tests
+
+ if test "$have_gtk" = yes -a "$have_gtk2" = no; then
+ # check for this function that was not in libcapplet 1.2.
+ # (only needed in Gnome/Gtk 1.x, not Gnome/Gtk 2.x)
+ AC_CHECK_X_LIB(capplet, capplet_widget_changes_are_immediate,
+ [AC_DEFINE(HAVE_CRAPPLET_IMMEDIATE)], [true],
+ $ac_gnome_config_libs)
+ fi
+
+
+ GNOME_DATADIR=""
+ if test "$have_gtk" = yes; then
+ if test -n "$pkg_config"; then
+ if test "$have_gtk2" = yes; then
+ GNOME_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
+ else
+ GNOME_DATADIR=`$pkg_config --variable=prefix gtk+`
+ fi
+ else
+ GNOME_DATADIR=`$gtk_config --prefix`
+ fi
+ GNOME_DATADIR="$GNOME_DATADIR/share"
+ fi
+
+ # .desktop files go in different places in Gnome 1.x and Gnome 2.x...
+ if test "$have_gtk2" = yes; then
+ GNOME_PANELDIR='$(GNOME_PANELDIR2)'
+ else
+ GNOME_PANELDIR='$(GNOME_PANELDIR1)'
+ 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)
+
+ if test "$have_gtk2" = yes; then
+ GTK_EXTRA_OBJS=""
+ else
+ GTK_EXTRA_OBJS="\$(GTK_EXTRA_OBJS)"
+ fi
+ fi
+
+fi
+
+
+# Check for the Gnome Help Browser.
+#
+if test "$have_gtk" = yes; then
+ AC_CHECK_PROGS(have_gnome_help, yelp gnome-help-browser, no)
+ if test "$have_gnome_help" != no; then
+ have_gnome_help=yes
+ fi
+fi
+
+
+###############################################################################
+#
+# Check for -lxml
+#
+###############################################################################
+
+have_xml=no
+with_xml_req=unspecified
+xml_halfassed=no
+AC_ARG_WITH(xml,
+[ --with-xml The XML toolkit is needed for some parts of
+ the Gtk interface. Without it, the configuration
+ interface will be much less featureful.],
+[with_xml="$withval"; with_xml_req="$withval"],[with_xml=yes])
+
+# if --with-xml=/directory/ was specified, remember that directory so that
+# we can also look for the `xml-config' program in that directory.
+case "$with_xml" in
+ /*)
+ xml_dir="$with_xml"
+ ;;
+ *)
+ xml_dir=""
+ ;;
+esac
+
+HANDLE_X_PATH_ARG(with_xml, --with-xml, XML)
+
+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 "$with_xml" = yes; then
+ have_xml=no
+ have_old_xml=no
+
+ # if the user specified --with-gtk=/foo/ or --with-gnome=/foo/ then
+ # look in /foo/bin/ for for xml-config.
+ #
+ xml_path="$PATH"
+
+ if test ! -z "$gtk_dir"; then
+ # canonicalize slashes.
+ foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
+ xml_path="$foo:$xml_path"
+ fi
+
+ if test ! -z "$gnome_dir"; then
+ # canonicalize slashes.
+ foo=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
+ xml_path="$foo:$xml_path"
+ fi
+
+ if test -n "$pkg_config" ; then
+ #
+ # the new way...
+ # run pkg-config based tests.
+ #
+ pkgs=""
+ ok="yes"
+
+ # If we have Gtk 2.x, then *only* XML 2.x will work.
+ # If we have Gtk 1.x, or don't have Gtk at all, then
+ # either XML 1.x or 2.x will work.
+
+ # First check for XML 2.x.
+ #
+ pkg_check_version libxml-2.0 2.4.6
+
+ # If that didn't work (we don't have XML 2.x) and we *don't* have
+ # Gtk 2.x, then check to see if we have XML 1.x
+ #
+ if test "$ok" = no -a "$have_gtk2" = no; then
+ ok=yes
+ pkg_check_version libxml 1.0
+ fi
+
+ have_xml="$ok"
+
+ if test "$have_xml" = yes; then
+ AC_CACHE_CHECK([for XML includes], ac_cv_xml_config_cflags,
+ [ac_cv_xml_config_cflags=`$pkg_config --cflags $pkgs`])
+ AC_CACHE_CHECK([for XML libs], ac_cv_xml_config_libs,
+ [ac_cv_xml_config_libs=`$pkg_config --libs $pkgs`])
+ ac_xml_config_cflags=$ac_cv_xml_config_cflags
+ ac_xml_config_libs=$ac_cv_xml_config_libs
+ fi
+
+ else
+ #
+ # the old way...
+ # run {xml2,xml}-config based tests.
+ #
+
+ AC_PATH_PROGS(xml_config, xml2-config xml-config,, $xml_path)
+
+ # If we found the xml-config program, run it to get flags.
+ #
+ if test -n "$xml_config" ; then
+ AC_CACHE_CHECK([for XML includes], ac_cv_xml_config_cflags,
+ [ac_cv_xml_config_cflags=`$xml_config --cflags`])
+ AC_CACHE_CHECK([for XML libs], ac_cv_xml_config_libs,
+ [ac_cv_xml_config_libs=`$xml_config --libs`])
+ ac_xml_config_cflags=$ac_cv_xml_config_cflags
+ ac_xml_config_libs=$ac_cv_xml_config_libs
+ fi
+
+ ac_save_xml_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $ac_xml_config_cflags"
+
+ # first try <libxml/parser.h> which is the new way...
+ #
+ AC_CHECK_X_HEADER(libxml/xmlIO.h, [have_xml=yes],,
+ [#include <libxml/parser.h>])
+
+ # if that didn't work, then try just <parser.h> which is the old way...
+ #
+ if test "$have_xml" = no; then
+ AC_CHECK_X_HEADER(xmlIO.h, [have_xml=yes; have_old_xml=yes],,
+ [#include <parser.h>])
+ fi
+
+ CPPFLAGS="$ac_save_xml_CPPFLAGS"
+ fi
+
+
+ have_zlib=no
+ if test "$have_xml" = yes; then
+ # we have the XML headers; now make sure zlib is around.
+ # yes, it's stupid we have to do this too, but there is
+ # dependency screwage in Gnome.
+ AC_CHECK_X_LIB(z, zlibVersion, [have_zlib=yes])
+ if test "$have_zlib" = no; then
+ xml_halfassed=yes
+ have_xml=no
+ fi
+ fi
+
+ if test "$have_xml" = yes; then
+ # we have the header, now check for the library
+ have_xml=no
+ xml_halfassed=yes
+ AC_CHECK_X_LIB(c, xmlParseChunk,
+ [have_xml=yes
+ xml_halfassed=no
+ XML_LIBS="$ac_xml_config_libs"
+ AC_DEFINE(HAVE_XML)],
+ [true],
+ $ac_xml_config_libs)
+ fi
+
+ if test "$have_xml" = yes; then
+ INCLUDES="$INCLUDES $ac_xml_config_cflags"
+ GTK_LIBS="$GTK_LIBS $ac_xml_config_libs"
+ AC_DEFINE(HAVE_XML)
+ if test "$have_old_xml" = yes; then
+ AC_DEFINE(HAVE_OLD_XML_HEADERS)
+ fi
+ fi
+
+fi
+
+
+###############################################################################
+#
+# Checking whether Motif is really Lesstif.
+#
+###############################################################################
+
+have_lesstif=no
+if test "$have_motif" = yes ; then
+ AC_CACHE_CHECK([whether Motif is really LessTif],
+ ac_cv_have_lesstif,
+ [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
+ [long vers = LesstifVersion;],
+ [ac_cv_have_lesstif=yes],
+ [ac_cv_have_lesstif=no])])
+ 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
+ AC_CACHE_CHECK([LessTif version number],
+ ac_cv_lesstif_version_string,
+ [AC_TRY_X_RUN([#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);
+ }],
+ [ltv=`cat conftest-lt`
+ ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
+ ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`],
+ [ac_cv_lesstif_version=unknown
+ ac_cv_lesstif_version_string=unknown],
+ [ac_cv_lesstif_version=unknown
+ ac_cv_lesstif_version_string=unknown])])
+ 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
+ AC_CACHE_CHECK([Motif version number],
+ ac_cv_motif_version_string,
+ [AC_TRY_X_RUN([#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);
+ }],
+ [mtv=`cat conftest-mt`
+ ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
+ ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`],
+ [ac_cv_motif_version=unknown
+ ac_cv_motif_version_string=unknown],
+ [ac_cv_motif_version=unknown
+ ac_cv_motif_version_string=unknown])])
+ 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
+ AC_MSG_CHECKING(whether Motif requires XPM)
+ if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
+ then
+ motif_requires_xpm=yes
+ AC_MSG_RESULT(maybe)
+ else
+ AC_MSG_RESULT(no)
+ 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_CHECK_X_LIB(Xp, XpQueryExtension,
+ [have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"],
+ [true], -lX11 -lXext -lm)
+fi
+
+
+###############################################################################
+#
+# Checking whether Motif requires -lXintl (for _Xsetlocale.)
+#
+###############################################################################
+
+have_xintl=no
+if test "$have_motif" = yes ; then
+ AC_CHECK_X_LIB(Xintl, _Xsetlocale, [have_xintl=yes], [have_xintl=no],
+ -lX11 -lXext -lm)
+ if test "$have_xintl" = yes; then
+ MOTIF_LIBS="$MOTIF_LIBS -lXintl"
+ fi
+fi
+
+
+###############################################################################
+#
+# Check for -lGL or -lMesaGL.
+#
+###############################################################################
+
+have_gl=no
+ac_have_mesa_gl=no
+with_gl_req=unspecified
+gl_halfassed=no
+AC_ARG_WITH(gl,[
+Graphics options:
+
+ --with-gl Build those demos which depend on OpenGL.],
+ [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
+
+HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
+
+ac_mesagl_version=unknown
+ac_mesagl_version_string=unknown
+
+if test "$with_gl" = yes; then
+ AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
+ if test "$have_gl" = yes ; then
+ AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no,
+ [#include <GL/gl.h>])
+ 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.
+ #
+ AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
+ [ac_cv_have_mesa_gl=no
+ AC_EGREP_X_HEADER(Mesa|MESA, GL/glx.h, [ac_cv_have_mesa_gl=yes])
+ ])
+ ac_have_mesa_gl=$ac_cv_have_mesa_gl
+
+
+ gl_lib_1=""
+ GL_LIBS=""
+
+
+ # 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.)
+ #