SUMMARY="Free Lemmings clone"
DESCRIPTION="Pingus is a free Lemmings(tm) clone for GNU/Linux, Win32 and \
other operating systems supported by SDL. It is covered under the GPL."
HOMEPAGE="https://pingus.seul.org"
COPYRIGHT="1998-2011 Ingo Ruhnke"
LICENSE="GNU GPL v3"
REVISION="4"
SOURCE_URI="https://github.com/Pingus/pingus/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="c4cd89e1d350d2472f32de5f6266ac9f3658a3620eace3f79efac45db4323b65"
PATCHES="pingus-$portVersion.patchset"
ADDITIONAL_FILES="pingus.rdef.in"

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

PROVIDES="
	pingus$secondaryArchSuffix = $portVersion
	app:Pingus$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_signals$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libsdl_1.2$secondaryArchSuffix
	lib:libsdl_image_1.2$secondaryArchSuffix
	lib:libsdl_mixer_1.2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_signals$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libsdl_1.2$secondaryArchSuffix
	devel:libsdl_image_1.2$secondaryArchSuffix
	devel:libsdl_mixer_1.2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:scons
	"

BUILD()
{
	scons \
		with_opengl=false \
		BINDIR=$appsDir/Pingus \
		DATADIR=$appsDir/Pingus/data \
		MANDIR=$manDir
}

INSTALL()
{
	mkdir -p $appsDir/Pingus/data

	make install \
		BINDIR=$appsDir/Pingus \
		DATADIR=$appsDir/Pingus/data \
		MANDIR=$manDir

	mv $appsDir/Pingus/pingus.bin $appsDir/Pingus/Pingus
	rm $appsDir/Pingus/pingus

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

	addResourcesToBinaries  $sourceDir/pingus.rdef \
		$appsDir/Pingus/Pingus

	addAppDeskbarSymlink $appsDir/Pingus/Pingus
}
