2016-10-01 03:02:32 -07:00
AC_DEFUN([BITCOIN_FIND_BDB53],[
2013-09-07 12:43:25 -07:00
AC_MSG_CHECKING([for Berkeley DB C++ headers])
BDB_CPPFLAGS=
BDB_LIBS=
bdbpath=X
2016-10-01 03:02:32 -07:00
bdb53path=X
2013-09-07 12:43:25 -07:00
bdbdirlist=
2016-10-01 03:02:32 -07:00
for _vn in 5.3 53 5 ''; do
2013-09-07 12:43:25 -07:00
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 14:25:33 -07:00
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2013-09-07 12:43:25 -07:00
#include <${searchpath}db_cxx.h>
2014-08-26 14:25:33 -07:00
]],[[
2016-10-01 03:02:32 -07:00
#if !((DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR >= 3) || DB_VERSION_MAJOR > 5)
#error "failed to find bdb 5.3+"
2013-09-07 12:43:25 -07:00
#endif
2014-08-26 14:25:33 -07:00
]])],[
2013-09-07 12:43:25 -07:00
if test "x$bdbpath" = "xX"; then
bdbpath="${searchpath}"
fi
],[
continue
])
2014-08-26 14:25:33 -07:00
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2013-09-07 12:43:25 -07:00
#include <${searchpath}db_cxx.h>
2014-08-26 14:25:33 -07:00
]],[[
2016-10-01 03:02:32 -07:00
#if !(DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR == 3)
#error "failed to find bdb 5.3"
2013-09-07 12:43:25 -07:00
#endif
2014-08-26 14:25:33 -07:00
]])],[
2016-10-01 03:02:32 -07:00
bdb53path="${searchpath}"
2013-09-07 12:43:25 -07:00
break
2014-08-26 14:25:33 -07:00
],[])
2013-09-07 12:43:25 -07:00
done
if test "x$bdbpath" = "xX"; then
AC_MSG_RESULT([no])
2015-01-19 11:16:49 -08:00
AC_MSG_ERROR([libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
2016-10-01 03:02:32 -07:00
elif test "x$bdb53path" = "xX"; then
2013-09-07 12:43:25 -07:00
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
2016-10-01 03:02:32 -07:00
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 5.3])],[
AC_MSG_WARN([Found Berkeley DB other than 5.3; wallets opened by this build will not be portable!])
2013-09-07 12:43:25 -07:00
],[
2016-10-01 03:02:32 -07:00
AC_MSG_ERROR([Found Berkeley DB other than 5.3, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)])
2013-09-07 12:43:25 -07:00
])
else
2016-10-01 03:02:32 -07:00
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb53path}],db_cxx)
bdbpath="${bdb53path}"
2013-09-07 12:43:25 -07:00
fi
AC_SUBST(BDB_CPPFLAGS)
# TODO: Ideally this could find the library version and make sure it matches the headers being used
2016-10-01 03:02:32 -07:00
for searchlib in db_cxx-5.3 db_cxx; do
2013-09-07 12:43:25 -07:00
AC_CHECK_LIB([$searchlib],[main],[
BDB_LIBS="-l${searchlib}"
break
])
done
if test "x$BDB_LIBS" = "x"; then
2014-08-11 05:37:24 -07:00
AC_MSG_ERROR([libdb_cxx missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
2013-09-07 12:43:25 -07:00
fi
AC_SUBST(BDB_LIBS)
])