# $Id: PKGBUILD 136945 2015-07-15 06:36:28Z arojas $
# Maintainer:  Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Mateusz Herych
# Contributor: Jaroslaw Swierczynski <swiergot@aur.archlinux.org>

pkgname=kadu
pkgver=2.1
pkgrel=2
pkgdesc='Qt-based Jabber/XMPP and Gadu-Gadu client'
arch=('i686' 'x86_64')
url='http://www.kadu.net/'
license=('GPL')
depends=('libgadu' 'libxss' 'enchant' 'phonon-qt5' 'qca-qt5' 'libidn'
         'libmpdclient' 'libotr' 'libarchive' 'injeqt' 'xdg-utils' 'qt5-multimedia'
         'qt5-quick1' 'qt5-x11extras' 'qt5-svg' 'hicolor-icon-theme')
makedepends=('cmake' 'libao' 'libsndfile' 'libxtst' 'curl' 'chrpath' 'ninja'
             'qt5-tools')
install=kadu.install
source=(http://download.kadu.im/stable/$pkgname-$pkgver.tar.bz2 qdatastream.patch qt_dock_icon.patch)
md5sums=('b40f95123b1167c51c26bee8d56577d2'
         '289814966b21db02efab4125eec41b74'
         '961d79dbbf5ec5827b8cda424773b9c8')

prepare() {
  sed -i 's/unity_integration//g' $pkgname-$pkgver/Plugins.cmake
  sed -i 's/indicator_docking//g' $pkgname-$pkgver/Plugins.cmake

# Fix build with coinstallable Qca-qt5
  sed -i 's|<QtCrypto/QtCrypto>|<Qca-qt5/QtCrypto/QtCrypto>|g' $pkgname-$pkgver/kadu-core/main.cpp

# Fix build with Qt 5.5
  cd $pkgname-$pkgver
  patch -p1 -i "$srcdir"/qdatastream.patch

# Fix tray icon in Plasma 5 http://www.kadu.im/redmine/issues/3020
  patch -p2 -i "$srcdir"/qt_dock_icon.patch
}

build() {
  mkdir build
  cd build

  cmake ../$pkgname-$pkgver \
    -GNinja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=/usr/lib \
    -DQT_QMAKE_EXECUTABLE=qmake-qt4
  ninja
}

package() {
  DESTDIR="$pkgdir" LIBDIR=/usr/lib ninja -C build install
  chrpath -d "$pkgdir"/usr/lib/kadu/plugins/*.so
}
