From 5a11f31aac4fa6a5c5ebb4fa0964e1c07a420e8c Mon Sep 17 00:00:00 2001
From: Zac Medico <zmedico@gentoo.org>
Date: Wed, 12 Apr 2017 01:49:09 -0700
Subject: [PATCH] configure: link against zstd if detected

https://bugs.gentoo.org/show_bug.cgi?id=601610
---
 configure.ac        | 6 ++++--
 src/Makefile-env.am | 3 +++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 51daf91..8914b71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -851,12 +851,14 @@ AS_IF([test "x$with_librocksdb_static" = "xyes"],
 AM_CONDITIONAL(WITH_SLIBROCKSDB, [ test "x$with_librocksdb_static" = "xyes" ])
 AM_CONDITIONAL(WITH_LIBROCKSDB, [ test "x$with_librocksdb_static" = "xyes" -o "x$with_librocksdb" = "xyes" ])
 
-# rocksdb detects bzlib and lz4 in its Makefile, which forces us to do the same.
+# rocksdb detects headers in its Makefile, which forces us to do the same.
 AS_IF([test "x$with_librocksdb_static" = "xyes"], [
   AC_CHECK_HEADER([bzlib.h], [have_bzlib=yes])
-  AC_CHECK_HEADER([lz4.h], [have_lz4=yes])])
+  AC_CHECK_HEADER([lz4.h], [have_lz4=yes])]
+  AC_CHECK_HEADER([zstd.h], [have_zstd=yes])])
 AM_CONDITIONAL(HAVE_BZLIB, [test "x$have_bzlib" = "xyes"])
 AM_CONDITIONAL(HAVE_LZ4, [test "x$have_lz4" = "xyes"])
+AM_CONDITIONAL(HAVE_ZSTD, [test "x$have_zstd" = "xyes"])
 
 # needs libcurl and libxml2
 if test "x$with_rest_bench" = xyes && test "x$with_system_libs3" = xno; then
diff --git a/src/Makefile-env.am b/src/Makefile-env.am
index 4771bad..0ee42f8 100644
--- a/src/Makefile-env.am
+++ b/src/Makefile-env.am
@@ -280,6 +280,9 @@ endif
 if HAVE_LZ4
 LIBKV += -llz4
 endif
+if HAVE_ZSTD
+LIBKV += -lzstd
+endif
 endif # WITH_SLIBROCKSDB
 LIBKV += -lz -lleveldb -lsnappy
 LIBOS += $(LIBOS_TYPES) $(LIBKV) $(LIBFUSE_LIBS)
-- 
2.10.2

