SUMMARY="A roguelike adventure through dungeons filled with dangerous monsters"
DESCRIPTION="Dungeon Crawl Stone Soup is a game of dungeon exploration, \
combat and magic, involving characters of diverse skills, worshipping dieties \
of great power and caprice. To win, you'll need to be a master of tactics and \
strategy, and prevail against overwhelming odds."
HOMEPAGE="https://crawl.develz.org"
COPYRIGHT="1997-2021 Linley Henzell, the dev team, and the contributors"
LICENSE="crawl"
REVISION="2"
SOURCE_URI="https://github.com/crawl/crawl/releases/download/$portVersion/stone_soup-$portVersion-nodeps.tar.xz"
CHECKSUM_SHA256="d8a6f7419e324a225d95474e7e878d58370a0727f3d436e50fb5375ff1fdf343"
SOURCE_FILENAME="crawl-$portVersion.tar.xz"
SOURCE_DIR="stone_soup-$portVersion"
PATCHES="crawl-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2 ?x86"
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
commandBinDir=$prefix/bin
fi

PROVIDES="
	crawl$secondaryArchSuffix = $portVersion
	app:DungeonCrawlStoneSoup = $portVersion
	cmd:crawl
	"
REQUIRES="
	haiku$secondaryArchSuffix
	dejavu
	pyyaml_python3
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:liblua$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:liblua$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libpcre$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libSDL2_image_2.0$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:bison
	cmd:cmp
	cmd:flex
	cmd:fc_list$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:lua
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	cmd:pngcrush
	cmd:python3
	cmd:which
	cmd:xargs
	dejavu
	pyyaml_python3
	"

defineDebugInfoPackage crawl$secondaryArchSuffix \
	"$appsDir/DungeonCrawlStoneSoup" \
	"$commandBinDir/crawl"

BUILD()
{
	cd ./source
	if [ -n "$secondaryArchSuffix" ]; then
		set HAIKU_HYBRID_SECONDARY="$effectiveTargetArchitecture"
	fi

	make $jobArgs TILES=y "$@"
	mv crawl crawl-tiles
	make $jobArgs "$@"
}

INSTALL()
{
	cd ./source
	install -m 755 \
		-d "$appsDir" "$commandBinDir" "$dataDir"/crawl \
		"$docDir" "$manDir"/man6

	cp -r dat "$dataDir"/crawl/
	cp -r ../docs ../settings "$docDir"
	mv "$docDir"/docs/crawl.6 "$manDir"/man6

	install -m 555 crawl-tiles "$appsDir"/DungeonCrawlStoneSoup
	install -m 555 crawl "$commandBinDir"
	addAppDeskbarSymlink "$appsDir"/DungeonCrawlStoneSoup \
		"Dungeon Crawl Stone Soup"
}
