SUMMARY="Additional components to increase the functionality of KIO"
DESCRIPTION="A kioslave is a plugin designed to be intimately familiar with a \
certain protocol, so that a standardized interface can be used to get at data \
from any number of places. A few examples are the http and ftp kioslaves, \
which using nearly identical methods will retrieve data from an http or ftp \
server respectively.
This package also supports the following protocols:
* fish
* mtp
* sftp
* smb"
HOMEPAGE="https://github.com/KDE/kio-extras/"
COPYRIGHT="2010-2019 KDE Organisation"
LICENSE="GNU LGPL v2"
REVISION="3"
SOURCE_URI="https://github.com/KDE/kio-extras/archive/v$portVersion.tar.gz"
SOURCE_DIR="kio-extras-$portVersion"
CHECKSUM_SHA256="5a0c97d699990bfe4200d15867d37125c8dbfe6e8a61106b2b34c3668060e844"
PATCHES="kio_extras-$portVersion.patchset"

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

GLOBAL_WRITABLE_FILES="
	settings/xdg/kio-extras.categories keep-old
	"

PROVIDES="
	kio_extras$secondaryArchSuffix = $portVersion
	lib:libkioarchive$secondaryArchSuffix = $portVersion compat >= 5
	lib:libmolletnetwork5$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libKF5Activities$secondaryArchSuffix
	lib:libKF5Archive$secondaryArchSuffix
	lib:libKF5Auth$secondaryArchSuffix
	lib:libKF5Bookmarks$secondaryArchSuffix
	lib:libKF5Codecs$secondaryArchSuffix
	lib:libKF5Completion$secondaryArchSuffix
	lib:libKF5ConfigCore$secondaryArchSuffix
	lib:libKF5ConfigWidgets$secondaryArchSuffix
	lib:libKF5CoreAddons$secondaryArchSuffix
	lib:libKF5DBusAddons$secondaryArchSuffix
	lib:libKF5DNSSD$secondaryArchSuffix
	lib:libKF5GuiAddons$secondaryArchSuffix
	lib:libKF5I18n$secondaryArchSuffix
	lib:libKF5IconThemes$secondaryArchSuffix
	lib:libKF5ItemViews$secondaryArchSuffix
	lib:libKF5KIOCore$secondaryArchSuffix
	lib:libKF5JobWidgets$secondaryArchSuffix
	lib:libKF5Pty$secondaryArchSuffix
	lib:libKF5Service$secondaryArchSuffix
	lib:libKF5Solid$secondaryArchSuffix
	lib:libKF5WidgetsAddons$secondaryArchSuffix
	lib:libKF5WindowSystem$secondaryArchSuffix
	lib:libKF5XmlGui$secondaryArchSuffix
	lib:libmtp$secondaryArchSuffix
	lib:libphonon4qt5$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libsmbclient$secondaryArchSuffix
	lib:libssh$secondaryArchSuffix
	lib:libssp$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	extra_cmake_modules$secondaryArchSuffix
	devel:libKF5Activities$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:libKF5DBusAddons$secondaryArchSuffix
	devel:libKF5DNSSD$secondaryArchSuffix
	devel:libKF5DocTools$secondaryArchSuffix
	devel:libKF5GuiAddons$secondaryArchSuffix
	devel:libKF5I18n$secondaryArchSuffix
	devel:libKF5IconThemes$secondaryArchSuffix
	devel:libKF5ItemViews$secondaryArchSuffix
	devel:libKF5JobWidgets$secondaryArchSuffix
	devel:libKF5KIOCore$secondaryArchSuffix
	devel:libKF5Pty$secondaryArchSuffix
	devel:libKF5Service$secondaryArchSuffix
	devel:libKF5Solid$secondaryArchSuffix
	devel:libKF5WidgetsAddons$secondaryArchSuffix
	devel:libKF5WindowSystem$secondaryArchSuffix
	devel:libKF5XmlGui$secondaryArchSuffix
	devel:libmtp$secondaryArchSuffix
	devel:libphonon4qt5$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libsmbclient$secondaryArchSuffix
	devel:libssh$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:gperf
	cmd:lrelease$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:find
	cmd:update_mime_database$secondaryArchSuffix
	"

TEST_REQUIRES="
	qthaikuplugins$secondaryArchSuffix #it opens windows during the tests, maybe we don't want that on the buildbots.
	"

BUILD()
{
	# disable docs generation
	sed -e '/add_subdirectory( doc )/ s/^#*/#/' -i CMakeLists.txt

	mkdir -p build
	cd build

	cmake .. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DKDE_INSTALL_PLUGINDIR=$addOnsDir/Qt5 \
		-DECM_DIR=/system/data/cmake/Modules/ECM/cmake \
		-DLIBSSH_LIBRARIES="-lssh" \
		-DCMAKE_CXX_FLAGS="-fstack-protector"
	make $jobArgs
}

INSTALL()
{
	cd build
	make $jobArgs install

	rm -rf $dataDir/mime/{aliases,generic-icons,globs,globs2,icons,magic}
	rm -rf $dataDir/mime/{mime.cache,subclasses,treemagic,types,version,XMLnamespaces}

	prepareInstalledDevelLibs \
		libkioarchive \

	packageEntries devel \
		$libDir/cmake \
		$developDir
}

TEST()
{
	export LIBRARY_PATH="$sourceDir/build/bin${LIBRARY_PATH:+:$LIBRARY_PATH}"
	cd build
	make test
}
