AC_DEFUN([APU_CHECK_BERKELEY_DB], [
bdb_version=$1
if test "$2" != "-1"; then
bdb_version="$bdb_version.$2"
if test "$3" != "-1"; then
bdb_version="$bdb_version.$3"
fi
fi
bdb_places=$4
bdb_default_search_headers=$5
bdb_default_search_lib_names=$6
apu_have_db=0
apu_check_lib_save_libs="$LIBS"
apu_check_lib_save_ldflags="$LDFLAGS"
apu_check_lib_save_cppflags="$CPPFLAGS"
found=not
for bdb_place in $bdb_places; do
LDFLAGS="$apu_check_lib_save_ldflags"
CPPFLAGS="$apu_check_lib_save_cppflags"
case "$bdb_place" in
"std" )
description="the standard places"
;;
*":"* )
header="`echo $bdb_place | sed -e 's/:.*$//'`"
lib="`echo $bdb_place | sed -e 's/^.*://'`"
CPPFLAGS="$CPPFLAGS -I$header"
LDFLAGS="$LDFLAGS -L$lib"
description="$header and $lib"
;;
* )
if test -d $bdb_place; then
LDFLAGS="$LDFLAGS -L$bdb_place/lib"
CPPFLAGS="$CPPFLAGS -I$bdb_place/include"
else
AC_MSG_CHECKING([for Berkeley DB $bdb_version in $bdb_place])
AC_MSG_RESULT([directory not found])
continue
fi
description="$bdb_place"
;;
esac
AC_MSG_CHECKING([for Berkeley DB $bdb_version in $description])
AC_MSG_RESULT()
for bdb_libname in $bdb_default_search_lib_names; do
for bdb_header in $bdb_default_search_headers; do
changequote(,)
cache_id="`echo ac_cv_header_${bdb_header} \
| sed -e 's/[^a-zA-Z0-9_]/_/g'`"
changequote([,])
unset $cache_id
AC_CHECK_HEADER([$bdb_header], [
if test "$1" = "3" -o "$1" = "4" -o "$1" = "5"; then
changequote(,)
cache_id="`echo apu_cv_check_berkeley_db_$1_$2_$3_${bdb_header}_${bdb_libname}_in_${bdb_place} \
| sed -e 's/[^a-zA-Z0-9_]/_/g'`"
changequote([,])
AC_MSG_CHECKING([for -l$bdb_libname])
AC_CACHE_VAL($cache_id,
[
APU_TRY_BERKELEY_DB($1, $2, $3, $bdb_header, $bdb_libname)
eval "$cache_id=$apu_try_berkeley_db"
])
result="`eval echo '$'$cache_id`"
AC_MSG_RESULT($result)
elif test "$1" = "1"; then
AC_CHECK_LIB($bdb_libname,
dbopen,
[result=yes],
[result=no]
)
elif test "$1" = "2"; then
AC_CHECK_LIB($bdb_libname,
db_open,
[result=yes],
[result=no]
)
fi
], [result="no"])
if test "$result" = "yes"; then
found="$bdb_place"
break
fi
done
test "$found" != "not" && break
done
test "$found" != "not" && break
done
LDFLAGS="$apu_check_lib_save_ldflags"
CPPFLAGS="$apu_check_lib_save_cppflags"
case "$found" in
"not")
apu_have_db=0
;;
"std")
apu_db_header=$bdb_header
apu_db_lib=$bdb_libname
apu_have_db=1
;;
*":"*)
header="`echo $found | sed -e 's/:.*$//'`"
lib="`echo $found | sed -e 's/^.*://'`"
APR_ADDTO(APRUTIL_INCLUDES, [-I$header])
APR_ADDTO(APRUTIL_LDFLAGS, [-L$lib])
apu_db_header=$bdb_header
apu_db_lib=$bdb_libname
apu_have_db=1
;;
*)
APR_ADDTO(APRUTIL_INCLUDES, [-I$found/include])
APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib])
apu_db_header=$bdb_header
apu_db_lib=$bdb_libname
apu_have_db=1
;;
esac
])
AC_DEFUN([APU_TRY_BERKELEY_DB],
[
apu_try_berkeley_db_save_libs="$LIBS"
apu_check_berkeley_db_major=$1
apu_check_berkeley_db_minor=$2
apu_check_berkeley_db_patch=$3
apu_try_berkeley_db_header=$4
apu_try_berkeley_db_libname=$5
LIBS="$LIBS -l$apu_try_berkeley_db_libname"
AC_TRY_RUN(
[
main ()
{
int major, minor, patch;
db_version(&major, &minor, &patch);
/* Sanity check: ensure that db.h constants actually match the db library */
if (major != DB_VERSION_MAJOR
|| minor != DB_VERSION_MINOR
|| patch != DB_VERSION_PATCH)
exit (1);
/* Run-time check: ensure the library claims to be the correct version. */
if ($apu_check_berkeley_db_major != -1) {
if (major < $apu_check_berkeley_db_major)
exit (1);
if (major > $apu_check_berkeley_db_major)
exit (0);
}
if ($apu_check_berkeley_db_minor != -1) {
if (minor < $apu_check_berkeley_db_minor)
exit (1);
if (minor > $apu_check_berkeley_db_minor)
exit (0);
}
if ($apu_check_berkeley_db_patch == -1
|| patch >= $apu_check_berkeley_db_patch)
exit (0);
else
exit (1);
}
],
[apu_try_berkeley_db=yes],
[apu_try_berkeley_db=no],
[apu_try_berkeley_db=yes]
)
LIBS="$apu_try_berkeley_db_save_libs"
]
)
AC_DEFUN([APU_CHECK_DB1], [
places=$1
if test -z "$places"; then
places="std"
fi
APU_CHECK_BERKELEY_DB(1, 0, 0,
"$places",
"db1/db.h db.h",
"db1"
)
if test "$apu_have_db" = "1"; then
apu_db_version=1
fi
])
AC_DEFUN([APU_CHECK_DB185], [
places=$1
if test -z "$places"; then
places="std"
fi
APU_CHECK_BERKELEY_DB(1, -1, -1,
"$places",
"db_185.h",
"db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=185
fi
])
AC_DEFUN([APU_CHECK_DB2], [
places=$1
if test -z "$places"; then
places="std"
fi
APU_CHECK_BERKELEY_DB(2, -1, -1,
"$places",
"db2/db.h db.h",
"db2 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=2
fi
])
AC_DEFUN([APU_CHECK_DB3], [
places=$1
if test -z "$places"; then
places="std"
fi
APU_CHECK_BERKELEY_DB(3, -1, -1,
"$places",
"db3/db.h db.h",
"db3 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=3
fi
])
AC_DEFUN([APU_CHECK_DB4], [
places=$1
if test -z "$places"; then
places="std /usr/local /usr/local/BerkeleyDB.4.0 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "0", "-1",
"$places",
"db4/db.h db.h",
"db-4.0 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB41], [
places=$1
if test -z "$places"; then
places="std /usr/local /usr/local/BerkeleyDB.4.1 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "1", "-1",
"$places",
"db41/db.h db4/db.h db.h",
"db-4.1 db41 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB42], [
places=$1
if test -z "$places"; then
places="std /usr/local /usr/local/BerkeleyDB.4.2 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "2", "-1",
"$places",
"db42/db.h db4/db.h db.h",
"db-4.2 db42 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB43], [
places=$1
if test -z "$places"; then
places="std /usr/local/BerkeleyDB.4.3 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "3", "-1",
"$places",
"db43/db.h db4/db.h db.h",
"db-4.3 db4-4.3 db43 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB44], [
places=$1
if test -z "$places"; then
places="std /usr/local/BerkeleyDB.4.4 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "4", "-1",
"$places",
"db44/db.h db4/db.h db.h",
"db-4.4 db4-4.4 db44 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB45], [
places=$1
if test -z "$places"; then
places="std /usr/local/BerkeleyDB.4.5 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "5", "-1",
"$places",
"db45/db.h db4/db.h db.h",
"db-4.5 db4-4.5 db45 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB46], [
places=$1
if test -z "$places"; then
places="std /usr/local/BerkeleyDB.4.6 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "6", "-1",
"$places",
"db46/db.h db4/db.h db.h",
"db-4.6 db4-4.6 db46 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB47], [
places=$1
if test -z "$places"; then
places="std /usr/local/BerkeleyDB.4.7 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "7", "-1",
"$places",
"db47/db.h db4/db.h db.h",
"db-4.7 db4-4.7 db47 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB48], [
places=$1
if test -z "$places"; then
places="std /usr/local/BerkeleyDB.4.8 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("4", "8", "-1",
"$places",
"db48/db.h db4/db.h db.h",
"db-4.8 db4-4.8 db48 db4 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=4
fi
])
AC_DEFUN([APU_CHECK_DB50], [
places=$1
if test -z "$places"; then
places="std /usr/local/BerkeleyDB.5.0 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("5", "0", "-1",
"$places",
"db50/db.h db5/db.h db.h",
"db-5.0 db5-5.0 db50 db5 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=5
fi
])
AC_DEFUN([APU_CHECK_DB51], [
places=$1
if test -z "$places"; then
places="std /usr/local/BerkeleyDB.5.1 /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("5", "1", "-1",
"$places",
"db51/db.h db5/db.h db.h",
"db-5.1 db5-5.1 db51 db5 db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=5
fi
])
AC_DEFUN([APU_CHECK_DB], [
requested=$1
check_places=$2
case "$requested" in
db)
APU_CHECK_DB_ALL("$check_places")
if test "$apu_have_db" = "0"; then
AC_MSG_ERROR(Berkeley db requested, but not found)
fi
;;
db1)
APU_CHECK_DB1("$check_places")
if test "$apu_db_version" != "1"; then
AC_MSG_ERROR(Berkeley db1 not found)
fi
;;
db185)
APU_CHECK_DB185("$check_places")
if test "$apu_db_version" != "185"; then
AC_MSG_ERROR(Berkeley db185 not found)
fi
;;
db2)
APU_CHECK_DB2("$check_places")
if test "$apu_db_version" != "2"; then
AC_MSG_ERROR(Berkeley db2 not found)
fi
;;
db3)
APU_CHECK_DB3("$check_places")
if test "$apu_db_version" != "3"; then
AC_MSG_ERROR(Berkeley db3 not found)
fi
;;
db4)
APU_CHECK_DB4("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db41)
APU_CHECK_DB41("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db42)
APU_CHECK_DB42("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db43)
APU_CHECK_DB43("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db44)
APU_CHECK_DB44("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db45)
APU_CHECK_DB45("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db46)
APU_CHECK_DB46("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db47)
APU_CHECK_DB47("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db48)
APU_CHECK_DB48("$check_places")
if test "$apu_db_version" != "4"; then
AC_MSG_ERROR(Berkeley db4 not found)
fi
;;
db50)
APU_CHECK_DB50("$check_places")
if test "$apu_db_version" != "5"; then
AC_MSG_ERROR(Berkeley db5 not found)
fi
;;
db51)
APU_CHECK_DB51("$check_places")
if test "$apu_db_version" != "5"; then
AC_MSG_ERROR(Berkeley db5 not found)
fi
;;
default)
APU_CHECK_DB_ALL("$check_places")
;;
esac
])
AC_DEFUN([APU_CHECK_DB_ALL], [
all_places=$1
APU_CHECK_DB51("$all_places")
if test "$apu_db_version" != "5"; then
APU_CHECK_DB50("$all_places")
if test "$apu_db_version" != "5"; then
APU_CHECK_DB48("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB47("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB46("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB45("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB44("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB43("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB42("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB41("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB4("$all_places")
if test "$apu_db_version" != "4"; then
APU_CHECK_DB3("$all_places")
if test "$apu_db_version" != "3"; then
APU_CHECK_DB2("$all_places")
if test "$apu_db_version" != "2"; then
APU_CHECK_DB1("$all_places")
if test "$apu_db_version" != "1"; then
APU_CHECK_DB185("$all_places")
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
AC_MSG_CHECKING(for Berkeley DB)
if test "$apu_have_db" = "1"; then
AC_MSG_RESULT(found db$apu_db_version)
else
AC_MSG_RESULT(not found)
fi
])
AC_DEFUN([APU_CHECK_DBM], [
apu_use_sdbm=0
apu_use_ndbm=0
apu_use_gdbm=0
apu_use_db=0
dnl it's in our codebase
apu_have_sdbm=1
apu_have_gdbm=0
apu_have_ndbm=0
apu_have_db=0
apu_db_header=db.h apu_db_version=0
AC_ARG_WITH(dbm, [APR_HELP_STRING([--with-dbm=DBM], [choose the DBM type to use.
DBM={sdbm,gdbm,ndbm,db,db1,db185,db2,db3,db4,db41,db42,db43,db44,db45,db46,db47,db48,db50,db51}])],
[
if test "$withval" = "yes"; then
AC_MSG_ERROR([--with-dbm needs to specify a DBM type to use.
One of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44, db45, db46, db47, db48, db50, db51])
fi
requested="$withval"
], [
requested=default
])
AC_ARG_WITH([gdbm], [APR_HELP_STRING([--with-gdbm=DIR], [enable GDBM support])],
[
apu_have_gdbm=0
if test "$withval" = "yes"; then
AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
elif test "$withval" = "no"; then
apu_have_gdbm=0
else
saved_cppflags="$CPPFLAGS"
saved_ldflags="$LDFLAGS"
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib "
AC_MSG_CHECKING(checking for gdbm in $withval)
AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
if test "$apu_have_gdbm" != "0"; then
APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
fi
CPPFLAGS="$saved_cppflags"
LDFLAGS="$saved_ldflags"
fi
])
AC_ARG_WITH([ndbm], [APR_HELP_STRING([--with-ndbm=PATH], [
Find the NDBM header and library in `PATH/include' and
`PATH/lib'. If PATH is of the form `HEADER:LIB', then search
for header files in HEADER, and the library in LIB. If you omit
the `=PATH' part completely, the configure script will search
for NDBM in a number of standard places.])],
[
apu_have_ndbm=0
if test "$withval" = "yes"; then
AC_MSG_CHECKING(checking for ndbm in the usual places)
apu_want_ndbm=1
NDBM_INC=""
NDBM_LDFLAGS=""
elif test "$withval" = "no"; then
apu_want_ndbm=0
else
apu_want_ndbm=1
case "$withval" in
*":"*)
NDBM_INC="-I`echo $withval |sed -e 's/:.*$//'`"
NDBM_LDFLAGS="-L`echo $withval |sed -e 's/^.*://'`"
AC_MSG_CHECKING(checking for ndbm includes with $NDBM_INC libs with $NDBM_LDFLAGS )
;;
*)
NDBM_INC="-I$withval/include"
NDBM_LDFLAGS="-L$withval/lib"
AC_MSG_CHECKING(checking for ndbm includes in $withval)
;;
esac
fi
save_cppflags="$CPPFLAGS"
save_ldflags="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $NDBM_INC"
LDFLAGS="$LDFLAGS $NDBM_LDFLAGS"
if test "$apu_want_ndbm" != "0"; then
AC_CHECK_HEADER(ndbm.h,
AC_CHECK_LIB(c, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=c],
AC_CHECK_LIB(dbm, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=dbm],
AC_CHECK_LIB(db, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db],
AC_CHECK_LIB(db, __db_ndbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db])
)
)
)
)
if test "$apu_have_ndbm" != "0"; then
if test "$withval" != "yes"; then
APR_ADDTO(APRUTIL_INCLUDES, [$NDBM_INC])
APR_ADDTO(APRUTIL_LDFLAGS, [$NDBM_LDFLAGS])
fi
elif test "$withval" != "yes"; then
AC_ERROR( NDBM not found in the specified directory)
fi
fi
CPPFLAGS="$save_cppflags"
LDFLAGS="$save_ldflags"
], [
apu_have_ndbm=0
])
if test -n "$apu_db_xtra_libs"; then
saveddbxtralibs="$LIBS"
LIBS="$apu_db_xtra_libs $LIBS"
fi
AC_ARG_WITH([berkeley-db], [APR_HELP_STRING([--with-berkeley-db=PATH],
[Find the Berkeley DB header and library in `PATH/include' and
`PATH/lib'. If PATH is of the form `HEADER:LIB', then search
for header files in HEADER, and the library in LIB. If you omit
the `=PATH' part completely, the configure script will search
for Berkeley DB in a number of standard places.])],
[
if test "$withval" = "yes"; then
apu_want_db=1
user_places=""
elif test "$withval" = "no"; then
apu_want_db=0
else
apu_want_db=1
user_places="$withval"
fi
if test "$apu_want_db" != "0"; then
APU_CHECK_DB($requested, $user_places)
if test "$apu_have_db" = "0"; then
AC_ERROR(Berkeley DB not found.)
fi
fi
])
if test -n "$apu_db_xtra_libs"; then
LIBS="$saveddbxtralibs"
fi
case "$requested" in
sdbm)
apu_use_sdbm=1
apu_default_dbm=sdbm
;;
gdbm)
apu_use_gdbm=1
apu_default_dbm=gdbm
;;
ndbm)
apu_use_ndbm=1
apu_default_dbm=ndbm
;;
db)
apu_use_db=1
apu_default_dbm=db
;;
db1)
apu_use_db=1
apu_default_dbm=db1
;;
db185)
apu_use_db=1
apu_default_dbm=db185
;;
db2)
apu_use_db=1
apu_default_dbm=db2
;;
db3)
apu_use_db=1
apu_default_dbm=db3
;;
db4)
apu_use_db=1
apu_default_dbm=db4
;;
db41)
apu_use_db=1
apu_default_dbm=db4
;;
db42)
apu_use_db=1
apu_default_dbm=db4
;;
db43)
apu_use_db=1
apu_default_dbm=db4
;;
db44)
apu_use_db=1
apu_default_dbm=db4
;;
db45)
apu_use_db=1
apu_default_dbm=db4
;;
db46)
apu_use_db=1
apu_default_dbm=db4
;;
db47)
apu_use_db=1
apu_default_dbm=db4
;;
db48)
apu_use_db=1
apu_default_dbm=db4
;;
db50)
apu_use_db=1
apu_default_dbm=db5
;;
db51)
apu_use_db=1
apu_default_dbm=db5
;;
default)
apu_default_dbm="sdbm (default)"
apu_use_sdbm=1
;;
*)
AC_MSG_ERROR([--with-dbm=$look_for is an unknown DBM type.
Use one of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44, db45, db46, db47, db48, db50, db51])
;;
esac
AC_MSG_CHECKING(for default DBM)
AC_MSG_RESULT($apu_default_dbm)
AC_SUBST(apu_use_sdbm)
AC_SUBST(apu_use_gdbm)
AC_SUBST(apu_use_ndbm)
AC_SUBST(apu_use_db)
AC_SUBST(apu_have_sdbm)
AC_SUBST(apu_have_gdbm)
AC_SUBST(apu_have_ndbm)
AC_SUBST(apu_have_db)
AC_SUBST(apu_db_header)
AC_SUBST(apu_db_version)
if test "$apu_have_db" = "1"; then
LDADD_dbm_db="-l$apu_db_lib"
if test -n "apu_db_xtra_libs"; then
LDADD_dbm_db="$LDADD_dbm_db $apu_db_xtra_libs"
fi
fi
if test "$apu_have_gdbm" = "1"; then
LDADD_dbm_gdbm="-lgdbm"
fi
if test "$apu_have_ndbm" = "1"; then
LDADD_dbm_ndbm="-l$apu_ndbm_lib"
fi
AC_SUBST(LDADD_dbm_db)
AC_SUBST(LDADD_dbm_gdbm)
AC_SUBST(LDADD_dbm_ndbm)
])