diff --git a/README.cn.md b/README.cn.md index eb087ac..a7b2058 100644 --- a/README.cn.md +++ b/README.cn.md @@ -16,7 +16,7 @@ |基础数据结构|dict hash ringbuffer queue rbtree sort vector macro |网络库|rtsp rtmp skt p2p rpc ipc |异步|gevent workq thread -|I/O解析|base64 config log file filewatcher strex +|I/O解析|base64 config log file filewatcher strex submask |多媒体|uvc jpeg-ex mp4parser |其他|debug hal plugin time posix4win @@ -29,11 +29,17 @@ `> cd libraries\libposix4win\` `> nmake /f Makefile.nmake clean` `> nmake /f Makefile.nmake` + 默认debug版本,编译release版本 + `> nmake /f Makefile.nmake clean` + `> nmake /f Makefile.nmake MODE=release` ### Linux * linux 平台 (Ubuntu14.04 gcc-4.8.4+及以上版本 32/64 bit) `$ cd libraries` - `$ ./build.sh` + `$ ./build.sh` + 默认debug版本,编译release版本 + `$ ./build.sh {all|libxxx} linux release` + 安装 `$ sudo ./build.sh install` * host(linux) target(rasberrypi) @@ -46,13 +52,16 @@ * android arm 交叉编译 (需要下载 [android-ndk-r9-linux-x86_64.tar.bz2](http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2)) - `$ ./build.sh all android` + `$ ./build.sh all android` + 默认debug版本,编译release版本 + `$ ./build.sh {all|libxxx} android release` * android 原生开发 also need ndk tools `$ cd android_jni_libs` `$ ndk-build` - + 默认debug版本,编译release版本 + `$ ndk-build MODE=release` After install, the libxxx.xx will be installed in /usr/local/lib/. libxxx.h, libxxx.so or libxxx.a of libraries are also in ./output/$(ARCH) diff --git a/README.md b/README.md index fb29b62..e70436a 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,17 @@ This is a collection of basic libraries. `> cd libraries\libposix4win\` `> nmake /f Makefile.nmake clean` `> nmake /f Makefile.nmake` - + default debug version, compiler release version + `> nmake /f Makefile.nmake clean` + `> nmake /f Makefile.nmake MODE=release` + ### Linux * linux platform (>= Ubuntu14.04 >= gcc-4.8.4 32/64 bit) `$ cd libraries` `$ ./build.sh` + default debug version,compiler release version + `$ ./build.sh {all|libxxx} linux release` + install `$ sudo ./build.sh install` * host(linux) target(rasberrypi) @@ -47,12 +53,15 @@ This is a collection of basic libraries. * android arm cross compile (you need download [android-ndk-r9-linux-x86_64.tar.bz2](http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2)) `$ ./build.sh all android` + default debug version,compiler release version + `$ ./build.sh {all|libxxx} android release` * android naitve develop also need ndk tools `$ cd android_jni_libs` `$ ndk-build` - + default debug version,compiler release version + `$ ndk-build MODE=release` After install, the libxxx.xx will be installed in /usr/local/lib/. libxxx.h, libxxx.so or libxxx.a of libraries are also in ./output/$(ARCH) diff --git a/build.sh b/build.sh index 5d2cef0..1f45021 100755 --- a/build.sh +++ b/build.sh @@ -4,16 +4,23 @@ set -e CMD=$0 MODULE=$1 ARCH=$2 +MODE=$3 #default is linux case $# in 0) MODULE=all; - ARCH=linux;; + ARCH=linux; + MODE=debug;; 1) - ARCH=linux;; + ARCH=linux; + MODE=debug;; +2) + MODE=debug;; + esac + #add supported platform to here PLATFORM="[linux|pi|android|ios]" @@ -27,22 +34,23 @@ NETWORK_LIBS="libskt librpc librtsp" usage() { echo "==== usage ====" - echo "$CMD [platform]" + echo "$CMD [platform] [mode]" echo ": library to compile or all library, must needed" echo "[platform]: linux, raspberrypi or android, default is linux, optional" + echo "[mode]: debug or release, default is debug, optional" echo "" - echo "./build.sh all $PLATFORM" - echo "./build.sh basic_libs $PLATFORM" - echo "./build.sh network_libs $PLATFORM" + echo "./build.sh all $PLATFORM [debug|release]" + echo "./build.sh basic_libs $PLATFORM [debug|release]" + echo "./build.sh network_libs $PLATFORM [debug|release]" echo "" echo "basic libraries (must):" for item in $BASIC_LIBS; do - echo "$CMD $item $PLATFORM"; + echo "$CMD $item $PLATFORM [debug|release]"; done echo "" echo "network libraries (optional):" for item in $NETWORK_LIBS; do - echo "$CMD $item $PLATFORM"; + echo "$CMD $item $PLATFORM [debug|release]"; done exit } @@ -72,7 +80,7 @@ config_common() { STRIP=${CROSS_PREFIX}strip LIBS_DIR=`pwd` - OUTPUT=${LIBS_DIR}/output/${ARCH} + OUTPUT=${LIBS_DIR}/output/${ARCH}/ } config_arch() @@ -93,9 +101,9 @@ config_arch() check_output() { - if [ ! -d "${OUTPUT}" ]; then + if [ ! -d "${OUTPUT}/debug" ]; then mkdir -p ${OUTPUT}/include - mkdir -p ${OUTPUT}/lib + mkdir -p ${OUTPUT}/{release,debug}/lib fi } @@ -122,7 +130,7 @@ build_module() return ;; "install") - MAKE="make ARCH=${ARCH}" + MAKE="make ARCH=${ARCH} MODE=${MODE}" ${MAKE} install > /dev/null if [ $? -ne 0 ]; then echo "==== install ${ARCH} ${MODULE} failed" @@ -132,7 +140,7 @@ build_module() fi ;; "uninstall") - MAKE="make ARCH=${ARCH}" + MAKE="make ARCH=${ARCH} MODE=${MODE}" ${MAKE} uninstall > /dev/null if [ $? -ne 0 ]; then echo "==== uninstall ${ARCH} ${MODULE} failed" @@ -142,7 +150,7 @@ build_module() fi ;; *) - MAKE="make ARCH=${ARCH} OUTPUT=${OUTPUT}" + MAKE="make ARCH=${ARCH} OUTPUT=${OUTPUT} MODE=${MODE}" if [[ ${ARCH} == "linux" || ${ARCH} == "pi" || ${ARCH} == "android" ]]; then ${MAKE} > /dev/null else @@ -176,6 +184,8 @@ do_build() { case $MODULE in "all") + rm -rf output + check_output build_all clean; build_all;; "clean") diff --git a/build/autogen_lib.sh b/build/autogen_lib.sh index e98c226..d568955 100755 --- a/build/autogen_lib.sh +++ b/build/autogen_lib.sh @@ -9,6 +9,7 @@ LIBFOO_H=${MODULE}.h TEST_LIBFOO_C=test_${MODULE}.c README_MD=README.md ANDROID_MK=Android.mk +NMAKE=Makefile.nmake VERSION_SH=version.sh LIBFOO_MACRO=`echo ${MODULE} | tr 'a-z' 'A-Z'` @@ -103,6 +104,7 @@ CC = ${S}(CROSS_PREFIX)gcc CXX = ${S}(CROSS_PREFIX)g++ LD = ${S}(CROSS_PREFIX)ld AR = ${S}(CROSS_PREFIX)ar +STRIP = ${S}(CROSS_PREFIX)strip ifeq (${S}(COLOR_INC), ${S}(wildcard ${S}(COLOR_INC))) include ${S}(COLOR_INC) @@ -133,7 +135,13 @@ OBJS_UNIT_TEST = test_${S}(LIBNAME).o ############################################################################### # cflags and ldflags ############################################################################### -CFLAGS := -g -Wall -Werror -fPIC +ifeq (${S}(MODE), release) +CFLAGS := -O2 -Wall -Werror -fPIC +LTYPE := release +else +CFLAGS := -g -Wall -Werror -fPIC +LTYPE := debug +endif CFLAGS += ${S}(${S}(ARCH)_CFLAGS) CFLAGS += -I${S}(OUTPUT)/include @@ -178,16 +186,17 @@ clean: install: ${S}(MAKEDIR_OUTPUT) + if [ "${S}(MODE)" = "release" ];then ${S}(STRIP) ${S}(TGT); fi ${S}(CP_V) -r ${S}(TGT_LIB_H) ${S}(OUTPUT)/include - ${S}(CP_V) -r ${S}(TGT_LIB_A) ${S}(OUTPUT)/lib - ${S}(CP_V) -r ${S}(TGT_LIB_SO) ${S}(OUTPUT)/lib - ${S}(CP_V) -r ${S}(TGT_LIB_SO_VER) ${S}(OUTPUT)/lib + ${S}(CP_V) -r ${S}(TGT_LIB_A) ${S}(OUTPUT)/${S}(LTYPE)/lib + ${S}(CP_V) -r ${S}(TGT_LIB_SO) ${S}(OUTPUT)/${S}(LTYPE)/lib + ${S}(CP_V) -r ${S}(TGT_LIB_SO_VER) ${S}(OUTPUT)/${S}(LTYPE)/lib uninstall: - ${S}(RM_V) -f ${S}(OUTPUT)/include/${S}(TGT_LIB_H) - ${S}(RM_V) -f ${S}(OUTPUT)/lib/${S}(TGT_LIB_A) - ${S}(RM_V) -f ${S}(OUTPUT)/lib/${S}(TGT_LIB_SO) - ${S}(RM_V) -f ${S}(OUTPUT)/lib/${S}(TGT_LIB_SO_VER) + cd ${S}(OUTPUT)/include/ && rm -f ${S}(TGT_LIB_H) + ${S}(RM_V) -f ${S}(OUTPUT)/${S}(LTYPE)/lib/${S}(TGT_LIB_A) + ${S}(RM_V) -f ${S}(OUTPUT)/${S}(LTYPE)/lib/${S}(TGT_LIB_SO) + ${S}(RM_V) -f ${S}(OUTPUT)/${S}(LTYPE)/lib/${S}(TGT_LIB_SO_VER) ! } @@ -200,6 +209,10 @@ include ${S}(CLEAR_VARS) LOCAL_MODULE := ${MODULE} +ifeq (${S}(MODE), release) +LOCAL_CFLAGS += -O2 +endif + LIBRARIES_DIR := ${S}(LOCAL_PATH)/../ LOCAL_C_INCLUDES := ${S}(LOCAL_PATH) @@ -211,6 +224,66 @@ include ${S}(BUILD_SHARED_LIBRARY) ! } +autogen_makefile_nmake() +{ +cat > ${NMAKE} < ${README_MD} </dev/null\` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h </dev/null` autogen_version_h() { cat > version.h <