SUMMARY="A Qt-based markdown text editor"
DESCRIPTION="CuteMarkEd is a Qt-based markdown editor with live HTML preview, \
math expressions, code and markdown syntax highlighting."
HOMEPAGE="https://cloose.github.io/CuteMarkEd"
COPYRIGHT="2013 Christian Loose
	2007 David Loren Parsons
	2011-2012 Ali Rantakari
	2012 CodeCatalyst, LLC"
LICENSE="GNU GPL v2
	MIT"
REVISION="4"
SOURCE_URI="https://github.com/cloose/CuteMarkEd/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="78a41808c2f0452375810abdff76eeaaee012f8d1368a2b8772ec6b4d2ceeec8"
SOURCE_DIR="CuteMarkEd-$portVersion"
PATCHES="cutemarked-$portVersion.patchset"
ADDITIONAL_FILES="CuteMarkEd.rdef.in"

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

PROVIDES="
	cutemarked$secondaryArchSuffix = $portVersion
	app:CuteMarkEd$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libhunspell_1.7$secondaryArchSuffix
	lib:libmarkdown$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Test$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libhunspell_1.7$secondaryArchSuffix
	devel:libmarkdown$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5QmlDebug$secondaryArchSuffix
	devel:libQt5Test$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

defineDebugInfoPackage cutemarked$secondaryArchSuffix \
	$appsDir/CuteMarkEd

BUILD()
{
	qmake CuteMarkEd.pro
	make $jobArgs
}

INSTALL()
{
	install -d $appsDir
	install -T app/cutemarked $appsDir/CuteMarkEd

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local INTERNAL="`echo "$portVersion" | cut -d. -f4`"
	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@INTERNAL@|$INTERNAL|" \
		$portDir/additional-files/CuteMarkEd.rdef.in > CuteMarkEd.rdef

	addResourcesToBinaries CuteMarkEd.rdef \
		$appsDir/CuteMarkEd

	addAppDeskbarSymlink $appsDir/CuteMarkEd
}
