2016-09-29 07:57:47 +02:00
dnl Copyright (c) 2013-2015 The Bitcoin Core developers
dnl Distributed under the MIT software license, see the accompanying
dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
2013-09-07 21:43:25 +02:00
AC_DEFUN([BITCOIN_FIND_BDB48],[
AC_MSG_CHECKING([for Berkeley DB C++ headers])
BDB_CPPFLAGS=
BDB_LIBS=
bdbpath=X
bdb48path=X
bdbdirlist=
for _vn in 4.8 48 4 5 ''; do
for _pfx in b lib ''; do
bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
done
done
for searchpath in $bdbdirlist ''; do
test -n "${searchpath}" && searchpath="${searchpath}/"
2014-08-26 23:25:33 +02:00
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2013-09-07 21:43:25 +02:00
#include <${searchpath}db_cxx.h>
2014-08-26 23:25:33 +02:00
]],[[
2013-09-07 21:43:25 +02:00
#if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
#error "failed to find bdb 4.8+"
#endif
2014-08-26 23:25:33 +02:00
]])],[
2013-09-07 21:43:25 +02:00
if test "x$bdbpath" = "xX"; then
bdbpath="${searchpath}"
fi
],[
continue
])
2014-08-26 23:25:33 +02:00
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2013-09-07 21:43:25 +02:00
#include <${searchpath}db_cxx.h>
2014-08-26 23:25:33 +02:00
]],[[
2013-09-07 21:43:25 +02:00
#if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
#error "failed to find bdb 4.8"
#endif
2014-08-26 23:25:33 +02:00
]])],[
2013-09-07 21:43:25 +02:00
bdb48path="${searchpath}"
break
2014-08-26 23:25:33 +02:00
],[])
2013-09-07 21:43:25 +02:00
done
if test "x$bdbpath" = "xX"; then
AC_MSG_RESULT([no])
2016-02-04 13:41:58 +01:00
AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
2013-09-07 21:43:25 +02:00
elif test "x$bdb48path" = "xX"; then
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!])
],[
2014-08-11 14:37:24 +02:00
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)])
2013-09-07 21:43:25 +02:00
])
else
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
bdbpath="${bdb48path}"
fi
AC_SUBST(BDB_CPPFLAGS)
# TODO: Ideally this could find the library version and make sure it matches the headers being used
for searchlib in db_cxx-4.8 db_cxx; do
AC_CHECK_LIB([$searchlib],[main],[
BDB_LIBS="-l${searchlib}"
break
])
done
if test "x$BDB_LIBS" = "x"; then
2016-02-04 13:41:58 +01:00
AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
2013-09-07 21:43:25 +02:00
fi
AC_SUBST(BDB_LIBS)
])