# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=gtksourceview3
pkgver=3.24.11+28+g73e57b57
pkgrel=1
pkgdesc="A text widget adding syntax highlighting and more to GNOME"
url="https://wiki.gnome.org/Projects/GtkSourceView"
arch=(x86_64)
license=(GPL)
depends=(gtk3 libxml2)
makedepends=(intltool gobject-introspection vala gtk-doc autoconf-archive
             yelp-tools git)
checkdepends=(xorg-server-xvfb)
_commit=73e57b5787ac60776c57032e05a4cc32207f9cf6  # gnome-3-24
source=("git+https://gitlab.gnome.org/GNOME/gtksourceview.git#commit=$_commit")
sha256sums=('SKIP')

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

prepare() {
  cd gtksourceview

  # Workaround incompat with recent autoconf-archive
  find . -name Makefile.am -exec sed -i '/@CODE_COVERAGE_RULES@/d' {} +

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd gtksourceview
  ./configure --prefix=/usr --sysconfdir=/etc \
      --localstatedir=/var --disable-static \
      --disable-glade-catalog --enable-gtk-doc --disable-Werror
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd gtksourceview
  dbus-run-session xvfb-run \
    -s '-screen 0 1920x1080x24 -nolisten local' \
    make check
}

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