# Template file for 'libtorrent-rasterbar'
# Breaks ABI/API without changing soname, revbump all dependants
pkgname=libtorrent-rasterbar
version=1.2.18
revision=5
build_style=cmake
configure_args="-Dbuild_examples=ON -Dbuild_tools=ON
 -Dpython-bindings=ON -Dbuild_tests=ON"
hostmakedepends="pkg-config gettext python3-devel python3-setuptools"
makedepends="openssl-devel boost-devel geoip-devel python3-devel"
short_desc="C++ bittorrent library by Rasterbar Software"
maintainer="Orphaned <orphan@voidlinux.org>"
license="BSD-3-Clause"
homepage="https://libtorrent.org/"
distfiles="https://github.com/arvidn/libtorrent/releases/download/v${version}/${pkgname}-${version}.tar.gz"
checksum=fef2b6817de4e6d960e019c27f21daf27bc2468a81d9e028a19d45d61456fa72

CXXFLAGS="-std=c++14"

make_check=ci-skip
# TODO: The test_resume failed in CI for i686 but passed with xbps-uunshare

pre_configure() {
	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
		vsed -i CMakeLists.txt -e "s;Threads::Threads;& atomic;"
	fi
}


post_install() {
	local f

	# Install examples. They are not installed with make install :P
	for f in client_test connection_tester dump_torrent simple_client upnp_test \
		custom_storage make_torrent stats_counters; do
		vbin ${wrksrc}/build/examples/${f}
	done
	vlicense LICENSE
}

libtorrent-rasterbar-python3_package() {
	lib32disabled=yes
	short_desc+=" - Python3 bindings"
	pkg_install() {
		vmove "usr/lib/python3*"
	}
}

libtorrent-rasterbar-devel_package() {
	depends="${sourcepkg}>=${version}_${revision} openssl-devel boost-devel geoip-devel"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/share/cmake
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
	}
}

libtorrent-rasterbar-examples_package() {
	short_desc+=" - example binaries"
	pkg_install() {
		vmove usr/bin
	}
}
