SUMMARY="The Legend of Edgar is a platform game"
DESCRIPTION="Edgar must battle his way across the world, solving puzzles and \
defeating powerful enemies to achieve his quest. When Edgar's father fails \
to return home after venturing out one dark and stormy night, Edgar fears the \
worst: he has been captured by the evil sorceror who lives in a fortress \
beyond the forbidden swamp. Donning his armour, Edgar sets off to rescue him, \
but his quest will not be easy..."
HOMEPAGE="https://www.parallelrealities.co.uk/games/edgar/"
COPYRIGHT="2009-2021 Parallel Realities"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/riksweeney/edgar/releases/download/$portVersion/edgar-$portVersion-1.tar.gz"
CHECKSUM_SHA256="f4793f9a14cc0cddf516fe5dadaa91d87836852668ab1188cee88dc90bce4184"
SOURCE_FILENAME="edgar-$portVersion.tar.gz"
SOURCE_DIR="edgar-$portVersion"
PATCHES="edgar-$portVersion.patchset"
ADDITIONAL_FILES="edgar.rdef.in"

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

USER_SETTINGS_FILES="
	settings/parallelrealities/Edgar directory
	"

PROVIDES="
	edgar$secondaryArchSuffix = $portVersion
	app:Edgar = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	lib:libSDL2_mixer_2.0$secondaryArchSuffix
	lib:libSDL2_ttf_2.0$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libintl$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libSDL2_image_2.0$secondaryArchSuffix
	devel:libSDL2_mixer_2.0$secondaryArchSuffix
	devel:libSDL2_ttf_2.0$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	make PREFIX=$prefix BIN_DIR=$appsDir/ \
		DATA_DIR=$dataDir/edgar/ DOC_DIR=$docDir/ \
		MAN_DIR=$manDir/man6 LOCALE_DIR=$dataDir/locale/ $jobArgs
}

INSTALL()
{
	make install PREFIX=$prefix BIN_DIR=$appsDir/ \
		DATA_DIR=$dataDir/edgar/ DOC_DIR=$docDir/ \
		MAN_DIR=$manDir/man6 LOCALE_DIR=$dataDir/locale/

	rm -rf $prefix/share
	mv $appsDir/edgar $appsDir/Edgar

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

	addResourcesToBinaries edgar.rdef \
		$appsDir/Edgar

	addAppDeskbarSymlink $appsDir/Edgar
}
