# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: kastor <kastor@fobos.org.ar>

_name=pupnp
pkgname=libupnp
pkgver=1.14.25
pkgrel=1
pkgdesc='Portable Open Source UPnP Development Kit'
arch=(x86_64 aarch64)
url="https://pupnp.sourceforge.io/"
license=(BSD-3-Clause)
depends=(glibc)
makedepends=(cmake)
provides=(
  libixml.so
  libupnp.so
)
source=(https://github.com/$_name/$_name/archive/release-$pkgver/$_name-release-$pkgver.tar.gz)
sha512sums=('2aed5c72cb8e33b89d85e6755b99e7bd4e82ffb58d03ef58c2cdd790d4dc6c33b3a9f91168595930be53f0bb803e266e2bb02ea5fcc5cda8edada9453bf56492')
b2sums=('e502dbc8e57030e807e5f92a6bea41bab696d4fcc5259ce5ba4d130f9f88d56f77300757c988aecb913547a21cf1382791c72801aa26c64aaf71cbc32199f74a')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -D UPNP_BUILD_STATIC=OFF
    -D blocking_tcp_connections=OFF
    -D reuseaddr=ON
    -S $_name-release-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $_name-release-$pkgver/COPYING -t "$pkgdir/usr/share/licenses/$pkgname"
  install -vDm 644 $_name-release-$pkgver/{ChangeLog,README.md} -t "$pkgdir/usr/share/doc/$pkgname"
# Fix broken cmake files
  sed -e 's|/COMPONENT||g' -e 's|/UPNP_Development||g' -i "$pkgdir"/usr/lib/cmake/*/*.cmake
}

# vim: ts=2 sw=2 et:
