SUMMARY="WebM VP8 video codec library"
DESCRIPTION="The WebM VP8 SDK allows you to integrate your applications with \
the VP8 video codec, a high quality, royalty free, open source codec deployed \
on millions of computers and devices worldwide.

This distribution of the WebM VP8 Codec SDK includes the following support:
- WebM VP8 Encoder
- WebM VP8 Decoder"
HOMEPAGE="https://www.webmproject.org/"
COPYRIGHT="2009-2012 Google Inc.,
	The Mozilla Foundation and
	The Xiph.Org Foundation"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/webmproject/libvpx/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="85803ccbdbdd7a3b03d930187cb055f1353596969c1f92ebec2db839fa4f834a"
SOURCE_FILENAME="libvpx-$portVersion.tar.gz"
SOURCE_DIR="libvpx-$portVersion"

ARCHITECTURES="all !x86_gcc2 ?x86"
SECONDARY_ARCHITECTURES="x86"

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="6.4.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
portVersionCompat="$portVersion compat >= ${portVersion%.*}"

PROVIDES="
	libvpx6$secondaryArchSuffix = $portVersion
	lib:libvpx$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
	# Note: The build system also looks for libvorbis and SDL, but that seems
	# to be needed only for building the sample player, which we don't need.
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:awk
	cmd:make
	cmd:perl
	cmd:yasm
	cmd:egrep
	cmd:grep
	cmd:sed
	cmd:find
	cmd:xargs
	cmd:diff
	"

BUILD()
{
	export CONFIG_SPATIAL_SVC=yes
	# not an auto tools configure
	./configure \
		--prefix="$prefix" \
		--libdir="$libDir" \
		--as=yasm \
		--enable-pic \
		--enable-shared \
		--enable-vp8 \
		--enable-vp9 \

	make $jobArgs
}

INSTALL()
{
	CONFIG_SPATIAL_SVC=yes \
	make install

	prepareInstalledDevelLibs libvpx
	fixPkgconfig

	mkdir -p $includeDir
	mv $prefix/include/* $includeDir
	rmdir $prefix/include

	if [ -n "$secondaryArchSuffix" -a "$commandBinDir" != "$prefix/bin" ]; then
		mkdir -p "$commandBinDir"
		mv "$prefix"/bin/vpxdec "$commandBinDir"
		mv "$prefix"/bin/vpxenc "$commandBinDir"
	fi

	# devel package
	rm -rf \
		"$developDir"

	# bin package
	rm -rf \
		"$commandBinDir"

	if [ -n "$secondaryArchSuffix" -a "$commandBinDir" != "$prefix"/bin ]; then
		rmdir "$prefix"/bin
	fi
}
