SUMMARY="Library for connecting and sending data to icecast servers"
DESCRIPTION="Libshout is a library for communicating with and sending data to \
an icecast server.  It handles the socket connection, the timing of the \
data, and prevents bad data from getting to the icecast server."
HOMEPAGE="https://www.icecast.org/"
COPYRIGHT="2002-2020 the Icecast team
	2011,2019 Xiph.Org Foundation
	2012-2015 Philipp Schafft
	2014 Michael Smith
	2014 Brendan Cully
	1995-1997 by Sam Rushing"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="http://downloads.xiph.org/releases/libshout/libshout-$portVersion.tar.gz"
CHECKSUM_SHA256="d9e568668a673994ebe3f1eb5f2bee06e3236a5db92b8d0c487e1c0f886a6890"
PATCHES="libshout-$portVersion.patchset"

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

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

libVersion="3.2.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	libshout$secondaryArchSuffix = $portVersion
	cmd:shout$commandSuffix
	lib:libshout$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libspeex$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libtheora$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	"

PROVIDES_devel="
	libshout${secondaryArchSuffix}_devel = $portVersion
	devel:libshout$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libshout$secondaryArchSuffix == $portVersion base
	devel:libogg$secondaryArchSuffix
	devel:libspeex$secondaryArchSuffix
	devel:libtheora$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libogg$secondaryArchSuffix
	devel:libspeex$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libtheora$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libshout$secondaryArchSuffix \
	$libDir/libshout.so.$libVersion

PATCH()
{
	echo "AC_CONFIG_MACRO_DIRS([m4])" >> configure.ac
}

BUILD()
{
	export LIBS="-lnetwork"
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libshout.la

	prepareInstalledDevelLibs libshout
	fixPkgconfig

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