SUMMARY="Library to seek, decode, and playback Opus streams"
DESCRIPTION="Opus is a totally open, royalty-free, highly versatile audio \
codec. Opus is unmatched for interactive speech and music transmission over \
the Internet, but is also intended for storage and streaming applications. \
It is standardized by the Internet Engineering Task Force (IETF) as RFC 6716 \
which incorporated technology from Skype's SILK codec and Xiph.Org's CELT \
codec.

The opusfile library provides seeking, decode, and playback of Opus streams \
in the Ogg container (.opus files) including over http(s) on posix and \
windows systems."
HOMEPAGE="https://opus-codec.org/"
COPYRIGHT="2001-2018 Xiph.org"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://downloads.xiph.org/releases/opus/opusfile-$portVersion.tar.gz"
CHECKSUM_SHA256="118d8601c12dd6a44f52423e68ca9083cc9f2bfe72da7a8c1acb22a80ae3550b"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	opusfile$secondaryArchSuffix = $portVersionCompat
	lib:libopusfile$secondaryArchSuffix = $libVersionCompat
	lib:libopusurl$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopus$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	"

PROVIDES_devel="
	opusfile${secondaryArchSuffix}_devel = $portVersionCompat
	devel:libopusfile$secondaryArchSuffix = $libVersionCompat
	devel:libopusurl$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	opusfile$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libogg$secondaryArchSuffix
	devel:libopus$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtool$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

defineDebugInfoPackage opusfile$secondaryArchSuffix \
	"$libDir"/libopusfile.so.$libVersion \
	"$libDir"/libopusurl.so.$libVersion \

BUILD()
{
	autoreconf -fi
	runConfigure ./configure
	make
}

INSTALL()
{
	make install

	# remove libtool library file
	rm -f "$libDir"/libopus*.la

	prepareInstalledDevelLibs libopusfile libopusurl
	fixPkgconfig

	packageEntries devel \
		"$developDir"
}

TEST()
{
	make check
}
