2016-09-21 15:54:41 -07: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.
2018-04-01 07:32:10 -07:00
AC_DEFUN([BITCOIN_FIND_BDB62],[
2017-02-07 01:41:47 -08:00
AC_ARG_VAR(BDB_CFLAGS, [C compiler flags for BerkeleyDB, bypasses autodetection])
AC_ARG_VAR(BDB_LIBS, [Linker flags for BerkeleyDB, bypasses autodetection])
if test "x$BDB_CFLAGS" = "x"; then
AC_MSG_CHECKING([for Berkeley DB C++ headers])
BDB_CPPFLAGS=
bdbpath=X
2018-04-01 07:32:10 -07:00
bdb62path=X
2017-02-07 01:41:47 -08:00
bdbdirlist=
2018-04-01 07:32:10 -07:00
for _vn in 6.2 62 6 ''; do
2017-02-07 01:41:47 -08:00
for _pfx in b lib ''; do
bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
done
done
for searchpath in $bdbdirlist ''; do
test -n "${searchpath}" && searchpath="${searchpath}/"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <${searchpath}db_cxx.h>
]],[[
2018-04-01 07:32:10 -07:00
#if !((DB_VERSION_MAJOR == 6 && DB_VERSION_MINOR >= 2) || DB_VERSION_MAJOR > 6)
#error "failed to find bdb 6.2+"
2017-02-07 01:41:47 -08:00
#endif
]])],[
if test "x$bdbpath" = "xX"; then
bdbpath="${searchpath}"
fi
],[
continue
])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <${searchpath}db_cxx.h>
]],[[
2018-04-01 07:32:10 -07:00
#if !(DB_VERSION_MAJOR == 6 && DB_VERSION_MINOR == 2)
#error "failed to find bdb 6.2"
2017-02-07 01:41:47 -08:00
#endif
]])],[
2018-04-01 07:32:10 -07:00
bdb62path="${searchpath}"
2017-02-07 01:41:47 -08:00
break
],[])
2013-09-07 12:43:25 -07:00
done
2017-02-07 01:41:47 -08:00
if test "x$bdbpath" = "xX"; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
2018-04-01 07:32:10 -07:00
elif test "x$bdb62path" = "xX"; then
2017-02-07 01:41:47 -08:00
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
2018-04-01 07:32:10 -07:00
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 6.2])],[
AC_MSG_WARN([Found Berkeley DB other than 6.2; wallets opened by this build will not be portable!])
2017-02-07 01:41:47 -08:00
],[
2018-04-01 07:32:10 -07:00
AC_MSG_ERROR([Found Berkeley DB other than 6.2, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)])
2017-02-07 01:41:47 -08:00
])
else
2018-04-01 07:32:10 -07:00
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb62path}],db_cxx)
bdbpath="${bdb62path}"
2017-02-07 01:41:47 -08:00
fi
2013-09-07 12:43:25 -07:00
else
2017-02-07 01:41:47 -08:00
BDB_CPPFLAGS=${BDB_CFLAGS}
2013-09-07 12:43:25 -07:00
fi
AC_SUBST(BDB_CPPFLAGS)
2018-04-01 07:32:10 -07:00
2013-09-07 12:43:25 -07:00
if test "x$BDB_LIBS" = "x"; then
2017-02-07 01:41:47 -08:00
# TODO: Ideally this could find the library version and make sure it matches the headers being used
2018-04-01 07:32:10 -07:00
for searchlib in db_cxx-6.2 db_cxx db6_cxx; do
2017-02-07 01:41:47 -08:00
AC_CHECK_LIB([$searchlib],[main],[
BDB_LIBS="-l${searchlib}"
break
])
done
if test "x$BDB_LIBS" = "x"; then
AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
fi
2013-09-07 12:43:25 -07:00
fi
AC_SUBST(BDB_LIBS)
])