scd: Use Assuan macro instead of a number constant.
[gnupg.git] / m4 / ldap.m4
index 34c1289..954f88a 100644 (file)
@@ -17,15 +17,22 @@ AC_DEFUN([GNUPG_CHECK_LDAP],
 # OpenLDAP, circa 1999, was terrible with creating weird dependencies.
 # If all else fails, the user can play guess-the-dependency by using
 # something like ./configure LDAPLIBS="-Lfoo -lbar"
+gnupg_have_ldap=no
+AC_ARG_WITH(ldap,
+  AC_HELP_STRING([--with-ldap=DIR],[look for the LDAP library in DIR]),
+  [_ldap_with=$withval])
 
-  AC_ARG_WITH(ldap,
-     AC_HELP_STRING([--with-ldap=DIR],[look for the LDAP library in DIR]),
-     [
-     if test -d "$withval" ; then
-        CPPFLAGS="${CPPFLAGS} -I$withval/include"
-        LDFLAGS="${LDFLAGS} -L$withval/lib"
-     fi
-     ])
+if test x$_ldap_with != xno ; then
+
+  if test -d "$withval" ; then
+     LDAP_CPPFLAGS="-I$withval/include"
+     LDAP_LDFLAGS="-L$withval/lib"
+  fi
+
+  _ldap_save_cppflags=$CPPFLAGS
+  CPPFLAGS="${LDAP_CPPFLAGS} ${CPPFLAGS}"
+  _ldap_save_ldflags=$LDFLAGS
+  LDFLAGS="${LDAP_LDFLAGS} ${LDFLAGS}"
 
   for MY_LDAPLIBS in ${LDAPLIBS+"$LDAPLIBS"} "-lldap" "-lldap -llber" "-lldap -llber -lresolv" "-lwldap32"; do
     _ldap_save_libs=$LIBS
@@ -57,10 +64,14 @@ AC_DEFUN([GNUPG_CHECK_LDAP],
 
     if test "$gnupg_cv_func_ldap_init" = yes || \
         test "$gnupg_cv_func_ldaplber_init" = yes ; then
-       LDAPLIBS=$MY_LDAPLIBS
-       GPGKEYS_LDAP="gpgkeys_ldap$EXEEXT"
+       LDAPLIBS="$LDAP_LDFLAGS $MY_LDAPLIBS"
+       GPGKEYS_LDAP="gpg2keys_ldap$EXEEXT"
+       gnupg_have_ldap=yes
 
-       AC_CHECK_FUNCS(ldap_get_option ldap_set_option ldap_start_tls_s)
+       AC_CHECK_FUNCS(ldap_get_option ldap_set_option)
+       # The extra test for ldap_start_tls_sA is for W32 because 
+       # that is the actual function in the library.
+       AC_CHECK_FUNCS(ldap_start_tls_s ldap_start_tls_sA)
 
        if test "$ac_cv_func_ldap_get_option" != yes ; then
           AC_MSG_CHECKING([whether LDAP supports ld_errno])
@@ -82,4 +93,9 @@ AC_DEFUN([GNUPG_CHECK_LDAP],
 
   AC_SUBST(GPGKEYS_LDAP)
   AC_SUBST(LDAPLIBS)
+  AC_SUBST(LDAP_CPPFLAGS)
+
+  CPPFLAGS=$_ldap_save_cppflags
+  LDFLAGS=$_ldap_save_ldflags
+fi
 ])dnl