# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils games

# Link to source code was found at:
# http://borrevolution.vg-network.com/forum/viewtopic.php?p=3732#3732

# Potential alternative:
# http://gp2xforge.rix0r.nl/svn/bor/bor/

# Game data, rather than engine
BOR_PV="1.0029"

DESCRIPTION="Beats of Rage, a retro arcade-style beat-em-up engine"
HOMEPAGE="http://www.borgeneration.com/
	http://borrevolution.vg-network.com/"
SRC_URI="http://borrevolution.vg-network.com/linuxbor/borsdlx.zip
	demo? ( http://www.whphp.net/senile/pc/beats_of_rage_${BOR_PV}.zip )"

LICENSE="as-is"
SLOT="0"
KEYWORDS="~x86"
IUSE="demo"
# Something is pre-stripping the executable
RESTRICT="strip"

RDEPEND="media-libs/libsdl"
DEPEND="${RDEPEND}
	app-arch/unzip"

S=${WORKDIR}
dir=${GAMES_DATADIR}/bor

src_unpack() {
	unpack ${A}

	mv -f Makefile{.lnx,}
}

src_compile() {
	emake clean || die "emake clean failed"

	emake \
		|| die "emake failed"
}

src_install() {
	dogamesbin bor || die "dogamesbin failed"

	if use demo ; then
		insinto "${dir}"
		newins BOR/BOR.PAK bor.pak || die "newins BOR.PAK failed"

		# Reasonable example
		games_make_wrapper ${PN}-demo "bor -pak \"${dir}/bor.pak\" -res 800 600"
		make_desktop_entry ${PN}-demo "Beats of Rage"
		dodoc BOR/*.txt
	fi

	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst

	elog "Get games from e.g.: http://www.borgeneration.com/"
	elog "To run, use e.g.:    bor -pak game.pak -res 800 600"
	echo
}