2008-05-07 13:39:42 +00:00
|
|
|
dnl $Id: db.m4 15456 2005-06-16 21:04:43Z lha $
|
2001-02-13 16:46:19 +00:00
|
|
|
dnl
|
|
|
|
dnl tests for various db libraries
|
|
|
|
dnl
|
2002-08-30 21:23:27 +00:00
|
|
|
AC_DEFUN([rk_DB],[
|
|
|
|
AC_ARG_ENABLE(berkeley-db,
|
2008-05-07 13:39:42 +00:00
|
|
|
AS_HELP_STRING([--disable-berkeley-db],
|
2002-08-30 21:23:27 +00:00
|
|
|
[if you don't want berkeley db]),[
|
2001-02-13 16:46:19 +00:00
|
|
|
])
|
2002-02-19 15:46:56 +00:00
|
|
|
|
2008-05-07 13:39:42 +00:00
|
|
|
AC_ARG_ENABLE(ndbm-db,
|
|
|
|
AS_HELP_STRING([--disable-ndbm-db],
|
|
|
|
[if you don't want ndbm db]),[
|
|
|
|
])
|
|
|
|
|
2002-02-19 15:46:56 +00:00
|
|
|
have_ndbm=no
|
|
|
|
db_type=unknown
|
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
if test "$enable_berkeley_db" != no; then
|
2002-02-19 15:46:56 +00:00
|
|
|
|
2001-02-13 16:46:19 +00:00
|
|
|
AC_CHECK_HEADERS([ \
|
2002-08-30 21:23:27 +00:00
|
|
|
db4/db.h \
|
|
|
|
db3/db.h \
|
2001-02-13 16:46:19 +00:00
|
|
|
db.h \
|
|
|
|
db_185.h \
|
|
|
|
])
|
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
dnl db_create is used by db3 and db4
|
2001-02-13 16:46:19 +00:00
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
AC_FIND_FUNC_NO_LIBS(db_create, db4 db3 db, [
|
2002-02-19 15:46:56 +00:00
|
|
|
#include <stdio.h>
|
2002-08-30 21:23:27 +00:00
|
|
|
#ifdef HAVE_DB4_DB_H
|
|
|
|
#include <db4/db.h>
|
|
|
|
#elif defined(HAVE_DB3_DB_H)
|
|
|
|
#include <db3/db.h>
|
|
|
|
#else
|
2002-02-19 15:46:56 +00:00
|
|
|
#include <db.h>
|
2002-08-30 21:23:27 +00:00
|
|
|
#endif
|
2002-02-19 15:46:56 +00:00
|
|
|
],[NULL, NULL, 0])
|
2001-02-13 16:46:19 +00:00
|
|
|
|
2002-02-19 15:46:56 +00:00
|
|
|
if test "$ac_cv_func_db_create" = "yes"; then
|
|
|
|
db_type=db3
|
|
|
|
if test "$ac_cv_funclib_db_create" != "yes"; then
|
|
|
|
DBLIB="$ac_cv_funclib_db_create"
|
|
|
|
else
|
|
|
|
DBLIB=""
|
|
|
|
fi
|
2002-08-30 21:23:27 +00:00
|
|
|
AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4 library])
|
2002-02-19 15:46:56 +00:00
|
|
|
else
|
|
|
|
|
|
|
|
dnl dbopen is used by db1/db2
|
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
|
2002-02-19 15:46:56 +00:00
|
|
|
#include <stdio.h>
|
2002-08-30 21:23:27 +00:00
|
|
|
#if defined(HAVE_DB2_DB_H)
|
|
|
|
#include <db2/db.h>
|
|
|
|
#elif defined(HAVE_DB_185_H)
|
2002-02-19 15:46:56 +00:00
|
|
|
#include <db_185.h>
|
|
|
|
#elif defined(HAVE_DB_H)
|
|
|
|
#include <db.h>
|
|
|
|
#else
|
|
|
|
#error no db.h
|
|
|
|
#endif
|
|
|
|
],[NULL, 0, 0, 0, NULL])
|
|
|
|
|
|
|
|
if test "$ac_cv_func_dbopen" = "yes"; then
|
|
|
|
db_type=db1
|
|
|
|
if test "$ac_cv_funclib_dbopen" != "yes"; then
|
|
|
|
DBLIB="$ac_cv_funclib_dbopen"
|
|
|
|
else
|
|
|
|
DBLIB=""
|
|
|
|
fi
|
|
|
|
AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
dnl test for ndbm compatability
|
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
if test "$ac_cv_func_dbm_firstkey" != yes; then
|
|
|
|
AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
|
|
|
|
#include <stdio.h>
|
|
|
|
#define DB_DBM_HSEARCH 1
|
|
|
|
#include <db.h>
|
|
|
|
DBM *dbm;
|
|
|
|
],[NULL])
|
|
|
|
|
|
|
|
if test "$ac_cv_func_dbm_firstkey" = "yes"; then
|
|
|
|
if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
|
|
|
|
LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
|
|
|
|
else
|
|
|
|
LIB_NDBM=""
|
|
|
|
fi
|
|
|
|
AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
|
|
|
|
AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
|
2002-02-19 15:46:56 +00:00
|
|
|
else
|
2002-08-30 21:23:27 +00:00
|
|
|
$as_unset ac_cv_func_dbm_firstkey
|
|
|
|
$as_unset ac_cv_funclib_dbm_firstkey
|
2002-02-19 15:46:56 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi # berkeley db
|
|
|
|
|
2008-05-07 13:39:42 +00:00
|
|
|
if test "$enable_ndbm_db" != "no"; then
|
2002-02-19 15:46:56 +00:00
|
|
|
|
2008-05-07 13:39:42 +00:00
|
|
|
if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
|
2002-02-19 15:46:56 +00:00
|
|
|
|
|
|
|
AC_CHECK_HEADERS([ \
|
2008-05-07 13:39:42 +00:00
|
|
|
dbm.h \
|
|
|
|
ndbm.h \
|
2002-02-19 15:46:56 +00:00
|
|
|
])
|
2008-05-07 13:39:42 +00:00
|
|
|
|
|
|
|
AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
|
2002-02-19 15:46:56 +00:00
|
|
|
#include <stdio.h>
|
2008-05-07 13:39:42 +00:00
|
|
|
#if defined(HAVE_NDBM_H)
|
|
|
|
#include <ndbm.h>
|
|
|
|
#elif defined(HAVE_DBM_H)
|
|
|
|
#include <dbm.h>
|
|
|
|
#endif
|
2002-02-19 15:46:56 +00:00
|
|
|
DBM *dbm;
|
|
|
|
],[NULL])
|
2008-05-07 13:39:42 +00:00
|
|
|
|
2002-02-19 15:46:56 +00:00
|
|
|
if test "$ac_cv_func_dbm_firstkey" = "yes"; then
|
|
|
|
if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
|
2008-05-07 13:39:42 +00:00
|
|
|
LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
|
2002-02-19 15:46:56 +00:00
|
|
|
else
|
2008-05-07 13:39:42 +00:00
|
|
|
LIB_NDBM=""
|
2002-02-19 15:46:56 +00:00
|
|
|
fi
|
|
|
|
AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
|
|
|
|
have_ndbm=yes
|
|
|
|
if test "$db_type" = "unknown"; then
|
2008-05-07 13:39:42 +00:00
|
|
|
db_type=ndbm
|
|
|
|
DBLIB="$LIB_NDBM"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
|
|
|
|
$as_unset ac_cv_func_dbm_firstkey
|
|
|
|
$as_unset ac_cv_funclib_dbm_firstkey
|
|
|
|
|
|
|
|
AC_CHECK_HEADERS([ \
|
|
|
|
gdbm/ndbm.h \
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <gdbm/ndbm.h>
|
|
|
|
DBM *dbm;
|
|
|
|
],[NULL])
|
|
|
|
|
|
|
|
if test "$ac_cv_func_dbm_firstkey" = "yes"; then
|
|
|
|
if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
|
|
|
|
LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
|
|
|
|
else
|
|
|
|
LIB_NDBM=""
|
|
|
|
fi
|
|
|
|
AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
|
|
|
|
have_ndbm=yes
|
|
|
|
if test "$db_type" = "unknown"; then
|
|
|
|
db_type=ndbm
|
|
|
|
DBLIB="$LIB_NDBM"
|
|
|
|
fi
|
2002-02-19 15:46:56 +00:00
|
|
|
fi
|
|
|
|
fi
|
2008-05-07 13:39:42 +00:00
|
|
|
fi #enable_ndbm_db
|
2002-02-19 15:46:56 +00:00
|
|
|
fi # unknown
|
|
|
|
|
|
|
|
if test "$have_ndbm" = "yes"; then
|
|
|
|
AC_MSG_CHECKING([if ndbm is implemented with db])
|
2008-05-07 13:39:42 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
2002-02-19 15:46:56 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#if defined(HAVE_GDBM_NDBM_H)
|
|
|
|
#include <gdbm/ndbm.h>
|
|
|
|
#elif defined(HAVE_NDBM_H)
|
|
|
|
#include <ndbm.h>
|
|
|
|
#elif defined(HAVE_DBM_H)
|
|
|
|
#include <dbm.h>
|
|
|
|
#endif
|
2008-05-07 13:39:42 +00:00
|
|
|
int main(int argc, char **argv)
|
2002-02-19 15:46:56 +00:00
|
|
|
{
|
|
|
|
DBM *d;
|
|
|
|
|
|
|
|
d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
|
|
|
|
if (d == NULL)
|
|
|
|
return 1;
|
|
|
|
dbm_close(d);
|
|
|
|
return 0;
|
2008-05-07 13:39:42 +00:00
|
|
|
}]])],[
|
2002-02-19 15:46:56 +00:00
|
|
|
if test -f conftest.db; then
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
|
|
|
|
else
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
fi],[AC_MSG_RESULT([no])])
|
2001-02-13 16:46:19 +00:00
|
|
|
fi
|
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
|
|
|
|
AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
|
|
|
|
AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
|
|
|
|
|
2002-09-16 21:04:40 +00:00
|
|
|
## it's probably not correct to include LDFLAGS here, but we might
|
|
|
|
## need it, for now just add any possible -L
|
|
|
|
z=""
|
|
|
|
for i in $LDFLAGS; do
|
|
|
|
case "$i" in
|
|
|
|
-L*) z="$z $i";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
DBLIB="$z $DBLIB"
|
2002-02-19 15:46:56 +00:00
|
|
|
AC_SUBST(DBLIB)dnl
|
|
|
|
AC_SUBST(LIB_NDBM)dnl
|
2001-02-13 16:46:19 +00:00
|
|
|
])
|