Skip to content

Commit

Permalink
auto detect ROCKSDB_LDFLAGS & acquire submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelMaker committed Aug 5, 2017
1 parent b929c9e commit 6f22b70
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ tags

make_config.mk
src/*.d
src/build_version.cc
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

# ----------------------------------------------
Expand Down Expand Up @@ -105,10 +109,7 @@ LDFLAGS += $(LIB_PATH) \
-lnemo$(DEBUG_SUFFIX) \
-lnemodb$(DEBUG_SUFFIX) \
-lrocksdb$(DEBUG_SUFFIX) \
-lglog \
-lz \
-lbz2 \
-lsnappy
-lglog

# ---------------End Dependences----------------

Expand Down
2 changes: 0 additions & 2 deletions Makefile.global

This file was deleted.

72 changes: 72 additions & 0 deletions detect_environment
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
#include <snappy.h>
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 <gflags/gflags.h>
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 <gflags/gflags.h>
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 <<EOF
#include <zlib.h>
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 <<EOF
#include <bzlib.h>
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 <<EOF
#include <lz4.h>
#include <lz4hc.h>
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 <<EOF
#include <zstd.h>
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"
8 changes: 0 additions & 8 deletions release.sh

This file was deleted.

2 changes: 1 addition & 1 deletion third/nemo
Submodule nemo updated 2 files
+1 −1 3rdparty/nemo-rocksdb
+1 −2 Makefile
2 changes: 1 addition & 1 deletion third/nemo-rocksdb
Submodule nemo-rocksdb updated 2 files
+0 −1 .gitignore
+3 −1 Makefile
5 changes: 2 additions & 3 deletions tools/pika_to_redis/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/ \
Expand All @@ -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/ \
Expand Down
8 changes: 3 additions & 5 deletions tools/ssdb_to_pika/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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

Expand Down

0 comments on commit 6f22b70

Please sign in to comment.