# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
# Contributor: Knut Franke <Knut.Franke ad gmx dot de>
# Contributor: Olaf Leidinger <leidola at newcon dot de>
# Contributor: Robal <nigrantis.tigris at gmail dot com>

pkgname=scidavis
pkgver=1.D4
pkgrel=1
pkgdesc="Application for Scientific Data Analysis and Visualization, fork of QtiPlot"
arch=('i686' 'x86_64')
url="http://scidavis.sourceforge.net/"
license=('GPL')
depends=('gsl' 'mesa' 'muparser' 'python2-pyqt4' 'shared-mime-info' 
         'qt-assistant-compat' 'qwt' 'qwtplot3d')
source=(http://prdownloads.sourceforge.net/sourceforge/scidavis/${pkgname}.${pkgver}.tar.gz
        scidavis-python2.patch
        scidavis-qtassistant.patch
        scidavis-qwt5.patch)
install=${pkgname}.install
md5sums=('a429ad206e44b23ad2dd4b8a94d63876'
         'a0cdc1b257a158a848e37c91122bd5f7'
         'f891b7a14b5b3f1dbf9a0df2a4e8ea1d'
         'd622f925d7677556cba55f98f3735aa9')

prepare() {
  cd "${srcdir}"
  # fix python
  patch -p0 -i "${srcdir}/scidavis-python2.patch"
  # fix qtassistant
  patch -p0 -i "${srcdir}/scidavis-qtassistant.patch"
  # fix qwt
  patch -p0 -i "${srcdir}/scidavis-qwt5.patch"
}

build() {
  cd "${srcdir}/${pkgname}.${pkgver}"
  qmake-qt4
  make
}

package() {
  cd "${srcdir}/${pkgname}.${pkgver}"
  make INSTALL_ROOT="${pkgdir}" install

  _pydir=$(python2 -c "from distutils import sysconfig; print sysconfig.get_python_lib()")
  python2 $(dirname ${_pydir})/py_compile.py "${pkgdir}/etc/scidavisrc.py"
  python2 $(dirname ${_pydir})/py_compile.py "${pkgdir}/usr/share/scidavis/scidavisUtil.py"
}

