SUMMARY="Audio module tracker formerly known as ModPlug Tracker"
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-2022 OpenMPT contributors
	1997-2003 Olivier Lapicque"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://lib.openmpt.org/files/libopenmpt/src/libopenmpt-$portVersion+release.autotools.tar.gz"
CHECKSUM_SHA256="c0bada4bebfc707961111bdb5ff6bbe337f5d71e837e8278f2e362a909eb925b"
SOURCE_DIR="libopenmpt-$portVersion+release.autotools"

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

libopenmptVersion=0.3.3
libopenmptVersionCompat="$libopenmptVersion compat >= ${libopenmptVersion%%.*}"

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

PROVIDES_devel="
	libopenmpt${secondaryArchSuffix}_devel = $portVersion
	devel:libopenmpt$secondaryArchSuffix = $libopenmptVersionCompat
	"
REQUIRES_devel="
	libopenmpt$secondaryArchSuffix == $portVersion base
	"

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

defineDebugInfoPackage libopenmpt$secondaryArchSuffix \
	$libDir/libopenmpt.so.$libopenmptVersion

BUILD()
{
	# Build a minimal LIB for FFMPEG
	runConfigure ./configure \
		--disable-openmpt123 \
		--disable-examples \
		--without-mpg123 \
		--without-ogg \
		--without-vorbis \
		--without-vorbisfile \
		--without-portaudio \
		--without-portaudiocpp \
		--without-sndfile \
		--without-flac \
		--disable-static

	make $jobArgs
}

INSTALL()
{
	make install
	prepareInstalledDevelLibs libopenmpt
	rm $developLibDir/*.la
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir $docDir
}

TEST()
{
	make check
}
