# Maintainer: Márcio Silva <coadde@parabola.nu>
# based of mypaint

_pkgname=mypaint
pkgname=libmypaint-gegl-git
pkgver=r704.6477ad3
pkgrel=1
pkgdesc="MyPaint Libraries, with brush dynamics and GEGL support"
arch=('i686' 'x86_64' 'armv7h')
url="http://mypaint.org/"
license=('GPL' 'LGPL')
depends=('json-c' 'gegl')
makedepends=('git' 'intltool')
provides=("lib${_pkgname}")
conflicts=("lib${_pkgname}-gegl")
source=(lib${_pkgname}-${pkgver}::git+https://github.com/${_pkgname}/lib${_pkgname}.git)
md5sums=('SKIP')

pkgver() {
  cd lib${_pkgname}-${pkgver}
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd lib${_pkgname}-${pkgver}
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd lib${_pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --enable-docs \
    --enable-gegl \
    --with-glib
  make
}

package() {
  cd $srcdir/lib$_pkgname-$pkgver
  make DESTDIR="${pkgdir}" install

  # fixing headers files, it's needed for GIMP 2.9 and above package
  install -vdm 0755					$pkgdir/usr/include/glib
  ln -vs lib$_pkgname-gegl/$_pkgname-gegl-glib.h        $pkgdir/usr/include
  ln -vs lib$_pkgname-gegl/$_pkgname-gegl-surface.h	$pkgdir/usr/include
  ln -vs ../lib$_pkgname/glib/$_pkgname-brush.h		$pkgdir/usr/include/glib
  ln -vs lib$_pkgname/$_pkgname-brush-settings-gen.h	$pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-brush-settings.h	$pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-brush.h			$pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-config.h		$pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-fixed-tiled-surface.h	$pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-glib-compat.h		$pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-mapping.h               $pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-rectangle.h		$pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-surface.h		$pkgdir/usr/include
  ln -vs lib$_pkgname/$_pkgname-tiled-surface.h		$pkgdir/usr/include
}