# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=openfec
pkgver=1.4.2.11
pkgrel=1
pkgdesc="Open Forward Erasure Codecs"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url="http://openfec.org/"
license=(
  CECILL-2.0
  CECILL-C
)
depends=(glibc)
makedepends=(cmake)
provides=(libopenfec.so)
# NOTE: we are using roc-streaming's version, because the original upstream is effectively dead:
# https://github.com/roc-streaming/openfec
source=(https://github.com/roc-streaming/openfec/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('e77da3997296e6518574102e54af2f60d27a691bb32ea9eb61a5de714974e35287d2c18e1564fa7d299fa2191af1ad718ffd8f9fd5ad7ea468aca0dd6b88e9e5')
b2sums=('d54fcb6f3a6ea76e44519384fb288e1a896315642175694ed887ee7637c9b479d94a4e461e446b92baf669695f496eb30b5b7836b86b297c3cc95bd63edbd48d')

build() {
  local cmake_options=(
    -B build
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_INSTALL_LIBDIR=lib
    -DBUILD_SHARED_LIBS=ON
    -S $pkgname-$pkgver
    -W no-dev
  )

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

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

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/{LICENCE,Licence}* -t "$pkgdir/usr/share/licenses/$pkgname/"
}
