SUMMARY="A port of the wonderful puzzle game Fish Fillets from ALTAR interactive"
DESCRIPTION="Fish Fillets NG is strictly a puzzle game. The goal in every of \
the seventy levels is always the same: find a safe way out. The fish utter \
witty remarks about their surroundings, the various inhabitants of their \
underwater realm quarrel among themselves or comment on the efforts of your \
fish. The whole game is accompanied by quiet, comforting music."
HOMEPAGE="http://fillets.sourceforge.net/"
COPYRIGHT="2004-2011 Ivo Danihelka"
LICENSE="GNU GPL v2"
REVISION="3"
SOURCE_URI="http://prdownloads.sourceforge.net/fillets/fillets-ng-$portVersion.tar.gz"
CHECKSUM_SHA256="329a4d9515d60bebdb657d070824933b993b85864b9d3e302e6361accab992da"
SOURCE_DIR="fillets-ng-1.0.1"
SOURCE_URI_2="http://prdownloads.sourceforge.net/fillets/fillets-ng-data-$portVersion.tar.gz"
CHECKSUM_SHA256_2="f0c979fb35ec550a43246fc209add8f45ca550a382c94d6383bb3f01b1073799"
PATCHES="fish_fillets-$portVersion.patchset"
ADDITIONAL_FILES="fish_fillets.rdef.in"

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

PROVIDES="
	fish_fillets$secondaryArchSuffix = $portVersion
	app:"FishFilletsNG"$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfribidi$secondaryArchSuffix
	lib:liblua$secondaryArchSuffix >= 5.1
	lib:libSDL_1.2$secondaryArchSuffix
	lib:libSDL_image_1.2$secondaryArchSuffix
	lib:libSDL_mixer_1.2$secondaryArchSuffix
	lib:libSDL_ttf_2.0$secondaryArchSuffix
	lib:libsmpeg$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfribidi$secondaryArchSuffix
	devel:liblua$secondaryArchSuffix >= 5.1
	devel:libSDL$secondaryArchSuffix
	devel:libSDL_image$secondaryArchSuffix
	devel:libSDL_mixer$secondaryArchSuffix
	devel:libSDL_ttf$secondaryArchSuffix
	devel:libsmpeg$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:lua5.1$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	autoreconf -vfi
	./configure --prefix=$appsDir/"Fish-Fillets" \
		LUA_CFLAGS=-I"$(finddir B_SYSTEM_HEADERS_DIRECTORY)$secondaryArchSubDir/lua5.1" \
		LUA_LIBS=-L"$(finddir B_SYSTEM_LIB_DIRECTORY)$secondaryArchSubDir -llua"

	make $jobArgs
}

INSTALL()
{
	make install
	ln -s $appsDir/"Fish-Fillets"/bin/fillets $appsDir/"Fish-Fillets"/"Fish Fillets NG"

	mkdir -p $appsDir/"Fish-Fillets"/share/games/fillets-ng
	cp -R $sourceDir2/fillets-ng-data-1.0.1/* $appsDir/"Fish-Fillets"/share/games/fillets-ng/

	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/fish_fillets.rdef.in > fish_fillets.rdef

	addResourcesToBinaries fish_fillets.rdef \
		$appsDir/"Fish-Fillets"/bin/fillets

	addAppDeskbarSymlink $appsDir/"Fish-Fillets"/"Fish Fillets NG"
}
