# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: jtts <jussaar@mbnet.fi>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgname=lib32-librsvg
pkgver=2.46.0
pkgrel=1
pkgdesc="SVG rendering library (32-bit)"
url="https://wiki.gnome.org/Projects/LibRsvg"
arch=(x86_64)
license=(LGPL)
depends=(lib32-gdk-pixbuf2 lib32-pango lib32-libcroco librsvg)
makedepends=(intltool gobject-introspection vala python2 gtk-doc git lib32-rust)
_commit=b4aa8d277d30f4042797dc8b64c073b10f8bac4b  # tags/2.46.0^0
source=("git+https://gitlab.gnome.org/GNOME/librsvg.git#commit=$_commit"
        multilib.diff)
sha256sums=('SKIP'
            'c32283a724e8d1a87ad64330ee72781396b6f439dcae0f56da074e9a988ec544')

pkgver() {
  cd librsvg
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd librsvg

  # Hack to cross-compile rust only
  patch -Np1 -i ../multilib.diff

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  export CC='gcc -m32'
  export CXX='g++ -m32'
  export PKG_CONFIG_PATH=/usr/lib32/pkgconfig
  export RUST_TARGET=i686-unknown-linux-gnu

  cd librsvg
  ./configure --prefix=/usr --disable-static --enable-vala --disable-gtk-doc --libdir=/usr/lib32
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0 /g' libtool
  make
}

check() {
  cd librsvg
  # Reftests are probably broken
  # e.g. 91-nonzero-translation-ref.png's background is only 95% transparent,
  # while 91-nonzero-translation-out.png is 100% transparent
  make check || :
}

package() {
  cd librsvg
  make DESTDIR="$pkgdir" install
  rm -r "$pkgdir"/usr/{bin,include,share}
}

# vim: ts=2 sw=2 et:
