]> Pileus Git - ~andy/fetchmail/blobdiff - configure.ac
Update website for 6.3.24.
[~andy/fetchmail] / configure.ac
index a80b787fb9e130881f2db1792c59a661544aa923..c379ccb763d566f01ce4552d49ad5767797847df 100644 (file)
@@ -1,35 +1,90 @@
 dnl Autoconfigure input file for fetchmail
-dnl Eric S. Raymond <esr@thyrsus.com>
-dnl
+#
+# Fetchmail automatic configuration support
+#
+# Eric S. Raymond <esr@thyrsus.com>
+# 2004 - 2012 Matthias Andree <matthias.andree@gmx.de>
+#
 dnl Process this file with autoconf to produce a configure script.
 dnl
 
-AC_INIT([fetchmail],[6.2.7-beta1])
+dnl XXX - if bumping version here, check fetchmail.man, too!
+AC_INIT([fetchmail],[6.3.24],[fetchmail-users@lists.berlios.de])
 AC_CONFIG_SRCDIR([fetchmail.h])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_LIBOBJ_DIR([.])
 
-dnl we may need a newer automake version - the oldest tested is 1.7
-AC_PREREQ(2.59)
-AM_INIT_AUTOMAKE(1.5 foreign no-installinfo)
+AC_CANONICAL_HOST
+
+dnl automake options are in Makefile.am
+AC_PREREQ(2.60)
+dnl 2.60 required for AC_USE_SYSTEM_EXTENSIONS
+AM_INIT_AUTOMAKE([silent-rules -Wall])
+AM_SILENT_RULES
+
+dnl python is optional
+#
+# you can pass PYTHON=: in environment or on the command line
+# to disable python detection and continue without building/installing
+# fetchmail.conf -- be sure to check README.packaging, too!
+#
+AM_PATH_PYTHON(2.0,,AC_MSG_WARN([Disabling fetchmailconf: python 2.0 or greater not found]))
+AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
 
 AC_PROG_AWK
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_PROG_INSTALL
 AC_PROG_CPP                    dnl Later checks need this.
+AC_PROG_RANLIB
 AM_PROG_CC_C_O
-AC_AIX
+AC_USE_SYSTEM_EXTENSIONS
+
 AC_ISC_POSIX
