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])
47 dnl db_create is used by db3 and db4 and db5
49 AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db5 db4 db3 db, [
52 #include <$dbheader/db.h>
57 #elif defined(HAVE_DB3_DB_H)
64 if test "$ac_cv_func_db_create" = "yes"; then
66 if test "$ac_cv_funclib_db_create" != "yes"; then
67 DBLIB="$ac_cv_funclib_db_create"
71 AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library])
74 dnl dbopen is used by db1/db2
76 AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
78 #if defined(HAVE_DB2_DB_H)
80 #elif defined(HAVE_DB_H)
85 ],[NULL, 0, 0, 0, NULL])
87 if test "$ac_cv_func_dbopen" = "yes"; then
89 if test "$ac_cv_funclib_dbopen" != "yes"; then
90 DBLIB="$ac_cv_funclib_dbopen"
94 AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
97 dnl test for ndbm compatability
99 if test "$ac_cv_func_dbm_firstkey" != yes; then
100 AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
102 #define DB_DBM_HSEARCH 1
107 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
108 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
109 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
113 AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
114 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
116 $as_unset ac_cv_func_dbm_firstkey
117 $as_unset ac_cv_funclib_dbm_firstkey
123 if test "$enable_ndbm_db" != "no"; then
125 if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
132 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
134 #if defined(HAVE_NDBM_H)
136 #elif defined(HAVE_DBM_H)
142 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
143 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
144 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
148 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
150 if test "$db_type" = "unknown"; then
156 $as_unset ac_cv_func_dbm_firstkey
157 $as_unset ac_cv_funclib_dbm_firstkey
163 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
165 #include <gdbm/ndbm.h>
169 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
170 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
171 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
175 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
177 if test "$db_type" = "unknown"; then
186 if test "$have_ndbm" = "yes"; then
187 AC_MSG_CHECKING([if ndbm is implemented with db])
188 AC_RUN_IFELSE([AC_LANG_SOURCE([[
191 #if defined(HAVE_GDBM_NDBM_H)
192 #include <gdbm/ndbm.h>
193 #elif defined(HAVE_NDBM_H)
195 #elif defined(HAVE_DBM_H)
198 int main(int argc, char **argv)
202 d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
208 if test -f conftest.db; then
210 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
213 fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])])
216 AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
217 AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
218 AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
219 AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl
221 ## it's probably not correct to include LDFLAGS here, but we might
222 ## need it, for now just add any possible -L
224 for i in $LDFLAGS; do
231 AC_SUBST(LIB_NDBM)dnl