2 dnl custom autoconf rules for APRUTIL
6 dnl APU_FIND_APR: figure out where APR is located
8 AC_DEFUN(APU_FIND_APR,[
10 dnl use the find_apr.m4 script to locate APR. sets apr_found and apr_config
12 if test "$apr_found" = "no"; then
13 AC_MSG_ERROR(APR could not be located. Please use the --with-apr option.)
16 APR_BUILD_DIR="`$apr_config --installbuilddir`"
18 dnl make APR_BUILD_DIR an absolute directory (we'll need it in the
19 dnl sub-projects in some cases)
20 APR_BUILD_DIR="`cd $APR_BUILD_DIR && pwd`"
22 APR_INCLUDES="`$apr_config --includes`"
23 APR_LIBS="`$apr_config --link-libtool --libs`"
24 APR_SO_EXT="`$apr_config --apr-so-ext`"
25 APR_LIB_TARGET="`$apr_config --apr-lib-target`"
27 AC_SUBST(APR_INCLUDES)
29 AC_SUBST(APR_BUILD_DIR)
34 dnl APU_TEST_EXPAT(directory): test if Expat is located in the specified dir
36 dnl if present: sets expat_include_dir, expat_libs, possibly expat_old
38 AC_DEFUN(APU_TEST_EXPAT,[
39 AC_MSG_CHECKING(for Expat in ifelse($2,,$1,$2))
43 if test -r "$1/lib/expat.h"; then
44 dnl Expat 1.95.* distribution
45 expat_include_dir="$1/lib"
48 expat_libtool="$1/libexpat.la"
49 elif test -r "$1/include/expat.h" -a \
50 -r "$1/lib/libexpat.la"; then
51 dnl Expat 1.95.* installation (with libtool)
52 expat_include_dir="$1/include"
53 expat_ldflags="-L$1/lib"
55 expat_libtool="$1/lib/libexpat.la"
56 elif test -r "$1/include/expat.h" -a \
57 -r "$1/lib64/libexpat.la"; then
58 dnl Expat 1.95.* installation on certain 64-bit platforms (with libtool)
59 expat_include_dir="$1/include"
60 expat_ldflags="-L$1/lib64"
62 expat_libtool="$1/lib64/libexpat.la"
63 elif test -r "$1/include/expat.h" -a \
64 -r "$1/lib/libexpat.a"; then
65 dnl Expat 1.95.* installation (without libtool)
66 dnl FreeBSD textproc/expat2
67 expat_include_dir="$1/include"
68 expat_ldflags="-L$1/lib"
70 elif test -r "$1/xmlparse.h"; then
71 dnl maybe an expat-lite. use this dir for both includes and libs
72 expat_include_dir="$1"
75 expat_libtool="$1/libexpat.la"
77 elif test -r "$1/include/xmlparse.h" -a \
78 -r "$1/lib/libexpat.a"; then
79 dnl previously installed expat
80 expat_include_dir="$1/include"
81 expat_ldflags="-L$1/lib"
84 elif test -r "$1/include/xml/xmlparse.h" -a \
85 -r "$1/lib/xml/libexpat.a"; then
86 dnl previously installed expat
87 expat_include_dir="$1/include/xml"
88 expat_ldflags="-L$1/lib"
91 elif test -r "$1/include/xmltok/xmlparse.h"; then
92 dnl Debian distribution
93 expat_include_dir="$1/include/xmltok"
94 expat_ldflags="-L$1/lib"
95 expat_libs="-lxmlparse -lxmltok"
97 elif test -r "$1/include/xml/xmlparse.h" -a \
98 -r "$1/lib/libexpat.a"; then
99 dnl FreeBSD textproc/expat package
100 expat_include_dir="$1/include/xml"
101 expat_ldflags="-L$1/lib"
104 elif test -r "$1/xmlparse/xmlparse.h"; then
105 dnl Expat 1.0 or 1.1 source directory
106 expat_include_dir="$1/xmlparse"
111 dnl ### test for installed Expat 1.95.* distros
113 if test -n "$expat_include_dir"; then
114 dnl ### more info about what we found there? version? using .la?
123 dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled)
125 AC_DEFUN(APU_FIND_EXPAT,[
128 [ --with-expat=DIR specify Expat location or 'builtin'], [
129 if test "$withval" = "yes"; then
130 AC_MSG_ERROR([a directory must be specified for --with-expat])
131 elif test "$withval" = "no"; then
132 AC_MSG_ERROR([Expat cannot be disabled (at this time)])
133 elif test "$withval" = "builtin"; then
134 abs_expatdir="`cd $srcdir/xml/expat && pwd`"
135 if test -d $abs_expatdir/. -a ! -d xml/expat/.; then
138 APU_TEST_EXPAT($abs_expatdir, xml/expat)
140 abs_expatdir="`cd $withval && pwd`"
141 APU_TEST_EXPAT($abs_expatdir, $withval)
142 if test -z "$expat_include_dir"; then
143 AC_MSG_ERROR([Expat was not found (or recognized) in \"$withval\"])
148 if test -z "$expat_include_dir"; then
149 for d in /usr /usr/local xml/expat-cvs xml/expat $srcdir/xml/expat ; do
151 if test -n "$expat_include_dir"; then
152 dnl For /usr installs of expat, we can't specify -L/usr/lib
153 if test "$d" = "/usr"; then
160 if test -z "$expat_include_dir"; then
161 AC_MSG_ERROR([could not locate Expat. use --with-expat])
164 dnl If this expat doesn't use libtool natively, we'll mimic it for our
165 dnl dependency library generation.
166 if test -z "$expat_libtool"; then
167 expat_libtool="$expat_ldflags $expat_libs"
170 if test -n "$expat_old"; then
171 AC_DEFINE(APR_HAVE_OLD_EXPAT, 1, [define if Expat 1.0 or 1.1 was found])
174 dnl special-case the bundled distribution (use absolute dirs)
175 if test "$expat_include_dir" = "xml/expat/lib" -o "$expat_include_dir" = "xml/expat-cvs/lib"; then
176 bundled_subdir="`echo $expat_include_dir | sed -e 's%/lib%%'`"
177 APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir])
178 expat_include_dir=$top_builddir/$bundled_subdir/lib
179 expat_ldflags="-L$top_builddir/$bundled_subdir/lib"
181 expat_libtool=$top_builddir/$bundled_subdir/libexpat.la
182 APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`"
183 APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libtool])
185 if test "$expat_include_dir" = "$abs_srcdir/xml/expat/include" -o "$expat_include_dir" = "$abs_srcdir/xml/expat/lib"; then
186 dnl This is a bit of a hack. This only works because we know that
187 dnl we are working with the bundled version of the software.
188 bundled_subdir="xml/expat"
189 APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir])
190 expat_include_dir=$abs_srcdir/$bundled_subdir/lib
191 expat_ldflags="-L$top_builddir/$bundled_subdir/lib"
193 expat_libtool=$top_builddir/$bundled_subdir/libexpat.la
194 APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`"
195 APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libtool])
197 APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libs])
200 APR_XML_DIR=$bundled_subdir
201 APR_XML_EXPAT_OLD=$expat_old
202 AC_SUBST(APR_XML_SUBDIRS)
203 AC_SUBST(APR_XML_DIR)
204 AC_SUBST(APR_XML_EXPAT_OLD)
206 if test "$expat_include_dir" != "/usr/include"; then
207 APR_ADDTO(APRUTIL_INCLUDES, [-I$expat_include_dir])
209 APR_ADDTO(APRUTIL_LDFLAGS, [$expat_ldflags])
210 APR_ADDTO(APRUTIL_LIBS, [$expat_libtool])
215 dnl Find a particular LDAP library
217 AC_DEFUN(APU_FIND_LDAPLIB,[
218 if test ${apu_has_ldap} != "1"; then
221 unset ac_cv_lib_${ldaplib}_ldap_init
222 unset ac_cv_lib_${ldaplib}___ldap_init
223 AC_CHECK_LIB(${ldaplib}, ldap_init,
225 APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l${ldaplib} ${extralib}])
226 APR_ADDTO(APRUTIL_LIBS,[-l${ldaplib} ${extralib}])
227 AC_CHECK_LIB(${ldaplib}, ldapssl_install_routines, apu_has_ldap_netscape_ssl="1", , ${extralib})
228 AC_CHECK_LIB(${ldaplib}, ldap_start_tls_s, apu_has_ldap_starttls="1", , ${extralib})
236 dnl APU_FIND_LDAP: figure out where LDAP is located
238 AC_DEFUN(APU_FIND_LDAP,[
240 echo $ac_n "${nl}checking for ldap support..."
243 apu_has_ldap_netscape_ssl="0"
244 apu_has_ldap_starttls="0"
246 AC_ARG_WITH(ldap-include,[ --with-ldap-include=path path to ldap include files with trailing slash])
247 AC_ARG_WITH(ldap-lib,[ --with-ldap-lib=path path to ldap lib file])
248 AC_ARG_WITH(ldap,[ --with-ldap=library ldap library to use],
250 save_cppflags="$CPPFLAGS"
251 save_ldflags="$LDFLAGS"
253 if test -n "$with_ldap_include"; then
254 CPPFLAGS="$CPPFLAGS -I$with_ldap_include"
255 APR_ADDTO(APRUTIL_INCLUDES, [-I$with_ldap_include])
257 if test -n "$with_ldap_lib"; then
258 LDFLAGS="$LDFLAGS -L$with_ldap_lib"
259 APR_ADDTO(APRUTIL_LDFLAGS, [-L$with_ldap_lib])
263 if test "$LIBLDAP" = "yes"; then
264 dnl The iPlanet C SDK 5.0 is as yet untested...
265 APU_FIND_LDAPLIB("ldap50", "-lnspr4 -lplc4 -lplds4 -liutil50 -llber50 -lldif50 -lnss3 -lprldap50 -lssl3 -lssldap50")
266 APU_FIND_LDAPLIB("ldapssl41", "-lnspr3 -lplc3 -lplds3")
267 APU_FIND_LDAPLIB("ldapssl40")
268 APU_FIND_LDAPLIB("ldapssl30")
269 APU_FIND_LDAPLIB("ldapssl20")
270 APU_FIND_LDAPLIB("ldap", "-llber")
271 APU_FIND_LDAPLIB("ldap", "-llber -lresolv")
272 APU_FIND_LDAPLIB("ldap", "-llber -lresolv -lsocket -lnsl")
273 APU_FIND_LDAPLIB("ldap", "-ldl -lpthread")
275 APU_FIND_LDAPLIB($LIBLDAP)
276 APU_FIND_LDAPLIB($LIBLDAP, "-lresolv")
277 APU_FIND_LDAPLIB($LIBLDAP, "-lresolv -lsocket -lnsl")
278 APU_FIND_LDAPLIB($LIBLDAP, "-ldl -lpthread")
281 test ${apu_has_ldap} != "1" && AC_MSG_ERROR(could not find an LDAP library)
282 AC_CHECK_LIB(lber, ber_init)
284 AC_CHECK_HEADERS(lber.h, lber_h=["#include <lber.h>"])
285 AC_CHECK_HEADERS(ldap.h, ldap_h=["#include <ldap.h>"], [],
290 AC_CHECK_HEADERS(ldap_ssl.h, ldap_ssl_h=["#include <ldap_ssl.h>"])
292 CPPFLAGS=$save_cppflags
293 LDFLAGS=$save_ldflags
300 AC_SUBST(apu_has_ldap_netscape_ssl)
301 AC_SUBST(apu_has_ldap_starttls)
302 AC_SUBST(apu_has_ldap)