SUMMARY="DuckDuckGo abstracts one fingertip away"
DESCRIPTION="Desktop App that shows the Abstract / Definition text \
from DuckDuckGo Instant Answers."
HOMEPAGE="https://github.com/emctague/abstrakt"
COPYRIGHT="2018 Ethan McTague"
LICENSE="MIT"
REVISION="1"
srcGitRev="62563051df47b39f39ed2a912a2dd319f42fabf7"
SOURCE_URI="https://github.com/emctague/abstrakt/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="3cdc7b3db08690b4f7c3eb146d6379dc341e2fcbc719a4ae6cec9d31420ecb73"
SOURCE_DIR="abstrakt-$srcGitRev"
ADDITIONAL_FILES="abstrakt.rdef.in"

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

PROVIDES="
	abstrakt$secondaryArchSuffix = $portVersion
	app:abstrakt$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGl$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGl$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

defineDebugInfoPackage abstrakt$secondaryArchSuffix \
	$appsDir/Abstrakt

BUILD()
{
	lrelease abstrakt.pro

	mkdir -p haiku_build && cd haiku_build
	qmake ../Input.pro

	make $jobArgs
}

INSTALL()
{
	cd haiku_build
	mkdir -p $appsDir
	cp Input $appsDir/Abstrakt

	# Icon
	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|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/abstrakt.rdef.in > abstrakt.rdef

	addResourcesToBinaries abstrakt.rdef \
		$appsDir/Abstrakt

	addAppDeskbarSymlink $appsDir/Abstrakt
}
