# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libvpx
pkgver=1.14.1
pkgrel=0
pkgdesc="Library for the vp8/vp9 codecs"
url="https://www.webmproject.org/"
arch="all"
license="BSD-3-Clause"
makedepends="coreutils nasm bash perl diffutils linux-headers" # linux-headers is needed on ppc64le
subpackages="$pkgname-dev $pkgname-utils"
source="https://github.com/webmproject/libvpx/archive/v$pkgver/libvpx-v$pkgver.tar.gz
	fix-arm-float-abi.patch
	"
# net required for tests
# tests disabled due to failing to find symbols
options="!check"

# secfixes:
#   1.13.0-r3:
#     - CVE-2023-5217
#   1.8.2-r0:
#     - CVE-2020-0034
#   1.8.1-r0:
#     - CVE-2019-9371
#     - CVE-2019-9433
#     - CVE-2019-9325
#     - CVE-2019-9232

# GCC13 unrecognized '-mlsx' '-mlasx' on loongarch64
[ "$CARCH" = "loongarch64" ] && _target="--target=generic-gnu"

build() {
	# build fix for arm
	export CROSS=" "
	export CFLAGS="$CFLAGS -O2 -flto=auto -ffat-lto-objects"
	export CXXFLAGS="$CXXFLAGS -O2 -flto=auto -ffat-lto-objects"
	./configure \
		--prefix=/usr \
		--disable-install-srcs \
		--disable-static \
		--enable-libs \
		--enable-multithread \
		--enable-pic \
		--enable-postproc \
		--enable-runtime-cpu-detect \
		--enable-shared \
		--enable-temporal-denoising \
		--enable-unit-tests \
		--enable-vp8 \
		--enable-vp9 \
		--enable-vp9-highbitdepth \
		--enable-vp9-postproc \
		--enable-vp9-temporal-denoising \
		$_target
	make
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
}

utils() {
	pkgdesc="$pkgdesc (tools)"

	amove usr/bin
}

sha512sums="
3e3bfad3d035c0bc3db7cb5a194d56d3c90f5963fb1ad527ae5252054e7c48ce2973de1346c97d94b59f7a95d4801bec44214cce10faf123f92b36fca79a8d1e  libvpx-v1.14.1.tar.gz
4eadbc2f4eb68eaff35cf85515aef271d6fd47293a53cba7b7a6e9e0fb71106dfb5ded45b9e9ba83264a91846e4a5fa4db42e39fc3eaff6ac37769e622f90f6c  fix-arm-float-abi.patch
"
