SUMMARY="A chess engine and console frontend"
DESCRIPTION="GNU Chess is a free software chess engine developed by the GNU \
project. It started as a project by Stuart Cracraft and Richard Stallman in \
1984. It is supported as an engine for a wide range of graphical frontents \
such as XBoard and glChess, but also works autonomously on the console."
HOMEPAGE="https://www.gnu.org/software/chess/"
COPYRIGHT="2001-2020 Free Software Foundation, Inc."
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="http://ftpmirror.gnu.org/chess/gnuchess-$portVersion.tar.gz"
CHECKSUM_SHA256="e536675a61abe82e61b919f6b786755441d9fcd4c21e1c82fb9e5340dd229846"
PATCHES="gnuchess-$portVersion.patchset"

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

if [ "$targetArchitecture" != x86_gcc2 ]; then
	commandSuffix=$secondaryArchSuffix
	commandBinDir=$binDir
else
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	gnuchess$secondaryArchSuffix = $portVersion
	cmd:gnuchess$commandSuffix = $portVersion
	cmd:gnuchessu$commandSuffix = $portVersion
	cmd:gnuchessx$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoreconf
	cmd:awk
	cmd:find
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	autoreconf -vfi
	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install
}

TEST()
{
	make check
}
