APP=mtpaint
VERSION=3.40
BUILD=1sml
HOMEPAGE="http://mtpaint.sourceforge.net/"
DOWNLOAD="https://sourceforge.net/projects/mtpaint/files/mtpaint/3.40/mtpaint-3.40.tar.bz2"
DESC="Paint program in GTK2"
REQUIRES="giflib openjpeg gtk2 lcms2"

build() {
  mkandenterbuilddir
  rm -rf $APP-$VERSION

  tar xf $SRCDIR/$APP-$VERSION.tar.?z*
  cd $APP-$VERSION
  fixbuilddirpermissions


  # bring deprecated function call into conformance with libpng14
  sed -i 's/png_set_gray_1_2_4_to_8/png_set_expand_gray_1_2_4_to_8/' src/png.c

  # Fix build with giflib-5.1 (thanks to Arch)
  sed -i 's:EGifOpenFileName(file_name, FALSE):EGifOpenFileName(file_name, FALSE, NULL):' src/png.c
  sed -i 's:DGifOpenFileName(file_name):DGifOpenFileName(file_name, NULL):g' src/png.c
  sed -i 's:EGifCloseFile(giffy):EGifCloseFile(giffy, NULL):g' src/png.c
  sed -i 's:DGifCloseFile(giffy):DGifCloseFile(giffy, NULL):g' src/png.c
  sed -i 's:MakeMapObject(:GifMakeMapObject(:g' src/png.c
  sed -i 's:FreeMapObject(:GifFreeMapObject(:g' src/png.c

  ./configure \
    --prefix="" 

  make
  make install DESTDIR=$PKG

  install -Dm 644 doc/mtpaint.1 $PKG/share/man/man1/mtpaint.1
  cp COPYING $PKGDOCS/

  mkfinalpkg
}

SHA512SUMS="
abcf74b11403019f6f3c563b0d3de9dd27eb9fb7c0a279ad5b866eea6074538dcf1d3900fca3cc782a922fbf79cd1b625337328a53704167eb77055c7a8f509e  mtpaint-3.40.tar.lz
"
