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="2007-2018 Josh Green, Pedro Lopez-Cabanillas, David Henningsson"
LICENSE="GNU LGPL v2.1"
REVISION="3"
SOURCE_URI="https://github.com/FluidSynth/fluidsynth/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="da8878ff374d12392eecf87e96bad8711b8e76a154c25a571dd8614d1af80de8"
PATCHES="fluidsynth-$portVersion.patchset"

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

PROVIDES="
	fluidsynth${secondaryArchSuffix} = $portVersion
	cmd:fluidsynth
	lib:libfluidsynth${secondaryArchSuffix} = 1.7.2 compat >= 1
	"
REQUIRES="
	haiku${secondaryArchSuffix}
	lib:libFLAC$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	"

PROVIDES_devel="
	fluidsynth${secondaryArchSuffix}_devel = $portVersion
	devel:libfluidsynth$secondaryArchSuffix = 1.7.2 compat >= 1
	"
REQUIRES_devel="
	fluidsynth$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	fluidsynth2${secondaryArchSuffix}_devel
	"

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

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DLIB_INSTALL_DIR=$libDir \
		-DINCLUDE_INSTALL_DIR=$includeDir
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $(dirname $manDir)
	mv $prefix/share/man $manDir
	rm -rf $prefix/share

	prepareInstalledDevelLib libfluidsynth
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
