# Maintainer: Christian Hesse <mail@eworm.de>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - patch to fix signed char declaration for ARM

pkgname=gimp-nufraw
_realver=0.43-3
pkgver=0.43.3
pkgrel=10
pkgdesc='Converter for raw files; utility and GIMP plugin'
url='https://sourceforge.net/projects/nufraw/'
arch=('x86_64')
license=('GPL')
depends=('cfitsio' 'exiv2' 'gtkimageview' 'lcms2' 'lensfun' 'libjpeg-turbo')
makedepends=('gimp')
conflicts=('gimp-ufraw')
replaces=('gimp-ufraw')
optdepends=('gimp: to use the gimp import plugin for raw images')
source=("https://downloads.sourceforge.net/nufraw/nufraw-${_realver}.tar.gz"
        '0001-nufraw-glib-2.70.patch'
        '0002-exiv2-error.patch'
         signed-char.patch)
sha256sums=('2c7dcc1590993ec267b3112562b2433010d6f94f6acc6506c76aa29cf8c6c32c'
            '042aa55a757c4ed1198fe4628c87933f958d768c2cd5270db1b2e4369daaf090'
            '01fd29b180662da1a1510236bc64fac614229adaf1bc7b11df8b88745d6458da'
            '93b20b1b6634de7b56a6b50fe35f320dbf68e9dc7b530c5540a88637a14d3fa0')

prepare() {
  cd "nufraw-${_realver}"

  # fix build with glib 2.70
  patch -p1 < ../0001-nufraw-glib-2.70.patch

  # fix build with exiv2 0.28.0
  patch -p1 < ../0002-exiv2-error.patch

  patch -p1 < ../signed-char.patch

  # fix metadata path with appstream
  sed -i '/appdatadir/s|/appdata|/metainfo/|' Makefile.am

  autoreconf -fi

  mv nufraw.desktop{.desktop,}
  chmod +x generate_schemas.sh
}

build() {
  cd "nufraw-${_realver}"

  ./configure \
    --prefix='/usr' \
    --enable-extras \
    --enable-mime \
    --enable-openmp \
    --with-gimp \
    --with-cinepaint \
    --enable-contrast
  make
}

package() {
  make -C "nufraw-${_realver}" DESTDIR="$pkgdir" install
  rm -f "$pkgdir/usr/bin/dcraw"
}