SUMMARY="Snowball compiler and stemming algorithms"
DESCRIPTION="Snowball is a small string processing language for creating \
stemming algorithms for use in Information Retrieval, plus a collection of \
stemming algorithms implemented using it."
HOMEPAGE="https://github.com/snowballstem/snowball"
COPYRIGHT="2001 Dr Martin Porter
	2004,2005 Richard Boulton
	2013 Yoshiki Shibukawa
	2006,2007,2009,2010,2011,2014-2019 Olly Betts"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/snowballstem/snowball/archive/refs/tags/v${portVersion}.tar.gz"
CHECKSUM_SHA256="425cdb5fba13a01db59a1713780f0662e984204f402d3dae1525bda9e6d30f1a"
PATCHES="snowball_stemmer-$portVersion.patchset"
SOURCE_DIR="snowball-$portVersion"

ARCHITECTURES="all ?x86"
SECONDARY_ARCHITECTURES="x86"

libVersion="2.2.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	snowball_stemmer$secondaryArchSuffix = $portVersion
	cmd:snowball$secondaryArchSuffix = portVersion compat >= 2
	cmd:stemwords$secondaryArchSuffix = portVersion compat >= 2
	lib:libstemmer$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	snowball_stemmer${secondaryArchSuffix}_devel = portVersion
	devel:libstemmer$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	snowball_stemmer$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:perl
	"

defineDebugInfoPackage snowball_stemmer$secondaryArchSuffix \
	$libDir/libstemmer.so.2

BUILD()
{
	make $jobArgs
}

INSTALL()
{
	install -d  $binDir $libDir $includeDir
	install snowball stemwords $binDir
	install libstemmer.a $libDir
	install include/libstemmer.h $includeDir
	install libstemmer.so.* $libDir

	# prepare develop/lib
	prepareInstalledDevelLibs libstemmer
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check_stemtest
}
