SUMMARY="An open source engine for Heroes or Might and Magic III"
DESCRIPTION="
We want to rewrite the entire H3 engine (VCMI is NOT another mod) giving it \
new possibilities. Few years of intensive work resulted in creating an \
application with an impressive amount of features.

You'll require the original game files to use this port."
HOMEPAGE="https://vcmi.eu"
COPYRIGHT="2005-2017 VCMI Team"
LICENSE="GNU GPL v2"
REVISION="6"
SOURCE_URI="https://github.com/vcmi/vcmi/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="b7f2459d7e054c8bdcf419cbb80040e751d3dbb06dc1113ac28f7365930f902e"
PATCHES="vcmi-$portVersion.patchset"

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

PROVIDES="
	vcmi$secondaryArchSuffix = $portVersion
	cmd:vcmibuilder
	cmd:vcmiclient
	cmd:vcmilauncher
	cmd:vcmiserver
	devel:libfuzzylite_static$secondaryArchSuffix
	lib:libminizip$secondaryArchSuffix
	lib:libvcmi$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:innoextract
	lib:libavcodec$secondaryArchSuffix
	lib:libboost_filesystem$secondaryArchSuffix
	lib:libboost_program_options$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libboost_thread$secondaryArchSuffix
	lib:libboost_unit_test_framework$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	lib:libSDL2_mixer_2.0$secondaryArchSuffix
	lib:libSDL2_ttf_2.0$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	# dependency of devel:libQt5Gui
	devel:libavcodec$secondaryArchSuffix
	devel:libboost_filesystem$secondaryArchSuffix
	devel:libboost_program_options$secondaryArchSuffix
	devel:libboost_system$secondaryArchSuffix
	devel:libboost_thread$secondaryArchSuffix
	devel:libboost_unit_test_framework$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libSDL2_image_2.0$secondaryArchSuffix
	devel:libSDL2_mixer_2.0$secondaryArchSuffix
	devel:libSDL2_ttf_2.0$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:as$secondaryArchSuffix
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build
	export CFLAGS=-DUSE_FILE32API
	export CXXFLAGS="$CFLAGS -DBOOST_NO_CXX11_CONSTEXPR"
	cmake .. -DDATA_DIR=$relativeDataDir/vcmi \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DLIB_DIR=$relativeLibDir \
		-DCMAKE_BUILD_TYPE='Release'
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $(dirname $includeDir)
	mv $prefix/include $includeDir

	prepareInstalledDevelLibs libfuzzylite-static

	rm -r $prefix/share # desktop file and png icons we don't care about
}
