SUMMARY="A software real-time synthesizer"
DESCRIPTION="
Fluidsynth is a free open source software synthesizer written in C. It \
can convert MIDI note data to an audio signal using SoundFont technology \
without a SoundFont compatible soundcard. Fluidsynth can perform as a virtual \
MIDI device and read in SMF (.mid) files directly. Another function is its \
ability to send audio data to a Raw or Wave file."
HOMEPAGE="https://www.fluidsynth.org/"
COPYRIGHT="2017-2019 Tom Moebert
	2007-2019 Josh Green
	2007-2019 Pedro Lopez-Cabanillas
	2007-2019 David Henningsson
	2000-2019 Peter Hanappe"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://github.com/FluidSynth/fluidsynth/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="a254efceff5d99f8d658d12d25318317f37307e6df852ec9baeb7da173496967"
SOURCE_DIR="fluidsynth-$portVersion"
PATCHES="fluidsynth2-$portVersion.patchset"
if [ "$effectiveTargetArchitecture" = x86_gcc2 ]; then
	PATCHES="$PATCHES
	fluidsynth2-$portVersion-gcc2.patchset"
fi

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

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

PROVIDES="
	fluidsynth2$secondaryArchSuffix = $portVersion
	lib:libfluidsynth$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libFLAC$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libinstpatch_1.0$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libSDL_1.2$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	"
if [ "$effectiveTargetArchitecture" != x86_gcc2 ]; then
REQUIRES="$REQUIRES
	lib:libgomp$secondaryArchSuffix
	"
fi

PROVIDES_devel="
	fluidsynth2${secondaryArchSuffix}_devel = $portVersion
	devel:libfluidsynth$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	fluidsynth2$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	fluidsynth${secondaryArchSuffix}_devel
	"

SUMMARY_tools="$SUMMARY (fluidsynth binary)"
DESCRIPTION_tools="$DESCRIPTION (fluidsynth binary)"
PROVIDES_tools="
	fluidsynth2${secondaryArchSuffix}_tools = $portVersion
	cmd:fluidsynth$secondaryArchSuffix = $portVersion
	"
REQUIRES_tools="
	fluidsynth2$secondaryArchSuffix == $portVersion base
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libFLAC$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libinstpatch_1.0$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix >= 8
	devel:libSDL_1.2$secondaryArchSuffix
	devel:libsndfile$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage fluidsynth2$secondaryArchSuffix \
	"$libDir"/libfluidsynth.so.$libVersion \
	"$(getPackagePrefix tools)/$relativeBinDir"/fluidsynth

BUILD()
{
	mkdir -p build && cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DBIN_INSTALL_DIR=$binDir \
		-DLIB_INSTALL_DIR=$libDir \
		-DINCLUDE_INSTALL_DIR=$includeDir \
		-DMAN_INSTALL_DIR=$manDir/man1
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLib libfluidsynth
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
	packageEntries tools \
		$binDir \
		$manDir
}

TEST()
{
	cd build
	make check
}
