SUMMARY="Free and open source C++ spell checking library"
DESCRIPTION="Nuspell is a free and open source spell checker library \
and command-line program designed for languages with rich morphology \
and complex word compounding. \
Nuspell is a pure C++ re-implementation of Hunspell.

Main features of Nuspell spell checker:

 - Full unicode support backed by ICU
 - Backward compatibility with Hunspell dictionary file format
 - Twofold affix stripping (for agglutinative languages, like Azeri, Basque, Estonian, Finnish, Hungarian, Turkish, etc.)
 - Support complex compounds (for example, Hungarian, German and Dutch)
 - Support language specific features (for example, special casing of Azeri and Turkish dotted i, or German sharp s)
 - Handle conditional affixes, circumfixes, fogemorphemes, forbidden words, pseudoroots and homonyms.
 - Free software. Licensed under GNU LGPL v3."
HOMEPAGE="https://nuspell.github.io/"
COPYRIGHT="2016-2019 Dimitrij Mijoski, Sander van Geloven
	2007-2016 Hunspell developers et al.
	2002-2008 László Németh (Hunspell)
	2001-2002 Kevin Hendricks (MySpell)"
LICENSE="GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://github.com/nuspell/nuspell/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="01804d490bec517748ee49fa2f1249f4c99380c26335e32082cdaa02b5b2b4dc"
SOURCE_FILENAME="nuspell-$portVersion.tar.gz"
PATCHES="nuspell-$portVersion.patchset"

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

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="$portVersion compat >= 4"

PROVIDES="
	$portName = $portVersion
	lib:libnuspell$secondaryArchSuffix = $libVersion
	cmd:nuspell = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libicudata$secondaryArchSuffix
	lib:libicuuc$secondaryArchSuffix
	"

PROVIDES_devel="
	nuspell${secondaryArchSuffix}_devel = $portVersion
	devel:libnuspell$secondaryArchSuffix = $libVersion
	"
REQUIRES_devel="
	nuspell$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libicudata$secondaryArchSuffix >= 66
	devel:libicuuc$secondaryArchSuffix >= 66
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	#cmd:git # for tests
	#cmd:ronn # for the docs (ruby stuff)
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake $cmakeDirArgs .. \
		-DCMAKE_INSTALL_BINDIR=$commandBinDir \
		-DCMAKE_BUILD_TYPE=Release \
		-DBUILD_SHARED_LIBS=ON
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs libnuspell
	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	cd build
	make test
}
