# Template file for 'libvpx5'
pkgname=libvpx5
version=1.7.0
revision=3
wrksrc="libvpx-${version}"
hostmakedepends="perl yasm"
short_desc="VP8 and VP9 video codec (1.7 series)"
maintainer="q66 <daniel@octaforge.org>"
license="BSD-3-Clause-Clear"
homepage="http://www.webmproject.org"
distfiles="https://github.com/webmproject/libvpx/archive/v${version}.tar.gz"
checksum=1fec931eb5c94279ad219a5b6e0202358e94a93a90cfb1603578c326abfc1238

do_configure() {
	export LD="$CC"

	if [ "$CROSS_BUILD" ]; then
		case "$XBPS_TARGET_MACHINE" in
			aarch64*) _cross="--target=arm64-linux-gcc";;
			armv7*) _cross="--target=armv7-linux-gcc";;
			*) _cross="--target=generic-gnu";;
		esac
	else
		# ppc32 is not a supported config, force generic-gnu
		case "$XBPS_TARGET_MACHINE" in
			ppc64*) ;;
			ppc*) _cross="--target=generic-gnu";;
		esac
	fi
	CFLAGS+=" -fPIC"

	./configure --enable-vp8 --enable-vp9 --disable-tools \
		--disable-examples --disable-docs --enable-experimental \
		--enable-runtime-cpu-detect --enable-shared \
		--enable-postproc --enable-pic --disable-install-docs \
		--disable-install-srcs --disable-install-bins --as=yasm ${_cross}
}

do_build() {
	make ${makejobs}
}

do_install() {
	make DIST_DIR=${DESTDIR}/usr install
	vlicense LICENSE
}

libvpx5-devel_package() {
	depends="libvpx5>=${version}_${revision}"
	conflicts="libvpx-devel>=0"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
		vmove usr/lib/pkgconfig
	}
}

libvpx_package() {
	archs=noarch
	build_style=meta
	depends="libvpx5-${version}_${revision}"
	short_desc+=" (transitional package)"
}
