SUMMARY="MIDI processing library and player using the GUS patch set"
DESCRIPTION="WildMIDI is a simple software midi player which has a core \
softsynth library that can be used with other applications.."
HOMEPAGE="https://www.mindwerks.net/projects/wildmidi/"
COPYRIGHT="2000-2021 Mindwerks"
LICENSE="GNU GPL v3
	GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://github.com/Mindwerks/wildmidi/archive/refs/tags/wildmidi-$portVersion.tar.gz"
CHECKSUM_SHA256="6f267c8d331e9859906837e2c197093fddec31829d2ebf7b958cf6b7ae935430"
SOURCE_DIR="wildmidi-wildmidi-$portVersion"

ARCHITECTURES="all ?x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

GLOBAL_WRITABLE_FILES="
	settings/etc/wildmidi/wildmidi.cfg auto-merge
	"

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

PROVIDES="
	wildmidi$secondaryArchSuffix = $portVersion compat >= 0.4
	cmd:wildmidi$secondaryArchSuffix = $portVersion
	lib:libWildMidi$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	timidity_freepats
	"

PROVIDES_devel="
	wildmidi${secondaryArchSuffix}_devel = $portVersion
	devel:libWildMidi$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	wildmidi${secondaryArchSuffix} == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libopenal$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake $cmakeDirArgs .. \
		-DWANT_PLAYER=ON \
		-DWANT_OPENAL=ON

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $sysconfDir/etc/wildmidi
	echo "dir /system/data/midi/freepats" > $sysconfDir/etc/wildmidi/wildmidi.cfg
	sed '1d' < $sourceDir/cfg/wildmidi.cfg >> $sysconfDir/etc/wildmidi/wildmidi.cfg

	prepareInstalledDevelLibs libWildMidi
	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}
