From 6f22b70ac211684fb30b3ae036f2150796b5c43e Mon Sep 17 00:00:00 2001 From: KernelMaker Date: Sat, 5 Aug 2017 11:54:05 +0800 Subject: [PATCH] auto detect ROCKSDB_LDFLAGS & acquire submodules --- .gitignore | 1 + Makefile | 9 +++-- Makefile.global | 2 - detect_environment | 72 ++++++++++++++++++++++++++++++++++++ release.sh | 8 ---- third/nemo | 2 +- third/nemo-rocksdb | 2 +- tools/pika_to_redis/Makefile | 5 +-- tools/ssdb_to_pika/Makefile | 8 ++-- 9 files changed, 85 insertions(+), 24 deletions(-) delete mode 100644 Makefile.global delete mode 100644 release.sh diff --git a/.gitignore b/.gitignore index e530603182..5cc18bc23f 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ tags make_config.mk src/*.d +src/build_version.cc diff --git a/Makefile b/Makefile index 88b1519933..bdd9c7f03e 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,9 @@ ifeq ($(MAKECMDGOALS),dbg) DEBUG_LEVEL=2 endif +$(info updating submodule) +dummy := $(shell (git submodule init && git submodule update)) + # compile with -O2 if debug level is not 2 ifneq ($(DEBUG_LEVEL), 2) OPT += -O2 -fno-omit-frame-pointer @@ -42,6 +45,7 @@ dummy := $(shell ("$(CURDIR)/detect_environment" "$(CURDIR)/make_config.mk")) include make_config.mk CLEAN_FILES += $(CURDIR)/make_config.mk PLATFORM_LDFLAGS += $(TCMALLOC_LDFLAGS) +PLATFORM_LDFLAGS += $(ROCKSDB_LDFLAGS) PLATFORM_CXXFLAGS += $(TCMALLOC_EXTENSION_FLAGS) # ---------------------------------------------- @@ -105,10 +109,7 @@ LDFLAGS += $(LIB_PATH) \ -lnemo$(DEBUG_SUFFIX) \ -lnemodb$(DEBUG_SUFFIX) \ -lrocksdb$(DEBUG_SUFFIX) \ - -lglog \ - -lz \ - -lbz2 \ - -lsnappy + -lglog # ---------------End Dependences---------------- diff --git a/Makefile.global b/Makefile.global deleted file mode 100644 index 6671f31f08..0000000000 --- a/Makefile.global +++ /dev/null @@ -1,2 +0,0 @@ -RPATH = /usr/local/pika22/lib/ -LFLAGS = -Wl,-rpath=$(RPATH) diff --git a/detect_environment b/detect_environment index 0a89eca09f..a316ec02da 100755 --- a/detect_environment +++ b/detect_environment @@ -32,9 +32,81 @@ if [ "$?" = 0 ]; then TCMALLOC_EXTENSION_FLAGS=" -DTCMALLOC_EXTENSION" fi +# Test whether Snappy library is installed +# http://code.google.com/p/snappy/ +$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null < + int main() {} +EOF +if [ "$?" = 0 ]; then + ROCKSDB_LDFLAGS="$ROCKSDB_LDFLAGS -lsnappy" +fi + +# Test whether gflags library is installed +# http://gflags.github.io/gflags/ +# check if the namespace is gflags +$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null << EOF + #include + using namespace gflags; + int main() {} +EOF +if [ "$?" = 0 ]; then + ROCKSDB_LDFLAGS="$ROCKSDB_LDFLAGS -lgflags" +else + # check if namespace is google + $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null << EOF + #include + using namespace google; + int main() {} +EOF +if [ "$?" = 0 ]; then + ROCKSDB_LDFLAGS="$ROCKSDB_LDFLAGS -lgflags" +fi +fi + +# Test whether zlib library is installed +$CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null < + int main() {} +EOF +if [ "$?" = 0 ]; then + ROCKSDB_LDFLAGS="$ROCKSDB_LDFLAGS -lz" +fi + +# Test whether bzip library is installed +$CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null < + int main() {} +EOF +if [ "$?" = 0 ]; then + ROCKSDB_LDFLAGS="$ROCKSDB_LDFLAGS -lbz2" +fi + +# Test whether lz4 library is installed +$CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null < + #include + int main() {} +EOF +if [ "$?" = 0 ]; then + ROCKSDB_LDFLAGS="$ROCKSDB_LDFLAGS -llz4" +fi + +# Test whether zstd library is installed +$CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null < + int main() {} +EOF +if [ "$?" = 0 ]; then + ROCKSDB_LDFLAGS="$ROCKSDB_LDFLAGS -lzstd" +fi + + + # Test processor nums PROCESSOR_NUMS=$(cat /proc/cpuinfo | grep processor | wc -l) +echo "ROCKSDB_LDFLAGS=$ROCKSDB_LDFLAGS" >> "$OUTPUT" echo "TCMALLOC_EXTENSION_FLAGS=$TCMALLOC_EXTENSION_FLAGS" >> "$OUTPUT" echo "TCMALLOC_LDFLAGS=$TCMALLOC_LDFLAGS" >> "$OUTPUT" echo "PROCESSOR_NUMS=$PROCESSOR_NUMS" >> "$OUTPUT" diff --git a/release.sh b/release.sh deleted file mode 100644 index 3f14fa761e..0000000000 --- a/release.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Used for Release only. - -TAG="2.1.4" -make clean && make RPATH=./lib __REL=1 - -tar -czf pika${TAG}_bin.tar.gz output diff --git a/third/nemo b/third/nemo index ff9c2fc6e9..7e9c1f5b97 160000 --- a/third/nemo +++ b/third/nemo @@ -1 +1 @@ -Subproject commit ff9c2fc6e9dd5ffd606cae02790c84ca0745c764 +Subproject commit 7e9c1f5b971102f43ab58a5af4cfb0ae66bcdcfb diff --git a/third/nemo-rocksdb b/third/nemo-rocksdb index c640d32815..ee936b9122 160000 --- a/third/nemo-rocksdb +++ b/third/nemo-rocksdb @@ -1 +1 @@ -Subproject commit c640d328151b620864b45597620196d24ba56fd2 +Subproject commit ee936b91228180cc0205c776934e6c27bfed76a7 diff --git a/tools/pika_to_redis/Makefile b/tools/pika_to_redis/Makefile index d4b887f549..6853940f4f 100644 --- a/tools/pika_to_redis/Makefile +++ b/tools/pika_to_redis/Makefile @@ -2,6 +2,7 @@ GCC = g++ CPPFLAGS = -Wall -W -Wno-unused-parameter -DDEBUG -D__XDEBUG__ -g -O3 -std=c++11 OBJECT = pika_to_redis +include ../../make_config.mk LIB_PATH = -L ../../third/nemo/lib/ \ -L ../../third/pink/pink/lib/ \ -L ../../third/slash/slash/lib/ \ @@ -10,14 +11,12 @@ LIB_PATH = -L ../../third/nemo/lib/ \ LIBS = -Wl,-Bstatic -lnemo -lrocksdb\ -Wl,-Bdynamic -lpthread\ - -lsnappy \ -lrt \ - -lz \ - -lbz2 \ -lpink \ -lslash \ -lnemodb \ -lrocksdb +LIBS += $(ROCKSDB_LDFLAGS) INCLUDE_PATH = -I../../third/pink/ \ diff --git a/tools/ssdb_to_pika/Makefile b/tools/ssdb_to_pika/Makefile index 207d000a55..08989c4c0b 100644 --- a/tools/ssdb_to_pika/Makefile +++ b/tools/ssdb_to_pika/Makefile @@ -4,6 +4,7 @@ OBJECT = ssdb_to_pika SRC_DIR = . OUTPUT = . +include ../../make_config.mk INCLUDE_PATH = -I./ \ -I../../third/nemo/include \ -I../../third/nemo-rocksdb/include \ @@ -15,11 +16,8 @@ STATIC_LIBS = ./libssdb-client.a \ ../../third/nemo-rocksdb/lib/libnemodb.a \ ../../third/rocksdb/librocksdb.a -LIBS = -lsnappy \ - -lrt \ - -lz \ - -lbz2 \ - -lpthread +LIBS = -lrt -pthread +LIBS += $(ROCKSDB_LDFLAGS) .PHONY: all clean