# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=networkmanager-openconnect
pkgver=1.2.10
pkgrel=2.1
pkgdesc="NetworkManager VPN plugin for OpenConnect"
url="https://wiki.gnome.org/Projects/NetworkManager"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=(GPL)
depends=(
  libnm
  libsecret
  openconnect
)
makedepends=(
  gcr
  git
  intltool
  libnma
  libnma-gtk4
  python
  webkit2gtk-4.1
)
optdepends=(
  'gcr: GUI support'
  'libnma-gtk4: GUI support (GTK 4)'
  'libnma: GUI support (GTK 3)'
  'webkit2gtk-4.1: GUI support'
)
_commit=a28d393b5fc9e0df9c19292065187e7145e83f51  # tags/1.2.10^0
source=("git+https://gitlab.gnome.org/GNOME/NetworkManager-openconnect.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd NetworkManager-openconnect
  git describe --tags | sed 's/-dev/dev/;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd NetworkManager-openconnect
  intltoolize --automake --copy
  autoreconf -fvi
}

build() {
  cd NetworkManager-openconnect
  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
    --libexecdir=/usr/lib --disable-static --with-gtk4
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  depends+=(libopenconnect.so)

  cd NetworkManager-openconnect
  make DESTDIR="$pkgdir" install dbusservicedir=/usr/share/dbus-1/system.d
  echo 'u nm-openconnect - "NetworkManager OpenConnect"' |
    install -Dm644 /dev/stdin "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
}

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