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_DBXY], [
places=$1
db_major=$2
db_minor=$3
if test -z "$places"; then
places="std /usr/local /usr/local/BerkeleyDB.${db_major}.${db_minor} /boot/home/config"
fi
APU_CHECK_BERKELEY_DB("${db_major}", "${db_minor}", "-1",
"$places",
"db${db_major}${db_minor}/db.h db${db_major}/db.h db.h",
"db-${db_major}.${db_minor} db${db_major}-${db_major}.${db_minor} db${db_major}${db_minor} db-${db_major} db${db_major} db"
)
if test "$apu_have_db" = "1"; then
apu_db_version=${db_major}
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
;;
db[[45]][[0-9]])
db_major=`echo "$requested" | sed -e 's/db//' -e 's/.$//'`
db_minor=`echo "$requested" | sed -e 's/db//' -e 's/.//'`
APU_CHECK_DBXY("$check_places", "$db_major", "$db_minor")
if test "$apu_db_version" != "$db_major"; then
AC_MSG_ERROR(Berkeley db$db_major not found)
fi
;;
db[[45]])
db_major=`echo "$requested" | sed -e 's/db//'`
db_minor=9
while [[ $db_minor -ge 0 ]]
do
APU_CHECK_DBXY("$check_places", "$db_major", "$db_minor")
if test "$apu_have_db" = "1"; then
break
fi
db_minor=`expr $db_minor - 1`
done
if test "$apu_db_version" != "$db_major"; then
AC_MSG_ERROR(Berkeley db$db_major not found)
fi
;;
default)
APU_CHECK_DB_ALL("$check_places")
;;
esac
])
AC_DEFUN([APU_CHECK_DB_ALL], [
all_places=$1
db_version=59
while [[ $db_version -ge 40 ]]
do
db_major=`echo $db_version | sed -e 's/.$//'`
db_minor=`echo $db_version | sed -e 's/.//'`
APU_CHECK_DBXY("$all_places", "$db_major", "$db_minor")
if test "$apu_have_db" = "1"; then
break
fi
db_version=`expr $db_version - 1`
done
if test "$apu_have_db" = "0"; then
APU_CHECK_DB3("$all_places")
fi
if test "$apu_have_db" = "0"; then
APU_CHECK_DB2("$all_places")
fi
if test "$apu_have_db" = "0"; then
APU_CHECK_DB1("$all_places")
fi
if test "$apu_have_db" = "0"; then
APU_CHECK_DB185("$all_places")
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
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
db_max_version=53
db_min_version=41
dbm_list="sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4"
db_version="$db_min_version"
while [[ $db_version -le $db_max_version ]]
do
dbm_list="$dbm_list, db$db_version"
db_version=`expr $db_version + 1`
done
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,db4X,db5X} for some X=0,...,9])],
[
if test "$withval" = "yes"; then
AC_MSG_ERROR([--with-dbm needs to specify a DBM type to use.
One of: $dbm_list])
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 | gdbm | ndbm | db)
eval "apu_use_$requested=1"
apu_default_dbm=$requested
;;
db185 | db[[12345]])
apu_use_db=1
apu_default_dbm=$requested
;;
db[[45]][[0-9]])
apu_use_db=1
apu_default_dbm=`echo $requested | sed -e 's/.$//'`
;;
default)
apu_default_dbm="sdbm (default)"
apu_use_sdbm=1
;;
*)
AC_MSG_ERROR([--with-dbm=$requested is an unknown DBM type.
Use one of: $dbm_list])
;;
esac
dnl so that the AC_MSG_CHECKING would be output before the actual
dnl checks, but it isn't happening now.
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
APR_ADDTO(LDADD_dbm_db, [-l$apu_db_lib])
if test -n "apu_db_xtra_libs"; then
APR_ADDTO(LDADD_dbm_db, [$apu_db_xtra_libs])
fi
fi
if test "$apu_have_gdbm" = "1"; then
APR_ADDTO(LDADD_dbm_gdbm, [-lgdbm])
fi
if test "$apu_have_ndbm" = "1"; then
APR_ADDTO(LDADD_dbm_ndbm, [-l$apu_ndbm_lib])
fi
AC_SUBST(LDADD_dbm_db)
AC_SUBST(LDADD_dbm_gdbm)
AC_SUBST(LDADD_dbm_ndbm)
])