SUMMARY="A Qt Fossil GUI"
DESCRIPTION="Fuel is cross-platform GUI front-end for the excellent Fossil SCM \
tool written in Qt. Fuel runs on Windows, OSX as well as various flavors of \
Unix including Linux and FreeBSD."
HOMEPAGE="https://fuel-scm.org/fossil/home/"
COPYRIGHT="2018 Kostas Karanikolas"
LICENSE="GNU GPL v2"
REVISION="3"
SOURCE_URI="https://fuel-scm.org/files/releases/fuel-$portVersion.tar.gz"
CHECKSUM_SHA256="4e463cb9f3cf9c31c7ae95ce76b558502c0b07e1dd4109da714997f0dc9a65db"
PATCHES="fuel-$portVersion.patchset"
ADDITIONAL_FILES="fuel.rdef.in"

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

PROVIDES="
	fuel$secondaryArchSuffix = $portVersion
	app:fuel
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:fossil
	lib:libcrypto$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libssl$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
	"

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

INSTALL()
{
	mkdir -p "$appsDir"
	install -T fuel "$appsDir"/Fuel

	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/fuel.rdef.in > fuel.rdef

	addResourcesToBinaries fuel.rdef "$appsDir"/Fuel
	addAppDeskbarSymlink "$appsDir"/Fuel
}
