SUMMARY="A compat layer/bridge from libmodplug to libopenmpt"
DESCRIPTION="libopenmpt is a cross-platform C++ and C module playback \
library. It is based on the player code of the Open ModPlug Tracker project. \
It offers high-quality module playback on a variety of platforms."
HOMEPAGE="https://openmpt.org/"
COPYRIGHT="2004-2020 OpenMPT contributors
	1997-2003 Olivier Lapicque"
LICENSE="BSD (3-clause)"
REVISION="2"
SOURCE_URI="https://lib.openmpt.org/files/libopenmpt-modplug/libopenmpt-modplug-$portVersion-openmpt1.tar.gz"
CHECKSUM_SHA256="ecce1a0eecfdb0b5824cab89c270dce59596295a2c17c2b043215ecf4d7c4ff7"
SOURCE_DIR="libopenmpt-modplug-$portVersion-openmpt1"

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

libopenmpt_modplugVersion=1.0.0
libopenmpt_modplugVersionCompat="$libopenmpt_modplugVersion compat >= ${libopenmpt_modplugVersion%%.*}"

PROVIDES="
	libopenmpt_modplug$secondaryArchSuffix = $portVersion
	lib:libopenmpt_modplug$secondaryArchSuffix = $libopenmpt_modplugVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libopenmpt$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libopenmpt_modplug${secondaryArchSuffix}_devel = $portVersion
	devel:libopenmpt_modplug$secondaryArchSuffix = $libopenmpt_modplugVersionCompat
	"
REQUIRES_devel="
	libopenmpt_modplug$secondaryArchSuffix == $portVersion base
	devel:libopenmpt$secondaryArchSuffix
	"
CONFLICTS_devel="
	libmodplug${secondaryArchSuffix}_devel
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libopenmpt$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libopenmpt_modplug$secondaryArchSuffix \
	$libDir/libopenmpt_modplug.so.$libopenmpt_modplugVersion \

BUILD()
{
	runConfigure ./configure \
		--enable-libopenmpt_modplug

	make $jobArgs
}

INSTALL()
{
	make install

	mkdir -p $includeDir
	cp -r libmodplug $includeDir

	prepareInstalledDevelLib libopenmpt_modplug
	rm $developLibDir/*.la
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir $docDir
}

TEST()
{
	make check
}
