SUMMARY="An implementation of Double-Array Trie"
DESCRIPTION="This is an implementation of double-array structure for \
representing trie, as proposed by Junichi Aoe. \
Trie is a kind of digital search tree, an efficient indexing method in which \
search time is independent of database size. It only takes O(m) search time, \
where m is the length of the search string. Comparably as efficient as hashing, \
trie also provides flexibility on incremental matching and key spelling \
manipulation. This makes it ideal for lexical analyzers, as well as spelling \
dictionaries."
HOMEPAGE="https://linux.thai.net/projects/datrie"
COPYRIGHT="2006-2019 Theppitak Karoonboonyanan"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://github.com/tlwg/libdatrie/releases/download/v$portVersion/libdatrie-$portVersion.tar.xz"
CHECKSUM_SHA256="452dcc4d3a96c01f80f7c291b42be11863cd1554ff78b93e110becce6e00b149"

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

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

PROVIDES="
	libdatrie$secondaryArchSuffix = $portVersion
	lib:libdatrie$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix >= 2
	"

PROVIDES_devel="
	libdatrie${secondaryArchSuffix}_devel = $portVersion
	cmd:trietool$secondaryArchSuffix = $portVersion
	devel:libdatrie$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	haiku$secondaryArchSuffix
	libdatrie$secondaryArchSuffix == $portVersion base
	lib:libiconv$secondaryArchSuffix >= 2
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix >= 2
	"
BUILD_PREREQUIRES="
	cmd:gawk
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libdatrie$secondaryArchSuffix \
	$libDir/libdatrie.so.$libVersion

BUILD()
{
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	rm -f $binDir/trietool-0.2
	rm -f $libDir/libdatrie.la

	prepareInstalledDevelLib libdatrie
	fixPkgconfig

	packageEntries devel \
		$binDir \
		$developDir \
		$manDir
}

TEST()
{
	make check
}
