3 dnl tests for various db libraries
7 AC_ARG_WITH(berkeley-db,
8 AS_HELP_STRING([--with-berkeley-db],
9 [enable support for berkeley db @<:@default=check@:>@]),
11 [with_berkeley_db=check])
14 AC_ARG_WITH(berkeley-db-include,
15 AS_HELP_STRING([--with-berkeley-db-include=dir],
16 [use berkeley-db headers in dir]),
18 [with_berkeley_db_include=check])
20 AC_ARG_ENABLE(ndbm-db,
21 AS_HELP_STRING([--disable-ndbm-db],
22 [if you don't want ndbm db]),[
28 AS_IF([test "x$with_berkeley_db" != xno],
29 [AS_IF([test "x$with_berkeley_db_include" != xcheck],
30 [AC_CHECK_HEADERS(["$dbheader/db.h"],
31 [AC_SUBST([DBHEADER], [$dbheader])
32 AC_DEFINE([HAVE_DBHEADER], [1],
33 [Define if you have user supplied header location])
35 [if test "x$with_berkeley_db_include" != xcheck; then
37 [--with-berkeley-db-include was given but include test failed])
48 dnl db_create is used by db3 and db4 and db5
50 AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db5 db4 db3 db, [
53 #include <$dbheader/db.h>
58 #elif defined(HAVE_DB3_DB_H)
65 if test "$ac_cv_func_db_create" = "yes"; then
67 if test "$ac_cv_funclib_db_create" != "yes"; then
68 DBLIB="$ac_cv_funclib_db_create"
72 AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library])
75 dnl dbopen is used by db1/db2
77 AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
79 #if defined(HAVE_DB2_DB_H)
81 #elif defined(HAVE_DB_185_H)
83 #elif defined(HAVE_DB_H)
88 ],[NULL, 0, 0, 0, NULL])
90 if test "$ac_cv_func_dbopen" = "yes"; then
92 if test "$ac_cv_funclib_dbopen" != "yes"; then
93 DBLIB="$ac_cv_funclib_dbopen"
97 AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
101 dnl test for ndbm compatability
103 if test "$ac_cv_func_dbm_firstkey" != yes; then
104 AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
106 #define DB_DBM_HSEARCH 1
111 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
112 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
113 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
117 AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
118 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
120 $as_unset ac_cv_func_dbm_firstkey
121 $as_unset ac_cv_funclib_dbm_firstkey
127 if test "$enable_ndbm_db" != "no"; then
129 if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
136 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
138 #if defined(HAVE_NDBM_H)
140 #elif defined(HAVE_DBM_H)
146 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
147 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
148 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
152 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
154 if test "$db_type" = "unknown"; then
160 $as_unset ac_cv_func_dbm_firstkey
161 $as_unset ac_cv_funclib_dbm_firstkey
167 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
169 #include <gdbm/ndbm.h>
173 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
174 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
175 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
179 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
181 if test "$db_type" = "unknown"; then
190 if test "$have_ndbm" = "yes"; then
191 AC_MSG_CHECKING([if ndbm is implemented with db])
192 AC_RUN_IFELSE([AC_LANG_SOURCE([[
195 #if defined(HAVE_GDBM_NDBM_H)
196 #include <gdbm/ndbm.h>
197 #elif defined(HAVE_NDBM_H)
199 #elif defined(HAVE_DBM_H)
202 int main(int argc, char **argv)
206 d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
212 if test -f conftest.db; then
214 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
217 fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])])
220 AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
221 AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
222 AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
223 AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl
225 ## it's probably not correct to include LDFLAGS here, but we might
226 ## need it, for now just add any possible -L
228 for i in $LDFLAGS; do
235 AC_SUBST(LIB_NDBM)dnl