Skip to content

Commit 6a55515

Browse files
committed
Merge #9705: build: Add options to override BDB cflags/libs
5cc2ebb Update OpenBSD and FreeBSD build steps (Wladimir J. van der Laan) 8713de8 build: Add options to override BDB cflags/libs (Wladimir J. van der Laan)
2 parents d304fef + 5cc2ebb commit 6a55515

File tree

3 files changed

+70
-60
lines changed

3 files changed

+70
-60
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
])

doc/build-openbsd.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OpenBSD build guide
22
======================
3-
(updated for OpenBSD 5.9)
3+
(updated for OpenBSD 6.0)
44

55
This guide describes how to build bitcoind and command-line utilities on OpenBSD.
66

@@ -124,7 +124,7 @@ To configure with wallet:
124124
```bash
125125
./configure --with-gui=no --with-boost=$BOOST_PREFIX \
126126
CC=egcc CXX=eg++ CPP=ecpp \
127-
LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/"
127+
BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include"
128128
```
129129

130130
To configure without wallet:
@@ -142,6 +142,8 @@ gmake check
142142
Clang (not currently working)
143143
------------------------------
144144

145+
WARNING: This is outdated, needs to be updated for OpenBSD 6.0 and re-tried.
146+
145147
Using a newer g++ results in linking the new code to a new libstdc++.
146148
Libraries built with the old g++, will still import the old library.
147149
This gives conflicts, necessitating rebuild of all C++ dependencies of the application.

doc/build-unix.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ For further documentation on the depends system see [README.md](../depends/READM
315315
Building on FreeBSD
316316
--------------------
317317

318-
(Updated as of FreeBSD 10.3)
318+
(Updated as of FreeBSD 11.0)
319319

320320
Clang is installed by default as `cc` compiler, this makes it easier to get
321321
started than on [OpenBSD](build-openbsd.md). Installing dependencies:
@@ -337,7 +337,7 @@ with 4.8-built Bitcoin Core is needed follow the steps under "Berkeley DB" above
337337
Then build using:
338338

339339
./autogen.sh
340-
./configure --with-incompatible-bdb CPPFLAGS=-I/usr/local/include/db5 LDFLAGS=-L/usr/local/lib/db5
340+
./configure --with-incompatible-bdb BDB_CFLAGS="-I/usr/local/include/db5" BDB_LIBS="-L/usr/local/lib -ldb_cxx-5"
341341
make
342342

343343
*Note on debugging*: The version of `gdb` installed by default is [ancient and considered harmful](https://wiki.freebsd.org/GdbRetirement).

0 commit comments

Comments
 (0)