SUMMARY="A game like Deflektor (C64) or Mindbender (Amiga)"
DESCRIPTION="Make the laser reach the target by rotating mirrors. Beware of \
overheating!"
HOMEPAGE="https://www.artsoft.org/mirrormagic/"
COPYRIGHT="1989-2018 Artsoft Entertainment"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://www.artsoft.org/RELEASES/unix/mirrormagic/mirrormagic-$portVersion.tar.gz"
CHECKSUM_SHA256="c79ad19d461c080011e12f5b9e6b1d3de4b8325e452ef4bb6e8a63a62ce9ffec"
ADDITIONAL_FILES="mirrormagic.rdef.in"

ARCHITECTURES="all"

PROVIDES="
	mirrormagic = $portVersion
	app:mirrormagic = $portVersion
	"
REQUIRES="
	haiku
	lib:libSDL_1.2
	lib:libSDL_image_1.2
	lib:libSDL_mixer_1.2
	lib:libSDL_net_1.2
	"

BUILD_REQUIRES="
	haiku_devel
	devel:libSDL_1.2
	devel:libSDL_image_1.2
	devel:libSDL_mixer_1.2
	devel:libSDL_net_1.2
	"
BUILD_PREREQUIRES="
	cmd:gcc
	cmd:ld
	cmd:make
	"

BUILD()
{
	rm -rf lib

	make sdl \
		RO_GAME_DIR="$appsDir/Mirror Magic" \
		RW_GAME_DIR="$settingsDir/$portName"
}

INSTALL()
{
	mkdir -p "$appsDir/Mirror Magic"
	cp rocksndiamonds "$appsDir/Mirror Magic/Mirror Magic"
	cp -r conf graphics levels music sounds "$appsDir/Mirror Magic"

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

	addResourcesToBinaries $sourceDir/mirrormagic.rdef "$appsDir/Mirror Magic/Mirror Magic"

	addAppDeskbarSymlink "$appsDir/Mirror Magic/Mirror Magic"
}
