# $Id$
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Brice Carpentier <brice@daknet.org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - drop valgrind makedepend

pkgname=cairo
pkgver=1.15.12
pkgrel=1
pkgdesc="2D graphics library with support for multiple output devices"
url="https://cairographics.org/"
arch=(x86_64)
license=(LGPL MPL)
depends=(libpng libxrender libxext fontconfig pixman glib2 lzo)
makedepends=(librsvg gtk2 poppler-glib libspectre gtk-doc git)
_commit=7149686456ec3c481fa1d3dbe76a0dab1e42b519  # tags/1.15.12^0
source=("git+https://anongit.freedesktop.org/git/cairo#commit=$_commit"
        utf-8.diff)
sha1sums=('SKIP'
          '3f680dea8533bcce4ca2af5d25c546235ef7b339')

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

prepare() {
  cd $pkgname

  # Fixup tag for pkgver()
  git tag -f 1.15.10 5e6b9aeb5e3402ff17ae8ee8548ae2341c2f7d59

  # Fix non-UTF-8 sources giving gtk-doc trouble
  patch -Np1 -i ../utf-8.diff

  # Update gtk-doc
  cp /usr/share/aclocal/gtk-doc.m4 build/aclocal.gtk-doc.m4
  cp /usr/share/gtk-doc/data/gtk-doc.make build/Makefile.am.gtk-doc

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure --prefix=/usr \
        --sysconfdir=/etc \
        --localstatedir=/var \
        --disable-static \
        --disable-gl \
        --enable-tee \
        --enable-svg \
        --enable-ps \
        --enable-pdf \
        --enable-gobject \
        --enable-gtk-doc
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  # https://people.gnome.org/~federico/blog/helping-cairo.html
  #make check
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
}