SUMMARY="An advanced CDDA reader with error correction"
DESCRIPTION="This is a port of xiph.org's cdda paranoia \
https://www.xiph.org/paranoia/ to use libcdio for CDROM access. By doing \
this, cdparanoia runs on platforms other than GNU/Linux."
HOMEPAGE="https://www.gnu.org/software/libcdio/"
COPYRIGHT="2012-2019 Rocky Bernstein
	Monty
	Robert Kausch"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://ftp.gnu.org/gnu/libcdio/libcdio-paranoia-10.2+2.0.0.tar.bz2"
CHECKSUM_SHA256="4565c18caf401083c53733e6d2847b6671ba824cff1c7792b9039693d34713c1"
SOURCE_DIR="libcdio-paranoia-10.2+2.0.0"
if [ $effectiveTargetArchitecture = x86_gcc2 ]; then
	PATCHES="libcdio_paranoia-10.2_2.0.0.patchset"
fi

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	libcdio_paranoia$secondaryArchSuffix = $portVersion
	cmd:cd_paranoia$secondaryArchSuffix
	lib:libcdio_cdda$secondaryArchSuffix = $libVersionCompat
	lib:libcdio_paranoia$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcdio$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	"

PROVIDES_devel="
	libcdio_paranoia${secondaryArchSuffix}_devel = $portVersion
	devel:libcdio_cdda$secondaryArchSuffix = $libVersionCompat
	devel:libcdio_paranoia$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libcdio_paranoia$secondaryArchSuffix == $portVersion base
	devel:libcdio$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcdio$secondaryArchSuffix >= 19
	devel:libiconv$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libcdio_paranoia$secondaryArchSuffix \
	"$binDir"/cd-paranoia \
	"$libDir"/libcdio_cdda.so.$libVersion \
	"$libDir"/libcdio_paranoia.so.$libVersion

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

INSTALL()
{
	make install

	rm $libDir/lib*.la

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $documentationDir
	fi

	prepareInstalledDevelLibs libcdio_cdda libcdio_paranoia
	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
