Skip to content

Commit 8713de8

Browse files
committed
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.
1 parent 02464da commit 8713de8

File tree

1 file changed

+64
-56
lines changed

1 file changed

+64
-56
lines changed

build-aux/m4/bitcoin_find_bdb48.m4

Lines changed: 64 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,68 +3,76 @@ dnl Distributed under the MIT software license, see the accompanying
33
dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
AC_DEFUN([BITCOIN_FIND_BDB48],[
6-
AC_MSG_CHECKING([for Berkeley DB C++ headers])
7-
BDB_CPPFLAGS=
8-
BDB_LIBS=
9-
bdbpath=X
10-
bdb48path=X
11-
bdbdirlist=
12-
for _vn in 4.8 48 4 5 ''; do
13-
for _pfx in b lib ''; do
14-
bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
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])
8+
9+
if test "x$BDB_CFLAGS" = "x"; then
10+
AC_MSG_CHECKING([for Berkeley DB C++ headers])
11+
BDB_CPPFLAGS=
12+
bdbpath=X
13+
bdb48path=X
14+
bdbdirlist=
15+
for _vn in 4.8 48 4 5 ''; do
16+
for _pfx in b lib ''; do
17+
bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
18+
done
19+
done
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>
24+
]],[[
25+
#if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
26+
#error "failed to find bdb 4.8+"
27+
#endif
28+
]])],[
29+
if test "x$bdbpath" = "xX"; then
30+
bdbpath="${searchpath}"
31+
fi
32+
],[
33+
continue
34+
])
35+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
36+
#include <${searchpath}db_cxx.h>
37+
]],[[
38+
#if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
39+
#error "failed to find bdb 4.8"
40+
#endif
41+
]])],[
42+
bdb48path="${searchpath}"
43+
break
44+
],[])
1545
done
16-
done
17-
for searchpath in $bdbdirlist ''; do
18-
test -n "${searchpath}" && searchpath="${searchpath}/"
19-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
20-
#include <${searchpath}db_cxx.h>
21-
]],[[
22-
#if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
23-
#error "failed to find bdb 4.8+"
24-
#endif
25-
]])],[
26-
if test "x$bdbpath" = "xX"; then
27-
bdbpath="${searchpath}"
28-
fi
29-
],[
30-
continue
31-
])
32-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
33-
#include <${searchpath}db_cxx.h>
34-
]],[[
35-
#if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
36-
#error "failed to find bdb 4.8"
37-
#endif
38-
]])],[
39-
bdb48path="${searchpath}"
40-
break
41-
],[])
42-
done
43-
if test "x$bdbpath" = "xX"; then
44-
AC_MSG_RESULT([no])
45-
AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
46-
elif test "x$bdb48path" = "xX"; then
47-
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
48-
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
49-
AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!])
50-
],[
51-
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)])
52-
])
46+
if test "x$bdbpath" = "xX"; then
47+
AC_MSG_RESULT([no])
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!])
53+
],[
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)])
55+
])
56+
else
57+
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
58+
bdbpath="${bdb48path}"
59+
fi
5360
else
54-
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
55-
bdbpath="${bdb48path}"
61+
BDB_CPPFLAGS=${BDB_CFLAGS}
5662
fi
5763
AC_SUBST(BDB_CPPFLAGS)
5864
59-
# TODO: Ideally this could find the library version and make sure it matches the headers being used
60-
for searchlib in db_cxx-4.8 db_cxx; do
61-
AC_CHECK_LIB([$searchlib],[main],[
62-
BDB_LIBS="-l${searchlib}"
63-
break
64-
])
65-
done
6665
if test "x$BDB_LIBS" = "x"; then
67-
AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
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}"
70+
break
71+
])
72+
done
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)])
75+
fi
6876
fi
6977
AC_SUBST(BDB_LIBS)
7078
])

0 commit comments

Comments
 (0)