2014-12-09 13:29:32 -08:00
|
|
|
#!/bin/bash
|
2015-07-02 14:13:03 -07:00
|
|
|
set -e
|
2014-12-06 16:43:53 -08:00
|
|
|
|
2014-12-09 13:24:24 -08:00
|
|
|
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
|
|
|
|
cd "$root_dir"
|
2015-07-02 11:59:14 -07:00
|
|
|
|
2014-12-07 02:02:51 -08:00
|
|
|
os_dir=$(./platform/os.sh osdir)
|
2014-12-06 17:18:12 -08:00
|
|
|
|
2015-07-02 14:13:03 -07:00
|
|
|
if test -e "${os_dir}/libbitcoind.so" || test -e "${os_dir}/libbitcoind.dylib"; then
|
|
|
|
read -r -p 'libbitcoind already built. Rebuild? (Y/n): ' choice
|
2014-12-07 00:04:13 -08:00
|
|
|
if test x"$choice" != x'y' -a x"$choice" != x'Y'; then
|
2015-07-02 14:13:03 -07:00
|
|
|
echo 'libbitcoind ready.'
|
2014-12-07 00:02:31 -08:00
|
|
|
exit 0
|
|
|
|
fi
|
2014-12-07 02:07:57 -08:00
|
|
|
rm -rf libbitcoind
|
2015-07-02 14:13:03 -07:00
|
|
|
rm -f "${os_dir}/libbitcoind.*"
|
2014-12-07 00:02:31 -08:00
|
|
|
fi
|
|
|
|
|
2015-07-02 14:13:03 -07:00
|
|
|
if [ -d "${root_dir}/libbitcoind" ]; then
|
|
|
|
read -r -p "libbitcoind (bitcoind repo) exists, would you like to remove it? (Y/n): " choice
|
|
|
|
if [ "$choice" = "y" -o "$choice" = "Y" ]; then
|
|
|
|
rm -rf "${root_dir}/libbitcoind"
|
2014-12-06 17:18:12 -08:00
|
|
|
else
|
2015-07-02 14:13:03 -07:00
|
|
|
echo "ok you chose not to remove the bitcoin repo, exiting...bu bye!"
|
2014-12-06 17:18:12 -08:00
|
|
|
fi
|
2015-07-02 14:13:03 -07:00
|
|
|
fi
|
|
|
|
#read the PATCH VERSION
|
|
|
|
if test -e "${root_dir/PATCH_VERSION}"; then
|
|
|
|
tag=`cat "$root_dir/PATCH_VERSION" | xargs`
|
2014-12-06 17:18:12 -08:00
|
|
|
else
|
2015-07-02 14:13:03 -07:00
|
|
|
echo "no tag file found, please create it in the root of the project as so: 'echo \"v0.10.2\" > PATCH_VERSION'"
|
|
|
|
exit 0
|
2014-12-06 17:18:12 -08:00
|
|
|
fi
|
2014-12-06 16:43:53 -08:00
|
|
|
|
2015-07-02 14:13:03 -07:00
|
|
|
echo "attempting to checkout tag: $tag of bitcoin from github..."
|
|
|
|
git clone --depth 1 --branch "${tag}" git://github.com/bitcoin/bitcoin.git libbitcoind
|
|
|
|
btc_dir="${root_dir}/libbitcoind"
|
|
|
|
|
2014-12-07 00:56:43 -08:00
|
|
|
echo "Found BTC directory: $btc_dir"
|
|
|
|
|
|
|
|
echo './patch-bitcoin.sh' "$btc_dir"
|
2015-07-02 14:13:03 -07:00
|
|
|
./bin/patch-bitcoin "$btc_dir"
|
2014-12-06 16:43:53 -08:00
|
|
|
|
2015-07-02 14:13:03 -07:00
|
|
|
cd "$btc_dir"
|
2014-12-06 16:43:53 -08:00
|
|
|
|
2014-12-07 00:24:57 -08:00
|
|
|
if ! test -d .git; then
|
|
|
|
echo 'Please point this script to an upstream bitcoin git repo.'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-12-07 00:56:43 -08:00
|
|
|
echo './autogen.sh'
|
2015-07-02 14:13:03 -07:00
|
|
|
./autogen.sh
|
|
|
|
options=`cat ${root_dir}/bin/config_options.sh`
|
|
|
|
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
|
2014-12-06 16:43:53 -08:00
|
|
|
|
2015-07-02 14:13:03 -07:00
|
|
|
echo 'Copying libbitcoind.{so|dylib} to its appropriate location.'
|
|
|
|
if test -e "${os_dir}/libbitcoind.so"
|
|
|
|
mv src/libbitcoind.so "${os_dir}/libbitcoind.so"
|
|
|
|
elif test -e "${os_dir}/libbitcoind.dylib"; then
|
|
|
|
mv src/libbitcoind.dylib "${os_dir}/libbitcoind.dylib"
|
|
|
|
fi
|
2014-12-06 17:18:12 -08:00
|
|
|
|
2014-12-06 16:43:53 -08:00
|
|
|
echo 'Build finished successfully.'
|