SRS 6.0-b0 源码 + danmaku 后端(排除 objs/3rdparty/测试媒体)

This commit is contained in:
RRRosmontis
2026-08-27 21:46:20 +08:00
commit 41b5da7c7e
578 changed files with 237858 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
# generate the binary
#
# params:
# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
# $SRS_OBJS the objs directory for Makefile. ie. objs
#
# $MAIN_ENTRANCES array, disable all except the $APP_MAIN itself. ie. ["srs_main_server"]
# $APP_MAIN the object file that contains main function. ie. srs_main_server
# $BUILD_KEY a string indicates the build key for Makefile. ie. srs
# $APP_NAME the app name to output. ie. srs
# $MODULE_OBJS array, the objects to compile the app.
# $ModuleLibFiles array, the 3rdpart library file to link with. ie. [objs/st-1.9/obj/libst.a objs/libx264/obj/libx264.a]
# $LINK_OPTIONS the linker options. ie. -ldl
FILE=${SRS_OBJS}/Makefile
APP_TARGET="${SRS_OBJS}/${APP_NAME}"
echo "Generating app ${APP_NAME} depends.";
echo "# build ${APP_TARGET}" >> ${FILE}
# generate the binary depends, for example:
# srs: objs/srs
echo "${BUILD_KEY}: ${APP_TARGET}" >> ${FILE}
echo "" >> ${FILE}
# the link commands, for example:
# objs/srs: objs/src/core/srs_core.o
echo -n "${APP_TARGET}: " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=`basename $item`
FILE_NAME=${FILE_NAME%.*}
ignored=0
for disabled_item in ${MAIN_ENTRANCES[*]}; do
if [[ ${FILE_NAME} == ${disabled_item} && ${FILE_NAME} != ${APP_MAIN} ]]; then
ignored=1
continue;
fi
done
if [ ! -f ${SRS_WORKDIR}/${item} ]; then
ignored=1
fi
if [ ${ignored} == 1 ]; then
echo "Ignore file ${FILE_NAME}"
continue;
fi
OBJ_FILE=${SRS_OBJS}/$item
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
echo "" >> ${FILE}
echo "Generating app ${APP_NAME} link.";
# genereate the actual link command, for example:
# $(LINK) -o objs/srs objs/src/core/srs_core.o -ldl
echo -n " \$(LINK) -o ${APP_TARGET} " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=`basename $item`
FILE_NAME=${FILE_NAME%.*}
ignored=0
for disabled_item in ${MAIN_ENTRANCES[*]}; do
if [[ ${FILE_NAME} == ${disabled_item} && ${FILE_NAME} != ${APP_MAIN} ]]; then
ignored=1
continue;
fi
done
if [ ! -f ${SRS_WORKDIR}/${item} ]; then
ignored=1
fi
if [ ${ignored} == 1 ]; then
echo "Ignore file ${FILE_NAME}"
continue;
fi
OBJ_FILE=${SRS_OBJS}/$item
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
# 3rdpart library static link.
for item in ${ModuleLibFiles[*]}; do
echo -n "$item " >> ${FILE}
done
# link options.
echo -n "${LINK_OPTIONS}" >> ${FILE}
echo "" >> ${FILE}
echo "" >> ${FILE}
echo -n "Generate app ${APP_NAME} ok"; echo '!';
+271
View File
@@ -0,0 +1,271 @@
#!/bin/bash
# output variables:
# SRS_AUTO_HEADERS_H: the auto generated header file.
SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
# write user options to headers
echo "// auto generated by configure" > $SRS_AUTO_HEADERS_H
echo "#ifndef SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_PACKAGER \"${SRS_AUTO_PACKAGER}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
function srs_define_macro()
{
macro=$1 && file=$2
echo "#define $macro" >> $file
echo "#define ${macro}_BOOL true" >> $file
}
function srs_define_macro_value()
{
macro=$1 && value=$2 && file=$3
echo "#define $macro $value" >> $file
echo "#define ${macro}_BOOL true" >> $file
}
function srs_undefine_macro()
{
macro=$1 && file=$2
echo "#undef $macro" >> $file
echo "#define ${macro}_BOOL false" >> $file
}
#####################################################################################
# generate auto headers file, depends on the finished of options.sh
#####################################################################################
# auto headers in depends.
if [[ $SRS_HDS == YES ]]; then
srs_define_macro "SRS_HDS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_HDS" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_SRT == YES ]]; then
srs_define_macro "SRS_SRT" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SRT" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_CXX11 == YES ]]; then
srs_define_macro "SRS_CXX11" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_CXX11" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_CXX14 == YES ]]; then
srs_define_macro "SRS_CXX14" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_CXX14" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_BACKTRACE == YES ]]; then
srs_define_macro "SRS_BACKTRACE" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_BACKTRACE" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_RTC == YES ]]; then
srs_define_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
srs_define_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_FFMPEG_OPUS == YES ]]; then
srs_define_macro "SRS_FFMPEG_OPUS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_FFMPEG_OPUS" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_H265 == YES ]]; then
srs_define_macro "SRS_H265" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_H265" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_SIMULATOR == YES ]]; then
srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_HTTPS == YES ]]; then
srs_define_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_GB28181 == YES ]]; then
srs_define_macro "SRS_GB28181" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_GB28181" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_APM == YES ]]; then
srs_define_macro "SRS_APM" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_APM" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_UTEST == YES ]]; then
srs_define_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H
fi
# whatever the FFMPEG tools, if transcode and ingest specified,
# srs always compile the FFMPEG tool stub which used to start the FFMPEG process.
if [[ $SRS_FFMPEG_STUB == YES ]]; then
srs_define_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_GPERF == YES ]]; then
srs_define_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_GPERF_MC == YES ]]; then
srs_define_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_GPERF_MD == YES ]]; then
srs_define_macro "SRS_GPERF_MD" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_GPERF_MD" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_GPERF_MP == YES ]]; then
srs_define_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_GPERF_CP == YES ]]; then
srs_define_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_SANITIZER == YES ]; then
srs_define_macro "SRS_SANITIZER" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SANITIZER" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_SANITIZER_LOG == YES ]; then
srs_define_macro "SRS_SANITIZER_LOG" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SANITIZER_LOG" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_VALGRIND == YES ]; then
srs_define_macro "SRS_VALGRIND" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_VALGRIND" $SRS_AUTO_HEADERS_H
fi
#####################################################################################
# for embeded.
#####################################################################################
# for log level compile settings
if [[ $SRS_LOG_VERBOSE == YES ]]; then
srs_define_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_LOG_INFO == YES ]]; then
srs_define_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_LOG_TRACE == YES ]]; then
srs_define_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_SINGLE_THREAD == YES ]]; then
srs_define_macro "SRS_SINGLE_THREAD" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SINGLE_THREAD" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_SIGNAL_API == YES ]]; then
srs_define_macro "SRS_SIGNAL_API" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SIGNAL_API" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_LOG_LEVEL_V2 == YES ]]; then
srs_define_macro "SRS_LOG_LEVEL_V2" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_LOG_LEVEL_V2" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_CROSS_BUILD == YES ]]; then
srs_define_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_CYGWIN64 == YES ]]; then
srs_define_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_OSX == YES ]]; then
srs_define_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_DEBUG == YES ]]; then
srs_define_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_DEBUG_STATS == YES ]]; then
srs_define_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
fi
# prefix
echo "" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_DEFAULT_CONFIG \"${SRS_DEFAULT_CONFIG}\"" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
# generated the contributors from AUTHORS.txt
#####################################################################################
if [[ -f AUTHORS.md ]]; then
RTMP_SIG_SRS_AUTHORS=$(cat AUTHORS.md|grep "^-"|awk -F '`' '{print $2}')
echo "#define RTMP_SIG_SRS_AUTHORS \"\\" >> $SRS_AUTO_HEADERS_H
for CONTRIBUTOR in $RTMP_SIG_SRS_AUTHORS; do
echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
done
echo "\"" >> $SRS_AUTO_HEADERS_H
else
echo "#define RTMP_SIG_SRS_AUTHORS \"ossrs\"" >> $SRS_AUTO_HEADERS_H
fi
# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
# auto header EOF.
#####################################################################################
echo "#endif" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
# In .circleci/config.yml, generate *.gcno with
# ./configure --gcov && make utest
# and generate *.gcda by
# ./objs/srs_utest
# Workdir is objs/cover.
workdir=$(cd `dirname $0`/.. && pwd)/objs/cover
# Create trunk under workdir.
mkdir -p $workdir && cd $workdir
ret=$?; if [[ $ret -ne 0 ]]; then echo "Enter workdir failed, ret=$ret"; exit $ret; fi
CODECOV_ARGS=""
if [[ $SRS_PROJECT != '' ]]; then
# -R root dir Used when not in git/hg project to identify project root directory
# -p dir Project root directory. Also used when preparing gcov
CODECOV_ARGS="$CODECOV_ARGS -R $SRS_PROJECT -p $SRS_PROJECT"
fi
if [[ $SRS_BRANCH != '' ]]; then
# -B branch Specify the branch name
CODECOV_ARGS="$CODECOV_ARGS -B $SRS_BRANCH"
fi
if [[ $SRS_SHA != '' ]]; then
# -C sha Specify the commit sha
CODECOV_ARGS="$CODECOV_ARGS -C $SRS_SHA"
fi
if [[ $SRS_PR != '' ]]; then
# -P pr Specify the pull request number
CODECOV_ARGS="$CODECOV_ARGS -P $SRS_PR"
fi
# Upload report with *.gcov
# Remark: The file codecov.yml is not neccessary. It literally depends on git.
# Note: The right path is like:
# https://codecov.io/gh/ossrs/srs/src/3.0release/trunk/src/protocol/srs_rtmp_stack.cpp
# https://codecov.io/gh/ossrs/srs/src/20fbb4466fdc8ba5d810b8570df6004063212838/trunk/src/protocol/srs_rtmp_stack.cpp
cd $workdir &&
export CODECOV_TOKEN="$CODECOV_TOKEN" &&
bash <(curl -s https://codecov.io/bash) $CODECOV_ARGS -f '!*gtest*' -f '!*c++*' -f '!*ffmpeg-*-fit*' &&
echo "Done" && exit 0
+762
View File
@@ -0,0 +1,762 @@
#!/bin/bash
# variables, parent script must set it:
# SRS_JOBS: the build jobs.
# SrsArmMakeOptions: the arm make options for ubuntu12(armhf, v7cpu)
#####################################################################################
#####################################################################################
# prepare the depends tools and libraries
# DEPENDS: options.sh, only when user options parsed, the depends tools are known.
#####################################################################################
#####################################################################################
#####################################################################################
# Check OS and CPU architectures.
#####################################################################################
if [[ $OS_IS_UBUNTU != YES && $OS_IS_CENTOS != YES && $OS_IS_OSX != YES && $SRS_CYGWIN64 != YES ]]; then
if [[ $SRS_CROSS_BUILD != YES && $SRS_GENERIC_LINUX != YES ]]; then
echo "Your OS `uname -s` is not supported."
if [[ $(uname -s) == "Linux" ]]; then
echo "Please try --generic-linux=on for other Linux systems."
fi
exit 1
fi
fi
# The absolute path of SRS_OBJS, for prefix and PKG_CONFIG_PATH
SRS_DEPENDS_LIBS=$(mkdir -p $SRS_OBJS && cd $SRS_OBJS && pwd)
echo -n "SRS_JOBS: $SRS_JOBS, SRS_DEPENDS_LIBS: ${SRS_DEPENDS_LIBS}"
if [[ ! -z $OS_IS_LINUX ]]; then echo -n ", OS_IS_LINUX: $OS_IS_LINUX"; fi
if [[ ! -z $OS_IS_OSX ]]; then echo -n ", OS_IS_OSX: $OS_IS_OSX"; fi
if [[ ! -z $OS_IS_CYGWIN ]]; then echo -n ", OS_IS_CYGWIN: $OS_IS_CYGWIN"; fi
if [[ ! -z $OS_IS_UBUNTU ]]; then echo -n ", OS_IS_UBUNTU: $OS_IS_UBUNTU"; fi
if [[ ! -z $OS_IS_CENTOS ]]; then echo -n ", OS_IS_CENTOS: $OS_IS_CENTOS"; fi
if [[ ! -z $SRS_CROSS_BUILD ]]; then echo -n ", SRS_CROSS_BUILD: $SRS_CROSS_BUILD"; fi
if [[ ! -z $OS_IS_LOONGARCH64 ]]; then echo -n ", OS_IS_LOONGARCH64: $OS_IS_LOONGARCH64"; fi
if [[ ! -z $OS_IS_MIPS64 ]]; then echo -n ", OS_IS_MIPS64: $OS_IS_MIPS64"; fi
if [[ ! -z $OS_IS_LOONGSON ]]; then echo -n ", OS_IS_LOONGSON: $OS_IS_LOONGSON"; fi
if [[ ! -z $OS_IS_X86_64 ]]; then echo -n ", OS_IS_X86_64: $OS_IS_X86_64"; fi
if [[ ! -z $OS_IS_RISCV ]]; then echo -n ", OS_IS_RISCV: $OS_IS_RISCV"; fi
echo ""
#####################################################################################
# Check dependency tools.
#####################################################################################
if [[ $SRS_OSX == YES ]]; then
brew --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Please install brew at https://brew.sh/"; exit $ret;
fi
fi
# Check perl, which is depended by automake for building libopus etc.
perl --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install perl by:"
echo " yum install -y perl"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install perl by:"
echo " apt install -y perl"
else
echo "Please install perl"
fi
exit $ret;
fi
gcc --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install gcc by:"
echo " yum install -y gcc"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install gcc by:"
echo " apt install -y gcc"
else
echo "Please install gcc"
fi
exit $ret;
fi
g++ --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install g++ by:"
echo " yum install -y gcc-c++"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install g++ by:"
echo " apt install -y g++"
else
echo "Please install gcc-c++"
fi
exit $ret;
fi
make --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install make by:"
echo " yum install -y make"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install make by:"
echo " apt install -y make"
else
echo "Please install make"
fi
exit $ret;
fi
patch --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install patch by:"
echo " yum install -y patch"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install patch by:"
echo " apt install -y patch"
else
echo "Please install patch"
fi
exit $ret;
fi
unzip -v >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install unzip by:"
echo " yum install -y unzip"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install unzip by:"
echo " apt install -y unzip"
else
echo "Please install unzip"
fi
exit $ret;
fi
automake --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install automake by:"
echo " yum install -y automake"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install automake by:"
echo " apt install -y automake"
else
echo "Please install automake"
fi
exit $ret;
fi
if [[ $SRS_VALGRIND == YES ]]; then
valgrind --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Please install valgrind"; exit $ret;
fi
if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then
echo "Please install valgrind-dev"; exit $ret;
fi
fi
# Check tclsh, which is depended by SRT.
if [[ $SRS_SRT == YES ]]; then
tclsh <<< "exit" >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install tclsh by:"
echo " yum install -y tcl"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install tclsh by:"
echo " apt install -y tclsh"
else
echo "Please install tclsh"
fi
exit $ret;
fi
cmake --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install cmake by:"
echo " yum install -y cmake"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install cmake by:"
echo " apt install -y cmake"
else
echo "Please install cmake"
fi
exit $ret;
fi
fi
pkg-config --version >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Please install pkg-config"; exit $ret;
fi
which ls >/dev/null 2>/dev/null; ret=$?; if [[ 0 -ne $ret ]]; then
if [[ $OS_IS_CENTOS == YES ]]; then
echo "Please install which by:"
echo " yum install -y which"
elif [[ $OS_IS_UBUNTU == YES ]]; then
echo "Please install which by:"
echo " apt install -y which"
else
echo "Please install which"
fi
exit $ret;
fi
#####################################################################################
# Try to load cache if exists /usr/local/srs-cache
#####################################################################################
# Use srs-cache from base image. See https://github.com/ossrs/dev-docker/blob/ubuntu20-cache/Dockerfile
# Note that the cache for cygwin is not under /usr/local, but copy to objs instead.
if [[ -d /usr/local/srs-cache/srs/trunk/objs && $(pwd) != "/usr/local/srs-cache/srs/trunk" && $SRS_BUILD_CACHE == YES ]]; then
SOURCE_DIR=$(ls -d /usr/local/srs-cache/srs/trunk/objs/Platform-SRS${SRS_MAJOR}-* 2>/dev/null|head -n 1)
if [[ -d $SOURCE_DIR ]]; then
TARGET_DIR=${SRS_OBJS}/${SRS_PLATFORM} &&
echo "Build from cache, source=$SOURCE_DIR, target=$TARGET_DIR" &&
rm -rf $TARGET_DIR && mkdir -p ${SRS_OBJS} && cp -R $SOURCE_DIR $TARGET_DIR &&
du -sh /usr/local/srs-cache/srs/trunk/objs/Platform-* &&
du -sh /usr/local/srs-cache/srs/trunk/objs/Platform-*/* &&
du -sh objs/Platform-* &&
ls -lh objs
fi
fi
#####################################################################################
# Check for address sanitizer, see https://github.com/google/sanitizers
#####################################################################################
if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES ]]; then
echo 'int main() { return 0; }' > ${SRS_OBJS}/test_sanitizer.c &&
gcc -fsanitize=address -fno-omit-frame-pointer -g -O0 ${SRS_OBJS}/test_sanitizer.c \
-o ${SRS_OBJS}/test_sanitizer 1>/dev/null 2>&1;
ret=$?; rm -rf ${SRS_OBJS}/test_sanitizer*
if [[ $ret -ne 0 ]]; then
echo "Please install libasan, see https://github.com/google/sanitizers";
if [[ $OS_IS_CENTOS == YES ]]; then echo " sudo yum install -y libasan"; fi
exit $ret;
fi
fi
if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES && $SRS_SANITIZER_STATIC == NO ]]; then
echo 'int main() { return 0; }' > ${SRS_OBJS}/test_sanitizer.c &&
gcc -fsanitize=address -fno-omit-frame-pointer -static-libasan -g -O0 ${SRS_OBJS}/test_sanitizer.c \
-o ${SRS_OBJS}/test_sanitizer 1>/dev/null 2>&1;
ret=$?; rm -rf ${SRS_OBJS}/test_sanitizer*
if [[ $ret -eq 0 ]]; then
echo "link static-libasan"
SRS_SANITIZER_STATIC=YES
fi
fi
if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES && $SRS_SANITIZER_LOG == NO ]]; then
echo "#include <sanitizer/asan_interface.h>" > ${SRS_OBJS}/test_sanitizer.c &&
echo "int main() { return 0; }" >> ${SRS_OBJS}/test_sanitizer.c &&
gcc -fsanitize=address -fno-omit-frame-pointer -g -O0 ${SRS_OBJS}/test_sanitizer.c \
-o ${SRS_OBJS}/test_sanitizer 1>/dev/null 2>&1;
ret=$?; rm -rf ${SRS_OBJS}/test_sanitizer*
if [[ $ret -eq 0 ]]; then
echo "libasan api found ok!";
SRS_SANITIZER_LOG=YES
fi
fi
#####################################################################################
# state-threads
#####################################################################################
# check the cross build flag file, if flag changed, need to rebuild the st.
_ST_MAKE=linux-debug && _ST_OBJ="LINUX_`uname -r`_DBG"
# Always alloc on heap, @see https://github.com/ossrs/srs/issues/509#issuecomment-719931676
_ST_EXTRA_CFLAGS="-DMALLOC_STACK"
# For valgrind to detect memory issues.
if [[ $SRS_VALGRIND == YES ]]; then
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_VALGRIND"
fi
# for osx, use darwin for st, donot use epoll.
if [[ $SRS_OSX == YES ]]; then
_ST_MAKE=darwin-debug && _ST_OBJ="DARWIN_`uname -r`_DBG"
fi
# for windows/cygwin
if [[ $SRS_CYGWIN64 = YES ]]; then
_ST_MAKE=cygwin64-debug && _ST_OBJ="CYGWIN64_`uname -s`_DBG"
fi
# For Ubuntu, the epoll detection might be fail.
if [[ $OS_IS_UBUNTU == YES ]]; then
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_HAVE_EPOLL"
fi
# Whether enable debug stats.
if [[ $SRS_DEBUG_STATS == YES ]]; then
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DDEBUG_STATS"
fi
# Pass the global extra flags.
if [[ $SRS_EXTRA_FLAGS != '' ]]; then
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS $SRS_EXTRA_FLAGS"
fi
# Whether link as .so
if [[ $SRS_SHARED_ST == YES ]]; then
_ST_STATIC_ONLY=no;
else
_ST_STATIC_ONLY=yes;
fi
# The final args to make st.
_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_OBJS}/${SRS_PLATFORM}/3rdparty/st/libst.a ]]; then
rm -rf ${SRS_OBJS}/st && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/st ${SRS_OBJS}/ &&
echo "The state-threads is ok."
else
echo "Building state-threads." &&
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/st ${SRS_OBJS}/st &&
cp -rf ${SRS_WORKDIR}/3rdparty/st-srs ${SRS_OBJS}/${SRS_PLATFORM}/ &&
env EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" make -C ${SRS_OBJS}/${SRS_PLATFORM}/st-srs ${_ST_MAKE_ARGS} &&
mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/st &&
cp -f ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/st.h ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/st/ &&
cp -f ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/libst.a ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/st/ &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/st ${SRS_OBJS}/ &&
echo "The state-threads is ok."
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build state-threads failed, ret=$ret"; exit $ret; fi
#####################################################################################
# nginx for HLS, nginx-1.5.0
#####################################################################################
function write_nginx_html5()
{
cat<<END > ${html_file}
<video width="100%" autoplay controls autobuffer type="application/vnd.apple.mpegurl"
src="${hls_stream}">
</video>
END
}
# create the nginx dir, for http-server if not build nginx
mkdir -p ${SRS_OBJS}/nginx
# the demo dir.
# create forward dir
mkdir -p ${SRS_OBJS}/nginx/html/live &&
html_file=${SRS_OBJS}/nginx/html/live/livestream.html && hls_stream=livestream.m3u8 && write_nginx_html5 &&
# copy players to nginx html dir.
rm -rf ${SRS_OBJS}/nginx/html/players &&
cp -rf $SRS_WORKDIR/research/players ${SRS_OBJS}/nginx/html/ &&
# for favicon.ico
rm -rf ${SRS_OBJS}/nginx/html/favicon.ico &&
cp -f $SRS_WORKDIR/research/api-server/static-dir/favicon.ico ${SRS_OBJS}/nginx/html/favicon.ico &&
# For srs-console.
rm -rf ${SRS_OBJS}/nginx/html/console &&
cp -rf $SRS_WORKDIR/research/console ${SRS_OBJS}/nginx/html/ &&
# For SRS signaling.
rm -rf ${SRS_OBJS}/nginx/html/demos &&
cp -rf $SRS_WORKDIR/3rdparty/signaling/www/demos ${SRS_OBJS}/nginx/html/ &&
# For home page index.html
rm -rf ${SRS_OBJS}/nginx/html/index.html &&
cp -f $SRS_WORKDIR/research/api-server/static-dir/index.html ${SRS_OBJS}/nginx/html/index.html &&
# nginx.html to detect whether nginx is alive
echo "Nginx is ok." > ${SRS_OBJS}/nginx/html/nginx.html
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build web pages failed, ret=$ret"; exit $ret; fi
#####################################################################################
# Generate default self-sign certificate for HTTPS server, test only.
#####################################################################################
if [[ ! -f $SRS_WORKDIR/conf/server.key || ! -f $SRS_WORKDIR/conf/server.crt ]]; then
openssl genrsa -out $SRS_WORKDIR/conf/server.key 2048 &&
openssl req -new -x509 -key $SRS_WORKDIR/conf/server.key -out $SRS_WORKDIR/conf/server.crt -days 3650 \
-subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" &&
echo "Generate test-only self-sign certificate files"
fi
#####################################################################################
# openssl, for rtmp complex handshake and HLS encryption.
#####################################################################################
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then
echo "Warning: Use system libssl, without compiling openssl."
fi
# @see http://www.openssl.org/news/secadv/20140407.txt
# Affected users should upgrade to OpenSSL 1.1.0e. Users unable to immediately
# upgrade can alternatively recompile OpenSSL with -DOPENSSL_NO_HEARTBEATS.
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then
OPENSSL_OPTIONS="-no-shared -no-threads -DOPENSSL_NO_HEARTBEATS"
OPENSSL_CONFIG="./config"
# https://stackoverflow.com/questions/15539062/cross-compiling-of-openssl-for-linux-arm-v5te-linux-gnueabi-toolchain
if [[ $SRS_CROSS_BUILD == YES ]]; then
OPENSSL_CONFIG="./Configure linux-generic32"
if [[ $SRS_CROSS_BUILD_ARCH == "arm" ]]; then OPENSSL_CONFIG="./Configure linux-armv4"; fi
if [[ $SRS_CROSS_BUILD_ARCH == "aarch64" ]]; then OPENSSL_CONFIG="./Configure linux-aarch64"; fi
if [[ $SRS_CROSS_BUILD_ARCH == "mipsel" ]]; then OPENSSL_CONFIG="./Configure linux-mips32"; fi
elif [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/openssl/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}/3rdparty/openssl/lib && cd ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/openssl/lib &&
cp /usr/local/ssl/lib/libssl.a . && cp /usr/local/ssl/lib/libcrypto.a . &&
mkdir -p /usr/local/ssl/lib/pkgconfig && cp -rf /usr/local/ssl/lib/pkgconfig .)
(mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/openssl/include && cd ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/openssl/include &&
cp -rf /usr/local/ssl/include/openssl .)
fi
# Warning if not use the system ssl.
if [[ -f /usr/local/ssl/lib/libssl.a && $SRS_SSL_LOCAL == YES ]]; then
echo "Warning: Local openssl is on, ignore system openssl"
fi
fi
# Patch for loongarch mips64, disable ASM for build failed message as bellow:
# Error: opcode not supported on this processor: mips3 (mips3)
if [[ $OS_IS_MIPS64 == YES ]]; then OPENSSL_CONFIG="./Configure linux64-mips64"; fi
if [[ $OS_IS_LOONGSON == YES ]]; then OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-asm"; fi
# For RTC, we should use ASM to improve performance, not a little improving.
if [[ $SRS_RTC == NO || $SRS_NASM == NO ]]; then
OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-asm"
echo "Warning: NASM is off, performance is hurt"
fi
# Mac OS X can have issues (its often a neglected platform).
# @see https://wiki.openssl.org/index.php/Compilation_and_Installation
if [[ $SRS_OSX == YES ]]; then
export KERNEL_BITS=64;
fi
# Use 1.0 if required.
if [[ $SRS_SSL_1_0 == YES ]]; then
OPENSSL_AR="$SRS_TOOL_AR -r" # For openssl 1.0, MUST specifies the args for ar or build faild.
OPENSSL_CANDIDATE="openssl-OpenSSL_1_0_2u" &&
OPENSSL_UNZIP="tar xf ${SRS_WORKDIR}/3rdparty/$OPENSSL_CANDIDATE.tar.gz -C ${SRS_OBJS}/${SRS_PLATFORM}"
else
OPENSSL_AR="$SRS_TOOL_AR"
OPENSSL_CANDIDATE="openssl-1.1-fit" &&
OPENSSL_UNZIP="cp -R ${SRS_WORKDIR}/3rdparty/$OPENSSL_CANDIDATE ${SRS_OBJS}/${SRS_PLATFORM}/"
fi
#
# https://wiki.openssl.org/index.php/Compilation_and_Installation#Configure_Options
# Already defined: -no-shared -no-threads -no-asm
# Should enable: -no-dtls -no-dtls1 -no-ssl3
# Might able to disable: -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
# Note that we do not disable more features, because no file could be removed.
#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_OBJS}/${SRS_PLATFORM}/3rdparty/openssl/lib/libssl.a ]]; then
rm -rf ${SRS_OBJS}/openssl && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/openssl ${SRS_OBJS}/ &&
echo "The $OPENSSL_CANDIDATE is ok."
else
echo "Building $OPENSSL_CANDIDATE." &&
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/openssl \
${SRS_OBJS}/openssl &&
${OPENSSL_UNZIP} &&
(
cd ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} &&
chmod +x ./config ./Configure &&
${OPENSSL_CONFIG} --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdparty/openssl $OPENSSL_OPTIONS
) &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} CC=${SRS_TOOL_CC} AR="${OPENSSL_AR}" \
LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} ${SRS_JOBS} &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} install_sw &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/openssl ${SRS_OBJS}/ &&
echo "The $OPENSSL_CANDIDATE is ok."
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build $OPENSSL_CANDIDATE failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# srtp
#####################################################################################
if [[ $SRS_RTC == YES && $SRS_USE_SYS_SRTP == YES ]]; then
echo "Warning: Use system libsrtp, without compiling srtp."
fi
if [[ $SRS_RTC == YES && $SRS_USE_SYS_SRTP == NO ]]; then
SRTP_OPTIONS=""
# To eliminate warnings, see https://stackoverflow.com/a/34208904/17679565
# was built for newer macOS version (11.6) than being linked (11.0)
if [[ $SRS_OSX == YES ]]; then
export MACOSX_DEPLOYMENT_TARGET=11.0
echo "Set MACOSX_DEPLOYMENT_TARGET to avoid warnings"
fi
# If use ASM for SRTP, we enable openssl(with ASM).
if [[ $SRS_SRTP_ASM == YES ]]; then
SRTP_OPTIONS="--enable-openssl"
SRTP_CONFIGURE="env PKG_CONFIG_PATH=${SRS_DEPENDS_LIBS}/openssl/lib/pkgconfig ./configure"
else
SRTP_OPTIONS="--disable-openssl"
SRTP_CONFIGURE="./configure"
fi
if [[ $SRS_CROSS_BUILD == YES ]]; then
SRTP_OPTIONS="$SRTP_OPTIONS --host=$SRS_CROSS_BUILD_HOST"
fi
if [[ $OS_IS_LOONGARCH64 == YES ]]; then
SRTP_OPTIONS="$SRTP_OPTIONS --build=loongarch64-unknown-linux-gnu"
fi
# Copy and patch source files, then build and install libsrtp.
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srtp2/lib/libsrtp2.a ]]; then
rm -rf ${SRS_OBJS}/srtp2 &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srtp2 ${SRS_OBJS} &&
echo "The libsrtp-2-fit is ok."
else
echo "Building libsrtp-2-fit."
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srtp2 \
${SRS_OBJS}/srtp2 &&
cp -rf ${SRS_WORKDIR}/3rdparty/libsrtp-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
# For cygwin64, the patch is not available, so use sed instead.
if [[ $SRS_CYGWIN64 == YES ]]; then
sed -i 's/char bit_string/static char bit_string/g' ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/math/datatypes.c
else
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/gcc10-01.patch
fi &&
# Patch the cpu arch guessing for RISCV.
if [[ $OS_IS_RISCV == YES ]]; then
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/config.guess ${SRS_WORKDIR}/3rdparty/patches/srtp/config.guess-02.patch
fi &&
(
cd ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit &&
$SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdparty/srtp2
) &&
# Sometimes it might fail because autoconf failed to generate crypto/include.config.h
if [[ $SRS_CYGWIN64 == YES ]]; then
SRS_PATCH_SOURCE=${SRS_WORKDIR}/3rdparty/patches/srtp/cygwin-crypto-include-config.h
if [[ $SRS_SRTP_ASM == YES ]]; then
SRS_PATCH_SOURCE=${SRS_WORKDIR}/3rdparty/patches/srtp/cygwin-gcm-crypto-include-config.h
fi
grep -q 'HAVE_UINT64_T 1' ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/include/config.h ||
cp -f $SRS_PATCH_SOURCE ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/include/config.h
fi &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit ${SRS_JOBS} &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit install &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srtp2 ${SRS_OBJS}/ &&
echo "The libsrtp-2-fit is ok."
fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build libsrtp failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# libopus, for WebRTC to transcode AAC with Opus.
#####################################################################################
# For cross build, we use opus of FFmpeg, so we don't build the libopus.
if [[ $SRS_RTC == YES && $SRS_USE_SYS_FFMPEG != YES && $SRS_FFMPEG_OPUS != YES ]]; then
# Only build static libraries if no shared FFmpeg.
if [[ $SRS_SHARED_FFMPEG != YES ]]; then
OPUS_OPTIONS="--disable-shared --disable-doc"
fi
if [[ $OS_IS_LOONGARCH64 == YES ]]; then
OPUS_OPTIONS="$OPUS_OPTIONS --build=loongarch64-unknown-linux-gnu"
fi
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/opus/lib/libopus.a ]]; then
rm -rf ${SRS_OBJS}/opus && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/opus ${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 ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/opus ${SRS_OBJS}/opus &&
tar xf ${SRS_WORKDIR}/3rdparty/opus-1.3.1.tar.gz -C ${SRS_OBJS}/${SRS_PLATFORM} &&
(
# Opus requires automake 1.15, and fails for automake 1.16+, so we run autoreconf to fix it.
cd ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 && autoreconf &&
./configure --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdparty/opus --enable-static $OPUS_OPTIONS
) &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 ${SRS_JOBS} &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 install &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/opus ${SRS_OBJS}/ &&
echo "The opus-1.3.1 is ok."
fi
if [ ! -f ${SRS_OBJS}/opus/lib/libopus.a ]; then echo "Build opus-1.3.1 failed."; exit -1; fi
fi
#####################################################################################
# ffmpeg-fit, for WebRTC to transcode AAC with Opus.
#####################################################################################
if [[ $SRS_FFMPEG_FIT == YES && $SRS_USE_SYS_FFMPEG == YES ]]; then
echo "Warning: Use system ffmpeg, without compiling ffmpeg."
fi
if [[ $SRS_FFMPEG_FIT == YES && $SRS_USE_SYS_FFMPEG == NO ]]; then
FFMPEG_CONFIGURE="env SRS_FFMPEG_FIT=on"
if [[ $SRS_FFMPEG_OPUS != YES ]]; then
FFMPEG_CONFIGURE="$FFMPEG_CONFIGURE PKG_CONFIG_PATH=${SRS_DEPENDS_LIBS}/opus/lib/pkgconfig"
fi
FFMPEG_CONFIGURE="$FFMPEG_CONFIGURE ./configure"
# Disable all features, note that there are still some options need to be disabled.
FFMPEG_OPTIONS="--disable-everything"
# Disable all asm for FFmpeg, to compatible with ARM CPU.
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-asm --disable-x86asm --disable-inline-asm"
# Only build static libraries if no shared FFmpeg.
if [[ $SRS_SHARED_FFMPEG == YES ]]; then
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-shared"
fi
# For loongson/mips64, disable mips64r6, or build failed.
if [[ $OS_IS_MIPS64 == YES && $OS_IS_LOONGSON == YES ]]; then FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-mips64r6"; fi
# For cross-build.
if [[ $SRS_CROSS_BUILD == YES ]]; then
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-cross-compile --target-os=linux --disable-pthreads"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --arch=$SRS_CROSS_BUILD_ARCH";
if [[ $SRS_CROSS_BUILD_CPU != "" ]]; then FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cpu=$SRS_CROSS_BUILD_CPU"; fi
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cross-prefix=$SRS_CROSS_BUILD_PREFIX"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cc=${SRS_TOOL_CC} --cxx=${SRS_TOOL_CXX} --ar=${SRS_TOOL_AR} --ld=${SRS_TOOL_LD}"
fi
# For audio codec opus, use FFmpeg native one, or external libopus.
if [[ $SRS_FFMPEG_OPUS == YES ]]; then
# TODO: FIXME: Note that the audio might be corrupted, see https://github.com/ossrs/srs/issues/3140
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=opus --enable-encoder=opus"
else
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=libopus --enable-encoder=libopus --enable-libopus"
fi
# Disable features of ffmpeg.
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-avdevice --disable-avformat --disable-swscale --disable-postproc --disable-avfilter --disable-network"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-dwt --disable-error-resilience --disable-lsp --disable-lzo --disable-faan --disable-pixelutils"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-hwaccels --disable-devices --disable-audiotoolbox --disable-videotoolbox --disable-cuvid"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-d3d11va --disable-dxva2 --disable-ffnvcodec --disable-nvdec --disable-nvenc --disable-v4l2-m2m --disable-vaapi"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-vdpau --disable-appkit --disable-coreimage --disable-avfoundation --disable-securetransport --disable-iconv"
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --disable-lzma --disable-sdl2"
# Enable FFmpeg native AAC encoder and decoder.
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=aac --enable-decoder=aac_fixed --enable-decoder=aac_latm --enable-encoder=aac"
# Enable FFmpeg native MP3 decoder, which depends on dct.
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=mp3 --enable-dct"
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/ffmpeg/lib/libavcodec.a ]]; then
rm -rf ${SRS_OBJS}/ffmpeg && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/ffmpeg ${SRS_OBJS}/ &&
echo "The ffmpeg-4-fit is ok."
else
echo "Building ffmpeg-4-fit." &&
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/ffmpeg \
${SRS_OBJS}/ffmpeg &&
cp -rf ${SRS_WORKDIR}/3rdparty/ffmpeg-4-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
(
cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit &&
$FFMPEG_CONFIGURE --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdparty/ffmpeg \
--pkg-config=pkg-config --pkg-config-flags='--static' --extra-libs='-lpthread' --extra-libs='-lm' \
${FFMPEG_OPTIONS}
) &&
# See https://www.laoyuyu.me/2019/05/23/android/clang_compile_ffmpeg/
if [[ $SRS_CROSS_BUILD == YES ]]; then
sed -i -e 's/#define getenv(x) NULL/\/\*#define getenv(x) NULL\*\//g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_GMTIME_R 0/#define HAVE_GMTIME_R 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_LOCALTIME_R 0/#define HAVE_LOCALTIME_R 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
# For MIPS, which fail with:
# ./libavutil/libm.h:54:32: error: static declaration of 'cbrt' follows non-static declaration
# /root/openwrt/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/include/math.h:163:13: note: previous declaration of 'cbrt' was here
if [[ $SRS_CROSS_BUILD_ARCH == "mipsel" || $SRS_CROSS_BUILD_ARCH == "arm" || $SRS_CROSS_BUILD_ARCH == "aarch64" ]]; then
sed -i -e 's/#define HAVE_CBRT 0/#define HAVE_CBRT 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_CBRTF 0/#define HAVE_CBRTF 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_COPYSIGN 0/#define HAVE_COPYSIGN 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_ERF 0/#define HAVE_ERF 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_HYPOT 0/#define HAVE_HYPOT 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_RINT 0/#define HAVE_RINT 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_LRINT 0/#define HAVE_LRINT 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_LRINTF 0/#define HAVE_LRINTF 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_ROUND 0/#define HAVE_ROUND 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_ROUNDF 0/#define HAVE_ROUNDF 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_TRUNC 0/#define HAVE_TRUNC 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
sed -i -e 's/#define HAVE_TRUNCF 0/#define HAVE_TRUNCF 1/g' ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/config.h &&
echo "FFmpeg sed ok"
fi
fi &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit ${SRS_JOBS} &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit install &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/ffmpeg ${SRS_OBJS}/ &&
echo "The ffmpeg-4-fit is ok."
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build ffmpeg-4-fit failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2.
#####################################################################################
# Guess where is the ffmpeg.
SYSTEMP_FFMPEG_BIN=`which ffmpeg`
# Always link the ffmpeg tools if exists.
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/
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}"
echo -e "${RED} Please copy it from srs-docker${BLACK}"
echo -e "${RED} or download from http://ffmpeg.org/download.html${BLACK}"
echo -e "${RED} or disable it by --without-ffmpeg${BLACK}"
exit -1;
fi
fi
#####################################################################################
# SRT module, https://github.com/ossrs/srs/issues/1147#issuecomment-577469119
#####################################################################################
if [[ $SRS_SRT == YES && $SRS_USE_SYS_SRT == YES ]]; then
echo "Warning: Use system libsrt, without compiling srt."
fi
if [[ $SRS_SRT == YES && $SRS_USE_SYS_SRT == NO ]]; then
# Always disable c++11 for libsrt, because only the srt-app requres it.
LIBSRT_OPTIONS="--enable-apps=0 --enable-static=1 --enable-c++11=0"
if [[ $SRS_SHARED_SRT == YES ]]; then
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --enable-shared=1"
else
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --enable-shared=0"
fi
# For windows build, over cygwin
if [[ $SRS_CYGWIN64 == YES ]]; then
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix"
fi
# For cross-build.
if [[ $SRS_CROSS_BUILD == YES ]]; then
TOOL_GCC_REALPATH=$(realpath $(which $SRS_TOOL_CC))
SRT_COMPILER_PREFIX=$(echo $TOOL_GCC_REALPATH |sed 's/-gcc.*$/-/')
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --with-compiler-prefix=$SRT_COMPILER_PREFIX"
fi
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srt/lib/libsrt.a ]]; then
rm -rf ${SRS_OBJS}/srt && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srt ${SRS_OBJS}/ &&
echo "libsrt-1-fit is ok."
else
if [[ $SRS_USE_SYS_SSL != YES && ! -d ${SRS_OBJS}/openssl/lib/pkgconfig ]]; then
echo "OpenSSL pkgconfig no found, build srt-1-fit failed."
exit -1
fi
echo "Build srt-1-fit" &&
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srt ${SRS_OBJS}/srt &&
cp -rf ${SRS_WORKDIR}/3rdparty/srt-1-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
patch -p0 -R ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit/srtcore/api.cpp ${SRS_WORKDIR}/3rdparty/patches/srt/api.cpp-01.patch &&
(
cd ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit &&
env PKG_CONFIG_PATH=${SRS_DEPENDS_LIBS}/openssl/lib/pkgconfig \
./configure --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdparty/srt $LIBSRT_OPTIONS
) &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit ${SRS_JOBS} &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit install &&
# If exists lib64 of libsrt, copy it to lib
if [[ -d ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srt/lib64 ]]; then
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srt/lib64 ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srt/lib
fi &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srt ${SRS_OBJS}/ &&
echo "libsrt-1-fit is ok."
fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build srt-1-fit failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# build utest code
#####################################################################################
if [[ $SRS_UTEST == YES ]]; then
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gtest/googletest/include/gtest/gtest.h ]]; then
rm -rf ${SRS_OBJS}/gtest && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gtest ${SRS_OBJS}/ &&
echo "The gtest-fit is ok."
else
echo "Build gtest-fit" &&
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}gtest-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gtest ${SRS_OBJS}/gtest &&
cp -rf ${SRS_WORKDIR}/3rdparty/gtest-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gtest &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gtest ${SRS_OBJS}/ &&
echo "The gtest-fit is ok."
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gtest-1.6.0 failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# build gperf code
#####################################################################################
if [[ $SRS_GPERF == YES ]]; then
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gperf/bin/pprof ]]; then
rm -rf ${SRS_OBJS}/gperf && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gperf ${SRS_OBJS}/ &&
cp -f ${SRS_OBJS}/gperf/bin/pprof ${SRS_OBJS}/ &&
echo "The gperftools-2-fit is ok."
else
echo "Build gperftools-2-fit" &&
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gperf \
${SRS_OBJS}/gperf ${SRS_OBJS}/pprof &&
cp -rf ${SRS_WORKDIR}/3rdparty/gperftools-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
(
cd ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2-fit &&
./configure --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdparty/gperf --enable-frame-pointers
) &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2-fit ${SRS_JOBS} &&
make -C ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2-fit install &&
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/gperf ${SRS_OBJS}/ &&
cp -f ${SRS_OBJS}/gperf/bin/pprof ${SRS_OBJS}/ &&
echo "The gperftools-2-fit is ok."
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gperftools-2-fit failed, ret=$ret"; exit $ret; fi
fi
+6
View File
@@ -0,0 +1,6 @@
ip=`ifconfig 2>&1|grep 'inet addr'|grep -v '127.0.0.1'|awk 'NR==1 {print $2}'|awk -F ':' '{print $2}'`
if [[ -z $ip ]]; then
echo "127.0.0.1"
else
echo $ip
fi
+96
View File
@@ -0,0 +1,96 @@
#
# Generate the module(in src, not modules) info to Makefile
#
# params:
# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
# $SRS_OBJS the objs directory for Makefile. ie. objs
#
# $MODULE_DIR the module dir. ie. src/os/linux
# $MODULE_ID the id of module. ie. CORE
# $MODULE_DEPENDS array, the denpend MODULEs id. ie. (CORE OS)
# $ModuleLibIncs array, the depend 3rdpart library includes. ie. (objs/st-1.9/obj objs/libx264/obj)
# $MODULE_FILES array, the head/cpp files of modules. ie. (public log)
# $DEFINES string, the build macro defines. ie. "-DMY_SRS"
#
# returns:
# $MODULE_OBJS array, the objects of the modules, used for link the binary
FILE=${SRS_OBJS}/Makefile
echo "#####################################################################################" >> ${FILE}
echo "# The module ${MODULE_ID}." >> ${FILE}
echo "#####################################################################################" >> ${FILE}
echo >> ${FILE}
# INCS
echo "# INCS for ${MODULE_ID}, headers of module and its depends to compile" >> ${FILE}
#
# the public include files, for example:
# CORE_MODULE_INCS = -Isrc/core
echo "${MODULE_ID}_MODULE_INCS = -I${SRS_WORKDIR}/${MODULE_DIR} " >> ${FILE}
#
# the private include files, for example:
# CORE_INCS = -Isrc/core -Iobjs
# CORE_LIBS_INCS = -Iobjs/st -Iobjs/ffmpeg/include
# where the public will be used for other modules which depends on it.
INCS_NAME="${MODULE_ID}_INCS"
#
# current module header files
echo -n "${INCS_NAME} = -I${SRS_WORKDIR}/${MODULE_DIR} " >> ${FILE}
#
# depends module header files
for item in ${MODULE_DEPENDS[*]}; do
DEP_INCS_NAME="${item}_MODULE_INCS"
echo -n "\$(${DEP_INCS_NAME})" >> ${FILE}
done
echo "" >> ${FILE}
#
# depends library header files
INCS_LIBS_NAME="${MODULE_ID}_LIBS_INCS"
echo -n "${INCS_LIBS_NAME} = " >> ${FILE}
for item in ${ModuleLibIncs[*]}; do
echo -n "-I${item} " >> ${FILE}
done
echo "" >> ${FILE}; echo "" >> ${FILE}
# DEPS
echo "# DEPS for ${MODULE_ID}, the depends of make schema" >> ${FILE}
# depends on headers of self module, for example:
# CORE_DEPS = src/core/srs_core.hpp
DEPS_NAME="${MODULE_ID}_DEPS"
echo -n "${DEPS_NAME} = " >> ${FILE}
for item in ${MODULE_FILES[*]}; do
HEADER_FILE="${SRS_WORKDIR}/${MODULE_DIR}/${item}.hpp"
if [ -f ${HEADER_FILE} ]; then
echo -n " ${HEADER_FILE}" >> ${FILE}
fi
done
# depends on other modules, for example:
# MAIN_DEPS = $(CORE_DEPS)
for item in ${MODULE_DEPENDS[*]}; do
DEP_DEPS_NAME="${item}_DEPS"
echo -n " \$(${DEP_DEPS_NAME}) " >> ${FILE}
done
echo "" >> ${FILE}; echo "" >> ${FILE}
# OBJ
echo "# OBJ for ${MODULE_ID}, each object file" >> ${FILE}
MODULE_OBJS=()
for item in ${MODULE_FILES[*]}; do
CPP_FILE="${SRS_WORKDIR}/${MODULE_DIR}/${item}.cpp"
OBJ_FILE="${SRS_OBJS}/${MODULE_DIR}/${item}.o"
MODULE_OBJS="${MODULE_OBJS[@]} ${MODULE_DIR}/${item}.cpp"
if [ -f ${CPP_FILE} ]; then
echo "${OBJ_FILE}: \$(${DEPS_NAME}) ${CPP_FILE} " >> ${FILE}
echo " \$(CXX) -c \$(CXXFLAGS) ${DEFINES}\\" >> ${FILE}
echo " \$(${INCS_NAME})\\" >> ${FILE}
echo " \$(${INCS_LIBS_NAME})\\" >> ${FILE}
echo " -o ${OBJ_FILE} \\" >> ${FILE}
echo " ${CPP_FILE}" >> ${FILE}
fi
done
echo "" >> ${FILE}
# parent Makefile, to create module output dir before compile it.
echo " @mkdir -p ${SRS_OBJS}/${MODULE_DIR}" >> ${SRS_MAKEFILE}
echo -n "Generate modules ${MODULE_ID} ok"; echo '!';
+766
View File
@@ -0,0 +1,766 @@
#!/bin/bash
################################################################
help=no
# feature options
SRS_HDS=NO
SRS_SRT=YES
SRS_RTC=YES
SRS_H265=YES
SRS_GB28181=NO
SRS_CXX11=YES
SRS_CXX14=NO
SRS_BACKTRACE=YES
SRS_NGINX=NO
SRS_UTEST=NO
# Always enable the bellow features.
SRS_STREAM_CASTER=YES
SRS_INGEST=YES
SRS_SSL=YES
SRS_SSL_1_0=NO
SRS_SSL_LOCAL=NO
SRS_HTTPS=YES
SRS_STAT=YES
SRS_TRANSCODE=YES
SRS_HTTP_CALLBACK=YES
SRS_HTTP_SERVER=YES
SRS_HTTP_API=YES
SRS_HTTP_CORE=YES
SRS_HLS=YES
SRS_DVR=YES
#
################################################################
# FFmpeg stub is the stub code in SRS for ingester or encoder.
SRS_FFMPEG_STUB=NO
# FFmpeg tool is the binary for FFmpeg tool, to exec ingest or transcode.
SRS_FFMPEG_TOOL=NO
# FFmpeg fit is the source code for RTC, to transcode audio or video in SRS.
SRS_FFMPEG_FIT=RESERVED
# Whether use FFmpeg native opus codec for RTC. If not, use libopus instead.
# Should disable it by default, because the cost of it is very high, see https://github.com/ossrs/srs/pull/3868
SRS_FFMPEG_OPUS=NO
# arguments
SRS_PREFIX=/usr/local/srs
SRS_DEFAULT_CONFIG=conf/srs.conf
SRS_JOBS=1
# If enabled, force to use SRS_JOBS for make on linux, however you're able to overwrite by -jN on macOS.
SRS_FORCE_MAKE_JOBS=YES
SRS_STATIC=NO
# If enabled, link shared libraries for libst.so which uses MPL license.
# See https://ossrs.net/lts/zh-cn/license#state-threads
SRS_SHARED_ST=NO
# If enabled, link shared libraries for libsrt.so which uses MPL license.
# See https://ossrs.net/lts/zh-cn/license#srt
SRS_SHARED_SRT=RESERVED
# If enabled, link shared libraries for FFmpeg which is LGPL license.
# See https://ossrs.net/lts/zh-cn/license#ffmpeg
SRS_SHARED_FFMPEG=RESERVED
# If enabled, link shared libraries for SRTP which is BSD license.
# See https://ossrs.net/lts/zh-cn/license#srtp
SRS_SHARED_SRTP=RESERVED
# whether enable the gcov
SRS_GCOV=NO
# Whether enable cloud logging and APM(Application Performance Monitor).
SRS_APM=NO
# whether enable the log verbose/info/trace level.
# always enable the warn/error level.
SRS_LOG_VERBOSE=NO
SRS_LOG_INFO=NO
SRS_LOG_TRACE=YES
# Whether use new level definition, see https://stackoverflow.com/a/2031209/17679565
SRS_LOG_LEVEL_V2=YES
#
################################################################
# Experts options.
SRS_USE_SYS_SSL=NO # Use system ssl(-lssl) if required.
SRS_USE_SYS_FFMPEG=NO # Use system ffmpeg if required.
SRS_USE_SYS_SRT=NO # Use system srt(-lsrt) if required.
SRS_USE_SYS_SRTP=NO # Use system srtp(-lsrtp) if required.
SRS_VALGRIND=NO
SRS_SANITIZER=RESERVED
SRS_SANITIZER_STATIC=NO
SRS_SANITIZER_LOG=NO
SRS_BUILD_TAG= # Set the object files tag name.
SRS_CLEAN=YES # Whether do "make clean" when configure.
SRS_SIMULATOR=NO # Whether enable RTC simulate API.
SRS_GENERATE_OBJS=NO # Whether generate objs and quit.
SRS_SINGLE_THREAD=YES # Whether force single thread mode.
SRS_SIGNAL_API=NO # Use http API to simulate sending signal to SRS, for debugging.
#
################################################################
# Performance options.
SRS_GPERF=NO # Performance test: tcmalloc
SRS_GPERF_MC=NO # Performance test: gperf memory check
SRS_GPERF_MD=NO # Performance test: gperf memory defence
SRS_GPERF_MP=NO # Performance test: gperf memory profile
SRS_GPERF_CP=NO # Performance test: gperf cpu profile
SRS_GPROF=NO # Performance test: gprof
#
################################################################
# Preset options
SRS_GENERIC_LINUX= # Try to run as generic linux, not CentOS or Ubuntu.
SRS_OSX= #For OSX/macOS/Darwin PC.
SRS_CYGWIN64= # For Cygwin64 for Windows PC or servers.
SRS_CROSS_BUILD= #For cross build, for example, on Ubuntu.
# For cross build, the cpu, for example(FFmpeg), --cpu=24kc
SRS_CROSS_BUILD_CPU=
# For cross build, the arch, for example(FFmpeg), --arch=aarch64
SRS_CROSS_BUILD_ARCH=
# For cross build, the host, for example(libsrtp), --host=aarch64-linux-gnu
SRS_CROSS_BUILD_HOST=
# For cross build, the cross prefix, for example(FFmpeg), --cross-prefix=aarch64-linux-gnu-
SRS_CROSS_BUILD_PREFIX=
# For cache build
SRS_BUILD_CACHE=YES
#
#####################################################################################
# Toolchain for cross-build on Ubuntu for ARM or MIPS.
SRS_TOOL_CC=gcc
SRS_TOOL_CXX=g++
SRS_TOOL_AR=ar
SRS_TOOL_LD=ld
SRS_TOOL_RANDLIB=randlib
SRS_EXTRA_FLAGS=
SRS_EXTRA_LDFLAGS=
#
#####################################################################################
# Performance optimize.
SRS_NASM=YES
SRS_SRTP_ASM=YES
SRS_DEBUG=NO
SRS_DEBUG_STATS=NO
#####################################################################################
function apply_system_options() {
OS_IS_OSX=$(uname -s |grep -q Darwin && echo YES)
OS_IS_LINUX=$(uname -s |grep -q Linux && echo YES)
OS_IS_CYGWIN=$(uname -s |grep -q CYGWIN && echo YES)
OS_IS_CENTOS=$(yum --version >/dev/null 2>&1 && echo YES)
# For Debian, we think it's ubuntu also.
# For example, the wheezy/sid which is debian armv7 linux, can not identified by uname -v.
OS_IS_UBUNTU=$(apt-get --version >/dev/null 2>&1 && echo YES)
OS_IS_LOONGSON=$(uname -r |grep -q loongson && echo YES)
# Use gcc to detect the CPU arch.
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then echo "Please install gcc"; exit 1; fi
OS_IS_LOONGARCH64=$(gcc -dM -E - </dev/null |grep '#define __loongarch64 1' -q && echo YES)
OS_IS_MIPS64=$(gcc -dM -E - </dev/null |grep '#define __mips64 1' -q && echo YES)
OS_IS_X86_64=$(gcc -dM -E - </dev/null |grep -q '#define __x86_64 1' && echo YES)
OS_IS_RISCV=$(gcc -dM -E - </dev/null |grep -q '#define __riscv 1' && echo YES)
# Set the os option automatically.
if [[ $OS_IS_OSX == YES ]]; then SRS_OSX=YES; fi
if [[ $OS_IS_CYGWIN == YES ]]; then SRS_CYGWIN64=YES; fi
if [[ $OS_IS_OSX == YES ]]; then SRS_JOBS=$(sysctl -n hw.ncpu 2>/dev/null || echo 1); fi
if [[ $OS_IS_LINUX == YES || $OS_IS_CYGWIN == YES ]]; then
SRS_JOBS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || echo 1)
fi
if [[ $OS_IS_UBUNTU != YES && $OS_IS_CENTOS != YES && $OS_IS_OSX != YES && $SRS_CYGWIN64 != YES ]]; then
echo "Warning: Your OS is not Ubuntu(no apt-get), CentOS(no yum), maxOS(not Darwin), Windows(not CYGWIN)"
fi
}
apply_system_options
#####################################################################################
# Show help menu.
#####################################################################################
function show_help() {
cat << END
Configure to generate Makefile.
-h, --help Print this message and exit 0.
Features:
--https=on|off Whether enable HTTPS client and server. Default: $(value2switch $SRS_HTTPS)
--utest=on|off Whether build the utest. Default: $(value2switch $SRS_UTEST)
--srt=on|off Whether build the SRT. Default: $(value2switch $SRS_SRT)
--rtc=on|off Whether build the WebRTC. Default: $(value2switch $SRS_RTC)
--gb28181=on|off Whether build the GB28181. Default: $(value2switch $SRS_GB28181)
--cxx11=on|off Whether enable the C++11. Default: $(value2switch $SRS_CXX11)
--cxx14=on|off Whether enable the C++14. Default: $(value2switch $SRS_CXX14)
--ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
--ffmpeg-opus=on|off Whether enable the FFmpeg native opus codec. Default: $(value2switch $SRS_FFMPEG_OPUS)
--apm=on|off Whether enable cloud logging and APM(Application Performance Monitor). Default: $(value2switch $SRS_APM)
--h265=on|off Whether build the HEVC(H.265) support. Default: $(value2switch $SRS_H265)
--prefix=<path> The absolute installation path. Default: $SRS_PREFIX
--jobs[=N] Allow N jobs at once; infinite jobs with no arg. Default: $SRS_JOBS
--config=<path> The default config file for SRS. Default: $SRS_DEFAULT_CONFIG
Performance: @see https://ossrs.net/lts/zh-cn/docs/v5/doc/performance
--valgrind=on|off Whether build valgrind for memory check. Default: $(value2switch $SRS_VALGRIND)
--gperf=on|off Whether build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only). Default: $(value2switch $SRS_GPERF)
--gmc=on|off Whether build memory check with gperf tools. Default: $(value2switch $SRS_GPERF_MC)
--gmd=on|off Whether build memory defense(corrupt memory) with gperf tools. Default: $(value2switch $SRS_GPERF_MD)
--gmp=on|off Whether build memory profile with gperf tools. Default: $(value2switch $SRS_GPERF_MP)
--gcp=on|off Whether build cpu profile with gperf tools. Default: $(value2switch $SRS_GPERF_CP)
--gprof=on|off Whether build SRS with gprof(GNU profile tool). Default: $(value2switch $SRS_GPROF)
--sanitizer=on|off Whether build SRS with address sanitizer(asan). Default: $(value2switch $SRS_SANITIZER)
--sanitizer-static=on|off Whether build SRS with static libasan(asan). Default: $(value2switch $SRS_SANITIZER_STATIC)
--sanitizer-log=on|off Whether hijack the log for libasan(asan). Default: $(value2switch $SRS_SANITIZER_LOG)
--nasm=on|off Whether build FFMPEG for RTC with nasm. Default: $(value2switch $SRS_NASM)
--srtp-nasm=on|off Whether build SRTP with ASM(openssl-asm), requires RTC and openssl-1.0.*. Default: $(value2switch $SRS_SRTP_ASM)
Toolchain options:
--static=on|off Whether add '-static' to link options. Default: $(value2switch $SRS_STATIC)
--cc=<CC> Toolchain: Use c compiler CC. Default: $SRS_TOOL_CC
--cxx=<CXX> Toolchain: Use c++ compiler CXX. Default: $SRS_TOOL_CXX
--ar=<AR> Toolchain: Use archive tool AR. Default: $SRS_TOOL_CXX
--ld=<LD> Toolchain: Use linker tool LD. Default: $SRS_TOOL_CXX
--randlib=<RANDLIB> Toolchain: Use randlib tool RANDLIB. Default: $SRS_TOOL_CXX
--extra-flags=<EFLAGS> Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS.
--extra-ldflags=<ELDFLAGS> Set ELDFLAGS as LDFLAGS.
Cross Build options: @see https://ossrs.net/lts/zh-cn/docs/v4/doc/arm#ubuntu-cross-build-srs
--cross=on|off Enable cross-build, please set bellow Toolchain also. Default: $(value2switch $SRS_CROSS_BUILD)
--cpu=<CPU> Toolchain: Select the minimum required CPU for cross-build. For example: --cpu=24kc
--arch=<ARCH> Toolchain: Select architecture for cross-build. For example: --arch=aarch64
--host=<BUILD> Toolchain: Cross-compile to build programs to run on HOST. For example: --host=aarch64-linux-gnu
--cross-prefix=<PREFIX> Toolchain: Use PREFIX for compilation tools. For example: --cross-prefix=aarch64-linux-gnu-
Experts:
--sys-ssl=on|off Do not compile ssl, use system ssl(-lssl) if required. Default: $(value2switch $SRS_USE_SYS_SSL)
--ssl-1-0=on|off Whether use openssl-1.0.*. Default: $(value2switch $SRS_SSL_1_0)
--ssl-local=on|off Whether use local openssl, not system even exists. Default: $(value2switch $SRS_SSL_LOCAL)
--shared-st=on|off Use shared libraries for ST which is MPL license. Default: $(value2switch $SRS_SHARED_ST)
--shared-srt=on|off Use shared libraries for SRT which is MPL license. Default: $(value2switch $SRS_SHARED_SRT)
--sys-srt=on|off Do not compile srt, use system srt(-lsrt) if required. Default: $(value2switch $SRS_USE_SYS_SRT)
--shared-ffmpeg=on|off Use shared libraries for FFmpeg which is LGPL license. Default: $(value2switch $SRS_SHARED_FFMPEG)
--sys-ffmpeg=on|off Do not compile ffmpeg, use system ffmpeg if required. Default: $(value2switch $SRS_USE_SYS_FFMPEG)
--sys-srtp=on|off Do not compile srtp, use system srtp(-lsrtp) if required. Default: $(value2switch $SRS_USE_SYS_SRTP)
--shared-srtp=on|off Use shared libraries for SRTP which is BSD license. Default: $(value2switch $SRS_SHARED_SRTP)
--clean=on|off Whether do 'make clean' when configure. Default: $(value2switch $SRS_CLEAN)
--simulator=on|off RTC: Whether enable network simulator. Default: $(value2switch $SRS_SIMULATOR)
--generate-objs=on|off RTC: Whether generate objs and quit. Default: $(value2switch $SRS_GENERATE_OBJS)
--single-thread=on|off Whether force single thread mode. Default: $(value2switch $SRS_SINGLE_THREAD)
--signal-api=on|off Whether support sending signal by HTTP API. Default: $(value2switch $SRS_SIGNAL_API)
--build-tag=<TAG> Set the build object directory suffix.
--debug=on|off Whether enable the debug code, may hurt performance. Default: $(value2switch $SRS_DEBUG)
--debug-stats=on|off Whether enable the debug stats, may hurt performance. Default: $(value2switch $SRS_DEBUG_STATS)
--gcov=on|off Whether enable the GCOV for coverage. Default: $(value2switch $SRS_GCOV)
--log-verbose=on|off Whether enable the log verbose level. Default: $(value2switch $SRS_LOG_VERBOSE)
--log-info=on|off Whether enable the log info level. Default: $(value2switch $SRS_LOG_INFO)
--log-trace=on|off Whether enable the log trace level. Default: $(value2switch $SRS_LOG_TRACE)
--log-level_v2=on|off Whether use v2.0 log level definition, see log4j specs. Default: $(value2switch $SRS_LOG_LEVEL_V2)
--backtrace=on|off Whether show backtrace when crashing. Default: $(value2switch $SRS_BACKTRACE)
--generic-linux=on|off Whether run as generic linux, if not CentOS or Ubuntu. Default: $(value2switch $SRS_GENERIC_LINUX)
Deprecated:
--cross-build Enable cross-build, please set bellow Toolchain also. Default: $(value2switch $SRS_CROSS_BUILD)
--hds=on|off Whether build the hds streaming, mux RTMP to F4M/F4V files. Default: $(value2switch $SRS_HDS)
--osx Enable build for OSX/Darwin AppleOS. Deprecated for automatically detecting the OS.
--x86-64 Enable build for __x86_64 systems. Deprecated for automatically detecting the OS.
--x86-x64 Enable build for __x86_64 systems. Deprecated for automatically detecting the OS.
--cygwin64 Use cygwin64 to build for Windows. Deprecated for automatically detecting the OS.
--nginx Build nginx tool. Deprecated for not depends on it.
--ffmpeg Build FFmpeg tool. Deprecated for not build it, user should do it.
For example:
./configure
END
}
#####################################################################################
# Parse user options
#####################################################################################
function parse_user_option() {
# Ignore the options.
if [[ $option == '--demo' || $option == '--dev' || $option == '--fast-dev' || $option == '--pi'
|| $option == '--cubie' || $option == '--fast' || $option == '--pure-rtmp' || $option == '--disable-all'
|| $option == '--full' || $option == '--with-http-callback' || $option == '--without-http-callback'
|| $option == '--http-callback' || $option == '--with-http-api' || $option == '--without-http-api'
|| $option == '--http-api' || $option == '--with-http-server' || $option == '--without-http-server'
|| $option == '--http-server' || $option == '--with-hls' || $option == '--without-hls'
|| $option == '--hls' || $option == '--with-dvr' || $option == '--without-dvr'
|| $option == '--dvr' || $option == '--without-transcode' || $option == '--without-ingest'
|| $option == '--without-stat' || $option == '--without-stream-caster' || $option == '--without-ssl'
|| $option == '--without-librtmp' || ($option == '--librtmp' && $(switch2value $value) == NO)
|| $option == '--without-research' || ($option == '--research' && $(switch2value $value) == NO)
]]; then
echo "Ignore option $option $value"; return 0;
fi
# if specified export single file, export project first.
if [[ $option == '--export-librtmp-single' || $option == '--export-librtmp-project' || $option == '--with-librtmp' || $option == '--librtmp' ]]; then
echo "Error: The $option is not supported yet, please read https://github.com/ossrs/srs-librtmp/issues/32"; exit 1
fi
if [[ $option == '--with-research' || $option == '--research' ]]; then
echo "Error: The $option is not supported yet"; exit 1
fi
if [[ $option == '--arm' || $option == '--mips' || $option == '--with-arm-ubuntu12' || $option == '--with-mips-ubuntu12' ]]; then
echo "Error: Removed misleading option $option, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/arm#ubuntu-cross-build-srs"
exit -1
fi
# Parse options to variables.
case "$option" in
-h) help=YES ;;
--help) help=YES ;;
--jobs) SRS_JOBS=${value} ;;
--force-make-jobs) SRS_FORCE_MAKE_JOBS=${value} ;;
--prefix) SRS_PREFIX=${value} ;;
--config) SRS_DEFAULT_CONFIG=${value} ;;
--static) SRS_STATIC=$(switch2value $value) ;;
--cpu) SRS_CROSS_BUILD_CPU=${value} ;;
--arch) SRS_CROSS_BUILD_ARCH=${value} ;;
--host) SRS_CROSS_BUILD_HOST=${value} ;;
--cross-prefix) SRS_CROSS_BUILD_PREFIX=${value} ;;
--cc) SRS_TOOL_CC=${value} ;;
--cxx) SRS_TOOL_CXX=${value} ;;
--ar) SRS_TOOL_AR=${value} ;;
--ld) SRS_TOOL_LD=${value} ;;
--randlib) SRS_TOOL_RANDLIB=${value} ;;
--extra-flags) SRS_EXTRA_FLAGS=${value} ;;
--extra-ldflags) SRS_EXTRA_LDFLAGS=${value} ;;
--build-tag) SRS_BUILD_TAG=${value} ;;
--srtp-nasm) SRS_SRTP_ASM=$(switch2value $value) ;;
--nasm) SRS_NASM=$(switch2value $value) ;;
--ssl) SRS_SSL=$(switch2value $value) ;;
--https) SRS_HTTPS=$(switch2value $value) ;;
--ssl-1-0) SRS_SSL_1_0=$(switch2value $value) ;;
--ssl-local) SRS_SSL_LOCAL=$(switch2value $value) ;;
--hds) SRS_HDS=$(switch2value $value) ;;
--transcode) SRS_TRANSCODE=$(switch2value $value) ;;
--ingest) SRS_INGEST=$(switch2value $value) ;;
--stat) SRS_STAT=$(switch2value $value) ;;
--stream-caster) SRS_STREAM_CASTER=$(switch2value $value) ;;
--stream-converter) SRS_STREAM_CASTER=$(switch2value $value) ;;
--utest) SRS_UTEST=$(switch2value $value) ;;
--gcov) SRS_GCOV=$(switch2value $value) ;;
--apm) SRS_APM=$(switch2value $value) ;;
--srt) SRS_SRT=$(switch2value $value) ;;
--rtc) SRS_RTC=$(switch2value $value) ;;
--simulator) SRS_SIMULATOR=$(switch2value $value) ;;
--generate-objs) SRS_GENERATE_OBJS=$(switch2value $value) ;;
--single-thread) SRS_SINGLE_THREAD=$(switch2value $value) ;;
--signal-api) SRS_SIGNAL_API=$(switch2value $value) ;;
--ffmpeg-fit) SRS_FFMPEG_FIT=$(switch2value $value) ;;
--ffmpeg-opus) SRS_FFMPEG_OPUS=$(switch2value $value) ;;
--h265) SRS_H265=$(switch2value $value) ;;
--gb28181) SRS_GB28181=$(switch2value $value) ;;
--cxx11) SRS_CXX11=$(switch2value $value) ;;
--cxx14) SRS_CXX14=$(switch2value $value) ;;
--backtrace) SRS_BACKTRACE=$(switch2value $value) ;;
--clean) SRS_CLEAN=$(switch2value $value) ;;
--gperf) SRS_GPERF=$(switch2value $value) ;;
--gmc) SRS_GPERF_MC=$(switch2value $value) ;;
--gmd) SRS_GPERF_MD=$(switch2value $value) ;;
--gmp) SRS_GPERF_MP=$(switch2value $value) ;;
--gcp) SRS_GPERF_CP=$(switch2value $value) ;;
--gprof) SRS_GPROF=$(switch2value $value) ;;
--sanitizer) SRS_SANITIZER=$(switch2value $value) ;;
--sanitizer-static) SRS_SANITIZER_STATIC=$(switch2value $value) ;;
--sanitizer-log) SRS_SANITIZER_LOG=$(switch2value $value) ;;
--use-sys-ssl) SRS_USE_SYS_SSL=YES ;;
--sys-ssl) SRS_USE_SYS_SSL=$(switch2value $value) ;;
--use-shared-st) SRS_SHARED_ST=YES ;;
--use-shared-srt) SRS_SHARED_SRT=YES ;;
--shared-st) SRS_SHARED_ST=$(switch2value $value) ;;
--shared-srt) SRS_SHARED_SRT=$(switch2value $value) ;;
--use-sys-srt) SRS_USE_SYS_SRT=YES ;;
--sys-srt) SRS_USE_SYS_SRT=$(switch2value $value) ;;
--shared-ffmpeg) SRS_SHARED_FFMPEG=$(switch2value $value) ;;
--use-sys-ffmpeg) SRS_USE_SYS_FFMPEG=YES ;;
--sys-ffmpeg) SRS_USE_SYS_FFMPEG=$(switch2value $value) ;;
--shared-srtp) SRS_SHARED_SRTP=$(switch2value $value) ;;
--use-sys-srtp) SRS_USE_SYS_SRTP=YES ;;
--sys-srtp) SRS_USE_SYS_SRTP=$(switch2value $value) ;;
--valgrind) SRS_VALGRIND=$(switch2value $value) ;;
--log-verbose) SRS_LOG_VERBOSE=$(switch2value $value) ;;
--log-info) SRS_LOG_INFO=$(switch2value $value) ;;
--log-trace) SRS_LOG_TRACE=$(switch2value $value) ;;
--log-level_v2) SRS_LOG_LEVEL_V2=$(switch2value $value) ;;
--debug) SRS_DEBUG=$(switch2value $value) ;;
--debug-stats) SRS_DEBUG_STATS=$(switch2value $value) ;;
--cross-build) SRS_CROSS_BUILD=YES ;;
--generic-linux) SRS_GENERIC_LINUX=$(switch2value $value) ;;
--build-cache) SRS_BUILD_CACHE=$(switch2value $value) ;;
##########################################################################################
--without-srtp-nasm) SRS_SRTP_ASM=NO ;; # Deprecated, might be removed in future.
--with-srtp-nasm) SRS_SRTP_ASM=YES ;; # Deprecated, might be removed in future.
--without-nasm) SRS_NASM=NO ;; # Deprecated, might be removed in future.
--with-nasm) SRS_NASM=YES ;; # Deprecated, might be removed in future.
--with-ssl) SRS_SSL=YES ;; # Deprecated, might be removed in future.
--with-hds) SRS_HDS=YES ;; # Deprecated, might be removed in future.
--without-hds) SRS_HDS=NO ;; # Deprecated, might be removed in future.
--with-transcode) SRS_TRANSCODE=YES ;; # Deprecated, might be removed in future.
--with-ingest) SRS_INGEST=YES ;; # Deprecated, might be removed in future.
--with-stat) SRS_STAT=YES ;; # Deprecated, might be removed in future.
--with-stream-caster) SRS_STREAM_CASTER=YES ;; # Deprecated, might be removed in future.
--with-utest) SRS_UTEST=YES ;; # Deprecated, might be removed in future.
--without-utest) SRS_UTEST=NO ;; # Deprecated, might be removed in future.
--with-srt) SRS_SRT=YES ;; # Deprecated, might be removed in future.
--without-srt) SRS_SRT=NO ;; # Deprecated, might be removed in future.
--with-rtc) SRS_RTC=YES ;; # Deprecated, might be removed in future.
--without-rtc) SRS_RTC=NO ;; # Deprecated, might be removed in future.
--with-clean) SRS_CLEAN=YES ;; # Deprecated, might be removed in future.
--without-clean) SRS_CLEAN=NO ;; # Deprecated, might be removed in future.
--with-gperf) SRS_GPERF=YES ;; # Deprecated, might be removed in future.
--without-gperf) SRS_GPERF=NO ;; # Deprecated, might be removed in future.
--with-gmc) SRS_GPERF_MC=YES ;; # Deprecated, might be removed in future.
--without-gmc) SRS_GPERF_MC=NO ;; # Deprecated, might be removed in future.
--with-gmd) SRS_GPERF_MD=YES ;; # Deprecated, might be removed in future.
--without-gmd) SRS_GPERF_MD=NO ;; # Deprecated, might be removed in future.
--with-gmp) SRS_GPERF_MP=YES ;; # Deprecated, might be removed in future.
--without-gmp) SRS_GPERF_MP=NO ;; # Deprecated, might be removed in future.
--with-gcp) SRS_GPERF_CP=YES ;; # Deprecated, might be removed in future.
--without-gcp) SRS_GPERF_CP=NO ;; # Deprecated, might be removed in future.
--with-gprof) SRS_GPROF=YES ;; # Deprecated, might be removed in future.
--without-gprof) SRS_GPROF=NO ;; # Deprecated, might be removed in future.
--with-valgrind) SRS_VALGRIND=YES ;; # Deprecated, might be removed in future.
--without-valgrind) SRS_VALGRIND=NO ;; # Deprecated, might be removed in future.
--cross) SRS_CROSS_BUILD=$(switch2value $value) ;; # Deprecated, might be removed in future.
--enable-cross-compile) SRS_CROSS_BUILD=YES ;; # Deprecated, might be removed in future.
##########################################################################################
--osx) SRS_OSX=YES ;; # Deprecated, might be removed in future.
--cygwin64) SRS_CYGWIN64=YES ;; # Deprecated, might be removed in future.
--x86-x64) SRS_X86_X64=YES ;; # Deprecated, might be removed in future.
--x86-64) SRS_X86_X64=YES ;; # Deprecated, might be removed in future.
--with-nginx) SRS_NGINX=YES ;; # Deprecated, might be removed in future.
--without-nginx) SRS_NGINX=NO ;; # Deprecated, might be removed in future.
--nginx) SRS_NGINX=$(switch2value $value) ;; # Deprecated, might be removed in future.
--with-ffmpeg) SRS_FFMPEG_TOOL=YES ;; # Deprecated, might be removed in future.
--without-ffmpeg) SRS_FFMPEG_TOOL=NO ;; # Deprecated, might be removed in future.
--ffmpeg) SRS_FFMPEG_TOOL=$(switch2value $value) ;; # Deprecated, might be removed in future.
--ffmpeg-tool) SRS_FFMPEG_TOOL=$(switch2value $value) ;; # Deprecated, might be removed in future.
*)
echo "$0: error: invalid option \"$option\""
exit 1
;;
esac
}
function parse_user_option_to_value_and_option() {
case "$option" in
-*=*)
value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'`
option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/. +,=]*||'`
;;
*) value="" ;;
esac
}
# For variable values, might be three values: YES, RESERVED, NO(by default).
function value2switch() {
if [[ $1 == YES ]]; then
echo on;
elif [[ $1 == RESERVED ]]; then
echo reserved;
else
echo off;
fi
}
# For user options, only off or on(by default).
function switch2value() {
if [[ $1 == off ]]; then
echo NO;
else
echo YES;
fi
}
opt=
for option
do
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 auto options
#####################################################################################
function apply_auto_options() {
if [[ $OS_IS_CYGWIN == YES ]]; then
SRS_CYGWIN64=YES
fi
if [[ $SRS_CROSS_BUILD == YES ]]; then
if [[ $SRS_CROSS_BUILD_PREFIX != "" && $SRS_CROSS_BUILD_HOST == "" ]]; then
SRS_CROSS_BUILD_HOST=$(echo $SRS_CROSS_BUILD_PREFIX| sed 's/-$//g')
fi
if [[ $SRS_TOOL_CC != "" && $SRS_CROSS_BUILD_HOST == "" ]]; then
SRS_CROSS_BUILD_HOST=$(echo $SRS_TOOL_CC| sed 's/-gcc$//g')
fi
if [[ $SRS_CROSS_BUILD_PREFIX == "" ]]; then
SRS_CROSS_BUILD_PREFIX="${SRS_CROSS_BUILD_HOST}-"
fi
SRS_TOOL_CC=${SRS_CROSS_BUILD_PREFIX}gcc
SRS_TOOL_CXX=${SRS_CROSS_BUILD_PREFIX}g++
SRS_TOOL_AR=${SRS_CROSS_BUILD_PREFIX}ar
SRS_TOOL_LD=${SRS_CROSS_BUILD_PREFIX}ld
SRS_TOOL_RANDLIB=${SRS_CROSS_BUILD_PREFIX}randlib
if [[ $SRS_CROSS_BUILD_ARCH == "" ]]; then
echo $SRS_TOOL_CC| grep arm >/dev/null 2>&1 && SRS_CROSS_BUILD_ARCH="arm"
echo $SRS_TOOL_CC| grep aarch64 >/dev/null 2>&1 && SRS_CROSS_BUILD_ARCH="aarch64"
echo $SRS_TOOL_CC| grep mipsel >/dev/null 2>&1 && SRS_CROSS_BUILD_ARCH="mipsel"
fi
echo "For cross build, host: $SRS_CROSS_BUILD_HOST, prefix: $SRS_CROSS_BUILD_PREFIX, arch: $SRS_CROSS_BUILD_ARCH, cpu: $SRS_CROSS_BUILD_CPU gcc: $SRS_TOOL_CC"
fi
if [[ $SRS_OSX == YES ]]; then
SRS_TOOL_LD=$SRS_TOOL_CC
fi
# Enable FFmpeg fit for RTC to transcode audio from AAC to OPUS, if user enabled it.
if [[ $SRS_RTC == YES && $SRS_FFMPEG_FIT == RESERVED ]]; then
SRS_FFMPEG_FIT=YES
fi
if [[ $SRS_USE_SYS_FFMPEG == YES && $SRS_SHARED_FFMPEG == RESERVED ]]; then
SRS_SHARED_FFMPEG=YES
fi
if [[ $SRS_CROSS_BUILD == YES && $SRS_FFMPEG_OPUS != YES ]]; then
echo "Enable FFmpeg native opus for cross building"
SRS_FFMPEG_OPUS=YES
fi
if [[ $SRS_USE_SYS_SRT == YES && $SRS_SHARED_SRT == RESERVED ]]; then
SRS_SHARED_SRT=YES
fi
if [[ $SRS_USE_SYS_SRTP == YES && $SRS_SHARED_SRTP == RESERVED ]]; then
SRS_SHARED_SRTP=YES
fi
# Enable asan, but disable for Centos
# @see https://github.com/ossrs/srs/issues/3347
if [[ $SRS_SANITIZER == RESERVED && $OS_IS_CENTOS != YES ]]; then
echo "Enable asan by auto options."
SRS_SANITIZER=YES
fi
# If enable gperf, disable sanitizer.
if [[ $SRS_GPERF == YES && $SRS_SANITIZER == YES ]]; then
echo "Disable sanitizer for gperf"
SRS_SANITIZER=NO
fi
# if transcode/ingest specified, requires the ffmpeg stub classes.
SRS_FFMPEG_STUB=NO
if [[ $SRS_TRANSCODE == YES ]]; then SRS_FFMPEG_STUB=YES; fi
if [[ $SRS_INGEST == YES ]]; then SRS_FFMPEG_STUB=YES; fi
if [[ $SRS_SRTP_ASM == YES && $SRS_RTC == NO ]]; then
echo "Disable SRTP-ASM, because RTC is disabled."
SRS_SRTP_ASM=NO
fi
if [[ $SRS_SRTP_ASM == YES && $SRS_NASM == NO ]]; then
echo "Disable SRTP-ASM, because NASM is disabled."
SRS_SRTP_ASM=NO
fi
# TODO: FIXME: Should build address sanitizer for cygwin64.
# See https://github.com/ossrs/srs/issues/3252
if [[ $SRS_CYGWIN64 == YES && $SRS_SANITIZER == YES ]]; then
echo "Disable address sanitizer for cygwin64"
SRS_SANITIZER=NO
fi
# TODO: FIXME: Should fix bug for SRT for cygwin64. Build ok, but fail in SrsSrtSocket::accept.
# See https://github.com/ossrs/srs/issues/3251
if [[ $SRS_CYGWIN64 == YES && $SRS_SRT == YES ]]; then
echo "Disable SRT for cygwin64"
SRS_SRT=NO
fi
# TODO: FIXME: Cygwin: ST stuck when working in multiple threads mode.
# See https://github.com/ossrs/srs/issues/3253
if [[ $SRS_CYGWIN64 == YES && $SRS_SINGLE_THREAD != YES ]]; then
echo "Force single thread for cygwin64"
SRS_SINGLE_THREAD=YES
fi
# parse the jobs for make
if [[ ! -z SRS_JOBS ]]; then
export SRS_JOBS="--jobs=${SRS_JOBS}"
fi
}
apply_auto_options
#####################################################################################
# Apply detail options
#####################################################################################
function apply_detail_options() {
# Always enable HTTP utilies.
if [[ $SRS_HTTP_CORE == NO ]]; then SRS_HTTP_CORE=YES; echo -e "${YELLOW}[WARN] Always enable HTTP utilies.${BLACK}"; fi
if [[ $SRS_STREAM_CASTER == NO ]]; then SRS_STREAM_CASTER=YES; echo -e "${YELLOW}[WARN] Always enable StreamConverter.${BLACK}"; fi
if [[ $SRS_INGEST == NO ]]; then SRS_INGEST=YES; echo -e "${YELLOW}[WARN] Always enable Ingest.${BLACK}"; fi
if [[ $SRS_SSL == NO ]]; then SRS_SSL=YES; echo -e "${YELLOW}[WARN] Always enable SSL.${BLACK}"; fi
if [[ $SRS_STAT == NO ]]; then SRS_STAT=YES; echo -e "${YELLOW}[WARN] Always enable Statistic.${BLACK}"; fi
if [[ $SRS_TRANSCODE == NO ]]; then SRS_TRANSCODE=YES; echo -e "${YELLOW}[WARN] Always enable Transcode.${BLACK}"; fi
if [[ $SRS_HTTP_CALLBACK == NO ]]; then SRS_HTTP_CALLBACK=YES; echo -e "${YELLOW}[WARN] Always enable HTTP callback.${BLACK}"; fi
if [[ $SRS_HTTP_SERVER == NO ]]; then SRS_HTTP_SERVER=YES; echo -e "${YELLOW}[WARN] Always enable HTTP server.${BLACK}"; fi
if [[ $SRS_HTTP_API == NO ]]; then SRS_HTTP_API=YES; echo -e "${YELLOW}[WARN] Always enable HTTP API.${BLACK}"; fi
if [[ $SRS_HLS == NO ]]; then SRS_HLS=YES; echo -e "${YELLOW}[WARN] Always enable HLS.${BLACK}"; fi
if [[ $SRS_DVR == NO ]]; then SRS_DVR=YES; echo -e "${YELLOW}[WARN] Always enable DVR.${BLACK}"; fi
if [[ $SRS_SANITIZER == RESERVED ]]; then SRS_SANITIZER=NO; fi
}
apply_detail_options
#####################################################################################
# Regenerate options for tracing.
#####################################################################################
function regenerate_options() {
# save all config options to macro to write to auto headers file
SRS_AUTO_USER_CONFIGURE=`echo $opt`
# regenerate the options for default values.
SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --config=$SRS_DEFAULT_CONFIG"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --osx=$(value2switch $SRS_OSX)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --hls=$(value2switch $SRS_HLS)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --hds=$(value2switch $SRS_HDS)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --dvr=$(value2switch $SRS_DVR)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ssl=$(value2switch $SRS_SSL)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --https=$(value2switch $SRS_HTTPS)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ssl-1-0=$(value2switch $SRS_SSL_1_0)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ssl-local=$(value2switch $SRS_SSL_LOCAL)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sys-ssl=$(value2switch $SRS_USE_SYS_SSL)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --transcode=$(value2switch $SRS_TRANSCODE)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ingest=$(value2switch $SRS_INGEST)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --stat=$(value2switch $SRS_STAT)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-callback=$(value2switch $SRS_HTTP_CALLBACK)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-server=$(value2switch $SRS_HTTP_SERVER)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --stream-converter=$(value2switch $SRS_STREAM_CASTER)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-api=$(value2switch $SRS_HTTP_API)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --utest=$(value2switch $SRS_UTEST)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srt=$(value2switch $SRS_SRT)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sys-srt=$(value2switch $SRS_USE_SYS_SRT)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=$(value2switch $SRS_RTC)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --h265=$(value2switch $SRS_H265)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=$(value2switch $SRS_GB28181)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=$(value2switch $SRS_SIMULATOR)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=$(value2switch $SRS_CXX11)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=$(value2switch $SRS_CXX14)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --backtrace=$(value2switch $SRS_BACKTRACE)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-fit=$(value2switch $SRS_FFMPEG_FIT)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sys-ffmpeg=$(value2switch $SRS_USE_SYS_FFMPEG)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-opus=$(value2switch $SRS_FFMPEG_OPUS)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=$(value2switch $SRS_NASM)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=$(value2switch $SRS_SRTP_ASM)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sys-srtp=$(value2switch $SRS_USE_SYS_SRTP)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=$(value2switch $SRS_CLEAN)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gperf=$(value2switch $SRS_GPERF)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmc=$(value2switch $SRS_GPERF_MC)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmd=$(value2switch $SRS_GPERF_MD)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmp=$(value2switch $SRS_GPERF_MP)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcp=$(value2switch $SRS_GPERF_CP)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gprof=$(value2switch $SRS_GPROF)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --static=$(value2switch $SRS_STATIC)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --shared-st=$(value2switch $SRS_SHARED_ST)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --shared-srt=$(value2switch $SRS_SHARED_SRT)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --shared-ffmpeg=$(value2switch $SRS_SHARED_FFMPEG)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --shared-srtp=$(value2switch $SRS_SHARED_SRTP)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-verbose=$(value2switch $SRS_LOG_VERBOSE)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-info=$(value2switch $SRS_LOG_INFO)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace=$(value2switch $SRS_LOG_TRACE)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-level_v2=$(value2switch $SRS_LOG_LEVEL_V2)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcov=$(value2switch $SRS_GCOV)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --apm=$(value2switch $SRS_APM)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug=$(value2switch $SRS_DEBUG)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug-stats=$(value2switch $SRS_DEBUG_STATS)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cross-build=$(value2switch $SRS_CROSS_BUILD)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer=$(value2switch $SRS_SANITIZER)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer-static=$(value2switch $SRS_SANITIZER_STATIC)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer-log=$(value2switch $SRS_SANITIZER_LOG)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cygwin64=$(value2switch $SRS_CYGWIN64)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --single-thread=$(value2switch $SRS_SINGLE_THREAD)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --signal-api=$(value2switch $SRS_SIGNAL_API)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --generic-linux=$(value2switch $SRS_GENERIC_LINUX)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --build-cache=$(value2switch $SRS_BUILD_CACHE)"
if [[ $SRS_CROSS_BUILD_ARCH != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --arch=$SRS_CROSS_BUILD_ARCH"; fi
if [[ $SRS_CROSS_BUILD_CPU != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --cpu=$SRS_CROSS_BUILD_CPU"; fi
if [[ $SRS_CROSS_BUILD_HOST != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --host=$SRS_CROSS_BUILD_HOST"; fi
if [[ $SRS_CROSS_BUILD_PREFIX != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --cross-prefix=$SRS_CROSS_BUILD_PREFIX"; fi
if [[ $SRS_EXTRA_FLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_FLAGS\\\""; fi
if [[ $SRS_EXTRA_LDFLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-ldflags=\\\"$SRS_EXTRA_LDFLAGS\\\""; 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
if [[ $SRS_TOOL_LD != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ld=$SRS_TOOL_LD"; fi
if [[ $SRS_TOOL_RANDLIB != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --randlib=$SRS_TOOL_RANDLIB"; fi
echo "User config: $SRS_AUTO_USER_CONFIGURE"
echo "Detail config: ${SRS_AUTO_CONFIGURE}"
}
regenerate_options
#####################################################################################
# Check conflicted options
#####################################################################################
function check_option_conflicts() {
if [[ $SRS_TOOL_CC == '' || $SRS_TOOL_CXX == '' || $SRS_TOOL_AR == '' || $SRS_TOOL_LD == '' || $SRS_TOOL_RANDLIB == '' ]]; then
echo "Error: No build toolchain, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR, ld: $SRS_TOOL_LD, randlib: $SRS_TOOL_RANDLIB"; exit -1
fi
if [[ $SRS_CROSS_BUILD == YES && ($SRS_TOOL_CC == 'gcc' || $SRS_TOOL_CXX == 'g++' || $SRS_TOOL_AR == 'ar') ]]; then
echo "Error: For cross build, should setup the toolchain(./configure -h|grep -i toolchain), cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR"; exit 1
fi
if [[ $SRS_NGINX == YES ]]; then
echo "Warning: Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker"
SRS_NGINX=NO
fi
# TODO: FIXME: check more os.
__check_ok=YES
# check conflict
if [[ $SRS_GPERF == NO ]]; then
if [[ $SRS_GPERF_MC == YES ]]; then echo "gperf-mc depends on gperf, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPERF_MD == YES ]]; then echo "gperf-md depends on gperf, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPERF_MP == YES ]]; then echo "gperf-mp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPERF_CP == YES ]]; then echo "gperf-cp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
fi
if [[ $SRS_GPERF_MC == YES && $SRS_GPERF_MP == YES ]]; then
echo "gperf-mc not compatible with gperf-mp, see: ./configure --help";
echo "@see: https://gperftools.github.io/gperftools/heap_checker.html";
echo "Note that since the heap-checker uses the heap-profiling framework internally, it is not possible to run both the heap-checker and heap profiler at the same time";
__check_ok=NO
fi
# generate the group option: SRS_GPERF
__gperf_slow=NO
if [[ $SRS_GPERF_MC == YES ]]; then SRS_GPERF=YES; __gperf_slow=YES; fi
if [[ $SRS_GPERF_MD == YES ]]; then SRS_GPERF=YES; __gperf_slow=YES; fi
if [[ $SRS_GPERF_MP == YES ]]; then SRS_GPERF=YES; __gperf_slow=YES; fi
if [[ $SRS_GPERF_CP == YES ]]; then SRS_GPERF=YES; __gperf_slow=YES; fi
if [[ $__gperf_slow == YES ]]; then if [[ $SRS_GPROF == YES ]]; then
echo "gmc/gmp/gcp not compatible with gprof, see: ./configure --help"; __check_ok=NO;
fi fi
# check variable neccessary
if [[ $SRS_HDS == RESERVED ]]; then echo "you must specifies the hds, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_SSL == RESERVED ]]; then echo "you must specifies the ssl, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_STREAM_CASTER == RESERVED ]]; then echo "you must specifies the stream-converter, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_UTEST == RESERVED ]]; then echo "you must specifies the utest, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPERF == RESERVED ]]; then echo "you must specifies the gperf, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPERF_MC == RESERVED ]]; then echo "you must specifies the gperf-mc, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPERF_MD == RESERVED ]]; then echo "you must specifies the gperf-md, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPERF_MP == RESERVED ]]; then echo "you must specifies the gperf-mp, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPERF_CP == RESERVED ]]; then echo "you must specifies the gperf-cp, see: ./configure --help"; __check_ok=NO; fi
if [[ $SRS_GPROF == RESERVED ]]; then echo "you must specifies the gprof, see: ./configure --help"; __check_ok=NO; fi
if [[ -z $SRS_PREFIX ]]; then echo "you must specifies the prefix, see: ./configure --prefix"; __check_ok=NO; fi
if [[ $__check_ok == NO ]]; then
exit 1;
fi
}
check_option_conflicts
+7
View File
@@ -0,0 +1,7 @@
# Reset all variables for config of modules.
SRS_MODULE_NAME=()
SRS_MODULE_MAIN=()
SRS_MODULE_APP=()
SRS_MODULE_DEFINES=""
+75
View File
@@ -0,0 +1,75 @@
#!/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"
# Detect gcc, which is required.
gcc --version >/dev/null 2>/dev/null || (ret=$?; echo "Please install gcc"; exit $ret)
# Discover SRS version from header file.
mkdir -p ${SRS_OBJS} &&
echo '#include <stdio.h>' > ${SRS_OBJS}/test_version.c &&
echo '#include <srs_core_version.hpp>' >> ${SRS_OBJS}/test_version.c &&
echo 'int main(int argc, char** argv) {' >> ${SRS_OBJS}/test_version.c &&
echo ' printf("%d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);' >> ${SRS_OBJS}/test_version.c &&
echo ' return 0;' >> ${SRS_OBJS}/test_version.c &&
echo '}' >> ${SRS_OBJS}/test_version.c &&
gcc -g -O0 ${SRS_OBJS}/test_version.c -I${SRS_WORKDIR}/src/core -o ${SRS_OBJS}/test_version 1>/dev/null 2>&1 &&
SRS_VERSION=$(./${SRS_OBJS}/test_version 2>/dev/null) &&
SRS_MAJOR=$(echo $SRS_VERSION |awk -F . '{print $1}');
ret=$?; rm -rf ${SRS_OBJS}/test_version*; if [[ $ret -ne 0 ]]; then echo "Detect SRS version failed"; exit $ret; fi
echo "Discover SRS version=${SRS_VERSION}, major=${SRS_MAJOR}"
if [[ $OSTYPE == cygwin ]]; then
OS_KERNRL_RELEASE=$(uname -r|awk -F '(' '{print $1}')
fi
# Build platform cache.
SRS_PLATFORM="${SRS_BUILD_TAG}${OS_PREFIX}-SRS${SRS_MAJOR}-${OS_KERNEL_NAME}-${OS_KERNRL_RELEASE}"
# Build platform cache with gcc version.
if [[ $OS_KERNEL_NAME == Darwin ]]; then
GCC_VERSION="Clang$(gcc --version 2>/dev/null|grep clang|awk '{print $4}')"
SRS_PLATFORM="${SRS_PLATFORM}-${GCC_VERSION}"
else
GCC_VERSION="GCC$(gcc --version 2>/dev/null|grep gcc|awk '{print $3}')"
echo $GCC_VERSION| grep '-' >/dev/null && GCC_VERSION=$(echo $GCC_VERSION| awk -F '-' '{print$1}')
SRS_PLATFORM="${SRS_PLATFORM}-${GCC_VERSION}"
fi
# Use isolate cache for different SRS version.
SRS_PLATFORM="${SRS_PLATFORM}-$(uname -m)"
if [[ $SRS_CROSS_BUILD == YES ]]; then
SRS_TOOL_CC_NAME=$(basename $SRS_TOOL_CC)
SRS_PLATFORM="${SRS_PLATFORM}-crossbuild-$(echo $SRS_TOOL_CC_NAME|awk -F - '{print $1"-"$2}')"
fi
echo "SRS_WORKDIR: ${SRS_WORKDIR}, SRS_OBJS: ${SRS_OBJS}, SRS_PLATFORM: ${SRS_PLATFORM}"
echo "All outputs to: ${SRS_OBJS}/${SRS_PLATFORM}"
# For src object files on each platform.
(
mkdir -p ${SRS_OBJS} &&
(cd ${SRS_OBJS} && rm -rf src utest srs srs_utest research include lib srs_hls_ingester srs_mp4_parser) &&
mkdir -p ${SRS_OBJS}/src ${SRS_OBJS}/research ${SRS_OBJS}/utest &&
mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty &&
(cd ${SRS_OBJS} && rm -rf st ffmpeg opus srtp2 openssl srt) &&
mkdir -p ${SRS_OBJS}/st ${SRS_OBJS}/ffmpeg ${SRS_OBJS}/opus ${SRS_OBJS}/srtp2 ${SRS_OBJS}/openssl \
${SRS_OBJS}/srt &&
mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/st ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/ffmpeg \
${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/opus ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srtp2 \
${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/openssl ${SRS_OBJS}/${SRS_PLATFORM}/3rdparty/srt
)
ret=$?; if [[ $ret -ne 0 ]]; then echo "Create build directory failed, ret=$ret"; exit $ret; fi
if [[ $SRS_CLEAN == NO ]]; then
echo "Fast cleanup, if need to do full cleanup, please use: make clean"
fi
# TODO: FIXME: Remove python, use Go for api server demo.
# Python or python2, for CentOS8.
python2 --version >/dev/null 2>&1 && alias python=python2 &&
echo "Alias python2 as python"
+57
View File
@@ -0,0 +1,57 @@
#!/bin/bash
# colorful summary
SrsHlsSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_HLS == YES ]]; then SrsHlsSummaryColor="\${GREEN}"; fi
SrsDvrSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_DVR == YES ]]; then SrsDvrSummaryColor="\${GREEN}"; fi
SrsNginxSummaryColor="\${GREEN}(Disabled) "; if [[ $SRS_NGINX == YES ]]; then SrsNginxSummaryColor="\${GREEN}"; fi
SrsSslSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_SSL == YES ]]; then SrsSslSummaryColor="\${GREEN}"; fi
SrsFfmpegSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_FFMPEG_TOOL == YES ]]; then SrsFfmpegSummaryColor="\${GREEN}"; fi
SrsTranscodeSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_TRANSCODE == YES ]]; then SrsTranscodeSummaryColor="\${GREEN}"; fi
SrsIngestSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_INGEST == YES ]]; then SrsIngestSummaryColor="\${GREEN}"; fi
SrsHttpCallbackSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_HTTP_CALLBACK == YES ]]; then SrsHttpCallbackSummaryColor="\${GREEN}"; fi
SrsHttpServerSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_HTTP_SERVER == YES ]]; then SrsHttpServerSummaryColor="\${GREEN}"; fi
SrsHttpApiSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_HTTP_API == YES ]]; then SrsHttpApiSummaryColor="\${GREEN}"; fi
SrsStreamConverterSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_STREAM_CASTER == YES ]]; then SrsStreamConverterSummaryColor="\${GREEN}"; fi
SrsUtestSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_UTEST == YES ]]; then SrsUtestSummaryColor="\${GREEN}"; fi
SrsGperfSummaryColor="\${GREEN}(Disabled) "; if [[ $SRS_GPERF == YES ]]; then SrsGperfSummaryColor="\${GREEN}"; fi
SrsGperfMCSummaryColor="\${GREEN}(Disabled) "; if [[ $SRS_GPERF_MC == YES ]]; then SrsGperfMCSummaryColor="\${YELLOW}"; fi
SrsGperfMDSummaryColor="\${GREEN}(Disabled) "; if [[ $SRS_GPERF_MD == YES ]]; then SrsGperfMDSummaryColor="\${YELLOW}"; fi
SrsGperfMPSummaryColor="\${GREEN}(Disabled) "; if [[ $SRS_GPERF_MP == YES ]]; then SrsGperfMPSummaryColor="\${YELLOW}"; fi
SrsGperfCPSummaryColor="\${GREEN}(Disabled) "; if [[ $SRS_GPERF_CP == YES ]]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi
SrsGprofSummaryColor="\${GREEN}(Disabled) "; if [[ $SRS_GPROF == YES ]]; then SrsGprofSummaryColor="\${YELLOW}"; fi
SrsValgrindSummaryColor="\${YELLOW}(Disabled) "; if [[ $SRS_VALGRIND == YES ]]; then SrsValgrindSummaryColor="\${GREEN}"; fi
cat <<END > ${SRS_OBJS}/${SRS_BUILD_SUMMARY}
#!/bin/bash
#####################################################################################
# linux shell color support.
RED="\\${RED}"
GREEN="\\${GREEN}"
YELLOW="\\${YELLOW}"
BLACK="\\${BLACK}"
echo -e "\${GREEN}The build summary:\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " \${GREEN}For SRS benchmark, gperf, gprof and valgrind, please read:\${BLACK}"
echo -e " \${GREEN} https://www.jianshu.com/p/6d4a89359352\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " |\${GREEN}The main server usage: ./objs/srs -c conf/srs.conf, start the srs server\${BLACK}"
echo -e " | ${SrsHlsSummaryColor}About HLS, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/delivery-hls\${BLACK}"
echo -e " | ${SrsDvrSummaryColor}About DVR, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/dvr\${BLACK}"
echo -e " | ${SrsSslSummaryColor}About SSL, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/rtmp-handshake\${BLACK}"
echo -e " | ${SrsTranscodeSummaryColor}About transcoding, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/ffmpeg\${BLACK}"
echo -e " | ${SrsIngestSummaryColor}About ingester, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/ingest\${BLACK}"
echo -e " | ${SrsHttpCallbackSummaryColor}About http-callback, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-callback\${BLACK}"
echo -e " | ${SrsHttpServerSummaryColor}Aoubt http-server, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-server\${BLACK}"
echo -e " | ${SrsHttpApiSummaryColor}About http-api, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-api\${BLACK}"
echo -e " | ${SrsStreamConverterSummaryColor}About stream-caster, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/streamer\${BLACK}"
echo -e " | ${SrsValgrindSummaryColor}About VALGRIND, please read https://github.com/ossrs/state-threads/issues/2\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e "\${GREEN}binaries, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/install\${BLACK}"
echo "You can:"
echo " ./objs/srs -c conf/srs.conf"
echo " to start the srs server, with config conf/srs.conf."
END
+199
View File
@@ -0,0 +1,199 @@
# generate utest Makefile
#
# params:
# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
# $SRS_OBJS the objs directory for Makefile. ie. objs
#
# $APP_NAME the app name to output. ie. srs_utest
# $MODULE_DIR the src dir of utest code. ie. src/utest
# $LINK_OPTIONS the link options for utest. ie. -lpthread -ldl
FILE=${SRS_OBJS}/${SRS_PLATFORM}/utest/Makefile
# create dir for Makefile
mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/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=../../..
# gest dir, relative to objs/utest, it's trunk/objs/{Platform}/gtest
GTEST_DIR=../3rdparty/gtest/googletest
# Whether enable C++11 or higher versions.
# For linux, always use C++11 for gtest required, see https://github.com/google/googletest
# For cygwin64, ignore because it use -std=gnu++11 by default.
SRS_CPP_VERSION="-std=c++11"
if [[ $SRS_CYGWIN64 == YES ]]; then SRS_CPP_VERSION="-std=gnu++11"; fi
cat << END > ${FILE}
# user must run make the ${SRS_OBJS}/utest dir
# at the same dir of Makefile.
# A sample Makefile for building Google Test and using it in user
# tests. Please tweak it to suit your environment and project. You
# may want to move it to your project's root directory.
#
# SYNOPSIS:
#
# make [all] - makes everything.
# make TARGET - makes the given target.
# make clean - removes all files generated by make.
# Please tweak the following variable definitions as needed by your
# project, except GTEST_HEADERS, which you can use in your own targets
# but shouldn't modify.
# Points to the root of Google Test, relative to where this file is.
# Remember to tweak this if you move this file.
GTEST_DIR = ${GTEST_DIR}
# Where to find user code.
USER_DIR = .
# C++ compiler
CXX = ${SRS_TOOL_CXX}
# Flags passed to the preprocessor.
CPPFLAGS += -I\$(GTEST_DIR)/include
# Flags passed to the C++ compiler.
CXXFLAGS += ${CXXFLAGS} ${UTEST_EXTRA_DEFINES}
CXXFLAGS += -Wno-unused-private-field -Wno-unused-command-line-argument
CXXFLAGS += ${SRS_CPP_VERSION}
# All tests produced by this Makefile. Remember to add new tests you
# created to the list.
TESTS = ${SRS_TRUNK_PREFIX}/${SRS_OBJS}/${APP_NAME}
# All Google Test headers. Usually you shouldn't change this
# definition.
GTEST_HEADERS = \$(GTEST_DIR)/include/gtest/*.h \\
\$(GTEST_DIR)/include/gtest/internal/*.h
# House-keeping build targets.
all : \$(TESTS)
clean :
rm -f \$(TESTS) gtest.a gtest_main.a *.o
# Builds gtest.a and gtest_main.a.
# Usually you shouldn't tweak such internal variables, indicated by a
# trailing _.
GTEST_SRCS_ = \$(GTEST_DIR)/src/*.cc \$(GTEST_DIR)/src/*.h \$(GTEST_HEADERS)
# For simplicity and to avoid depending on Google Test's
# implementation details, the dependencies specified below are
# conservative and not optimized. This is fine as Google Test
# compiles fast and for ordinary users its source rarely changes.
gtest-all.o : \$(GTEST_SRCS_)
\$(CXX) \$(CPPFLAGS) -I\$(GTEST_DIR) \$(CXXFLAGS) -c \\
\$(GTEST_DIR)/src/gtest-all.cc
gtest_main.o : \$(GTEST_SRCS_)
\$(CXX) \$(CPPFLAGS) -I\$(GTEST_DIR) \$(CXXFLAGS) -c \\
\$(GTEST_DIR)/src/gtest_main.cc
gtest.a : gtest-all.o
\$(AR) \$(ARFLAGS) \$@ \$^
gtest_main.a : gtest-all.o gtest_main.o
\$(AR) \$(ARFLAGS) \$@ \$^
# Builds a sample test. A test should link with either gtest.a or
# gtest_main.a, depending on whether it defines its own main()
# function.
#####################################################################################
#####################################################################################
# SRS(Simple RTMP Server) utest section
#####################################################################################
#####################################################################################
END
#####################################################################################
# Includes, the include dir.
echo "# Includes, the include dir." >> ${FILE}
#
# current module header files
echo -n "SRS_UTEST_INC = -I${SRS_TRUNK_PREFIX}/${MODULE_DIR} " >> ${FILE}
#
# depends module header files
for item in ${MODULE_DEPENDS[*]}; do
DEP_INCS_NAME="${item}_INCS"
echo -n "-I${SRS_TRUNK_PREFIX}/${!DEP_INCS_NAME} " >> ${FILE}
done
#
# depends library header files
for item in ${ModuleLibIncs[*]}; do
if [[ "${item:0:1}" == "/" ]]; then
echo -n "-I${item} " >> ${FILE}
else
echo -n "-I${SRS_TRUNK_PREFIX}/${item} " >> ${FILE}
fi
done
echo "" >> ${FILE}; echo "" >> ${FILE}
#####################################################################################
# Depends, the depends objects
echo "# Depends, the depends objects" >> ${FILE}
#
# current module header files
echo -n "SRS_UTEST_DEPS = " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=${item%.*}
echo -n "${SRS_TRUNK_PREFIX}/${SRS_OBJS}/${FILE_NAME}.o " >> ${FILE}
done
echo "" >> ${FILE}; echo "" >> ${FILE}
#
echo "# Depends, utest header files" >> ${FILE}
DEPS_NAME="UTEST_DEPS"
echo -n "${DEPS_NAME} = " >> ${FILE}
for item in ${MODULE_FILES[*]}; do
HEADER_FILE="${SRS_TRUNK_PREFIX}/${MODULE_DIR}/${item}.hpp"
echo -n " ${HEADER_FILE}" >> ${FILE}
done
echo "" >> ${FILE}; echo "" >> ${FILE}
#####################################################################################
# Objects, build each object of utest
echo "# Objects, build each object of utest" >> ${FILE}
#
MODULE_OBJS=()
for item in ${MODULE_FILES[*]}; do
MODULE_OBJS="${MODULE_OBJS[@]} ${item}.o"
cat << END >> ${FILE}
${item}.o : \$(${DEPS_NAME}) ${SRS_TRUNK_PREFIX}/${MODULE_DIR}/${item}.cpp \$(SRS_UTEST_DEPS)
\$(CXX) \$(CPPFLAGS) \$(CXXFLAGS) \$(SRS_UTEST_INC) -c ${SRS_TRUNK_PREFIX}/${MODULE_DIR}/${item}.cpp -o \$@
END
done
echo "" >> ${FILE}
#####################################################################################
# App for utest
#
# link all depends libraries
echo "# link all depends libraries" >> ${FILE}
echo -n "DEPS_LIBRARIES_FILES = " >> ${FILE}
for item in ${ModuleLibFiles[*]}; do
if [[ "${item:0:1}" == "/" ]]; then
echo -n "${item} " >> ${FILE}
else
echo -n "${SRS_TRUNK_PREFIX}/${item} " >> ${FILE}
fi
done
echo "" >> ${FILE}; echo "" >> ${FILE}
#
echo "# generate the utest binary" >> ${FILE}
cat << END >> ${FILE}
${SRS_TRUNK_PREFIX}/${SRS_OBJS}/${APP_NAME} : \$(SRS_UTEST_DEPS) ${MODULE_OBJS} gtest.a
\$(CXX) -o \$@ \$(CPPFLAGS) \$(CXXFLAGS) \$^ \$(DEPS_LIBRARIES_FILES) ${LINK_OPTIONS}
END
#####################################################################################
# parent Makefile, to create module output dir before compile it.
echo " @mkdir -p ${SRS_OBJS}/utest" >> ${SRS_MAKEFILE}
echo -n "Generate utest ok"; echo '!';