Document PostgreSQL row counting fix.
[apr-util.git] / build / apu-conf.m4
blob4622109507578a1d86aecd649cc4170eb11abd74
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.
18 dnl
19 dnl custom autoconf rules for APRUTIL
20 dnl
22 dnl
23 dnl APU_FIND_APR: figure out where APR is located
24 dnl
25 AC_DEFUN([APU_FIND_APR], [
27   dnl use the find_apr.m4 script to locate APR. sets apr_found and apr_config
28   APR_FIND_APR(,,,[1])
29   if test "$apr_found" = "no"; then
30     AC_MSG_ERROR(APR could not be located. Please use the --with-apr option.)
31   fi
33   APR_BUILD_DIR="`$apr_config --installbuilddir`"
35   dnl make APR_BUILD_DIR an absolute directory (we'll need it in the
36   dnl sub-projects in some cases)
37   APR_BUILD_DIR="`cd $APR_BUILD_DIR && pwd`"
39   APR_INCLUDES="`$apr_config --includes`"
40   APR_LIBS="`$apr_config --link-libtool --libs`"
41   APR_SO_EXT="`$apr_config --apr-so-ext`"
42   APR_LIB_TARGET="`$apr_config --apr-lib-target`"
44   AC_SUBST(APR_INCLUDES)
45   AC_SUBST(APR_LIBS)
46   AC_SUBST(APR_BUILD_DIR)
49 dnl
50 dnl APU_TRY_EXPAT_LINK(
51 dnl      test-message, cache-var-name, hdrs, libs,
52 dnl      [actions-on-success], [actions-on-failure])
53 dnl         
54 dnl Tests linking against expat with libraries 'libs' and includes
55 dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
56 dnl On success, sets $expat_libs to libs, sets $apu_have_expat to 1, 
57 dnl and runs actions-on-success; on failure runs actions-on-failure.
58 dnl
59 AC_DEFUN([APU_TRY_EXPAT_LINK], [
60 AC_CACHE_CHECK([$1], [$2], [
61   apu_expat_LIBS=$LIBS
62   LIBS="$LIBS $4"
63   AC_TRY_LINK([#include <stdlib.h>
64 #include <$3>], [XML_ParserCreate(NULL);],
65     [$2=yes], [$2=no])
66   LIBS=$apu_expat_LIBS
69 if test $[$2] = yes; then
70    AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
71              [Define if $3 is available])
72    apu_expat_libs="$4"
73    apu_has_expat=1
74    $5
75 else
76    apu_has_expat=0
77    $6
81 dnl
82 dnl APU_SYSTEM_EXPAT: tests for a system expat installation
83 dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
84 dnl appropriately.  This is mostly for compatibility with existing
85 dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
86 dnl be dropped later.
87 dnl
88 AC_DEFUN([APU_SYSTEM_EXPAT], [
90   APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system, 
91     [expat.h], [-lexpat])
93   if test $apu_has_expat = 0; then
94     APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
95        [xmltok/xmlparse.h], [-lxmlparse -lxmltok])
96   fi
98   if test $apu_has_expat = 0; then
99     APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
100        [xml/xmlparse.h], [-lexpat])
101   fi
103   if test $apu_has_expat = 0; then
104     APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
105        [xmlparse/xmlparse.h], [-lexpat])
106   fi
108   if test $apu_has_expat = 0; then
109     APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
110     APR_ADDTO(CPPFLAGS, [-I/usr/local/include])
112     APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local], 
113        apu_cv_expat_usrlocal, [expat.h], [-lexpat],
114        [APR_ADDTO(APRUTIL_INCLUDES, [-I/usr/local/include])
115         APR_ADDTO(APRUTIL_LDFLAGS, [-L/usr/local/lib])],[
116        APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
117        APR_REMOVEFROM(CPPFLAGS, [-I/usr/local/include])
118       ])
119   fi
124 dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled)
126 AC_DEFUN([APU_FIND_EXPAT], [
128 save_cppflags="$CPPFLAGS"
129 save_ldflags="$LDFLAGS"
131 apu_has_expat=0
133 # Default: will use either external or bundled expat.
134 apu_try_external_expat=1
135 apu_try_builtin_expat=1
137 AC_ARG_WITH([expat],
138 [  --with-expat=DIR        specify Expat location, or 'builtin'], [
139   if test "$withval" = "yes"; then
140     AC_MSG_ERROR([a directory must be specified for --with-expat])
141   elif test "$withval" = "no"; then
142     AC_MSG_ERROR([Expat cannot be disabled (at this time)])
143   elif test "$withval" = "builtin"; then
144     apu_try_external_expat=0
145   else
146     # Add given path to standard search paths if appropriate:
147     if test "$withval" != "/usr"; then
148       APR_ADDTO(LDFLAGS, [-L$withval/lib])
149       APR_ADDTO(CPPFLAGS, [-I$withval/include])
150       APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
151       APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
152     fi
153     # ...and refuse to fall back on the builtin expat.
154     apu_try_builtin_expat=0
155   fi
158 if test $apu_try_external_expat = 1; then
159   APU_SYSTEM_EXPAT
162 if test "${apu_has_expat}${apu_try_builtin_expat}" = "01"; then
163   dnl This is a bit of a hack.  This only works because we know that
164   dnl we are working with the bundled version of the software.
165   bundled_subdir="xml/expat"
166   APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir])
167   APR_ADDTO(APRUTIL_INCLUDES, [-I$top_builddir/$bundled_subdir/lib])
168   APR_ADDTO(LDFLAGS, [-L$top_builddir/$bundled_subdir/lib])
169   apu_expat_libs="$top_builddir/$bundled_subdir/lib/libexpat.la"
172 APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
173 APR_ADDTO(APRUTIL_LIBS, [$apu_expat_libs])
175 APR_XML_DIR=$bundled_subdir
176 AC_SUBST(APR_XML_DIR)
178 CPPFLAGS=$save_cppflags
179 LDFLAGS=$save_ldflags
183 dnl 
184 dnl Find a particular LDAP library
186 AC_DEFUN([APU_FIND_LDAPLIB], [
187   if test ${apu_has_ldap} != "1"; then
188     ldaplib=$1
189     extralib=$2
190     unset ac_cv_lib_${ldaplib}_ldap_init
191     unset ac_cv_lib_${ldaplib}___ldap_init
192     AC_CHECK_LIB(${ldaplib}, ldap_init, 
193       [
194         LDADD_ldap="-l${ldaplib} ${extralib}"
195         AC_CHECK_LIB(${ldaplib}, ldapssl_client_init, apu_has_ldapssl_client_init="1", , ${extralib})
196         AC_CHECK_LIB(${ldaplib}, ldapssl_client_deinit, apu_has_ldapssl_client_deinit="1", , ${extralib})
197         AC_CHECK_LIB(${ldaplib}, ldapssl_add_trusted_cert, apu_has_ldapssl_add_trusted_cert="1", , ${extralib})
198         AC_CHECK_LIB(${ldaplib}, ldap_start_tls_s, apu_has_ldap_start_tls_s="1", , ${extralib})
199         AC_CHECK_LIB(${ldaplib}, ldap_sslinit, apu_has_ldap_sslinit="1", , ${extralib})
200         AC_CHECK_LIB(${ldaplib}, ldapssl_init, apu_has_ldapssl_init="1", , ${extralib})
201         AC_CHECK_LIB(${ldaplib}, ldapssl_install_routines, apu_has_ldapssl_install_routines="1", , ${extralib})
202         apu_has_ldap="1";
203       ], , ${extralib})
204   fi
209 dnl APU_FIND_LDAP: figure out where LDAP is located
211 AC_DEFUN([APU_FIND_LDAP],  [
213 echo $ac_n "${nl}checking for ldap support..."
215 apu_has_ldap="0";
216 apu_has_ldapssl_client_init="0"
217 apu_has_ldapssl_client_deinit="0"
218 apu_has_ldapssl_add_trusted_cert="0"
219 apu_has_ldap_start_tls_s="0"
220 apu_has_ldapssl_init="0"
221 apu_has_ldap_sslinit="0"
222 apu_has_ldapssl_install_routines="0"
223 apu_has_ldap_openldap="0"
224 apu_has_ldap_solaris="0"
225 apu_has_ldap_novell="0"
226 apu_has_ldap_microsoft="0"
227 apu_has_ldap_netscape="0"
228 apu_has_ldap_mozilla="0"
229 apu_has_ldap_tivoli="0"
230 apu_has_ldap_zos="0"
231 apu_has_ldap_other="0"
232 LDADD_ldap=""
234 AC_ARG_WITH(ldap-include,[  --with-ldap-include=path  path to ldap include files with trailing slash])
235 AC_ARG_WITH(ldap-lib,[  --with-ldap-lib=path    path to ldap lib file])
236 AC_ARG_WITH(ldap,[  --with-ldap=library     ldap library to use],
237   [
238     save_cppflags="$CPPFLAGS"
239     save_ldflags="$LDFLAGS"
240     save_libs="$LIBS"
241     if test -n "$with_ldap_include"; then
242       CPPFLAGS="$CPPFLAGS -I$with_ldap_include"
243       APR_ADDTO(APRUTIL_INCLUDES, [-I$with_ldap_include])
244     fi
245     if test -n "$with_ldap_lib"; then
246       LDFLAGS="$LDFLAGS -L$with_ldap_lib"
247       APR_ADDTO(APRUTIL_LDFLAGS, [-L$with_ldap_lib])
248     fi
250     LIBLDAP="$withval"
251     if test "$LIBLDAP" = "yes"; then
252 dnl The iPlanet C SDK 5.0 is as yet untested... 
253       APU_FIND_LDAPLIB("ldap50", "-lnspr4 -lplc4 -lplds4 -liutil50 -llber50 -lldif50 -lnss3 -lprldap50 -lssl3 -lssldap50")
254       APU_FIND_LDAPLIB("ldapssl41", "-lnspr3 -lplc3 -lplds3")
255       APU_FIND_LDAPLIB("ldapssl40")
256       APU_FIND_LDAPLIB("ldapssl30")
257       APU_FIND_LDAPLIB("ldapssl20")
258       APU_FIND_LDAPLIB("ldapsdk", "-lldapx -lldapssl -lldapgss -lgssapi_krb5")
259       APU_FIND_LDAPLIB("ldapsdk", "-lldapx -lldapssl -lldapgss -lgss -lresolv -lsocket")
260       APU_FIND_LDAPLIB("ldap", "-llber")
261       APU_FIND_LDAPLIB("ldap", "-llber -lresolv")
262       APU_FIND_LDAPLIB("ldap", "-llber -lresolv -lsocket -lnsl")
263       APU_FIND_LDAPLIB("ldap", "-ldl -lpthread")
264     else
265       APU_FIND_LDAPLIB($LIBLDAP)
266       APU_FIND_LDAPLIB($LIBLDAP, "-lresolv")
267       APU_FIND_LDAPLIB($LIBLDAP, "-lresolv -lsocket -lnsl")
268       APU_FIND_LDAPLIB($LIBLDAP, "-ldl -lpthread")
269     fi
271     test ${apu_has_ldap} != "1" && AC_MSG_ERROR(could not find an LDAP library)
272     AC_CHECK_LIB(lber, ber_init)
274     AC_CHECK_HEADERS(lber.h, lber_h=["#include <lber.h>"])
276     # Solaris has a problem in <ldap.h> which prevents it from
277     # being included by itself.  Check for <ldap.h> manually,
278     # including lber.h first.
279     AC_CACHE_CHECK([for ldap.h], [apr_cv_hdr_ldap_h],
280     [AC_TRY_CPP(
281     [#ifdef HAVE_LBER_H
282     #include <lber.h>
283     #endif
284     #include <ldap.h>
285     ], [apr_cv_hdr_ldap_h=yes], [apr_cv_hdr_ldap_h=no])])
286     if test "$apr_cv_hdr_ldap_h" = "yes"; then
287       ldap_h=["#include <ldap.h>"]
288       AC_DEFINE([HAVE_LDAP_H], 1, [Defined if ldap.h is present])
289     fi
291     AC_CHECK_HEADERS(ldap_ssl.h, ldap_ssl_h=["#include <ldap_ssl.h>"])
293     if test "$apr_cv_hdr_ldap_h" = "yes"; then
294       AC_CACHE_CHECK([for LDAP toolkit],
295                      [apr_cv_ldap_toolkit], [
296         if test "x$apr_cv_ldap_toolkit" = "x"; then
297           AC_EGREP_CPP([OpenLDAP], [$lber_h
298                        $ldap_h 
299                        LDAP_VENDOR_NAME], [apu_has_ldap_openldap="1"
300                                            apr_cv_ldap_toolkit="OpenLDAP"])
301         fi
302         if test "x$apr_cv_ldap_toolkit" = "x"; then
303           AC_EGREP_CPP([Sun Microsystems Inc.], [$lber_h
304                        $ldap_h
305                        LDAP_VENDOR_NAME], [apu_has_ldap_solaris="1"
306                                            apr_cv_ldap_toolkit="Solaris"])
307         fi
308         if test "x$apr_cv_ldap_toolkit" = "x"; then
309           AC_EGREP_CPP([Novell], [$lber_h
310                        $ldap_h
311                        LDAP_VENDOR_NAME], [apu_has_ldap_novell="1"
312                                            apr_cv_ldap_toolkit="Novell"])
313         fi
314         if test "x$apr_cv_ldap_toolkit" = "x"; then
315           AC_EGREP_CPP([Microsoft Corporation.], [$lber_h
316                        $ldap_h
317                        LDAP_VENDOR_NAME], [apu_has_ldap_microsoft="1"
318                                            apr_cv_ldap_toolkit="Microsoft"])
319         fi
320         if test "x$apr_cv_ldap_toolkit" = "x"; then
321           AC_EGREP_CPP([Netscape Communications Corp.], [$lber_h
322                        $ldap_h
323                        LDAP_VENDOR_NAME], [apu_has_ldap_netscape="1"
324                                            apr_cv_ldap_toolkit="Netscape"])
325         fi
326         if test "x$apr_cv_ldap_toolkit" = "x"; then
327           AC_EGREP_CPP([mozilla.org], [$lber_h
328                        $ldap_h
329                        LDAP_VENDOR_NAME], [apu_has_ldap_mozilla="1"
330                                            apr_cv_ldap_toolkit="Mozilla"])
331         fi
332         if test "x$apr_cv_ldap_toolkit" = "x"; then
333           AC_EGREP_CPP([International Business Machines], [$lber_h
334                        $ldap_h
335                        LDAP_VENDOR_NAME], [apu_has_ldap_tivoli="1"
336                                            apr_cv_ldap_toolkit="Tivoli"])
337         fi
338         if test "x$apr_cv_ldap_toolkit" = "x"; then
339           case "$host" in
340           *-ibm-os390)
341             AC_EGREP_CPP([IBM], [$lber_h
342                                  $ldap_h], [apu_has_ldap_zos="1"
343                                             apr_cv_ldap_toolkit="z/OS"])
344             ;;
345           esac
346         fi
347         if test "x$apr_cv_ldap_toolkit" = "x"; then
348           apu_has_ldap_other="1"
349           apr_cv_ldap_toolkit="unknown"
350         fi
351       ])
352     fi
354     CPPFLAGS=$save_cppflags
355     LDFLAGS=$save_ldflags
356     LIBS=$save_libs
357   ])
359 if test "$apu_has_ldap_openldap" = "1"; then
360     AC_CACHE_CHECK([style of ldap_set_rebind_proc routine], ac_cv_ldap_set_rebind_proc_style,
361     APR_TRY_COMPILE_NO_WARNING([
362     #ifdef HAVE_LBER_H
363     #include <lber.h>
364     #endif
365     #ifdef HAVE_LDAP_H
366     #include <ldap.h>
367     #endif
368     ], [
369     int tmp = ldap_set_rebind_proc((LDAP *)0, (LDAP_REBIND_PROC *)0, (void *)0);
370     /* use tmp to suppress the warning */
371     tmp=0;
372     ], ac_cv_ldap_set_rebind_proc_style=three, ac_cv_ldap_set_rebind_proc_style=two))
374     if test "$ac_cv_ldap_set_rebind_proc_style" = "three"; then
375         AC_DEFINE(LDAP_SET_REBIND_PROC_THREE, 1, [Define if ldap_set_rebind_proc takes three arguments])
376     fi
379 AC_SUBST(ldap_h)
380 AC_SUBST(lber_h)
381 AC_SUBST(ldap_ssl_h)
382 AC_SUBST(apu_has_ldapssl_client_init)
383 AC_SUBST(apu_has_ldapssl_client_deinit)
384 AC_SUBST(apu_has_ldapssl_add_trusted_cert)
385 AC_SUBST(apu_has_ldap_start_tls_s)
386 AC_SUBST(apu_has_ldapssl_init)
387 AC_SUBST(apu_has_ldap_sslinit)
388 AC_SUBST(apu_has_ldapssl_install_routines)
389 AC_SUBST(apu_has_ldap)
390 AC_SUBST(apu_has_ldap_openldap)
391 AC_SUBST(apu_has_ldap_solaris)
392 AC_SUBST(apu_has_ldap_novell)
393 AC_SUBST(apu_has_ldap_microsoft)
394 AC_SUBST(apu_has_ldap_netscape)
395 AC_SUBST(apu_has_ldap_mozilla)
396 AC_SUBST(apu_has_ldap_tivoli)
397 AC_SUBST(apu_has_ldap_zos)
398 AC_SUBST(apu_has_ldap_other)
399 AC_SUBST(LDADD_ldap)
404 dnl APU_CHECK_CRYPT_R_STYLE
406 dnl  Decide which of a couple of flavors of crypt_r() is necessary for
407 dnl  this platform.
409 AC_DEFUN([APU_CHECK_CRYPT_R_STYLE], [
411 AC_CACHE_CHECK([style of crypt_r], apr_cv_crypt_r_style, 
412 [AC_TRY_COMPILE([#include <crypt.h>],
413  [CRYPTD buffer;
414   crypt_r("passwd", "hash", &buffer);], 
415  [apr_cv_crypt_r_style=cryptd],
416  [AC_TRY_COMPILE([#include <crypt.h>],
417   [struct crypt_data buffer;
418    crypt_r("passwd", "hash", &buffer);], 
419   [apr_cv_crypt_r_style=struct_crypt_data],
420   [apr_cv_crypt_r_style=none])])])
422 if test "$apr_cv_crypt_r_style" = "cryptd"; then
423    AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
424 elif test "$apr_cv_crypt_r_style" = "struct_crypt_data"; then
425    AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])