SUMMARY="Crossplatform Jabber/XMPP client"
DESCRIPTION="Vacuum IM is a free/libre cross-platform Qt-based Jabber client."
HOMEPAGE="http://www.vacuum-im.org/"
COPYRIGHT="2008-2019 Vacuum Team"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/Vacuum-IM/vacuum-im/archive/$portVersion-Alpha.tar.gz"
CHECKSUM_SHA256="c037e113e02c25f75ea0fb8902faba4f06b9253d4f241d4238d943baef85635a"
SOURCE_DIR="vacuum-im-$portVersion-Alpha"
#PATCHES="vacuum-$portVersion.patchset"
ADDITIONAL_FILES="vacuum.rdef"

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

PROVIDES="
	vacuum$secondaryArchSuffix = $portVersion
	app:Vacuum$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libidn$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Sql$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libidn$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Multimedia$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Sql$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake
	make $jobArgs
}

INSTALL()
{
	# TODO: fix make install
	mkdir -p $appsDir/Vacuum-IM/lib

	cp vacuum $appsDir/Vacuum-IM/Vacuum
	cp -r resources plugins $appsDir/Vacuum-IM
	cp -r src/libs/*.so* $appsDir/Vacuum-IM/lib
	cp -r src/translations $appsDir/Vacuum-IM
	rm -rf $appsDir/Vacuum-IM/translations/{ts*,.tx}

	local APP_SIGNATURE="application/x-vnd.vacuum"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"

	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/vacuum.rdef > vacuum.rdef

	addResourcesToBinaries vacuum.rdef $appsDir/Vacuum-IM/Vacuum
	addAppDeskbarSymlink $appsDir/Vacuum-IM/Vacuum
}
