# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgbase=gspell
pkgname=(
  gspell
  gspell-docs
)
pkgver=1.14.1
pkgrel=2
pkgdesc="Spell-checking library for GTK applications"
url="https://gitlab.gnome.org/GNOME/gspell"
arch=(x86_64 aarch64)
license=(LGPL-2.1-or-later)
depends=(
  enchant
  glib2
  glibc
  gtk3
  icu
)
makedepends=(
  git
  glib2-devel
  gobject-introspection
  gtk-doc
  meson
  vala
)
checkdepends=(
  aspell
  hspell
  hunspell
  hunspell-en_us
  libvoikko
  nuspell
  xorg-server-xvfb
)
source=("git+https://gitlab.gnome.org/GNOME/gspell.git#tag=$pkgver")
b2sums=('958d87df47d310f5153c16ce2d2d313c519c6508a34428d76cbc69cea66a29e290b69785ec98faecbfdff6a4c2ec7d47f65de4943ae1bffa60b552ac8baa5c1a')

prepare() {
  cd gspell
}

build() {
  local meson_options=(
    -D install_tests=false
  )

  arch-meson gspell build "${meson_options[@]}"
  meson compile -C build
}

check() {
  echo '*:hunspell' > enchant.ordering
  ENCHANT_CONFIG_DIR="$PWD" \
    xvfb-run -s '-nolisten local' \
    meson test -C build --print-errorlogs
}

package_gspell(){
  depends+=(
    libenchant-2.so
    libgtk-3.so
    libg{lib,object,io}-2.0.so
    libicuuc.so
    libpango-1.0.so
  )
  provides+=("libgspell-${pkgver%%.*}.so")

  meson install -C build --destdir "$pkgdir"

  mkdir -p doc/usr/share
  mv {"$pkgdir",doc}/usr/share/gtk-doc
}

package_gspell-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mv doc/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
