~ubuntu-branches/ubuntu/hardy/gnupg/hardy-updates

« back to all changes in this revision

Viewing changes to m4/ldap.m4

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-12-16 16:57:39 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051216165739-v0m2d1you6hd8jho
Tags: upstream-1.4.2
ImportĀ upstreamĀ versionĀ 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl Check for LDAP
 
2
dnl Copyright (C) 2005 Free Software Foundation, Inc.
 
3
dnl
 
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.
 
9
dnl
 
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.
 
12
 
 
13
AC_DEFUN([GNUPG_CHECK_LDAP],
 
14
[
 
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"
 
20
 
 
21
  AC_ARG_WITH(ldap,
 
22
     AC_HELP_STRING([--with-ldap=DIR],[look for the LDAP library in DIR]),
 
23
     [
 
24
     if test -d "$withval" ; then
 
25
        CPPFLAGS="${CPPFLAGS} -I$withval/include"
 
26
        LDFLAGS="${LDFLAGS} -L$withval/lib"
 
27
     fi
 
28
     ])
 
29
 
 
30
  for MY_LDAPLIBS in ${LDAPLIBS+"$LDAPLIBS"} "-lldap" "-lldap -llber" "-lldap -llber -lresolv" "-lwldap32"; do
 
31
    _ldap_save_libs=$LIBS
 
32
    LIBS="$MY_LDAPLIBS $1 $LIBS"
 
33
 
 
34
    AC_MSG_CHECKING([whether LDAP via \"$MY_LDAPLIBS\" is present and sane])
 
35
    AC_TRY_LINK([
 
36
#ifdef _WIN32
 
37
#include <winsock2.h>
 
38
#include <winldap.h>
 
39
#else
 
40
#include <ldap.h>
 
41
#endif
 
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])
 
45
 
 
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])
 
52
    fi
 
53
 
 
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])
 
56
    fi
 
57
 
 
58
    if test "$gnupg_cv_func_ldap_init" = yes || \
 
59
        test "$gnupg_cv_func_ldaplber_init" = yes ; then
 
60
       LDAPLIBS=$MY_LDAPLIBS
 
61
       GPGKEYS_LDAP="gpgkeys_ldap$EXEEXT"
 
62
 
 
63
       AC_CHECK_FUNCS(ldap_get_option ldap_set_option ldap_start_tls_s)
 
64
 
 
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])
 
71
 
 
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])
 
74
          fi
 
75
       fi
 
76
    fi
 
77
 
 
78
    LIBS=$_ldap_save_libs
 
79
 
 
80
    if test "$GPGKEYS_LDAP" != "" ; then break; fi
 
81
  done
 
82
 
 
83
  AC_SUBST(GPGKEYS_LDAP)
 
84
  AC_SUBST(LDAPLIBS)
 
85
])dnl