build: Add options to override BDB cflags/libs

Add environment settings to specify the CFLAGS and LIBS to be used for
BerkeleyDB directly. These will completely by-pass autodetection in the
same way as other similar flags.

```
BDB_CFLAGS  C compiler flags for BerkeleyDB, bypasses autodetection
BDB_LIBS    Linker flags for BerkeleyDB, bypasses autodetection
```

Implements #3921.
This commit is contained in:
Wladimir J. van der Laan 2017-02-07 09:41:47 +00:00
parent 02464da5e4
commit 8713de83a0

View File

@ -3,68 +3,76 @@ dnl Distributed under the MIT software license, see the accompanying
dnl file COPYING or http://www.opensource.org/licenses/mit-license.php. dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
AC_DEFUN([BITCOIN_FIND_BDB48],[ AC_DEFUN([BITCOIN_FIND_BDB48],[
AC_MSG_CHECKING([for Berkeley DB C++ headers]) AC_ARG_VAR(BDB_CFLAGS, [C compiler flags for BerkeleyDB, bypasses autodetection])
BDB_CPPFLAGS= AC_ARG_VAR(BDB_LIBS, [Linker flags for BerkeleyDB, bypasses autodetection])
BDB_LIBS=
bdbpath=X if test "x$BDB_CFLAGS" = "x"; then
bdb48path=X AC_MSG_CHECKING([for Berkeley DB C++ headers])
bdbdirlist= BDB_CPPFLAGS=
for _vn in 4.8 48 4 5 ''; do bdbpath=X
for _pfx in b lib ''; do bdb48path=X
bdbdirlist="$bdbdirlist ${_pfx}db${_vn}" bdbdirlist=
for _vn in 4.8 48 4 5 ''; do
for _pfx in b lib ''; do
bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
done
done done
done for searchpath in $bdbdirlist ''; do
for searchpath in $bdbdirlist ''; do test -n "${searchpath}" && searchpath="${searchpath}/"
test -n "${searchpath}" && searchpath="${searchpath}/" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <${searchpath}db_cxx.h>
#include <${searchpath}db_cxx.h> ]],[[
]],[[ #if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
#if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4) #error "failed to find bdb 4.8+"
#error "failed to find bdb 4.8+" #endif
#endif ]])],[
]])],[ if test "x$bdbpath" = "xX"; then
if test "x$bdbpath" = "xX"; then bdbpath="${searchpath}"
bdbpath="${searchpath}" fi
fi ],[
],[ continue
continue ])
]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <${searchpath}db_cxx.h>
#include <${searchpath}db_cxx.h> ]],[[
]],[[ #if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
#if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8) #error "failed to find bdb 4.8"
#error "failed to find bdb 4.8" #endif
#endif ]])],[
]])],[ bdb48path="${searchpath}"
bdb48path="${searchpath}" break
break ],[])
],[]) done
done if test "x$bdbpath" = "xX"; then
if test "x$bdbpath" = "xX"; then AC_MSG_RESULT([no])
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)])
AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)]) elif test "x$bdb48path" = "xX"; then
elif test "x$bdb48path" = "xX"; then BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
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_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!])
AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!]) ],[
],[ 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)])
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)]) ])
]) else
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
bdbpath="${bdb48path}"
fi
else else
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx) BDB_CPPFLAGS=${BDB_CFLAGS}
bdbpath="${bdb48path}"
fi fi
AC_SUBST(BDB_CPPFLAGS) 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 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)]) # 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
AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
fi
fi fi
AC_SUBST(BDB_LIBS) AC_SUBST(BDB_LIBS)
]) ])