1 dnl $Id: db3-check.m4,v 1.11.6.6 2004-04-21 00:56:58 bfernhomberg Exp $
2 dnl Autoconf macro to check for the Berkeley DB library
4 AC_DEFUN([AC_PATH_BDB],
8 bdb_search_dirs="/usr/local/include/db4 /usr/local/include /usr/include/db4 /usr/include"
10 dnl make sure atalk_libname is defined beforehand
11 [[ -n "$atalk_libname" ]] || AC_MSG_ERROR([internal error, atalk_libname undefined])
14 [ --with-bdb=PATH specify path to Berkeley DB installation[[auto]]],
15 if test "x$withval" = "xno"; then
17 elif test "x$withval" = "xyes"; then
20 bdb_search_dirs="$withval/include/db4 $withval/include $withval"
25 if test "x$dobdbsearch" = "xyes"; then
26 for bdbdir in $bdb_search_dirs; do
27 AC_MSG_CHECKING([for Berkeley DB headers in $bdbdir])
28 if test -f "$bdbdir/db.h" ; then
30 bdblibdir="`echo $bdbdir | sed 's/\/include\/db4$//'`"
31 bdblibdir="`echo $bdblibdir | sed 's/\/include$//'`"
32 bdblibdir="${bdblibdir}/${atalk_libname}"
33 bdbbindir="`echo $bdbdir | sed 's/include\/db4$/bin/'`"
34 bdbbindir="`echo $bdbbindir | sed 's/include$/bin/'`"
37 savedldflags="$LDFLAGS"
38 savedcppflags="$CPPFLAGS"
40 CPPFLAGS="$CFLAGS -I$bdbdir"
42 LDFLAGS="-L$bdblibdir $LDFLAGS"
44 dnl This check breaks if bdb was configured with --with-uniquename, removed for now
45 dnl dnl db_create is BDB >3 specific
46 dnl AC_CHECK_LIB(db, db_create, [
49 dnl BDB_LIBS="-ldb"], [
50 dnl AC_CHECK_LIB(db4, db_create, [
52 dnl LIBS="$LIBS -ldb4"
53 dnl BDB_LIBS="-ldb4"])
60 dnl check for header ... should only fail if the header cannot be compiled
61 dnl it does exist, otherwise we wouldn't be here
63 if test "x$bdbfound" = "xyes"; then
64 AC_CHECK_HEADERS(db.h, bdbfound=yes, bdbfound=no)
67 if test "x$bdbfound" = "xno"; then
68 AC_MSG_WARN([Berkeley DB libraries found, but required header files cannot be used!!!])
71 dnl check we have the correct bdb version
72 AC_MSG_CHECKING([Berkeley DB version >= 4.1])
80 #define DB_MAJOR_REQ 4
81 #define DB_MINOR_REQ 1
82 #define DB_PATCH_REQ 0
86 int major, minor, patch;
89 version_str = db_version(&major, &minor, &patch);
91 /* check header version */
92 if (DB_VERSION_MAJOR < DB_MAJOR_REQ || DB_VERSION_MINOR < DB_MINOR_REQ ||
93 DB_VERSION_PATCH < DB_PATCH_REQ ) {
94 printf("header file version too old (%d.%d.%d), ", DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
98 /* check library version */
99 if (major < DB_MAJOR_REQ || minor < DB_MINOR_REQ || patch < DB_PATCH_REQ) {
100 printf("library version too old (%d.%d.%d), ",major, minor, patch);
104 /* check header and library match */
105 if ( major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR || patch != DB_VERSION_PATCH) {
106 printf("header/library version mismatch (%d.%d.%d/%d.%d.%d), ",
107 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, major, minor, patch);
111 printf("%d.%d.%d, ",major, minor, patch);
114 ], atalk_cv_bdbversion="yes", atalk_cv_bdbversion="no", atalk_cv_bdbversion="cross")
117 if test ${atalk_cv_bdbversion} = "yes"; then
124 if test "x$bdbfound" = "xyes"; then
125 if test "$bdbdir" != "/usr/include"; then
126 BDB_CFLAGS="-I$bdbdir"
128 if test "$bdblibdir" != "/usr/lib"; then
129 BDB_LIBS="-L$bdblibdir $BDB_LIBS"
132 BDB_PATH="`echo $bdbdir | sed 's,include\/db4$,,'`"
133 BDB_PATH="`echo $BDB_PATH | sed 's,include$,,'`"
135 CFLAGS="$savedcflags"
136 LDFLAGS="$savedldflags"
137 CPPFLAGS="$savedcppflags"
146 if test "x$bdbfound" = "xyes"; then
147 ifelse([$1], , :, [$1])
149 ifelse([$2], , :, [$2])