-AC_MINIX
+dnl AC_ISC_POSIX: - XXX FIXME: remove in fetchmail 6.4.
+dnl This macro adds `-lcposix' to output variable `LIBS' if necessary
+dnl for Posix facilities.  Sun dropped support for the obsolete
+dnl INTERACTIVE Systems Corporation Unix on 2006-07-23.  New programs
+dnl need not use this macro.  It is implemented as
+dnl `AC_SEARCH_LIBS([strerror], [cposix])'
+
+dnl check for b0rked Solaris (and other shells) and find one that works
+AC_MSG_CHECKING(for a working shell...)
+for i in /usr/xpg6/bin/sh /usr/xpg4/bin/sh /usr/ccs/bin/sh /bin/sh /usr/bin/sh /bin/ksh /bin/bash /usr/local/bin/bash ; do
+    $i -c 'if ! false ; then echo $(echo ok) ; fi' >config.$$ 2>/dev/null
+    j=`cat config.$$`
+    rm -f config.$$
+    if test "x$j" = "xok" ; then
+        SHELL=$i
+        AC_SUBST(SHELL)
+        break
+    fi
+done
+AC_MSG_RESULT($SHELL)
+if test "x$SHELL" = "x" ; then
+    AC_MSG_ERROR(no SUS compliant shell found - on Solaris, install SUNWxcu4)
+fi
+
+
 AC_HEADER_STDC
 AC_HEADER_TIME
 AC_TYPE_SIZE_T
 AC_TYPE_PID_T
 AC_TYPE_SIGNAL
 AC_CHECK_HEADERS([unistd.h termios.h termio.h sgtty.h stdarg.h \
-       alloca.h sys/itimer.h fcntl.h sys/fcntl.h memory.h sys/wait.h \
-       arpa/inet.h arpa/nameser.h netinet/in.h net/socket.h \
+       sys/itimer.h fcntl.h sys/fcntl.h memory.h sys/wait.h \
+       arpa/inet.h arpa/nameser.h netinet/in.h net/socket.h netdb.h \
        sys/select.h sys/socket.h sys/time.h langinfo.h])
+if test _$ac_cv_header_stdarg_h != _yes ; then
+AC_MSG_WARN([stdarg.h is not defined. Unsupported configuration, proceed at your own risk.])
+fi
+AC_CHECK_TYPE(u_int32_t,,
+       AC_DEFINE(u_int32_t,unsigned int,
+               [Define to unsigned int if <sys/types.h> does not define.]),
+       [AC_INCLUDES_DEFAULT
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif])
 AC_CHECK_HEADERS([resolv.h],,,[
 #include <sys/types.h>
 #ifdef HAVE_NETINET_IN_H
@@ -40,42 +95,51 @@ AC_CHECK_HEADERS([resolv.h],,,[
 #endif
 ])
 
+AC_CHECK_DECLS([h_errno],,,[
+       AC_INCLUDES_DEFAULT
+       #ifdef HAVE_NETDB_H
+       #include <netdb.h>
+       #endif
+])
+
 AC_C_CONST                     dnl getopt needs this.
 
 AM_PROG_LEX
 AC_PROG_MAKE_SET
 AC_PROG_YACC
 
-AC_FUNC_ALLOCA
-
+# Check for OS special cases
+case $host_os in
+darwin*)
+    AC_MSG_NOTICE(found Darwin - Adding -DBIND_8_COMPAT to CFLAGS)
+    CPPFLAGS="$CPPFLAGS -DBIND_8_COMPAT"
+    ;;
+# Check for FreeBSD special case: more libs needed
+freebsd*)
+    AC_MSG_NOTICE(found FreeBSD - Adding -lkvm -lcom_err to standard libraries)
+    LIBS="$LIBS -lkvm -lcom_err"
+    ;;
 # Check for LynxOS special case: -lbsd needed (at least on 2.3.0) and -s
 # not working.
-if test `uname` = "LynxOS" 
-then
-  echo "Adding -lbsd to standard libraries"
-  LIBS="$LIBS -lbsd"
-  LDFLAGS=""
-  echo "Prepending standard include path to gcc flags"
-  CPFLAGS="-I/usr/include"
-fi
-
-# Check for FreeBSD special case: more libs needed
-if test `uname` = "FreeBSD" 
-then
-   echo "Adding -lmd -lkvm -lcom_err to standard libraries"
-   LIBS="$LIBS -lmd -lkvm -lcom_err"
-fi
+lynxos*)
+    AC_MSG_NOTICE(found LynxOS - Adding -lbsd to standard libraries)
+    LIBS="$LIBS -lbsd"
+    LDFLAGS=`echo $LDFLAGS | sed "s/-s //"`
+    AC_MSG_NOTICE(found LynxOS - Prepending standard include path to gcc flags)
+    CPPFLAGS="$CPPFLAGS -I/usr/include"
+    ;;
 # Check for Rhapsody special case: it doesn't like -s
-if test `uname` = "Rhapsody" 
-then
-   echo "Removing -s load flag"
-   LDFLAGS=`echo $LDFLAGS | sed "s/-s //"`
-fi
+rhapsody*)
+    AC_MSG_NOTICE(found Rhapsody - Removing -s load flag)
+    LDFLAGS=`echo $LDFLAGS | sed "s/-s //"`
+    ;;
+esac
+
+AC_CACHE_SAVE
+
 dnl i18n
-AM_GNU_GETTEXT(no-libtool, need-ngettext)
-AM_GNU_GETTEXT_VERSION(0.14.1)
+AM_GNU_GETTEXT([external], [need-ngettext])
+AM_GNU_GETTEXT_VERSION([0.17])
 dnl end i18n
 
 # Under sysV68, socket and friends are provided by the C library.
@@ -98,50 +162,86 @@ AC_CHECK_LIB(cposix, strchr,
                LIBS="$LIBS -lcposix"])
 
 dnl Port hack for Sparc/NetBSD-1.5
-AC_CHECK_LIB(intl, gettext,
-               [LIBS="$LIBS -lintl"])
-
-AC_REPLACE_FUNCS([strstr strcasecmp memmove stpcpy])
+dnl
+dnl NB: this has been disabled as it causes the unconditional
+dnl addition of libintl to the build, which is both undesired
+dnl and breaks on Solaris/Blastwave.org machines.
+dnl
+dnl AC_CHECK_LIB(intl, gettext,
+dnl            [LIBS="$LIBS -lintl"])
 
-AC_CHECK_FUNC(MD5Init, [],
-             [AC_LIBSOURCE(md5c.c)
-               EXTRAOBJ="$EXTRAOBJ md5c.\$(OBJEXT)"])
+AC_REPLACE_FUNCS([strstr strcasecmp memmove stpcpy strlcpy strlcat])
 
 AC_CHECK_FUNC(getopt_long, [],
               [AC_LIBSOURCES([getopt.c, getopt1.c])
               EXTRAOBJ="$EXTRAOBJ getopt.\$(OBJEXT) getopt1.\$(OBJEXT)"])
 
 AC_FUNC_VPRINTF
-if test -n "$ALLOCA"
-then
-  EXTRAOBJ="$EXTRAOBJ alloca.\$(OBJEXT)"
-fi
 
 AC_SUBST(EXTRAOBJ)
 
-AC_CHECK_FUNCS(tcsetattr stty setsid geteuid seteuid gethostbyname \
-  res_search strerror syslog \
-  snprintf vprintf vsnprintf vsyslog \
-  atexit inet_aton strftime setrlimit socketpair sigprocmask sigaction \
-  strdup)
+AC_CHECK_FUNCS(tcsetattr stty setsid geteuid seteuid dnl
+  strerror syslog snprintf vprintf vsnprintf vsyslog dnl
+  atexit inet_aton strftime setrlimit socketpair dnl
+  sigaction strdup setlocale)
+
+AC_CHECK_DECLS([strerror,getenv])
+dnl INET6 is used by KAME/getnameinfo
+AC_CACHE_CHECK(for AF_INET6/PF_INET6,ac_cv_inet6,
+AC_COMPILE_IFELSE([
+  AC_LANG_PROGRAM([[
+    #ifdef HAVE_SYS_TYPES_H
+    #include <sys/types.h>
+    #endif
+    #ifdef HAVE_SYS_SOCKET_H
+    #include <sys/socket.h>
+    #endif
+  ]],[[
+    int foo = AF_INET6;
+    int bar = PF_INET6;
+  ]])],
+  ac_cv_inet6=yes , ac_cv_inet6=no
+))
+if test "x$ac_cv_inet6" = xyes
+then
+    AC_DEFINE(INET6,1,Define to 1 if your system defines AF_INET6 and PF_INET6.)
+fi
 
 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
 # and breaks gethostbyname(2).  It's better to use the bind stuff in the C
 # library.  So don't add -lresolv to the link list unless it's necessary
 # (It will be necessary when using GNU libc6).
-AC_CHECK_FUNC(res_search,
-    AC_MSG_RESULT(using libc's resolver functions),
-    AC_CHECK_LIB(resolv,res_search, 
-       [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
+old_LIBS="$LIBS"
+for lib in '' -lresolv; do
+    if test -z "$lib"; then
+       AC_MSG_CHECKING([for res_search in libc])
+    else
+       AC_MSG_CHECKING([for res_search in $lib])
+    fi
+    LIBS="$old_LIBS $lib"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+extern int res_search();
+]], [[res_search(0, 0, 0, 0, 0); dn_skipname(0,0);]])],
+    [AC_MSG_RESULT([found])
+     AC_DEFINE(HAVE_RES_SEARCH, [1],
+              [Define to 1 if you have the 'res_search' and 'dn_skipname' functions.])
+     break], [AC_MSG_RESULT([not found])])
+     LIBS=$old_LIBS
+done
 
 dnl Check for libcrypt -- it may live in libc or libcrypt, as on IRIX
 AC_CHECK_FUNC(crypt, , AC_CHECK_LIB(crypt,crypt))
 
-dnl Check for RSA refersence library in case we're using SSL
-AC_CHECK_LIB(rsaref, RSAPublicDecrypt)
-
-dnl AC_FUNC_SETVBUF_REVERSED
-
 dnl Check for usable void pointer type
 AC_MSG_CHECKING(use of void pointer type)
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[char *p;
@@ -245,30 +345,30 @@ case "$enable_fallback" in
                                #not reached
                        fi
                        AC_DEFINE_UNQUOTED(FALLBACK_MDA, "$sendmail -i %T", Fallback MTA to use if defined)
-                       echo "Will use $sendmail as fallback MDA."
+                       AC_MSG_NOTICE(Will use $sendmail as fallback MDA.)
                        ;;
        procmail)       if test -z "$procmail" ; then
                                AC_MSG_ERROR([procmail selected as fallback, but not found])
                                #not reached
                        fi
                        AC_DEFINE_UNQUOTED(FALLBACK_MDA, "$procmail -d %T")
-                       echo "Will use $procmail as fallback MDA."
+                       AC_MSG_NOTICE(Will use $procmail as fallback MDA.)
                        ;;
        maildrop)       if test -z "$maildrop" ; then
                                AC_MSG_ERROR([maildrop selected as fallback, but not found])
                                #not reached
                        fi
                        AC_DEFINE_UNQUOTED(FALLBACK_MDA, "$maildrop -d %T")
-                       echo "Will use $maildrop as fallback MDA."
+                       AC_MSG_NOTICE(Will use $maildrop as fallback MDA.)
                        ;;
-       no|unset)       echo "Will not use a fallback MDA"
+       no|unset)       AC_MSG_NOTICE(Will not use a fallback MDA.)
                        ;;
        auto|yes|set)   if test -n "$sendmail" ; then
                                AC_DEFINE_UNQUOTED(FALLBACK_MDA,"$sendmail -i %T")
-                               echo "Will use $sendmail as fallback MDA."
+                               AC_MSG_NOTICE(Will use $sendmail as fallback MDA.)
                        else
-                               echo "No fallback MDA available. procmail and maildrop are not eligible"
-                               echo "for automatic fallback MDA configuration for reliability reasons."
+                               AC_MSG_WARN(No fallback MDA available.  procmail and maildrop are not eligible)
+                               AC_MSG_WARN(for automatic fallback MDA configuration for reliability reasons.)
                        fi
                        ;;
        *)              AC_MSG_ERROR([unkown value for --enable-fallback given: $enable_fallback])
@@ -286,6 +386,7 @@ AC_ARG_ENABLE(POP2,
        [with_POP2=$enableval],
        [with_POP2=no])
 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE,1,Define if you want POP2 support compiled in)
+AM_CONDITIONAL(POP2_ENABLE, test "$with_POP2" = yes)
 
 ###    use option --disable-POP3 to omit the POP3 support
 AC_ARG_ENABLE(POP3,
@@ -293,13 +394,15 @@ AC_ARG_ENABLE(POP3,
        [with_POP3=$enableval],
        [with_POP3=yes])
 test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE,1,Define if you want POP3 support compiled in)
+AM_CONDITIONAL(POP3_ENABLE, test "$with_POP3" = yes)
 
 ###    use option --disable-IMAP to omit the IMAP support
 AC_ARG_ENABLE(IMAP,
        [  --disable-IMAP          don't compile in IMAP protocol support],
        [with_IMAP=$enableval],
        [with_IMAP=yes])
-test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE,1,"Define if you want IMAP support compiled in")
+test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE,1,Define if you want IMAP support compiled in)
+AM_CONDITIONAL(IMAP_ENABLE, test "$with_IMAP" = yes)
 
 ###    use option --disable-ETRN to omit the ETRN support
 AC_ARG_ENABLE(ETRN,
@@ -307,6 +410,7 @@ AC_ARG_ENABLE(ETRN,
        [with_ETRN=$enableval],
        [with_ETRN=yes])
 test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE,1,Define if you want ETRN support compiled in.)
+AM_CONDITIONAL(ETRN_ENABLE, test "$with_ETRN" = yes)
 
 ###    use option --disable-ODMR to omit the ODMR support
 AC_ARG_ENABLE(ODMR,
@@ -314,6 +418,7 @@ AC_ARG_ENABLE(ODMR,
        [with_ODMR=$enableval],
        [with_ODMR=yes])
 test "$with_ODMR" = "yes" && AC_DEFINE(ODMR_ENABLE,1,Define if you want ODMR support compiled in)
+AM_CONDITIONAL(ODMR_ENABLE, test "$with_ODMR" = yes)
 
 ###    use option --enable-RPA to compile in the RPA support
 AC_ARG_ENABLE(RPA,
@@ -321,6 +426,7 @@ AC_ARG_ENABLE(RPA,
        [with_RPA=$enableval],
        [with_RPA=no])
 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE,1,Define if you want RPA support compiled in)
+AM_CONDITIONAL(RPA_ENABLE, test "$with_RPA" = yes)
 
 ###    use option --enable-NTLM to compile in the NTLM support
 AC_ARG_ENABLE(NTLM,
@@ -328,62 +434,98 @@ AC_ARG_ENABLE(NTLM,
        [with_NTLM=$enableval],
        [with_NTLM=no])
 test "$with_NTLM" = "yes" && AC_DEFINE(NTLM_ENABLE,1,Define if you want NTLM authentication)
+AM_CONDITIONAL(NTLM_ENABLE, test "$with_NTLM" = yes)
 
 ###    use option --enable-SDPS to compile in the SDPS support
 AC_ARG_ENABLE(SDPS,
        [  --enable-SDPS           compile in SDPS protocol support],
        [with_SDPS=$enableval],
        [with_SDPS=no])
-test "$with_SDPS" = "yes" && AC_DEFINE(SDPS_ENABLE,1,Define if you want SDPS support compiled in)
+if test "$with_SDPS" = yes ; then
+   if test "$with_POP3" != yes ; then
+       AC_MSG_WARN([SDPS cannot be enabled with POP3 disabled. Disabling SDPS.])
+       with_SDPS=no
+   else
+       AC_DEFINE(SDPS_ENABLE,1,Define if you want SDPS support compiled in)
+   fi
+fi
+if test "$with_POP3" != yes && test "$with_POP2" != yes \
+    && test "$with_IMAP"  != yes ; then
+    AC_MSG_ERROR([You must enable at least one of POP2, POP3 and IMAP.])
+fi
+
+AC_CACHE_SAVE
 
 ###    use option --enable-opie to compile in the OPIE support
 AC_ARG_ENABLE(opie,
        [  --enable-opie           support OTP through the OPIE library],
-       [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
-          AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
+       [ AC_CHECK_HEADER(opie.h,, [AC_MSG_ERROR([cannot find <opie.h>, which is required for OPIE support.])])
+          AC_CHECK_LIB(opie,opiegenerator,, [AC_MSG_ERROR([cannot find libopie, which is required for OPIE support.])])
           with_opie=$enableval],
        [with_opie=no])
 test "$with_opie" = "yes" && AC_DEFINE(OPIE_ENABLE,1,Define if you want OPIE support compiled in)
 
-### XXX FIXME: the inet6-apps library is no longer available,
-### http://www.inner.net/pub/ipv6/ states, as of 2005-07-03:
-### "/pub/ipv6
-### Our IPv6 software is now long defunct. Please find a more modern
-### source."
-AC_ARG_ENABLE(inet6,
-       [  --enable-inet6          support IPv6],
-
-       [ AC_CHECK_FUNC(getaddrinfo, [with_inet6=yes],
-         [ LDFLAGS="$LDFLAGS -L/usr/inet6/lib";
-           AC_CHECK_LIB(inet6, getaddrinfo, [with_inet6=yes
-           LIBS="$LIBS -linet6"],
-           [ echo 'configure: cannot find proper glibc version or libinet6,';
-             echo '           which is required for IPv6 support.';
-             exit 1]) ] )],
-       [with_inet6=no])
-test "$with_inet6" = "yes" && AC_DEFINE(INET6_ENABLE,1,Define if you want IPv6 support compiled in)
-
-AC_CHECK_FUNCS(inner_connect)
-
-AC_ARG_ENABLE(netsec,
-       [  --enable-netsec         support network security (requires inet6-apps library)],
-        [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,,
-         [ unset ac_cv_lib_inet6_net_security_strtorequest;
-            LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; 
-            AC_CHECK_LIB(inet6, net_security_strtorequest,,
-            [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required';
-              echo '           for network security support. Either it does not exist, or it was';
-              echo '           not built with network security support enabled.';
-              exit 1]) ])
-        unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,,
-        [ unset ac_cv_header_net_security_h; 
-       CPPFLAGS="$CPPFLAGS -I/usr/inet6/include"; 
-       CFLAGS="$CFLAGS -I/usr/inet6/include"; AC_CHECK_HEADER(net/security.h,,
-         [ echo 'configure: cannot find <net/security.h>, which is required';
-          echo '             for network security support.';
-          exit 1]) ]) ]
-       [with_netsec=no])
-test "$with_netsec" = "yes" && AC_DEFINE(NET_SECURITY,1,Define if you want network security support compiled in)
+dnl Mostly stolen from gnulib's getaddrinfo.m4
+AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
+AC_CACHE_CHECK([for getaddrinfo],[fm_cv_getaddrinfo],[
+  AC_TRY_LINK([
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+  ], [getaddrinfo(0, 0, 0, 0);],
+    [ fm_cv_getaddrinfo=yes],
+    [ fm_cv_getaddrinfo=no ])
+])
+
+if test x"$fm_cv_getaddrinfo" = "xyes"; then  
+     AC_DEFINE(HAVE_GETADDRINFO, 1,
+      [Define to 1 if you have the getaddrinfo function.])
+fi
+
+AC_CACHE_CHECK([for getnameinfo],[fm_cv_getnameinfo],[
+  AC_TRY_LINK([
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifndef NULL
+#define NULL 0
+#endif
+  ], [getnameinfo(NULL,0, NULL,0, NULL, 0, 0);],
+    [ fm_cv_getnameinfo=yes],
+    [ fm_cv_getnameinfo=no ])
+])
+if test $fm_cv_getnameinfo = yes ; then
+    AC_DEFINE(HAVE_GETNAMEINFO,1,[Define to 1 if your system has getnameinfo()])
+fi
+
+AM_CONDITIONAL(NEED_GETADDRINFO, test "$fm_cv_getaddrinfo" != yes)
+AM_CONDITIONAL(NEED_GETNAMEINFO, test "$fm_cv_getnameinfo"   != yes)
+
+AC_CHECK_FUNCS(inet_ntop)
+dnl Check if getaddrinfo is async-signal-safe - most implementations aren't
+if test "$fm_cv_getaddrinfo" = yes ; then
+    AC_MSG_CHECKING(if your getaddrinfo is async-signal-safe)
+    gai_ts=no
+    dnl we have getaddrinfo() - check if the OS is known to have a async-signal-safe implementation
+    case $host_os in
+       darwin9*)                               gai_ts=yes ;;
+       linux*)                                 gai_ts=yes ;;
+       freebsd5.5|freebsd6*|freebsd7*)         gai_ts=yes ;;
+       solaris2.8|solaris2.9|solaris2.10)      gai_ts=yes ;;
+    esac
+    AC_MSG_RESULT($gai_ts)
+    if test $gai_ts = yes ; then
+       AC_DEFINE(GETADDRINFO_ASYNCSAFE, 1, [define to 1 if you know your getaddrinfo function is async-signal-safe])
+    fi
+fi
 
 # This version of the Kerberos 4 and 5 options addresses the follwing issues:
 # 
@@ -403,8 +545,7 @@ test "$with_netsec" = "yes" && AC_DEFINE(NET_SECURITY,1,Define if you want netwo
 ###    use option --with-kerberos5=DIR to point at a Kerberos 5 directory
 ### make sure --with-ssl is run before --with-kerberos* !
 AC_ARG_WITH(kerberos5,
-       [  --with-kerberos5=DIR    point fetchmail compilation at a Kerberos 5
-directory],
+       [  --with-kerberos5=DIR    point fetchmail compilation at a Kerberos 5 directory],
 [
 if test "$with_kerberos5" != "no"
 then
@@ -414,23 +555,23 @@ then
   AS_MESSAGE(checking kerberosV for OpenBSD...)
   AC_DEFINE(HEIMDAL,1,Define if you have HEIMDAL kerberos 5)
   AC_DEFINE(KERBEROS_V5,1,Define if you have Kerberos V5)
-  CEFLAGS="$CEFLAGS -I/usr/include/kerberosV"
+  CFLAGS="$CFLAGS -I/usr/include/kerberosV"
   LIBS="$LIBS -lasn1 -lkrb5 -lcom_err -lkafs"
 elif krb5-config 2> /dev/null >/dev/null ; then
   krb5_prefix=`krb5-config --prefix krb5`
   AC_MSG_RESULT([krb5-config points to kerberosV under $krb5_prefix])
   if test -f ${krb5_prefix}/include/et/com_err.h && \
    ! test -f ${krb5_prefix}/include/com_err.h  ; then
-    CEFLAGS="$CEFLAGS -I${krb5_prefix}/include/et"
+    CFLAGS="$CFLAGS -I${krb5_prefix}/include/et"
   fi
   unset krb5_prefix
-  CEFLAGS="$CEFLAGS `krb5-config --cflags krb5`"
+  CFLAGS="$CFLAGS `krb5-config --cflags krb5`"
   LIBS="$LIBS `krb5-config --libs krb5`"
   AC_DEFINE(KERBEROS_V5)
 else
   if test "$with_kerberos5" != "yes" 
   then
-      LDEFLAGS="$LDEFLAGS -L${with_kerberos5}/lib"
+      LDFLAGS="$LDFLAGS -L${with_kerberos5}/lib"
       searchdirs="$with_kerberos5"
   else
       searchdirs="/usr/kerberos /usr/local/krb5 /usr/athena /usr"
@@ -438,22 +579,23 @@ else
   with_kerberos5=
   for dir in $searchdirs
   do AC_MSG_CHECKING([for Kerberos V in $dir])
-     if test -f "$dir/include/krb5.h"
+     if test -f "$dir/include/krb5.h" || test -f "$dir/include/krb5/krb5.h"
      then
+       if test -d "$dir/include/krb5" ; then CPPFLAGS="$CPPFLAGS -I$dir/include/krb5" ; fi
         ac_krblibs=
-        if test -f "$dir/include/roken.h"
+        if test -f "$dir/include/roken.h" || test -f "$dir/include/krb5/roken.h"
         then
            ac_krblibs="-lasn1 -lroken -lcom_err"
            AC_MSG_RESULT([Heimdal found])
           dnl Attempt to detect if we need to -ldb2 to link Heimdal
           dnl we assume we do if it is available
            AC_CHECK_LIB(db2, db_open, ac_krblibs="$ac_krblibs -ldb2", [],
-                ${LDEFLAGS})
+                ${LDFLAGS})
            AC_CHECK_LIB(des, des_string_to_key, libk5crypto=-ldes,
-              AC_CHECK_LIB(ssl, MD5_Init, [],
+              AC_CHECK_LIB(crypto, MD5_Init, [],
                 AC_MSG_ERROR([DES libraries not found. Try adding --with-ssl to enable OpenSSL support]),
-                ${LDEFLAGS} ${ac_krblibs}),
-           ${LDEFLAGS} ${ac_krblibs})
+                ${LDFLAGS} ${ac_krblibs}),
+           ${LDFLAGS} ${ac_krblibs})
            AC_DEFINE(HEIMDAL)
         else
           AC_MSG_RESULT([found])
@@ -465,15 +607,15 @@ else
                    krb5_des_string_to_key,
                    libk5crypto=-lk5crypto,
                       AC_MSG_ERROR([Kerberos 5 DES libraries not found]),
-                   ${LDEFLAGS} ${ac_krblibs}),
-                 ${LDEFLAGS} ${ac_krblibs})
+                   ${LDFLAGS} ${ac_krblibs}),
+                 ${LDFLAGS} ${ac_krblibs})
         fi
         AC_CHECK_LIB(krb5, krb5_init_context,[],
            continue,
-           ${LDEFLAGS} ${ac_krblibs})
+           ${LDFLAGS} ${ac_krblibs})
         AC_DEFINE(KERBEROS_V5)
-        test "$dir" != "/usr" && CEFLAGS="$CEFLAGS -I$dir/include"
-        LDEFLAGS="$LDEFLAGS -L$dir/lib"
+        test "$dir" != "/usr" && CFLAGS="$CFLAGS -I$dir/include"
+        LDFLAGS="$LDFLAGS -L$dir/lib"
        LIBS="$LIBS $ac_krblibs $libk5crypto"
         with_kerberos5=$dir
         break
@@ -489,26 +631,30 @@ fi
 ]) dnl --with-kerberos5=DIR
 
 ###    use option --with-kerberos=DIR to point at a Kerberos 4 directory
+KERBEROS_V4=0
 AC_ARG_WITH(kerberos,
-       [  --with-kerberos=DIR     point fetchmail compilation at a Kerberos 4
-directory],
+       [  --with-kerberos=DIR     point fetchmail compilation at a Kerberos 4 directory],
 [
 if test "$with_kerberos" != "no"
 then
+    AC_MSG_WARN([Kerberos IV support is obsolete. Use --with-kerberos5 if possible.])
 # Check for a NetBSD/OpenBSD special case
 if test "$with_kerberos" = "yes" && ( test `uname` = "NetBSD" || test `uname` = "OpenBSD" )
 then
   AS_MESSAGE(checking kerberosIV for `uname`...)
-  AC_DEFINE(KERBEROS_V4,1,Define if you have Kerberos V4)
-  CEFLAGS="$CEFLAGS -I/usr/include/kerberosIV"
-  LIBS="$LIBS -lkrb -ldes"
+  KERBEROS_V4=1
+  CFLAGS="$CFLAGS -I/usr/include/kerberosIV"
+  case `uname` in
+      NetBSD)  LIBS="$LIBS -lkrb -ldes -lroken -lcom_err" ;;
+      OpenBSD) LIBS="$LIBS -lkrb -ldes" ;;
+  esac
 elif krb4-config 2> /dev/null >/dev/null ; then
   krb4_prefix=`krb4-config --prefix`
   AC_MSG_RESULT([krb4-config points to kerberosIV under $krb4_prefix])
   unset krb4_prefix
-  CEFLAGS="$CEFLAGS `krb4-config --cflags`"
+  CFLAGS="$CFLAGS `krb4-config --cflags`"
   LIBS="$LIBS `krb4-config --libs`"
-  AC_DEFINE(KERBEROS_V4)
+  KERBEROS_V4=1
 elif krb5-config 2> /dev/null >/dev/null ; then
   krb4_prefix=`krb5-config --prefix krb4`
   AC_MSG_RESULT([krb5-config points to kerberosIV under $krb4_prefix])
@@ -516,16 +662,16 @@ elif krb5-config 2> /dev/null >/dev/null ; then
     AC_DEFINE(KERBEROS_V4_V5,1,Define if you have Kerberos V4 headers under a kerberosIV directory)
   fi
   unset krb4_prefix
-  CEFLAGS="$CEFLAGS `krb5-config --cflags krb4`"
+  CFLAGS="$CFLAGS `krb5-config --cflags krb4`"
   LIBS="$LIBS `krb5-config --libs krb4`"
-  AC_DEFINE(KERBEROS_V4)
+  KERBEROS_V4=1
 else
   #we need to detect when we're building under a kerberosV compatibility
   #layer, btw...
   if test "$with_kerberos" != "yes" ; then
      searchdirs="$with_kerberos"
   else
-     searchdirs="$with_kerberos5 /usr/kerberos /usr/kerberosIV /usr/athena/usr"
+     searchdirs="$with_kerberos5 /usr/kerberos /usr/kerberosIV /usr/athena /usr"
   fi
   with_kerberos=
   ac_saveLDFLAGS="$LDFLAGS"
@@ -545,7 +691,11 @@ else
        AC_CHECK_LIB(45, krb_mk_req)
      fi
      LDFLAGS="-L$dir/lib $ac_saveLDFLAGS"
-     AC_SEARCH_LIBS(des_string_to_key, [des425 des crypto], [], continue)
+     if test `uname` = "FreeBSD"; then
+        AC_SEARCH_LIBS(_ossl_old_des_string_to_key, [des425 des crypto], [], continue)
+     else
+        AC_SEARCH_LIBS(des_string_to_key, [crypto], [], continue)
+     fi
      AC_SEARCH_LIBS(krb_realmofhost, [krb4 krb], [], continue)
      with_kerberos="$dir"
      if test -f "$dir/include/kerberosIV/krb.h" ; then
@@ -553,10 +703,10 @@ else
      else
        dir="$dir/include"
      fi
-     AC_DEFINE(KERBEROS_V4)
+     KERBEROS_V4=1
      test -f "$with_kerberos5/roken.h" && AC_DEFINE(HEIMDAL)
-     test "$dir" != "/usr/include" && CEFLAGS="$CEFLAGS -I$dir"
-     LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
+     test "$dir" != "/usr/include" && CFLAGS="$CFLAGS -I$dir"
+     LDFLAGS="$LDFLAGS -L$with_kerberos/lib"
      break
   done
   if test -z "$with_kerberos" ; then
@@ -566,6 +716,10 @@ else
 fi
 fi
 ]) dnl --with-kerberos=DIR
+if test "$KERBEROS_V4" = 1 ; then
+    AC_DEFINE(KERBEROS_V4,1,Define if you have Kerberos V4)
+fi
+AM_CONDITIONAL(KERBEROS_V4_ENABLE, test "$KERBEROS_V4" = 1)
 
 ###    use option --with-ssl to compile in the SSL support
 AC_ARG_WITH(ssl,
@@ -576,7 +730,7 @@ test "$with_ssl" != "no" && AC_DEFINE(SSL_ENABLE,1,Define if you want SSL suppor
 
 if test "$with_ssl" = "yes"
 then
-    #  He didn't specify an SSL location.  Let's look at some common
+    #  User didn't specify an SSL location.  Let's look at some common
     #  directories where SSL has been found in the past and try and auto
     #  configure for SSL.  OpenSSL determination will be made later.
     #  This will screw up if an OpenSSL install is located in a later
@@ -614,22 +768,44 @@ then
   if test -r $with_ssl/include/openssl/ssl.h
   then
     ###        ssl.h found under openssl.  Use openssl configuration preferentially,
-    echo "Enabling OpenSSL support in $with_ssl"
-    test "$with_ssl" != "/usr" && CEFLAGS="$CEFLAGS -I$with_ssl/include"
+    AC_MSG_NOTICE(Enabling OpenSSL support in $with_ssl.)
+    test "$with_ssl" != "/usr" && CFLAGS="$CFLAGS -I$with_ssl/include"
     ### In Red Hat 9, this file includes a reference to <krb5.h>, so we
     ### force the Kerberos direcory onto the include path so it will build.
-    CEFLAGS="$CEFLAGS -I/usr/kerberos/include"
+    CFLAGS="$CFLAGS -I/usr/kerberos/include"
     ###        OpenBSD comes with ssl headers
   else
     AC_MSG_ERROR([SSL support enabled, but OpenSSL not found])
   fi
-  LDEFLAGS="$LDEFLAGS -L$with_ssl/lib"
+  LDFLAGS="$LDFLAGS -L$with_ssl/lib"
   LIBS="$LIBS -lssl -lcrypto"
+  dnl check if -ldl is needed
+  AC_MSG_CHECKING([for additional library dependencies of SSL])
+  found=0
+  save_LIBS="$LIBS"
+  for i in "" "-ldl" ; do
+      LIBS="$LDFLAGS $save_LIBS $i"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>],[SSL_library_init()])],[found=1; break])
+  done
+  if test $found = 0 ; then
+      AC_MSG_RESULT([error])
+      AC_MSG_ERROR([cannot link with SSL - check config.log])
+  fi
+  LIBS="$save_LIBS $i"
+  if test "$i" = "" ; then i="(none)" ; fi
+  AC_MSG_RESULT($i)
+  dnl XXX FIXME: use pkg-config if available!
   AC_DEFINE(SSL_ENABLE)
 else
-  echo 'Disabling SSL support...'
+  AC_MSG_WARN(Disabling SSL support.)
+  AC_MSG_WARN(Consider re-running configure --with-ssl.)
 fi
 
+case "$LIBS" in *-lssl*)
+       AC_CHECK_DECLS([SSLv2_client_method],,,[#include <openssl/ssl.h>])
+       ;;
+esac
+
 ###    use option --with-socks=DIR to point at SOCKS library
 AC_ARG_WITH(socks,
        [  --with-socks[=DIR]      add built-in SOCKS firewall access],
@@ -638,13 +814,13 @@ if test "$with_socks" != no
 then
     if test "$with_socks" != yes
     then
-        LDEFLAGS="$LDEFLAGS -L$with_socks"
+        LDFLAGS="$LDFLAGS -L$with_socks"
     else
         AC_CHECK_LIB(socks, Rconnect,,
                AC_MSG_ERROR([could not find libsocks which is needed for built-in SOCKS support]))
     fi
     AC_DEFINE(HAVE_SOCKS,1,Define if you want built-in SOCKS support)
-    CEFLAGS="$CEFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
+    CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
     LIBS="-lsocks $LIBS"
 fi])
 
@@ -656,18 +832,21 @@ if test "$with_socks5" != no
 then
   if test "$with_socks5" != yes
   then
-    LDEFLAGS="$LDEFLAGS -L$with_socks5"
+    LDFLAGS="$LDFLAGS -L$with_socks5"
   fi
   ac_savedLDFLAGS="$LDFLAGS"
-  LDFLAGS="$LDEFLAGS $LDFLAGS"
+  LDFLAGS="$LDFLAGS $LDFLAGS"
   AC_CHECK_LIB(socks5, SOCKSconnect,,
        AC_MSG_ERROR([could not find libsocks5 which is needed for built-in SOCKS5 support]))
   AC_DEFINE(HAVE_SOCKS)
-  CEFLAGS="$CEFLAGS -Dconnect=SOCKSconnect -Dgetsockname=SOCKSgetsockname -Dbind=SOCKSbind -Daccept=SOCKSaccept -Dlisten=SOCKSlisten -Dselect=SOCKSselect -Drecvfrom=SOCKSrecvfrom -Dsendto=SOCKSsendto -Drecv=SOCKSrecv -Dsend=SOCKSsend -Dread=SOCKSread -Dwrite=SOCKSwrite -Drresvport=SOCKSrresvport -Dshutdown=SOCKSshutdown -Dlisten=SOCKSlisten -Dclose=SOCKSclose -Ddup=SOCKSdup -Ddup2=SOCKSdup2 -Dgethostbyname=SOCKSgethostbyname"
+  CFLAGS="$CFLAGS -Dconnect=SOCKSconnect -Dgetsockname=SOCKSgetsockname -Dbind=SOCKSbind -Daccept=SOCKSaccept -Dlisten=SOCKSlisten -Dselect=SOCKSselect -Drecvfrom=SOCKSrecvfrom -Dsendto=SOCKSsendto -Drecv=SOCKSrecv -Dsend=SOCKSsend -Dread=SOCKSread -Dwrite=SOCKSwrite -Drresvport=SOCKSrresvport -Dshutdown=SOCKSshutdown -Dlisten=SOCKSlisten -Dclose=SOCKSclose -Ddup=SOCKSdup -Ddup2=SOCKSdup2 -Dgethostbyname=SOCKSgethostbyname"
   AC_CHECK_FUNC(SOCKSfclose, [CFLAGS="$CFLAGS -Dfclose=SOCKSfclose"])
   LDFLAGS="$ac_savedLDFLAGS"
 fi])
 
+dnl for libesmtp/ modules:
+ACX_WHICH_GETHOSTBYNAME_R
+
 ###    use option --with-hesiod=DIR to point at a HESIOD directory
 AC_ma_SEARCH_PACKAGE(hesiod, hesiod_getmailhost, /usr/athena /usr /usr/local,hesiod, hesiod.h)
 
@@ -681,41 +860,62 @@ then
   then
     with_gssapi=$with_kerberos5
   fi
+
   if test "$with_gssapi" != "yes" -a -n "$with_gssapi"
   then
     CFLAGS="$CFLAGS -I$with_gssapi/include"
     LDFLAGS="$LDFLAGS -L$with_gssapi/lib"
   fi
 
-  AC_CHECK_LIB(gss, gss_check_version, LIBS="$LIBS -lgss", nogss=t)
-  if test -n "$nogss"
-  then
-  if test -f "$with_gssapi/include/roken.h"
-  then
-     LIBS="$LIBS -lkrb5 -lasn1 -ldes -lroken -ldb -ldl"
-     AC_CHECK_LIB(gssapi, gss_init_sec_context,LIBS="$LIBS -lgssapi",
-                  AC_MSG_ERROR([could not find libgssapi which is needed for GSSAPI support]), )
-     AC_DEFINE(HEIMDAL)
+  dnl obtain gssapi default libs
+  if krb5-config --libs gssapi 2>/dev/null >/dev/null ; then
+      LIBS="$LIBS `krb5-config --libs gssapi`"
   else
-     AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,LIBS="$LIBS -lgssapi_krb5",
-                  AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
-  fi
+    AC_CHECK_LIB(gss, gss_check_version, LIBS="$LIBS -lgss", nogss=t)
+    if test -n "$nogss"
+    then
+      # -lgss not found
+      if test "$with_gssapi" = yes ; then
+         with_gssapi=/usr
+      fi
+      if test -f "$with_gssapi/include/roken.h" -o -f "$with_gssapi/include/krb5/roken.h"
+      then
+         # have roken.h, assume Heimdal
+        case `uname` in
+            NetBSD) LIBS="$LIBS -lkrb5" ;;
+            *)      LIBS="$LIBS -lkrb5 -lasn1 -ldes -lroken -ldb -ldl" ;;
+        esac
+         AC_CHECK_LIB(gssapi, gss_init_sec_context,LIBS="$LIBS -lgssapi",
+                      AC_MSG_ERROR([could not find libgssapi which is needed for GSSAPI support]), )
+         AC_DEFINE(HEIMDAL)
+      else
+         # no roken.h, assume MIT
+         AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,LIBS="$LIBS -lgssapi_krb5",
+                      AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
+      fi
+    fi
   fi
   AC_DEFINE(GSSAPI,1,Define if you want GSSAPI authentication)
-  save_CPPFLAGS=$CPPFLAGS
-  CPPFLAGS="-I$with_gssapi/include"
-  AC_CHECK_HEADERS(gss.h gssapi.h gssapi/gssapi.h gssapi/gssapi_generic.h)
-  if test "$ac_cv_header_gssapi_h" = "yes"; then
-    AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi.h, AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE,1,Define if you have MIT kerberos))
-  else
-    AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi/gssapi.h, AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE))
+  if test "$with_gssapi" != yes ; then
+    CPPFLAGS="$CPPFLAGS -I$with_gssapi/include"
   fi
+  AC_CHECK_HEADERS(gss.h gssapi.h gssapi/gssapi.h gssapi/gssapi_generic.h)
+  AC_CHECK_DECLS(GSS_C_NT_HOSTBASED_SERVICE,,,[
+    AC_INCLUDES_DEFAULT
+    #if HAVE_GSS_H
+    #include <gss.h>
+    #endif
+    #if HAVE_GSSAPI_GSSAPI_H
+    #include <gssapi/gssapi.h>
+    #elif HAVE_GSSAPI_H
+    #include <gssapi.h>
+    #endif
+    #if HAVE_GSSAPI_GSSAPI_GENERIC_H
+    #include <gssapi/gssapi_generic.h>
+    #endif
+    ])
 fi])
 
-AC_SUBST(CPFLAGS)
-AC_SUBST(CEFLAGS)
-AC_SUBST(LDEFLAGS)
-
 dnl ,------------------------------------------------------------------
 dnl Check if we need TRIO
 needtrio=0
@@ -768,8 +968,7 @@ if test "$needtrio" = 1 ; then
 fi
 dnl ----------------------------------------------------------------'
 
-AC_CONFIG_FILES([Makefile m4/Makefile m4-local/Makefile
-                po/Makefile.in intl/Makefile])
+AC_CONFIG_FILES([Makefile po/Makefile.in])
 AC_OUTPUT
 
 dnl Local Variables: