# $Id: PKGBUILD 271532 2016-07-12 17:20:33Z arojas $
# Maintainer (Arch): Felix Yan <felixonmars@archlinux.org>
# Contributor (Arch): Andrea Scarpino <andrea@archlinux.org>
# Contributor (Arch): Pierre Schmitz <pierre@archlinux.de>
# Maintainer: André Silva <emulatorman@parabola.nu>
pkgbase=kdepim
pkgname=(akonadiconsole kaddressbook kmail knotes korganizer)
pkgver=16.04.3
pkgrel=1.nonprism1
arch=('i686' 'x86_64')
url='http://pim.kde.org'
license=('GPL' 'LGPL' 'FDL')
groups=('kde-applications' 'kdepim')
makedepends=(extra-cmake-modules kdepim-runtime qt5-tools kdoctools knewstuff kpimtextedit
             ktexteditor kdnssd kldap libktnef kontactinterface kxmlrpcclient kblog akonadi-search boost
             libgravatar mailcommon incidenceeditor libksieve python kdesignerplugin)
source=("http://download.kde.org/stable/applications/$pkgver/src/$pkgbase-$pkgver.tar.xz")
sha1sums=('3c107ffa31de10c19ef479630d349708e85813d9')

prepare() {
	mkdir -p build
}

build() {
	cd build
	cmake ../$pkgbase-$pkgver \
		-DCMAKE_BUILD_TYPE=Release \
		-DBUILD_TESTING=OFF \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DKDE_INSTALL_LIBEXECDIR=lib \
		-DKDEPIM_STORAGESERVICE_GDRIVE=OFF
	make
}

package_akonadiconsole() {
	pkgdesc='Akonadi Management and Debugging Console, without Google Drive support'
	depends=(calendarsupport messagelib hicolor-icon-theme)
	conflicts=("kdepim-$pkgname")
	replaces=("kdepim-$pkgname")
	url='http://pim.kde.org'

	cd build/akonadiconsole
	make DESTDIR="$pkgdir" install
}

package_kaddressbook() {
	pkgdesc='Contact Manager, without Google Drive support'
	depends=('kdepim-common' 'kontactinterface')
	optdepends=('kdepim-addons: additional plugins')
	conflicts=("kdepim-$pkgname")
	replaces=("kdepim-$pkgname")
	url="http://kde.org/applications/office/kaddressbook/"

	cd "$srcdir"/build/kaddressbook
	make DESTDIR="$pkgdir" install
}

package_kmail() {
	pkgdesc='Mail Client, without Google Drive support'
	depends=(kdepim-common kontactinterface kio-pim libksieve kdepim-addons)
	optdepends=('kleopatra: mail encryption support' 'kdepim-addons: additional plugins')
	conflicts=("kdepim-$pkgname")
	replaces=("kdepim-$pkgname")
	url="http://kde.org/applications/internet/kmail/"

	for _i in kmail agents/archivemailagent agents/mailfilteragent \
	  storageservicemanager importwizard grantleeeditor mboximporter sieveeditor; do
	  cd "$srcdir"/build/$_i
	  make DESTDIR="$pkgdir" install
	done

	for _i in akonadi_archivemail_agent kmail importwizard sieveeditor; do
	  cd "$srcdir"/build/doc/$_i
	  make DESTDIR="$pkgdir" install
	done
}

package_knotes() {
	pkgdesc='Popup Notes, without Google Drive support'
	depends=('kdepim-common' 'kontactinterface')
	conflicts=("kdepim-$pkgname")
	replaces=("kdepim-$pkgname")
	url="http://kde.org/applications/utilities/knotes/"

	cd "$srcdir"/build/knotes
	make DESTDIR="$pkgdir" install

	for _i in knotes akonadi_notes_agent; do
	  cd "$srcdir"/build/doc/$_i
	  make DESTDIR="$pkgdir" install
	done
}

package_korganizer() {
	pkgdesc='Calendar and Scheduling Program, without Google Drive support'
	depends=('kdepim-common' 'kontactinterface')
	optdepends=('kdepim-addons: additional plugins')
	conflicts=("kdepim-$pkgname")
	replaces=("kdepim-$pkgname")
	url="http://kde.org/applications/office/korganizer"

	for _i in korganizer korgac; do
	  cd "$srcdir"/build/$_i
	  make DESTDIR="$pkgdir" install
	done

	cd "$srcdir"/build/doc/korganizer
	make DESTDIR="$pkgdir" install
}