bitcore-node-zcash/bin/build-libbitcoind

84 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
set -e
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
cd "${root_dir}"
options=`cat ${root_dir}/bin/config_options.sh`
os_dir=$(./platform/os.sh osdir)
#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`
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 make inside libbitcoind (assuming you've previously patched and configured libbitcoind)..."
cd "${btc_dir}"
only_make=true
else
echo "Removing cloning, patching, and building libbitcoind..."
fi
if [ "${only_make}" = false ]; then
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 0
fi
echo "attempting to checkout tag: ${tag} of bitcoin from github..."
git clone --depth 1 --branch "${tag}" git://github.com/bitcoin/bitcoin.git libbitcoind
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
echo './autogen.sh'
./autogen.sh
fi
full_options="${options}${os_dir}"
echo "running the configure script with the following options:\n :::[\"${full_options}\"]:::"
${full_options}
echo 'make V=1'
make V=1
ext=$($root_dir/platform/os.sh ext)
echo 'Copying libbitcoind.{so|dylib} to its appropriate location.'
if test -e "${root_dir}/libbitcoind/src/.libs/libbitcoind.${ext}"; then
if [ "$ext" = "dylib" ]; then
if [ ! -d "${os_dir}/lib" ]; then
mkdir -p "${os_dir}/lib"
fi
cp -R "${root_dir}"/libbitcoind/src/.libs/libbitcoind.*dylib "${os_dir}/lib/"
else
if [ ! -d "${os_dir}" ]; then
mkdir -p "${os_dir}"
fi
cp -P "${root_dir}"/libbitcoind/src/.libs/libbitcoind.so* "${os_dir}/"
fi
fi
echo 'Build finished successfully.'