bitcore-node-zcash/bin/build-libbitcoind

151 lines
4.9 KiB
Plaintext
Raw Normal View History

2014-12-09 13:29:32 -08:00
#!/bin/bash
2014-12-09 13:24:24 -08:00
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
options=`cat ${root_dir}/bin/config_options.sh`
h_and_a_dir=$($root_dir/platform/os.sh h_and_a_dir)
depends_dir=$($root_dir/platform/os.sh depends_dir)
os_dir=$(${root_dir}/platform/os.sh osdir)
host=$(${root_dir}/platform/os.sh host)
btc_dir="${root_dir}/libbitcoind"
ext=$($root_dir/platform/os.sh ext)
export CPPFLAGS="-I${h_and_a_dir}/include/boost -I${h_and_a_dir}/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include -L${h_and_a_dir}/lib"
echo "Using BTC directory: ${btc_dir}"
cd "${root_dir}"
2015-07-27 06:54:39 -07:00
build_dependencies () {
if [ -d "${btc_dir}" ]; then
pushd "${depends_dir}"
2015-07-27 06:54:39 -07:00
echo "using host for dependencies: ${host}"
boost_files_count=`find "${h_and_a_dir}"/lib -iname "libboost_*-mt.a" | wc -l | xargs`
db_files_count=`find "${h_and_a_dir}"/lib -iname "libdb*.a" | wc -l | xargs`
should_rebuild=false
if [[ "${boost_files_count}" -lt 5 || ( "${db_files_count}" -lt 1 && "${test}" = true ) ]]; then
should_rebuild=true
fi
if [ "${should_rebuild}" = true ]; then
if [ "${test}" = true ]; then
make HOST=${host} NO_QT=1 NO_UPNP=1
else
make HOST=${host} NO_QT=1 NO_WALLET=1 NO_UPNP=1
fi
else
echo "Looks like libs are already built, so we won't rebuild them. Incidentally, we found: ${boost_files_count} boost libraries and: ${db_files_count} Berkeley DB libraries and you have test mode set to: ${test}"
fi
2015-07-27 06:54:39 -07:00
popd
fi
}
get_patch_file () {
if test -e "${root_dir/PATCH_VERSION}"; then
tag=`cat "${root_dir}/PATCH_VERSION" | xargs`
else
echo "no tag file found, please create it in the root of the project as so: 'echo \"v0.10.2\" > PATCH_VERSION'"
exit 1
fi
}
compare_patch () {
cd "${btc_dir}"
get_patch_file
echo "running the diff command from HEAD to ${tag}"
git diff ${tag}..HEAD > /tmp/tmp.patch
matching_patch=`diff -w /tmp/tmp.patch "${root_dir}/etc/bitcoin.patch"`
}
debug=
2015-07-31 08:40:15 -07:00
if [ "${BITCORENODE_ENV}" == "debug" ]; then
options=`cat ${root_dir}/bin/config_options_debug.sh`
fi
test=false
2015-07-31 08:40:15 -07:00
if [ "${BITCORENODE_ENV}" == "test" ]; then
test=true
options=`cat ${root_dir}/bin/config_options_test.sh`
2014-12-07 00:02:31 -08:00
fi
patch_file_sha=$(shasum -a 256 "${root_dir}/etc/bitcoin.patch" | awk '{print $1}')
patch_sha="${root_dir}"/etc/patch_sha.txt
last_patch_file_sha=
if [ -e "${patch_sha}" ]; then
last_patch_file_sha=$(cat "${patch_sha}")
fi
shared_file_built=false
if [ "${last_patch_file_sha}" == "${patch_file_sha}" ]; then
shared_file_built=true
fi
if [ "${shared_file_built}" = false ]; then
mac_response=$($root_dir/platform/os.sh mac_dependencies)
if [ "${mac_response}" != "" ]; then
echo "${mac_response}"
exit -1
fi
only_make=false
if [ -d "${btc_dir}" ]; then
echo "running compare patch..."
compare_patch
repatch=false
if [[ "${matching_patch}" =~ [^\s\\] ]]; then
echo "Warning! libbitcoind is not patched with:\
${root_dir}/etc/bitcoin.patch."
echo -n "Would you like to remove the current patch, checkout the tag: ${tag} and \
apply the current patch from "${root_dir}"/etc/bitcoin.patch? (y/N): "
2015-07-31 08:40:15 -07:00
if [ "${BITCORENODE_ASSUME_YES}" = true ]; then
input=y
echo ""
else
read input
fi
if [[ "${input}" =~ ^y|^Y ]]; then
repatch=true
rm -f "${os_dir}/libbitcoind.*"
echo "Removing directory: \"${btc_dir}\" and starting over!"
rm -fr "${btc_dir}"
fi
fi
if [ "${repatch}" = false ]; then
echo "Running make inside libbitcoind (assuming you've previously patched and configured libbitcoind)..."
cd "${btc_dir}"
only_make=true
fi
fi
2014-12-06 16:43:53 -08:00
if [ "${only_make}" = false ]; then
echo "Cloning, patching, and building libbitcoind..."
get_patch_file
echo "attempting to checkout tag: ${tag} of bitcoin from github..."
cd "${root_dir}"
git clone --depth 1 --branch "${tag}" https://github.com/bitcoin/bitcoin.git libbitcoind
2014-12-06 16:43:53 -08:00
cd "${btc_dir}"
echo '../patch-bitcoin.sh' "${btc_dir}"
../bin/patch-bitcoin "${btc_dir}"
if ! test -d .git; then
echo 'Please point this script to an upstream bitcoin git repo.'
exit 1
fi
2014-12-06 16:43:53 -08:00
fi
build_dependencies
echo './autogen.sh'
./autogen.sh
boost_libdir="--with-boost-libdir=${h_and_a_dir}/lib"
full_options="${options} ${boost_libdir} --prefix=${os_dir}"
echo "running the configure script with the following options:\n :::[\"${full_options}\"]:::"
${full_options}
echo 'make V=1'
make V=1
2014-12-06 16:43:53 -08:00
echo "Creating the sha marker for the patching in libbitcoind..."
echo -n `shasum -a 256 "${root_dir}"/etc/bitcoin.patch | awk '{print $1}'` > "${root_dir}"/etc/patch_sha.txt
echo 'Build finished successfully.'
else
echo 'Using existing shared library.'
2015-07-02 14:13:03 -07:00
fi
2014-12-06 17:18:12 -08:00