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-2017 Rocky Bernstein and Herbert Valerio Riedel"
LICENSE="GNU GPL v3"
REVISION="3"
SOURCE_URI="https://ftpmirror.gnu.org/libcdio/libcdio-$portVersion.tar.gz
	https://ftp.gnu.org/gnu/libcdio/libcdio-$portVersion.tar.gz"
CHECKSUM_SHA256="1b481b5da009bea31db875805665974e2fc568e2b2afa516f4036733657cf958"
SOURCE_DIR="libcdio-$portVersion"
PATCHES="libcdio-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

libcdioLibs="
	libcdio
	"
libcdioVersion=18.0.0
for i in lib $libcdioLibs; do
	eval "${i}VersionCompat=\"\$${i}Version compat >= \${${i}Version%%.*}\""
done

PROVIDES="
	libcdio1$secondaryArchSuffix = $portVersion
	lib:libcdio$secondaryArchSuffix = $libcdioVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcddb$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	"

PROVIDES_devel="
	libcdio1${secondaryArchSuffix}_devel = $portVersion
	devel:libcdio$secondaryArchSuffix = $libcdioVersionCompat
	"
REQUIRES_devel="
	libcdio1$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	libcdio${secondaryArchSuffix}_devel
	libcdio0${secondaryArchSuffix}_devel
	"

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 libcdio1$secondaryArchSuffix \
	"$libDir"/libcdio.so.$libcdioVersion

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

INSTALL()
{
	make install

	rm -rf "$libDir"/lib*.la "$documentationDir" "$binDir" \
		"$libDir"/libcdio++* "$libDir"/libiso9660* "$libDir"/libudf*

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

	# devel package
	packageEntries devel \
		"$developDir"
}

TEST()
{
	make check
}
