From 51a64ba295cf9d53e420cb033267afb9775529ea Mon Sep 17 00:00:00 2001 From: Yan Shiguang Date: Mon, 19 Jun 2017 10:15:53 +0800 Subject: [PATCH] Compatible with gcc4.4 (#904) (#902) --- .travis.yml | 1 + Makefile | 2 +- build.sh | 27 ++++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dec729bb..357ca978 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,6 +66,7 @@ before_script: - echo 'TCMALLOC_PATH=./thirdparty' >> depends.mk - echo 'COMMON_PATH=./common/output' >> depends.mk - echo 'LEVELDB_PATH=./thirdparty' >> depends.mk + - echo 'STD_FLAG=c++11' >> depends.mk script: make -j4 && make check && make test diff --git a/Makefile b/Makefile index 3b615798..7af11c51 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ LDFLAGS = -L$(PBRPC_PATH)/lib -lsofa-pbrpc \ SO_LDFLAGS += -rdynamic $(DEPS_LDPATH) $(SO_DEPS_LDFLAGS) -lpthread -lrt -lz -ldl \ -shared -Wl,--version-script,so-version-script # hide symbol of thirdparty libs -CXXFLAGS = -std=c++11 -Wall -fPIC $(OPT) +CXXFLAGS = -std=$(STD_FLAG) -Wall -fPIC $(OPT) FUSEFLAGS = -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 -I$(FUSE_PATH)/include FUSE_LL_FLAGS = -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 -I$(FUSE_LL_PATH)/include diff --git a/build.sh b/build.sh index 2a30438f..04972ac7 100755 --- a/build.sh +++ b/build.sh @@ -68,6 +68,7 @@ if [ ! -f "${FLAG_DIR}/snappy_1_1_1" ] \ || [ ! -f "${DEPS_PREFIX}/lib/libsnappy.a" ] \ || [ ! -f "${DEPS_PREFIX}/include/snappy.h" ]; then cd snappy-1.1.1 + autoreconf -ivf ./configure ${DEPS_CONFIG} make -j4 make install @@ -153,6 +154,22 @@ if [ ! -f "${FLAG_DIR}/gperftools_2_2_1" ] \ touch "${FLAG_DIR}/gperftools_2_2_1" fi +# test c++11 +set +e +if test -z "$CXX"; then + CXX=g++ +fi + +$CXX --std=c++11 -x c++ - -o teststd.out 2>/dev/null <> depends.mk echo "COMMON_PATH=./thirdparty" >> depends.mk echo "TCMALLOC_PATH=./thirdparty" >> depends.mk +if test -z "$STD_FLAG"; then + echo "STD_FLAG=c++0x" >> depends.mk +else + echo "STD_FLAG=c++11" >> depends.mk +fi + ######################################## # build tera ########################################