SUMMARY="Desktop Syncing Client for ownCloud"
DESCRIPTION="The ownCloud Desktop Client is a tool to synchronize
files from ownCloud Server with your computer."
HOMEPAGE="https://github.com/owncloud/client"
COPYRIGHT="Klaas Freitag
ownCloud GmbH"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://download.owncloud.com/desktop/stable/owncloudclient-$portVersion.13407.tar.xz"
CHECKSUM_SHA256="d8a7381e5f17d255342a3bace52d906c08bb1e76e07a89eeb14e3fda8bad41ca"
SOURCE_DIR="owncloudclient-$portVersion.13407"
PATCHES="owncloud_client-$portVersion.patchset"

ARCHITECTURES="!x86_gcc2 ?x86"
SECONDARY_ARCHITECTURES="?x86"

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	cmd:owncloud
	cmd:owncloudcmd
	libowncloud_csync${secondaryArchSuffix} = $portVersion
	libowncloudsync${secondaryArchSuffix} = $portVersion
	lib:libowncloud_csync$secondaryArchSuffix = $portVersion
	lib:libowncloudsync$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku${secondaryArchSuffix}
	lib:libcmocka$secondaryArchSuffix
	lib:libQt5Concurrent$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix >= 5.14.0
	lib:libqt5keychain$secondaryArchSuffix
	lib:libqt5Network$secondaryArchSuffix
	lib:libqt5Test$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libowncloud_csync${secondaryArchSuffix}_devel = $portVersion
	libowncloudsync${secondaryArchSuffix}_devel = $portVersion
	devel:libowncloud_csync$secondaryArchSuffix = $portVersion
	devel:libowncloudsync$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	owncloud_client${secondaryArchSuffix} == $portVersion base
	devel:libQt5Gui$secondaryArchSuffix >= 5.14.0
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	extra_cmake_modules$secondaryArchSuffix
	devel:libcmocka$secondaryArchSuffix
	devel:libQt5Concurrent$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5DBus$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix >= 5.14.0
	devel:libqt5keychain$secondaryArchSuffix
	devel:libqt5Network$secondaryArchSuffix
	devel:libqt5Test$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++${secondaryArchSuffix}
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:linguist$secondaryArchSuffix >= 5
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	mkdir -p build
	cd build
	# FindZLIB actually finds libzlib from OpenCollada,
	# work around it by forcing the path
	cmake $cmakeDirArgs \
		-DCMAKE_INSTALL_BINDIR=$commandBinDir \
		-DECM_DIR=/system/data/cmake/Modules/ECM/cmake \
		-DZLIB_LIBRARY=/system/$relativeDevelopLibDir/libz.so \
		..
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	# we did tell you it does not belong here already...
	mkdir -p $includeDir
	mv $prefix/include/owncloudsync $includeDir/
	rmdir $prefix/include

	prepareInstalledDevelLibs \
		libowncloud_csync \
		libowncloudsync
	packageEntries devel \
		$developDir
}
