##
 # @file build/MEGAsync/MEGAShellExtDolphin/PKGBUILD
 # @brief script to generate package dolphinmegasync for ArchLinux
 #
 # (c) 2013-2016 by Mega Limited, Auckland, New Zealand
 #
 # This file is part of the MEGA SDK - Client Access Engine.
 #
 # Applications using the MEGA API must present a valid application key
 # and comply with the the rules set forth in the Terms of Service.
 #
 # The MEGA SDK is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
 # @copyright Simplified (2-clause) BSD License.
 #
 # You should have received a copy of the license along with this
 # program.
##

pkgname=dolphin-megasync
pkgver=EXT_VERSION
pkgrel=`cat MEGA_BUILD_ID || echo "1"`
epoch=
pkgdesc="MEGA Desktop App plugin for Dolphin"
arch=('x86_64')
url="http://mega.nz/#sync"
license=() #TODO
depends=('megasync>=3.5' 'dolphin')
makedepends=('extra-cmake-modules' 'kde-sdk-meta' 'dolphin')
provides=("dolphin-megasync=${pkgver}")
conflicts=()
replaces=()
backup=()
options=()
changelog= #TODO
source=("./${pkgname}_$pkgver.tar.gz")
noextract=()
md5sums=('MD5SUM')
validpgpkeys=()

prepare() {
	cd "$pkgname-$pkgver"
}

build() {
	cd "$pkgname-$pkgver"
	cmake $PWD
	make
}

check() {
	cd "$pkgname-$pkgver"
}

package() {
	cd "$pkgname-$pkgver"
	make install DESTDIR=$pkgdir

	#fix missplaced .so for kf5
	if [ -d $pkgdir/usr/lib/qt5 ]; then
		cp -av $pkgdir/usr/lib/qt5/* $pkgdir/usr/lib/qt/
		rm -rf $pkgdir/usr/lib/qt5
	fi
}
