SUMMARY="Blast the Asteroids!"
DESCRIPTION="You pilot your ship through the dreaded \"Maelstrom\" asteroid \
belt -- suddenly your best friend thrusts towards you and fires, directly at \
your cockpit. You raise your shields just in time, and the battle is joined.

The deadliest stretch of space known to mankind has just gotten deadlier.
Everywhere massive asteroids jostle for a chance to crush your ship, and \
deadly shinobi fighter patrols pursue you across the asteroid belt. But the \
deadliest of them all is your sister ship, assigned to you on patrol. The \
pilot, trained by your own Navy, battle hardened by months in the Maelstrom, \
is equipped with a twin of your own ship and intimate knowledge of your tactics.

The lovely Stratocaster R&R facility never sounded so good, but as you fire \
full thrusters to dodge the latest barrage you begin to think you'll never \
get home..."
HOMEPAGE="http://www.libsdl.org/projects/Maelstrom"
COPYRIGHT="1996-2005 Sam Lantinga"
LICENSE="GNU GPL v2"
REVISION="5"
SOURCE_URI="http://www.libsdl.org/projects/Maelstrom/src/Maelstrom-$portVersion.tar.gz"
CHECKSUM_SHA256="e7983c2c7376cdcca1944db1706d92aedd529638cf13358c88a60df982ba7b46"
SOURCE_DIR="Maelstrom-$portVersion"
PATCHES="
	maelstrom-3.0.6-64bits.patch
	maelstrom-3.0.6-gcc34.patch
	maelstrom-3.0.6-gcc53.patch
	maelstrom-3.0.6-security.patch
	maelstrom-3.0.6-warnings.patch
	maelstrom-$portVersion.patchset
	"
ADDITIONAL_FILES="maelstrom.rdef.in"

ARCHITECTURES="all"

PROVIDES="
	maelstrom = $portVersion
	app:Maelstrom
	cmd:Maelstrom_netd$secondaryArchSuffix
	"
REQUIRES="
	haiku
	lib:libSDL_1.2
	lib:libSDL_net_1.2
	"

BUILD_REQUIRES="
	devel:libSDL
	devel:libSDL_net
	"
BUILD_PREREQUIRES="
	haiku_devel
	cmd:autom4te
	cmd:gcc
	cmd:ld
	cmd:libtoolize
	cmd:make
	cmd:nasm
	"

BUILD()
{
	libtoolize --force --copy --install
	aclocal
	touch NEWS AUTHORS ChangeLog # Yeah, automake needs all this stuff...
	automake --add-missing
	autoconf

	export LDFLAGS=-lnetwork
	export CPPFLAGS=-D__BEOS__
	runConfigure --omit-dirs "docDir dataRootDir" ./configure
	make $jobArgs
}

INSTALL()
{
	mkdir -p $binDir
	make install

	cp Maelstrom $appsDir/Maelstrom/
	cp Maelstrom-netd $binDir

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

	addResourcesToBinaries $sourceDir/maelstrom.rdef $appsDir/Maelstrom/Maelstrom

	addAppDeskbarSymlink $appsDir/Maelstrom/Maelstrom
}
