# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Daniel Isenmann <daniel@archlinux.org>

# WARNING: upstream is abandonware: https://github.com/mono/libgdiplus/issues/744
pkgname=libgdiplus
pkgver=6.1
pkgrel=2
url='https://www.mono-project.com/docs/gui/libgdiplus/'
pkgdesc='Open Source Implementation of the GDI+ API'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=(MIT)
depends=(
  'cairo'
  'fontconfig'
  'glib2'
  'glibc'
  'harfbuzz'
  'libexif'
  'libjpeg-turbo'
  'libpng'
  'libtiff'
  'libx11'
  'pango'
)
makedepends=('giflib')
# NOTE: tests all broken due to gtest changes:
# https://github.com/mono/libgdiplus/issues/737
# https://github.com/mono/libgdiplus/issues/743
source=("https://github.com/mono/libgdiplus/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('c51f2702eb5eee0b7975ddc5840888d11cc0d3ea0e6c3c49afca42ef4ca90064b9ece30c447948647c950a1af36f780c79b7d07b304ec3a855cbf3da2371e94d')
b2sums=('e7c02b046fbf310e281833df651b30276bca555145842dae0ba3c14aa130b74663e9ea88f4b6e39e143b5278e5248f5407646c0d4c7038809bda98fa47800832')

prepare() {
  cd $pkgname-$pkgver
  # do not update the submodule, gtest based tests are broken anyways
  sed -e 's/: update_submodules/:/' -i Makefile.am
  autoreconf -fiv
}

build() {
  cd $pkgname-$pkgver
  ./configure \
    --prefix=/usr \
    --with-pango

  # prevent excessive overlinking due to libtool
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  depends+=('giflib' 'libgif.so')

  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" \
    NEWS README.md TODO AUTHORS ChangeLog
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}

# vim: ts=2 sw=2 et:
