1 dnl $Id: db3-check.m4,v 1.11.6.1 2003-10-29 23:53:24 bfernhomberg Exp $
2 dnl Autoconf macro to check for the Berkeley DB library
4 AC_DEFUN([AC_PATH_BDB], [
7 bdb_search_dirs="/usr/local/include/db4 /usr/local/include /usr/include/db4 /usr/include"
11 [ --with-bdb=PATH specify path to Berkeley DB installation[[auto]]],
12 if test "x$withval" == "xno"; then
14 elif test "x$withval" == "xyes"; then
17 bdb_search_dirs="$withval/include/db4 $withval/include $withval"
22 if test "x$dobdbsearch" != "xno"; then
23 for bdbdir in $bdb_search_dirs ; do
24 AC_MSG_CHECKING([for Berkeley DB headers in $bdbdir])
25 if test -f "$bdbdir/db.h" ; then
27 bdblibdir="`echo $bdbdir | sed 's/include\/db4$/lib/'`"
28 bdblibdir="`echo $bdblibdir | sed 's/include$/lib/'`"
29 bdbbindir="`echo $bdbdir | sed 's/include\/db4$/bin/'`"
30 bdbbindir="`echo $bdbbindir | sed 's/include$/bin/'`"
33 savedldflags="$LDFLAGS"
34 savedcppflags="$CPPFLAGS"
35 CFLAGS="$CFLAGS -I$bdbdir"
36 CPPFLAGS="$CFLAGS -I$bdbdir"
37 LDFLAGS="-L$bdblibdir $LDFLAGS"
39 dnl db_create is BDB >3 specific
40 AC_CHECK_LIB(db, db_create, [
42 LDFLAGS="$LDFLAGS -ldb"
44 AC_CHECK_LIB(db4, db_create, [
46 LDFLAGS="$LDFLAGS -ldb4"
50 dnl check for header ... should only fail if the header cannot be compiled
51 dnl it does exist, otherwise we wouldn't be here
53 if test "x$bdbfound" = "xyes"; then
54 AC_CHECK_HEADERS([db.h],[
55 dnl check we have the correct bdb version
56 AC_MSG_CHECKING(Berkeley DB version >= 4.0)
63 #define DB_MAJOR_REQ 4
64 #define DB_MINOR_REQ 0
65 #define DB_PATCH_REQ 0
69 int major, minor, patch;
72 version_str = db_version(&major, &minor, &patch);
74 /* check header version */
75 if (DB_VERSION_MAJOR < DB_MAJOR_REQ || DB_VERSION_MINOR < DB_MINOR_REQ ||
76 DB_VERSION_PATCH < DB_PATCH_REQ )
79 /* check library version */
80 if (major < DB_MAJOR_REQ || minor < DB_MINOR_REQ || patch < DB_PATCH_REQ)
83 /* check header and library match */
84 if ( major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR || patch != DB_VERSION_PATCH)
90 atalk_cv_bdbversion="yes",
91 atalk_cv_bdbversion="no",
92 atalk_cv_bdbversion="cross")
94 if test ${atalk_cv_bdbversion} = "yes"; then
102 AC_MSG_WARN([Berkeley DB libraries found, but required header files cannot be used!!!])
106 if test "x$bdbfound" = "xyes"; then
107 if test "$bdbdir" != "/usr/include"; then
108 BDB_CFLAGS="-I$bdbdir"
110 if test "$bdblibdir" != "/usr/lib"; then
111 BDB_LIBS="-L$bdblibdir $BDB_LIBS"
114 BDB_PATH="`echo $bdbdir | sed 's,include\/db4$,,'`"
115 BDB_PATH="`echo $BDB_PATH | sed 's,include$,,'`"
117 CFLAGS="$savedcflags"
118 LDFLAGS="$savedldflags"
119 CPPFLAGS="$savedcppflags"
127 if test "x$bdbfound" = "xyes"; then
128 ifelse([$1], , :, [$1])
130 ifelse([$2], , :, [$2])