# Maintainer: PktSurf <smlinux@pktsurf.in>
app=gimp
version=2.10.34
build=1sml
homepage="https://www.gimp.org/"
download="https://download.gimp.org/mirror/pub/gimp/v2.8/gimp-2.8.22.tar.bz2"
desc="The GNU Image Manipulation Program"
requires="libexif alsa-lib curl libgudev babl gtk2 dbus-glib gegl glib-networking hicolor-icon-theme lcms2 libwebp openjpeg"

prepbuilddir() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  # We might have an issue with pagecurl causing gimp to segfault
  # https://gitlab.gnome.org/GNOME/gimp/-/issues/4392
  # remove /lib/gimp/2.0/plug-ins/pagecurl ?

  # credits: sabotage linux

  sed -i 's@^[[:space:]]*-I$(includedir)@@' $(find . -name Makefile.in)
  sed -i 's@^libgimpui = .*$@libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la $(top_builddir)/libgimpmodule/libgimpmodule-$(GIMP_API_VERSION).la@' $(find plug-ins/ -name Makefile.in)
  sed -i 's@^libgimpconfig = .*$@libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la $(top_builddir)/libgimpmath/.libs/libgimpmath-$(GIMP_API_VERSION).la@' $(find plug-ins/ -name Makefile.in)
  printf '#!/bin/sh\necho -lfreetype -I/usr/include/freetype2\n' > freetype-config
  chmod +x freetype-config
  export PATH="$PWD:$PATH"
}

build() {
  ./configure \
    --prefix="/" \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --disable-altivec \
    --disable-python \
    --disable-alsatest \
    --disable-nls \
    --disable-silent-rules \
    --disable-glibtest \
    --without-webkit 

  for i in po po-plug-ins po-python po-libgimp po-script-fu po-tips ; do           
    printf 'all:\n\ttrue\ninstall:\n\ttrue\nclean:\n\ttrue\n' > "$i"/Makefile
  done    

  make
  make install DESTDIR=$pkg

  cp COPYING $pkgdocs/

  mkfinalpkg
}

sha512sums="
4802ce3758daba868570f1ac97a3f1cb41e1130fcc6376f9bf4c999441f8fd25937aa71b6f726d82d7c780f4153b11d2595bb76bc2356a42266909fbcc0bd34a  gimp-2.10.34.tar.bz2
"
