SUMMARY="Modern music player and library organizer based on Amarok 1.4 and Qt5"
DESCRIPTION="Clementine Music Player is a multiplatform music player. It is inspired by Amarok 1.4, \
focusing on a fast and easy-to-use interface for searching and playing your music.

Now with Podcast support including integration and synchronization with gpodder.net. \
Music from Soundcloud and jazzradio.com is available in the Internet tab in the sidebar, \
as well as any songs you've uploaded to Google Drive. \
Clementine Music Player will also now show moodbars for the music you play from your local disc.

Clementine Music Player Features:

Search and play your local music library.
Listen to internet radio from Spotify, Grooveshark, Last.fm, SomaFM, Magnatune, Jamendo, SKY.fm, Digitally Imported, JAZZRADIO.com, Soundcloud, and Icecast.
Search and play songs you've uploaded to Google Drive.
Create smart playlists and dynamic playlists.
Tabbed playlists, import and export M3U, XSPF, PLS and ASX.
CUE sheet support.
Play audio CDs.
Visualisations from projectM.
Lyrics and artist biographies and photos.
Transcode music into MP3, Ogg Vorbis, Ogg Speex, FLAC or AAC.
Edit tags on MP3 and OGG files, organise your music.
Fetch missing tags from MusicBrainz.
Discover and download Podcasts.
Download missing album cover art from Last.fm and Amazon.
Cross-platform - works on Windows, Mac OS X and Linux.
Native desktop notifications on Linux (libnotify) and Mac OS X (Growl).
Remote control using a Wii Remote, MPRIS or the command-line.
Copy music to your iPod, iPhone, MTP or mass-storage USB player.
Queue manager."
HOMEPAGE="https://www.clementine-player.org/"
COPYRIGHT="2010-2020 David Sansome, John Maguire, Arnaud Bienner"
LICENSE="GNU GPL v3"
REVISION="4"
srcGitRev="fc4cb6fc7a71695beef3c30a25fe78c4aabc6017"
SOURCE_URI="https://github.com/clementine-player/Clementine/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="79628e500f37f92539fa522e265bf40bf54da2cdb243589992ad681536f0c86e"
SOURCE_DIR="Clementine-$srcGitRev"
PATCHES="clementine-$portVersion.patchset"
ADDITIONAL_FILES="clementine.rdef.in"

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

PROVIDES="
	clementine$secondaryArchSuffix = $portVersion
	app:Clementine$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	dbus$secondaryArchSuffix
	haiku$secondaryArchSuffix
	lib:libcdio$secondaryArchSuffix
	lib:libchromaprint$secondaryArchSuffix
	lib:libfftw3$secondaryArchSuffix
	lib:libgio_2.0$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgmodule_2.0$secondaryArchSuffix
	lib:libgobject_2.0$secondaryArchSuffix
	lib:libgstapp_1.0$secondaryArchSuffix
	lib:libgstaudio_1.0$secondaryArchSuffix
	lib:libgstbase_1.0$secondaryArchSuffix
	lib:libgstpbutils_1.0$secondaryArchSuffix
	lib:libgstreamer_1.0$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libmtp$secondaryArchSuffix
	lib:libprotobuf$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libtag$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	sparsehash$secondaryArchSuffix
	devel:libboost_atomic$secondaryArchSuffix >= 1.69.0
	devel:libboost_chrono$secondaryArchSuffix >= 1.69.0
	devel:libboost_date_time$secondaryArchSuffix >= 1.69.0
	devel:libboost_filesystem$secondaryArchSuffix >= 1.69.0
	devel:libboost_locale$secondaryArchSuffix >= 1.69.0
	devel:libboost_regex$secondaryArchSuffix >= 1.69.0
	devel:libboost_system$secondaryArchSuffix >= 1.69.0
	devel:libboost_thread$secondaryArchSuffix >= 1.69.0
	devel:libcdio$secondaryArchSuffix >= 19
	devel:libchromaprint$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libfftw3$secondaryArchSuffix
	devel:libgio_2.0$secondaryArchSuffix
	devel:libgl$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libgstapp_1.0$secondaryArchSuffix
	devel:libgstaudio_1.0$secondaryArchSuffix
	devel:libgstbadaudio_1.0$secondaryArchSuffix
	devel:libgstbase_1.0$secondaryArchSuffix
	devel:libgstreamer_1.0$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libmtp$secondaryArchSuffix
	devel:libprotobuf$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libtag$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:orcc$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$appsDir/Clementine \
		-DCMAKE_DISABLE_FIND_PACKAGE_Qt5DBus=OFF \
		-DCCACHE_EXECUTABLE=OFF \
		-DENABLE_BREAKPAD=OFF \
		-DENABLE_DEVICEKIT=OFF \
		-DENABLE_DROPBOX=OFF \
		-DENABLE_GIO=ON \
		-DENABLE_GOOGLE_DRIVE=OFF \
		-DENABLE_LIBGPOD=OFF \
		-DENABLE_LIBLASTFM=OFF \
		-DENABLE_SPOTIFY_BLOB=OFF \
		-DENABLE_UDISKS2=OFF \
		-DENABLE_VISUALISATIONS=OFF \
		-DENABLE_WIIMOTEDEV=OFF \
		-DUSE_SYSTEM_PROJECTM=OFF
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/Clementine
	cp build/clementine $appsDir/Clementine/Clementine
	cp build/clementine-tagreader $appsDir/Clementine

	local APP_SIGNATURE="application/x-vnd.clementine"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3 | cut -d~ -f1`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/clementine.rdef.in > clementine.rdef

	addResourcesToBinaries clementine.rdef $appsDir/Clementine/Clementine
	mimeset -f $appsDir/Clementine/Clementine
	addAppDeskbarSymlink $appsDir/Clementine/Clementine
}
