diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index ec90341275..654160a992 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -329,12 +329,12 @@ OS_IS_WINDOWS_CYGWIN64=NO function windows_cygwin64_prepare() { # TODO auto install cygwin64 tools ? - if [[ $OSTYPE == cygwin ]]; then - OS_IS_WINDOWS_CYGWIN64=YES - SRS_WINDOWS=YES - fi - - return 0 + if [[ $OSTYPE == cygwin ]]; then + OS_IS_WINDOWS_CYGWIN64=YES + SRS_WINDOWS=YES + fi + + return 0 } windows_cygwin64_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "windows_cygwin64 prepare failed, ret=$ret"; exit $ret; fi @@ -380,7 +380,7 @@ function _srs_link_file() ##################################################################################### # Only supports: # linux, centos/ubuntu as such, -# windows(with cygwin64 toolchain) +# windows(with cygwin64 toolchain) # cross build for embeded system, for example, mips or arm, # directly build on arm/mips, for example, pi or cubie, # export srs-librtmp @@ -407,7 +407,7 @@ if [[ $SRS_OSX == YES ]]; then fi # for windows/cygwin if [[ $OS_IS_WINDOWS_CYGWIN64 = YES ]]; then - _ST_MAKE=cygwin64-debug && _ST_OBJ="CYGWIN64_`uname -s`_DBG" + _ST_MAKE=cygwin64-debug && _ST_OBJ="CYGWIN64_`uname -s`_DBG" fi # Whether enable debug stats. if [[ $SRS_DEBUG_STATS == YES ]]; then @@ -427,17 +427,20 @@ fi _ST_MAKE_ARGS="${_ST_MAKE} STATIC_ONLY=${_ST_STATIC_ONLY}" _ST_MAKE_ARGS="${_ST_MAKE_ARGS} CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB}" # Patched ST from https://github.com/ossrs/state-threads/tree/srs -if [[ -f ${SRS_3RD_ST_PATH}/libst.a ]]; then +if [[ -f ${SRS_3RD_ST_STORE_PATH}/libst.a ]]; then + rm -rf ${SRS_3RD_ST_PATH} && + cp -rf ${SRS_3RD_ST_STORE_PATH} ${SRS_OBJS} && echo -e "The state-threads is ok."; else echo "Building state-threads."; ( rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && - cp -rf ${SRS_WORKDIR}/3rdparty/st-srs ${SRS_OBJS}/${SRS_PLATFORM} && + cp -rf ${SRS_WORKDIR}/3rdparty/st-srs ${SRS_OBJS}/${SRS_PLATFORM} && cd ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && # Build source code. env EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" make ${_ST_MAKE_ARGS} && - cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/* ${SRS_3RD_ST_PATH} + cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/* ${SRS_3RD_ST_PATH} && + cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/* ${SRS_3RD_ST_STORE_PATH} ) fi # check status @@ -545,7 +548,7 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then OPENSSL_CONFIG="./Configure linux-generic32" if [[ $SRS_CROSS_BUILD_ARMV7 == YES ]]; then OPENSSL_CONFIG="./Configure linux-armv4"; fi if [[ $SRS_CROSS_BUILD_AARCH64 == YES ]]; then OPENSSL_CONFIG="./Configure linux-aarch64"; fi - elif [[ ! -f ${SRS_3RD_OPENSSL_PATH}/lib/libssl.a ]]; then + elif [[ ! -f ${SRS_3RD_OPENSSL_STORE_PATH}/lib/libssl.a ]]; then # Try to use exists libraries. #if [[ -f /usr/local/ssl/lib/libssl.a && $SRS_SSL_LOCAL == NO ]]; then # (mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && @@ -586,15 +589,18 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then #OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-ssl2 -no-comp -no-idea -no-hw -no-engine -no-dso -no-err -no-nextprotoneg -no-psk -no-srp -no-ec2m -no-weak-ssl-ciphers" # # cross build not specified, if exists flag, need to rebuild for no-arm platform. - if [[ -f ${SRS_3RD_OPENSSL_PATH}/lib/libssl.a ]]; then + if [[ -f ${SRS_3RD_OPENSSL_STORE_PATH}/lib/libssl.a ]]; then + rm -rf ${SRS_3RD_OPENSSL_PATH} && + cp -rf ${SRS_3RD_OPENSSL_STORE_PATH} ${SRS_OBJS} && echo "The $OPENSSL_CANDIDATE is ok."; else echo "Building $OPENSSL_CANDIDATE."; ( rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} && - cd ${SRS_OBJS}/${SRS_PLATFORM} && - ${OPENSSL_UNZIP} && cd $OPENSSL_CANDIDATE && ${OPENSSL_CONFIG} --prefix=${SRS_3RD_OPENSSL_PATH} $OPENSSL_OPTIONS && - make CC=${SRS_TOOL_CC} AR="${OPENSSL_AR}" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} ${SRS_JOBS} && make install_sw + cd ${SRS_OBJS}/${SRS_PLATFORM} && + ${OPENSSL_UNZIP} && cd $OPENSSL_CANDIDATE && ${OPENSSL_CONFIG} --prefix=${SRS_3RD_OPENSSL_STORE_PATH} $OPENSSL_OPTIONS && + make CC=${SRS_TOOL_CC} AR="${OPENSSL_AR}" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} ${SRS_JOBS} && make install_sw && + cp -rf ${SRS_3RD_OPENSSL_STORE_PATH} ${SRS_OBJS} ) fi # Which lib we use. @@ -621,18 +627,21 @@ if [[ $SRS_CROSS_BUILD == YES ]]; then SRTP_OPTIONS="$SRTP_OPTIONS --host=$SRS_CROSS_BUILD_HOST" fi # Patched ST from https://github.com/ossrs/state-threads/tree/srs -if [[ -f ${SRS_3RD_SRTP2_PATH}/lib/libsrtp2.a ]]; then +if [[ -f ${SRS_3RD_SRTP2_STORE_PATH}/lib/libsrtp2.a ]]; then + rm -rf ${SRS_3RD_SRTP2_PATH} && + cp -rf ${SRS_3RD_SRTP2_STORE_PATH} ${SRS_OBJS} && echo "The libsrtp-2-fit is ok."; else echo "Building libsrtp-2-fit."; ( rm -rf ${SRS_3RD_SRTP2_PATH} && - cd ${SRS_OBJS}/${SRS_PLATFORM} && + cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf libsrtp-2-fit && - cp -R ${SRS_WORKDIR}/3rdparty/libsrtp-2-fit . && - cd libsrtp-2-fit && - $SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=${SRS_3RD_SRTP2_PATH} && - make ${SRS_JOBS} && make install + cp -R ${SRS_WORKDIR}/3rdparty/libsrtp-2-fit . && + cd libsrtp-2-fit && + $SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=${SRS_3RD_SRTP2_STORE_PATH} && + make ${SRS_JOBS} && make install && + cp -rf ${SRS_3RD_SRTP2_STORE_PATH} ${SRS_OBJS} ) fi # check status @@ -648,18 +657,21 @@ if [[ $SRS_RTC == YES && $SRS_CROSS_BUILD == NO ]]; then if [[ $SRS_SHARED_FFMPEG == NO ]]; then OPUS_OPTIONS="--disable-shared --disable-doc" fi - if [[ -f ${SRS_3RD_OPUS_PATH}/lib/libopus.a ]]; then + if [[ -f ${SRS_3RD_OPUS_STORE_PATH}/lib/libopus.a ]]; then + rm -rf ${SRS_3RD_OPUS_PATH} && + cp -rf ${SRS_3RD_OPUS_STORE_PATH} ${SRS_OBJS} && echo "The opus-1.3.1 is ok."; else echo "Building opus-1.3.1."; ( rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 && - cd ${SRS_OBJS}/${SRS_PLATFORM} && + cd ${SRS_OBJS}/${SRS_PLATFORM} && tar xf ${SRS_WORKDIR}/3rdparty/opus-1.3.1.tar.gz && - cd opus-1.3.1 && - ./configure --prefix=${SRS_3RD_OPUS_PATH} --enable-static $OPUS_OPTIONS && + cd opus-1.3.1 && + ./configure --prefix=${SRS_3RD_OPUS_STORE_PATH} --enable-static $OPUS_OPTIONS && make ${SRS_JOBS} && - make install + make install && + cp -rf ${SRS_3RD_OPUS_STORE_PATH} ${SRS_OBJS} ) fi # check status @@ -674,7 +686,7 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then if [[ $SRS_CROSS_BUILD == YES ]]; then FFMPEG_CONFIGURE=./configure else - FFMPEG_CONFIGURE="env PKG_CONFIG_PATH=${SRS_3RD_OPUS_PATH}/lib/pkgconfig ./configure" + FFMPEG_CONFIGURE="env PKG_CONFIG_PATH=${SRS_3RD_OPUS_STORE_PATH}/lib/pkgconfig ./configure" fi # If disable nasm, disable all ASMs. @@ -698,17 +710,19 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=libopus --enable-encoder=libopus --enable-libopus" fi - if [[ -f ${SRS_3RD_FFMPEG_PATH}/lib/libavcodec.a ]]; then + if [[ -f ${SRS_3RD_FFMPEG_STORE_PATH}/lib/libavcodec.a ]]; then + rm -rf ${SRS_3RD_FFMPEG_PATH} && + cp -rf ${SRS_3RD_FFMPEG_STORE_PATH} ${SRS_OBJS} && echo "The ffmpeg-4-fit is ok."; else echo "Building ffmpeg-4-fit."; ( rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && - cp -rf ${SRS_WORKDIR}/3rdparty/ffmpeg-4-fit ${SRS_OBJS}/${SRS_PLATFORM} && - cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && + cp -rf ${SRS_WORKDIR}/3rdparty/ffmpeg-4-fit ${SRS_OBJS}/${SRS_PLATFORM} && + cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && # Build source code. $FFMPEG_CONFIGURE \ - --prefix=${SRS_3RD_FFMPEG_PATH} --pkg-config=pkg-config \ + --prefix=${SRS_3RD_FFMPEG_STORE_PATH} --pkg-config=pkg-config \ --pkg-config-flags="--static" --extra-libs="-lpthread" --extra-libs="-lm" \ --disable-everything ${FFMPEG_OPTIONS} \ --disable-programs --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages \ @@ -725,7 +739,8 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then sed -i -e 's/#define HAVE_GMTIME_R 0/#define HAVE_GMTIME_R 1/g' config.h && sed -i -e 's/#define HAVE_LOCALTIME_R 0/#define HAVE_LOCALTIME_R 1/g' config.h fi && - make ${SRS_JOBS} && make install + make ${SRS_JOBS} && make install && + cp -rf ${SRS_3RD_FFMPEG_STORE_PATH} ${SRS_OBJS} ) fi # check status @@ -736,15 +751,15 @@ fi # live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2. ##################################################################################### # Guess whether the ffmpeg is. -SYSTEMP_FFMPEG_BIN=/usr/local/bin/ffmpeg -if [[ ! -f $SYSTEMP_FFMPEG_BIN ]]; then SYSTEMP_FFMPEG_BIN=/usr/local/ffmpeg/bin/ffmpeg; fi +SYSTEMP_FFMPEG_BIN=`which ffmpeg` # Always link the ffmpeg tools if exists. -if [[ -f $SYSTEMP_FFMPEG_BIN && ! -f ${SRS_OBJS}/ffmpeg ]]; then +if [[ -f $SYSTEMP_FFMPEG_BIN && ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then mkdir -p ${SRS_OBJS}/ffmpeg/bin && - cp -f $SYSTEMP_FFMPEG_BIN ${SRS_OBJS}/ffmpeg/bin/ffmpeg + cp -f $SYSTEMP_FFMPEG_BIN ${SRS_OBJS}/ffmpeg/bin/ fi if [ $SRS_FFMPEG_TOOL = YES ]; then if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then + cp -f $SYSTEMP_FFMPEG_BIN ${SRS_OBJS}/ffmpeg/bin/ && echo "ffmpeg-4.1 is ok."; else echo -e "${RED}Error: No FFmpeg found at /usr/local/bin/ffmpeg${BLACK}" @@ -759,12 +774,14 @@ fi # SRT module, https://github.com/ossrs/srs/issues/1147#issuecomment-577469119 ##################################################################################### if [[ $SRS_SRT == YES ]]; then - if [[ -f ${SRS_3RD_SRT_PATH}/lib/libsrt.a ]]; then + if [[ -f ${SRS_3RD_SRT_STORE_PATH}/lib/libsrt.a ]]; then + rm -rf SRS_3RD_SRT_PATH && + cp -rf ${SRS_3RD_SRT_STORE_PATH} ${SRS_OBJS} && echo "libsrt-1-fit is ok."; else echo "Build srt-1-fit" ( - if [[ ! -d ${SRS_3RD_OPENSSL_PATH}/lib/pkgconfig ]]; then + if [[ ! -d ${SRS_3RD_OPENSSL_STORE_PATH}/lib/pkgconfig ]]; then echo "OpenSSL pkgconfig no found, build srt-1-fit failed."; exit -1; fi @@ -775,23 +792,25 @@ if [[ $SRS_SRT == YES ]]; then else LIBSRT_OPTIONS="$LIBSRT_OPTIONS --enable-shared=0" fi - - if [[ $SRS_WINDOWS == YES ]]; then - LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix" - fi - + + if [[ $SRS_WINDOWS == YES ]]; then + LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix" + fi + # Start build libsrt. rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit && - cd ${SRS_OBJS}/${SRS_PLATFORM} && + cd ${SRS_OBJS}/${SRS_PLATFORM} && cp -rf ${SRS_WORKDIR}/3rdparty/srt-1-fit ${SRS_OBJS}/${SRS_PLATFORM} && - cd srt-1-fit && - PKG_CONFIG_PATH=${SRS_3RD_OPENSSL_PATH}/lib/pkgconfig ./configure --prefix=${SRS_3RD_SRT_PATH} $LIBSRT_OPTIONS && + cd srt-1-fit && + PKG_CONFIG_PATH=${SRS_3RD_OPENSSL_PATH}/lib/pkgconfig ./configure --prefix=${SRS_3RD_SRT_STORE_PATH} $LIBSRT_OPTIONS && make ${SRS_JOBS} && make install && - - # If exists lib64 of libsrt, link it to lib - if [[ -d ${SRS_3RD_SRT_PATH}/lib64 ]]; then - mv ${SRS_3RD_SRT_PATH}/lib64 ${SRS_3RD_SRT_PATH}/lib - fi + + # If exists lib64 of libsrt, link it to lib + if [[ -d ${SRS_3RD_SRT_STORE_PATH}/lib64 ]]; then + mv ${SRS_3RD_SRT_STORE_PATH}/lib64 ${SRS_3RD_SRT_STORE_PATH}/lib + fi && + + cp -rf ${SRS_3RD_SRT_STORE_PATH} ${SRS_OBJS} ) ret=$?; if [[ $ret -ne 0 ]]; then echo "Build srt-1-fit failed, ret=$ret"; exit $ret; fi fi @@ -801,14 +820,14 @@ fi # build utest code ##################################################################################### if [ $SRS_UTEST = YES ]; then - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0/include/gtest/gtest.h ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gtest/include/gtest/gtest.h ]]; then echo "The gtest-1.6.0 is ok."; else echo "Build gtest-1.6.0"; ( - rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0 && cd ${SRS_OBJS}/${SRS_PLATFORM} && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gtest && cd ${SRS_OBJS}/${SRS_PLATFORM} && unzip -q ${SRS_WORKDIR}/3rdparty/gtest-1.6.0.zip && - mv ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0 ${SRS_OBJS}/${SRS_PLATFORM}/gtest + mv ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0 ${SRS_OBJS}/${SRS_PLATFORM}/gtest ) fi # check status diff --git a/trunk/auto/setup_variables.sh b/trunk/auto/setup_variables.sh index 422c6c7a40..1cea717f49 100755 --- a/trunk/auto/setup_variables.sh +++ b/trunk/auto/setup_variables.sh @@ -6,7 +6,7 @@ OS_KERNRL_RELEASE=$(uname -r|awk -F '-' '{print $1}') OS_PREFIX="Platform" if [[ $OSTYPE == cygwin ]]; then - OS_KERNRL_RELEASE=$(uname -r|awk -F '(' '{print $1}') + OS_KERNRL_RELEASE=$(uname -r|awk -F '(' '{print $1}') fi # Build platform cache. @@ -27,7 +27,9 @@ if [[ $SRS_CROSS_BUILD == YES ]]; then SRS_PLATFORM="${SRS_PLATFORM}-CROSSBUILD-$(echo $SRS_TOOL_CC|awk -F - '{print $1}')" fi +#TODO find the link lib in objs/Platform_some_platfomr/3rdpatry/some-lib # 3rdparty lib path +# eg: objs/st, objs/ffmpeg etc. SRS_3RD_ST_PATH=${SRS_OBJS}/st SRS_3RD_FFMPEG_PATH=${SRS_OBJS}/ffmpeg SRS_3RD_OPUS_PATH=${SRS_OBJS}/opus @@ -35,21 +37,45 @@ SRS_3RD_SRTP2_PATH=${SRS_OBJS}/srtp2 SRS_3RD_OPENSSL_PATH=${SRS_OBJS}/openssl SRS_3RD_SRT_PATH=${SRS_OBJS}/srt +# 3rdparty lib store path +# eg: objs/Platform-CYGWIN_NT-10.0-3.2.0-GCC11.2.0-SRS5-x86_64/3rdpatry/st +SRS_3RD_ST_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/st +SRS_3RD_FFMPEG_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/ffmpeg +SRS_3RD_OPUS_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/opus +SRS_3RD_SRTP2_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srtp2 +SRS_3RD_OPENSSL_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl +SRS_3RD_SRT_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt + echo "SRS_WORKDIR: ${SRS_WORKDIR}, SRS_OBJS_DIR: ${SRS_OBJS_DIR}, SRS_OBJS: ${SRS_OBJS}, SRS_PLATFORM: ${SRS_PLATFORM}" # For src object files on each platform. ( mkdir -p ${SRS_OBJS_DIR} && cd ${SRS_OBJS_DIR} && rm -rf src utest srs srs_utest research include lib srs_hls_ingester srs_mp4_parser && + # on windows, clean *.exe + rm -rf srs.exe srs_utest.exe srs_hls_ingester.exe srs_mp4_parser.exe && mkdir -p ${SRS_PLATFORM}/src && mkdir -p ${SRS_PLATFORM}/research && mkdir -p ${SRS_PLATFORM}/include && mkdir -p ${SRS_PLATFORM}/lib && - mkdir -p ${SRS_3RD_ST_PATH} && - mkdir -p ${SRS_3RD_FFMPEG_PATH} && - mkdir -p ${SRS_3RD_OPUS_PATH} && - mkdir -p ${SRS_3RD_SRTP2_PATH} && - mkdir -p ${SRS_3RD_OPENSSL_PATH} + mkdir -p ${SRS_PLATFORM}/utest && + + rm -rf st ffmpeg opus srtp2 openssl srt && + # objs/some-lib + mkdir -p ${SRS_3RD_ST_PATH} && + mkdir -p ${SRS_3RD_FFMPEG_PATH} && + mkdir -p ${SRS_3RD_OPUS_PATH} && + mkdir -p ${SRS_3RD_SRTP2_PATH} && + mkdir -p ${SRS_3RD_OPENSSL_PATH} && + mkdir -p ${SRS_3RD_SRT_STORE_PATH} && + + # objs/Platform_some_platform/3rdpatry/some-lib + mkdir -p ${SRS_3RD_ST_STORE_PATH} && + mkdir -p ${SRS_3RD_FFMPEG_STORE_PATH} && + mkdir -p ${SRS_3RD_OPUS_STORE_PATH} && + mkdir -p ${SRS_3RD_SRTP2_STORE_PATH} && + mkdir -p ${SRS_3RD_OPENSSL_STORE_PATH} && + mkdir -p ${SRS_3RD_SRT_STORE_PATH} ) if [[ $SRS_CLEAN == NO ]]; then echo "Fast cleanup, if need to do full cleanup, please use: make clean"