SUMMARY="Multiplatform Notepad++-like editor"
DESCRIPTION="Notepadqq is designed from developers, for developers. With its \
more than 100 supported languages, it is the ideal text editor for your daily \
tasks."
HOMEPAGE="http://notepadqq.altervista.org/"
COPYRIGHT="2012-2019 Notepadqq Project"
LICENSE="GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://github.com/JuBan1/notepadqq/archive/ote.tar.gz"
CHECKSUM_SHA256="4528c5be728396007630ee91723a2107894611b9f7149713ad276529b7297bd6"
SOURCE_FILENAME="notepadqq-ote.tar.gz"
SOURCE_DIR="notepadqq-ote"
PATCHES="notepadqq-$portVersion.patchset"
ADDITIONAL_FILES="notepadqq.rdef.in"

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

PROVIDES="
	notepadqq$secondaryArchSuffix = $portVersion
	app:Notepadqq$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libuchardet$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libuchardet$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:find
	cmd:g++$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	cmd:which
	"

BUILD()
{
	./configure --prefix "$appsDir/Notepadqq"

	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/Notepadqq/Resources
	make install

	mv $appsDir/Notepadqq/lib/notepadqq/notepadqq-bin \
		$appsDir/Notepadqq/Notepadqq
	mv $appsDir/Notepadqq/share/notepadqq/* \
		$appsDir/Notepadqq/Resources

	# Cleanup
	rm -rf $appsDir/Notepadqq/{bin,share,lib}

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

	addResourcesToBinaries notepadqq.rdef $appsDir/Notepadqq/Notepadqq
	addAppDeskbarSymlink $appsDir/Notepadqq/Notepadqq
}
