# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=libde265
pkgver=1.0.9
pkgrel=0
pkgdesc="Open h.265 video codec implementation"
url="https://github.com/strukturag/libde265"
arch="all"
license="LGPL-3.0-or-later"
makedepends="autoconf automake libtool"
options="!check"  # no tests provided
subpackages="$pkgname-dev $pkgname-examples"
source="https://github.com/strukturag/libde265/releases/download/v$pkgver/libde265-$pkgver.tar.gz
	export-only-decoder-api.patch
	disable_tools.patch
	"
# secfixes:
#   1.0.8-r2:
#     - CVE-2021-35452
#     - CVE-2021-36408
#     - CVE-2021-36410
#     - CVE-2021-36411
#     - CVE-2022-1253

prepare() {
	default_prepare
	autoreconf -fvi
}

build() {
	# This is en/decoder, so performance matters more than size.
	export CPPFLAGS="${CPPFLAGS/-Os/-O2}"
	export CXXFLAGS="${CXXFLAGS/-Os/-O2}"

	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--disable-sherlock265
	make
}

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

	# The upstream do the same in their Ubuntu/PPA packages.
	mv "$pkgdir"/usr/bin/dec265 "$pkgdir"/usr/bin/libde265-dec265
}

examples() {
	pkgdesc="$pkgdesc (examples)"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/*
}

sha512sums="
225f9aa25eb6565ebf4f549d9d427ae278c4f6f67c76c51bcad79188faac0f5c93e9538357b264a7e2e9043014ccbc07750fb7d1ce1e7bb87fe2e0d1782cba61  libde265-1.0.9.tar.gz
f7bd3799f4e4440e7efb98671eca425a5926dd526f8b1147cee2e49b1995853f67b63287c12739ef8ea680713af903517820f83f7f88eac6459f37bae01b4d50  export-only-decoder-api.patch
1f12bf8c7f52932ab8a205996b4439afb75baf9bd6aab13126791f281784f5c7f1b3e20f9c20cfb0ab889b8643da5737a51d5571b54a3a8733ff5da835564eca  disable_tools.patch
"