# 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.D5
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' 'glu' 'mesa' 'muparser' 'python2-pyqt4' 'shared-mime-info' 
         'qt-assistant-compat' 'qwt5' '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=('2bc5cde484544bd3f570e8cd6125812b'
         '467cb6e8f6577ad54ea8b4371bc09118'
         'c4e257140ed772c08be2a151ae725634'
         '8d3f9b4cafd886ca4835178c44b03db5')

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"
}

