make.sh and Makefile.in changed

connection_manager
yuqing 2018-05-22 17:06:43 +08:00
parent e759b2d0f8
commit 7cad20223b
3 changed files with 33 additions and 7 deletions

27
make.sh
View File

@ -1,11 +1,26 @@
ENABLE_STATIC_LIB=0
ENABLE_SHARED_LIB=1
TARGET_PREFIX=$DESTDIR/usr/local
TARGET_CONF_PATH=$DESTDIR/etc/mc
TARGET_PREFIX=$DESTDIR/usr
TARGET_CONF_PATH=$DESTDIR/etc
LIB_VERSION=lib64
DEBUG_FLAG=1
if [ -f /usr/include/fastcommon/_os_define.h ]; then
OS_BITS=$(fgrep OS_BITS /usr/include/fastcommon/_os_define.h | awk '{print $NF;}')
elif [ -f /usr/local/include/fastcommon/_os_define.h ]; then
OS_BITS=$(fgrep OS_BITS /usr/local/include/fastcommon/_os_define.h | awk '{print $NF;}')
else
OS_BITS=64
fi
if [ "$OS_BITS" -eq 64 ]; then
LIB_VERSION=lib64
else
LIB_VERSION=lib
fi
CFLAGS="$CFLAGS -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE"
if [ "$DEBUG_FLAG" = "1" ]; then
CFLAGS="$CFLAGS -g -O1 -DDEBUG_FLAG"
@ -17,8 +32,13 @@ LIBS=''
uname=$(uname)
if [ "$uname" = "Linux" ]; then
CFLAGS="$CFLAGS"
elif [ "$uname" = "FreeBSD" ]; then
elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
CFLAGS="$CFLAGS"
if [ "$uname" = "Darwin" ]; then
LIB_VERSION=lib
TARGET_PREFIX=$TARGET_PREFIX/local
fi
elif [ "$uname" = "SunOS" ]; then
CFLAGS="$CFLAGS -D_THREAD_SAFE"
LIBS="$LIBS -lsocket -lnsl -lresolv"
@ -96,5 +116,6 @@ sed_replace "s#\$(LIBS)#$LIBS#g" Makefile
sed_replace "s#\$(TARGET_PREFIX)#$TARGET_PREFIX#g" Makefile
sed_replace "s#\$(ENABLE_STATIC_LIB)#$ENABLE_STATIC_LIB#g" Makefile
sed_replace "s#\$(ENABLE_SHARED_LIB)#$ENABLE_SHARED_LIB#g" Makefile
sed_replace "s#\\\$(LIB_VERSION)#$LIB_VERSION#g" Makefile
make $1 $2

View File

@ -3,8 +3,7 @@
COMPILE = $(CC) $(CFLAGS) -fPIC
INC_PATH = -I/usr/include -I/usr/local/include
LIB_PATH = $(LIBS) -lfastcommon
TARGET_LIB = $(TARGET_PREFIX)/lib64
TARGET_PATH = $(TARGET_PREFIX)/bin
TARGET_LIB = $(TARGET_PREFIX)/$(LIB_VERSION)
ALL_HEADERS = sf_types.h sf_global.h sf_define.h sf_nio.h sf_service.h sf_func.h sf_util.h list.h
ALL_LIBS = libserverframe.so
@ -21,14 +20,13 @@ libserverframe.so: sf_nio.lo sf_service.lo sf_global.lo sf_func.lo sf_util.lo
.c.lo:
$(COMPILE) -c -o $@ $< $(INC_PATH)
install:
mkdir -p $(TARGET_PATH)
mkdir -p $(TARGET_LIB)
mkdir -p $(TARGET_PREFIX)/include/sf
cp -f $(ALL_LIBS) $(TARGET_LIB)
cp -f $(ALL_HEADERS) $(TARGET_PREFIX)/include/sf
# if [ ! -h $(TARGET_LIB)/libserverframe.so ]; then cd $(TARGET_LIB); ln -s libserverframe.so.1 libserverframe.so; fi
if [ ! -e $(TARGET_PREFIX)/lib/libserverframe.so ]; then ln -s $(TARGET_LIB)/libserverframe.so $(TARGET_PREFIX)/lib/libserverframe.so; fi
clean:
rm -f *.lo $(ALL_LIBS) $(ALL_PRGS)

View File

@ -32,10 +32,17 @@ void log_plus(const int priority, const char* file,
#ifdef DEBUG_FLAG
#ifdef OS_LINUX
#ifdef SYS_gettid
tid = (long)syscall(SYS_gettid);
#else
tid = (long)pthread_self();
#endif
#else
tid = (long)pthread_self();
#endif
hlen = snprintf(buf, sizeof(buf), "%s:%d %ld ", file, line, tid);
#else