SUMMARY="A Boulder Dash like game"
DESCRIPTION="Supaplex is a Boulder Dash like game where you control a \
red Pac-Man like character called Murphy who needs to collect \
\"Infotrons\" while exploring inside a computer. Watch out for \
various hazards though! Like in Boulder Dash, the \"boulders\" \
that are freed from support will fall down and can crush Murphy \
or block further passage through a level. Other obstacles and \
hazards exist too, and will require some thinking ahead to \
overcome safely.

OpenSupaplex is a 1:1 reimplementation of the original \
game in C and SDL, with just a few changes to make it easy to use \
with game controllers, and also easy to port to any platform."
HOMEPAGE="https://github.com/sergiou87/open-supaplex"
COPYRIGHT="Philip Jespersen, Michael Stopp, Robin Heydon, Matt Smith, David Whittaker, Sergio Padrino"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/sergiou87/open-supaplex/archive/refs/tags/v${portVersion}.tar.gz"
CHECKSUM_SHA256="769f7cf8684e8d42849581a210d11bbe5c487a24738560f574a084e9d749164b"
SOURCE_DIR="open-supaplex-$portVersion"
PATCHES="open_supaplex-$portVersion.patchset"
ADDITIONAL_FILES="open_supaplex.rdef.in"

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

PROVIDES="
	open_supaplex$secondaryArchSuffix = $portVersion
	app:OpenSupaplex
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_mixer_2.0$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libSDL2_mixer_2.0$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cd linux
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/OpenSupaplex/data
	cp linux/opensupaplex $appsDir/OpenSupaplex/OpenSupaplex
	cp -R resources/* $appsDir/OpenSupaplex/data
	mv $appsDir/OpenSupaplex/data/audio-hq $appsDir/OpenSupaplex
	rm -rf $appsDir/OpenSupaplex/data/audio-{lq,mq}

	local APP_SIGNATURE="application/x-vnd.open-supaplex"
	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/open_supaplex.rdef.in > $sourceDir/open_supaplex.rdef

	addResourcesToBinaries  $sourceDir/open_supaplex.rdef \
		$appsDir/OpenSupaplex/OpenSupaplex
	addAppDeskbarSymlink $appsDir/OpenSupaplex/OpenSupaplex
}
