SUMMARY="Fast-paced 3D lightcycle game based on Tron"
DESCRIPTION="Armagetron is a multiplayer game in 3d that attempts to emulate \
and expand on the lightcycle sequence from the movie Tron. It's an old school \
arcade game slung into the 21st century. Highlights include a customizable \
playing arena, HUD, unique graphics, and AI bots. For the more advanced player \
there are new game modes and a wide variety of physics 	settings to tweak as \
well."
HOMEPAGE="http://www.armagetronad.org/"
COPYRIGHT="2007-2021 OSS Armagetronad Team"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://launchpad.net/armagetronad/0.2.9/$portVersion/+download/armagetronad-$portVersion.tbz"
CHECKSUM_SHA256="59b6c7c01ce3f8cca5437e33f974a637529541a11aa4f52c1a5c17499e26f6a1"
PATCHES="armagetronad-$portVersion.patchset"
ADDITIONAL_FILES="armagetronad.rdef.in"

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

GLOBAL_WRITABLE_FILES="
	settings/armagetronad/aiplayers.cfg keep-old
	settings/armagetronad/default.cfg keep-old
	settings/armagetronad/examples/breakfast_in_hell.cfg keep-old
	settings/armagetronad/examples/cvs_test/fortress_complete.cfg keep-old
	settings/armagetronad/examples/cvs_test/fortress_physics.cfg keep-old
	settings/armagetronad/examples/cvs_test/fortress_politics.cfg keep-old
	settings/armagetronad/examples/cvs_test/fortress_scoring.cfg keep-old
	settings/armagetronad/examples/cvs_test/sumo_complete.cfg keep-old
	settings/armagetronad/examples/death_zone.cfg keep-old
	settings/armagetronad/examples/fortress_soccer.cfg keep-old
	settings/armagetronad/examples/single_use_turbo.cfg keep-old
	settings/armagetronad/examples/teamsumo.cfg keep-old
	settings/armagetronad/master.srv keep-old
	settings/armagetronad/rc.config keep-old
	settings/armagetronad/settings.cfg keep-old
	settings/armagetronad/settings_authentication.cfg keep-old
	settings/armagetronad/settings_dedicated.cfg keep-old
	settings/armagetronad/settings_visual.cfg keep-old
	settings/armagetronad/subcultures.srv keep-old
	settings/armagetronad/keys_cursor.cfg keep-old
	settings/armagetronad/keys_cursor_single.cfg keep-old
	settings/armagetronad/keys_twohand.cfg keep-old
	settings/armagetronad/keys_wasd.cfg keep-old
	settings/armagetronad/keys_x.cfg keep-old
	settings/armagetronad/keys_zqsd.cfg keep-old
	"

PROVIDES="
	armagetronad$secondaryArchSuffix = $portVersion
	app:ArmagetronAdvanced = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL_1.2$secondaryArchSuffix
	lib:libSDL_image_1.2$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL$secondaryArchSuffix
	devel:libSDL_image$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoreconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	autoreconf -vfi
	LDFLAGS=-lnetwork ./configure \
		--prefix=$appsDir/Armagetron \
		--bindir=$appsDir/Armagetron \
		--datadir=$appsDir/Armagetron/data \
		--sysconfdir=$settingsDir \
		--localstatedir=$settingsDir \
		--disable-dependency-tracking \
		--disable-games \
		--disable-binreloc \
		--disable-desktop
	make $jobArgs
}

INSTALL()
{
	make install
	mv $appsDir/Armagetron/armagetronad "$appsDir/Armagetron/Armagetron Advanced"

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

	addResourcesToBinaries  $sourceDir/armagetronad.rdef "$appsDir/Armagetron/Armagetron Advanced"
	addAppDeskbarSymlink "$appsDir/Armagetron/Armagetron Advanced"
}
