1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 20:01:56 +00:00
srs/trunk/auto/depends.sh

818 lines
37 KiB
Bash
Raw Normal View History

2013-11-27 14:41:58 +00:00
#!/bin/bash
2014-03-16 12:16:42 +00:00
# variables, parent script must set it:
# SRS_JOBS: the build jobs.
# SrsArmMakeOptions: the arm make options for ubuntu12(armhf, v7cpu)
2014-03-04 05:03:20 +00:00
2014-02-28 06:38:27 +00:00
#####################################################################################
#####################################################################################
# prepare the depends tools and libraries
# DEPENDS: options.sh, only when user options parsed, the depends tools are known.
#####################################################################################
#####################################################################################
#####################################################################################
# utilities
#####################################################################################
2014-02-28 05:17:31 +00:00
function require_sudoer()
{
sudo echo "" >/dev/null 2>&1
ret=$?; if [[ 0 -ne $ret ]]; then
echo "\"$1\" require sudoer failed. ret=$ret";
exit $ret;
fi
}
2013-11-27 14:41:58 +00:00
# TODO: check gcc/g++
2016-12-07 04:09:39 +00:00
echo "Checking gcc/g++/gdb/make."
echo "Required tools are ok."
#####################################################################################
2014-02-28 06:38:27 +00:00
# for Ubuntu, auto install tools by apt-get
#####################################################################################
OS_IS_UBUNTU=NO
function Ubuntu_prepare()
{
if [ $SRS_CUBIE = YES ]; then
2016-12-07 04:09:39 +00:00
echo "For cubieboard, please use ubuntu prepare."
else
uname -v|grep Ubuntu >/dev/null 2>&1
ret=$?; if [[ 0 -ne $ret ]]; then
# for debian, we think it's ubuntu also.
# for example, the wheezy/sid which is debian armv7 linux, can not identified by uname -v.
if [[ ! -f /etc/debian_version ]]; then
return 0;
fi
fi
fi
OS_IS_UBUNTU=YES
2016-12-07 04:09:39 +00:00
echo "Installing tools for Ubuntu."
2013-12-10 02:34:33 +00:00
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing gcc."
require_sudoer "sudo apt-get install -y --force-yes gcc"
2014-03-16 12:16:42 +00:00
sudo apt-get install -y --force-yes gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The gcc is installed."
fi
2013-12-10 02:34:33 +00:00
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing g++."
require_sudoer "sudo apt-get install -y --force-yes g++"
2014-03-16 12:16:42 +00:00
sudo apt-get install -y --force-yes g++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The g++ is installed."
fi
2013-12-10 02:34:33 +00:00
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing make."
require_sudoer "sudo apt-get install -y --force-yes make"
2014-03-16 12:16:42 +00:00
sudo apt-get install -y --force-yes make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The make is installed."
fi
2014-04-16 04:37:19 +00:00
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing patch."
2014-04-16 04:37:19 +00:00
require_sudoer "sudo apt-get install -y --force-yes patch"
sudo apt-get install -y --force-yes patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The patch is installed."
2014-04-16 04:37:19 +00:00
fi
2015-03-04 10:20:15 +00:00
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing unzip."
2015-03-04 10:20:15 +00:00
require_sudoer "sudo apt-get install -y --force-yes unzip"
sudo apt-get install -y --force-yes unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The unzip is installed."
2015-03-04 10:20:15 +00:00
fi
2017-02-28 06:47:00 +00:00
if [[ $SRS_VALGRIND == YES ]]; then
valgrind --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing valgrind."
require_sudoer "sudo apt-get install -y --force-yes valgrind"
sudo apt-get install -y --force-yes valgrind; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind is installed."
fi
2017-01-05 02:45:41 +00:00
fi
2017-02-28 06:47:00 +00:00
if [[ $SRS_VALGRIND == YES ]]; then
if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then
echo "Installing valgrind-dev."
require_sudoer "sudo apt-get install -y --force-yes valgrind-dbg"
2017-02-28 06:47:00 +00:00
sudo apt-get install -y --force-yes valgrind-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind-dev is installed."
fi
2017-01-06 09:51:07 +00:00
fi
2020-04-13 11:50:40 +00:00
if [[ $SRS_SRT == YES ]]; then
echo "SRT enable, install depend tools"
tclsh <<< "exit" >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing tcl."
require_sudoer "sudo apt-get install -y --force-yes tcl"
sudo apt-get install -y --force-yes tcl; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The tcl is installed."
fi
cmake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing cmake."
require_sudoer "sudo apt-get install -y --force-yes cmake"
sudo apt-get install -y --force-yes cmake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The cmake is installed."
fi
fi
2020-04-13 11:50:40 +00:00
pkg-config --version >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2020-04-21 06:02:26 +00:00
echo "Installing pkg-config."
require_sudoer "sudo apt-get install -y --force-yes pkg-config"
sudo apt-get install -y --force-yes pkg-config; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The pkg-config is installed."
2020-04-13 11:50:40 +00:00
fi
2016-12-07 04:09:39 +00:00
echo "Tools for Ubuntu are installed."
2014-03-16 12:16:42 +00:00
return 0
}
# donot prepare tools, for srs-librtmp depends only gcc and g++.
2020-05-27 06:20:40 +00:00
Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for ubuntu failed, ret=$ret"; exit $ret; fi
2020-03-28 09:20:40 +00:00
#####################################################################################
2014-02-28 06:38:27 +00:00
# for Centos, auto install tools by yum
#####################################################################################
OS_IS_CENTOS=NO
function Centos_prepare()
{
if [[ ! -f /etc/redhat-release ]]; then
2014-03-16 12:16:42 +00:00
return 0;
fi
OS_IS_CENTOS=YES
2016-12-07 04:09:39 +00:00
echo "Installing tools for Centos."
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing gcc."
require_sudoer "sudo yum install -y gcc"
2014-03-16 12:16:42 +00:00
sudo yum install -y gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The gcc is installed."
fi
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing gcc-c++."
require_sudoer "sudo yum install -y gcc-c++"
2014-03-16 12:16:42 +00:00
sudo yum install -y gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The gcc-c++ is installed."
fi
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing make."
require_sudoer "sudo yum install -y make"
2014-03-16 12:16:42 +00:00
sudo yum install -y make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The make is installed."
fi
2014-04-16 04:37:19 +00:00
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing patch."
2014-04-16 04:37:19 +00:00
require_sudoer "sudo yum install -y patch"
sudo yum install -y patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The patch is installed."
2014-04-16 04:37:19 +00:00
fi
2015-03-04 10:20:15 +00:00
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
2016-12-07 04:09:39 +00:00
echo "Installing unzip."
2015-03-04 10:20:15 +00:00
require_sudoer "sudo yum install -y unzip"
sudo yum install -y unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
2016-12-07 04:09:39 +00:00
echo "The unzip is installed."
2015-03-04 10:20:15 +00:00
fi
2017-02-28 06:47:00 +00:00
if [[ $SRS_VALGRIND == YES ]]; then
valgrind --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing valgrind."
require_sudoer "sudo yum install -y valgrind"
sudo yum install -y valgrind; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind is installed."
fi
2017-01-05 02:45:41 +00:00
fi
2015-03-17 13:51:19 +00:00
2017-02-28 06:47:00 +00:00
if [[ $SRS_VALGRIND == YES ]]; then
if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then
echo "Installing valgrind-devel."
require_sudoer "sudo yum install -y valgrind-devel"
sudo yum install -y valgrind-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind-devel is installed."
fi
2017-01-06 09:51:07 +00:00
fi
2020-04-13 11:50:40 +00:00
if [[ $SRS_SRT == YES ]]; then
echo "SRT enable, install depend tools"
tclsh <<< "exit" >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing tcl."
require_sudoer "sudo yum install -y tcl"
sudo yum install -y tcl; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The tcl is installed."
fi
cmake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing cmake."
require_sudoer "sudo yum install -y cmake"
sudo yum install -y cmake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The cmake is installed."
fi
fi
2020-04-13 11:50:40 +00:00
pkg-config --version --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Please install pkg-config"; exit -1;
fi
2013-12-10 03:37:59 +00:00
2016-12-07 04:09:39 +00:00
echo "Tools for Centos are installed."
return 0
}
# donot prepare tools, for srs-librtmp depends only gcc and g++.
2020-05-27 06:20:40 +00:00
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for CentOS failed, ret=$ret"; exit $ret; fi
2020-03-28 09:20:40 +00:00
#####################################################################################
# For OSX, auto install tools by brew
#####################################################################################
OS_IS_OSX=NO
function OSX_prepare()
{
uname -s|grep Darwin >/dev/null 2>&1
ret=$?; if [[ 0 -ne $ret ]]; then
if [ $SRS_OSX = YES ]; then
echo "OSX check failed, actual is `uname -s`"
exit 1;
fi
return 0;
fi
# cross build for arm, install the cross build tool chain.
if [ $SRS_CROSS_BUILD = YES ]; then
2021-01-18 09:28:51 +00:00
echo "The embeded(arm/mips) is invalid for OSX"
2020-03-28 09:20:40 +00:00
return 1
fi
OS_IS_OSX=YES
# requires the osx when os
if [ $OS_IS_OSX = YES ]; then
if [ $SRS_OSX = NO ]; then
2020-04-15 13:59:27 +00:00
echo "OSX detected, please use: ./configure --osx"
2020-03-28 09:20:40 +00:00
exit 1
fi
fi
2020-04-15 13:59:27 +00:00
echo "OSX detected, install tools if needed"
2020-03-28 09:20:40 +00:00
brew --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install brew"
echo "ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\""
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install brew success"
fi
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc"
echo "brew install gcc"
brew install gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc success"
fi
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-c++"
echo "brew install gcc-c++"
brew install gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-c++ success"
fi
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install make"
echo "brew install make"
brew install make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install make success"
fi
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install patch"
echo "brew install patch"
brew install patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install patch success"
fi
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install unzip"
echo "brew install unzip"
brew install unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install unzip success"
fi
2020-04-15 02:35:38 +00:00
pkg-config --version >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Please install pkg-config"; exit -1;
fi
if [[ $SRS_GB28181 == YES ]]; then
if [[ ! -f /usr/local/opt/libiconv/lib/libiconv.a ]]; then
echo "install libiconv"
echo "brew install libiconv"
brew install libiconv; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install libiconv success"
fi
fi
if [[ $SRS_SRT == YES ]]; then
echo "SRT enable, install depend tools"
tclsh <<< "exit" >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing tcl."
echo "brew install tcl."
brew install tcl; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install tcl success"
fi
cmake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing cmake."
echo "brew install cmake."
brew install cmake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install cmake success"
fi
fi
2020-03-28 09:20:40 +00:00
echo "OSX install tools success"
return 0
}
# donot prepare tools, for srs-librtmp depends only gcc and g++.
2020-05-27 06:20:40 +00:00
OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$ret"; exit $ret; fi
2020-03-28 09:20:40 +00:00
#####################################################################################
# for Centos, auto install tools by yum
#####################################################################################
2016-12-07 04:09:39 +00:00
# We must use a bash function instead of variable.
function sed_utility() {
2020-03-28 09:20:40 +00:00
if [ $OS_IS_OSX = YES ]; then
sed -i '' "$@"
else
sed -i "$@"
fi
ret=$?; if [[ $ret -ne 0 ]]; then
2020-03-28 09:20:40 +00:00
if [ $OS_IS_OSX = YES ]; then
echo "sed -i '' \"$@\""
else
echo "sed -i \"$@\""
fi
return $ret
fi
}
SED="sed_utility" && echo "SED is $SED"
2015-10-26 05:34:28 +00:00
2020-03-29 10:44:01 +00:00
function _srs_link_file()
{
2020-03-29 11:06:51 +00:00
tmp_dir=$1; if [[ $tmp_dir != *'/' ]]; then tmp_dir+='/'; fi
tmp_dest=$2; if [[ $tmp_dest != *'/' ]]; then tmp_dest+='/'; fi
tmp_prefix=$3; if [[ $tmp_prefix != *'/' ]]; then tmp_prefix+='/'; fi
2020-03-29 10:44:01 +00:00
echo "LINK files at dir: $tmp_dir, dest: $tmp_dest, prefix: $tmp_prefix, pwd: `pwd`"
for file in `(cd $tmp_dir && find . -maxdepth 1 -type f ! -name '*.o' ! -name '*.d' ! -name '*.log')`; do
basefile=`basename $file` &&
#echo "ln -sf ${tmp_prefix}${tmp_dir}$basefile ${tmp_dest}$basefile" &&
ln -sf ${tmp_prefix}${tmp_dir}$basefile ${tmp_dest}$basefile;
done
}
2015-03-17 13:12:30 +00:00
#####################################################################################
# check the os.
#####################################################################################
2019-05-04 23:55:55 +00:00
# Only supports:
# linux, centos/ubuntu as such,
2015-09-23 02:22:58 +00:00
# cross build for embeded system, for example, mips or arm,
# directly build on arm/mips, for example, pi or cubie,
2015-03-17 13:12:30 +00:00
# export srs-librtmp
# others is invalid.
2020-05-27 06:20:40 +00:00
if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $OS_IS_OSX = NO ]]; then
2015-09-23 02:27:57 +00:00
if [[ $SRS_PI = NO && $SRS_CUBIE = NO && $SRS_CROSS_BUILD = NO ]]; then
2019-05-04 23:55:55 +00:00
echo "Your OS `uname -s` is not supported."
2015-09-23 02:22:58 +00:00
exit 1
fi
2015-03-17 13:12:30 +00:00
fi
2013-11-27 14:41:58 +00:00
#####################################################################################
# state-threads
2013-11-27 14:41:58 +00:00
#####################################################################################
2020-05-27 06:20:40 +00:00
# check the cross build flag file, if flag changed, need to rebuild the st.
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-O0" && _ST_LD=${SRS_TOOL_LD} && _ST_OBJ="LINUX_`uname -r`_DBG"
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_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE" && _ST_LD=${SRS_TOOL_CC} && _ST_OBJ="DARWIN_`uname -r`_DBG"
fi
2021-02-15 05:09:13 +00:00
# Whether enable debug stats.
if [[ $SRS_DEBUG_STATS == YES ]]; then
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DDEBUG_STATS"
fi
2020-10-31 13:53:15 +00:00
# Always alloc on heap, @see https://github.com/ossrs/srs/issues/509#issuecomment-719931676
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMALLOC_STACK"
2020-05-27 06:20:40 +00:00
# Pass the global extra flags.
if [[ $SRS_EXTRA_FLAGS != '' ]]; then
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS $SRS_EXTRA_FLAGS"
2013-11-27 14:41:58 +00:00
fi
2020-05-27 06:20:40 +00:00
# Patched ST from https://github.com/ossrs/state-threads/tree/srs
2021-03-02 08:21:11 +00:00
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/libst.a ]]; then
2020-05-27 06:20:40 +00:00
echo "The state-threads is ok.";
else
echo "Building state-threads.";
(
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/st-srs &&
# Create a hidden directory .src
cd ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && ln -sf ../../../3rdparty/st-srs .src &&
# Link source files under .src
_srs_link_file .src/ ./ ./ &&
for dir in `(cd .src && find . -maxdepth 1 -type d|grep '\./')`; do
dir=`basename $dir` && mkdir -p $dir && _srs_link_file .src/$dir/ $dir/ ../
done &&
# Link source files under .src/xxx, the first child dir.
for dir in `(cd .src && find . -maxdepth 1 -type d|grep '\./'|grep -v Linux|grep -v Darwin)`; do
mkdir -p $dir &&
for file in `(cd .src/$dir && find . -maxdepth 1 -type f ! -name '*.o' ! -name '*.d')`; do
ln -sf ../.src/$dir/$file $dir/$file;
done;
done &&
# Build source code.
make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" \
CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${_ST_LD} RANDLIB=${SRS_TOOL_RANDLIB} &&
cd .. && rm -rf st && ln -sf st-srs/${_ST_OBJ} st
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build state-threads failed, ret=$ret"; exit $ret; fi
# Always update the links.
2021-03-02 08:21:11 +00:00
(cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf st && ln -sf st-srs/${_ST_OBJ} st)
2020-05-27 06:20:40 +00:00
(cd ${SRS_OBJS} && rm -rf st && ln -sf ${SRS_PLATFORM}/st-srs/${_ST_OBJ} st)
if [ ! -f ${SRS_OBJS}/st/libst.a ]; then echo "Build state-threads static lib failed."; exit -1; fi
2013-11-27 14:41:58 +00:00
2020-03-06 15:01:48 +00:00
#####################################################################################
2013-11-27 14:41:58 +00:00
# nginx for HLS, nginx-1.5.0
#####################################################################################
function write_nginx_html5()
{
2014-04-02 10:07:34 +00:00
cat<<END > ${html_file}
<video width="100%" autoplay controls autobuffer type="application/vnd.apple.mpegurl"
2016-12-07 04:09:39 +00:00
src="${hls_stream}">
</video>
END
}
# create the nginx dir, for http-server if not build nginx
2020-05-27 06:20:40 +00:00
mkdir -p ${SRS_OBJS}/nginx
2013-11-27 14:41:58 +00:00
# the demo dir.
2020-05-27 06:20:40 +00:00
# create forward dir
mkdir -p ${SRS_OBJS}/nginx/html/live &&
mkdir -p ${SRS_OBJS}/nginx/html/forward/live
# generate default html pages for android.
html_file=${SRS_OBJS}/nginx/html/live/demo.html && hls_stream=demo.m3u8 && write_nginx_html5
html_file=${SRS_OBJS}/nginx/html/live/livestream.html && hls_stream=livestream.m3u8 && write_nginx_html5
html_file=${SRS_OBJS}/nginx/html/live/livestream_ld.html && hls_stream=livestream_ld.m3u8 && write_nginx_html5
html_file=${SRS_OBJS}/nginx/html/live/livestream_sd.html && hls_stream=livestream_sd.m3u8 && write_nginx_html5
html_file=${SRS_OBJS}/nginx/html/forward/live/livestream.html && hls_stream=livestream.m3u8 && write_nginx_html5
html_file=${SRS_OBJS}/nginx/html/forward/live/livestream_ld.html && hls_stream=livestream_ld.m3u8 && write_nginx_html5
html_file=${SRS_OBJS}/nginx/html/forward/live/livestream_sd.html && hls_stream=livestream_sd.m3u8 && write_nginx_html5
# copy players to nginx html dir.
rm -rf ${SRS_OBJS}/nginx/html/players &&
2021-04-28 07:45:34 +00:00
ln -sf `pwd`/research/players ${SRS_OBJS}/nginx/html/players
2020-05-27 06:20:40 +00:00
# for favicon.ico
rm -rf ${SRS_OBJS}/nginx/html/favicon.ico &&
ln -sf `pwd`/research/api-server/static-dir/favicon.ico ${SRS_OBJS}/nginx/html/favicon.ico
2021-04-24 11:07:37 +00:00
# For srs-console.
rm -rf ${SRS_OBJS}/nginx/html/console &&
ln -sf `pwd`/research/console ${SRS_OBJS}/nginx/html/console
2021-05-02 13:06:31 +00:00
# For SRS signaling.
rm -rf ${SRS_OBJS}/nginx/html/demos &&
ln -sf `pwd`/3rdparty/signaling/www/demos ${SRS_OBJS}/nginx/html/demos
2021-04-24 11:07:37 +00:00
# For home page index.html
rm -rf ${SRS_OBJS}/nginx/html/index.html &&
ln -sf `pwd`/research/api-server/static-dir/index.html ${SRS_OBJS}/nginx/html/index.html
2020-05-27 06:20:40 +00:00
# nginx.html to detect whether nginx is alive
echo "Nginx is ok." > ${SRS_OBJS}/nginx/html/nginx.html
2013-12-07 11:27:31 +00:00
#####################################################################################
# cherrypy for http hooks callback, CherryPy-3.2.4
#####################################################################################
2020-12-24 03:33:49 +00:00
if [[ $SRS_CHERRYPY == YES ]]; then
# Detect python or python2
python --version >/dev/null 2>&1 && SYS_PYTHON=python;
python2 --version >/dev/null 2>&1 && SYS_PYTHON=python2;
# Install cherrypy for api server.
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/CherryPy-3.2.4/setup.py ]]; then
echo "CherryPy-3.2.4 is ok.";
else
echo "Installing CherryPy-3.2.4";
(
rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
unzip -q ../../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 &&
$SYS_PYTHON setup.py install --user --prefix=''
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build CherryPy-3.2.4 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi
echo "Link players to cherrypy static-dir"
rm -rf research/api-server/static-dir/players &&
ln -sf `pwd`/research/players research/api-server/static-dir/players &&
rm -f research/api-server/static-dir/crossdomain.xml &&
ln -sf `pwd`/research/players/crossdomain.xml research/api-server/static-dir/crossdomain.xml &&
rm -rf research/api-server/static-dir/live &&
mkdir -p `pwd`/${SRS_OBJS}/nginx/html/live &&
ln -sf `pwd`/${SRS_OBJS}/nginx/html/live research/api-server/static-dir/live &&
rm -rf research/api-server/static-dir/forward &&
mkdir -p `pwd`/${SRS_OBJS}/nginx/html/forward &&
ln -sf `pwd`/${SRS_OBJS}/nginx/html/forward research/api-server/static-dir/forward
ret=$?; if [[ $ret -ne 0 ]]; then echo "Warning: Ignore error to link players to cherrypy static-dir."; fi
2014-11-08 12:14:20 +00:00
fi
2013-11-27 14:41:58 +00:00
#####################################################################################
# openssl, for rtmp complex handshake and HLS encryption.
2013-11-27 14:41:58 +00:00
#####################################################################################
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
2020-04-03 05:42:24 +00:00
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-armv4"
2020-04-03 13:59:32 +00:00
elif [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then
2020-10-23 13:22:58 +00:00
# Try to use exists libraries.
if [[ -f /usr/local/ssl/lib/libssl.a && $SRS_SSL_LOCAL == NO ]]; then
2020-04-03 13:59:32 +00:00
(mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib &&
2020-04-03 14:46:04 +00:00
ln -sf /usr/local/ssl/lib/libssl.a && ln -sf /usr/local/ssl/lib/libcrypto.a &&
mkdir -p /usr/local/ssl/lib/pkgconfig && ln -sf /usr/local/ssl/lib/pkgconfig)
2020-04-03 13:59:32 +00:00
(mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include &&
ln -sf /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
2014-02-28 14:42:25 +00:00
fi
2020-04-03 05:42:24 +00:00
# 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"
2020-04-03 05:42:24 +00:00
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
2020-04-03 05:42:24 +00:00
export KERNEL_BITS=64;
fi
# Use 1.0 if required.
2020-11-03 08:56:05 +00:00
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.
2020-05-11 03:45:20 +00:00
OPENSSL_CANDIDATE="openssl-OpenSSL_1_0_2u" && OPENSSL_UNZIP="tar xf ../../3rdparty/$OPENSSL_CANDIDATE.tar.gz"
else
OPENSSL_AR="$SRS_TOOL_AR"
OPENSSL_CANDIDATE="openssl-1.1-fit" && OPENSSL_UNZIP="cp -R ../../3rdparty/$OPENSSL_CANDIDATE ."
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.
2021-03-02 08:21:11 +00:00
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/$OPENSSL_CANDIDATE/_release/lib/libssl.a ]]; then
2021-01-18 04:34:11 +00:00
echo "The $OPENSSL_CANDIDATE is ok.";
else
echo "Building $OPENSSL_CANDIDATE.";
(
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
${OPENSSL_UNZIP} && cd $OPENSSL_CANDIDATE && ${OPENSSL_CONFIG} --prefix=`pwd`/_release $OPENSSL_OPTIONS &&
make CC=${SRS_TOOL_CC} AR="${OPENSSL_AR}" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} ${SRS_JOBS} && make install_sw &&
cd .. && rm -rf openssl && ln -sf $OPENSSL_CANDIDATE/_release openssl
)
fi
# Which lib we use.
OPENSSL_LIB="$OPENSSL_CANDIDATE/_release"
if [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_LIB}/lib/libssl.a ]]; then
OPENSSL_LIB="openssl"
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build $OPENSSL_CANDIDATE failed, ret=$ret"; exit $ret; fi
# Always update the links.
2021-03-02 08:21:11 +00:00
(cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf openssl && ln -sf $OPENSSL_CANDIDATE/_release openssl)
2020-03-29 07:23:40 +00:00
(cd ${SRS_OBJS} && rm -rf openssl && ln -sf ${SRS_PLATFORM}/${OPENSSL_LIB} openssl)
if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build $OPENSSL_CANDIDATE failed."; exit -1; fi
2014-02-28 14:42:25 +00:00
fi
2020-03-28 16:16:37 +00:00
#####################################################################################
# srtp
#####################################################################################
2020-05-27 06:20:40 +00:00
SRTP_CONFIG="echo SRTP without openssl(ASM) optimization" && SRTP_OPTIONS=""
# If use ASM for SRTP, we enable openssl(with ASM).
if [[ $SRS_SRTP_ASM == YES ]]; then
echo "SRTP with openssl(ASM) optimization" &&
SRTP_CONFIG="export PKG_CONFIG_PATH=../openssl/lib/pkgconfig" && SRTP_OPTIONS="--enable-openssl"
2020-03-28 16:16:37 +00:00
fi
2020-05-27 06:20:40 +00:00
# Patched ST from https://github.com/ossrs/state-threads/tree/srs
2021-03-02 08:21:11 +00:00
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/_release/lib/libsrtp2.a ]]; then
2021-03-02 09:48:40 +00:00
echo "The libsrtp-2-fit is ok.";
2020-05-27 06:20:40 +00:00
else
2021-03-02 09:48:40 +00:00
echo "Building libsrtp-2-fit.";
2020-05-27 06:20:40 +00:00
(
rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
rm -rf libsrtp-2-fit && cp -R ../../3rdparty/libsrtp-2-fit . && cd libsrtp-2-fit &&
2020-05-27 06:20:40 +00:00
${SRTP_CONFIG} && ./configure ${SRTP_OPTIONS} --prefix=`pwd`/_release &&
make ${SRS_JOBS} && make install &&
cd .. && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2
2020-05-27 06:20:40 +00:00
)
fi
# check status
2021-03-02 09:48:40 +00:00
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build libsrtp-2-fit failed, ret=$ret"; exit $ret; fi
2020-05-27 06:20:40 +00:00
# Always update the links.
2021-03-02 08:21:11 +00:00
(cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2)
(cd ${SRS_OBJS} && rm -rf srtp2 && ln -sf ${SRS_PLATFORM}/libsrtp-2-fit/_release srtp2)
2021-03-02 09:48:40 +00:00
if [ ! -f ${SRS_OBJS}/srtp2/lib/libsrtp2.a ]; then echo "Build libsrtp-2-fit static lib failed."; exit -1; fi
2020-03-28 16:16:37 +00:00
#####################################################################################
# libopus, for WebRTC to transcode AAC with Opus.
#####################################################################################
2020-05-27 06:20:40 +00:00
if [[ $SRS_RTC == YES ]]; then
2021-03-02 08:21:11 +00:00
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1/_release/lib/libopus.a ]]; then
echo "The opus-1.3.1 is ok.";
else
echo "Building opus-1.3.1.";
(
2020-03-28 16:16:37 +00:00
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
tar xf ../../3rdparty/opus-1.3.1.tar.gz && cd opus-1.3.1 &&
./configure --prefix=`pwd`/_release --enable-static --disable-shared && make ${SRS_JOBS} && make install
cd .. && rm -rf opus && ln -sf opus-1.3.1/_release opus
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build opus-1.3.1 failed, ret=$ret"; exit $ret; fi
2020-03-28 16:16:37 +00:00
# Always update the links.
2021-03-02 08:21:11 +00:00
(cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf opus && ln -sf opus-1.3.1/_release opus)
2020-04-29 11:07:25 +00:00
(cd ${SRS_OBJS} && rm -rf opus && ln -sf ${SRS_PLATFORM}/opus-1.3.1/_release opus)
if [ ! -f ${SRS_OBJS}/opus/lib/libopus.a ]; then echo "Build opus-1.3.1 failed."; exit -1; fi
fi
#####################################################################################
# ffmpeg-fix, for WebRTC to transcode AAC with Opus.
#####################################################################################
if [[ $SRS_FFMPEG_FIT == YES ]]; then
FFMPEG_OPTIONS=""
2020-04-15 02:35:38 +00:00
# If disable nasm, disable all ASMs.
if [[ $SRS_NASM == NO ]]; then
FFMPEG_OPTIONS="--disable-asm --disable-x86asm --disable-inline-asm"
fi
2020-04-15 02:35:38 +00:00
# If no nasm, we disable the x86asm.
nasm -v >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
FFMPEG_OPTIONS="--disable-x86asm"
fi
2021-03-02 09:48:40 +00:00
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/_release/lib/libavcodec.a ]]; then
echo "The ffmpeg-4-fit is ok.";
else
2021-03-02 09:48:40 +00:00
echo "Building ffmpeg-4-fit.";
(
2021-03-02 09:48:40 +00:00
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit &&
2020-03-29 09:15:29 +00:00
# Create a hidden directory .src
2021-03-02 09:48:40 +00:00
cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && cp -R ../../../3rdparty/ffmpeg-4-fit/* . &&
2021-03-02 05:20:38 +00:00
# For libopus and other codecs.
ABS_OBJS=$(cd .. && pwd) &&
2020-03-29 09:15:29 +00:00
# Build source code.
PKG_CONFIG_PATH=$ABS_OBJS/opus/lib/pkgconfig ./configure \
--prefix=`pwd`/_release \
2021-03-02 05:20:38 +00:00
--pkg-config-flags="--static" --extra-libs="-lpthread" --extra-libs="-lm" ${FFMPEG_OPTIONS} \
--disable-programs --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages \
--disable-avdevice --disable-avformat --disable-swscale --disable-postproc --disable-avfilter --disable-network \
--disable-dct --disable-dwt --disable-error-resilience --disable-lsp --disable-lzo --disable-faan --disable-pixelutils \
2020-04-10 00:55:04 +00:00
--disable-hwaccels --disable-devices --disable-audiotoolbox --disable-videotoolbox --disable-cuda-llvm --disable-cuvid \
--disable-d3d11va --disable-dxva2 --disable-ffnvcodec --disable-nvdec --disable-nvenc --disable-v4l2-m2m --disable-vaapi \
--disable-vdpau --disable-appkit --disable-coreimage --disable-avfoundation --disable-securetransport --disable-iconv \
--disable-lzma --disable-sdl2 --disable-everything --enable-decoder=aac --enable-decoder=aac_fixed --enable-decoder=aac_latm \
--enable-decoder=libopus --enable-encoder=aac --enable-encoder=opus --enable-encoder=libopus --enable-libopus &&
make ${SRS_JOBS} && make install &&
2021-03-02 09:48:40 +00:00
cd .. && rm -rf ffmpeg && ln -sf ffmpeg-4-fit/_release ffmpeg
)
fi
# check status
2021-03-02 09:48:40 +00:00
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build ffmpeg-4-fit failed, ret=$ret"; exit $ret; fi
2020-03-28 16:16:37 +00:00
# Always update the links.
2021-03-02 09:48:40 +00:00
(cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf ffmpeg && ln -sf ffmpeg-4-fit/_release ffmpeg)
(cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg-4-fit/_release ffmpeg)
if [ ! -f ${SRS_OBJS}/ffmpeg/lib/libavcodec.a ]; then echo "Build ffmpeg-4-fit failed."; exit -1; fi
fi
2013-11-30 03:59:21 +00:00
#####################################################################################
# live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2.
2013-11-30 03:59:21 +00:00
#####################################################################################
# Always link the ffmpeg tools if exists.
if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg ]]; then
2020-03-29 07:23:40 +00:00
mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin &&
2020-06-20 13:48:04 +00:00
ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg &&
(cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg)
fi
if [ $SRS_FFMPEG_TOOL = YES ]; then
2020-03-29 07:23:40 +00:00
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg ]]; then
echo "ffmpeg-4.1 is ok.";
2013-11-30 03:59:21 +00:00
else
2020-10-23 13:45:32 +00:00
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}"
2020-03-29 07:23:40 +00:00
exit -1;
2013-11-30 03:59:21 +00:00
fi
2020-03-29 07:23:40 +00:00
# Always update the links.
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg ]]; then
(cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg)
fi
2013-11-30 03:59:21 +00:00
fi
#####################################################################################
# SRT module, https://github.com/ossrs/srs/issues/1147#issuecomment-577469119
#####################################################################################
if [[ $SRS_SRT == YES ]]; then
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/srt/lib/libsrt.a ]]; then
echo "libsrt-1-fit is ok.";
else
echo "Build srt-1-fit"
(
if [[ ! -d ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/pkgconfig ]]; then
echo "OpenSSL pkgconfig no found, build srt-1-fit failed.";
exit -1;
fi
# Always disable c++11 for libsrt, because only the srt-app requres it.
LIBSRT_OPTIONS="--disable-app --enable-shared=0 --enable-static --enable-c++11=0"
# Start build libsrt.
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
cp -R ../../3rdparty/srt-1-fit srt-1-fit && cd srt-1-fit &&
PKG_CONFIG_PATH=../openssl/lib/pkgconfig ./configure --prefix=`pwd`/_release $LIBSRT_OPTIONS &&
make ${SRS_JOBS} && make install &&
cd .. && rm -rf srt && ln -sf srt-1-fit/_release srt &&
# If exists lib64 of libsrt, link it to lib
if [[ -d srt/lib64 ]]; then
cd srt && ln -sf lib64 lib
fi
)
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build srt-1-fit failed, ret=$ret"; exit $ret; fi
fi
# Always update the links.
(cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf srt && ln -sf srt-1-fit/_release srt)
(cd ${SRS_OBJS} && rm -rf srt && ln -sf ${SRS_PLATFORM}/srt-1-fit/_release srt)
if [ ! -f ${SRS_OBJS}/srt/lib/libsrt.a ]; then echo "Build srt-1-fit failed."; exit -1; fi
fi
2014-03-03 10:28:50 +00:00
#####################################################################################
# build utest code
#####################################################################################
if [ $SRS_UTEST = YES ]; then
2021-03-02 08:21:11 +00:00
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0/include/gtest/gtest.h ]]; then
2016-12-07 04:09:39 +00:00
echo "The gtest-1.6.0 is ok.";
2014-03-04 08:13:12 +00:00
else
2016-12-07 04:09:39 +00:00
echo "Build gtest-1.6.0";
2014-03-04 08:13:12 +00:00
(
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
unzip -q ../../3rdparty/gtest-1.6.0.zip &&
rm -rf gtest && ln -sf gtest-1.6.0 gtest
2014-03-04 08:13:12 +00:00
)
fi
# check status
2016-12-07 04:09:39 +00:00
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gtest-1.6.0 failed, ret=$ret"; exit $ret; fi
# Always update the links.
2021-03-02 08:21:11 +00:00
(cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf gtest && ln -sf gtest-1.6.0 gtest)
2020-03-29 07:23:40 +00:00
(cd ${SRS_OBJS} && rm -rf gtest && ln -sf ${SRS_PLATFORM}/gtest-1.6.0 gtest)
2016-12-07 04:09:39 +00:00
if [ ! -f ${SRS_OBJS}/gtest/include/gtest/gtest.h ]; then echo "Build gtest-1.6.0 failed."; exit -1; fi
2014-03-03 10:28:50 +00:00
fi
2014-03-06 06:10:45 +00:00
#####################################################################################
# build gperf code
#####################################################################################
if [ $SRS_GPERF = YES ]; then
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gperf/bin/pprof ]]; then
2016-12-07 04:09:39 +00:00
echo "The gperftools-2.1 is ok.";
2014-03-06 06:10:45 +00:00
else
2016-12-07 04:09:39 +00:00
echo "Build gperftools-2.1";
2014-03-06 06:10:45 +00:00
(
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2.1 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
unzip -q ../../3rdparty/gperftools-2.1.zip && cd gperftools-2.1 &&
2014-03-06 06:10:45 +00:00
./configure --prefix=`pwd`/_release --enable-frame-pointers && make ${SRS_JOBS} && make install &&
cd .. && rm -rf gperf && ln -sf gperftools-2.1/_release gperf &&
rm -rf pprof && ln -sf gperf/bin/pprof pprof
2014-03-06 06:10:45 +00:00
)
fi
# check status
2016-12-07 04:09:39 +00:00
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gperftools-2.1 failed, ret=$ret"; exit $ret; fi
# Always update the links.
2020-03-29 07:23:40 +00:00
(cd ${SRS_OBJS} && rm -rf pprof && ln -sf ${SRS_PLATFORM}/gperf/bin/pprof pprof)
2020-04-06 13:37:37 +00:00
(cd ${SRS_OBJS} && rm -rf gperf && ln -sf ${SRS_PLATFORM}/gperftools-2.1/_release gperf)
if [ ! -f ${SRS_OBJS}/pprof ]; then echo "Build gperftools-2.1 failed."; exit -1; fi
2014-03-06 06:10:45 +00:00
fi