]> granicus.if.org Git - apache/blob - build/find_ldap.m4
Introduce ap_(get|set)_core_module_config() functions/macros and use them
[apache] / build / find_ldap.m4
1 dnl -------------------------------------------------------- -*- autoconf -*-
2 dnl Licensed to the Apache Software Foundation (ASF) under one or more
3 dnl contributor license agreements.  See the NOTICE file distributed with
4 dnl this work for additional information regarding copyright ownership.
5 dnl The ASF licenses this file to You under the Apache License, Version 2.0
6 dnl (the "License"); you may not use this file except in compliance with
7 dnl the License.  You may obtain a copy of the License at
8 dnl
9 dnl     http://www.apache.org/licenses/LICENSE-2.0
10 dnl
11 dnl Unless required by applicable law or agreed to in writing, software
12 dnl distributed under the License is distributed on an "AS IS" BASIS,
13 dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 dnl See the License for the specific language governing permissions and
15 dnl limitations under the License.
16
17
18 dnl 
19 dnl Find a particular LDAP library
20 dnl
21 AC_DEFUN([AP_FIND_LDAPLIB], [
22   if test ${ap_has_ldap} != "1"; then
23     ldaplib=$1
24     extralib=$2
25     # Clear the cache entry for subsequent AP_FIND_LDAPLIB invocations.
26     changequote(,)
27     ldaplib_cache_id="`echo $ldaplib | sed -e 's/[^a-zA-Z0-9_]/_/g'`"
28     changequote([,])
29     unset ac_cv_lib_${ldaplib_cache_id}_ldap_init
30     unset ac_cv_lib_${ldaplib_cache_id}___ldap_init
31     AC_CHECK_LIB(${ldaplib}, ldap_init, 
32       [
33         LDADD_ldap="-l${ldaplib} ${extralib}"
34         AC_CHECK_LIB(${ldaplib}, ldapssl_client_init, ap_has_ldapssl_client_init="1", , ${extralib})
35         AC_CHECK_LIB(${ldaplib}, ldapssl_client_deinit, ap_has_ldapssl_client_deinit="1", , ${extralib})
36         AC_CHECK_LIB(${ldaplib}, ldapssl_add_trusted_cert, ap_has_ldapssl_add_trusted_cert="1", , ${extralib})
37         AC_CHECK_LIB(${ldaplib}, ldap_start_tls_s, ap_has_ldap_start_tls_s="1", , ${extralib})
38         AC_CHECK_LIB(${ldaplib}, ldap_sslinit, ap_has_ldap_sslinit="1", , ${extralib})
39         AC_CHECK_LIB(${ldaplib}, ldapssl_init, ap_has_ldapssl_init="1", , ${extralib})
40         AC_CHECK_LIB(${ldaplib}, ldapssl_install_routines, ap_has_ldapssl_install_routines="1", , ${extralib})
41         ap_has_ldap="1";
42         AC_DEFINE(AP_HAS_LDAP, 1, [Defined if httpd is compiled with ldap support])
43       ], , ${extralib})
44   fi
45 ])
46
47
48 dnl
49 dnl AP_FIND_LDAP: figure out where LDAP is located
50 dnl
51 AC_DEFUN([AP_FIND_LDAP],  [
52
53 echo $ac_n "${nl}checking for ldap support..."
54
55 ap_has_ldap="0";
56 ap_has_ldapssl_client_init="0"
57 ap_has_ldapssl_client_deinit="0"
58 ap_has_ldapssl_add_trusted_cert="0"
59 ap_has_ldap_start_tls_s="0"
60 ap_has_ldapssl_init="0"
61 ap_has_ldap_sslinit="0"
62 ap_has_ldapssl_install_routines="0"
63 ap_has_ldap_openldap="0"
64 ap_has_ldap_solaris="0"
65 ap_has_ldap_novell="0"
66 ap_has_ldap_microsoft="0"
67 ap_has_ldap_netscape="0"
68 ap_has_ldap_mozilla="0"
69 ap_has_ldap_tivoli="0"
70 ap_has_ldap_zos="0"
71 ap_has_ldap_other="0"
72 LDADD_ldap=""
73
74 AC_ARG_WITH(lber,[  --with-lber=library     lber library to use],
75   [
76     if test "$withval" = "yes"; then
77       ap_liblber_name="lber"
78     else
79       ap_liblber_name="$withval"
80     fi
81   ],
82   [
83     ap_liblber_name="lber"
84   ])
85
86 AC_ARG_WITH(ldap-include,[  --with-ldap-include=path  path to ldap include files with trailing slash])
87 AC_ARG_WITH(ldap-lib,[  --with-ldap-lib=path    path to ldap lib file])
88 AC_ARG_WITH(ldap,[  --with-ldap=library     ldap library to use],
89   [
90     if test "$with_ldap" != "no"; then
91       save_cppflags="$CPPFLAGS"
92       save_ldflags="$LDFLAGS"
93       save_libs="$LIBS"
94       if test -n "$with_ldap_include"; then
95         CPPFLAGS="$CPPFLAGS -I$with_ldap_include"
96         APR_ADDTO(INCLUDES, [-I$with_ldap_include])
97       fi
98       if test -n "$with_ldap_lib"; then
99         APR_ADDTO(LDFLAGS, [-L$with_ldap_lib])
100       fi
101
102       LIBLDAP="$withval"
103       if test "$LIBLDAP" = "yes"; then
104         dnl The iPlanet C SDK 5.0 is as yet untested... 
105         AP_FIND_LDAPLIB("ldap50", "-lnspr4 -lplc4 -lplds4 -liutil50 -llber50 -lldif50 -lnss3 -lprldap50 -lssl3 -lssldap50")
106         AP_FIND_LDAPLIB("ldapssl41", "-lnspr3 -lplc3 -lplds3")
107         AP_FIND_LDAPLIB("ldapssl40")
108         AP_FIND_LDAPLIB("ldapssl30")
109         AP_FIND_LDAPLIB("ldapssl20")
110         AP_FIND_LDAPLIB("ldapsdk", "-lldapx -lldapssl -lldapgss -lgssapi_krb5")
111         AP_FIND_LDAPLIB("ldapsdk", "-lldapx -lldapssl -lldapgss -lgss -lresolv -lsocket")
112         AP_FIND_LDAPLIB("ldap", "-llber")
113         AP_FIND_LDAPLIB("ldap", "-llber -lresolv")
114         AP_FIND_LDAPLIB("ldap", "-llber -lresolv -lsocket -lnsl")
115         AP_FIND_LDAPLIB("ldap", "-ldl -lpthread")
116       else
117         AP_FIND_LDAPLIB($LIBLDAP)
118         AP_FIND_LDAPLIB($LIBLDAP, "-lresolv")
119         AP_FIND_LDAPLIB($LIBLDAP, "-lresolv -lsocket -lnsl")
120         AP_FIND_LDAPLIB($LIBLDAP, "-ldl -lpthread")
121       fi
122
123       test ${ap_has_ldap} != "1" && AC_MSG_ERROR(could not find an LDAP library)
124       AC_CHECK_LIB($ap_liblber_name, ber_init,
125         [LDADD_ldap="${LDADD_ldap} -l${ap_liblber_name}"])
126
127       AC_CHECK_HEADERS(lber.h, lber_h=["#include <lber.h>"])
128
129       # Solaris has a problem in <ldap.h> which prevents it from
130       # being included by itself.  Check for <ldap.h> manually,
131       # including lber.h first.
132       AC_CACHE_CHECK([for ldap.h], [ap_cv_hdr_ldap_h],
133       [AC_TRY_CPP(
134       [#ifdef HAVE_LBER_H
135       #include <lber.h>
136       #endif
137       #include <ldap.h>
138       ], [ap_cv_hdr_ldap_h=yes], [ap_cv_hdr_ldap_h=no])])
139       if test "$ap_cv_hdr_ldap_h" = "yes"; then
140         ldap_h=["#include <ldap.h>"]
141         AC_DEFINE([HAVE_LDAP_H], 1, [Defined if ldap.h is present])
142       fi
143
144       AC_CHECK_HEADERS(ldap_ssl.h, ldap_ssl_h=["#include <ldap_ssl.h>"])
145
146       if test "$ap_cv_hdr_ldap_h" = "yes"; then
147         AC_CACHE_CHECK([for LDAP toolkit],
148                        [ap_cv_ldap_toolkit], [
149           if test "x$ap_cv_ldap_toolkit" = "x"; then
150             AC_EGREP_CPP([OpenLDAP], [$lber_h
151                          $ldap_h 
152                          LDAP_VENDOR_NAME], [ap_has_ldap_openldap="1"
153                                              ap_cv_ldap_toolkit="OpenLDAP"])
154           fi
155           if test "x$ap_cv_ldap_toolkit" = "x"; then
156             AC_EGREP_CPP([Sun Microsystems Inc.], [$lber_h
157                          $ldap_h
158                          LDAP_VENDOR_NAME], [ap_has_ldap_solaris="1"
159                                              ap_cv_ldap_toolkit="Solaris"])
160           fi
161           if test "x$ap_cv_ldap_toolkit" = "x"; then
162             AC_EGREP_CPP([Novell], [$lber_h
163                          $ldap_h
164                          LDAP_VENDOR_NAME], [ap_has_ldap_novell="1"
165                                              ap_cv_ldap_toolkit="Novell"])
166           fi
167           if test "x$ap_cv_ldap_toolkit" = "x"; then
168             AC_EGREP_CPP([Microsoft Corporation.], [$lber_h
169                          $ldap_h
170                          LDAP_VENDOR_NAME], [ap_has_ldap_microsoft="1"
171                                              ap_cv_ldap_toolkit="Microsoft"])
172           fi
173           if test "x$ap_cv_ldap_toolkit" = "x"; then
174             AC_EGREP_CPP([Netscape Communications Corp.], [$lber_h
175                          $ldap_h
176                          LDAP_VENDOR_NAME], [ap_has_ldap_netscape="1"
177                                              ap_cv_ldap_toolkit="Netscape"])
178           fi
179           if test "x$ap_cv_ldap_toolkit" = "x"; then
180             AC_EGREP_CPP([mozilla.org], [$lber_h
181                          $ldap_h
182                          LDAP_VENDOR_NAME], [ap_has_ldap_mozilla="1"
183                                              ap_cv_ldap_toolkit="Mozilla"])
184           fi
185           if test "x$ap_cv_ldap_toolkit" = "x"; then
186             AC_EGREP_CPP([International Business Machines], [$lber_h
187                          $ldap_h
188                          LDAP_VENDOR_NAME], [ap_has_ldap_tivoli="1"
189                                              ap_cv_ldap_toolkit="Tivoli"])
190           fi
191           if test "x$ap_cv_ldap_toolkit" = "x"; then
192             case "$host" in
193             *-ibm-os390)
194               AC_EGREP_CPP([IBM], [$lber_h
195                                    $ldap_h], [ap_has_ldap_zos="1"
196                                               ap_cv_ldap_toolkit="z/OS"])
197               ;;
198             esac
199           fi
200           if test "x$ap_cv_ldap_toolkit" = "x"; then
201             ap_has_ldap_other="1"
202             ap_cv_ldap_toolkit="unknown"
203           fi
204         ])
205       fi
206
207       CPPFLAGS=$save_cppflags
208       LDFLAGS=$save_ldflags
209       LIBS=$save_libs
210     fi
211   ])
212
213 if test "$ap_has_ldap_openldap" = "1"; then
214     save_cppflags="$CPPFLAGS"
215     save_ldflags="$LDFLAGS"
216     save_libs="$LIBS"
217
218     CPPFLAGS="$CPPFLAGS $INCLUDES"
219     AC_CACHE_CHECK([style of ldap_set_rebind_proc routine], ac_cv_ldap_set_rebind_proc_style,
220     APR_TRY_COMPILE_NO_WARNING([
221     #ifdef HAVE_LBER_H
222     #include <lber.h>
223     #endif
224     #ifdef HAVE_LDAP_H
225     #include <ldap.h>
226     #endif
227     ], [
228     int tmp = ldap_set_rebind_proc((LDAP *)0, (LDAP_REBIND_PROC *)0, (void *)0);
229     /* use tmp to suppress the warning */
230     tmp=0;
231     ], ac_cv_ldap_set_rebind_proc_style=three, ac_cv_ldap_set_rebind_proc_style=two))
232
233     if test "$ac_cv_ldap_set_rebind_proc_style" = "three"; then
234         AC_DEFINE(LDAP_SET_REBIND_PROC_THREE, 1, [Define if ldap_set_rebind_proc takes three arguments])
235     fi
236
237     CPPFLAGS="$save_cppflags"
238     LDFLAGS="$save_ldflags"
239     LIBS="$save_libs"
240 fi
241
242 AC_SUBST(ldap_h)
243 AC_SUBST(lber_h)
244 AC_SUBST(ldap_ssl_h)
245 AC_SUBST(ap_has_ldapssl_client_init)
246 AC_SUBST(ap_has_ldapssl_client_deinit)
247 AC_SUBST(ap_has_ldapssl_add_trusted_cert)
248 AC_SUBST(ap_has_ldap_start_tls_s)
249 AC_SUBST(ap_has_ldapssl_init)
250 AC_SUBST(ap_has_ldap_sslinit)
251 AC_SUBST(ap_has_ldapssl_install_routines)
252 AC_SUBST(ap_has_ldap)
253 AC_SUBST(ap_has_ldap_openldap)
254 AC_SUBST(ap_has_ldap_solaris)
255 AC_SUBST(ap_has_ldap_novell)
256 AC_SUBST(ap_has_ldap_microsoft)
257 AC_SUBST(ap_has_ldap_netscape)
258 AC_SUBST(ap_has_ldap_mozilla)
259 AC_SUBST(ap_has_ldap_tivoli)
260 AC_SUBST(ap_has_ldap_zos)
261 AC_SUBST(ap_has_ldap_other)
262 AC_SUBST(LDADD_ldap)
263 AC_CONFIG_FILES(include/ap_ldap.h)
264 ])