SUMMARY="System Shock, but cross platform!"
DESCRIPTION="Based on the source code for PowerPC released by Night Dive \
Studios, Incorporated.

Shockolate is a cross platform source port of System Shock, using SDL2. \
This runs well on OSX, Linux, and Windows right now, with some missing \
features that need reviving due to not being included in the source code \
that was released.

The end goal for this project is something like what Chocolate Doom is for \
Doom: an experience that closely mimics the original, but portable and with \
some quality of life improvements including an OpenGL renderer and mod support!

You need contents of data folder from the original game copied into res/data \
folder."
HOMEPAGE="https://github.com/Interrupt/systemshock/"
COPYRIGHT="2019 Interrupt"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/Interrupt/systemshock/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="86bb909576c46c8bcf1ff12370bf3023083a1f19179727bcc6a36ec56c44a388"
SOURCE_FILENAME="systemshock-v$portVersion.tar.gz"
SOURCE_DIR="systemshock-$portVersion"
PATCHES="shockolate-$portVersion.patchset"

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

PROVIDES="
	shockolate$secondaryArchSuffix = $portVersion
	cmd:systemshock = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfluidsynth$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_mixer_2.0$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfluidsynth$secondaryArchSuffix >= 2
	devel:libGL$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libSDL2_mixer_2.0$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage shockolate$secondaryArchSuffix \
	$prefix/bin/systemshock

BUILD()
{
	mkdir -p build && cd build
	cmake -DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$prefix .. -L \
		-DSDL2MAIN_LIBRARY=$(finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib$secondaryArchSubDir/libSDL2.so \
		-DSDL2_LIBRARY=$(finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib$secondaryArchSubDir/libSDL2.so \
		-DSDL2_MIXER_LIBRARY=$(finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib$secondaryArchSubDir/libSDL2_mixer.so \
		-DSDL2_INCLUDE_DIRS=$(finddir B_SYSTEM_HEADERS_DIRECTORY)$secondaryArchSubDir/SDL2 \
		-DSDL2_MIXER_INCLUDE_DIRS=$(finddir B_SYSTEM_HEADERS_DIRECTORY)$secondaryArchSubDir/SDL2
	make $jobArgs systemshock
}

INSTALL()
{
	cd build
	mkdir -p $prefix/bin
	cp systemshock $prefix/bin
}
