# $Id: PKGBUILD 240918 2015-06-15 09:00:49Z arojas $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=cantor
pkgver=15.04.2
pkgrel=2
pkgdesc="KDE Frontend to Mathematical Software"
url="http://kde.org/applications/education/cantor/"
arch=('i686' 'x86_64')
license=('GPL' 'LGPL' 'FDL')
groups=('kde-applications' 'kdeedu')
depends=('analitza' 'libspectre' 'libqalculate' 'kdelibs4support' 'kpty' 'ktexteditor' 'knewstuff')
makedepends=('extra-cmake-modules' 'python' 'python2' 'kdoctools' 'luajit' 'r')
optdepends=('maxima: Maxima backend'
            'octave: Octave backend'
            'r: R backend'
            'luajit: LUA backend'
            'python: Python 3 backend'
	    'python2: Python 2 backend'
            'sagemath: SageMath backend')
conflicts=('kdeedu-cantor')
replaces=('kdeedu-cantor')
install=${pkgname}.install
source=("http://download.kde.org/stable/applications/${pkgver}/src/cantor-${pkgver}.tar.xz" 'r-3.2.patch')
sha1sums=('55b75171071deead3d22553d058342976b5b1ecd'
          '97fa0a72f1b9b23d658f754b821da12215b255e7')

prepare() {
  mkdir -p build

# Fix build with R 3.2
  cd $pkgname-$pkgver
  patch -p1 -i "$srcdir"/r-3.2.patch
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTING=OFF \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DKDE_INSTALL_USE_QT_SYS_PATHS=ON \
    -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 \
    -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so
  make
}

package() {
  cd "${srcdir}"/build
  make DESTDIR="${pkgdir}" install
}
