# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: William Díaz <wdiaz@archlinux.us>

pkgname=libnice
pkgver=0.1.22
pkgrel=2
pkgdesc="Nice: GLib ICE library"
url="https://libnice.freedesktop.org/"
arch=(x86_64 aarch64)
license=('MPL-1.1 OR LGPL-2.1-only')
depends=(
  glib2
  glibc
  gnutls
  gupnp-igd
)
makedepends=(
  git
  glib2-devel
  gobject-introspection
  graphviz
  gstreamer
  gtk-doc
  meson
)
optdepends=('gstreamer: "nice" GStreamer plugin')
provides=(libnice.so)
source=(
  "git+https://gitlab.freedesktop.org/libnice/libnice.git#tag=$pkgver"
  0001-Update-for-gupnp-igd-1.6.patch
)
b2sums=('a4ac4db7d29ae1085bc88d9c1c1acd3427c81f99ac4e3f08ed63784073acc0131063898a18bcd396c2f9bdaf7ef01a5e43a34fb839795480c384990fa20c76ed'
        'bdef1ab55744d926699f5595bbcf664d7a9f1b3a623d74271a714cffed3099ea1774cfc5ca32e09efd3c281dfed3c9152ba709e89c84acfeecf4d58bb0808267')

prepare() {
  cd libnice

  # https://gitlab.freedesktop.org/libnice/libnice/-/merge_requests/255
  git apply -3 ../0001-Update-for-gupnp-igd-1.6.patch

  # https://gitlab.freedesktop.org/libnice/libnice/-/issues/181
  git cherry-pick -n e4d838024b4b96fe4787afaa5d2d99dc9653104b
}

build() {
  local meson_options=(
    -D gtk_doc=enabled
  )

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

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir"
}

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