# Packager = Tuxcore <dev@tuxcore.org> 
pkgbase=lv2
pkgname=(lv2 lv2-docs lv2-example-plugins)
pkgver=1.18.10
pkgrel=1
pkgdesc="Plugin standard for audio systems"
arch=(x86_64)
url="https://lv2plug.in/"
license=(ISC)
makedepends=(
  asciidoc
  codespell
  doxygen
  flake8
  gtk2
  libsamplerate
  libsndfile
  meson
  pygmentize
  python-black
  python-lxml
  python-markdown
  python-pygments
  python-pylint
  python-rdflib
  serd
  sord
)
source=(https://lv2plug.in/spec/$pkgbase-$pkgver.tar.xz{,.sig})
sha512sums=('ab4bcf593f633b1ed16c0eb6aa4525458a00655ef9c87619bf85eaa966f8fd094a8e871b825f679e0d97923f8bbbf11841ff467022390ca2f1a5b5f66ccd5d1b'
            'SKIP')
b2sums=('72f9bc50ebac5d71279e0616bb1eb3c2a6748a28ff68988294135b18c7adc68c46a52b4698faf79f633768bf850d5052128a9f84b90aa9b5f9a56721acaf04c3'
        '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 $pkgbase-$pkgver build
  meson compile -C build
}

check() {
  meson test -C build
}

package_lv2() {
  optdepends=(
    'lv2-docs: for developer documentation'
    'lv2-example-plugins: for example plugins'
    'python-lxml: for lv2specgen.py'
    'python-markdown: for lv2specgen.py'
    'python-pygments: for lv2specgen.py'
    'python-rdflib: for lv2specgen.py'
    'sord: for lv2_validate'
  )

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

  (
    cd "$pkgdir"
    _pick lv2-docs usr/share/doc/lv2/
    _pick lv2-example-plugins usr/lib/lv2/eg-*
  )

  install -vDm 644 $pkgbase-$pkgver/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 $pkgbase-$pkgver/{NEWS,README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}

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

  mv -v $pkgname/* "$pkgdir"
  install -vDm 644 $pkgbase-$pkgver/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
}

package_lv2-example-plugins() {
  pkgdesc+=" - example plugins"
  depends=(libsamplerate libsndfile lv2-host)
  optdepends=(
    'gtk2: for eg-sampler.lv2 and eg-scope.lv2'
  )
  groups=(lv2-plugins pro-audio)

  mv -v $pkgname/* "$pkgdir"
  install -vDm 644 $pkgbase-$pkgver/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
}

# vim:set ts=2 sw=2 et:
