3 dnl tests for various db libraries
7 AC_ARG_WITH(db-type-preference,
8 AS_HELP_STRING([--with-db-type-preference=list],
9 [specify HDB backend DB type preference as whitespace-separated list of db1, db3, lmdb, and/or sqlite]),
10 [db_type_preference="$withval"],
11 [db_type_preference="lmdb db3 db1 sqlite"])
12 AC_ARG_WITH(berkeley-db,
13 AS_HELP_STRING([--with-berkeley-db],
14 [enable support for berkeley db @<:@default=check@:>@]),
16 [with_berkeley_db=check])
19 AC_ARG_WITH(berkeley-db-include,
20 AS_HELP_STRING([--with-berkeley-db-include=dir],
21 [use berkeley-db headers in dir]),
23 [with_berkeley_db_include=check])
25 AC_ARG_ENABLE(ndbm-db,
26 AS_HELP_STRING([--disable-ndbm-db],
27 [if you don't want ndbm db]),[
31 AS_HELP_STRING([--disable-mdb-db],
32 [if you don't want LMDB]),[
40 AS_IF([test "x$with_berkeley_db" != xno],
41 [AS_IF([test "x$with_berkeley_db_include" != xcheck],
42 [AC_CHECK_HEADERS(["$dbheader/db.h"],
43 [AC_SUBST([DBHEADER], [$dbheader])
44 AC_DEFINE([HAVE_DBHEADER], [1],
45 [Define if you have user supplied header location])
47 [if test "x$with_berkeley_db_include" != xcheck; then
49 [--with-berkeley-db-include was given but include test failed])
60 dnl db_create is used by db3 and db4 and db5
62 AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db-5 db5 db4 db3 db, [
65 #include <$dbheader/db.h>
72 #elif defined(HAVE_DB3_DB_H)
79 if test "$ac_cv_func_db_create" = "yes"; then
81 if test "$ac_cv_funclib_db_create" != "yes"; then
82 DB3LIB="$ac_cv_funclib_db_create"
86 AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library])
89 dnl dbopen is used by db1/db2
91 AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
93 #if defined(HAVE_DB2_DB_H)
95 #elif defined(HAVE_DB_H)
100 ],[NULL, 0, 0, 0, NULL])
102 if test "$ac_cv_func_dbopen" = "yes"; then
104 if test "$ac_cv_funclib_dbopen" != "yes"; then
105 DB1LIB="$ac_cv_funclib_dbopen"
109 AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
112 dnl test for ndbm compatability
114 if test "$ac_cv_func_dbm_firstkey" != yes; then
115 AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
117 #define DB_DBM_HSEARCH 1
122 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
123 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
124 NDBMLIB="$ac_cv_funclib_dbm_firstkey"
128 AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
129 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
131 $as_unset ac_cv_func_dbm_firstkey
132 $as_unset ac_cv_funclib_dbm_firstkey
139 AS_IF([test "x$enable_mdb_db" != xno],
140 [AC_CHECK_HEADER(lmdb.h, [
141 AC_CHECK_LIB(lmdb, mdb_env_create, have_lmdb=yes; LMDBLIB="-llmdb"
142 AC_DEFINE(HAVE_LMDB, 1, [define if you have the LMDB library]))])])
144 for db_type in unknown $db_type_preference; do
145 if eval test \"x\$have_${db_type}\" = xyes -o ${db_type} = sqlite; then
151 AS_IF([test "x$have_db3" = xyes -a "$db_type" = unknown], db_type=db3, db_type="$db_type")
152 AS_IF([test "x$have_db1" = xyes -a "$db_type" = unknown], db_type=db1, db_type="$db_type")
153 AS_IF([test "x$have_lmdb" = xyes -a "$db_type" = unknown], db_type=lmdb, db_type="$db_type")
155 if test "$enable_ndbm_db" != "no"; then
157 if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
164 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
166 #if defined(HAVE_NDBM_H)
168 #elif defined(HAVE_DBM_H)
174 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
175 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
176 NDBMLIB="$ac_cv_funclib_dbm_firstkey"
180 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
184 $as_unset ac_cv_func_dbm_firstkey
185 $as_unset ac_cv_funclib_dbm_firstkey
191 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
193 #include <gdbm/ndbm.h>
197 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
198 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
199 NDBMLIB="$ac_cv_funclib_dbm_firstkey"
203 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
205 if test "$db_type" = "unknown"; then
213 if test "$have_ndbm" = "yes"; then
214 AC_MSG_CHECKING([if ndbm is implemented with db])
215 AC_RUN_IFELSE([AC_LANG_SOURCE([[
218 #if defined(HAVE_GDBM_NDBM_H)
219 #include <gdbm/ndbm.h>
220 #elif defined(HAVE_NDBM_H)
222 #elif defined(HAVE_DBM_H)
225 int main(int argc, char **argv)
229 d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
235 if test -f conftest.db; then
237 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
240 fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])])
243 AM_CONDITIONAL(HAVE_DB1, test "$have_db1" = yes)dnl
244 AM_CONDITIONAL(HAVE_DB3, test "$have_db3" = yes)dnl
245 AM_CONDITIONAL(HAVE_LMDB, test "$have_lmdb" = yes)dnl
246 AM_CONDITIONAL(HAVE_NDBM, test "$have_ndbm" = yes)dnl
247 AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl
249 ## it's probably not correct to include LDFLAGS here, but we might
250 ## need it, for now just add any possible -L
252 for i in $LDFLAGS; do
259 LMDBLIB="$z $LMDBLIB"
260 NDMBLIB="$z $NDBMLIB"
267 AC_SUBST(db_type_preference)dnl