SRS学习笔记1

1.configure脚本分析

SRS_WORKDIR="."
SRS_OBJS_DIR="objs"
SRS_OBJS="${SRS_WORKDIR}/${SRS_OBJS_DIR}"
# 设置输出目录 ./objs
SRS_MAKEFILE="Makefile"

. auto/options.sh
# ----  options.sh   主要代码段       begin        -------
opt=

# for 语句没用关键字in 指定变量,就从命令行获取
for option
do
# opt 保存所有的选项
    opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"
    parse_user_option_to_value_and_option
    parse_user_option
done

if [ $help = yes ]; then
    show_help
    exit 0
fi

# 调用 apply_user_presets 根据是否是树莓派,cuibeboard等设置一些预定义值
apply_user_presets

# 判断是否需要编译ffmpeg,http_core,make 的 --jobs参数
apply_user_detail_options

# 产生最终的配置参数,保存在SRS_AUTO_CONFIGURE变量中
regenerate_options

# 检测是否有选项冲突
check_option_conflicts
# ----  options.sh   主要代码段     end          -------

# setup_variables.sh 文件设置ARM,MIPS平台交叉编译器信息
. auto/setup_variables.sh

# 清理以前的配置,调用 make clean清除目标后,删除Makefile
# clean the exists, when not export srs-librtmp.
# do this only when the options is ok.
if [[ -f Makefile ]]; then
make clean
fi
# remove makefile
rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE}

# 生成 objs目录
# create objs
mkdir -p ${SRS_OBJS}

# --export-librtmp-project=<path> 在 <path>产生一个工程
# --export-librtmp-single=<path> 在 <path> 产生example.c srs_librtmp.h srs_librtmp.cpp三个文件
. auto/generate-srs-librtmp-project.sh

# 检测操作系统,centos,ubuntu,osx安装必要的依赖
# 检测 libst.a, libhttp_parser.a,nginx,openssl,ffmpeg,gtest
# 若不存在则编译安装
# 若 SRS_HTTP_CALLBACK为YES,则安装 CherryPy-3.2.4 for http hooks callback
# 若 SRS_RESEARCH为YES,则编译ts_info,
# 最后安装srs.test脚本,执行 configure test and utest
. auto/depends.sh

# 生成 srs_auto_headers.hpp,生成宏定义,
# 如编译时间戳,编译日期等.
# SRS_AUTO_USER_CONFIGURE 是在编译时传递给configure脚本的参数如 --full
# SRS_AUTO_CONFIGURE 则是configure脚本最终生成的参数,例如
# "--prefix=/usr/local/srs --with-hls --with-hds --with-dvr --with-nginx 
# --with-ssl --with-ffmpeg --with-transcode --with-ingest --with-stat
# --with-http-callback --with-http-server --with-stream-caster 
# --with-http-api --with-librtmp --with-research --with-utest --without-gperf 
# --without-gmc --without-gmp --without-gcp --without-gprof
# --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace"
# SRS_AUTO_EMBEDED_TOOL_CHAIN 定义编译器的相关信息
# SRS_AUTO_FFMPEG_TOOL whether compile ffmpeg tool
# SRS_FFMPEG_STUB 
# whatever the FFMPEG tools, if transcode and ingest specified,
# srs always compile the FFMPEG tool stub which used to start the FFMPEG process.
# SRS_AUTO_PREFIX /usr/local/srs
# SRS_CONSTRIBUTORS 根据AUTHORS.txt生成
. auto/auto_headers.sh

# srs-librtmp sample entry
# SrsLibrtmpSampleEntry=ssl 或nossl
# utest make entry, (cd utest; make)
# SrsUtestMakeEntry=(cd objs/utest; $(MAKE))

# 在modules目录的子目录查找config文件
SRS_MODULES=()
__mfiles=`find modules -name "config"` && for __mfile in $__mfiles; do
    SRS_MODULES+=("`dirname $__mfile`")
done

# variables for makefile for all modules.
__mphonys="" && __mdefaults="" && __mcleanups=""
# add each modules for application
for SRS_MODULE in ${SRS_MODULES[*]}; do
    echo "install module at: $SRS_MODULE"
    . $SRS_MODULE/config # 包含config文件
    if [[ 0 -eq ${#SRS_MODULE_MAIN[@]} ]]; then continue; fi
    __mphonys="$__mphonys $SRS_MODULE_NAME"
    __mdefaults="$__mdefaults $SRS_MODULE_NAME"
    __mcleanups="$__mcleanups $SRS_MODULE_NAME"
done

#####################################################################################
# build tools or compiler args.
# enable gdb debug
GDBDebug=" -g -O0"
# the warning level.
WarnLevel=" -Wall"
# the compile standard.
CppStd="-ansi"
# for library compile
LibraryCompile=" -fPIC"
# performance of gprof
SrsGprof=""; SrsGprofLink=""; if [ $SRS_GPROF = YES ]; then SrsGprof=" -pg -lc_p"; SrsGprofLink=" -pg"; fi
# performance of gperf
SrsGperf=""; SrsGperfLink=""; if [ $SRS_GPERF = YES ]; then SrsGperfLink=" -lpthread"; fi
# the cxx flag generated.
CXXFLAGS="${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}"
if [ $SRS_GPERF = YES ]; then CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"; fi
cat << END > ${SRS_OBJS}/${SRS_MAKEFILE} # 输出变量到Makefile文件
GCC = gcc
CXX = g++
AR = ar
LINK = g++
CXXFLAGS = ${CXXFLAGS}

.PHONY: default srs srs_ingest_hls librtmp

default:

END

#####################################################################################
# Libraries, external library to build in srs,
# header(.h): add to ModuleLibIncs if need the specified library. for example, LibSTRoot
# library(.a): add to ModuleLibFiles if binary need the specifeid library. for example, LibSTfile
#
# st(state-threads) the basic network library for SRS.
LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a"
# hp(http-parser) the http request/url parser, for SRS to support HTTP callback.
LibHttpParserRoot=""; LibHttpParserfile=""
if [ $SRS_HTTP_CORE = YES ]; then LibHttpParserRoot="${SRS_OBJS_DIR}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi
# openssl-1.0.1f, for the RTMP complex handshake.
LibSSLRoot="";LibSSLfile=""
if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS_OBJS_DIR}/openssl/include"; LibSSLfile="${SRS_OBJS_DIR}/openssl/lib/libssl.a ${SRS_OBJS_DIR}/openssl/lib/libcrypto.a"; fi fi
# gperftools-2.1, for mem check and mem/cpu profile
LibGperfRoot=""; LibGperfFile=""
if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS_DIR}/gperf/include"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_and_profiler.a"; fi
# the link options, always use static link
SrsLinkOptions="-ldl"; 
if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lssl -lcrypto"; fi fi
# if static specified, add static
# TODO: FIXME: remove static.
if [ $SRS_STATIC = YES ]; then SrsLinkOptions="${SrsLinkOptions} -static"; fi
# if mips, add -lgcc_eh, or stl compile failed.
if [ $SRS_MIPS_UBUNTU12 = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lgcc_eh"; fi
# 此时 SrsLinkOptions="-ldl";没定义 SRS_USE_SYS_SSL

#####################################################################################
# 模块, 编译每一个模块, 然后链接到一个binary
#
#Core, depends only on system apis.核心模块,只依赖系统api
MODULE_ID="CORE"
MODULE_DEPENDS=()
ModuleLibIncs=(${SRS_OBJS_DIR})
MODULE_FILES=("srs_core" "srs_core_autofree" "srs_core_performance" "srs_core_mem_watch")
CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}"
# modules.sh用于输出编译信息到Makefile

#
#Kernel, depends on core, provides error/log/config, nothing about stream information.
MODULE_ID="KERNEL" 
MODULE_DEPENDS=("CORE") 
ModuleLibIncs=(${SRS_OBJS_DIR})
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream"
        "srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_file" 
        "srs_kernel_consts" "srs_kernel_aac" "srs_kernel_mp3" "srs_kernel_ts"
        "srs_kernel_buffer")
KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh
KERNEL_OBJS="${MODULE_OBJS[@]}"

#
#RTMP/HTTP/Raw Protocol, depends on core/kernel, provides rtmp/htttp protocol features.
MODULE_ID="PROTOCOL" 
MODULE_DEPENDS=("CORE" "KERNEL") 
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
MODULE_FILES=("srs_rtmp_amf0" "srs_rtmp_io" "srs_rtmp_stack"
        "srs_rtmp_handshake" "srs_rtmp_utility" "srs_rtmp_msg_array" "srs_protocol_buffer"
        "srs_raw_avc" "srs_rtsp_stack" "srs_http_stack" "srs_protocol_kbps" "srs_protocol_json")
PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh
PROTOCOL_OBJS="${MODULE_OBJS[@]}"


#
#App Module
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
    MODULE_ID="APP" 
    MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL") 
    ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${LibSSLRoot} ${SRS_OBJS_DIR})
    MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_source" 
            "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http_stream"
            "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config" 
            "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" "srs_app_http_conn" "srs_app_http_hooks" 
            "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge"
            "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_http_static"
            "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds"
            "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call"
            "srs_app_caster_flv")
    DEFINES=""
    # add each modules for app
    for SRS_MODULE in ${SRS_MODULES[*]}; do
        . $SRS_MODULE/config
        MODULE_FILES+=("${SRS_MODULE_APP[*]}")
        DEFINES="${DEFINES} ${SRS_MODULE_DEFINES}"
    done
    APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
    APP_OBJS="${MODULE_OBJS[@]}"
fi

#
#LIBS Module, build libsrs.a for static link.
MODULE_ID="LIBS" 
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL") 
ModuleLibIncs=(${SRS_OBJS_DIR})
MODULE_FILES=("srs_librtmp" "srs_lib_simple_socket" "srs_lib_bandwidth")
LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh
LIBS_OBJS="${MODULE_OBJS[@]}"

#
#Main Module
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
    MODULE_ID="MAIN" 
    MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "APP")
    ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibHttpParserRoot} ${LibSSLRoot})
    MODULE_FILES=("srs_main_server" "srs_main_ingest_hls")
    # add each modules for main
    for SRS_MODULE in ${SRS_MODULES[*]}; do
        . $SRS_MODULE/config
        MODULE_FILES+=("${SRS_MODULE_MAIN[*]}")
    done
    MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
    MAIN_OBJS="${MODULE_OBJS[@]}"
fi

#####################################################################################
# Binaries, main entrances, link the module and its depends modules,
# then link to a binary, for example, objs/srs
#
# disable all app when export librtmp
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
    # all main entrances
    MAIN_ENTRANCES=("srs_main_server" "srs_main_ingest_hls")
    # add each modules for main
    for SRS_MODULE in ${SRS_MODULES[*]}; do
        . $SRS_MODULE/config
        MAIN_ENTRANCES+=("${SRS_MODULE_MAIN[*]}")
    done
    # 
    # all depends libraries
    ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile} ${LibGperfFile})
    # all depends objects
    MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
    LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}"
    #
    # srs: srs(simple rtmp server) over st(state-threads)
    BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
    # 
    # srs_ingest_hls: to ingest hls stream to srs. 
    BUILD_KEY="srs_ingest_hls" APP_MAIN="srs_main_ingest_hls" APP_NAME="srs_ingest_hls" . auto/apps.sh
    # add each modules for application
    for SRS_MODULE in ${SRS_MODULES[*]}; do
        . $SRS_MODULE/config
        # no SRS_MODULE_MAIN 
        if [[ 0 -eq ${#SRS_MODULE_MAIN[@]} ]]; then continue; fi
        BUILD_KEY="$SRS_MODULE_NAME" APP_MAIN="$SRS_MODULE_MAIN" APP_NAME="$SRS_MODULE_NAME" . auto/apps.sh
    done
fi
# apps.sh用于生成可执行文件

# srs librtmp
if [ $SRS_LIBRTMP = YES ]; then
    MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${LIBS_OBJS[@]}"
    BUILD_KEY="librtmp" LIB_NAME="lib/srs_librtmp" . auto/libs.sh
fi
#
# utest, the unit-test cases of srs, base on gtest1.6
if [ $SRS_UTEST = YES ]; then
    MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol" 
            "srs_utest_kernel" "srs_utest_core" "srs_utest_config" 
            "srs_utest_reload")
    ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
    ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile})
    MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "APP")
    MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]}"
    LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
# 在utest目录下产生一个Makefile文件
fi

#####################################################################################
# generate colorful summary script
. auto/summary.sh

#####################################################################################
# makefile
echo "generate Makefile"

# backup old makefile.
rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk &&
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 server srs_ingest_hls librtmp utest _prepare_dir $__mphonys

# install prefix.
SRS_PREFIX=${SRS_PREFIX}
__REAL_INSTALL=\$(DESTDIR)\$(SRS_PREFIX)

END

# embeded, ubuntu12, use embeded tool chain.
if [ $SRS_CROSS_BUILD = YES ]; then
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
default:
    \$(MAKE) GCC=${SrsArmGCC} CXX=${SrsArmCXX} AR=${SrsArmAR} LINK=${SrsArmCXX} _default

END
# x86/x64, use gnu-gcc/g++ tool chain.
else
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
default:
    \$(MAKE) _default

END
fi

# the real entry for all platform:
#       the server, librtmp and utest
# where the bellow will check and disable some entry by only echo.
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
_default: server srs_ingest_hls librtmp utest $__mdefaults
    @bash objs/_srs_build_summary.sh

help:
    @echo "Usage: make <help>|<clean>|<server>|<srs_ingest_hls>|<librtmp>|<utest>|<install>|<install-api>|<uninstall>"
    @echo "     help               display this help menu"
    @echo "     clean              cleanup project"
    @echo "     server             build the srs(simple rtmp server) over st(state-threads)"
    @echo "     srs_ingest_hls     build the hls ingest tool of srs."
    @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 "@remark all modules will auto genearted and build"
    @echo "For example:"
    @echo "     make"
    @echo "     make help"

clean: 
    (cd ${SRS_OBJS_DIR} && rm -rf srs srs_utest $__mcleanups)
    (cd ${SRS_OBJS_DIR} && rm -rf src include lib)
    (cd ${SRS_OBJS_DIR}/utest && rm -rf *.o *.a)
    (cd research/librtmp && make clean)
    (cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players)

END

# if export librtmp, donot build the srs server.
if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
server: _prepare_dir
    @echo "donot build the srs(simple rtmp server) for srs-librtmp"
srs_ingest_hls: _prepare_dir
    @echo "donot build the srs_ingest_hls for srs-librtmp"

END
else
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
server: _prepare_dir
    @echo "build the srs(simple rtmp server) over st(state-threads)"
    \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} srs
srs_ingest_hls: _prepare_dir
    @echo "build the srs_ingest_hls for srs"
    \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} srs_ingest_hls

END
fi
# generate all modules entry
for SRS_MODULE in ${SRS_MODULES[*]}; do
    . $SRS_MODULE/config
    # if export librtmp, donot build the bravo-ingest.
    if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
        cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
$SRS_MODULE_NAME: _prepare_dir
    @echo "donot build the $SRS_MODULE_NAME for srs-librtmp"

END
    else
        cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
$SRS_MODULE_NAME: _prepare_dir
    @echo "build the $SRS_MODULE_NAME over SRS"
    \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} $SRS_MODULE_NAME

END
    fi
done

# disable install entry for srs-librtmp
if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
uninstall: 
    @echo "disable uninstall for srs-librtmp"

install-api: 
    @echo "disable install-api for srs-librtmp"

install: 
    @echo "disable install for srs-librtmp"

END
else
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
uninstall:
    @echo "rmdir \$(SRS_PREFIX)"
    @rm -rf \$(SRS_PREFIX)

install-api: install
    @echo "mkdir \$(__REAL_INSTALL)"
    @mkdir -p \$(__REAL_INSTALL)
    @echo "copy binary files"
    @mkdir -p \$(__REAL_INSTALL)/research/api-server
    @cp research/api-server/server.py \$(__REAL_INSTALL)/research/api-server
    @mkdir -p \$(__REAL_INSTALL)/objs/ffmpeg/bin
    @cp objs/ffmpeg/bin/ffmpeg \$(__REAL_INSTALL)/objs/ffmpeg/bin
    @echo "copy html files"
    @mkdir -p \$(__REAL_INSTALL)/research/api-server/static-dir/players
    @cp research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/research/api-server/static-dir
    @cp research/api-server/static-dir/index.html \$(__REAL_INSTALL)/research/api-server/static-dir
    @cp -r research/api-server/static-dir/players/* \$(__REAL_INSTALL)/research/api-server/static-dir/players
    @echo "copy init.d script files"
    @mkdir -p \$(__REAL_INSTALL)/etc/init.d
    @cp etc/init.d/srs-api \$(__REAL_INSTALL)/etc/init.d
    @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs-api
    @echo ""
    @echo "api installed, to link and start api:"
    @echo "     sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs-api /etc/init.d/srs-api"
    @echo "     /etc/init.d/srs-api start"
    @echo "     http://\$(shell bash auto/local_ip.sh):8085"
    @echo "@see: https://github.com/ossrs/srs/wiki/v1_CN_LinuxService"

install:
    @echo "mkdir \$(__REAL_INSTALL)"
    @mkdir -p \$(__REAL_INSTALL)
    @echo "make the http root dir"
    @mkdir -p \$(__REAL_INSTALL)/objs/nginx/html
    @cp research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/objs/nginx/html
    @echo "copy binary files"
    @mkdir -p \$(__REAL_INSTALL)/objs
    @cp objs/srs \$(__REAL_INSTALL)/objs
    @echo "copy srs conf files"
    @mkdir -p \$(__REAL_INSTALL)/conf
    @cp conf/*.conf \$(__REAL_INSTALL)/conf
    @echo "copy init.d script files"
    @mkdir -p \$(__REAL_INSTALL)/etc/init.d
    @cp etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d
    @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs
    @echo ""
    @echo "srs installed, to link and start srs:"
    @echo "     sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs"
    @echo "     /etc/init.d/srs start"
    @echo "@see: https://github.com/ossrs/srs/wiki/v1_CN_LinuxService"

END
fi

# generate srs-librtmp entry
if [ $SRS_LIBRTMP = YES ]; then
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
librtmp: server
    @echo "build the client publish/play library."
    \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} librtmp
    @echo "build the srs-librtmp sample"
    (cd research/librtmp; \$(MAKE) ${SrsLibrtmpSampleEntry})

END
else
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
librtmp: server
    @echo "srs-librtmp is disabled, ignore."

END
fi

if [ $SRS_UTEST = YES ]; then
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
utest: server
    @echo "build the utest for srs"
    ${SrsUtestMakeEntry}
    @echo "utest for srs build success"

END
else
    cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
utest: server
    @echo "utest is disabled, ignore"

END
fi

cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
# the ./configure will generate it.
_prepare_dir:
    @mkdir -p ${SRS_OBJS_DIR}
END

# generate makefile ok, append the tails.
cat ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk >> ${SRS_WORKDIR}/${SRS_MAKEFILE} &&
rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk

echo 'configure ok! '

#####################################################################################
# when configure success, prepare build
#####################################################################################
# create objs/logs for ffmpeg to write log.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
    mkdir -p ${SRS_OBJS}/logs
fi

#####################################################################################
# configure summary
#####################################################################################
# summary
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
    echo ""
    echo "configure summary:"
    echo "      ${SRS_AUTO_USER_CONFIGURE}"
    echo "      ${SRS_AUTO_CONFIGURE}"
    if [ $SRS_HLS = YES ]; then
        echo -e "${GREEN}HLS is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without HLS support${BLACK}"
    fi
    if [ $SRS_STREAM_CASTER = YES ]; then
        echo -e "${YELLOW}Experiment: StreamCaster is enabled${BLACK}"
    else
        echo -e "${GREEN}note: without StreamCaster support${BLACK}"
    fi
    if [ $SRS_HDS = YES ]; then
        echo -e "${YELLOW}Experiment: HDS is enabled${BLACK}"
    else
        echo -e "${GREEN}warning: without HDS support${BLACK}"
    fi
    if [ $SRS_NGINX = YES ]; then
        echo -e "${GREEN}Nginx http server is enabled${BLACK}"
    else
        echo -e "${GREEN}note: Nginx http server is disabled${BLACK}"
    fi
    if [ $SRS_DVR = YES ]; then
        echo -e "${GREEN}DVR is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without DVR support${BLACK}"
    fi
    if [ $SRS_SSL = YES ]; then
        echo -e "${GREEN}rtmp complex handshake is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without rtmp complex handshake support, donot support h264/aac to adobe flash player${BLACK}"
    fi
    if [ $SRS_FFMPEG_TOOL = YES ]; then
        echo -e "${GREEN}transcode/mux/ingest tool FFMPEG is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without transcode/mux/ingest tool FFMPEG support${BLACK}"
    fi
    if [ $SRS_TRANSCODE = YES ]; then
        echo -e "${GREEN}transcoding RTMP stream is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without transcoding RTMP stream support${BLACK}"
    fi
    if [ $SRS_INGEST = YES ]; then
        echo -e "${GREEN}ingest file/stream/device is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without ingest file/stream/device support${BLACK}"
    fi
    if [ $SRS_HTTP_CALLBACK = YES ]; then
        echo -e "${GREEN}http hooks callback over CherryPy is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without http hooks callback over CherryPy support${BLACK}"
    fi
    if [ $SRS_HTTP_SERVER = YES ]; then
        echo -e "${GREEN}http server to delivery http stream is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without http server to delivery http stream support${BLACK}"
    fi
    if [ $SRS_HTTP_API = YES ]; then
        echo -e "${GREEN}http api to manage server is enabled${BLACK}"
    else
        echo -e "${YELLOW}warning: without http api to manage server support${BLACK}"
    fi
    if [ $SRS_LIBRTMP = YES ]; then
        echo -e "${GREEN}srs-librtmp for client is enabled${BLACK}"
    else
        echo -e "${YELLOW}note: srs-librtmp for client is disabled${BLACK}"
    fi
    if [ $SRS_RESEARCH = YES ]; then
        echo -e "${GREEN}research tools are builded${BLACK}"
    else
        echo -e "${GREEN}note: research tools are not builded${BLACK}"
    fi
    if [ $SRS_UTEST = YES ]; then
        echo -e "${GREEN}utest for srs are builded${BLACK}"
    else
        echo -e "${YELLOW}note: utest for srs are not builded${BLACK}"
    fi
    if [ $SRS_GPERF = YES ]; then
        echo -e "${GREEN}gperf(tcmalloc) for srs are builded${BLACK}"
    else
        echo -e "${GREEN}note: gperf(tcmalloc) for srs are not builded${BLACK}"
    fi
    if [ $SRS_GPERF_MC = YES ]; then
        echo -e "${YELLOW}gmc(gperf memory check) for srs are builded -- Performance may suffer${BLACK}"
    else
        echo -e "${GREEN}note: gmc(gperf memory check) for srs are not builded${BLACK}"
    fi
    if [ $SRS_GPERF_MP = YES ]; then
        echo -e "${YELLOW}gmp(gperf memory profile) for srs are builded -- Performance may suffer${BLACK}"
    else
        echo -e "${GREEN}note: gmp(gperf memory profile) for srs are not builded${BLACK}"
    fi
    if [ $SRS_GPERF_CP = YES ]; then
        echo -e "${YELLOW}gcp(gperf cpu profile) for srs are builded -- Performance may suffer${BLACK}"
    else
        echo -e "${GREEN}note: gcp(gperf cpu profile) for srs are not builded${BLACK}"
    fi
    if [ $SRS_GPROF = YES ]; then
        echo -e "${YELLOW}gprof(GNU profile tool) for srs are builded -- Performance may suffer${BLACK}"
    else
        echo -e "${GREEN}note: gprof(GNU profile tool) for srs are not builded${BLACK}"
    fi
    if [ $SRS_ARM_UBUNTU12 = YES ]; then
        echo -e "${GREEN}arm-ubuntu12(armhf, v7cpu) for srs are builded${BLACK}"
    else
        echo -e "${GREEN}note: arm-ubuntu12(armhf, v7cpu) for srs are not builded${BLACK}"
    fi
    if [ $SRS_MIPS_UBUNTU12 = YES ]; then
        echo -e "${GREEN}mips-ubuntu12 for srs are builded${BLACK}"
    else
        echo -e "${GREEN}note: mips-ubuntu12 for srs are not builded${BLACK}"
    fi
    # add each modules for application
    for SRS_MODULE in ${SRS_MODULES[*]}; do
        echo -e "${GREEN}module: $SRS_MODULE${BLACK}"
    done
fi

#####################################################################################
# next step
#####################################################################################
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
    ip=`ifconfig|grep "inet addr"| grep -v "127.0.0.1"|awk '{print $2}'|awk -F ':' 'NR==1 {print $2}'`
    echo ""
    echo "to run 3rdparty application:"
    if [ $SRS_NGINX = YES ]; then
        echo "\" sudo ./objs/nginx/sbin/nginx  \" to start the nginx http server for hls"
    fi
    if [ $SRS_FFMPEG_TOOL = YES ]; then
        echo -e "\" ./objs/ffmpeg/bin/ffmpeg  \" is used for live stream transcoding"
    fi
    if [ $SRS_HTTP_CALLBACK = YES ]; then
        echo -e "\" python ./research/api-server/server.py 8085  \" to start the api-server"
    fi
    echo ""
    echo "to build:"
    echo "\" make \" to build the srs(simple rtmp server)."
    echo "\" make help \" to get the usage of make"
else
    # for srs-librtmp single file, 
    # package the whole project to srs_librtmp.h and srs_librtmp.cpp
    if [ $SRS_EXPORT_LIBRTMP_SINGLE != NO ]; then
        echo "package the whole project to srs_librtmp.h and srs_librtmp.cpp"
        . $SRS_EXPORT_LIBRTMP_SINGLE/auto/generate-srs-librtmp-single.sh
        echo -e "${GREEN}Please use the srs-librtmp files: ${BLACK}"
        echo -e "${GREEN}       $SRS_EXPORT_LIBRTMP_PROJECT/srs_librtmp.h ${BLACK}"
        echo -e "${GREEN}       $SRS_EXPORT_LIBRTMP_PROJECT/srs_librtmp.cpp ${BLACK}"
        echo -e "${GREEN}       $SRS_EXPORT_LIBRTMP_PROJECT/example.c ${BLACK}"
        echo -e "${GREEN}To compile the example: ${BLACK}"
        echo -e "${GREEN}       cd $SRS_EXPORT_LIBRTMP_PROJECT && $SRS_SINGLE_LIBRTMP_COMPILE ${BLACK}"
    # for srs-librtmp project.
    else
        echo -e "${GREEN}Please use the srs-librtmp project: ${BLACK}"
        echo -e "${GREEN}       cd $SRS_EXPORT_LIBRTMP_PROJECT && make ${BLACK}"
    fi
fi

 

转载于:https://www.cnblogs.com/yan-shi-yi/p/6807221.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值