SUMMARY="A third-person shooting DOS game"
DESCRIPTION="In this game, you get guns to shoot zombies and cyborgs. \
For a DOS game, the graphics are pretty good. It also comes with a map editor."
HOMEPAGE="https://github.com/lmartinking/cdogs-sdl"
SOURCE_URI="https://codeload.github.com/lmartinking/cdogs-sdl/zip/master"
SOURCE_URI_2="https://codeload.github.com/lmartinking/cdogs-sdl-data/zip/master"
SOURCE_FILENAME="cdogs-sdl-master.zip"
SOURCE_FILENAME_2="cdogs-sdl-data-master.zip"
CHECKSUM_SHA256="9dca57eb6d73e6ff0bbb97867b2ef1797d1a6899722294951f4f74bcf2c2f1af"
CHECKSUM_SHA256_2="8c71bf2d964f1bc098463abcd795bcd400570bad367fb952206be9e83bcdcb11"
SOURCE_DIR="cdogs-sdl-master/src"
REVISION="1"
LICENSE="GNU GPL v2"
COPYRIGHT="2008-2010 Lucas Martin-King"

ARCHITECTURES="x86 x86_gcc2"

PROVIDES="
	Cyberdogs_SDL= $portVersion
	app:Cyberdogs_SDL= $portVersion
	"
REQUIRES="
	haiku
	lib:libsdl
	lib:libsdl_mixer
	"
BUILD_REQUIRES="
	haiku_devel
	devel:libsdl
	devel:libsdl_mixer
	"
BUILD_PREREQUIRES="
	cmd:make
	cmd:gcc
	"

PATCH()
{
	sed -i "s|PREFIX		:= /usr/local|PREFIX		:= $appsDir/cdogs_sdl|" $sourceDir/Makefile
	sed -i "s|:= no|:= yes|" $sourceDir/Makefile
	sed -i "s|BINDIR		:= "'$(PREFIX)'"/games/bin|BINDIR		:= $appsDir/cdogs_sdl|" $sourceDir/Makefile
	sed -i "s|DATADIR		:= "'$(PREFIX)'"/share/games/cdogs-sdl|DATADIR		:= $appsDir/cdogs_sdl/data|" $sourceDir/Makefile
	sed -i "s|DOCDIR		:= "'$(PREFIX)'"/share/doc/cdogs-sdl|DOCDIR		:= $appsDir/cdogs_sdl/docs|" $sourceDir/Makefile
	sed -i "s|DATA		:= ../data|DATA		:= $appsDir/cdogs_sdl/data|" $sourceDir/Makefile
}

BUILD()
{
	mkdir -p $appsDir/cdogs_sdl/doc/
	mkdir -p $appsDir/cdogs_sdl/data
	mkdir -p $sourceDir/data
	mkdir -p $settingsDir/cdogs
	cd $sourceDir/data
	cp -r $sourceDir2/cdogs-sdl-data-master/* $sourceDir/data
	cd $sourceDir
	chmod 777 ./install.sh
	mkdir -p data
	make $jobArgs cdogs-sdl USE_PKGCONFIG=no
	make $jobArgs cdogs-sdl-editor USE_PKGCONFIG=no
}

INSTALL()
{
	mkdir -p $appsDir/cdogs_sdl
	cp cdogs-sdl $appsDir/cdogs_sdl
	cp cdogs-sdl-editor $appsDir/cdogs_sdl
	cp -r data/* $appsDir/cdogs_sdl/data
	addAppDeskbarSymlink $appsDir/cdogs_sdl/cdogs-sdl Cyberdogs-sdl
}
