upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr-util / build / apu-conf.m4
1 dnl
2 dnl custom autoconf rules for APRUTIL
3 dnl
4
5 dnl
6 dnl APU_FIND_APR: figure out where APR is located
7 dnl
8 AC_DEFUN(APU_FIND_APR,[
9
10   dnl use the find_apr.m4 script to locate APR. sets apr_found and apr_config
11   APR_FIND_APR
12   if test "$apr_found" = "no"; then
13     AC_MSG_ERROR(APR could not be located. Please use the --with-apr option.)
14   fi
15
16   APR_BUILD_DIR="`$apr_config --installbuilddir`"
17
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`"
21
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`"
26
27   AC_SUBST(APR_INCLUDES)
28   AC_SUBST(APR_LIBS)
29   AC_SUBST(APR_BUILD_DIR)
30 ])
31
32
33 dnl
34 dnl APU_TEST_EXPAT(directory): test if Expat is located in the specified dir
35 dnl
36 dnl if present: sets expat_include_dir, expat_libs, possibly expat_old
37 dnl
38 AC_DEFUN(APU_TEST_EXPAT,[
39   AC_MSG_CHECKING(for Expat in ifelse($2,,$1,$2))
40
41   expat_libtool=""
42
43   if test -r "$1/lib/expat.h"; then
44     dnl Expat 1.95.* distribution
45     expat_include_dir="$1/lib"
46     expat_ldflags="-L$1"
47     expat_libs="-lexpat"
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"
54     expat_libs="-lexpat"
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"
61     expat_libs="-lexpat"
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"
69     expat_libs="-lexpat"
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"
73     expat_ldflags="-L$1"
74     expat_libs="-lexpat"
75     expat_libtool="$1/libexpat.la"
76     expat_old=yes
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"
82     expat_libs="-lexpat"
83     expat_old=yes
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"
89     expat_libs="-lexpat"
90     expat_old=yes
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"
96     expat_old=yes
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"
102     expat_libs="-lexpat"
103     expat_old=yes
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"
107     expat_ldflags="-L$1"
108     expat_libs="-lexpat"
109     expat_old=yes
110   fi
111   dnl ### test for installed Expat 1.95.* distros
112
113   if test -n "$expat_include_dir"; then
114     dnl ### more info about what we found there? version? using .la?
115     AC_MSG_RESULT(yes)
116   else
117     AC_MSG_RESULT(no)
118   fi
119 ])
120
121
122 dnl
123 dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled)
124 dnl
125 AC_DEFUN(APU_FIND_EXPAT,[
126
127 AC_ARG_WITH([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
136       $mkdir_p xml/expat
137     fi
138     APU_TEST_EXPAT($abs_expatdir, xml/expat)
139   else
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\"])
144     fi
145   fi
146 ])
147
148 if test -z "$expat_include_dir"; then
149   for d in /usr /usr/local xml/expat-cvs xml/expat $srcdir/xml/expat ; do
150     APU_TEST_EXPAT($d)
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
154         expat_ldflags=""
155       fi
156       break
157     fi
158   done
159 fi
160 if test -z "$expat_include_dir"; then
161   AC_MSG_ERROR([could not locate Expat. use --with-expat])
162 fi
163
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" 
168 fi
169
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])
172 fi
173
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"
180   expat_libs="-lexpat"
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])
184 else
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"
192   expat_libs="-lexpat"
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])
196 else
197   APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libs])
198 fi
199 fi
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)
205
206 if test "$expat_include_dir" != "/usr/include"; then
207   APR_ADDTO(APRUTIL_INCLUDES, [-I$expat_include_dir])
208 fi
209 APR_ADDTO(APRUTIL_LDFLAGS, [$expat_ldflags])
210 APR_ADDTO(APRUTIL_LIBS, [$expat_libtool])
211 ])
212
213
214 dnl 
215 dnl Find a particular LDAP library
216 dnl
217 AC_DEFUN(APU_FIND_LDAPLIB,[
218   if test ${apu_has_ldap} != "1"; then
219     ldaplib=$1
220     extralib=$2
221     unset ac_cv_lib_${ldaplib}_ldap_init
222     unset ac_cv_lib_${ldaplib}___ldap_init
223     AC_CHECK_LIB(${ldaplib}, ldap_init, 
224       [
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})
229         apu_has_ldap="1";
230       ], , ${extralib})
231   fi
232 ])
233
234
235 dnl
236 dnl APU_FIND_LDAP: figure out where LDAP is located
237 dnl
238 AC_DEFUN(APU_FIND_LDAP,[
239
240 echo $ac_n "${nl}checking for ldap support..."
241
242 apu_has_ldap="0";
243 apu_has_ldap_netscape_ssl="0"
244 apu_has_ldap_starttls="0"
245
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],
249   [
250     save_cppflags="$CPPFLAGS"
251     save_ldflags="$LDFLAGS"
252     save_libs="$LIBS"
253     if test -n "$with_ldap_include"; then
254       CPPFLAGS="$CPPFLAGS -I$with_ldap_include"
255       APR_ADDTO(APRUTIL_INCLUDES, [-I$with_ldap_include])
256     fi
257     if test -n "$with_ldap_lib"; then
258       LDFLAGS="$LDFLAGS -L$with_ldap_lib"
259       APR_ADDTO(APRUTIL_LDFLAGS, [-L$with_ldap_lib])
260     fi
261
262     LIBLDAP="$withval"
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")
274     else
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")
279     fi
280
281     test ${apu_has_ldap} != "1" && AC_MSG_ERROR(could not find an LDAP library)
282     AC_CHECK_LIB(lber, ber_init)
283
284     AC_CHECK_HEADERS(lber.h, lber_h=["#include <lber.h>"])
285     AC_CHECK_HEADERS(ldap.h, ldap_h=["#include <ldap.h>"], [],
286 [#if HAVE_LBER_H
287 # include <lber.h>
288 # endif
289 ])
290     AC_CHECK_HEADERS(ldap_ssl.h, ldap_ssl_h=["#include <ldap_ssl.h>"])
291
292     CPPFLAGS=$save_cppflags
293     LDFLAGS=$save_ldflags
294     LIBS=$save_libs
295   ])
296
297 AC_SUBST(ldap_h)
298 AC_SUBST(lber_h)
299 AC_SUBST(ldap_ssl_h)
300 AC_SUBST(apu_has_ldap_netscape_ssl)
301 AC_SUBST(apu_has_ldap_starttls)
302 AC_SUBST(apu_has_ldap)
303
304 ])