1
dnl -------------------------------------------------------- -*- autoconf -*-
2
dnl Copyright 2002-2005 The Apache Software Foundation or its licensors, as
5
dnl Licensed under the Apache License, Version 2.0 (the "License");
6
dnl you may not use this file except in compliance with the License.
7
dnl 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.
22
dnl APU_LIB_BERKELEY_DB(major, minor, patch, places, headers, libnames)
24
dnl Search for a useable version of Berkeley DB in a number of
25
dnl common places. The installed DB must be no older than the
26
dnl version given by MAJOR, MINOR, and PATCH. All of these
27
dnl arguments are allowed to be '-1', indicating we don't care.
28
dnl PLACES is a list of places to search for a Berkeley DB
29
dnl installation. HEADERS is a list of headers to try. LIBNAMES
30
dnl is a list of names of the library to attempt to link against,
31
dnl typically 'db' and 'db4'.
33
dnl If we find a useable version, set CPPFLAGS and LIBS as
34
dnl appropriate, and set the shell variable `apu_have_db' to
35
dnl `1', and apu_db_lib to the matching lib name, and apu_db_header
36
dnl to the header to use. Otherwise, set `apu_have_db' to `0'.
38
dnl This macro also checks for the `--with-berkeley-db=PATH' flag;
39
dnl if given, the macro will use the PATH specified, and the
40
dnl configuration script will die if it can't find the library. If
41
dnl the user gives the `--without-berkeley-db' flag, the entire
42
dnl search is skipped.
44
dnl We cache the results of individual searches under particular
45
dnl prefixes, not the overall result of whether we found Berkeley
46
dnl DB. That way, the user can re-run the configure script with
47
dnl different --with-berkeley-db switch values, without interference
51
AC_DEFUN([APU_CHECK_BERKELEY_DB], [
53
if test "$2" != "-1"; then
54
bdb_version="$bdb_version.$2"
55
if test "$3" != "-1"; then
56
bdb_version="$bdb_version.$3"
60
bdb_default_search_headers=$5
61
bdb_default_search_lib_names=$6
65
# Save the original values of the flags we tweak.
66
apu_check_lib_save_libs="$LIBS"
67
apu_check_lib_save_ldflags="$LDFLAGS"
68
apu_check_lib_save_cppflags="$CPPFLAGS"
70
# The variable `found' is the prefix under which we've found
71
# Berkeley DB, or `not' if we haven't found it anywhere yet.
73
for bdb_place in $bdb_places; do
75
LDFLAGS="$apu_check_lib_save_ldflags"
76
CPPFLAGS="$apu_check_lib_save_cppflags"
79
description="the standard places"
82
header="`echo $bdb_place | sed -e 's/:.*$//'`"
83
lib="`echo $bdb_place | sed -e 's/^.*://'`"
84
CPPFLAGS="$CPPFLAGS -I$header"
85
LDFLAGS="$LDFLAGS -L$lib"
86
description="$header and $lib"
89
if test -d $bdb_place; then
90
LDFLAGS="$LDFLAGS -L$bdb_place/lib"
91
CPPFLAGS="$CPPFLAGS -I$bdb_place/include"
93
AC_MSG_CHECKING([for Berkeley DB $bdb_version in $bdb_place])
94
AC_MSG_RESULT([directory not found])
97
description="$bdb_place"
101
# Since there is no AC_MSG_NOTICE in autoconf 2.13, we use this
102
# trick to display a message instead.
103
AC_MSG_CHECKING([for Berkeley DB $bdb_version in $description])
106
for bdb_libname in $bdb_default_search_lib_names; do
107
for bdb_header in $bdb_default_search_headers; do
108
# Clear the header cache variable for each location
110
cache_id="`echo ac_cv_header_${bdb_header} \
111
| sed -e 's/[^a-zA-Z0-9_]/_/g'`"
114
AC_CHECK_HEADER([$bdb_header], [
115
if test "$1" = "3" -o "$1" = "4"; then
116
# We generate a separate cache variable for each prefix and libname
117
# we search under. That way, we avoid caching information that
118
# changes if the user runs `configure' with a different set of
121
cache_id="`echo apu_cv_check_berkeley_db_$1_$2_$3_${bdb_header}_${bdb_libname}_in_${bdb_place} \
122
| sed -e 's/[^a-zA-Z0-9_]/_/g'`"
125
AC_MSG_CHECKING([for -l$bdb_libname])
126
dnl We can't use AC_CACHE_CHECK here, because that won't print out
127
dnl the value of the computed cache variable properly.
128
AC_CACHE_VAL($cache_id,
130
APU_TRY_BERKELEY_DB($1, $2, $3, $bdb_header, $bdb_libname)
131
eval "$cache_id=$apu_try_berkeley_db"
133
result="`eval echo '$'$cache_id`"
134
AC_MSG_RESULT($result)
135
elif test "$1" = "1"; then
136
AC_CHECK_LIB($bdb_libname,
141
elif test "$1" = "2"; then
142
AC_CHECK_LIB($bdb_libname,
150
# If we found it, no need to search any more.
151
if test "$result" = "yes"; then
156
test "$found" != "not" && break
158
test "$found" != "not" && break
161
# Restore the original values of the flags we tweak.
162
LDFLAGS="$apu_check_lib_save_ldflags"
163
CPPFLAGS="$apu_check_lib_save_cppflags"
170
apu_db_header=$bdb_header
171
apu_db_lib=$bdb_libname
175
header="`echo $found | sed -e 's/:.*$//'`"
176
lib="`echo $found | sed -e 's/^.*://'`"
178
APR_ADDTO(APRUTIL_INCLUDES, [-I$header])
179
APR_ADDTO(APRUTIL_LDFLAGS, [-L$lib])
180
apu_db_header=$bdb_header
181
apu_db_lib=$bdb_libname
185
APR_ADDTO(APRUTIL_INCLUDES, [-I$found/include])
186
APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib])
187
apu_db_header=$bdb_header
188
apu_db_lib=$bdb_libname
195
dnl APU_TRY_BERKELEY_DB(major, minor, patch, header, libname)
197
dnl A subroutine of APU_CHECK_BERKELEY_DB.
199
dnl Check that a new-enough version of Berkeley DB is installed.
200
dnl "New enough" means no older than the version given by MAJOR,
201
dnl MINOR, and PATCH. The result of the test is not cached; no
202
dnl messages are printed. Use HEADER as the header file to include.
203
dnl Use LIBNAME as the library to link against.
204
dnl (e.g. LIBNAME should usually be "db" or "db4".)
206
dnl Set the shell variable `apu_try_berkeley_db' to `yes' if we found
207
dnl an appropriate version installed, or `no' otherwise.
209
dnl This macro uses the Berkeley DB library function `db_version' to
210
dnl find the version. If the library installed doesn't have this
211
dnl function, then this macro assumes it is too old.
213
dnl NOTE: This is pretty messed up. It seems that the FreeBSD port of
214
dnl Berkeley DB 4 puts the header file in /usr/local/include/db4, but the
215
dnl database library in /usr/local/lib, as libdb4.[a|so]. There is no
216
dnl /usr/local/include/db.h. So if you check for /usr/local first, you'll
217
dnl get the old header file from /usr/include, and the new library from
218
dnl /usr/local/lib. Disaster. Thus this test compares the version constants
219
dnl in the db.h header with the ones returned by db_version().
222
AC_DEFUN([APU_TRY_BERKELEY_DB],
224
apu_try_berkeley_db_save_libs="$LIBS"
226
apu_check_berkeley_db_major=$1
227
apu_check_berkeley_db_minor=$2
228
apu_check_berkeley_db_patch=$3
229
apu_try_berkeley_db_header=$4
230
apu_try_berkeley_db_libname=$5
232
LIBS="$LIBS -l$apu_try_berkeley_db_libname"
236
#include <$apu_try_berkeley_db_header>
239
int major, minor, patch;
241
db_version(&major, &minor, &patch);
243
/* Sanity check: ensure that db.h constants actually match the db library */
244
if (major != DB_VERSION_MAJOR
245
|| minor != DB_VERSION_MINOR
246
|| patch != DB_VERSION_PATCH)
249
/* Run-time check: ensure the library claims to be the correct version. */
251
if ($apu_check_berkeley_db_major != -1) {
252
if (major < $apu_check_berkeley_db_major)
254
if (major > $apu_check_berkeley_db_major)
258
if ($apu_check_berkeley_db_minor != -1) {
259
if (minor < $apu_check_berkeley_db_minor)
261
if (minor > $apu_check_berkeley_db_minor)
265
if ($apu_check_berkeley_db_patch == -1
266
|| patch >= $apu_check_berkeley_db_patch)
272
[apu_try_berkeley_db=yes],
273
[apu_try_berkeley_db=no],
274
[apu_try_berkeley_db=yes]
277
LIBS="$apu_try_berkeley_db_save_libs"
283
dnl APU_CHECK_DB1: is DB1 present?
285
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
287
AC_DEFUN([APU_CHECK_DB1], [
289
if test -z "$places"; then
292
APU_CHECK_BERKELEY_DB(1, 0, 0,
297
if test "$apu_have_db" = "1"; then
304
dnl APU_CHECK_DB185: is DB1.85 present?
306
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
308
dnl NB: BerkelyDB v2 and above can be compiled in 1.85 mode
309
dnl which has a libdb not libdb1 or libdb185
310
AC_DEFUN([APU_CHECK_DB185], [
312
if test -z "$places"; then
315
APU_CHECK_BERKELEY_DB(1, -1, -1,
320
if test "$apu_have_db" = "1"; then
327
dnl APU_CHECK_DB2: is DB2 present?
329
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
331
AC_DEFUN([APU_CHECK_DB2], [
333
if test -z "$places"; then
336
APU_CHECK_BERKELEY_DB(2, -1, -1,
341
if test "$apu_have_db" = "1"; then
348
dnl APU_CHECK_DB3: is DB3 present?
350
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
352
AC_DEFUN([APU_CHECK_DB3], [
354
if test -z "$places"; then
357
APU_CHECK_BERKELEY_DB(3, -1, -1,
362
if test "$apu_have_db" = "1"; then
369
dnl APU_CHECK_DB4: is DB4 present?
371
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
373
AC_DEFUN([APU_CHECK_DB4], [
375
if test -z "$places"; then
376
places="std /usr/local /usr/local/BerkeleyDB.4.0 /boot/home/config"
378
APU_CHECK_BERKELEY_DB("4", "0", "-1",
383
if test "$apu_have_db" = "1"; then
390
dnl APU_CHECK_DB41: is DB4.1 present?
392
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
394
AC_DEFUN([APU_CHECK_DB41], [
396
if test -z "$places"; then
397
places="std /usr/local /usr/local/BerkeleyDB.4.1 /boot/home/config"
399
APU_CHECK_BERKELEY_DB("4", "1", "-1",
401
"db41/db.h db4/db.h db.h",
404
if test "$apu_have_db" = "1"; then
411
dnl APU_CHECK_DB42: is DB4.2 present?
413
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
415
AC_DEFUN([APU_CHECK_DB42], [
417
if test -z "$places"; then
418
places="std /usr/local /usr/local/BerkeleyDB.4.2 /boot/home/config"
420
APU_CHECK_BERKELEY_DB("4", "2", "-1",
422
"db42/db.h db4/db.h db.h",
425
if test "$apu_have_db" = "1"; then
430
dnl APU_CHECK_DB43: is DB4.3 present?
432
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
434
AC_DEFUN([APU_CHECK_DB43], [
436
if test -z "$places"; then
437
places="std /usr/local/BerkeleyDB.4.3 /boot/home/config"
439
APU_CHECK_BERKELEY_DB("4", "3", "-1",
441
"db43/db.h db4/db.h db.h",
442
"db-4.3 db4-4.3 db43 db4 db"
444
if test "$apu_have_db" = "1"; then
449
dnl APU_CHECK_DB44: is DB4.4 present?
451
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
453
AC_DEFUN([APU_CHECK_DB44], [
455
if test -z "$places"; then
456
places="std /usr/local/BerkeleyDB.4.4 /boot/home/config"
458
APU_CHECK_BERKELEY_DB("4", "4", "-1",
460
"db44/db.h db4/db.h db.h",
461
"db-4.4 db4-4.4 db44 db4 db"
463
if test "$apu_have_db" = "1"; then
469
AC_DEFUN([APU_CHECK_DB], [
475
APU_CHECK_DB_ALL("$check_places")
476
if test "$apu_have_db" = "0"; then
477
AC_MSG_ERROR(Berkeley db requested, but not found)
481
APU_CHECK_DB1("$check_places")
482
if test "$apu_db_version" != "1"; then
483
AC_MSG_ERROR(Berkeley db1 not found)
487
APU_CHECK_DB185("$check_places")
488
if test "$apu_db_version" != "185"; then
489
AC_MSG_ERROR(Berkeley db185 not found)
493
APU_CHECK_DB2("$check_places")
494
if test "$apu_db_version" != "2"; then
495
AC_MSG_ERROR(Berkeley db2 not found)
499
APU_CHECK_DB3("$check_places")
500
if test "$apu_db_version" != "3"; then
501
AC_MSG_ERROR(Berkeley db3 not found)
505
APU_CHECK_DB4("$check_places")
506
if test "$apu_db_version" != "4"; then
507
AC_MSG_ERROR(Berkeley db4 not found)
511
APU_CHECK_DB41("$check_places")
512
if test "$apu_db_version" != "4"; then
513
AC_MSG_ERROR(Berkeley db4 not found)
517
APU_CHECK_DB42("$check_places")
518
if test "$apu_db_version" != "4"; then
519
AC_MSG_ERROR(Berkeley db4 not found)
523
APU_CHECK_DB43("$check_places")
524
if test "$apu_db_version" != "4"; then
525
AC_MSG_ERROR(Berkeley db4 not found)
529
APU_CHECK_DB44("$check_places")
530
if test "$apu_db_version" != "4"; then
531
AC_MSG_ERROR(Berkeley db4 not found)
535
APU_CHECK_DB_ALL("$check_places")
541
dnl APU_CHECK_DB_ALL: Try all Berkeley DB versions, from 4.3 to 1.
543
AC_DEFUN([APU_CHECK_DB_ALL], [
546
APU_CHECK_DB44("$all_places")
547
if test "$apu_db_version" != "4"; then
548
APU_CHECK_DB43("$all_places")
549
if test "$apu_db_version" != "4"; then
550
APU_CHECK_DB42("$all_places")
551
if test "$apu_db_version" != "4"; then
552
APU_CHECK_DB41("$all_places")
553
if test "$apu_db_version" != "4"; then
554
APU_CHECK_DB4("$all_places")
555
if test "$apu_db_version" != "4"; then
556
APU_CHECK_DB3("$all_places")
557
if test "$apu_db_version" != "3"; then
558
APU_CHECK_DB2("$all_places")
559
if test "$apu_db_version" != "2"; then
560
APU_CHECK_DB1("$all_places")
561
if test "$apu_db_version" != "1"; then
562
APU_CHECK_DB185("$all_places")
571
AC_MSG_CHECKING(for Berkeley DB)
572
if test "$apu_have_db" = "1"; then
573
AC_MSG_RESULT(found db$apu_db_version)
575
AC_MSG_RESULT(not found)
581
dnl APU_CHECK_DBM: see what kind of DBM backend to use for apr_dbm.
583
AC_DEFUN([APU_CHECK_DBM], [
588
dnl it's in our codebase
594
apu_db_header=db.h # default so apu_select_dbm.h is syntactically correct
598
--with-dbm=DBM choose the DBM type to use.
599
DBM={sdbm,gdbm,ndbm,db,db1,db185,db2,db3,db4,db41,db42,db43,db44}
601
if test "$withval" = "yes"; then
602
AC_MSG_ERROR([--with-dbm needs to specify a DBM type to use.
603
One of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44])
610
dnl We don't pull in GDBM unless the user asks for it, since it's GPL
611
AC_ARG_WITH([gdbm], [
612
--with-gdbm=DIR specify GDBM location
615
if test "$withval" = "yes"; then
616
AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
617
elif test "$withval" = "no"; then
620
CPPFLAGS="-I$withval/include"
621
LIBS="-L$withval/lib "
623
AC_MSG_CHECKING(checking for gdbm in $withval)
624
AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
625
if test "$apu_have_gdbm" != "0"; then
626
APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
627
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
632
AC_ARG_WITH([ndbm], [
634
Find the NDBM header and library in \`PATH/include' and
635
\`PATH/lib'. If PATH is of the form \`HEADER:LIB', then search
636
for header files in HEADER, and the library in LIB. If you omit
637
the \`=PATH' part completely, the configure script will search
638
for NDBM in a number of standard places.
641
if test "$withval" = "yes"; then
642
AC_MSG_CHECKING(checking for ndbm in the usual places)
646
elif test "$withval" = "no"; then
652
NDBM_INC="-I`echo $withval |sed -e 's/:.*$//'`"
653
NDBM_LDFLAGS="-L`echo $withval |sed -e 's/^.*://'`"
654
AC_MSG_CHECKING(checking for ndbm includes with $NDBM_INC libs with $NDBM_LDFLAGS )
657
NDBM_INC="-I$withval/include"
658
NDBM_LDFLAGS="-L$withval/lib"
659
AC_MSG_CHECKING(checking for ndbm includes in $withval)
664
save_cppflags="$CPPFLAGS"
665
save_ldflags="$LDFLAGS"
666
CPPFLAGS="$CPPFLAGS $NDBM_INC"
667
LDFLAGS="$LDFLAGS $NDBM_LDFLAGS"
668
dnl db_ndbm_open is what sleepcat's compatibility library actually has in it's lib
669
if test "$apu_want_ndbm" != "0"; then
670
AC_CHECK_HEADER(ndbm.h,
671
AC_CHECK_LIB(c, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=c],
672
AC_CHECK_LIB(dbm, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=dbm],
673
AC_CHECK_LIB(db, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db],
674
AC_CHECK_LIB(db, __db_ndbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db])
679
if test "$apu_have_ndbm" != "0"; then
680
if test "$withval" != "yes"; then
681
APR_ADDTO(APRUTIL_INCLUDES, [$NDBM_INC])
682
APR_ADDTO(APRUTIL_LDFLAGS, [$NDBM_LDFLAGS])
684
elif test "$withval" != "yes"; then
685
AC_ERROR( NDBM not found in the specified directory)
688
CPPFLAGS="$save_cppflags"
689
LDFLAGS="$save_ldflags"
691
dnl don't check it no one has asked us for it
696
if test -n "$apu_db_xtra_libs"; then
697
saveddbxtralibs="$LIBS"
698
LIBS="$apu_db_xtra_libs $LIBS"
701
dnl We're going to try to find the highest version of Berkeley DB supported.
703
dnl Note that we only do this if the user requested it, since the Sleepycat
704
dnl license is viral and requires distribution of source along with programs
706
AC_ARG_WITH([berkeley-db], [
707
--with-berkeley-db=PATH
708
Find the Berkeley DB header and library in \`PATH/include' and
709
\`PATH/lib'. If PATH is of the form \`HEADER:LIB', then search
710
for header files in HEADER, and the library in LIB. If you omit
711
the \`=PATH' part completely, the configure script will search
712
for Berkeley DB in a number of standard places.
714
if test "$withval" = "yes"; then
717
elif test "$withval" = "no"; then
721
user_places="$withval"
724
if test "$apu_want_db" != "0"; then
725
APU_CHECK_DB($requested, $user_places)
726
if test "$apu_have_db" = "0"; then
727
AC_ERROR(Berkeley DB not found.)
732
if test -n "$apu_db_xtra_libs"; then
733
LIBS="$saveddbxtralibs"
759
apu_default_dbm=db185
790
dnl ### use more sophisticated DBMs for the default?
791
apu_default_dbm="sdbm (default)"
795
AC_MSG_ERROR([--with-dbm=$look_for is an unknown DBM type.
796
Use one of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44])
800
dnl Yes, it'd be nice if we could collate the output in an order
801
dnl so that the AC_MSG_CHECKING would be output before the actual
802
dnl checks, but it isn't happening now.
803
AC_MSG_CHECKING(for default DBM)
804
AC_MSG_RESULT($apu_default_dbm)
806
AC_SUBST(apu_use_sdbm)
807
AC_SUBST(apu_use_gdbm)
808
AC_SUBST(apu_use_ndbm)
811
AC_SUBST(apu_have_sdbm)
812
AC_SUBST(apu_have_gdbm)
813
AC_SUBST(apu_have_ndbm)
814
AC_SUBST(apu_have_db)
815
AC_SUBST(apu_db_header)
816
AC_SUBST(apu_db_version)
818
dnl Since we have already done the AC_CHECK_LIB tests, if we have it,
819
dnl we know the library is there.
820
if test "$apu_have_gdbm" = "1"; then
821
APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lgdbm])
822
APR_ADDTO(APRUTIL_LIBS,[-lgdbm])
825
if test "$apu_have_ndbm" = "1"; then
826
APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_ndbm_lib])
827
APR_ADDTO(APRUTIL_LIBS,[-l$apu_ndbm_lib])
830
if test "$apu_have_db" = "1"; then
831
APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_db_lib])
832
APR_ADDTO(APRUTIL_LIBS,[-l$apu_db_lib])
833
if test -n "apu_db_xtra_libs"; then
834
APR_ADDTO(APRUTIL_EXPORT_LIBS,[$apu_db_xtra_libs])
835
APR_ADDTO(APRUTIL_LIBS,[$apu_db_xtra_libs])