# Template file for 'nextcloud-client'
pkgname=nextcloud-client
version=3.0.3
revision=1
wrksrc="desktop-${version}"
build_style=cmake
configure_args="-Wno-dev $(vopt_if shibboleth '' '-DNO_SHIBBOLETH=True')
 -DNO_WEBENGINE=True"
hostmakedepends="pkg-config"
makedepends="qt5-tools-devel qt5-declarative-devel qt5-webchannel-devel
 qt5-location-devel qtkeychain-qt5-devel sqlite-devel libcloudproviders-devel
 qt5-quickcontrols2-devel
 $(vopt_if dolphin 'extra-cmake-modules kio-devel')
 qt5-webkit-devel"
depends="qt5-graphicaleffects"
checkdepends="cmocka-devel"
conf_files="/etc/Nextcloud/sync-exclude.lst"
short_desc="NextCloud Desktop client"
maintainer="yopito <pierre.bourgin@free.fr>"
license="GPL-2.0-or-later"
homepage="https://nextcloud.com/clients/"
distfiles="https://github.com/nextcloud/desktop/archive/v${version}.tar.gz"
checksum=abd021ff06ecb267221a221dbf8b4efd3bd8e418053cc49b6b6faa290717c6d8

build_options="dolphin shibboleth"
desc_option_dolphin="Build KDE dolphin support"
desc_option_shibboleth="Build Shibboleth support (needs Qt5 WebKit)"
build_options_default="dolphin shibboleth"

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" qt5-qmake qt5-host-tools qt5-tools"
	# provides desktoptojson
	hostmakedepends+=" $(vopt_if dolphin 'kcoreaddons')"
fi

subpackages="$(vopt_if dolphin 'nextcloud-client-dolphin') nextcloud-client-devel"

if [ "$XBPS_CHECK_PKGS" ]; then
	configure_args+=" -DUNIT_TESTING=1"
	# argp.h is used only by testing and is not a requirement.
	# since usable (linking fails), let's disable it instead
	case "$XBPS_TARGET_MACHINE" in
		#*-musl) export LDFLAGS=-largp;;
		*-musl) configure_args+=" -DHAVE_ARGP_H=0";;
	esac
fi

nextcloud-client-dolphin_package() {
	short_desc+=" - KDE dolphin integration"
	depends="nextcloud-client>=${version}_${revision}"
	pkg_install() {
		vmove usr/lib/libnextclouddolphinpluginhelper.so
		vmove usr/lib/qt5
		vmove usr/share/kservices5
	}
}

nextcloud-client-devel_package() {
	depends="nextcloud-client>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/libnextcloudsync.so
		vmove "usr/lib/nextcloud/*.so"
	}
}
