SUMMARY="YouTube browser for SMPlayer"
DESCRIPTION="SMTube is an application that allows to browse, search and play \
YouTube videos. Videos are played back with a media player (by default \
SMPlayer) instead of a flash player, this allows better performance, \
particularly with HD content."
HOMEPAGE="https://www.smtube.org/"
COPYRIGHT="2006-2018 Ricardo Villalba"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://downloads.sf.net/smtube/smtube-$portVersion.tar.bz2"
CHECKSUM_SHA256="173f7f0902d336ef423b2074654bef461326ee6fba669f54865c81ac5b3daa65"

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

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	smtube$secondaryArchSuffix = $portVersion
	app:SMTube$commandSuffix = $portVersion
	cmd:smtube$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Script$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Script$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	make $jobArgs
}

INSTALL()
{
	smtubeDir=$appsDir/SMTube
	mkdir -p $smtubeDir
	cp src/smtube $smtubeDir/SMTube$commandSuffix
	mkdir -p $commandBinDir
	if [ -n "$commandSuffix" ]; then
	  mkdir -p $prefix/bin
	  symlinkRelative -s $smtubeDir/SMTube$commandSuffix $prefix/bin/smtube
	fi
	symlinkRelative -s $smtubeDir/SMTube$commandSuffix $commandBinDir/smtube
	addAppDeskbarSymlink $smtubeDir/SMTube$commandSuffix SMTube$commandSuffix
}
