1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 03:41:55 +00:00
srs/trunk/configure

807 lines
28 KiB
Text
Raw Normal View History

2013-10-17 12:58:04 +00:00
#!/bin/bash
2014-02-28 05:17:31 +00:00
#####################################################################################
# the main output dir, all configure and make output are in this dir.
#####################################################################################
# create the main objs
SRS_WORKDIR="."
SRS_OBJS_DIR="objs"
SRS_OBJS="${SRS_WORKDIR}/${SRS_OBJS_DIR}"
SRS_MAKEFILE="Makefile"
2013-10-17 12:58:04 +00:00
# linux shell color support.
RED="\\033[31m"
GREEN="\\033[32m"
YELLOW="\\033[33m"
BLACK="\\033[0m"
#####################################################################################
# parse user options, set the variables like:
# srs features: SRS_SSL/SRS_HLS/SRS_HTTP_CALLBACK/......
# build options: SRS_JOBS
#####################################################################################
# parse options, exit with error when parse options invalid.
. auto/options.sh
2015-09-23 03:54:53 +00:00
# setup variables when options parsed.
. auto/setup_variables.sh
# We don't need to cleanup the exists files.
2015-03-10 05:13:31 +00:00
rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE}
# create objs
mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}
2013-11-27 14:41:58 +00:00
# apply user options.
. auto/depends.sh
# the auto generated variables.
. auto/auto_headers.sh
2014-03-19 03:24:25 +00:00
2013-10-17 12:58:04 +00:00
#####################################################################################
# generate Makefile.
#####################################################################################
2014-03-15 11:44:06 +00:00
# ubuntu echo in Makefile cannot display color, use bash instead
SRS_BUILD_SUMMARY="_srs_build_summary.sh"
2013-10-17 12:58:04 +00:00
2014-03-03 10:28:50 +00:00
# utest make entry, (cd utest; make)
SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\""
2020-03-29 08:18:20 +00:00
if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM}/utest && \$(MAKE))"; fi
2014-03-03 10:28:50 +00:00
2015-03-07 08:39:05 +00:00
#####################################################################################
# finger out modules to install.
# where srs module is a dir which contains a config file.
SRS_MODULES=()
2015-03-07 08:39:05 +00:00
__mfiles=`find modules -name "config"` && for __mfile in $__mfiles; do
2015-03-31 10:06:55 +00:00
SRS_MODULES+=("`dirname $__mfile`")
2015-03-07 08:39:05 +00:00
done
# variables for makefile for all modules.
2016-01-04 09:28:18 +00:00
__mphonys="" && __mdefaults="" && __mcleanups="" && __makefiles=""
2015-03-07 08:39:05 +00:00
# add each modules for application
2015-03-31 10:06:55 +00:00
for SRS_MODULE in ${SRS_MODULES[*]}; do
2015-03-07 08:39:05 +00:00
echo "install module at: $SRS_MODULE"
. $SRS_MODULE/config
2016-01-04 09:28:18 +00:00
if [[ $SRS_MODULE_MAKEFILE != "" ]]; then
__makefiles="$__makefiles $SRS_MODULE_MAKEFILE"
fi
if [[ 0 -ne ${#SRS_MODULE_MAIN[@]} ]]; then
__mphonys="$__mphonys $SRS_MODULE_NAME"
__mdefaults="$__mdefaults $SRS_MODULE_NAME"
__mcleanups="$__mcleanups $SRS_MODULE_NAME"
fi
2015-03-07 08:39:05 +00:00
done
# generate extra phony for each modules.
cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}
.PHONY: $__mphonys
END
#####################################################################################
# build tools or compiler args.
# enable gdb debug
GDBDebug=" -g -O0"
# the warning level.
WarnLevel=" -Wall -Wno-deprecated-declarations"
# the compile standard.
CppStd="-ansi"
2020-06-03 11:18:41 +00:00
if [[ $SRS_CXX11 == YES ]]; then
CppStd="-std=c++11"
fi
2020-06-11 09:12:37 +00:00
if [[ $SRS_CXX14 == YES ]]; then
CppStd="-std=c++14"
fi
# 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="${CXXFLAGS} ${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}"
2018-12-22 12:08:42 +00:00
if [ $SRS_GPERF = YES ]; then
CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free";
fi
2019-02-02 13:42:03 +00:00
# For coverage.
if [[ $SRS_GCOV == YES ]]; then
2019-02-03 01:27:08 +00:00
SrsGcov="-fprofile-arcs -ftest-coverage"
fi
if [[ $SRS_GCOV == YES ]]; then
CXXFLAGS="${CXXFLAGS} ${SrsGcov}";
2019-02-02 13:42:03 +00:00
fi
# User configed options.
if [[ $SRS_EXTRA_FLAGS != '' ]]; then
CXXFLAGS="${CXXFLAGS} $SRS_EXTRA_FLAGS";
fi
2017-03-01 01:21:20 +00:00
# Start to generate the Makefile.
cat << END >> ${SRS_OBJS}/${SRS_MAKEFILE}
GCC = ${SRS_TOOL_CC}
CXX = ${SRS_TOOL_CXX}
AR = ${SRS_TOOL_AR}
2017-03-01 01:21:20 +00:00
ARFLAGS = -rs
LINK = ${SRS_TOOL_CXX}
CXXFLAGS = ${CXXFLAGS}
2020-05-29 09:00:06 +00:00
.PHONY: default srs srs_ingest_hls
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"
if [[ $SRS_SHARED_ST == YES ]]; then LibSTfile="-lst"; fi
2020-03-06 15:01:48 +00:00
# srtp
if [[ $SRS_RTC == YES ]]; then
LibSrtpRoot="${SRS_OBJS_DIR}/srtp2/include"; LibSrtpFile="${SRS_OBJS_DIR}/srtp2/lib/libsrtp2.a"
fi
# FFMPEG for WebRTC transcoding, such as aac to opus.
if [[ $SRS_FFMPEG_FIT == YES ]]; then
LibFfmpegRoot="${SRS_OBJS_DIR}/ffmpeg/include"; LibFfmpegFile="${SRS_OBJS_DIR}/ffmpeg/lib/libavcodec.a ${SRS_OBJS_DIR}/ffmpeg/lib/libswresample.a ${SRS_OBJS_DIR}/ffmpeg/lib/libavutil.a"
LibFfmpegRoot="${LibFfmpegRoot} ${SRS_OBJS_DIR}/opus/include"; LibFfmpegFile="${LibFfmpegFile} ${SRS_OBJS_DIR}/opus/lib/libopus.a"
fi
# openssl-1.1.0e, for the RTMP complex handshake.
LibSSLRoot="";LibSSLfile=""
2018-12-22 12:23:39 +00:00
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == NO ]]; then
2018-12-22 12:08:42 +00:00
LibSSLRoot="${SRS_OBJS_DIR}/openssl/include"; LibSSLfile="${SRS_OBJS_DIR}/openssl/lib/libssl.a ${SRS_OBJS_DIR}/openssl/lib/libcrypto.a";
fi
# gperftools-2.1, for mem check and mem/cpu profile
LibGperfRoot=""; LibGperfFile=""
2018-12-22 12:08:42 +00:00
if [ $SRS_GPERF = YES ]; then
LibGperfRoot="${SRS_OBJS_DIR}/gperf/include"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_and_profiler.a";
fi
if [ $SRS_GPERF_MD = YES ]; then
LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a";
fi
# srt code path
if [[ $SRS_SRT == YES ]]; then
LibSRTRoot="${SRS_WORKDIR}/src/srt"; LibSRTfile="${SRS_OBJS_DIR}/srt/lib/libsrt.a"
if [[ $SRS_SHARED_SRT == YES ]]; then LibSRTfile="-lsrt"; fi
fi
# For iconv on macOS only, CentOS seems ok.
if [[ $SRS_GB28181 == YES && $SRS_OSX == YES ]]; then
LibIconvRoot="/usr/local/opt/libiconv/include"; LibIconvfile="/usr/local/opt/libiconv/lib/libiconv.a"
fi
# the link options, always use static link
2021-02-15 11:47:02 +00:00
SrsLinkOptions="-ldl -lpthread";
2018-12-22 12:23:39 +00:00
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then
2018-12-22 12:08:42 +00:00
SrsLinkOptions="${SrsLinkOptions} -lssl -lcrypto";
fi
# Static link the c++ libraries, for user who build SRS by a new version of gcc,
# so we need to link the c++ libraries staticly but not all.
# @see https://stackoverflow.com/a/26107550
2018-12-22 12:08:42 +00:00
if [ $SRS_STATIC = YES ]; then
SrsLinkOptions="${SrsLinkOptions} -static-libstdc++";
2018-12-22 12:08:42 +00:00
fi
2019-02-02 13:42:03 +00:00
# For coverage.
if [[ $SRS_GCOV == YES ]]; then
2019-02-03 01:27:08 +00:00
SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}";
2019-02-02 13:42:03 +00:00
fi
2021-03-04 02:41:23 +00:00
# For FFMPEG/RTC on Linux.
if [[ $SRS_OSX != YES && $SRS_RTC == YES && $SRS_FFMPEG_FIT == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -lrt";
fi
#####################################################################################
# Modules, compile each module, then link to binary
#
#Core, depends only on system apis.
MODULE_ID="CORE"
MODULE_DEPENDS=()
ModuleLibIncs=(${SRS_OBJS_DIR})
2020-02-04 09:06:10 +00:00
MODULE_FILES=("srs_core" "srs_core_version4" "srs_core_autofree" "srs_core_performance"
2021-02-15 11:33:40 +00:00
"srs_core_time")
CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}"
#
#Kernel, depends on core, provides error/log/config, nothing about stream information.
MODULE_ID="KERNEL"
MODULE_DEPENDS=("CORE")
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
2015-09-22 00:48:55 +00:00
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_buffer"
"srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_io"
"srs_kernel_consts" "srs_kernel_aac" "srs_kernel_mp3" "srs_kernel_ts"
2021-02-25 05:46:52 +00:00
"srs_kernel_stream" "srs_kernel_balance" "srs_kernel_mp4" "srs_kernel_file"
"srs_kernel_kbps")
if [[ $SRS_RTC == YES ]]; then
2020-05-15 03:50:59 +00:00
MODULE_FILES+=("srs_kernel_rtc_rtp" "srs_kernel_rtc_rtcp")
fi
KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh
KERNEL_OBJS="${MODULE_OBJS[@]}"
#
2015-05-24 10:56:52 +00:00
#RTMP/HTTP/Raw Protocol, depends on core/kernel, provides rtmp/htttp protocol features.
2015-05-23 01:59:24 +00:00
MODULE_ID="PROTOCOL"
MODULE_DEPENDS=("CORE" "KERNEL")
2020-06-02 08:43:07 +00:00
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
2015-09-22 01:07:07 +00:00
MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_rtmp_stack"
"srs_rtmp_handshake" "srs_protocol_utility" "srs_rtmp_msg_array" "srs_protocol_stream"
2020-11-15 15:47:00 +00:00
"srs_raw_avc" "srs_rtsp_stack" "srs_http_stack" "srs_protocol_kbps" "srs_protocol_json"
2020-06-02 07:02:59 +00:00
"srs_protocol_format" "srs_service_log" "srs_service_st" "srs_service_http_client" "srs_service_http_conn"
"srs_service_rtmp_conn" "srs_service_utility" "srs_service_conn")
if [[ $SRS_RTC == YES ]]; then
2020-05-11 04:07:55 +00:00
MODULE_FILES+=("srs_rtc_stun_stack")
ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi
2015-05-24 10:56:52 +00:00
PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh
PROTOCOL_OBJS="${MODULE_OBJS[@]}"
#
2020-01-11 15:05:10 +00:00
#srt protocol features.
2020-01-22 02:59:50 +00:00
if [ $SRS_SRT = YES ]; then
MODULE_ID="SRT"
2020-06-02 07:02:59 +00:00
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "APP")
ModuleLibIncs=(${SRS_OBJS_DIR})
MODULE_FILES=("srt_server" "srt_handle" "srt_conn" "srt_to_rtmp" "ts_demux" "srt_data")
SRT_INCS=${LibSRTRoot}; MODULE_DIR=${LibSRTRoot} . auto/modules.sh
SRT_OBJS="${MODULE_OBJS[@]}"
2020-01-22 02:59:50 +00:00
fi
2017-03-26 02:16:21 +00:00
#
#App Module, for SRS server only.
2020-05-27 06:20:40 +00:00
MODULE_ID="APP"
2020-06-02 07:02:59 +00:00
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL")
2020-06-02 08:43:07 +00:00
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
if [ $SRS_GPERF = YES ]; then
ModuleLibIncs+=(${LibGperfRoot})
fi
2020-05-27 06:20:40 +00:00
if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
2020-05-27 06:20:40 +00:00
fi
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_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
2020-05-27 06:20:40 +00:00
"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_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" "srs_app_process" "srs_app_ng_exec"
"srs_app_hourglass" "srs_app_dash" "srs_app_fragment" "srs_app_dvr"
"srs_app_coworkers" "srs_app_hybrid")
if [[ $SRS_RTC == YES ]]; then
MODULE_FILES+=("srs_app_rtc_conn" "srs_app_rtc_dtls" "srs_app_rtc_sdp"
2020-05-27 06:20:40 +00:00
"srs_app_rtc_queue" "srs_app_rtc_server" "srs_app_rtc_source" "srs_app_rtc_api")
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
MODULE_FILES+=("srs_app_rtc_codec")
fi
2020-05-27 06:20:40 +00:00
if [[ $SRS_GB28181 == YES ]]; then
MODULE_FILES+=("srs_app_gb28181" "srs_app_gb28181_sip")
fi
if [[ $SRS_GB28181 == YES || $SRS_RTC == YES ]]; then
MODULE_FILES+=("srs_app_rtc_jitbuffer")
fi
if [[ $SRS_GB28181 == YES ]]; then
MODULE_FILES+=("srs_app_sip")
ModuleLibIncs+=(${LibIconvRoot})
2020-05-27 06:20:40 +00:00
fi
2020-05-27 06:20:40 +00:00
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[@]}"
#
#Server Module, for SRS only.
2020-05-27 06:20:40 +00:00
MODULE_ID="SERVER"
2020-06-02 07:02:59 +00:00
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "APP")
2020-05-27 06:20:40 +00:00
if [[ $SRS_SRT == YES ]]; then
MODULE_DEPENDS+=("SRT")
fi
2020-06-02 08:43:07 +00:00
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot})
2020-05-27 06:20:40 +00:00
if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
2020-05-27 06:20:40 +00:00
fi
if [[ $SRS_SRT == YES ]]; then
ModuleLibIncs+=("${LibSRTRoot[*]}")
2017-03-26 05:40:39 +00:00
fi
2020-05-27 06:20:40 +00:00
MODULE_FILES=("srs_main_server")
SERVER_INCS="src/main"; MODULE_DIR=${SERVER_INCS} . auto/modules.sh
SERVER_OBJS="${MODULE_OBJS[@]}"
2017-03-26 05:40:39 +00:00
#
#Main Module, for app from modules.
2020-05-27 06:20:40 +00:00
MODULE_ID="MAIN"
2020-06-02 07:02:59 +00:00
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL")
2020-06-02 08:43:07 +00:00
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot})
2020-05-27 06:20:40 +00:00
if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi
2020-05-27 06:20:40 +00:00
MODULE_FILES=()
DEFINES=""
# add each modules for main
for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config
MODULE_FILES+=("${SRS_MODULE_MAIN[*]}")
DEFINES="${DEFINES} ${SRS_MODULE_DEFINES}"
done
MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@]}"
#####################################################################################
# Binaries, main entrances, link the module and its depends modules,
# then link to a binary, for example, objs/srs
#
2020-05-27 06:20:40 +00:00
# all main entrances
MAIN_ENTRANCES=("srs_main_server")
for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config
MAIN_ENTRANCES+=("${SRS_MODULE_MAIN[*]}")
done
#
# all depends libraries
ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile})
if [[ $SRS_RTC == YES ]]; then
ModuleLibFiles+=(${LibSrtpFile})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}")
2020-05-27 06:20:40 +00:00
fi
if [[ $SRS_SRT == YES ]]; then
ModuleLibFiles+=("${LibSRTfile[*]}")
fi
if [[ $SRS_GB28181 == YES ]]; then
ModuleLibFiles+=("${LibIconvfile[*]}")
fi
2020-05-27 06:20:40 +00:00
# all depends objects
2020-06-02 07:02:59 +00:00
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}"
2020-06-02 08:43:07 +00:00
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot})
2020-05-27 06:20:40 +00:00
if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
2020-05-27 06:20:40 +00:00
fi
if [[ $SRS_SRT == YES ]]; then
MODULE_OBJS="${MODULE_OBJS} ${SRT_OBJS[@]}"
fi
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
#
# For modules, without the app module.
2020-06-02 07:02:59 +00:00
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${MAIN_OBJS[@]}"
2020-05-27 06:20:40 +00:00
ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile})
if [[ $SRS_RTC == YES ]]; then
ModuleLibFiles+=(${LibSrtpFile})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}")
2020-05-27 06:20:40 +00:00
fi
#
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[0]}" APP_NAME="$SRS_MODULE_NAME" . auto/apps.sh
done
2020-03-29 09:29:09 +00:00
# For utest on mac.
# @see https://github.com/protocolbuffers/protobuf/issues/51#issuecomment-111044468
if [[ $SRS_OSX == YES ]]; then
2020-03-29 10:01:46 +00:00
UTEST_EXTRA_DEFINES="-DGTEST_USE_OWN_TR1_TUPLE=1"
2020-03-29 09:29:09 +00:00
fi
#
# utest, the unit-test cases of srs, base on gtest1.6
if [ $SRS_UTEST = YES ]; then
2019-10-23 01:26:10 +00:00
MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol" "srs_utest_kernel" "srs_utest_core"
"srs_utest_config" "srs_utest_rtmp" "srs_utest_http" "srs_utest_avc" "srs_utest_reload"
"srs_utest_mp4" "srs_utest_service" "srs_utest_app" "srs_utest_rtc")
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi
if [[ $SRS_SRT == YES ]]; then
ModuleLibIncs+=("${LibSRTRoot[*]}")
fi
ModuleLibFiles=(${LibSTfile} ${LibSSLfile})
if [[ $SRS_RTC == YES ]]; then
ModuleLibFiles+=(${LibSrtpFile})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}")
fi
if [[ $SRS_SRT == YES ]]; then
ModuleLibFiles+=("${LibSRTfile[*]}")
fi
2020-06-02 07:02:59 +00:00
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "APP")
if [[ $SRS_SRT == YES ]]; then
MODULE_DEPENDS+=("SRT")
fi
2020-06-02 07:02:59 +00:00
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]} ${SRT_OBJS[@]}"
LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
fi
#####################################################################################
# generate colorful summary script
. auto/summary.sh
#####################################################################################
# makefile
2016-12-07 04:09:39 +00:00
echo "Generate Makefile"
2015-03-07 08:39:05 +00:00
# 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}
2021-04-24 11:07:37 +00:00
.PHONY: default _default install help clean destroy server srs_ingest_hls utest _prepare_dir $__mphonys
2020-04-10 00:55:04 +00:00
.PHONY: clean_srs clean_modules clean_openssl clean_nginx clean_cherrypy clean_srtp2 clean_opus clean_ffmpeg clean_st
2020-03-29 13:30:32 +00:00
.PHONY: st ffmpeg
# install prefix.
SRS_PREFIX=${SRS_PREFIX}
__REAL_INSTALL=\$(DESTDIR)\$(SRS_PREFIX)
2014-03-02 01:00:49 +00:00
default:
\$(MAKE) _default
2014-03-02 01:00:49 +00:00
END
# the real entry for all platform:
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
2020-05-29 09:00:06 +00:00
_default: server srs_ingest_hls utest __modules $__mdefaults
@bash objs/_srs_build_summary.sh
2013-10-17 12:58:04 +00:00
help:
2021-04-24 11:07:37 +00:00
@echo "Usage: make <help>|<clean>|<destroy>|<server>|<utest>|<install>|<uninstall>"
2020-03-29 13:36:41 +00:00
@echo " help Display this help menu"
@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 and other modules in main"
@echo " utest Build the utest for srs"
@echo " install Install srs to the prefix path"
@echo " uninstall Uninstall srs from prefix path"
2020-03-29 13:30:32 +00:00
@echo "To rebuild special module:"
2020-03-29 13:36:41 +00:00
@echo " st Rebuild st-srs in ${SRS_OBJS_DIR}/${SRS_PLATFORM}/st-srs"
@echo " ffmpeg Rebuild ffmpeg in ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4.2-fit"
2020-04-04 12:24:24 +00:00
@echo "To reconfigure special depends:"
@echo " clean_openssl Remove the openssl cache."
@echo " clean_srtp2 Remove the libsrtp2 cache."
@echo " clean_opus Remove the opus cache."
2020-04-10 00:55:04 +00:00
@echo " clean_ffmpeg Remove the FFmpeg cache."
@echo " clean_st Remove the ST cache."
2015-03-07 08:39:05 +00:00
@echo "For example:"
@echo " make"
@echo " make help"
2013-10-17 12:58:04 +00:00
doclean:
(cd ${SRS_OBJS_DIR} && rm -rf srs srs_utest $__mcleanups)
(cd ${SRS_OBJS_DIR} && rm -rf src/* include lib)
(mkdir -p ${SRS_OBJS_DIR}/utest && cd ${SRS_OBJS_DIR}/utest && rm -rf *.o *.a)
(cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players)
2013-10-17 12:58:04 +00:00
2020-03-29 08:51:56 +00:00
clean: clean_srs clean_modules
2020-03-29 13:30:32 +00:00
destroy:
2020-03-29 07:23:40 +00:00
(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/*)
@(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && find src -name "*.o" -delete)
@(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && find utest -name "*.o" -delete)
2020-03-29 07:23:40 +00:00
clean_modules:
@(cd ${SRS_OBJS_DIR} && rm -rf $__mdefaults)
2020-03-29 07:23:40 +00:00
clean_openssl:
(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf openssl*)
2020-04-04 12:24:24 +00:00
@echo "Please rebuild openssl by: ./configure"
2020-03-29 07:23:40 +00:00
2020-03-29 09:54:27 +00:00
clean_srtp2:
(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf libsrtp-2.0.0)
2020-04-04 12:24:24 +00:00
@echo "Please rebuild libsrtp2 by: ./configure"
2020-03-29 09:54:27 +00:00
clean_opus:
(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf opus-1.3.1)
2020-04-04 12:24:24 +00:00
@echo "Please rebuild opus by: ./configure"
2020-03-29 09:54:27 +00:00
2020-04-10 00:55:04 +00:00
clean_ffmpeg:
(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf ffmpeg-4.2-fit)
@echo "Please rebuild FFmpeg by: ./configure"
clean_st:
(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf st-srs)
@echo "Please rebuild ST by: ./configure"
2020-03-29 07:23:40 +00:00
clean_nginx:
(cd ${SRS_OBJS_DIR} && rm -rf nginx)
clean_cherrypy:
(cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players)
2020-03-29 13:30:32 +00:00
st:
(cd ${SRS_OBJS_DIR} && rm -f srs srs_utest)
(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM}/st-srs && \$(MAKE) clean && \$(MAKE) ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}")
2020-04-04 12:24:24 +00:00
@echo "Please rebuild srs by: rm -f objs/srs && make"
2020-03-29 13:30:32 +00:00
ffmpeg:
(cd ${SRS_OBJS_DIR} && rm -f srs srs_utest)
(cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4.2-fit && \$(MAKE) && \$(MAKE) install-libs)
2020-04-04 12:24:24 +00:00
@echo "Please rebuild srs by: rm -f objs/srs && make"
2020-03-29 13:30:32 +00:00
END
2016-01-04 09:28:18 +00:00
# for Makefile of all modules.
# depends on server, for some modules maybe use srs files.
echo "__modules: server" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
for MMF in ${__makefiles[*]}; do
echo " \$(MAKE) -f $MMF" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
done
echo "" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
2020-05-27 06:20:40 +00:00
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
2013-10-17 12:58:04 +00:00
server: _prepare_dir
@echo "Build the SRS server"
\$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} srs
2013-10-17 12:58:04 +00:00
END
2015-03-07 08:39:05 +00:00
# generate all modules entry
2015-03-31 10:06:55 +00:00
for SRS_MODULE in ${SRS_MODULES[*]}; do
2015-03-07 08:39:05 +00:00
. $SRS_MODULE/config
2020-05-27 06:20:40 +00:00
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
2019-12-20 03:49:27 +00:00
$SRS_MODULE_NAME: _prepare_dir server
2016-12-07 04:09:39 +00:00
@echo "Build the $SRS_MODULE_NAME over SRS"
2015-03-07 08:39:05 +00:00
\$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} $SRS_MODULE_NAME
END
done
2020-05-29 09:00:06 +00:00
# install entry
2020-05-27 06:20:40 +00:00
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
uninstall:
@echo "rmdir \$(SRS_PREFIX)"
@rm -rf \$(SRS_PREFIX)
install:
2016-12-07 04:09:39 +00:00
@echo "Now mkdir \$(__REAL_INSTALL)"
@mkdir -p \$(__REAL_INSTALL)
2016-12-07 04:09:39 +00:00
@echo "Now make the http root dir"
@mkdir -p \$(__REAL_INSTALL)/objs/nginx/html
@cp -f research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/objs/nginx/html
2016-12-07 04:09:39 +00:00
@echo "Now copy binary files"
@mkdir -p \$(__REAL_INSTALL)/objs
@cp -f objs/srs \$(__REAL_INSTALL)/objs
2016-12-07 04:09:39 +00:00
@echo "Now copy srs conf files"
@mkdir -p \$(__REAL_INSTALL)/conf
@cp -f conf/*.conf \$(__REAL_INSTALL)/conf
2016-12-07 04:09:39 +00:00
@echo "Now copy init.d script files"
@mkdir -p \$(__REAL_INSTALL)/etc/init.d
@cp -f etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d
@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs
@echo "Now copy systemctl service files"
@mkdir -p \$(__REAL_INSTALL)/usr/lib/systemd/system
@cp -f usr/lib/systemd/system/srs.service \$(__REAL_INSTALL)/usr/lib/systemd/system/srs.service
2014-03-23 03:25:42 +00:00
@echo ""
@echo "The api installed, to link and start srs, please"
@echo "For CentOS6:"
@echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs &&"
2014-03-23 03:25:42 +00:00
@echo " /etc/init.d/srs start"
@echo "For CentOS7:"
@echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs &&"
@echo " sudo cp -f \$(SRS_PREFIX)/usr/lib/systemd/system/srs.service /usr/lib/systemd/system/srs.service && sudo systemctl daemon-reload && sudo systemctl enable srs &&"
@echo " sudo systemctl start srs"
@echo "@see: https://github.com/ossrs/srs/wiki/v3_CN_LinuxService"
END
2014-03-07 10:55:15 +00:00
if [ $SRS_UTEST = YES ]; then
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
2014-03-04 04:45:41 +00:00
utest: server
2016-12-07 04:09:39 +00:00
@echo "Building the utest for srs"
2014-03-03 10:28:50 +00:00
${SrsUtestMakeEntry}
2016-12-07 04:09:39 +00:00
@echo "The utest is built ok."
2014-03-03 10:28:50 +00:00
2014-03-07 10:55:15 +00:00
END
else
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
2014-03-07 10:55:15 +00:00
utest: server
2016-12-07 04:09:39 +00:00
@echo "Ignore utest for it's disabled."
2014-03-07 10:55:15 +00:00
END
fi
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
2013-10-17 12:58:04 +00:00
# the ./configure will generate it.
_prepare_dir:
@mkdir -p ${SRS_OBJS_DIR}
2013-10-17 12:58:04 +00:00
END
2015-03-07 08:39:05 +00:00
# generate makefile ok, append the tails.
cat ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk >> ${SRS_WORKDIR}/${SRS_MAKEFILE} &&
rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk
2016-12-07 04:09:39 +00:00
echo 'Configure ok! '
2013-10-17 12:58:04 +00:00
2014-02-28 13:07:46 +00:00
#####################################################################################
# when configure success, prepare build
#####################################################################################
# create objs/logs for ffmpeg to write log.
2020-05-27 06:20:40 +00:00
mkdir -p ${SRS_OBJS}/logs
2014-02-28 13:07:46 +00:00
#####################################################################################
# configure summary
#####################################################################################
2013-11-30 06:12:19 +00:00
# summary
2020-05-27 06:20:40 +00:00
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: HLS is disabled.${BLACK}"
fi
if [ $SRS_STREAM_CASTER = YES ]; then
echo -e "${YELLOW}Experiment: StreamCaster is enabled.${BLACK}"
else
echo -e "${GREEN}Note: StreamCaster is disabled.${BLACK}"
fi
if [ $SRS_HDS = YES ]; then
echo -e "${YELLOW}Experiment: HDS is enabled.${BLACK}"
else
echo -e "${GREEN}Warning: HDS is disabled.${BLACK}"
fi
if [ $SRS_SRT = YES ]; then
echo -e "${YELLOW}Experiment: SRT is enabled. https://github.com/ossrs/srs/issues/1147${BLACK}"
else
echo -e "${GREEN}Warning: SRT is disabled.${BLACK}"
fi
if [ $SRS_RTC = YES ]; then
echo -e "${YELLOW}Experiment: RTC is enabled. https://github.com/ossrs/srs/issues/307${BLACK}"
else
echo -e "${GREEN}Warning: RTC is disabled.${BLACK}"
fi
if [ $SRS_HTTPS = YES ]; then
echo -e "${YELLOW}Experiment: HTTPS is enabled. https://github.com/ossrs/srs/issues/1657${BLACK}"
else
echo -e "${GREEN}Warning: HTTPS is disabled.${BLACK}"
fi
2020-05-27 06:20:40 +00:00
if [ $SRS_DVR = YES ]; then
echo -e "${GREEN}DVR is enabled.${BLACK}"
else
echo -e "${YELLOW}Warning: DVR is disabled.${BLACK}"
2014-05-04 10:38:08 +00:00
fi
2020-05-27 06:20:40 +00:00
if [ $SRS_SSL = YES ]; then
echo -e "${GREEN}RTMP complex handshake is enabled${BLACK}"
else
echo -e "${YELLOW}Warning: RTMP complex handshake is disabled, flash cann't play h264/aac.${BLACK}"
fi
if [[ $SRS_NASM == YES ]]; then
echo -e "${GREEN}NASM for HTTPS(openssl) and FFmepg is enabled${BLACK}"
else
echo -e "${YELLOW}Warning: NASM for HTTPS(openssl) and FFmepg is disabled${BLACK}"
fi
if [[ $SRS_SRTP_ASM == YES ]]; then
echo -e "${GREEN}SRTP-NASM for WebRTC(openssl) is enabled${BLACK}"
else
echo -e "${YELLOW}Warning: SRTP-NASM for WebRTC(openssl) is disabled${BLACK}"
fi
2020-05-27 06:20:40 +00:00
if [ $SRS_TRANSCODE = YES ]; then
echo -e "${GREEN}The transcoding is enabled${BLACK}"
else
echo -e "${YELLOW}Warning: The transcoding is disabled.${BLACK}"
fi
if [ $SRS_INGEST = YES ]; then
echo -e "${GREEN}The ingesting is enabled.${BLACK}"
else
echo -e "${YELLOW}Warning: The ingesting is disabled.${BLACK}"
fi
if [ $SRS_HTTP_CALLBACK = YES ]; then
echo -e "${GREEN}The http-callback is enabled${BLACK}"
else
echo -e "${YELLOW}Warning: The http-callback is disabled.${BLACK}"
fi
if [ $SRS_HTTP_SERVER = YES ]; then
echo -e "${GREEN}Embeded HTTP server for HTTP-FLV/HLS is enabled.${BLACK}"
else
echo -e "${YELLOW}Warning: Embeded HTTP server is disabled, HTTP-FLV is disabled, please use nginx to delivery HLS.${BLACK}"
fi
if [ $SRS_HTTP_API = YES ]; then
echo -e "${GREEN}The HTTP API is enabled${BLACK}"
else
echo -e "${YELLOW}Warning: The HTTP API is disabled.${BLACK}"
fi
if [ $SRS_UTEST = YES ]; then
echo -e "${GREEN}The utests are enabled.${BLACK}"
else
echo -e "${YELLOW}Note: The utests are disabled.${BLACK}"
fi
if [ $SRS_GPERF = YES ]; then
echo -e "${GREEN}The gperf(tcmalloc) is enabled.${BLACK}"
else
echo -e "${GREEN}Note: The gperf(tcmalloc) is disabled.${BLACK}"
fi
if [ $SRS_GPERF_MC = YES ]; then
echo -e "${YELLOW}The gmc(gperf memory check) is enabled, performance may suffer.${BLACK}"
else
echo -e "${GREEN}Note: The gmc(gperf memory check) is disabled.${BLACK}"
fi
if [ $SRS_GPERF_MD = YES ]; then
echo -e "${YELLOW}The gmd(gperf memory defense) is enabled, performance may suffer.${BLACK}"
else
echo -e "${GREEN}Note: The gmd(gperf memory defense) is disabled.${BLACK}"
fi
if [ $SRS_GPERF_MP = YES ]; then
echo -e "${YELLOW}The gmp(gperf memory profile) is enabled, performance may suffer.${BLACK}"
else
echo -e "${GREEN}Note: The gmp(gperf memory profile) is disabled.${BLACK}"
fi
if [ $SRS_GPERF_CP = YES ]; then
echo -e "${YELLOW}The gcp(gperf cpu profile) is enabled, performance may suffer.${BLACK}"
else
echo -e "${GREEN}Note: The gcp(gperf cpu profile) is disabled.${BLACK}"
fi
if [ $SRS_GPROF = YES ]; then
echo -e "${YELLOW}The gprof(GNU profile tool) is enabled, performance may suffer.${BLACK}"
else
echo -e "${GREEN}Note: The gprof(GNU profile tool) is disabled.${BLACK}"
fi
if [ $SRS_VALGRIND = YES ]; then
echo -e "${GREEN}The valgrind is enabled.${BLACK}"
else
echo -e "${GREEN}Note: The valgrind is disabled.${BLACK}"
fi
# add each modules for application
for SRS_MODULE in ${SRS_MODULES[*]}; do
echo -e "${GREEN}Enable module: $SRS_MODULE${BLACK}"
done
2013-11-30 06:12:19 +00:00
2020-04-04 10:47:12 +00:00
#####################################################################################
# Do cleanup when configure done.
#####################################################################################
if [[ $SRS_CLEAN == YES && -f Makefile ]]; then
#echo "Do full cleanup, you can disable it by: --clean=off"
2020-04-04 10:47:12 +00:00
make clean
fi
#####################################################################################
# next step
#####################################################################################
if [[ $SRS_CHERRYPY == YES ]]; then
echo ""
echo "You can run 3rdparty applications:"
if [ $SRS_HTTP_CALLBACK = YES ]; then
echo -e "\" python ./research/api-server/server.py 8085 \" to start the api-server"
fi
2013-12-07 12:34:42 +00:00
fi
2020-05-27 06:20:40 +00:00
echo ""
echo "You can build SRS:"
echo "\" make \" to build the SRS server"
echo "\" make help \" to get some help"
2020-05-27 06:20:40 +00:00