SUMMARY="A ModBus master application"
DESCRIPTION="A Qt-based graphical user interface that allows easy \
communication with ModBus RTU and TCP slaves.

Features:
* ModBus RTU/TCP master
* Monitor bus activity (raw data and PDU details)"
COPYRIGHT="2012-2020 Elbar"
HOMEPAGE="https://sourceforge.net/projects/qmodmaster/"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://download.sourceforge.net/qmodmaster/qModMaster-code-$portVersion-3.zip"
CHECKSUM_SHA256="1754581e3059f14c31c584aa7abe1f1a602d1814f293823272b1158bbc179b81"
SOURCE_DIR="qModMaster-code-$portVersion-3"
ADDITIONAL_FILES="qmodmaster.rdef.in"
PATCHES=qmodmaster-$portVersion.patchset

ARCHITECTURES="all !x86_gcc2"
if [ "$targetArchitecture" = x86_gcc2 ]; then
	SECONDARY_ARCHITECTURES="x86"
fi

PROVIDES="
	qmodmaster$secondaryArchSuffix = $portVersion
	app:QModMaster = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	cmd:unzip
	"

BUILD()
{
	qmake
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/QModMaster
	install -T ./qModMaster $appsDir/QModMaster/QModMaster
	cp -rf Docs  $appsDir/QModMaster/
	cp -rf ManModbus  $appsDir/QModMaster/
	local APP_SIGNATURE="application/x-vnd.qmodmaster"
	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/qmodmaster.rdef.in > qmodmaster.rdef

	addResourcesToBinaries qmodmaster.rdef $appsDir/QModMaster/QModMaster
	addAppDeskbarSymlink $appsDir/QModMaster/QModMaster
}
