SUMMARY="A fast compressor/decompressor"
DESCRIPTION="Snappy is a compression/decompression library. It does not aim \
for maximum compression, or compatibility with any other compression library; \
instead, it aims for very high speeds and reasonable compression. For instance, \
compared to the fastest mode of zlib, Snappy is an order of magnitude faster \
for most inputs, but the resulting compressed files are anywhere from 20% to \
100% bigger."
HOMEPAGE="https://google.github.io/snappy/"
COPYRIGHT="2005-2017 Google Inc"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/google/snappy/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="75c1fbb3d618dd3a0483bff0e26d0a92b495bbe5059c8b4f1c962b478b6e06e7"
PATCHES="snappy-$portVersion.patchset"

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

PROVIDES="
	snappy$secondaryArchSuffix = $portVersion compat >= 1
	lib:libsnappy$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	snappy${secondaryArchSuffix}_devel = $portVersion compat >= 1
	devel:libsnappy$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES_devel="
	snappy$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	cmake -S. -Bbuild \
		$cmakeDirArgs -DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=Release \
		-DSNAPPY_USE_BUNDLED_GTEST=OFF \
		-DSNAPPY_USE_BUNDLED_BENCHMARK_LIB=OFF
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install

	prepareInstalledDevelLib libsnappy

	mkdir -p $developLibDir/pkgconfig
	cat > $developLibDir/pkgconfig/snappy.pc << EOF
prefix=${prefix}
exec_prefix=${prefix}
libdir=${libDir}
includedir=${includeDir}

Name: snappy
Description: A fast compression/decompression library
Version: $portVersion
Libs: -L${developLibDir} -lsnappy
Cflags: -I${includedir}
EOF

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	build/snappy_unittest
}
