# Contributor: Knut Franke - Knut.Franke*gmx.de
# Contributor: Olaf Leidinger <leidola@newcon.de>
# Contributor: Robal <nigrantis.tigris*.gmail.com>
# Maintainer: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>

pkgname=scidavis
pkgver=0.2.4
pkgrel=9
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' 'qwtplot3d' 'qwt5')
source=(http://prdownloads.sourceforge.net/sourceforge/scidavis/${pkgname}-${pkgver}.tar.bz2
        multipeakfit.h.patch
        scidavis.pro.patch
        scidavis.sip.patch
        scidavis-python2.patch
        qt-assistant-compat.patch
        qwt5.patch)
install=${pkgname}.install
md5sums=('c5650475c5e0b22f9ee5dc49630a0e89'
         '59ac672f49e1e4e034bfdfb566b99589'
         '2ec36f34039ca8cd6db2401b1215590b'
         'c17bf09fa34cc9a75675d95b1585147f'
         'ff0a7cb32e8ed439f008bfd114cbf611'
         '2fefdab0fa536098637e7250efcd727e'
         '159aad53f13328123d42bfb7a4adf1b8')

prepare()
{
  cd "${srcdir}/${pkgname}-${pkgver}/${pkgname}"
  # fix private to public
  patch -p0 < "${srcdir}/multipeakfit.h.patch"
  # disable building self library
  patch < "${srcdir}/scidavis.pro.patch"
  # fix bug http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=655776
  patch -p0 < "${srcdir}/scidavis.sip.patch"
  # change python to python2
  patch < "${srcdir}/scidavis-python2.patch"
  # fix path to QtAssistant header
  patch -p0 < "${srcdir}/qt-assistant-compat.patch"
  # change qwt to qwt5
  patch < "${srcdir}/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"
}

