SUMMARY="A library to encapsulate CD-ROM reading and control"
DESCRIPTION="The libcdio package contains a library for CD-ROM and CD image \
access. Applications wishing to be oblivious of the OS- and device-dependent \
properties of a CD-ROM or of the specific details of various CD-image formats \
may benefit from using this library."
HOMEPAGE="https://www.gnu.org/software/libcdio/"
COPYRIGHT="2002-2019 Rocky Bernstein and Herbert Valerio Riedel"
LICENSE="GNU GPL v3"
REVISION="2"
SOURCE_URI="https://ftpmirror.gnu.org/libcdio/libcdio-$portVersion.tar.bz2
	https://ftp.gnu.org/gnu/libcdio/libcdio-$portVersion.tar.bz2"
CHECKSUM_SHA256="8550e9589dbd594bfac93b81ecf129b1dc9d0d51e90f9696f1b2f9b2af32712b"
PATCHES="libcdio-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

libcdioLibs="
	libcdio
	libcdioxx
	libiso9660
	libiso9660xx
	libudf
	"
libcdioVersion=19.0.0
libcdioxxVersion=1.0.0
libiso9660Version=11.0.0
libiso9660xxVersion=0.0.0
libudfVersion=0.0.0
for i in lib $libcdioLibs; do
	eval "${i}VersionCompat=\"\$${i}Version compat >= \${${i}Version%%.*}\""
done

PROVIDES="
	libcdio$secondaryArchSuffix = $portVersion
	lib:libcdio$secondaryArchSuffix = $libcdioVersionCompat
	lib:libcdio++$secondaryArchSuffix = $libcdioxxVersionCompat
	lib:libiso9660$secondaryArchSuffix = $libiso9660VersionCompat
	lib:libiso9660++$secondaryArchSuffix = $libiso9660xxVersionCompat
	lib:libudf$secondaryArchSuffix = $libudfVersionCompat
	"
if [ -z "$secondaryArchSuffix" ]; then
	PROVIDES="$PROVIDES
		cmd:cdda_player = $portVersion
		cmd:cd_drive = $portVersion
		cmd:cd_info = $portVersion
		cmd:cd_read = $portVersion
		cmd:iso_info = $portVersion
		cmd:iso_read = $portVersion
		cmd:mmc_tool = $portVersion
		"
fi
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcddb$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	"

PROVIDES_devel="
	libcdio${secondaryArchSuffix}_devel = $portVersion
	devel:libcdio$secondaryArchSuffix = $libcdioVersionCompat
	devel:libcdio++$secondaryArchSuffix = $libcdioxxVersionCompat
	devel:libiso9660$secondaryArchSuffix = $libiso9660VersionCompat
	devel:libiso9660++$secondaryArchSuffix = $libiso9660xxVersionCompat
	devel:libudf$secondaryArchSuffix = $libudfVersionCompat
	"
REQUIRES_devel="
	libcdio$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcddb$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:automake
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libcdio$secondaryArchSuffix \
	"$libDir"/libcdio.so.$libcdioVersion \
	"$libDir"/libcdio++.so.$libcdioxxVersion \
	"$libDir"/libiso9660.so.$libiso9660Version \
	"$libDir"/libiso9660++.so.$libiso9660xxVersion \
	"$libDir"/libudf.so.$libudfVersion \

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

INSTALL()
{
	make install

	rm -f "$libDir"/lib*.la

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

	# set up the develop directory correctly
	prepareInstalledDevelLibs ${libcdioLibs//xx/++}
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$developDir"
}

TEST()
{
	make check
}
