From ff84a6e7d25ae19ef099d4b89120762e354a3923 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Thu, 11 May 2017 15:17:26 -0700 Subject: [PATCH] Build and link with ZStd when creating the static RocksJava build Summary: Closes https://github.com/facebook/rocksdb/pull/2279 Differential Revision: D5048161 Pulled By: yiwu-arbug fbshipit-source-id: 43742ff93137e0a35ea7e855692c9e9a0cd41968 --- Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a0fa4028f..f16e60824 100644 --- a/Makefile +++ b/Makefile @@ -1391,6 +1391,9 @@ SNAPPY_VER = 1.1.4 SNAPPY_SHA256 = 134bfe122fd25599bb807bb8130e7ba6d9bdb851e0b16efcb83ac4f5d0b70057 LZ4_VER = 1.7.5 LZ4_SHA256 = 0190cacd63022ccb86f44fa5041dc6c3804407ad61550ca21c382827319e7e7e +ZSTD_VER ?= 1.2.0 +ZSTD_SHA256 ?= 4a7e4593a3638276ca7f2a09dc4f38e674d8317bbea51626393ca73fc047cbfb +ZSTD_DOWNLOAD_BASE ?= https://github.com/facebook/zstd/archive ifeq ($(PLATFORM), OS_MACOSX) ROCKSDBJNILIB = librocksdbjni-osx.jnilib @@ -1464,6 +1467,19 @@ liblz4.a: cd lz4-$(LZ4_VER)/lib && make CFLAGS='-fPIC' all cp lz4-$(LZ4_VER)/lib/liblz4.a . +libzstd.a: + -rm -rf zstd-$(ZSTD_VER) + curl -O -L ${ZSTD_DOWNLOAD_BASE}/v$(ZSTD_VER).tar.gz + mv v$(ZSTD_VER).tar.gz zstd-$(ZSTD_VER).tar.gz + ZSTD_SHA256_ACTUAL=`$(SHA256_CMD) zstd-$(ZSTD_VER).tar.gz | cut -d ' ' -f 1`; \ + if [ "$(ZSTD_SHA256)" != "$$ZSTD_SHA256_ACTUAL" ]; then \ + echo zstd-$(ZSTD_VER).tar.gz checksum mismatch, expected=\"$(ZSTD_SHA256)\" actual=\"$$ZSTD_SHA256_ACTUAL\"; \ + exit 1; \ + fi + tar xvzf zstd-$(ZSTD_VER).tar.gz + cd zstd-$(ZSTD_VER)/lib && make CFLAGS='-fPIC -O2 ${EXTRA_CFLAGS}' all + cp zstd-$(ZSTD_VER)/lib/libzstd.a . + # A version of each $(LIBOBJECTS) compiled with -fPIC and a fixed set of static compression libraries java_static_libobjects = $(patsubst %,jls/%,$(LIBOBJECTS)) CLEAN_FILES += jls @@ -1471,7 +1487,7 @@ CLEAN_FILES += jls JAVA_STATIC_FLAGS = -DZLIB -DBZIP2 -DSNAPPY -DLZ4 JAVA_STATIC_INCLUDES = -I./zlib-$(ZLIB_VER) -I./bzip2-$(BZIP2_VER) -I./snappy-$(SNAPPY_VER) -I./lz4-$(LZ4_VER)/lib -$(java_static_libobjects): jls/%.o: %.cc libz.a libbz2.a libsnappy.a liblz4.a +$(java_static_libobjects): jls/%.o: %.cc libz.a libbz2.a libsnappy.a liblz4.a libzstd.a $(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) $(JAVA_STATIC_FLAGS) $(JAVA_STATIC_INCLUDES) -fPIC -c $< -o $@ $(COVERAGEFLAGS) rocksdbjavastatic: $(java_static_libobjects)