# Template file for 'libtorrent'
pkgname=libtorrent
version=0.13.8
revision=5
build_style=gnu-configure
configure_args="--enable-static --disable-debug --without-kqueue
 --enable-aligned --with-posix-fallocate"
hostmakedepends="automake libtool pkg-config"
makedepends="openssl-devel zlib-devel"
# XXX: if built with XBPS_CHECK_PKGS, final binary will be dyn linked against libcppunit
checkdepends="libcppunit-devel"
short_desc="BitTorrent library written in C++"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://github.com/rakshasa/libtorrent"
distfiles="https://github.com/rakshasa/libtorrent/archive/v${version}.tar.gz"
checksum=0f6c2e7ffd3a1723ab47fdac785ec40f85c0a5b5a42c1d002272205b988be722

# https://github.com/rakshasa/rtorrent/issues/156
case "$XBPS_TARGET_MACHINE" in
	ppc64*) ;;
	ppc*|mips*) configure_args+=" --disable-instrumentation";;
esac

pre_configure() {
	autoreconf -fi
	sed -e 's,test "$cross_compiling" = yes, false,' -i configure
}

post_configure() {
	# Replace wrong (for cross buidls) -L/lib in Makefiles
	for f in $(find ${wrksrc} -name Makefile); do
		sed -i $f -e "s;-L/lib;-L${XBPS_CROSS_BASE}/lib;g"
	done
}

libtorrent-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
	}
}
