SUMMARY="Crossplatform chiptunes player"
DESCRIPTION="Player of computer music from ZX Spectrum, Amiga, Atari, Commodore and more."
HOMEPAGE="https://zxtune.bitbucket.io/"
COPYRIGHT="2008–2021 Vitamin, CAIG"
LICENSE="GNU GPL v3"
REVISION="2"
srcGitRev="d1e9526f9ca945eff79f09087b4ed75e58f050e7"
SOURCE_URI="https://github.com/vitamin-caig/zxtune/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="dfd1929fa365e754f48b8684e352b1973f84ceb5b6517b07db51a5100fe7d548"
SOURCE_DIR="zxtune-${srcGitRev}"
PATCHES="zxtune-$portVersion.patchset"
ADDITIONAL_FILES="
	zxtune.rdef.in
	icons.zip
	"

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

PROVIDES="
	zxtune$secondaryArchSuffix = $portVersion
	app:ZXTune$secondaryArchSuffix = $portVersion
	cmd:zxtune123 = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_filesystem$secondaryArchSuffix
	lib:libboost_locale$secondaryArchSuffix
	lib:libboost_program_options$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_filesystem$secondaryArchSuffix >= 1.69.0
	devel:libboost_locale$secondaryArchSuffix >= 1.69.0
	devel:libboost_program_options$secondaryArchSuffix >= 1.69.0
	devel:libboost_system$secondaryArchSuffix >= 1.69.0
	devel:libopenal$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:unzip
	cmd:xargs
	cmd:zip
	"

PATCH()
{
	unzip -o $sourceDir/../../additional-files/icons.zip -d \
		$sourceDir/apps/zxtune-qt/res/theme_restorer
	rm -rf $sourceDir/apps/zxtune-qt/ui/preferences/sound_*
}

BUILD()
{
	make platform=linux system.zlib=1 -C apps/zxtune-qt $jobArgs
	make platform=linux system.zlib=1 -C apps/zxtune123 $jobArgs
}

INSTALL()
{
	mkdir -p $prefix/bin $appsDir
	cp bin/linux/release/zxtune-qt $appsDir/ZXTune
	cp bin/linux/release/zxtune123 $prefix/bin

	local APP_SIGNATURE="application/x-vnd.zxtune"
	local MAJOR="`echo "${portVersion:1:4}" | cut -d. -f1`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/zxtune.rdef.in > zxtune.rdef

	addResourcesToBinaries zxtune.rdef $appsDir/ZXTune
	addAppDeskbarSymlink $appsDir/ZXTune
}
