SUMMARY="A free opensource 2D MMORPG client"
DESCRIPTION="OpenSource 2D MMORPG client for Evol Online and The Mana World"
HOMEPAGE="https://manaplus.org/"
COPYRIGHT="2004-2009 The Mana World Development Team
2009-2010 The Mana Developers
2011-2018 The ManaPlus Developers"
LICENSE="GNU GPL v2"
REVISION="3"
SOURCE_URI="https://github.com/ManaPlus/ManaPlus/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="200ad08ce441238c125661f29a28a61ae91219a90cca04ddea0bd5b4f142c64c"
SOURCE_DIR="ManaPlus-$portVersion"
PATCHES="manaplus-$portVersion.patchset"
ADDITIONAL_FILES="manaplus.rdef.in"

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

USER_SETTINGS_FILES="
	settings/Mana/ManaPlus
	"

PROVIDES="
	manaplus$secondaryArchSuffix = $portVersion
	app:ManaPlus$secondaryArchSuffix = $portVersion
	cmd:dyecmd$secondaryArchSuffix = $portVersion
	cmd:manaplus$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL_1.2$secondaryArchSuffix
	lib:libSDL_gfx$secondaryArchSuffix
	lib:libSDL_image_1.2$secondaryArchSuffix
	lib:libSDL_mixer_1.2$secondaryArchSuffix
	lib:libSDL_net_1.2$secondaryArchSuffix
	lib:libSDL_ttf_2.0$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL_1.2$secondaryArchSuffix
	devel:libSDL_gfx$secondaryArchSuffix
	devel:libSDL_image_1.2$secondaryArchSuffix
	devel:libSDL_mixer_1.2$secondaryArchSuffix
	devel:libSDL_net_1.2$secondaryArchSuffix
	devel:libSDL_ttf_2.0$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autopoint
	cmd:autoreconf
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage manaplus$secondaryArchSuffix \
	"$binDir"/dyecmd \
	"$binDir"/manaplus

BUILD()
{
	export LDFLAGS="-lnetwork -lGL -lintl"

	autoreconf -vfi
	runConfigure ./configure \
		--without-opengl
	make $jobArgs
}

INSTALL()
{
	make install

	mkdir -p "$appsDir"
	ln -s "$binDir"/manaplus "$appsDir"/ManaPlus

	local APP_SIGNATURE="application/x-vnd.ManaPlus"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/manaplus.rdef.in > manaplus.rdef

	addResourcesToBinaries manaplus.rdef \
		"$binDir"/manaplus

	addAppDeskbarSymlink "$appsDir"/ManaPlus
}
