1 dnl Copyright (c) 2013-2015 The Bitcoin Core developers
2 dnl Distributed under the MIT software license, see the accompanying
3 dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 AC_DEFUN([BITCOIN_FIND_BDB48],[
6 AC_ARG_VAR(BDB_CFLAGS, [C compiler flags for BerkeleyDB, bypasses autodetection])
7 AC_ARG_VAR(BDB_LIBS, [Linker flags for BerkeleyDB, bypasses autodetection])
9 if test "x$BDB_CFLAGS" = "x"; then
10 AC_MSG_CHECKING([for Berkeley DB C++ headers])
15 for _vn in 4.8 48 4 5 5.3 ''; do
16 for _pfx in b lib ''; do
17 bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
20 for searchpath in $bdbdirlist ''; do
21 test -n "${searchpath}" && searchpath="${searchpath}/"
22 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
23 #include <${searchpath}db_cxx.h>
25 #if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
26 #error "failed to find bdb 4.8+"
29 if test "x$bdbpath" = "xX"; then
30 bdbpath="${searchpath}"
35 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
36 #include <${searchpath}db_cxx.h>
38 #if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
39 #error "failed to find bdb 4.8"
42 bdb48path="${searchpath}"
46 if test "x$bdbpath" = "xX"; then
48 AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
49 elif test "x$bdb48path" = "xX"; then
50 BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
51 AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
52 AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!])
54 AC_MSG_ERROR([Found Berkeley DB other than 4.8, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)])
57 BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
58 bdbpath="${bdb48path}"
61 BDB_CPPFLAGS=${BDB_CFLAGS}
63 AC_SUBST(BDB_CPPFLAGS)
65 if test "x$BDB_LIBS" = "x"; then
66 # TODO: Ideally this could find the library version and make sure it matches the headers being used
67 for searchlib in db_cxx-4.8 db_cxx; do
68 AC_CHECK_LIB([$searchlib],[main],[
69 BDB_LIBS="-l${searchlib}"
73 if test "x$BDB_LIBS" = "x"; then
74 AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])