# Packager = Tuxcore <dev@tuxcore.org> 
pkgbase=sord
pkgname=(sord sord-docs)
pkgver=0.16.16
pkgrel=1
pkgdesc="A lightweight C library for storing RDF data in memory"
arch=(x86_64)
url="https://drobilla.net/software/sord.html"
license=(ISC)
makedepends=(
  doxygen
  glibc
  meson
  pcre2
  python-sphinx
  serd
  zix
)
source=(https://download.drobilla.net/$pkgname-$pkgver.tar.xz{,.sig})
sha512sums=('8728fa01466e8f64c1a70a6d4ce727cdac3aaba78db0163ad511d7e959a260c95ab47405cce24ca0e076fb1f0da761687d788cddef87a96aa813757d10f0bfe0'
            'SKIP')
b2sums=('e657f6e4d38df1c254ce6282ae54a6795e29fd60546373a2b4e1560b269658fa69dd93af4d6f75eaa73f9f777a2d82f99f80d34fd65e1001b8231b63af71029f'
        'SKIP')

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

build() {
  arch-meson $pkgname-$pkgver build
  meson compile -C build
}

check() {
  meson test -C build
}

package_sord() {
  depends=(
    glibc
    pcre2
    serd libserd-0.so
    zix libzix-0.so
  )
  provides=(libsord-0.so)
  optdepends=('sord-docs: for developer documentation')

  meson install -C build --destdir "$pkgdir"
  (
    cd "$pkgdir"
    _pick $pkgname-docs usr/share/doc
  )
  install -vDm 644 $pkgname-$pkgver/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 $pkgname-$pkgver/{AUTHORS,NEWS,README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}

package_sord-docs() {
  pkgdesc+=" - documentation"

  mv -v $pkgname/* "$pkgdir"
  mv -v "$pkgdir/usr/share/doc/"sord{-0,}
}
