Skip to content

Commit 51a64ba

Browse files
blueborelylei
authored andcommitted
Compatible with gcc4.4 (baidu#904)
(baidu#902)
1 parent 4dbf320 commit 51a64ba

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ before_script:
6666
- echo 'TCMALLOC_PATH=./thirdparty' >> depends.mk
6767
- echo 'COMMON_PATH=./common/output' >> depends.mk
6868
- echo 'LEVELDB_PATH=./thirdparty' >> depends.mk
69+
- echo 'STD_FLAG=c++11' >> depends.mk
6970

7071
script: make -j4 && make check && make test
7172

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LDFLAGS = -L$(PBRPC_PATH)/lib -lsofa-pbrpc \
2525
SO_LDFLAGS += -rdynamic $(DEPS_LDPATH) $(SO_DEPS_LDFLAGS) -lpthread -lrt -lz -ldl \
2626
-shared -Wl,--version-script,so-version-script # hide symbol of thirdparty libs
2727

28-
CXXFLAGS = -std=c++11 -Wall -fPIC $(OPT)
28+
CXXFLAGS = -std=$(STD_FLAG) -Wall -fPIC $(OPT)
2929
FUSEFLAGS = -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 -I$(FUSE_PATH)/include
3030
FUSE_LL_FLAGS = -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 -I$(FUSE_LL_PATH)/include
3131

Diff for: build.sh

+26-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ if [ ! -f "${FLAG_DIR}/snappy_1_1_1" ] \
6868
|| [ ! -f "${DEPS_PREFIX}/lib/libsnappy.a" ] \
6969
|| [ ! -f "${DEPS_PREFIX}/include/snappy.h" ]; then
7070
cd snappy-1.1.1
71+
autoreconf -ivf
7172
./configure ${DEPS_CONFIG}
7273
make -j4
7374
make install
@@ -153,14 +154,32 @@ if [ ! -f "${FLAG_DIR}/gperftools_2_2_1" ] \
153154
touch "${FLAG_DIR}/gperftools_2_2_1"
154155
fi
155156

157+
# test c++11
158+
set +e
159+
if test -z "$CXX"; then
160+
CXX=g++
161+
fi
162+
163+
$CXX --std=c++11 -x c++ - -o teststd.out 2>/dev/null <<EOF
164+
int main() {}
165+
EOF
166+
167+
if [ "$?" = 0 ]; then
168+
STD_FLAG=c++11
169+
fi
170+
rm -rf teststd.out
171+
set -e
172+
156173
# common
157174
if [ ! -f "${FLAG_DIR}/common" ] \
158175
|| [ ! -f "${DEPS_PREFIX}/lib/libcommon.a" ]; then
159176
rm -rf common
160177
git clone -b cpp11 https://github.com/baidu/common
161178
cd common
162179
sed -i 's/^PREFIX=.*/PREFIX=..\/..\/thirdparty/' config.mk
163-
sed -i '/^INCLUDE_PATH=*/s/$/ -I..\/..\/thirdparty\/boost_1_57_0/g' Makefile
180+
if test -z "$STD_FLAG"; then
181+
sed -i 's/-std=c++11/-std=c++0x/g' Makefile
182+
fi
164183
make -j4
165184
make install
166185
cd -
@@ -185,6 +204,12 @@ echo "GTEST_PATH=./thirdparty" >> depends.mk
185204
echo "COMMON_PATH=./thirdparty" >> depends.mk
186205
echo "TCMALLOC_PATH=./thirdparty" >> depends.mk
187206

207+
if test -z "$STD_FLAG"; then
208+
echo "STD_FLAG=c++0x" >> depends.mk
209+
else
210+
echo "STD_FLAG=c++11" >> depends.mk
211+
fi
212+
188213
########################################
189214
# build tera
190215
########################################

0 commit comments

Comments
 (0)