bitcore-node-zcash/bin/build-libbitcoind

125 lines
3.6 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)/.."
cd "${root_dir}"
options=`cat ${root_dir}/bin/config_options.sh`
2015-07-02 11:59:14 -07:00
2014-12-07 02:02:51 -08:00
os_dir=$(./platform/os.sh osdir)
host=$(./platform/os.sh host)
2015-07-27 06:54:39 -07:00
build_dependencies () {
if [ -d "${btc_dir}" ]; then
pushd "${btc_dir}"/depends
echo "using host for dependencies: ${host}"
make HOST=${host} NO_QT=1 NO_WALLET=1 NO_UPNP=1 #host is arch-os, e.g. x86_64-linux
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 "${root_dir}/libbitcoind"
get_patch_file
echo "running the diff command from HEAD to ${tag}"
git diff ${tag}..HEAD > /tmp/tmp.patch #uncommitted changes won't affect things here
matching_patch=`diff -w /tmp/tmp.patch "${root_dir}/etc/bitcoin.patch"`
}
#set the LD_LIBRARY_PATH for the linux clients.
export LD_LIBRARY_PATH="${root_dir}/libbitcoind/src/leveldb":"${os_dir}":$LD_LIBRARY_PATH
debug=
if [ "${BITCOINDJS_ENV}" == "debug" ]; then
options=`cat ${root_dir}/bin/config_options_debug.sh`
fi
test=
if [ "${BITCOINDJS_ENV}" == "test" ]; then
options=`cat ${root_dir}/bin/config_options_test.sh`
2014-12-07 00:02:31 -08:00
fi
btc_dir="${root_dir}/libbitcoind"
echo "Using BTC directory: ${btc_dir}"
rm -f "${os_dir}/libbitcoind.*"
only_make=false
if [ -d "${root_dir}/libbitcoind" ]; 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-23 13:59:13 -07:00
if [ "${BITCOINDJS_ASSUME_YES}" = true ]; then
input=y
echo ""
else
read input
fi
if [[ "${input}" =~ ^y|^Y ]]; then
repatch=true
echo "Removing directory: \"${root_dir}/libbitcoind\" and starting over!"
rm -fr "${root_dir}"/libbitcoind
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
2015-07-02 14:13:03 -07:00
fi
2014-12-06 16:43:53 -08:00
set -e
2014-12-07 00:56:43 -08:00
if [ "${only_make}" = false ]; then
echo "Removing 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
2014-12-07 00:24:57 -08:00
fi
2015-07-27 06:54:39 -07:00
build_dependencies
echo './autogen.sh'
./autogen.sh
full_options="${options}${os_dir}"
echo "running the configure script with the following options:\n :::[\"${full_options}\"]:::"
${full_options}
2015-07-02 14:13:03 -07:00
echo 'make V=1'
make V=1
2014-12-06 16:43:53 -08:00
2015-07-07 10:51:11 -07:00
ext=$($root_dir/platform/os.sh ext)
2015-07-02 14:13:03 -07:00
echo 'Copying libbitcoind.{so|dylib} to its appropriate location.'
if test -e "${root_dir}/libbitcoind/src/.libs/libbitcoind.${ext}"; then
2015-07-07 10:51:11 -07:00
if [ "$ext" = "dylib" ]; then
2015-07-09 12:50:15 -07:00
if [ ! -d "${os_dir}/lib" ]; then
mkdir -p "${os_dir}/lib"
fi
2015-07-10 08:18:27 -07:00
cp -R "${root_dir}"/libbitcoind/src/.libs/libbitcoind.*dylib "${os_dir}/lib/"
2015-07-07 10:51:11 -07:00
else
2015-07-10 08:57:27 -07:00
if [ ! -d "${os_dir}" ]; then
mkdir -p "${os_dir}"
fi
2015-07-09 09:41:48 -07:00
cp -P "${root_dir}"/libbitcoind/src/.libs/libbitcoind.so* "${os_dir}/"
2015-07-07 10:51:11 -07:00
fi
2015-07-02 14:13:03 -07:00
fi
2014-12-06 17:18:12 -08:00
2014-12-06 16:43:53 -08:00
echo 'Build finished successfully.'