# 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.26
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=('0ee631d5cfa45329b93a963e07cb250bc8f430c2d95cfb97658d786aaa15207d117a9d382698bfad1ce9913e73c2fb4a694b4a557002b0f75be67ef75bfb9e07')
b2sums=('f2d630de1b3dba71d1c19736921d26b83826289f5f1f70c5d545e6a6434993e690cbdfa72874aa7f5f26f9abcba8da732962fc4d1b6a3d37d798d269efb6e551')

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:
