# Contributor: Marian Buschsieweke <marian.buschsieweke@posteo.net>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
pkgname=libvolk
pkgver=3.1.2
_cpufeaturesver=0.9.0
pkgrel=2
pkgdesc="Vector-Optimized Library of Kernels"
url="https://www.libvolk.org/"
arch="all"
license="LGPL-3.0-or-later"
depends="python3"
makedepends="cmake py3-mako boost-dev orc-dev samurai"
checkdepends="bash"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/gnuradio/volk/archive/v$pkgver.tar.gz
	cpu_features-$_cpufeaturesver.tar.gz::https://github.com/google/cpu_features/archive/v$_cpufeaturesver.tar.gz
	"
builddir="$srcdir/volk-$pkgver"

prepare() {
	default_prepare

	rm -r cpu_features
	ln -s "../cpu_features-$_cpufeaturesver" cpu_features

	# for test ...
	ln -s docs/AUTHORS_RESUBMITTING_UNDER_LGPL_LICENSE.md AUTHORS_RESUBMITTING_UNDER_LGPL_LICENSE.md
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest -E "qa_volk_16ic_x2_dot_prod_16ic"
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

sha512sums="
65d34d3eccbaf0f4c887b2127875e9a16216bce18e2e3d71cfaefa956a6b73a95872a251ea01cd61e6b6b5378f6be544203bad2575d074e6f51bcf74718ce8d6  libvolk-3.1.2.tar.gz
4e732f46b3b9efe48f0b6d06cfa87b3b25ed00e51c42de84c74cbbd4d66bd0974ff1a757b91574c6a3064cba6e5c2460117dd23b79b4136e5d1cd7e78dda47b1  cpu_features-0.9.0.tar.gz
"
