SUMMARY="Ogg Vorbis audio compression format library"
DESCRIPTION="Ogg Vorbis is a fully open, non-proprietary, \
patent-and-royalty-free, general-purpose compressed audio format for mid to \
high quality (8kHz-48.0kHz, 16+ bit, polyphonic) audio and music at fixed and \
variable bitrates from 16 to 128 kbps/channel. This places Vorbis in the same \
competitive class as audio representations such as MPEG-4 (AAC), and similar \
to, but higher performance than MPEG-1/2 audio layer 3, MPEG-4 audio \
(TwinVQ), WMA and PAC.

The bitstream format for Vorbis I was frozen Monday, May 8th 2000. All \
bitstreams encoded since will remain compatible with all future releases of \
Vorbis."
HOMEPAGE="https://www.xiph.org/vorbis/"
COPYRIGHT="1994-2018 Xiph.Org Foundation"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://downloads.xiph.org/releases/vorbis/libvorbis-$portVersion.tar.gz"
CHECKSUM_SHA256="0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab"
PATCHES="libvorbis-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

vorbisLibs="
	libvorbis \
	libvorbisenc \
	libvorbisfile \
	"
libvorbisVersion="0.4.9"
libvorbisencVersion="2.0.12"
libvorbisfileVersion="3.3.8"
for i in $vorbisLibs; do
	eval "${i}VersionCompat=\"\$${i}Version compat >= \${${i}Version%%.*}\""
done

PROVIDES="
	libvorbis$secondaryArchSuffix = $portVersion
	lib:libvorbis$secondaryArchSuffix = $libvorbisVersionCompat
	lib:libvorbisenc$secondaryArchSuffix = $libvorbisencVersionCompat
	lib:libvorbisfile$secondaryArchSuffix = $libvorbisfileVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	"

PROVIDES_devel="
	libvorbis${secondaryArchSuffix}_devel = $portVersion
	devel:libvorbis$secondaryArchSuffix = $libvorbisVersionCompat
	devel:libvorbisenc$secondaryArchSuffix = $libvorbisencVersionCompat
	devel:libvorbisfile$secondaryArchSuffix = $libvorbisfileVersionCompat
	"
REQUIRES_devel="
	libvorbis$secondaryArchSuffix == $portVersion
	devel:libogg$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libogg$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libvorbis$secondaryArchSuffix \
	"$libDir"/libvorbis.so.$libvorbisVersion \
	"$libDir"/libvorbisenc.so.$libvorbisencVersion \
	"$libDir"/libvorbisfile.so.$libvorbisfileVersion \

PATCH()
{
	# use developDocDir instead of a hard-coded docdir
	sed -i -e "s|^\(docdir = \)\$(datadir)/doc/\$(PACKAGE)-\$(VERSION)|\1\$(prefix)/$relativeDevelopDocDir|;" \
		doc/libvorbis/Makefile.am \
		doc/vorbisenc/Makefile.am \
		doc/vorbisfile/Makefile.am \
		doc/Makefile.am
}

BUILD()
{
	autoreconf -vfi
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libvorbis*.la $libDir/libvorbis*.a

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf "$developDir"/documentation
	fi

	prepareInstalledDevelLibs $vorbisLibs
	fixPkgconfig

	# devel package
	packageEntries devel \
		$dataDir \
		$developDir
}

TEST()
{
	make check
}
