SUMMARY="An open source MPEG-4 and MPEG-2 AAC decoder"
DESCRIPTION="This is an open source MPEG-4 and MPEG-4 ACC decoder programmed in C \
and used in FAAC (freeware Advanced Audio Coder). It is used with the FAAC \
encoder and can be compile on various platforms. It supports MPEG-4 audio \
object types including LC, Main, LTP, LD, ER, SBR and PS. It contains a \
library (libfaad) that may be used by other programs."
HOMEPAGE="https://www.audiocoding.com/"
COPYRIGHT="2003-2005 M. Bakker, Nero AG."
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="https://github.com/knik0/faad2/archive/${portVersion//./_}.tar.gz"
CHECKSUM_SHA256="0c6d9636c96f95c7d736f097d418829ced8ec6dbd899cc6cc82b728480a84bfb"
SOURCE_DIR="faad2-${portVersion//./_}"
PATCHES="faad2-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	faad2$secondaryArchSuffix = $portVersion compat >= 2
	cmd:faad$secondaryArchSuffix = $portVersion
	lib:libfaad$secondaryArchSuffix = $libVersionCompat
	lib:libfaad_drm$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku${secondaryArchSuffix}
	"

PROVIDES_devel="
	faad2${secondaryArchSuffix}_devel = $portVersion compat >= 2
	devel:libfaad$secondaryArchSuffix = $libVersionCompat
	devel:libfaad_drm$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	faad2$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage faad2$secondaryArchSuffix \
	$libDir/libfaad.so.$libVersion \
	$libDir/libfaad_drm.so.$libVersion

BUILD()
{
	autoreconf -fi
	runConfigure ./configure --disable-static
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libfaad*.la

	prepareInstalledDevelLibs libfaad libfaad_drm

	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
