SUMMARY="Help a cat catch birds"
DESCRIPTION="cCATch is a portation of the game CATch, written in c using SDL"
HOMEPAGE="https://www.github.com/TheZeldakatze/c-CATch"
COPYRIGHT="2020 Victor Gamper"
LICENSE="GNU GPL v3"
REVISION="1"
srcGitRev="018c0fd7184e02992488a95ce514c3f1d77d7604" 
# 6 Dec 2021 commit.
SOURCE_URI="https://github.com/TheZeldakatze/c-CATch/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="c5f0d7b696d641b6168b92b05e822f76c92de31c784739d94f901b5596e593c5"
SOURCE_FILENAME="c-CATch-$srcGitRev.tar.gz"
SOURCE_DIR="c-CATch-$srcGitRev"
ADDITIONAL_FILES="ccatch.rdef.in"

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

PROVIDES="
	ccatch$secondaryArchSuffix = $portVersion
	app:cCATch = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libSDL_1.2$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libSDL_1.2$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	"

BUILD()
{
	gcc -lSDL -o c-CATch catch.c BitmapFontRenderer.c PidginImage.c
}

INSTALL()
{	
	# prepare the rdef file
	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|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/ccatch.rdef.in > $portDir/ccatch.rdef
	
	mkdir -p $appsDir
	cp c-CATch $appsDir/cCATch
	addResourcesToBinaries $portDir/ccatch.rdef $appsDir/cCATch
	addAppDeskbarSymlink $appsDir/cCATch
}
