Skip to content

Commit

Permalink
Compatible with gcc4.4 (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebore authored and lylei committed Jun 19, 2017
1 parent 4dbf320 commit 51a64ba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 26 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -153,14 +154,32 @@ 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 <<EOF
int main() {}
EOF

if [ "$?" = 0 ]; then
STD_FLAG=c++11
fi
rm -rf teststd.out
set -e

# common
if [ ! -f "${FLAG_DIR}/common" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libcommon.a" ]; then
rm -rf common
git clone -b cpp11 https://github.com/baidu/common
cd common
sed -i 's/^PREFIX=.*/PREFIX=..\/..\/thirdparty/' config.mk
sed -i '/^INCLUDE_PATH=*/s/$/ -I..\/..\/thirdparty\/boost_1_57_0/g' Makefile
if test -z "$STD_FLAG"; then
sed -i 's/-std=c++11/-std=c++0x/g' Makefile
fi
make -j4
make install
cd -
Expand All @@ -185,6 +204,12 @@ echo "GTEST_PATH=./thirdparty" >> 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
########################################
Expand Down

0 comments on commit 51a64ba

Please sign in to comment.