SUMMARY="A simple, distraction-free word processor"
DESCRIPTION="FocusWriter is a simple, distraction-free word processor. \
It utilizes a hide-away interface that you access by moving your mouse to \
the edges of the screen, allowing the program to have a familiar look and \
feel while still getting out of your way \
So that you can immerse yourself in your work."
HOMEPAGE="https://gottcode.org/"
COPYRIGHT="2008-2019 Graeme Gott"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/gottcode/focuswriter/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="bbf70def7d86ee18cabe9f8ac3922ebbf4dfdb36893df3e6fa3e026acfcb2057"
ADDITIONAL_FILES="focuswriter.rdef.in"

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

PROVIDES="
	focuswriter$secondaryArchSuffix = $portVersion
	app:FocusWriter$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libhunspell_1.7$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libhunspell_1.7$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake PREFIX=$appsDir/FocusWriter
	make $jobArgs
}

INSTALL()
{
	make install

	local APP_SIGNATURE="application/x-vnd-gottcode.focuswriter"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	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/focuswriter.rdef.in > focuswriter.rdef

	addResourcesToBinaries focuswriter.rdef $appsDir/FocusWriter/FocusWriter
	addAppDeskbarSymlink $appsDir/FocusWriter/FocusWriter
}
