2
dnl Copyright (C) 2005 Free Software Foundation, Inc.
4
dnl This file is free software, distributed under the terms of the GNU
5
dnl General Public License. As a special exception to the GNU General
6
dnl Public License, this file may be distributed as part of a program
7
dnl that contains a configuration script generated by Autoconf, under
8
dnl the same distribution terms as the rest of that program.
10
dnl Defines @GPGKEYS_LDAP@ to a executable name if a working ldap
11
dnl setup is found, and sets @LDAPLIBS@ to the necessary libraries.
13
AC_DEFUN([GNUPG_CHECK_LDAP],
15
# Try and link a LDAP test program to weed out unusable LDAP
16
# libraries. -lldap [-llber [-lresolv]] is for older OpenLDAPs.
17
# OpenLDAP, circa 1999, was terrible with creating weird dependencies.
18
# If all else fails, the user can play guess-the-dependency by using
19
# something like ./configure LDAPLIBS="-Lfoo -lbar"
22
AC_HELP_STRING([--with-ldap=DIR],[look for the LDAP library in DIR]),
24
if test -d "$withval" ; then
25
CPPFLAGS="${CPPFLAGS} -I$withval/include"
26
LDFLAGS="${LDFLAGS} -L$withval/lib"
30
for MY_LDAPLIBS in ${LDAPLIBS+"$LDAPLIBS"} "-lldap" "-lldap -llber" "-lldap -llber -lresolv" "-lwldap32"; do
32
LIBS="$MY_LDAPLIBS $1 $LIBS"
34
AC_MSG_CHECKING([whether LDAP via \"$MY_LDAPLIBS\" is present and sane])
42
],[ldap_open("foobar",1234);],
43
[gnupg_cv_func_ldap_init=yes],[gnupg_cv_func_ldap_init=no])
44
AC_MSG_RESULT([$gnupg_cv_func_ldap_init])
46
if test $gnupg_cv_func_ldap_init = no; then
47
AC_MSG_CHECKING([whether I can make LDAP be sane with lber.h])
48
AC_TRY_LINK([#include <lber.h>
49
#include <ldap.h>],[ldap_open("foobar",1234);],
50
[gnupg_cv_func_ldaplber_init=yes],[gnupg_cv_func_ldaplber_init=no])
51
AC_MSG_RESULT([$gnupg_cv_func_ldaplber_init])
54
if test "$gnupg_cv_func_ldaplber_init" = yes ; then
55
AC_DEFINE(NEED_LBER_H,1,[Define if the LDAP library requires including lber.h before ldap.h])
58
if test "$gnupg_cv_func_ldap_init" = yes || \
59
test "$gnupg_cv_func_ldaplber_init" = yes ; then
61
GPGKEYS_LDAP="gpgkeys_ldap$EXEEXT"
63
AC_CHECK_FUNCS(ldap_get_option ldap_set_option ldap_start_tls_s)
65
if test "$ac_cv_func_ldap_get_option" != yes ; then
66
AC_MSG_CHECKING([whether LDAP supports ld_errno])
67
AC_TRY_LINK([#include <ldap.h>],[LDAP *ldap; ldap->ld_errno;],
68
[gnupg_cv_func_ldap_ld_errno=yes],
69
[gnupg_cv_func_ldap_ld_errno=no])
70
AC_MSG_RESULT([$gnupg_cv_func_ldap_ld_errno])
72
if test "$gnupg_cv_func_ldap_ld_errno" = yes ; then
73
AC_DEFINE(HAVE_LDAP_LD_ERRNO,1,[Define if the LDAP library supports ld_errno])
80
if test "$GPGKEYS_LDAP" != "" ; then break; fi
83
AC_SUBST(GPGKEYS_LDAP)