stasis-aries-wal/m4/db.m4

183 lines
4.6 KiB
Text
Raw Permalink Normal View History

dnl
dnl Autoconf support for finding Berkeley DB
dnl
AC_DEFUN([AC_DB_HELP], [
AC_MSG_NOTICE([
Could not find Berkeley DB. Stasis includes benchmarks that use it.
They will not be built.
If your installed version is not one of the ones searched for, you may
have to specify it with --with-dbver.
If your installation is in a non-standard path, you can specify
it with --with-db=DIR.
])])
dnl
dnl Main macro for finding a usable db installation
dnl
AC_DEFUN([AC_CONFIG_DB], [
2006-07-21 01:03:01 +00:00
ac_dbvers='4.4 4.3 4.2'
ac_dbdir='yes'
AC_ARG_WITH(db,
AC_HELP_STRING([--with-db=DIR],
[location of a Berkeley DB installation (default system)]),
ac_dbdir=$withval)
AC_ARG_WITH(dbver,
AC_HELP_STRING([--with-dbver=VERSION],
Berkeley DB versions to try (default 4.3 or 4.2)),
ac_dbvers=$withval)
dnl
dnl First make sure we even want it
dnl
if test x$ac_dbdir = xno ; then
DB_ENABLED=0
else
DB_ENABLED=1
dnl
dnl Now check if we have a cached value, and if not, find it.
dnl
if test ! x$dtn_cv_path_db_h = x ; then
2005-03-21 08:59:20 +00:00
echo "checking for Berkeley DB installation... (cached) $dtn_cv_path_db_h/db.h, $dtn_cv_path_db_lib -l$dtn_cv_lib_db"
# echo "checking for Berkeley DB installation... (cached) $dtn_cv_path_db_h/db_cxx.h,
#$dtn_cv_path_db_lib -l$dtn_cv_lib_db"
else
AC_FIND_DB
fi
if test ! $dtn_cv_path_db_h = /usr/include ; then
CPPFLAGS="$CPPFLAGS -I$dtn_cv_path_db_h"
fi
if test ! $dtn_cv_path_db_lib = /usr/lib ; then
LDFLAGS="$LDFLAGS -L$dtn_cv_path_db_lib"
fi
#LIBS="$LIBS -l$dtn_cv_lib_db"
DB_LIBS="-l$dtn_cv_lib_db"
fi # DB_ENABLED
AC_SUBST(DB_ENABLED)
AC_SUBST(DB_LIBS)
AM_CONDITIONAL(DB_ENABLED, test x$ac_dbdir != xno)
#AM_CONDITIONAL(DB_ENABLED, $DB_ENABLED)
])
dnl
dnl Find db
dnl
AC_DEFUN([AC_FIND_DB], [
dtn_cv_path_db_h=
dtn_cv_path_db_lib=
dtn_cv_lib_db=
ac_save_CPPFLAGS="$CPPFLAGS"
ac_save_LDFLAGS="$LDFLAGS"
ac_save_LIBS="$LIBS"
AC_LANG_PUSH(C++)
for ac_dbver in $ac_dbvers ; do
ac_dbver_major=`echo $ac_dbver | cut -d . -f1`
ac_dbver_minor=`echo $ac_dbver | cut -d . -f2`
if test ! x"$ac_dbdir" = x"yes" ; then
ac_dbincdirs=$ac_dbdir/include
else
ac_dbincdirs="/usr/include /usr/local/include/db4 /usr/local/include/db42"
ac_dbincdirs="$ac_dbincdirs /usr/include/db$ac_dbver"
ac_dbincdirs="$ac_dbincdirs /usr/local/BerkeleyDB.$ac_dbver/include"
fi
if test ! x"$ac_dbdir" = x"yes" ; then
ac_dblibdirs="$ac_dbdir/lib"
else
ac_dblibdirs="/usr/lib /usr/local/lib /usr/local/lib/db42"
ac_dblibdirs="$ac_dblibdirs /usr/local/BerkeleyDB.$ac_dbver/lib"
fi
for ac_dbincdir in $ac_dbincdirs; do
CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dbincdir"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
dnl
dnl First check the version in the header file. If there's a match,
dnl fall through to the other check to make sure it links.
dnl If not, then we can break out of the two inner loops.
dnl
AC_MSG_CHECKING([for Berkeley DB header (version $ac_dbver) in $ac_dbincdir])
AC_LINK_IFELSE(
AC_LANG_PROGRAM(
[
2005-03-21 08:59:20 +00:00
#include <db.h>
#if (DB_VERSION_MAJOR != ${ac_dbver_major}) || \
(DB_VERSION_MINOR != ${ac_dbver_minor})
#error "incorrect version"
#endif
],
[
]),
[
AC_MSG_RESULT([yes])
],
[
AC_MSG_RESULT([no])
continue
])
for ac_dblibdir in $ac_dblibdirs; do
2005-03-21 08:59:20 +00:00
for ac_dblib in db-$ac_dbver; do
LDFLAGS="$ac_save_LDFLAGS -L$ac_dblibdir"
LIBS="$ac_save_LIBS -l$ac_dblib"
AC_MSG_CHECKING([for Berkeley DB library in $ac_dblibdir, -l$ac_dblib])
AC_LINK_IFELSE(
AC_LANG_PROGRAM(
[
2005-03-21 08:59:20 +00:00
#include <db.h>
],
[
DB *db;
db_create(&db, NULL, 0);
]),
[
AC_MSG_RESULT([yes])
dtn_cv_path_db_h=$ac_dbincdir
dtn_cv_path_db_lib=$ac_dblibdir
dtn_cv_lib_db=$ac_dblib
break 4
],
[
AC_MSG_RESULT([no])
])
done
done
done
done
AC_LANG_POP(C++)
CPPFLAGS="$ac_save_CPPFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
if test x$dtn_cv_path_db_h = x ; then
AC_DB_HELP
#AC_MSG_WARN([can't find usable Berkeley DB installation])
DB_ENABLED=0
fi
])