SUMMARY="A database engine"
DESCRIPTION="LMDB is compact, fast, powerful, and robust and implements \
a simplified variant of the BerkeleyDB (BDB) API."
HOMEPAGE="http://symas.com/mdb/"
COPYRIGHT="2011-2021 Howard Chu, Symas Corp."
LICENSE="OpenLDAP Public License"
REVISION="1"
SOURCE_URI="https://github.com/LMDB/lmdb/archive/LMDB_$portVersion.tar.gz"
CHECKSUM_SHA256="22054926b426c66d8f2bc22071365df6e35f3aacf19ad943bc6167d4cae3bebb"
SOURCE_DIR="lmdb-LMDB_$portVersion"
PATCHES="lmdb-$portVersion.patchset"

ARCHITECTURES="all ?x86_gcc2"
SECONDARY_ARCHITECTURES="?x86_gcc2 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

PROVIDES="
	lmdb$secondaryArchSuffix = $portVersion compat >= 0
	cmd:mdb_copy$commandSuffix
	cmd:mdb_dump$commandSuffix
	cmd:mdb_load$commandSuffix
	cmd:mdb_stat$commandSuffix
	lib:liblmdb$secondaryArchSuffix = $portVersion compat >= 0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	lmdb${secondaryArchSuffix}_devel = $portVersion compat >= 0
	devel:liblmdb$secondaryArchSuffix = $portVersion compat >= 0
	"
REQUIRES_devel="
	lmdb$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	cd libraries/liblmdb

	make $jobArgs
}

INSTALL()
{
	cd libraries/liblmdb

	make install \
		prefix="$prefix" \
		bindir="$commandBinDir" \
		libdir="$libDir" \
		includedir="$includeDir" \
		datarootdir="$dataDir" \
		mandir="$manDir/man1"

	prepareInstalledDevelLib liblmdb
	packageEntries devel $developDir
}

TEST()
{
	cd libraries/liblmdb
	make test
}
