SUMMARY="A 2D space trading and combat game"
DESCRIPTION="Endless Sky is a 2D space trading and combat game \
similar to the classic Escape Velocity series. Explore other star systems. \
Earn money by trading, carrying passengers, or completing missions. \
Use your earnings to buy a better ship or to upgrade the weapons and engines \
on your current one. Blow up pirates. Take sides in a civil war. \
Or leave human space behind and hope to find friendly aliens whose culture \
is more civilized than your own."
HOMEPAGE="http://endless-sky.github.io/"
COPYRIGHT="Michael Zahniser"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/endless-sky/endless-sky/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="6c22571b5398a18297aa7410890c319b5cb292a833889b4e7c0cd94d831f29af"
SOURCE_DIR="endless-sky-$portVersion"
PATCHES="endless_sky-$portVersion.patchset"
ADDITIONAL_FILES="endless-sky.rdef.in"

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

PROVIDES="
	endless_sky$secondaryArchSuffix = $portVersion
	app:EndlessSky = $portVersion
	"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libmad$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libGL$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libmad$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:gcc$secondaryArchSuffix
	cmd:scons
	"

BUILD()
{
	scons $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/EndlessSky
	cp -r endless-sky credits.txt data images sounds $appsDir/EndlessSky/

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

	addResourcesToBinaries  $sourceDir/endless-sky.rdef \
		$appsDir/EndlessSky/endless-sky
	addAppDeskbarSymlink $appsDir/EndlessSky/endless-sky EndlessSky
}
