1 dnl $Heimdal: db.m4 15456 2005-06-16 21:04:43Z lha $
4 dnl tests for various db libraries
7 AC_ARG_ENABLE(berkeley-db,
8 AS_HELP_STRING([--disable-berkeley-db],
9 [if you don't want berkeley db]),[
12 AC_ARG_ENABLE(ndbm-db,
13 AS_HELP_STRING([--disable-ndbm-db],
14 [if you don't want ndbm db]),[
20 if test "$enable_berkeley_db" != no; then
29 dnl db_create is used by db3 and db4
31 AC_FIND_FUNC_NO_LIBS(db_create, db4 db3 db, [
35 #elif defined(HAVE_DB3_DB_H)
42 if test "$ac_cv_func_db_create" = "yes"; then
44 if test "$ac_cv_funclib_db_create" != "yes"; then
45 DBLIB="$ac_cv_funclib_db_create"
49 AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4 library])
52 dnl dbopen is used by db1/db2
54 AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
56 #if defined(HAVE_DB2_DB_H)
58 #elif defined(HAVE_DB_185_H)
60 #elif defined(HAVE_DB_H)
65 ],[NULL, 0, 0, 0, NULL])
67 if test "$ac_cv_func_dbopen" = "yes"; then
69 if test "$ac_cv_funclib_dbopen" != "yes"; then
70 DBLIB="$ac_cv_funclib_dbopen"
74 AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
78 dnl test for ndbm compatability
80 if test "$ac_cv_func_dbm_firstkey" != yes; then
81 AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
83 #define DB_DBM_HSEARCH 1
88 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
89 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
90 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
94 AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
95 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
97 $as_unset ac_cv_func_dbm_firstkey
98 $as_unset ac_cv_funclib_dbm_firstkey
104 if test "$enable_ndbm_db" != "no"; then
106 if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
113 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
115 #if defined(HAVE_NDBM_H)
117 #elif defined(HAVE_DBM_H)
123 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
124 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
125 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
129 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
131 if test "$db_type" = "unknown"; then
137 $as_unset ac_cv_func_dbm_firstkey
138 $as_unset ac_cv_funclib_dbm_firstkey
144 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
146 #include <gdbm/ndbm.h>
150 if test "$ac_cv_func_dbm_firstkey" = "yes"; then
151 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
152 LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
156 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
158 if test "$db_type" = "unknown"; then
167 if test "$have_ndbm" = "yes"; then
168 AC_MSG_CHECKING([if ndbm is implemented with db])
169 AC_RUN_IFELSE([AC_LANG_SOURCE([[
172 #if defined(HAVE_GDBM_NDBM_H)
173 #include <gdbm/ndbm.h>
174 #elif defined(HAVE_NDBM_H)
176 #elif defined(HAVE_DBM_H)
179 int main(int argc, char **argv)
183 d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
189 if test -f conftest.db; then
191 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
194 fi],[AC_MSG_RESULT([no])])
197 AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
198 AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
199 AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
201 ## it's probably not correct to include LDFLAGS here, but we might
202 ## need it, for now just add any possible -L
204 for i in $LDFLAGS; do
211 AC_SUBST(LIB_NDBM)dnl