SUMMARY="A turn-based tactical war game"
DESCRIPTION="The outcome of the war lies in your hands. You decide which \
units are sent to the front lines, and when to unleash the reserves. Your \
mission objectives range from defending strategically vital locations to \
simply destroying all enemy forces in the area. Protect supply convoys or \
raid enemy facilities to uncover technological secrets or fill your storage \
bays so you can repair damaged units or build new ones in your own \
factories. Lead your troops to victory!"
HOMEPAGE="http://crimson.seul.org/"
COPYRIGHT="2001-2009 Jens Granseuer"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="http://crimson.seul.org/files/crimson-$portVersion.tar.gz"
CHECKSUM_SHA256="e82aa28f729140711e2d04c426462d96d33ce8485f5d3ca3f394210e412cefd2"
ADDITIONAL_FILES="crimson.rdef"

ARCHITECTURES="?all x86_gcc2"

PROVIDES="
	crimson = $portVersion
	app:CrimsonFields = $portVersion
	cmd:bi2cf = $portVersion
	cmd:cf2bmp = $portVersion
	cmd:cfed = $portVersion
	cmd:comet = $portVersion #leveleditor
	"
REQUIRES="
	haiku
	lib:libSDL_1.2
	lib:libSDL_mixer_1.2
	lib:libSDL_net_1.2
	lib:libSDL_ttf_2.0
	lib:libxml2
	lib:libz
	"

BUILD_REQUIRES="
	haiku_devel
	devel:libSDL_1.2
	devel:libSDL_mixer_1.2
	devel:libSDL_net_1.2
	devel:libSDL_ttf_2.0
	devel:libxml2
	devel:libz
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc
	cmd:make
	"

BUILD()
{
	runConfigure ./configure --enable-cfed \
		--enable-comet --enable-bi2cf --enable-cf2bmp
	make $jobArgs
}

INSTALL()
{
	make install
	mkdir $appsDir
	mv $binDir/crimson $appsDir/CrimsonFields

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/crimson.rdef > crimson.rdef
	addResourcesToBinaries crimson.rdef \
		$appsDir/CrimsonFields

	rm -r $dataDir/applications #not needed
	rm -r $dataDir/pixmaps #not needed
	addAppDeskbarSymlink $appsDir/CrimsonFields
}
