1 | # $Id: external_lookup.m4,v 1.4 2011/02/09 15:50:28 sbajic Exp $ |
---|
2 | # m4/external_lookup.m4 |
---|
3 | # Hugo Monteiro <hugo.monteiro@javali.pt> |
---|
4 | # |
---|
5 | # DS_EXT_LOOKUP() |
---|
6 | # |
---|
7 | # Activate external user lookup |
---|
8 | # |
---|
9 | AC_DEFUN([DS_EXT_LOOKUP], |
---|
10 | [ |
---|
11 | |
---|
12 | AC_ARG_ENABLE(external-lookup, |
---|
13 | [AS_HELP_STRING(--enable-external-lookup, |
---|
14 | Enable external lookup support |
---|
15 | )]) |
---|
16 | AC_MSG_CHECKING([whether to enable external lookup support]) |
---|
17 | case x"$enable_external_lookup" in |
---|
18 | xyes) # external lookup enabled explicity |
---|
19 | ;; |
---|
20 | xno) # external lookup disabled explicity |
---|
21 | ;; |
---|
22 | x) # external lookup disabled by default |
---|
23 | enable_external_lookup=no |
---|
24 | ;; |
---|
25 | *) AC_MSG_ERROR([unexpected value $enable_external_lookup for --{enable,disable}-external-lookup configure option]) |
---|
26 | ;; |
---|
27 | esac |
---|
28 | if test x"$enable_external_lookup" != xyes |
---|
29 | then |
---|
30 | enable_external_lookup=no |
---|
31 | AC_MSG_RESULT([$enable_external_lookup]) |
---|
32 | else |
---|
33 | enable_external_lookup=yes # overkill, but convenient |
---|
34 | AC_MSG_RESULT([$enable_external_lookup]) |
---|
35 | AC_DEFINE(EXT_LOOKUP, 1, [Defined if external lookup is enabled]) |
---|
36 | |
---|
37 | # Check for LDAP and LDAP version |
---|
38 | AC_CHECK_HEADERS([lber.h ldap.h]) |
---|
39 | if test x"$ac_cv_header_ldap_h" = "xyes" -a x"$ac_cv_header_lber_h" = "xyes" |
---|
40 | then |
---|
41 | AC_CHECK_LIB(lber, ber_alloc,AC_DEFINE([HAVE_LIBLBER], [1], [Define if you have liblber])) |
---|
42 | AC_CHECK_LIB(ldap, ldap_init,AC_DEFINE([HAVE_LIBLDAP], [1], [Define if you have libldap])) |
---|
43 | fi |
---|
44 | if test x"$ac_cv_lib_lber_ber_alloc" = "xyes" -a x"$ac_cv_lib_ldap_ldap_init" = "xyes" |
---|
45 | then |
---|
46 | AC_MSG_CHECKING([for OpenLDAP version >= 2.2.0]) |
---|
47 | AC_COMPILE_IFELSE([ |
---|
48 | AC_LANG_PROGRAM([[ |
---|
49 | #include <lber.h> |
---|
50 | #include <ldap.h> |
---|
51 | ]],[[ |
---|
52 | LDAPAPIInfo info; |
---|
53 | #ifdef LDAP_API_INFO_VERSION |
---|
54 | info.ldapai_info_version = LDAP_API_INFO_VERSION; |
---|
55 | #else |
---|
56 | info.ldapai_info_version = 1; |
---|
57 | #endif |
---|
58 | if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &info) != LDAP_SUCCESS) |
---|
59 | return 1; |
---|
60 | if(info.ldapai_vendor_version != LDAP_VENDOR_VERSION || LDAP_VENDOR_VERSION < 20204) |
---|
61 | return 1; |
---|
62 | return 0; |
---|
63 | ]]) |
---|
64 | ],[ |
---|
65 | AC_MSG_RESULT([yes]) |
---|
66 | have_ldap_version=yes |
---|
67 | ],[ |
---|
68 | AC_MSG_RESULT([no]) |
---|
69 | have_ldap_version=no |
---|
70 | ],[ # cross-compilation |
---|
71 | AC_MSG_ERROR([cross-compilation is unsupported, sorry]) |
---|
72 | have_ldap_version=no |
---|
73 | ]) |
---|
74 | fi |
---|
75 | AC_MSG_CHECKING([whether to enable LDAP support in external lookup]) |
---|
76 | if test x"$have_ldap_version" != "xyes" ; then |
---|
77 | AC_MSG_RESULT([no]) |
---|
78 | else |
---|
79 | AC_MSG_RESULT([yes]) |
---|
80 | external_lookup_libs="-lldap -llber" |
---|
81 | AC_SUBST(external_lookup_libs) |
---|
82 | AC_DEFINE(USE_LDAP, 1, [Defined if LDAP is found]) |
---|
83 | fi |
---|
84 | |
---|
85 | fi |
---|
86 | ]) |
---|