SUMMARY="A BitTorrent protocol implementation"
DESCRIPTION="The library supports connectivity to HTTP and UDP trackers, \
mainline DHT and the new generation Micro Transport Protocol (uTP). In \
addition, it provides many powerful BitTorrent network features including \
but not limited to torrent downloading and seeding, torrent creation and \
downloaded data verification, magnet links, advanced peer management, IP \
blocking lists."
HOMEPAGE="https://github.com/KDE/libktorrent/"
COPYRIGHT="2010-2019 KDE Organisation"
LICENSE="GNU LGPL v2"
REVISION="2"
SOURCE_URI="https://github.com/KDE/libktorrent/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="897d970d8e06c82dfb43757b23e3079731dbb74bca259c559e25b7d574dfece4"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	libktorrent$secondaryArchSuffix = $portVersion compat >= 2.1
	lib:libKF5Torrent$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgcrypt$secondaryArchSuffix
	lib:libgmp$secondaryArchSuffix
	lib:libKF5Archive$secondaryArchSuffix
	lib:libKF5Completion$secondaryArchSuffix
	lib:libKF5ConfigCore$secondaryArchSuffix
	lib:libKF5CoreAddons$secondaryArchSuffix
	lib:libKF5Crash$secondaryArchSuffix
	lib:libKF5I18n$secondaryArchSuffix
	lib:libKF5JobWidgets$secondaryArchSuffix
	lib:libKF5KIOCore$secondaryArchSuffix
	lib:libKF5KIOWidgets$secondaryArchSuffix
	lib:libKF5Service$secondaryArchSuffix
	lib:libKF5Solid$secondaryArchSuffix
	lib:libKF5WidgetsAddons$secondaryArchSuffix
	lib:libqca_qt5$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	"

PROVIDES_devel="
	libktorrent${secondaryArchSuffix}_devel = $portVersion base
	devel:libKF5Torrent$secondaryArchSuffix
	"
REQUIRES_devel="
	libktorrent$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	extra_cmake_modules$secondaryArchSuffix >= 5.65
	devel:libboost_system$secondaryArchSuffix
	devel:libgcrypt$secondaryArchSuffix
	devel:libgmp$secondaryArchSuffix
	devel:libKF5Archive$secondaryArchSuffix
	devel:libKF5Auth$secondaryArchSuffix
	devel:libKF5Bookmarks$secondaryArchSuffix
	devel:libKF5Codecs$secondaryArchSuffix
	devel:libKF5Completion$secondaryArchSuffix
	devel:libKF5ConfigCore$secondaryArchSuffix
	devel:libKF5ConfigWidgets$secondaryArchSuffix
	devel:libKF5CoreAddons$secondaryArchSuffix
	devel:libKF5Crash$secondaryArchSuffix
	devel:libKF5I18n$secondaryArchSuffix
	devel:libKF5ItemViews$secondaryArchSuffix
	devel:libKF5JobWidgets$secondaryArchSuffix
	devel:libKF5KIOCore$secondaryArchSuffix
	devel:libKF5Service$secondaryArchSuffix
	devel:libKF5Solid$secondaryArchSuffix
	devel:libKF5WidgetsAddons$secondaryArchSuffix
	devel:libKF5XmlGui$secondaryArchSuffix
	devel:libqca$secondaryArchSuffix >= 2
	devel:libQt5Core$secondaryArchSuffix >= 5.14
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:python2
	cmd:qdbuscpp2xml$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build

	cmake .. $cmakeDirArgs \
		-DECM_DIR=/system/data/cmake/Modules/ECM/cmake \
		-DECM_MKSPECS_INSTALL_DIR=$dataDir/Qt5/mkspecs
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs \
		libKF5Torrent

	packageEntries devel \
		$libDir/cmake \
		$developDir

}

TEST()
{
	cd build
	make test
}
