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.
+AS_IF([test "x$with_librocksdb_static" = "xyes"], [
+ AC_CHECK_HEADER([bzlib.h], [have_bzlib=yes])
+ AC_CHECK_HEADER([lz4.h], [have_lz4=yes])])
+AM_CONDITIONAL(HAVE_BZLIB, [test "x$have_bzlib" = "xyes"])
+AM_CONDITIONAL(HAVE_LZ4, [test "x$have_lz4" = "xyes"])
+
# error out if --with-jemalloc and --with-librocksdb_static as rocksdb uses tcmalloc
if test "x$with_jemalloc" = "xyes"; then
if test "x$with_librocksdb_static" != "xno"; then
# libkv/libos linking order is ornery
if WITH_SLIBROCKSDB
LIBKV += rocksdb/librocksdb.a
+if HAVE_BZLIB
+LIBKV += -lbz2
endif
-LIBKV += -lbz2 -lz -lleveldb -lsnappy
+if HAVE_LZ4
+LIBKV += -llz4
+endif
+endif # WITH_SLIBROCKSDB
+LIBKV += -lz -lleveldb -lsnappy
LIBOS += $(LIBOS_TYPES) $(LIBKV)
LIBMON += $(LIBMON_TYPES)