Commit 4e7c7bab authored by gejun's avatar gejun

config_brpc.sh supports mac

parent 29fc94eb
if [ -z "$BASH" ]; then SYSTEM=$(uname -s)
if [ "$SYSTEM" = "Darwin" ]; then
ECHO=echo ECHO=echo
SO=dylib
LDD="otool -L"
if [ "$(getopt -V)" = " --" ]; then
>&2 $ECHO "gnu-getopt must be installed and used"
exit 1
fi
else else
if [ -z "$BASH" ]; then
ECHO=echo
else
ECHO='echo -e' ECHO='echo -e'
fi
SO=so
LDD=ldd
fi fi
# NOTE: This requires GNU getopt. On Mac OS X and FreeBSD, you have to install this
# separately; see below.
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog -n 'config_brpc' -- "$@"` TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog -n 'config_brpc' -- "$@"`
WITH_GLOG=0 WITH_GLOG=0
...@@ -50,7 +62,7 @@ if [ -z "$HDRS_IN" ] || [ -z "$LIBS_IN" ]; then ...@@ -50,7 +62,7 @@ if [ -z "$HDRS_IN" ] || [ -z "$LIBS_IN" ]; then
fi fi
find_dir_of_lib() { find_dir_of_lib() {
local lib=$(find ${LIBS_IN} -name "lib${1}.a" -o -name "lib${1}.so" | head -n1) local lib=$(find ${LIBS_IN} -name "lib${1}.a" -o -name "lib${1}.$SO" | head -n1)
if [ ! -z "$lib" ]; then if [ ! -z "$lib" ]; then
dirname $lib dirname $lib
fi fi
...@@ -128,8 +140,8 @@ append_linking $PROTOBUF_LIB protobuf ...@@ -128,8 +140,8 @@ append_linking $PROTOBUF_LIB protobuf
LEVELDB_LIB=$(find_dir_of_lib_or_die leveldb) LEVELDB_LIB=$(find_dir_of_lib_or_die leveldb)
# required by leveldb # required by leveldb
if [ -f $LEVELDB_LIB/libleveldb.a ]; then if [ -f $LEVELDB_LIB/libleveldb.a ]; then
if [ -f $LEVELDB_LIB/libleveldb.so ]; then if [ -f $LEVELDB_LIB/libleveldb.$SO ]; then
if ldd $LEVELDB_LIB/libleveldb.so | grep -q libsnappy; then if $LDD $LEVELDB_LIB/libleveldb.$SO | grep -q libsnappy; then
SNAPPY_LIB=$(find_dir_of_lib snappy) SNAPPY_LIB=$(find_dir_of_lib snappy)
REQUIRE_SNAPPY="yes" REQUIRE_SNAPPY="yes"
fi fi
...@@ -247,8 +259,8 @@ if [ -z "$TCMALLOC_LIB" ]; then ...@@ -247,8 +259,8 @@ if [ -z "$TCMALLOC_LIB" ]; then
else else
append_to_output_libs "$TCMALLOC_LIB" " " append_to_output_libs "$TCMALLOC_LIB" " "
if [ -f $TCMALLOC_LIB/libtcmalloc_and_profiler.a ]; then if [ -f $TCMALLOC_LIB/libtcmalloc_and_profiler.a ]; then
if [ -f $TCMALLOC_LIB/libtcmalloc.so ]; then if [ -f $TCMALLOC_LIB/libtcmalloc.$SO ]; then
ldd $TCMALLOC_LIB/libtcmalloc.so > libtcmalloc.deps $LDD $TCMALLOC_LIB/libtcmalloc.$SO > libtcmalloc.deps
if grep -q libunwind libtcmalloc.deps; then if grep -q libunwind libtcmalloc.deps; then
TCMALLOC_REQUIRE_UNWIND="yes" TCMALLOC_REQUIRE_UNWIND="yes"
REQUIRE_UNWIND="yes" REQUIRE_UNWIND="yes"
...@@ -283,8 +295,8 @@ if [ $WITH_GLOG != 0 ]; then ...@@ -283,8 +295,8 @@ if [ $WITH_GLOG != 0 ]; then
else else
append_to_output_libs "$GLOG_LIB" " " append_to_output_libs "$GLOG_LIB" " "
if [ -f $GLOG_LIB/libglog.a ]; then if [ -f $GLOG_LIB/libglog.a ]; then
if [ -f "$GLOG_LIB/libglog.so" ]; then if [ -f "$GLOG_LIB/libglog.$SO" ]; then
ldd $GLOG_LIB/libglog.so > libglog.deps $LDD $GLOG_LIB/libglog.$SO > libglog.deps
if grep -q libunwind libglog.deps; then if grep -q libunwind libglog.deps; then
GLOG_REQUIRE_UNWIND="yes" GLOG_REQUIRE_UNWIND="yes"
REQUIRE_UNWIND="yes" REQUIRE_UNWIND="yes"
......
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