SUMMARY="Cross-platform music production software"
DESCRIPTION="LMMS is a free cross-platform alternative to commercial \
programs like FL Studio®, which allow you to produce music with your \
computer. This includes the creation of melodies and beats, the \
synthesis and mixing of sounds, and arranging of samples. You can have fun \
with your MIDI-keyboard and much more; all in a user-friendly and modern \
interface."
HOMEPAGE="http://lmms.io/"
COPYRIGHT="2004-2020 Tobias Doerffel et al."
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/lmms/lmms/releases/download/v$portVersion/lmms_$portVersion.tar.xz"
CHECKSUM_SHA256="b185507fb64ecfd8e31145135b58ab244b637f9efc09c4176caf70aa3cbaae1e"
SOURCE_DIR="lmms"
PATCHES="lmms-$portVersion.patchset"
ADDITIONAL_FILES="LMMS.rdef"

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

PROVIDES="
	lmms$secondaryArchSuffix = $portVersion
	app:lmms$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfftw3f$secondaryArchSuffix
	lib:libfluidsynth$secondaryArchSuffix >= 2
	lib:libmp3lame$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libsamplerate$secondaryArchSuffix
	lib:libsdl_1.2$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libvorbisenc$secondaryArchSuffix
	lib:libvorbisfile$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfftw3f$secondaryArchSuffix
	devel:libfluidsynth$secondaryArchSuffix >= 2
	devel:libmp3lame$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libsamplerate$secondaryArchSuffix
	devel:libsdl$secondaryArchSuffix
	devel:libsndfile$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build && cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=$appsDir/LMMS \
		-DWANT_QT5=ON \
		-Wno-dev
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mv $appsDir/LMMS/bin/lmms $appsDir/LMMS/LMMS
	mv $appsDir/LMMS/share/lmms/* $appsDir/LMMS/
	mv $appsDir/LMMS/lib/lmms $appsDir/LMMS/plugins
	rm -rf $appsDir/LMMS/{share,lib,bin}

	addResourcesToBinaries $portDir/additional-files/LMMS.rdef \
		$appsDir/LMMS/LMMS

	addAppDeskbarSymlink $appsDir/LMMS/LMMS
}
