# Template file for 'akonadi5'
pkgname=akonadi5
version=23.08.5
revision=3
build_style=cmake
build_helper="qemu"
hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools python3
 shared-mime-info libxslt pkg-config gettext qt5-tools-devel
 kconfig kcoreaddons"
makedepends="qt5-devel qt5-plugin-mysql qt5-plugin-odbc qt5-plugin-pgsql
 qt5-plugin-sqlite qt5-plugin-tds kcompletion-devel kconfigwidgets-devel
 kdbusaddons-devel kiconthemes-devel kitemmodels-devel kio-devel sqlite-devel
 qt5-tools-devel"
checkdepends="dbus ${depends}"
short_desc="PIM layer providing an asynchronous API to access PIM data"
maintainer="John <me@johnnynator.dev>"
license="LGPL-2.1-or-later"
homepage="https://community.kde.org/KDE_PIM/Akonadi"
distfiles="${KDE_SITE}/release-service/${version}/src/akonadi-${version}.tar.xz"
checksum=abdbdb28c1084a6ad119d7292175ad31efb4a7898a32cc32a35aa1485d9c4f38
conflicts="kf6-akonadi>=0"

pre_configure() {
	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
		vsed -e "s;^\(target_link_libraries(.*\);\1 atomic;" -i src/server/CMakeLists.txt
	fi
}

do_check() {
	# failing tests are disabled - sqlite tests hang on futex
	cd build
	dbus-run-session ctest -E \
		"(AkonadiServer-dbconfig|entitytreemodel|akonadixml-xmldocument|mimetypechecker|AkonadiControl-agenttype|.*sqlite.*)test"
}

post_install() {
	# TODO once everything moved to kf6-akonadi, drop them
	# It's needed to kmymoney, for now, conflicts with kf6-akonadi
	# kmail built with akonadi5 doesn't work with kf6-akonadi
	# fix conflict with akonadi
	: rm -r "${DESTDIR}"/{etc,usr/{bin,share}}
}

akonadi5-devel_package() {
	short_desc+=" - development files"
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/qt5/mkspecs
		vmove usr/lib/cmake
		vmove usr/lib/*.so
	}
}
