SUMMARY="BitTorrent library written in C++ for *nix"
DESCRIPTION="libtorrent is a C++ implementation of the BitTorrent protocol \
with the goals of being efficient and easy to use."
HOMEPAGE="http://libtorrent.rakshasa.no/"
COPYRIGHT="2005-2019 Jari Sundell"
LICENSE="GNU LGPL v2"
REVISION="1"
SOURCE_URI="https://github.com/rakshasa/rtorrent/releases/download/v0.9.8/libtorrent-$portVersion.tar.gz"
CHECKSUM_SHA256="ed115a28f4ae8cfcd33b94a597c076ca74fd549867a26e4fac9505c27288e983"
PATCHES="libtorrent-$portVersion.patchset"

ARCHITECTURES="all ?x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	libtorrent$secondaryArchSuffix = $portVersion
	lib:libtorrent$secondaryArchSuffix = $portVersion compat >= 0.13
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:gettext$secondaryArchSuffix
	lib:libcppunit$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libtorrent${secondaryArchSuffix}_devel = $portVersion
	devel:libtorrent$secondaryArchSuffix = $portVersion compat >= 0.13
	"
REQUIRES_devel="
	haiku${secondaryArchSuffix}_devel
	libtorrent$secondaryArchSuffix == $portVersion base
	cmd:gettext$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	devel:libcppunit$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcppunit$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libgettextlib$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoreconf
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:strip$secondaryArchSuffix
	"

BUILD()
{
	autoreconf -vfi
	export CFLAGS=-D_BSD_SOURCE
	runConfigure ./configure --disable-mincore
	make $jobArgs
}

INSTALL()
{
	make install
	rm -f $libDir/libtorrent.la

	strip $libDir/*.so

	prepareInstalledDevelLibs libtorrent
	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
