# $Id: PKGBUILD 240016 2015-06-02 06:46:29Z arojas $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgbase=kdeedu-marble
pkgname=('kdeedu-marble' 'marble-qt')
pkgver=15.04.2
pkgrel=1
pkgdesc="Desktop Globe"
url="http://kde.org/applications/education/marble/"
arch=('i686' 'x86_64')
license=('GPL' 'LGPL' 'FDL')
makedepends=('kdelibs' 'qt5-svg' 'qt5-webkit' 'qt5-script' 'qt5-tools' 'cmake' 'automoc4' 'gpsd' 'quazip' 'libwlocate')
source=("http://download.kde.org/stable/applications/${pkgver}/src/marble-${pkgver}.tar.xz")
sha1sums=('055a59c6e6eaaa7cdb5ba837b1987dab35c93686')

prepare() {
  mkdir -p build{,-qt}
}

build() {
  cd build
  cmake ../marble-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DKDE4_BUILD_TESTS=OFF \
    -DCMAKE_INSTALL_PREFIX=/usr
  make

  cd ../build-qt
  cmake ../marble-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DQT5BUILD=TRUE \
    -DCMAKE_INSTALL_PREFIX=/usr
}

package_kdeedu-marble() {
  depends=('kdebase-runtime')
  optdepends=('gpsd: GPS support' 'libwlocate: WLAN based geolocation'
            'quazip: reading and displaying KMZ files')
  groups=('kde-applications' 'kdeedu')
  install=$pkgname.install
            
  cd build
  make DESTDIR="${pkgdir}" install
# remove mobile and qt4 versions
  rm -r "$pkgdir"/usr/bin/marble-*
  rm -r "$pkgdir"/usr/share/applications/kde4/marble-*
}

package_marble-qt() {
  pkgdesc="Desktop Globe (Qt version)"
  depends=('qt5-svg' 'qt5-webkit' 'qt5-script')
  optdepends=('gpsd: GPS support' 'libwlocate: WLAN based geolocation'
          'quazip: reading and displaying KMZ files')
  conflicts=('kdeedu-marble')
  install=$pkgname.install  

  cd build-qt
  make DESTDIR="${pkgdir}" install
# remove mobile version
  rm -r "$pkgdir"/usr/bin/marble-{mobile,touch}
  rm -r "$pkgdir"/usr/share/applications/marble-{mobile,touch}.desktop
}
