# Template file for 'bitcoin'
pkgname=bitcoin
version=0.16.3
revision=1
build_style=gnu-configure
configure_args="--with-incompatible-bdb --disable-ccache --disable-static --enable-hardening --with-boost=${XBPS_CROSS_BASE}/usr"
hostmakedepends="pkg-config yasm"
makedepends="db-devel protobuf-devel boost-devel miniupnpc-devel libevent-devel
 qrencode-devel libatomic-devel"
short_desc="Bitcoin is a peer-to-peer network based digital currency"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="MIT"
homepage="https://bitcoin.org/"
distfiles="https://bitcoin.org/bin/bitcoin-core-${version}/bitcoin-${version}.tar.gz"
checksum=836eed97dfc79cff09f356e8fbd6a6ef2de840fb9ff20ebffb51ccffdb100218
conflicts="litecoin>=0" # Both provide libbitcoinconsensus.so.0

if [ -z "$CROSS_BUILD" ]; then
	# XXX -qt subpkg
	makedepends+=" qt5-devel qt5-tools-devel"
	configure_args+=" --with-gui"
fi

pre_configure() {
	extra_files="
		https://raw.github.com/bitcoin/bitcoin/v${version}/contrib/debian/bitcoin-qt.desktop
		https://raw.github.com/bitcoin/bitcoin/v${version}/share/pixmaps/bitcoin128.png
		https://raw.github.com/bitcoin/bitcoin/v${version}/contrib/debian/examples/bitcoin.conf
		https://raw.github.com/bitcoin/bitcoin/v${version}/doc/man/bitcoind.1"
	for f in ${extra_files}; do
		$XBPS_FETCH_CMD $f
	done
}


post_install() {
	rm "${DESTDIR}"/usr/bin/test_bitcoin
	rm "${DESTDIR}"/usr/bin/bench_bitcoin

	if [ -z "$CROSS_BUILD" ]; then
		rm "${DESTDIR}"/usr/bin/test_bitcoin-qt
	fi

	vlicense COPYING
}

bitcoin-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		vdoc doc/shared-libraries.md # Provides information on libbitcoinconsensus
	}
}

if [ -z "$CROSS_BUILD" ]; then

bitcoin-qt_package() {
	depends="desktop-file-utils"
	short_desc+=" - QT GUI"
	pkg_install() {
		vmove usr/bin/bitcoin-qt
		vmove usr/share/man/man1/bitcoin-qt.1
		vinstall bitcoin-qt.desktop 644 usr/share/applications
		vinstall bitcoin128.png 644 usr/share/pixmaps
		vlicense COPYING
	}
}

fi # !CROSS_BUILD
