1 dnl $Id: db3-check.m4,v 1.11.6.2 2003-11-24 17:16:51 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"
36 CPPFLAGS="$CFLAGS -I$bdbdir"
38 LDFLAGS="-L$bdblibdir $LDFLAGS"
40 dnl db_create is BDB >3 specific
41 AC_CHECK_LIB(db, db_create, [
45 AC_CHECK_LIB(db4, db_create, [
51 dnl check for header ... should only fail if the header cannot be compiled
52 dnl it does exist, otherwise we wouldn't be here
54 if test "x$bdbfound" = "xyes"; then
55 AC_CHECK_HEADERS([db.h],[
56 dnl check we have the correct bdb version
57 AC_MSG_CHECKING(Berkeley DB version >= 4.0)
64 #define DB_MAJOR_REQ 4
65 #define DB_MINOR_REQ 0
66 #define DB_PATCH_REQ 0
70 int major, minor, patch;
73 version_str = db_version(&major, &minor, &patch);
75 /* check header version */
76 if (DB_VERSION_MAJOR < DB_MAJOR_REQ || DB_VERSION_MINOR < DB_MINOR_REQ ||
77 DB_VERSION_PATCH < DB_PATCH_REQ )
80 /* check library version */
81 if (major < DB_MAJOR_REQ || minor < DB_MINOR_REQ || patch < DB_PATCH_REQ)
84 /* check header and library match */
85 if ( major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR || patch != DB_VERSION_PATCH)
91 atalk_cv_bdbversion="yes",
92 atalk_cv_bdbversion="no",
93 atalk_cv_bdbversion="cross")
95 if test ${atalk_cv_bdbversion} = "yes"; then
103 AC_MSG_WARN([Berkeley DB libraries found, but required header files cannot be used!!!])
107 if test "x$bdbfound" = "xyes"; then
108 if test "$bdbdir" != "/usr/include"; then
109 BDB_CFLAGS="-I$bdbdir"
111 if test "$bdblibdir" != "/usr/lib"; then
112 BDB_LIBS="-L$bdblibdir $BDB_LIBS"
115 BDB_PATH="`echo $bdbdir | sed 's,include\/db4$,,'`"
116 BDB_PATH="`echo $BDB_PATH | sed 's,include$,,'`"
118 CFLAGS="$savedcflags"
119 LDFLAGS="$savedldflags"
120 CPPFLAGS="$savedcppflags"
129 if test "x$bdbfound" = "xyes"; then
130 ifelse([$1], , :, [$1])
132 ifelse([$2], , :, [$2])