2014-12-06 16:43:53 -08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-12-06 17:18:12 -08:00
|
|
|
cur_dir="$(pwd)"
|
2014-12-06 16:43:53 -08:00
|
|
|
os_dir=$(dirname "$(./platform/os.sh)")
|
2014-12-06 17:18:12 -08:00
|
|
|
|
2014-12-07 00:02:31 -08:00
|
|
|
if test -e "${os_dir}/libbitcoind.so"; then
|
|
|
|
read -r -p 'libbitcoind.so 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
|
2014-12-07 00:02:31 -08:00
|
|
|
echo 'libbitcoind.so ready.'
|
|
|
|
exit 0
|
|
|
|
fi
|
2014-12-07 00:56:43 -08:00
|
|
|
rm -f "${os_dir}/libbitcoind.so"
|
2014-12-07 00:02:31 -08:00
|
|
|
fi
|
|
|
|
|
2014-12-06 17:18:12 -08:00
|
|
|
if test -n "$1"; then
|
|
|
|
if test "$1" = 'remote'; then
|
2014-12-07 00:56:43 -08:00
|
|
|
echo 'git clone'
|
2014-12-06 17:31:49 -08:00
|
|
|
git clone git://github.com/bitcoin/bitcoin.git libbitcoind || exit 1
|
|
|
|
btc_dir="${cur_dir}/libbitcoind"
|
2014-12-06 17:18:12 -08:00
|
|
|
else
|
|
|
|
btc_dir=$1
|
2014-12-06 17:31:49 -08:00
|
|
|
if ! test -d "$btc_dir"; then
|
|
|
|
"$0" remote
|
|
|
|
exit 0
|
|
|
|
fi
|
2014-12-06 17:18:12 -08:00
|
|
|
fi
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
btc_dir="${HOME}/bitcoin"
|
2014-12-06 17:31:49 -08:00
|
|
|
if ! test -d "$btc_dir"; then
|
|
|
|
"$0" remote
|
|
|
|
exit 0
|
|
|
|
fi
|
2014-12-06 17:18:12 -08:00
|
|
|
fi
|
2014-12-06 16:43:53 -08:00
|
|
|
|
2014-12-07 00:56:43 -08:00
|
|
|
echo "Found BTC directory: $btc_dir"
|
|
|
|
|
|
|
|
echo './patch-bitcoin.sh' "$btc_dir"
|
2014-12-06 16:43:53 -08:00
|
|
|
./patch-bitcoin.sh "$btc_dir" || exit 1
|
|
|
|
|
|
|
|
cd "$btc_dir" || exit 1
|
|
|
|
|
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:53:27 -08:00
|
|
|
bdb_compat=0
|
|
|
|
if cat /usr/include/db.h | grep -i DB_VERSION_STRING | grep -q 'DB 4.8' \
|
|
|
|
|| test -e /usr/include/db4.8 \
|
|
|
|
|| test -e /usr/include/db4.8.h; then
|
|
|
|
bdb_compat=1
|
|
|
|
fi
|
|
|
|
if test $bdb_compat -eq 0; then
|
|
|
|
set -- "--with-incompatible-bdb" "$@"
|
|
|
|
fi
|
|
|
|
|
2014-12-07 00:56:43 -08:00
|
|
|
echo './autogen.sh'
|
2014-12-06 16:43:53 -08:00
|
|
|
./autogen.sh || exit 1
|
2014-12-06 17:18:12 -08:00
|
|
|
if test -n "$1"; then
|
2014-12-07 00:56:43 -08:00
|
|
|
echo './configure --enable-daemonlib' "$@"
|
2014-12-07 00:53:27 -08:00
|
|
|
./configure --enable-daemonlib "$@" || exit 1
|
2014-12-06 17:18:12 -08:00
|
|
|
else
|
2014-12-07 00:56:43 -08:00
|
|
|
echo './configure --enable-daemonlib'
|
2014-12-07 00:53:27 -08:00
|
|
|
./configure --enable-daemonlib || exit 1
|
2014-12-06 17:18:12 -08:00
|
|
|
fi
|
2014-12-07 00:56:43 -08:00
|
|
|
echo 'make'
|
2014-12-06 16:43:53 -08:00
|
|
|
make || exit 1
|
|
|
|
|
2014-12-07 00:56:43 -08:00
|
|
|
echo 'Copying libbitcoind.so to its appropriate location.'
|
2014-12-06 16:43:53 -08:00
|
|
|
cp src/libbitcoind.so "${os_dir}/libbitcoind.so" || exit 1
|
|
|
|
|
2014-12-06 17:18:12 -08:00
|
|
|
cd "$cur_dir"
|
2014-12-06 17:36:24 -08:00
|
|
|
rm -rf libbitcoind
|
2014-12-06 17:18:12 -08:00
|
|
|
|
2014-12-06 16:43:53 -08:00
|
|
|
echo 'Build finished successfully.'
|
|
|
|
exit 0
|