# Template file for 'libtorrent'
pkgname=libtorrent
version=0.16.20
revision=1
build_style=gnu-configure
configure_args="--enable-static --disable-debug --without-kqueue
 --enable-aligned --with-posix-fallocate"
hostmakedepends="automake libtool pkg-config"
makedepends="libcurl-devel 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=f824c9a88dc7c0890476b28248134339163d10159af03127d9e9bbb2097be641

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

pre_configure() {
	# tests need ipv6 addy to function
	sed -e '/LibTorrent_Test_Torrent_Net/d' -i test/Makefile.am
	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"
	}
}
