2005-03-17 05:05:14 +01:00
|
|
|
dnl Check for LDAP
|
|
|
|
dnl Copyright (C) 2005 Free Software Foundation, Inc.
|
|
|
|
dnl
|
|
|
|
dnl This file is free software, distributed under the terms of the GNU
|
|
|
|
dnl General Public License. As a special exception to the GNU General
|
|
|
|
dnl Public License, this file may be distributed as part of a program
|
|
|
|
dnl that contains a configuration script generated by Autoconf, under
|
|
|
|
dnl the same distribution terms as the rest of that program.
|
|
|
|
dnl
|
2005-03-21 15:32:44 +01:00
|
|
|
dnl Defines @GPGKEYS_LDAP@ to a executable name if a working ldap
|
|
|
|
dnl setup is found, and sets @LDAPLIBS@ to the necessary libraries.
|
2005-03-17 05:05:14 +01:00
|
|
|
|
|
|
|
AC_DEFUN([GNUPG_CHECK_LDAP],
|
|
|
|
[
|
|
|
|
# Try and link a LDAP test program to weed out unusable LDAP
|
|
|
|
# libraries. -lldap [-llber [-lresolv]] is for older OpenLDAPs.
|
|
|
|
# OpenLDAP, circa 1999, was terrible with creating weird dependencies.
|
2005-03-21 15:32:44 +01:00
|
|
|
# If all else fails, the user can play guess-the-dependency by using
|
|
|
|
# something like ./configure LDAPLIBS="-Lfoo -lbar"
|
2010-06-09 18:53:51 +02:00
|
|
|
gnupg_have_ldap=no
|
2005-08-05 18:30:12 +02:00
|
|
|
AC_ARG_WITH(ldap,
|
2020-11-18 05:51:38 +01:00
|
|
|
AS_HELP_STRING([--with-ldap=DIR],[look for the LDAP library in DIR]),
|
2005-08-05 18:30:12 +02:00
|
|
|
[_ldap_with=$withval])
|
|
|
|
|
|
|
|
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}"
|
2005-03-17 05:05:14 +01:00
|
|
|
|
|
|
|
for MY_LDAPLIBS in ${LDAPLIBS+"$LDAPLIBS"} "-lldap" "-lldap -llber" "-lldap -llber -lresolv" "-lwldap32"; do
|
|
|
|
_ldap_save_libs=$LIBS
|
|
|
|
LIBS="$MY_LDAPLIBS $1 $LIBS"
|
|
|
|
|
2020-11-18 05:51:38 +01:00
|
|
|
AC_MSG_CHECKING([whether LDAP via "$MY_LDAPLIBS" is present and sane])
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
2005-03-17 05:05:14 +01:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <winldap.h>
|
|
|
|
#else
|
2022-09-15 04:21:28 +02:00
|
|
|
#define LDAP_DEPRECATED 1
|
2005-03-17 05:05:14 +01:00
|
|
|
#include <ldap.h>
|
|
|
|
#endif
|
2020-11-18 05:51:38 +01:00
|
|
|
]],[[ldap_open("foobar",1234);]])],
|
2005-03-17 05:05:14 +01:00
|
|
|
[gnupg_cv_func_ldap_init=yes],[gnupg_cv_func_ldap_init=no])
|
|
|
|
AC_MSG_RESULT([$gnupg_cv_func_ldap_init])
|
|
|
|
|
|
|
|
if test $gnupg_cv_func_ldap_init = no; then
|
|
|
|
AC_MSG_CHECKING([whether I can make LDAP be sane with lber.h])
|
2020-11-18 05:51:38 +01:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <lber.h>
|
2022-09-15 04:21:28 +02:00
|
|
|
#define LDAP_DEPRECATED 1
|
2020-11-18 05:51:38 +01:00
|
|
|
#include <ldap.h>]],[[ldap_open("foobar",1234);]])],
|
2005-03-17 05:05:14 +01:00
|
|
|
[gnupg_cv_func_ldaplber_init=yes],[gnupg_cv_func_ldaplber_init=no])
|
|
|
|
AC_MSG_RESULT([$gnupg_cv_func_ldaplber_init])
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$gnupg_cv_func_ldaplber_init" = yes ; then
|
|
|
|
AC_DEFINE(NEED_LBER_H,1,[Define if the LDAP library requires including lber.h before ldap.h])
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$gnupg_cv_func_ldap_init" = yes || \
|
|
|
|
test "$gnupg_cv_func_ldaplber_init" = yes ; then
|
2005-08-05 18:30:12 +02:00
|
|
|
LDAPLIBS="$LDAP_LDFLAGS $MY_LDAPLIBS"
|
2006-08-16 12:47:53 +02:00
|
|
|
GPGKEYS_LDAP="gpg2keys_ldap$EXEEXT"
|
2010-06-09 18:53:51 +02:00
|
|
|
gnupg_have_ldap=yes
|
2005-03-17 05:05:14 +01:00
|
|
|
|
2007-12-17 11:49:58 +01:00
|
|
|
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)
|
2005-03-17 05:05:14 +01:00
|
|
|
|
|
|
|
if test "$ac_cv_func_ldap_get_option" != yes ; then
|
|
|
|
AC_MSG_CHECKING([whether LDAP supports ld_errno])
|
2020-11-18 05:51:38 +01:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ldap.h>]],
|
|
|
|
[[LDAP *ldap; ldap->ld_errno;]])],
|
2005-03-17 05:05:14 +01:00
|
|
|
[gnupg_cv_func_ldap_ld_errno=yes],
|
|
|
|
[gnupg_cv_func_ldap_ld_errno=no])
|
|
|
|
AC_MSG_RESULT([$gnupg_cv_func_ldap_ld_errno])
|
|
|
|
|
|
|
|
if test "$gnupg_cv_func_ldap_ld_errno" = yes ; then
|
|
|
|
AC_DEFINE(HAVE_LDAP_LD_ERRNO,1,[Define if the LDAP library supports ld_errno])
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
LIBS=$_ldap_save_libs
|
|
|
|
|
|
|
|
if test "$GPGKEYS_LDAP" != "" ; then break; fi
|
|
|
|
done
|
|
|
|
|
|
|
|
AC_SUBST(GPGKEYS_LDAP)
|
|
|
|
AC_SUBST(LDAPLIBS)
|
2005-08-05 18:30:12 +02:00
|
|
|
AC_SUBST(LDAP_CPPFLAGS)
|
|
|
|
|
|
|
|
CPPFLAGS=$_ldap_save_cppflags
|
|
|
|
LDFLAGS=$_ldap_save_ldflags
|
|
|
|
fi
|
2005-03-17 05:05:14 +01:00
|
|
|
])dnl
|