1 dnl $Id: db3-check.m4,v 1.11.6.4 2004-03-02 13:32:17 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"
12 [ --with-bdb=PATH specify path to Berkeley DB installation[[auto]]],
13 if test "x$withval" = "xno"; then
15 elif test "x$withval" = "xyes"; then
18 bdb_search_dirs="$withval/include/db4 $withval/include $withval"
23 if test "x$dobdbsearch" = "xyes"; then
24 for bdbdir in $bdb_search_dirs; do
25 AC_MSG_CHECKING([for Berkeley DB headers in $bdbdir])
26 if test -f "$bdbdir/db.h" ; then
28 bdblibdir="`echo $bdbdir | sed 's/include\/db4$/lib/'`"
29 bdblibdir="`echo $bdblibdir | sed 's/include$/lib/'`"
30 bdbbindir="`echo $bdbdir | sed 's/include\/db4$/bin/'`"
31 bdbbindir="`echo $bdbbindir | sed 's/include$/bin/'`"
34 savedldflags="$LDFLAGS"
35 savedcppflags="$CPPFLAGS"
37 CPPFLAGS="$CFLAGS -I$bdbdir"
39 LDFLAGS="-L$bdblibdir $LDFLAGS"
41 dnl This check breaks if bdb was configured with --with-uniquename, removed for now
42 dnl dnl db_create is BDB >3 specific
43 dnl AC_CHECK_LIB(db, db_create, [
46 dnl BDB_LIBS="-ldb"], [
47 dnl AC_CHECK_LIB(db4, db_create, [
49 dnl LIBS="$LIBS -ldb4"
50 dnl BDB_LIBS="-ldb4"])
57 dnl check for header ... should only fail if the header cannot be compiled
58 dnl it does exist, otherwise we wouldn't be here
60 if test "x$bdbfound" = "xyes"; then
61 AC_CHECK_HEADERS(db.h, bdbfound=yes, bdbfound=no)
64 if test "x$bdbfound" = "xno"; then
65 AC_MSG_WARN([Berkeley DB libraries found, but required header files cannot be used!!!])
68 dnl check we have the correct bdb version
69 AC_MSG_CHECKING([Berkeley DB version >= 4.0])
77 #define DB_MAJOR_REQ 4
78 #define DB_MINOR_REQ 0
79 #define DB_PATCH_REQ 0
83 int major, minor, patch;
86 version_str = db_version(&major, &minor, &patch);
88 /* check header version */
89 if (DB_VERSION_MAJOR < DB_MAJOR_REQ || DB_VERSION_MINOR < DB_MINOR_REQ ||
90 DB_VERSION_PATCH < DB_PATCH_REQ ) {
91 printf("header file version too old (%d.%d.%d), ", DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
95 /* check library version */
96 if (major < DB_MAJOR_REQ || minor < DB_MINOR_REQ || patch < DB_PATCH_REQ) {
97 printf("library version too old (%d.%d.%d), ",major, minor, patch);
101 /* check header and library match */
102 if ( major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR || patch != DB_VERSION_PATCH) {
103 printf("header/library version mismatch (%d.%d.%d/%d.%d.%d), ",
104 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, major, minor, patch);
108 printf("%d.%d.%d, ",major, minor, patch);
111 ], atalk_cv_bdbversion="yes", atalk_cv_bdbversion="no", atalk_cv_bdbversion="cross")
114 if test ${atalk_cv_bdbversion} = "yes"; then
121 if test "x$bdbfound" = "xyes"; then
122 if test "$bdbdir" != "/usr/include"; then
123 BDB_CFLAGS="-I$bdbdir"
125 if test "$bdblibdir" != "/usr/lib"; then
126 BDB_LIBS="-L$bdblibdir $BDB_LIBS"
129 BDB_PATH="`echo $bdbdir | sed 's,include\/db4$,,'`"
130 BDB_PATH="`echo $BDB_PATH | sed 's,include$,,'`"
132 CFLAGS="$savedcflags"
133 LDFLAGS="$savedldflags"
134 CPPFLAGS="$savedcppflags"
143 if test "x$bdbfound" = "xyes"; then
144 ifelse([$1], , :, [$1])
146 ifelse([$2], , :, [$2])