db.m4 revision 1.1.1.2.10.1
1dnl Id 2dnl 3dnl tests for various db libraries 4dnl 5 6AC_DEFUN([rk_DB],[ 7AC_ARG_WITH(berkeley-db, 8 AS_HELP_STRING([--with-berkeley-db], 9 [enable support for berkeley db @<:@default=check@:>@]), 10 [], 11 [with_berkeley_db=check]) 12 13dbheader="" 14AC_ARG_WITH(berkeley-db-include, 15 AS_HELP_STRING([--with-berkeley-db-include=dir], 16 [use berkeley-db headers in dir]), 17 [dbheader=$withval], 18 [with_berkeley_db_include=check]) 19 20AC_ARG_ENABLE(ndbm-db, 21 AS_HELP_STRING([--disable-ndbm-db], 22 [if you don't want ndbm db]),[ 23]) 24 25have_ndbm=no 26db_type=unknown 27 28AS_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]) 34 ], 35 [if test "x$with_berkeley_db_include" != xcheck; then 36 AC_MSG_FAILURE( 37 [--with-berkeley-db-include was given but include test failed]) 38 fi 39 ])], 40 [AC_CHECK_HEADERS([ \ 41 db6/db.h \ 42 db5/db.h \ 43 db4/db.h \ 44 db3/db.h \ 45 db.h \ 46 ])]) 47 48dnl db_create is used by db3 and db4 and db5 49 50 AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db5 db4 db3 db, [ 51 #include <stdio.h> 52 #ifdef HAVE_DBHEADER 53 #include <$dbheader/db.h> 54 #elif HAVE_DB6_DB_H 55 #include <db6/db.h> 56 #elif HAVE_DB5_DB_H 57 #include <db5/db.h> 58 #elif HAVE_DB4_DB_H 59 #include <db4/db.h> 60 #elif defined(HAVE_DB3_DB_H) 61 #include <db3/db.h> 62 #else 63 #include <db.h> 64 #endif 65 ],[NULL, NULL, 0]) 66 67 if test "$ac_cv_func_db_create" = "yes"; then 68 db_type=db3 69 if test "$ac_cv_funclib_db_create" != "yes"; then 70 DBLIB="$ac_cv_funclib_db_create" 71 else 72 DBLIB="" 73 fi 74 AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library]) 75 fi 76 77dnl dbopen is used by db1/db2 78 79 AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [ 80 #include <stdio.h> 81 #if defined(HAVE_DB2_DB_H) 82 #include <db2/db.h> 83 #elif defined(HAVE_DB_H) 84 #include <db.h> 85 #else 86 #error no db.h 87 #endif 88 ],[NULL, 0, 0, 0, NULL]) 89 90 if test "$ac_cv_func_dbopen" = "yes"; then 91 db_type=db1 92 if test "$ac_cv_funclib_dbopen" != "yes"; then 93 DBLIB="$ac_cv_funclib_dbopen" 94 else 95 DBLIB="" 96 fi 97 AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library]) 98 fi 99 100dnl test for ndbm compatability 101 102 if test "$ac_cv_func_dbm_firstkey" != yes; then 103 AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [ 104 #include <stdio.h> 105 #define DB_DBM_HSEARCH 1 106 #include <db.h> 107 DBM *dbm; 108 ],[NULL]) 109 110 if test "$ac_cv_func_dbm_firstkey" = "yes"; then 111 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then 112 LIB_NDBM="$ac_cv_funclib_dbm_firstkey" 113 else 114 LIB_NDBM="" 115 fi 116 AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db]) 117 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)]) 118 else 119 $as_unset ac_cv_func_dbm_firstkey 120 $as_unset ac_cv_funclib_dbm_firstkey 121 fi 122 fi 123 124]) # fi berkeley db 125 126if test "$enable_ndbm_db" != "no"; then 127 128 if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then 129 130 AC_CHECK_HEADERS([ \ 131 dbm.h \ 132 ndbm.h \ 133 ]) 134 135 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [ 136 #include <stdio.h> 137 #if defined(HAVE_NDBM_H) 138 #include <ndbm.h> 139 #elif defined(HAVE_DBM_H) 140 #include <dbm.h> 141 #endif 142 DBM *dbm; 143 ],[NULL]) 144 145 if test "$ac_cv_func_dbm_firstkey" = "yes"; then 146 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then 147 LIB_NDBM="$ac_cv_funclib_dbm_firstkey" 148 else 149 LIB_NDBM="" 150 fi 151 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl 152 have_ndbm=yes 153 if test "$db_type" = "unknown"; then 154 db_type=ndbm 155 DBLIB="$LIB_NDBM" 156 fi 157 else 158 159 $as_unset ac_cv_func_dbm_firstkey 160 $as_unset ac_cv_funclib_dbm_firstkey 161 162 AC_CHECK_HEADERS([ \ 163 gdbm/ndbm.h \ 164 ]) 165 166 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [ 167 #include <stdio.h> 168 #include <gdbm/ndbm.h> 169 DBM *dbm; 170 ],[NULL]) 171 172 if test "$ac_cv_func_dbm_firstkey" = "yes"; then 173 if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then 174 LIB_NDBM="$ac_cv_funclib_dbm_firstkey" 175 else 176 LIB_NDBM="" 177 fi 178 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl 179 have_ndbm=yes 180 if test "$db_type" = "unknown"; then 181 db_type=ndbm 182 DBLIB="$LIB_NDBM" 183 fi 184 fi 185 fi 186 fi #enable_ndbm_db 187fi # unknown 188 189if test "$have_ndbm" = "yes"; then 190 AC_MSG_CHECKING([if ndbm is implemented with db]) 191 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 192#include <unistd.h> 193#include <fcntl.h> 194#if defined(HAVE_GDBM_NDBM_H) 195#include <gdbm/ndbm.h> 196#elif defined(HAVE_NDBM_H) 197#include <ndbm.h> 198#elif defined(HAVE_DBM_H) 199#include <dbm.h> 200#endif 201int main(int argc, char **argv) 202{ 203 DBM *d; 204 205 d = dbm_open("conftest", O_RDWR | O_CREAT, 0666); 206 if (d == NULL) 207 return 1; 208 dbm_close(d); 209 return 0; 210}]])],[ 211 if test -f conftest.db; then 212 AC_MSG_RESULT([yes]) 213 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)]) 214 else 215 AC_MSG_RESULT([no]) 216 fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])]) 217fi 218 219AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl 220AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl 221AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl 222AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl 223 224## it's probably not correct to include LDFLAGS here, but we might 225## need it, for now just add any possible -L 226z="" 227for i in $LDFLAGS; do 228 case "$i" in 229 -L*) z="$z $i";; 230 esac 231done 232DBLIB="$z $DBLIB" 233AC_SUBST(DBLIB)dnl 234AC_SUBST(LIB_NDBM)dnl 235]) 236