# $Id: PKGBUILD 236267 2015-04-11 15:07:47Z bpiotrowski $
# Maintainer: Daniel Isenmann <daniel@archlinux.org>

pkgname=gegl
pkgver=0.2.0
pkgrel=14
pkgdesc="Graph based image processing framework"
arch=('i686' 'x86_64')
url="http://www.gegl.org/"
license=('GPL3' 'LGPL3')
depends=('babl' 'libspiro')
makedepends=('intltool' 'ruby' 'lua' 'openexr' 'ffmpeg' 'librsvg' 'jasper' 'exiv2')
optdepends=('openexr: for using the openexr plugin'
            'ffmpeg: for using the ffmpeg plugin'
            'librsvg: for using the svg plugin'
            'jasper: for using the jasper plugin')
source=(http://ftp.gimp.org/pub/${pkgname}/${pkgver%.*}/${pkgname}-${pkgver}.tar.bz2
        gegl-0.2.0-ffmpeg-0.11.patch
        gegl-0.2.0-CVE-2012-4433.patch
        gegl-0.2.0-lua-5.2.patch
        gegl-0.2.0-remove-src-over-op.patch)
options=(!makeflags)
sha1sums=('764cc66cb3c7b261b8fc18a6268a0e264a91d573'
          'f5e4c0edd32e088f768e303081f1ed2d80588d4c'
          '44d48bd9ad008703de9f8eb683d557bac39a02c8'
          'c78a092b880874ba7784b652bcd9c532e2b9975d'
          'dc9ae21cc5ba0fb47ef05793f0cb169572dfab74')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -Np1 -i ../gegl-0.2.0-ffmpeg-0.11.patch
  patch -Np1 -i ../gegl-0.2.0-CVE-2012-4433.patch
  patch -Np1 -i ../gegl-0.2.0-lua-5.2.patch
  patch -Np1 -i ../gegl-0.2.0-remove-src-over-op.patch
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure  --prefix=/usr  --with-sdl --with-openexr --with-librsvg \
    --with-libavformat --with-jasper --disable-docs

  # https://bugzilla.gnome.org/show_bug.cgi?id=655517
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool

  make
}

check() {
  cd ${pkgname}-${pkgver}
  make check
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
}
