3 # Install libdb4.8 (Berkeley DB).
8 echo "Usage: ./install_db4.sh <base-dir> [<extra-bdb-configure-flag> ...]"
10 echo "Must specify a single argument: the directory in which db4 will be built."
11 echo "This is probably \`pwd\` if you're at the root of the bitcoin repository."
16 echo "$(cd "${1}" && pwd -P)"
19 BDB_PREFIX
="$(expand_path ${1})/db4"; shift;
20 BDB_VERSION
='db-4.8.30.NC'
21 BDB_HASH
='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef'
22 BDB_URL
="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz"
25 which "$1" >/dev
/null
2>&1
29 # Args: <sha256_hash> <filename>
31 if check_exists sha256sum
; then
32 echo "${1} ${2}" | sha256sum
-c
33 elif check_exists sha256
; then
34 if [ "$(uname)" = "FreeBSD" ]; then
35 sha256
-c "${1}" "${2}"
37 echo "${1} ${2}" | sha256
-c
40 echo "${1} ${2}" | shasum
-a 256 -c
45 # Args: <url> <filename> <sha256_hash>
47 # It's acceptable that we don't require SSL here because we manually verify
48 # content hashes below.
50 if [ -f "${2}" ]; then
51 echo "File ${2} already exists; not downloading again"
52 elif check_exists curl
; then
53 curl
--insecure "${1}" -o "${2}"
55 wget
--no-check-certificate "${1}" -O "${2}"
58 sha256_check
"${3}" "${2}"
61 mkdir
-p "${BDB_PREFIX}"
62 http_get
"${BDB_URL}" "${BDB_VERSION}.tar.gz" "${BDB_HASH}"
63 tar -xzvf ${BDB_VERSION}.
tar.gz
-C "$BDB_PREFIX"
64 cd "${BDB_PREFIX}/${BDB_VERSION}/"
66 # Apply a patch necessary when building with clang and c++11 (see https://community.oracle.com/thread/3952592)
67 CLANG_CXX11_PATCH_URL
='https://gist.githubusercontent.com/LnL7/5153b251fd525fe15de69b67e63a6075/raw/7778e9364679093a32dec2908656738e16b6bdcb/clang.patch'
68 CLANG_CXX11_PATCH_HASH
='7a9a47b03fd5fb93a16ef42235fa9512db9b0829cfc3bdf90edd3ec1f44d637c'
69 http_get
"${CLANG_CXX11_PATCH_URL}" clang.
patch "${CLANG_CXX11_PATCH_HASH}"
70 patch -p2 < clang.
patch
74 "${BDB_PREFIX}/${BDB_VERSION}/dist/configure" \
75 --enable-cxx --disable-shared --with-pic --prefix="${BDB_PREFIX}" \
81 echo "db4 build complete."
83 echo 'When compiling bitcoind, run `./configure` in the following way:'
85 echo " export BDB_PREFIX='${BDB_PREFIX}'"
86 echo ' ./configure LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/" ...'