# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libvpx
pkgver=1.15.0
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.14.1-r0:
#     - CVE-2024-5197
#   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="
8f483653a324c710fd431b87fd0d5d6f476f006bd8c8e9c6d1fa6abd105d6a40ac81c8fd5638b431c455d57ab2ee823c165e9875eb3932e6e518477422da3a7b  libvpx-v1.15.0.tar.gz
4eadbc2f4eb68eaff35cf85515aef271d6fd47293a53cba7b7a6e9e0fb71106dfb5ded45b9e9ba83264a91846e4a5fa4db42e39fc3eaff6ac37769e622f90f6c  fix-arm-float-abi.patch
"
