# Maintainer: Christian Hesse <mail@eworm.de>
# Maintainer: Christian Heusel <gromit@archlinux.org>
# Contributor: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Daniel Isenmann <daniel@archlinux.org>

pkgname=gimp
pkgver=2.10.36
pkgrel=6
pkgdesc='GNU Image Manipulation Program'
url='https://www.gimp.org/'
arch=('x86_64' 'aarch64')
license=('GPL' 'LGPL')
depends=(
  # Core deps
  'babl' 'cairo' 'fontconfig' 'freetype2' 'gcc-libs' 'gdk-pixbuf2' 'gegl' 'glib2' 'glibc' 'gtk2'
  'harfbuzz' 'hicolor-icon-theme' 'iso-codes' 'json-glib' 'lcms2' 'libgexiv2' 'libmypaint'
  'libunwind' 'mypaint-brushes1' 'pango' 'zlib'

  # Plugins deps
  'bzip2' 'libgudev' 'libheif' 'libjpeg-turbo' 'libjxl' 'libmng' 'libpng' 'librsvg' 'libtiff'
  'libwebp' 'libwmf' 'libx11' 'libxcursor' 'libxext' 'libxfixes' 'libxmu' 'libxpm' 'openexr'
  'openjpeg2' 'poppler-data' 'poppler-glib' 'xz' 'aalib'
)
makedepends=('alsa-lib' 'ghostscript' 'gtk-doc' 'gvfs' 'intltool')
optdepends=('alsa-lib: for MIDI event controller module'
            'ghostscript: for PostScript support'
            'gutenprint: for sophisticated printing only as gimp has built-in cups print support'
            'gvfs: for HTTP/S support (and many other schemes)')
conflicts=('gimp-plugin-wavelet-decompose')
replaces=('gimp-plugin-wavelet-decompose')
install=gimp.install
source=(https://download.gimp.org/pub/gimp/v${pkgver%.*}/${pkgname}-${pkgver}.tar.bz2
        gimp-2_10_36_fix-crash-on-exit.patch::https://gitlab.gnome.org/GNOME/gimp/-/merge_requests/1444.patch
        0001-no-check-update.patch
        linux.gpl)
sha256sums=('3d3bc3c69a4bdb3aea9ba2d5385ed98ea03953f3857aafd1d6976011ed7cdbb2'
            'd153c8968fb88bd935a7cb4d1b1c7b235abb79e123fcc12f6096da63330ef13a'
            'ac3e8b44cf391f4ab3050652f2cc1f146f451fb25178d5a596d905f5bad13fcf'
            '1003bbf5fc292d0d63be44562f46506f7b2ca5729770da9d38d3bb2e8a2f36b3')

prepare() {
  cd ${pkgname}-${pkgver}

  patch -Np1 < ../0001-no-check-update.patch
  # https://gitlab.archlinux.org/archlinux/packaging/packages/gimp/-/issues/2
  patch -Np1 < ../gimp-2_10_36_fix-crash-on-exit.patch

  autoreconf -vi
}

build() {
  cd ${pkgname}-${pkgver}

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --libexecdir=/usr/bin \
    --enable-mp \
    --enable-gimp-console \
    --enable-gtk-doc \
    --disable-check-update \
    --disable-python \
    --with-bug-report-url='https://gitlab.archlinux.org/archlinux/packaging/packages/gimp/-/issues' \
    --with-openexr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd ${pkgname}-${pkgver}

  make DESTDIR="${pkgdir}" install
  install -D -m644 "${srcdir}/linux.gpl" "${pkgdir}/usr/share/gimp/2.0/palettes/Linux.gpl"

  rm "${pkgdir}/usr/share/man/man1/gimp-console.1"
  ln -s gimp-console-${pkgver%.*}.1.gz "${pkgdir}/usr/share/man/man1/gimp-console.1.gz"
  ln -s gimptool-2.0 "${pkgdir}/usr/bin/gimptool"
  ln -sf gimptool-2.0.1.gz "${pkgdir}/usr/share/man/man1/gimptool.1.gz"
}

# vim: ts=2 sw=2 et:
