diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 03befe882..f31f3696c 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -338,7 +338,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build state-threads failed, ret=$ret"; exit $ret; fi # Always update the links. - (cd ${SRS_OBJS} && rm -f st && ln -sf ${SRS_PLATFORM}/st-srs/${_ST_OBJ} st) + (cd ${SRS_OBJS} && rm -rf st && ln -sf ${SRS_PLATFORM}/st-srs/${_ST_OBJ} st) if [ ! -f ${SRS_OBJS}/st/libst.a ]; then echo "Build state-threads static lib failed."; exit -1; fi fi @@ -464,7 +464,7 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build openssl-1.1.0e failed, ret=$ret"; exit $ret; fi # Always update the links. - (cd ${SRS_OBJS} && rm -f openssl && ln -sf ${SRS_PLATFORM}/${OPENSSL_LIB} openssl) + (cd ${SRS_OBJS} && rm -rf openssl && ln -sf ${SRS_PLATFORM}/${OPENSSL_LIB} openssl) if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build openssl-1.1.0e failed."; exit -1; fi fi @@ -472,24 +472,19 @@ fi # live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2. ##################################################################################### # Always link the ffmpeg tools if exists. -if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then - mkdir -p ${SRS_OBJS}/ffmpeg/bin && ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/ffmpeg/bin/ffmpeg +if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg ]]; then + mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin && + ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg fi if [ $SRS_FFMPEG_TOOL = YES ]; then - if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg ]]; then echo "ffmpeg-4.1 is ok."; else - echo "build ffmpeg-4.1"; - ( - cd ${SRS_OBJS} && pwd_dir=`pwd` && - rm -rf ffmepg.src && mkdir -p ffmpeg.src && cd ffmpeg.src && - rm -f build_ffmpeg.sh && ln -sf ../../auto/build_ffmpeg.sh && . build_ffmpeg.sh && - cd ${pwd_dir} && rm -rf ffmpeg && ln -sf ffmpeg.src/_release ffmpeg - ) + echo "no ffmpeg found, please use srs-docker or --without-ffmpeg"; + exit -1; fi - # check status - ret=$?; if [[ $ret -ne 0 ]]; then echo "build ffmpeg-4.1 failed, ret=$ret"; exit $ret; fi - if [ ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]; then echo "build ffmpeg-4.1 failed."; exit -1; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg) fi ##################################################################################### @@ -534,7 +529,7 @@ if [ $SRS_UTEST = YES ]; then # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gtest-1.6.0 failed, ret=$ret"; exit $ret; fi # Always update the links. - (cd ${SRS_OBJS} && rm -f gtest && ln -sf ${SRS_PLATFORM}/gtest-1.6.0 gtest) + (cd ${SRS_OBJS} && rm -rf gtest && ln -sf ${SRS_PLATFORM}/gtest-1.6.0 gtest) if [ ! -f ${SRS_OBJS}/gtest/include/gtest/gtest.h ]; then echo "Build gtest-1.6.0 failed."; exit -1; fi fi @@ -557,6 +552,6 @@ if [ $SRS_GPERF = YES ]; then # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gperftools-2.1 failed, ret=$ret"; exit $ret; fi # Always update the links. - (cd ${SRS_OBJS} && rm -f pprof && ln -sf ${SRS_PLATFORM}/gperf/bin/pprof pprof) + (cd ${SRS_OBJS} && rm -rf pprof && ln -sf ${SRS_PLATFORM}/gperf/bin/pprof pprof) if [ ! -f ${SRS_OBJS}/gperf/bin/pprof ]; then echo "Build gperftools-2.1 failed."; exit -1; fi fi diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 321288bc3..b3eec6712 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -105,6 +105,8 @@ SRS_TOOL_AR=ar SRS_TOOL_LD=ld SRS_TOOL_RANDLIB=randlib SRS_EXTRA_FLAGS= +# Set the object files tag name. +SRS_BUILD_TAG= ##################################################################################### # menu @@ -171,6 +173,7 @@ Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuec --ld= Use linker tool LD, default is ld. --randlib= Use randlib tool RANDLIB, default is randlib. --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. + --build-tag= Set the build object directory suffix. Conflicts: 1. --with-gmc vs --with-gmp: @@ -254,6 +257,7 @@ function parse_user_option() { --ld) SRS_TOOL_LD=${value} ;; --randlib) SRS_TOOL_RANDLIB=${value} ;; --extra-flags) SRS_EXTRA_FLAGS=${value} ;; + --build-tag) SRS_BUILD_TAG=${value} ;; --x86-x64) SRS_X86_X64=YES ;; --x86-64) SRS_X86_X64=YES ;; @@ -538,6 +542,7 @@ SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}" if [ $SRS_LOG_TRACE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace"; fi if [ $SRS_GCOV = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcov"; fi if [[ $SRS_EXTRA_FLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_FLAGS\\\""; fi + if [[ $SRS_BUILD_TAG != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --build-tag=\\\"$SRS_BUILD_TAG\\\""; fi if [[ $SRS_TOOL_CC != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cc=$SRS_TOOL_CC"; fi if [[ $SRS_TOOL_CXX != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx=$SRS_TOOL_CXX"; fi if [[ $SRS_TOOL_AR != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ar=$SRS_TOOL_AR"; fi diff --git a/trunk/auto/setup_variables.sh b/trunk/auto/setup_variables.sh index 9d37edbf7..3865f005f 100755 --- a/trunk/auto/setup_variables.sh +++ b/trunk/auto/setup_variables.sh @@ -1,3 +1,24 @@ #!/bin/bash # when options parsed, setup some variables, then build the depends. +OS_KERNEL_NAME=$(uname -s) +OS_KERNRL_RELEASE=$(uname -r|awk -F '-' '{print $1}') +OS_PREFIX="Platform" +SRS_PLATFORM="${OS_PREFIX}-${OS_KERNEL_NAME}-${OS_KERNRL_RELEASE}" +if [[ ${SRS_BUILD_TAG} != "" ]]; then + SRS_PLATFORM="${SRS_PLATFORM}-${SRS_BUILD_TAG}" +fi +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. +( + cd ${SRS_OBJS_DIR} && + rm -rf src utest srs research include lib srs_hls_ingester srs_mp4_parser && + mkdir -p ${SRS_PLATFORM}/src && ln -sf ${SRS_PLATFORM}/src && + mkdir -p ${SRS_PLATFORM}/utest && ln -sf ${SRS_PLATFORM}/utest && + mkdir -p ${SRS_PLATFORM}/research && ln -sf ${SRS_PLATFORM}/research && + mkdir -p ${SRS_PLATFORM}/include && ln -sf ${SRS_PLATFORM}/include && + mkdir -p ${SRS_PLATFORM}/lib && ln -sf ${SRS_PLATFORM}/lib +) +echo "Fast cleanup, if need to do full cleanup, please use: make clean" + diff --git a/trunk/auto/utest.sh b/trunk/auto/utest.sh index 1255e35a7..7dcde25af 100755 --- a/trunk/auto/utest.sh +++ b/trunk/auto/utest.sh @@ -16,7 +16,7 @@ mkdir -p ${SRS_OBJS}/utest # the prefix to generate the objs/utest/Makefile # dirs relative to current dir(objs/utest), it's trunk/objs/utest # trunk of srs, which contains the src dir, relative to objs/utest, it's trunk -SRS_TRUNK_PREFIX=../.. +SRS_TRUNK_PREFIX=../../.. # gest dir, relative to objs/utest, it's trunk/objs/gtest GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/gtest diff --git a/trunk/configure b/trunk/configure index 810f586cc..7f9baecde 100755 --- a/trunk/configure +++ b/trunk/configure @@ -8,8 +8,6 @@ SRS_WORKDIR="." SRS_OBJS_DIR="objs" SRS_OBJS="${SRS_WORKDIR}/${SRS_OBJS_DIR}" SRS_MAKEFILE="Makefile" -SRS_PLATFORM=`uname -s`-`uname -r|awk -F '-' '{print $1}'` -echo "SRS_WORKDIR: ${SRS_WORKDIR}, SRS_OBJS_DIR: ${SRS_OBJS_DIR}, SRS_OBJS: ${SRS_OBJS}, SRS_PLATFORM: ${SRS_PLATFORM}" # linux shell color support. RED="\\033[31m" @@ -43,11 +41,6 @@ mkdir -p ${SRS_OBJS}/${SRS_PLATFORM} # the auto generated variables. . auto/auto_headers.sh -# For src object files on each platform. -echo "Fast cleanup, if need to do full cleanup, please use: make clean" -(cd ${SRS_OBJS_DIR} && rm -rf src srs srs_hls_ingester srs_mp4_parser && -mkdir -p ${SRS_PLATFORM}/src && ln -sf ${SRS_PLATFORM}/src) - ##################################################################################### # generate Makefile. ##################################################################################### @@ -348,7 +341,9 @@ mv ${SRS_WORKDIR}/${SRS_MAKEFILE} ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk # generate phony header cat << END > ${SRS_WORKDIR}/${SRS_MAKEFILE} -.PHONY: default _default install install-api help clean doclean destroy server srs_ingest_hls librtmp utest _prepare_dir $__mphonys +.PHONY: default _default install install-api help clean destroy server srs_ingest_hls librtmp utest _prepare_dir $__mphonys +.PHONY: clean_srs clean_modules clean_st clean_openssl clean_ffmpeg clean_nginx clean_cherrypy +.PHONY: st # install prefix. SRS_PREFIX=${SRS_PREFIX} @@ -369,14 +364,18 @@ _default: server srs_ingest_hls librtmp utest __modules $__mdefaults help: @echo "Usage: make ||||||||" @echo " help display this help menu" - @echo " clean cleanup project" - @echo " destroy Deep cleanup project and depends" + @echo " clean cleanup project and all depends" + @echo " destroy Cleanup all files for this platform in ${SRS_OBJS_DIR}/${SRS_PLATFORM}" @echo " server build the srs(simple rtmp server) over st(state-threads)" @echo " librtmp build the client publish/play library, and samples" @echo " utest build the utest for srs" @echo " install install srs to the prefix path" @echo " install-api install srs and api-server to the prefix path" @echo " uninstall uninstall srs from prefix path" + @echo "To clean special module:" + @echo " clean_st Clean depend st-srs in ${SRS_OBJS_DIR}/${SRS_PLATFORM}/st-srs" + @echo " clean_openssl Clean depend openssl in objs" + @echo " clean_ffmpeg Clean depend ffmpeg in objs" @echo "@remark all modules will auto genearted and build" @echo "For example:" @echo " make" @@ -389,13 +388,34 @@ doclean: (cd research/librtmp && make clean) (cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players) -clean: doclean - @echo "You can do full clean by: make destroy" +clean: clean_srs clean_modules clean_st clean_openssl clean_ffmpeg clean_nginx clean_cherrypy + @echo "You can clean each some components, see make help" destroy: clean - (cd 3rdparty/st-srs && rm -rf Linux_* Darwin_* obj) - (cd 3rdparty/ffmpeg-4.2-fit && rm -rf Linux-* Darwin-*) - (cd ${SRS_OBJS_DIR} && rm -rf Linux-* Darwin-*) + (cd ${SRS_OBJS_DIR} && rm -rf ${SRS_PLATFORM}) + +clean_srs: + (cd ${SRS_OBJS_DIR} && rm -rf srs srs_utest) + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf include lib utest) + +clean_modules: + (cd ${SRS_OBJS_DIR} && rm -rf $__mdefaults) + +clean_st: + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM}/st-srs && make clean) + +clean_openssl: + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf openssl*) + +clean_ffmpeg: + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf ffmpeg) + +clean_nginx: + (cd ${SRS_OBJS_DIR} && rm -rf nginx) + +clean_cherrypy: + (cd research/librtmp && make clean) + (cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players) END diff --git a/trunk/scripts/package.sh b/trunk/scripts/package.sh index ac4928422..6a4fc3bc2 100755 --- a/trunk/scripts/package.sh +++ b/trunk/scripts/package.sh @@ -120,22 +120,22 @@ ok_msg "start build srs, ARM: $ARM, MIPS: $MIPS, PI: $PI, X86_64: $X86_X64, JOBS if [ $ARM = YES ]; then ( cd $work_dir && - ./configure --arm --jobs=$JOBS --prefix=$INSTALL && make + ./configure --arm --jobs=$JOBS --prefix=$INSTALL --build-tag=${os_machine} && make ) >> $log 2>&1 elif [ $MIPS = YES ]; then ( cd $work_dir && - ./configure --mips --jobs=$JOBS --prefix=$INSTALL && make + ./configure --mips --jobs=$JOBS --prefix=$INSTALL --build-tag=${os_machine} && make ) >> $log 2>&1 elif [ $PI = YES ]; then ( cd $work_dir && - ./configure --pi --jobs=$JOBS --prefix=$INSTALL && make + ./configure --pi --jobs=$JOBS --prefix=$INSTALL --build-tag=${os_machine} && make ) >> $log 2>&1 elif [ $X86_X64 = YES ]; then ( cd $work_dir && - ./configure --x86-x64 --jobs=$JOBS --prefix=$INSTALL && make + ./configure --x86-x64 --jobs=$JOBS --prefix=$INSTALL --build-tag=${os_machine} && make ) >> $log 2>&1 else failed_msg "invalid option, must be --x86-x64/--arm/--mips/--pi, see --help"; exit 1;