db.m4 revision 1.1.1.1
1dnl $Id: db.m4,v 1.1.1.1 2011/04/13 18:14:32 elric Exp $ 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 db5/db.h \ 42 db4/db.h \ 43 db3/db.h \ 44 db.h \ 45 ])]) 46 47dnl db_create is used by db3 and db4 and db5 48 49 AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db5 db4 db3 db, [ 50 #include <stdio.h> 51 #ifdef HAVE_DBHEADER 52 #include <$dbheader/db.h> 53 #elif HAVE_DB5_DB_H 54 #include <db5/db.h> 55 #elif HAVE_DB4_DB_H 56 #include <db4/db.h> 57 #elif defined(HAVE_DB3_DB_H) 58 #include <db3/db.h> 59 #else 60 #include <db.h> 61 #endif 62 ],[NULL, NULL, 0]) 63 64 if test "$ac_cv_func_db_create" = "yes"; then 65 db_type=db3 66 if test "$ac_cv_funclib_db_create" != "yes"; then 67 DBLIB="$ac_cv_funclib_db_create" 68 else 69 DBLIB="" 70 fi 71 AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library]) 72 fi 73 74dnl dbopen is used by db1/db2 75 76 AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [ 77 #include <stdio.h> 78 #if defined(HAVE_DB2_DB_H) 79 #include <db2/db.h> 80 #elif defined(HAVE_DB_H) 81 #include <db.h> 82 #else 83 #error no db.h 84 #endif 85 ],[NULL, 0, 0, 0, NULL]) 86 87 if test "$ac_cv_func_dbopen" = "yes"; then 88 db_type=db1 89 if test "$ac_cv_funclib_dbopen" != "yes"; then 90 DBLIB="$ac_cv_funclib_dbopen" 91 else 92 DBLIB="" 93 fi 94 AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library]) 95 fi 96 97dnl test for ndbm compatability 98 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, [ 101 #include <stdio.h> 102 #define DB_DBM_HSEARCH 1 103 #include <db.h> 104 DBM *dbm; 105 ],[NULL]) 106 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" 110 else 111 LIB_NDBM="" 112 fi 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)]) 115 else 116 $as_unset ac_cv_func_dbm_firstkey 117 $as_unset ac_cv_funclib_dbm_firstkey 118 fi 119 fi 120 121]) # fi berkeley db 122 123if test "$enable_ndbm_db" != "no"; then 124 125 if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then 126 127 AC_CHECK_HEADERS([ \ 128 dbm.h \ 129 ndbm.h \ 130 ]) 131 132 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [ 133 #include <stdio.h> 134 #if defined(HAVE_NDBM_H) 135 #include <ndbm.h> 136 #elif defined(HAVE_DBM_H) 137 #include <dbm.h> 138 #endif 139 DBM *dbm; 140 ],[NULL]) 141 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" 145 else 146 LIB_NDBM="" 147 fi 148 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl 149 have_ndbm=yes 150 if test "$db_type" = "unknown"; then 151 db_type=ndbm 152 DBLIB="$LIB_NDBM" 153 fi 154 else 155 156 $as_unset ac_cv_func_dbm_firstkey 157 $as_unset ac_cv_funclib_dbm_firstkey 158 159 AC_CHECK_HEADERS([ \ 160 gdbm/ndbm.h \ 161 ]) 162 163 AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [ 164 #include <stdio.h> 165 #include <gdbm/ndbm.h> 166 DBM *dbm; 167 ],[NULL]) 168 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" 172 else 173 LIB_NDBM="" 174 fi 175 AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl 176 have_ndbm=yes 177 if test "$db_type" = "unknown"; then 178 db_type=ndbm 179 DBLIB="$LIB_NDBM" 180 fi 181 fi 182 fi 183 fi #enable_ndbm_db 184fi # unknown 185 186if test "$have_ndbm" = "yes"; then 187 AC_MSG_CHECKING([if ndbm is implemented with db]) 188 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 189#include <unistd.h> 190#include <fcntl.h> 191#if defined(HAVE_GDBM_NDBM_H) 192#include <gdbm/ndbm.h> 193#elif defined(HAVE_NDBM_H) 194#include <ndbm.h> 195#elif defined(HAVE_DBM_H) 196#include <dbm.h> 197#endif 198int main(int argc, char **argv) 199{ 200 DBM *d; 201 202 d = dbm_open("conftest", O_RDWR | O_CREAT, 0666); 203 if (d == NULL) 204 return 1; 205 dbm_close(d); 206 return 0; 207}]])],[ 208 if test -f conftest.db; then 209 AC_MSG_RESULT([yes]) 210 AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)]) 211 else 212 AC_MSG_RESULT([no]) 213 fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])]) 214fi 215 216AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl 217AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl 218AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl 219AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl 220 221## it's probably not correct to include LDFLAGS here, but we might 222## need it, for now just add any possible -L 223z="" 224for i in $LDFLAGS; do 225 case "$i" in 226 -L*) z="$z $i";; 227 esac 228done 229DBLIB="$z $DBLIB" 230AC_SUBST(DBLIB)dnl 231AC_SUBST(LIB_NDBM)dnl 232]) 233