SUMMARY="A turn-based strategy engine"
DESCRIPTION="LGeneral is a turn-based strategy engine heavily inspired \
by Panzer General. You play single scenarios or whole campaigns turn by \
turn against a human player or the AI. Entrenchment, rugged defense, \
defensive fire, surprise contacts, surrender, unit supply, weather \
influence, reinforcements and other implementations contribute to the \
tactical and strategic depth of the game."
HOMEPAGE="http://lgames.sourceforge.net/"
COPYRIGHT="2000-2017 Michael Speck, Leo Savernik, Peter Ivanyi"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="http://downloads.sf.net/lgeneral/lgeneral-$portVersion.tar.gz"
CHECKSUM_SHA256="9c9d3fbd8595afca33a47533f9c2ce6320577b0bce85851f660c9bee07556028"
SOURCE_URI_2="http://downloads.sf.net/lgeneral/pg-data.tar.gz"
CHECKSUM_SHA256_2="cc6fa5d263d1d5824d706517958b1bb09b405ba0ed21e63e4a4d38e2727d7a04"
PATCHES="lgeneral-$portVersion.patchset"
ADDITIONAL_FILES="lgeneral.rdef"

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

PROVIDES="
	lgeneral$secondaryArchSuffix = $portVersion
	cmd:lgc_pg$secondaryArchSuffix = $portVersion
	cmd:lged$secondaryArchSuffix = $portVersion
	cmd:lgeneral$secondaryArchSuffix = $portVersion
	cmd:ltrextract$secondaryArchSuffix = $portVersion
	cmd:shptool$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libsdl$secondaryArchSuffix
	lib:libsdl_mixer$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libsdl$secondaryArchSuffix
	devel:libsdl_mixer$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:bison
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	libtoolize --force --copy --install
	runConfigure ./configure --disable-nls

	mkdir -p pg-data
	cp ../../sources-2/pg-data/* ./pg-data/

	make $jobArgs
}

INSTALL()
{
	make install

	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/lgeneral.rdef > lgeneral.rdef

	addResourcesToBinaries lgeneral.rdef \
		$binDir/lgeneral

	rm -rf $dataDir/applications
	rm -rf $dataDir/icons
	mkdir -p $dataDir/lgeneral/gfx/{flags,units,terrain}
	$binDir/lgc-pg --separate-bridges -s ./pg-data
	addAppDeskbarSymlink $binDir/lgeneral LGeneral
}
