SUMMARY="A fast key-value storage library written at Google"
DESCRIPTION="LevelDB stores keys and values in arbitrary byte arrays, and \
data is sorted by key. It supports batching writes, forward and backward \
iteration, and compression of the data via Google's Snappy compression \
library.
LevelDB is not an SQL database. Like other NoSQL and Dbm stores, it does \
not have a relational data model and it does not support SQL queries. Also, \
it has no support for indexes. Applications use LevelDB as a library, as it \
does not provide a server or command-line interface."
HOMEPAGE="http://leveldb.org/"
COPYRIGHT="2017 The LevelDB Authors"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/google/leveldb/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="9a37f8a6174f09bd622bc723b55881dc541cd50747cbd08831c2a82d620f6d76"
SOURCE_FILENAME="leveldb-$portVersion.tar.gz"
PATCHES="leveldb-$portVersion.patchset"

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

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

PROVIDES="
	leveldb$secondaryArchSuffix = $portVersion
	lib:libleveldb$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libsnappy$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"

PROVIDES_devel="
	leveldb${secondaryArchSuffix}_devel = $portVersion
	devel:libleveldb$secondaryArchSuffix = $libVersionCompat
	devel:libmemenv$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	leveldb$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbenchmark$secondaryArchSuffix
	devel:libgmock$secondaryArchSuffix
	devel:libsnappy$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage leveldb$secondaryArchSuffix \
	"$libDir"/libleveldb.so.$libVersion

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

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs libleveldb

	packageEntries devel \
		"$developDir" \
		"$libDir/cmake"
}

TEST()
{
	cd build
	make test
}
