SUMMARY="Plugin framework for desktop services"
DESCRIPTION="KService provides a plugin framework for handling desktop \
services. Services can be applications or libraries. They can be bound to \
MIME types or handled by application specific code."
HOMEPAGE="https://github.com/KDE/kservice/"
COPYRIGHT="2010-2021 KDE Organisation"
LICENSE="GNU LGPL v2"
REVISION="1"
SOURCE_URI="https://github.com/KDE/kservice/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="1918bd22098f440ec3fa4fb1c379d8f35a842e6ea1583474740ddbabfe660844"

PATCHES="kservice-$portVersion.patchset"

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

GLOBAL_WRITABLE_FILES="
	settings/xdg/menus/applications.menu keep-old
	"

PROVIDES="
	kservice$secondaryArchSuffix = $portVersion
	cmd:kbuildsycoca5$secondaryArchSuffix = $portVersion
	lib:libKF5Service$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libKF5ConfigCore$secondaryArchSuffix
	lib:libKF5CoreAddons$secondaryArchSuffix
	lib:libKF5Crash$secondaryArchSuffix
	lib:libKF5DBusAddons$secondaryArchSuffix
	lib:libKF5I18n$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	"

PROVIDES_devel="
	kservice${secondaryArchSuffix}_devel = $portVersion
	devel:libKF5Service$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES_devel="
	kservice$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	extra_cmake_modules$secondaryArchSuffix >= $portVersion
	devel:libKF5ConfigCore$secondaryArchSuffix == $portVersion
	devel:libKF5CoreAddons$secondaryArchSuffix == $portVersion
	devel:libKF5Crash$secondaryArchSuffix == $portVersion
	devel:libKF5DBusAddons$secondaryArchSuffix == $portVersion
	devel:libKF5I18n$secondaryArchSuffix == $portVersion
	devel:libQt5Core$secondaryArchSuffix >= 5.7
	devel:libQt5DBus$secondaryArchSuffix >= 5.7
	devel:libQt5Xml$secondaryArchSuffix >= 5.7
	"
BUILD_PREREQUIRES="
	cmd:bison
	cmd:cmake
	cmd:flex
	cmd:g++$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:python2
	"

BUILD()
{
	mkdir -p build
	cd build

#	TODO: ECM_MKSPECS_INSTALL_DIR is not picked up unless defined
	cmake .. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DECM_DIR=/system/data/cmake/Modules/ECM/cmake \
		-DECM_MKSPECS_INSTALL_DIR=$dataDir/Qt5/mkspecs
	make $jobArgs
}

INSTALL()
{
	cd build
	make install
#	TODO: doesn't work for some reason
#	rm -rf $settingsDir

	prepareInstalledDevelLibs \
		libKF5Service

	packageEntries devel \
		$libDir/cmake \
		$dataDir/Qt5/mkspecs \
		$developDir
}

TEST()
{
	cd build
	make test
}
