SUMMARY="A Spotify client using Qt"
DESCRIPTION="A lighter alternative to the official client, inspired by \
spotify-tui.
Much like spotify-tui, you need an actual Spotify client running, for example \
spotifyd, which can be configured from within the app. Also like other \
clients, controlling music playback requires Spotify Premium."
HOMEPAGE="https://github.com/kraxarn/spotify-qt"
COPYRIGHT="2020 Kraxarn"
LICENSE="GNU GPL v3"
REVISION="1"
srcGitRev="cc11ce0d1213f191847a6ad44e28be0b6a05a085"
SOURCE_URI="https://github.com/kraxarn/spotify-qt/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="2c431ee1cb881729a98951965bbed27a56e12056e13c6cef05a433413a484e6f"
SOURCE_FILENAME="spotify-qt-v$portVersion-$srcGitRev.tar.gz"
SOURCE_DIR="spotify-qt-$srcGitRev"
ADDITIONAL_FILES="spotify_qt.rdef.in"

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

PROVIDES="
	spotify_qt$secondaryArchSuffix = $portVersion
	app:SpotifyQt
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5DBus$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:qdbuscpp2xml$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build && cd build
	cmake -DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$appsDir ..
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2 | cut -c 1-1`"
	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		$portDir/additional-files/spotify_qt.rdef.in > spotify_qt.rdef

	mv $appsDir/bin/spotify-qt $appsDir/SpotifyQt
	rmdir $appsDir/bin

	addResourcesToBinaries spotify_qt.rdef \
		$appsDir/SpotifyQt

	addAppDeskbarSymlink $appsDir/SpotifyQt
}
