SUMMARY="A Beautiful Gemini Client"
DESCRIPTION="Lagrange is a desktop GUI client for browsing Geminispace. \
It offers modern conveniences familiar from web browsers, \
such as smooth scrolling, inline image viewing, multiple tabs, \
visual themes, Unicode fonts, bookmarks, history, and page outlines."
HOMEPAGE="https://gmi.skyjake.fi/lagrange/"
COPYRIGHT="2020-2022 Jaakko Keränen"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://github.com/skyjake/lagrange/releases/download/v$portVersion/lagrange-$portVersion.tar.gz"
CHECKSUM_SHA256="042937f466e879bd6199b4ed59b7f786b31c382918650a7a8caa1cdb75897868"
SOURCE_DIR="lagrange-$portVersion"
ADDITIONAL_FILES="lagrange.rdef.in"

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

PROVIDES="
	lagrange$secondaryArchSuffix = $portVersion
	app:lagrange = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfribidi$secondaryArchSuffix
	lib:libharfbuzz$secondaryArchSuffix
	lib:libmpg123$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libunistring$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfribidi$secondaryArchSuffix
	devel:libharfbuzz$secondaryArchSuffix
	devel:libmpg123$secondaryArchSuffix
	devel:libpcre$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libunistring$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:zip
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$appsDir/Lagrange \
		-DENABLE_POPUP_MENUS=NO
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	local APP_SIGNATURE="application/x-vnd.lagrange"
	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/lagrange.rdef.in > lagrange.rdef

	addResourcesToBinaries lagrange.rdef $appsDir/Lagrange/lagrange
	addAppDeskbarSymlink $appsDir/Lagrange/lagrange Lagrange
}
