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
9 dnl http://www.apache.org/licenses/LICENSE-2.0
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.
19 dnl Find a particular LDAP library
21 AC_DEFUN([AP_FIND_LDAPLIB], [
22 if test ${ap_has_ldap} != "1"; then
25 # Clear the cache entry for subsequent AP_FIND_LDAPLIB invocations.
27 ldaplib_cache_id="`echo $ldaplib | sed -e 's/[^a-zA-Z0-9_]/_/g'`"
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,
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})
42 AC_DEFINE(AP_HAS_LDAP, 1, [Defined if httpd is compiled with ldap support])
49 dnl AP_FIND_LDAP: figure out where LDAP is located
51 AC_DEFUN([AP_FIND_LDAP], [
53 echo $ac_n "${nl}checking for ldap support..."
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"
74 AC_ARG_WITH(lber,[ --with-lber=library lber library to use],
76 if test "$withval" = "yes"; then
77 ap_liblber_name="lber"
79 ap_liblber_name="$withval"
83 ap_liblber_name="lber"
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],
90 if test "$with_ldap" != "no"; then
91 save_cppflags="$CPPFLAGS"
92 save_ldflags="$LDFLAGS"
94 if test -n "$with_ldap_include"; then
95 CPPFLAGS="$CPPFLAGS -I$with_ldap_include"
96 APR_ADDTO(INCLUDES, [-I$with_ldap_include])
98 if test -n "$with_ldap_lib"; then
99 APR_ADDTO(LDFLAGS, [-L$with_ldap_lib])
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")
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")
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}"])
127 AC_CHECK_HEADERS(lber.h, lber_h=["#include <lber.h>"])
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],
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])
144 AC_CHECK_HEADERS(ldap_ssl.h, ldap_ssl_h=["#include <ldap_ssl.h>"])
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
152 LDAP_VENDOR_NAME], [ap_has_ldap_openldap="1"
153 ap_cv_ldap_toolkit="OpenLDAP"])
155 if test "x$ap_cv_ldap_toolkit" = "x"; then
156 AC_EGREP_CPP([Sun Microsystems Inc.], [$lber_h
158 LDAP_VENDOR_NAME], [ap_has_ldap_solaris="1"
159 ap_cv_ldap_toolkit="Solaris"])
161 if test "x$ap_cv_ldap_toolkit" = "x"; then
162 AC_EGREP_CPP([Novell], [$lber_h
164 LDAP_VENDOR_NAME], [ap_has_ldap_novell="1"
165 ap_cv_ldap_toolkit="Novell"])
167 if test "x$ap_cv_ldap_toolkit" = "x"; then
168 AC_EGREP_CPP([Microsoft Corporation.], [$lber_h
170 LDAP_VENDOR_NAME], [ap_has_ldap_microsoft="1"
171 ap_cv_ldap_toolkit="Microsoft"])
173 if test "x$ap_cv_ldap_toolkit" = "x"; then
174 AC_EGREP_CPP([Netscape Communications Corp.], [$lber_h
176 LDAP_VENDOR_NAME], [ap_has_ldap_netscape="1"
177 ap_cv_ldap_toolkit="Netscape"])
179 if test "x$ap_cv_ldap_toolkit" = "x"; then
180 AC_EGREP_CPP([mozilla.org], [$lber_h
182 LDAP_VENDOR_NAME], [ap_has_ldap_mozilla="1"
183 ap_cv_ldap_toolkit="Mozilla"])
185 if test "x$ap_cv_ldap_toolkit" = "x"; then
186 AC_EGREP_CPP([International Business Machines], [$lber_h
188 LDAP_VENDOR_NAME], [ap_has_ldap_tivoli="1"
189 ap_cv_ldap_toolkit="Tivoli"])
191 if test "x$ap_cv_ldap_toolkit" = "x"; then
194 AC_EGREP_CPP([IBM], [$lber_h
195 $ldap_h], [ap_has_ldap_zos="1"
196 ap_cv_ldap_toolkit="z/OS"])
200 if test "x$ap_cv_ldap_toolkit" = "x"; then
201 ap_has_ldap_other="1"
202 ap_cv_ldap_toolkit="unknown"
207 CPPFLAGS=$save_cppflags
208 LDFLAGS=$save_ldflags
213 if test "$ap_has_ldap_openldap" = "1"; then
214 save_cppflags="$CPPFLAGS"
215 save_ldflags="$LDFLAGS"
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([
228 int tmp = ldap_set_rebind_proc((LDAP *)0, (LDAP_REBIND_PROC *)0, (void *)0);
229 /* use tmp to suppress the warning */
231 ], ac_cv_ldap_set_rebind_proc_style=three, ac_cv_ldap_set_rebind_proc_style=two))
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])
237 CPPFLAGS="$save_cppflags"
238 LDFLAGS="$save_ldflags"
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)
263 AC_CONFIG_FILES(include/ap_ldap.h)