Commit 2230cc17 authored by gejun's avatar gejun

fix compilations on dev-machine

Change-Id: I402166c0666ee6d6a12d6d223261e51ebb760b5a
parent 4c2c7802
......@@ -208,31 +208,31 @@ clean:
output/include output/lib output/bin
libbase.a:$(BASE_OBJS)
@echo "Linking $@"
@echo "Packing $@"
@ar crs $@ $^
libbvar.a:$(BVAR_OBJS)
@echo "Linking $@"
@echo "Packing $@"
@ar crs $@ $^
libbthread.a:$(BTHREAD_OBJS)
@echo "Linking $@"
@echo "Packing $@"
@ar crs $@ $^
libjson2pb.a:$(JSON2PB_OBJS)
@echo "Linking $@"
@echo "Packing $@"
@ar crs $@ $^
libmcpack2pb.a:$(MCPACK2PB_OBJS)
@echo "Linking $@"
@echo "Packing $@"
@ar crs $@ $^
protoc-gen-mcpack:mcpack2pb/generator.o libmcpack2pb.a libbase.a libbthread.a libbvar.a
@echo "Linking $@"
@$(CXX) -o protoc-gen-mcpack -L$(LIBPATH) -Xlinker "-(" $^ -Xlinker "-)" $(LDFLAGS)
@$(CXX) -o protoc-gen-mcpack $(LIBPATH) -Xlinker "-(" $^ -Xlinker "-)" $(LDFLAGS)
libbrpc.a:$(BRPC_OBJS)
@echo "Linking $@"
@echo "Packing $@"
@ar crs libbrpc.a $^
.PHONY:output/include
......
......@@ -27,13 +27,17 @@ while true; do
* ) break ;;
esac
done
if [ -z "$INCS" ] || [ -z "$LIBS" ]; then
$ERROR "config_brpc: --incs=INCPATHS --libs=LIBPATHS must be specified"
exit 1
fi
find_dir_of_lib() {
dirname $(find ${LIBS} -name "lib${1}.a" -o -name "lib${1}.so" | head -n1)
local lib=$(find ${LIBS} -name "lib${1}.a" -o -name "lib${1}.so*" | head -n1)
if [ ! -z "$lib" ]; then
dirname $lib
fi
}
find_dir_of_lib_or_die() {
local dir=$(find_dir_of_lib $1)
......@@ -45,8 +49,12 @@ find_dir_of_lib_or_die() {
fi
}
find_bin() {
find ${LIBS} -name "$1" | head -n1
}
find_dir_of_header() {
find ${INCS} -path "*/$1" | sed "s|$1||g"
find ${INCS} -path "*/$1" | head -n1 | sed "s|$1||g"
}
find_dir_of_header_or_die() {
local dir=$(find_dir_of_header $1)
......@@ -83,15 +91,19 @@ fi
PROTOC=$(which protoc 2>/dev/null)
if [ -z "$PROTOC" ]; then
PROTOC=$(find_dir_of_lib_or_die protoc)/protoc
PROTOC=$(find_bin protoc)
if [ -z "$PROTOC" ]; then
$ERROR "Fail to find protoc"
exit 1
fi
fi
GFLAGS_INC=$(find_dir_of_header gflags/gflags.h)
PROTOBUF_INC=$(find_dir_of_header google/protobuf/message.h)
LEVELDB_INC=$(find_dir_of_header leveldb/db.h)
INCS=$($ECHO "$GFLAGS_INC\n$PROTOBUF_INC\n$LEVELDB_INC" | sort | uniq)
LIBS=$($ECHO "$GFLAGS_DIR\n$PROTOBUF_DIR\n$LEVELDB_DIR\n$SNAPPY_DIR\n$PROTOC_DIR" | sort | uniq)
INCS2=$($ECHO "$GFLAGS_INC\n$PROTOBUF_INC\n$LEVELDB_INC" | sort | uniq)
LIBS2=$($ECHO "$GFLAGS_DIR\n$PROTOBUF_DIR\n$LEVELDB_DIR\n$SNAPPY_DIR\n$PROTOC_DIR" | sort | uniq)
absent_in_the_list() {
TMP=$($ECHO "`$ECHO "$1\n$2" | sort | uniq`")
......@@ -102,8 +114,8 @@ absent_in_the_list() {
}
#can't use \n in texts because sh does not support -e
CONTENT="INCS=$($ECHO $INCS)"
CONTENT="${CONTENT}\nLIBS=$($ECHO $LIBS)"
CONTENT="INCS=$($ECHO $INCS2)"
CONTENT="${CONTENT}\nLIBS=$($ECHO $LIBS2)"
CONTENT="${CONTENT}\nPROTOC=$PROTOC"
CONTENT="${CONTENT}\nPROTOBUF_INC=$PROTOBUF_INC"
CONTENT="${CONTENT}\nCC=$CC"
......@@ -114,13 +126,14 @@ CONTENT="${CONTENT}\nifeq (\$(LINK_PERFTOOLS), 1)"
# required by cpu/heap profiler
TCMALLOC_DIR=$(find_dir_of_lib tcmalloc_and_profiler)
if [ ! -z "$TCMALLOC_DIR" ]; then
if absent_in_the_list "$TCMALLOC_DIR" "$LIBS"; then
if absent_in_the_list "$TCMALLOC_DIR" "$LIBS2"; then
CONTENT="${CONTENT}\n LIBS+=$TCMALLOC_DIR"
LIBS="${LIBS}\n$TCMALLOC_DIR"
LIBS2="${LIBS2}\n$TCMALLOC_DIR"
fi
TCMALLOC_INC=$(find_dir_of_header google/tcmalloc.h)
if absent_in_the_list "$TCMALLOC_INC" "$INCS"; then
if absent_in_the_list "$TCMALLOC_INC" "$INCS2"; then
CONTENT="${CONTENT}\n INCS+=$TCMALLOC_INC"
INCS2="${INCS2}\n$TCMALLOC_INC"
fi
if [ -f $TCMALLOC_DIR/libtcmalloc_and_profiler.a ]; then
CONTENT="${CONTENT}\n STATIC_LINKING+=-ltcmalloc_and_profiler"
......@@ -131,28 +144,17 @@ fi
# required by tcmalloc('s profiler)
UNWIND_DIR=$(find_dir_of_lib unwind)
if [ ! -z "$UNWIND_DIR" ]; then
if absent_in_the_list "$UNWIND_DIR" "$LIBS"; then
if absent_in_the_list "$UNWIND_DIR" "$LIBS2"; then
CONTENT="${CONTENT}\n LIBS+=$UNWIND_DIR"
LIBS="${LIBS}\n$UNWIND_DIR"
LIBS2="${LIBS2}\n$UNWIND_DIR"
fi
if [ -f $UNWIND_DIR/libunwind.a ]; then
CONTENT="${CONTENT}\n STATIC_LINKING+=-lunwind"
else
CONTENT="${CONTENT}\n DYNAMIC_LINKING+=-lunwind"
fi
fi
# required by libunwind
LZMA_DIR=$(find_dir_of_lib lzma)
if [ ! -z "$LZMA_DIR" ]; then
if absent_in_the_list "$LZMA_DIR" "$LIBS"; then
CONTENT="${CONTENT}\n LIBS+=$LZMA_DIR"
LIBS="${LIBS}\n$LZMA_DIR"
fi
if [ -f $LZMA_DIR/liblzma.a ]; then
CONTENT="${CONTENT}\n STATIC_LINKING+=-llzma"
else
CONTENT="${CONTENT}\n DYNAMIC_LINKING+=-llzma"
fi
# required by libunwind
CONTENT="${CONTENT}\n DYNAMIC_LINKING+=-llzma"
fi
CONTENT="${CONTENT}\nendif"
$ECHO "$CONTENT" > config.mk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment