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
|
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
function require_sudoer() {
|
2014-02-28 05:17:31 +00:00
|
|
|
sudo echo "" >/dev/null 2>&1
|
|
|
|
|
|
|
|
ret=$?; if [[ 0 -ne $ret ]]; then
|
|
|
|
echo "\"$1\" require sudoer failed. ret=$ret";
|
|
|
|
exit $ret;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-12-10 02:09:29 +00:00
|
|
|
#####################################################################################
|
2014-02-28 06:38:27 +00:00
|
|
|
# for Ubuntu, auto install tools by apt-get
|
2013-12-10 02:09:29 +00:00
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
function Ubuntu_prepare() {
|
2022-08-10 15:10:31 +00:00
|
|
|
if [[ $OS_IS_UBUNTU != YES ]]; then return 0; fi
|
2016-12-07 04:09:39 +00:00
|
|
|
echo "Installing tools for Ubuntu."
|
2013-12-10 02:09:29 +00:00
|
|
|
|
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."
|
2014-03-10 05:09:45 +00:00
|
|
|
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."
|
2013-12-10 02:09:29 +00:00
|
|
|
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++."
|
2014-03-10 05:09:45 +00:00
|
|
|
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."
|
2013-12-10 02:09:29 +00:00
|
|
|
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."
|
2014-03-10 05:09:45 +00:00
|
|
|
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."
|
2013-12-10 02:09:29 +00:00
|
|
|
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."
|
2020-01-20 03:25:39 +00:00
|
|
|
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
|
|
|
|
2021-05-16 08:14:00 +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
|
2013-12-10 02:09:29 +00:00
|
|
|
}
|
2014-11-08 08:45:50 +00:00
|
|
|
# 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
|
|
|
|
2013-12-10 02:09:29 +00:00
|
|
|
#####################################################################################
|
2014-02-28 06:38:27 +00:00
|
|
|
# for Centos, auto install tools by yum
|
2013-12-10 02:09:29 +00:00
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
function Centos_prepare() {
|
2022-08-10 15:10:31 +00:00
|
|
|
if [[ $OS_IS_CENTOS != YES ]]; then return 0; fi
|
2016-12-07 04:09:39 +00:00
|
|
|
echo "Installing tools for Centos."
|
2013-12-10 02:09:29 +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."
|
2013-12-10 02:09:29 +00:00
|
|
|
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."
|
2013-12-10 02:09:29 +00:00
|
|
|
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++."
|
2013-12-10 02:09:29 +00:00
|
|
|
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."
|
2013-12-10 02:09:29 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
|
2016-12-07 04:09:39 +00:00
|
|
|
echo "Installing make."
|
2013-12-10 02:09:29 +00:00
|
|
|
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."
|
2013-12-10 02:09:29 +00:00
|
|
|
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
|
|
|
|
2021-05-16 08:14:00 +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."
|
2015-03-10 04:50:27 +00:00
|
|
|
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
|
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
function OSX_prepare() {
|
|
|
|
if [[ $OS_IS_OSX != YES ]]; then
|
|
|
|
if [[ $SRS_OSX == YES ]]; then echo "OSX check failed, actual is `uname -s`"; exit 1; fi
|
|
|
|
return 0
|
2020-03-28 09:20:40 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# cross build for arm, install the cross build tool chain.
|
2022-11-18 15:02:35 +00:00
|
|
|
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
|
|
|
|
|
2022-11-18 15:02:35 +00:00
|
|
|
# Requires the osx when darwin detected
|
|
|
|
if [[ $OS_IS_OSX == YES && $SRS_OSX != YES ]]; then
|
|
|
|
echo "OSX detected, please use: ./configure --osx"
|
|
|
|
exit 1
|
2020-03-28 09:20:40 +00:00
|
|
|
fi
|
|
|
|
|
2020-04-15 13:59:27 +00:00
|
|
|
echo "OSX detected, install tools if needed"
|
|
|
|
|
2022-05-23 00:31:57 +00:00
|
|
|
brew --version >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
|
|
|
|
echo "Please install brew at https://brew.sh/"
|
|
|
|
exit $ret
|
2020-03-28 09:20:40 +00:00
|
|
|
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
|
|
|
|
|
2021-05-16 08:14:00 +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."
|
|
|
|
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
|
|
|
|
2021-10-24 05:29:14 +00:00
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
# Check OS and CPU architectures.
|
2015-03-17 13:12:30 +00:00
|
|
|
#####################################################################################
|
2022-11-20 04:29:57 +00:00
|
|
|
if [[ $OS_IS_UBUNTU != YES && $OS_IS_CENTOS != YES && $OS_IS_OSX != YES && $SRS_CROSS_BUILD != YES && $SRS_CYGWIN64 != YES ]]; then
|
2021-05-20 12:07:13 +00:00
|
|
|
echo "Your OS `uname -s` is not supported."
|
|
|
|
exit 1
|
2015-03-17 13:12:30 +00:00
|
|
|
fi
|
|
|
|
|
2022-11-18 15:02:35 +00:00
|
|
|
# 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 ""
|
|
|
|
|
2013-11-27 14:41:58 +00:00
|
|
|
#####################################################################################
|
2022-08-13 02:27:14 +00:00
|
|
|
# Try to load cache if exists /usr/local/srs-cache
|
|
|
|
#####################################################################################
|
2022-11-20 11:58:21 +00:00
|
|
|
# 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.
|
2022-08-13 02:27:14 +00:00
|
|
|
if [[ -d /usr/local/srs-cache/srs/trunk/objs && $(pwd) != "/usr/local/srs-cache/srs/trunk" ]]; then
|
|
|
|
SOURCE_DIR=$(ls -d /usr/local/srs-cache/srs/trunk/objs/Platform-* 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-* &&
|
2022-11-18 14:02:24 +00:00
|
|
|
du -sh /usr/local/srs-cache/srs/trunk/objs/Platform-*/* &&
|
2022-08-13 02:27:14 +00:00
|
|
|
du -sh objs/Platform-* &&
|
|
|
|
ls -lh objs
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#####################################################################################
|
2022-11-22 02:40:18 +00:00
|
|
|
# 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.cc &&
|
|
|
|
gcc -fsanitize=address -fno-omit-frame-pointer -g -O0 ${SRS_OBJS}/test_sanitizer.cc \
|
|
|
|
-o ${SRS_OBJS}/test_sanitizer 1>/dev/null 2>&1;
|
|
|
|
ret=$?; rm -f ${SRS_OBJS}/test_sanitizer ${SRS_OBJS}/test_sanitizer.cc
|
|
|
|
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
|
|
|
|
|
|
|
|
#####################################################################################
|
2020-02-17 07:30:20 +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.
|
2021-06-21 23:49:48 +00:00
|
|
|
_ST_MAKE=linux-debug && _ST_OBJ="LINUX_`uname -r`_DBG"
|
2021-04-26 00:01:49 +00:00
|
|
|
# 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.
|
2020-05-27 06:20:40 +00:00
|
|
|
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
|
2021-06-21 23:49:48 +00:00
|
|
|
_ST_MAKE=darwin-debug && _ST_OBJ="DARWIN_`uname -r`_DBG"
|
2020-05-27 06:20:40 +00:00
|
|
|
fi
|
2022-11-20 04:29:57 +00:00
|
|
|
# for windows/cygwin
|
|
|
|
if [[ $SRS_CYGWIN64 = YES ]]; then
|
|
|
|
_ST_MAKE=cygwin64-debug && _ST_OBJ="CYGWIN64_`uname -s`_DBG"
|
|
|
|
fi
|
2022-01-11 00:40:05 +00:00
|
|
|
# For Ubuntu, the epoll detection might be fail.
|
|
|
|
if [[ $OS_IS_UBUNTU == YES ]]; then
|
|
|
|
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_HAVE_EPOLL"
|
|
|
|
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-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
|
2021-04-26 00:01:49 +00:00
|
|
|
# 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}"
|
2021-06-21 23:49:48 +00:00
|
|
|
_ST_MAKE_ARGS="${_ST_MAKE_ARGS} CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB}"
|
2020-05-27 06:20:40 +00:00
|
|
|
# Patched ST from https://github.com/ossrs/state-threads/tree/srs
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/st/libst.a ]]; then
|
|
|
|
rm -rf ${SRS_OBJS}/st && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/st ${SRS_OBJS}/ &&
|
|
|
|
echo "The state-threads is ok."
|
2020-05-27 06:20:40 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
echo "Building state-threads." &&
|
|
|
|
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/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}/3rdpatry/st &&
|
|
|
|
cp -f ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/st.h ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/st/ &&
|
|
|
|
cp -f ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/libst.a ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/st/ &&
|
|
|
|
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/st ${SRS_OBJS}/ &&
|
|
|
|
echo "The state-threads is ok."
|
2020-05-27 06:20:40 +00:00
|
|
|
fi
|
|
|
|
# check status
|
|
|
|
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build state-threads failed, ret=$ret"; exit $ret; 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
|
|
|
|
#####################################################################################
|
2013-12-10 02:09:29 +00:00
|
|
|
function write_nginx_html5()
|
|
|
|
{
|
2014-04-02 10:07:34 +00:00
|
|
|
cat<<END > ${html_file}
|
2021-01-07 05:47:30 +00:00
|
|
|
<video width="100%" autoplay controls autobuffer type="application/vnd.apple.mpegurl"
|
2016-12-07 04:09:39 +00:00
|
|
|
src="${hls_stream}">
|
2013-12-10 02:09:29 +00:00
|
|
|
</video>
|
|
|
|
END
|
|
|
|
}
|
2014-04-05 05:14:59 +00:00
|
|
|
# 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
|
|
|
|
2014-11-08 08:45:50 +00:00
|
|
|
# the demo dir.
|
2020-05-27 06:20:40 +00:00
|
|
|
# create forward dir
|
|
|
|
mkdir -p ${SRS_OBJS}/nginx/html/live &&
|
2022-11-18 15:02:35 +00:00
|
|
|
html_file=${SRS_OBJS}/nginx/html/live/livestream.html && hls_stream=livestream.m3u8 && write_nginx_html5 &&
|
2020-05-27 06:20:40 +00:00
|
|
|
|
|
|
|
# copy players to nginx html dir.
|
|
|
|
rm -rf ${SRS_OBJS}/nginx/html/players &&
|
2022-11-18 15:02:35 +00:00
|
|
|
cp -rf $SRS_WORKDIR/research/players ${SRS_OBJS}/nginx/html/ &&
|
2020-05-27 06:20:40 +00:00
|
|
|
|
|
|
|
# for favicon.ico
|
|
|
|
rm -rf ${SRS_OBJS}/nginx/html/favicon.ico &&
|
2022-11-18 15:02:35 +00:00
|
|
|
cp -f $SRS_WORKDIR/research/api-server/static-dir/favicon.ico ${SRS_OBJS}/nginx/html/favicon.ico &&
|
2020-05-27 06:20:40 +00:00
|
|
|
|
2021-04-24 11:45:05 +00:00
|
|
|
# For srs-console.
|
|
|
|
rm -rf ${SRS_OBJS}/nginx/html/console &&
|
2022-11-18 15:02:35 +00:00
|
|
|
cp -rf $SRS_WORKDIR/research/console ${SRS_OBJS}/nginx/html/ &&
|
2021-04-24 11:45:05 +00:00
|
|
|
|
2021-05-02 13:46:41 +00:00
|
|
|
# For SRS signaling.
|
|
|
|
rm -rf ${SRS_OBJS}/nginx/html/demos &&
|
2022-11-18 15:02:35 +00:00
|
|
|
cp -rf $SRS_WORKDIR/3rdparty/signaling/www/demos ${SRS_OBJS}/nginx/html/ &&
|
2021-05-02 13:46:41 +00:00
|
|
|
|
2021-04-24 11:45:05 +00:00
|
|
|
# For home page index.html
|
|
|
|
rm -rf ${SRS_OBJS}/nginx/html/index.html &&
|
2022-11-18 15:02:35 +00:00
|
|
|
cp -f $SRS_WORKDIR/research/api-server/static-dir/index.html ${SRS_OBJS}/nginx/html/index.html &&
|
2021-04-24 11:45:05 +00:00
|
|
|
|
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
|
2014-04-05 05:14:59 +00:00
|
|
|
|
2022-11-18 15:02:35 +00:00
|
|
|
# check status
|
|
|
|
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build web pages failed, ret=$ret"; exit $ret; fi
|
|
|
|
|
2022-01-11 00:40:05 +00:00
|
|
|
#####################################################################################
|
|
|
|
# Generate default self-sign certificate for HTTPS server, test only.
|
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
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" &&
|
2022-01-11 00:40:05 +00:00
|
|
|
echo "Generate test-only self-sign certificate files"
|
|
|
|
fi
|
|
|
|
|
2013-12-07 11:27:31 +00:00
|
|
|
#####################################################################################
|
|
|
|
# cherrypy for http hooks callback, CherryPy-3.2.4
|
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
# TODO: FIXME: Replace by Go.
|
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 &&
|
2022-11-18 15:02:35 +00:00
|
|
|
ln -sf $SRS_WORKDIR/research/players research/api-server/static-dir/players &&
|
2020-12-24 03:33:49 +00:00
|
|
|
rm -rf research/api-server/static-dir/live &&
|
2022-11-18 15:02:35 +00:00
|
|
|
mkdir -p $SRS_WORKDIR/${SRS_OBJS}/nginx/html/live &&
|
|
|
|
ln -sf $SRS_WORKDIR/${SRS_OBJS}/nginx/html/live research/api-server/static-dir/live &&
|
2020-12-24 03:33:49 +00:00
|
|
|
rm -rf research/api-server/static-dir/forward &&
|
2022-11-18 15:02:35 +00:00
|
|
|
mkdir -p $SRS_WORKDIR/${SRS_OBJS}/nginx/html/forward &&
|
|
|
|
ln -sf $SRS_WORKDIR/${SRS_OBJS}/nginx/html/forward research/api-server/static-dir/forward
|
2020-12-24 03:33:49 +00:00
|
|
|
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-12-25 15:42:23 +00:00
|
|
|
|
2013-11-27 14:41:58 +00:00
|
|
|
#####################################################################################
|
2020-01-21 07:22:55 +00:00
|
|
|
# openssl, for rtmp complex handshake and HLS encryption.
|
2013-11-27 14:41:58 +00:00
|
|
|
#####################################################################################
|
2020-01-21 05:59:43 +00:00
|
|
|
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then
|
|
|
|
echo "Warning: Use system libssl, without compiling openssl."
|
|
|
|
fi
|
2015-09-21 04:01:48 +00:00
|
|
|
# @see http://www.openssl.org/news/secadv/20140407.txt
|
2017-02-25 04:06:39 +00:00
|
|
|
# Affected users should upgrade to OpenSSL 1.1.0e. Users unable to immediately
|
2014-04-09 03:06:53 +00:00
|
|
|
# upgrade can alternatively recompile OpenSSL with -DOPENSSL_NO_HEARTBEATS.
|
2020-01-21 05:59:43 +00:00
|
|
|
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"
|
2020-01-21 05:59:43 +00:00
|
|
|
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
|
2021-06-21 23:49:48 +00:00
|
|
|
OPENSSL_CONFIG="./Configure linux-generic32"
|
2021-10-03 06:17:53 +00:00
|
|
|
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
|
2022-11-18 15:02:35 +00:00
|
|
|
elif [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl/lib/libssl.a ]]; then
|
2020-10-23 13:22:58 +00:00
|
|
|
# Try to use exists libraries.
|
2021-01-26 09:54:44 +00:00
|
|
|
if [[ -f /usr/local/ssl/lib/libssl.a && $SRS_SSL_LOCAL == NO ]]; then
|
2022-11-18 15:02:35 +00:00
|
|
|
(mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl/lib && cd ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/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}/3rdpatry/openssl/include && cd ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl/include &&
|
|
|
|
cp -rf /usr/local/ssl/include/openssl .)
|
2020-04-03 13:59:32 +00:00
|
|
|
fi
|
2021-01-26 09:54:44 +00:00
|
|
|
# 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
|
2022-08-08 12:33:23 +00:00
|
|
|
# Patch for loongarch mips64, disable ASM for build failed message as bellow:
|
|
|
|
# Error: opcode not supported on this processor: mips3 (mips3)
|
2022-08-09 14:44:10 +00:00
|
|
|
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
|
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"
|
2021-01-25 14:23:42 +00:00
|
|
|
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
|
2020-04-03 06:37:48 +00:00
|
|
|
if [[ $SRS_OSX == YES ]]; then
|
2020-04-03 05:42:24 +00:00
|
|
|
export KERNEL_BITS=64;
|
|
|
|
fi
|
2021-03-01 12:47:57 +00:00
|
|
|
# Use 1.0 if required.
|
2020-11-03 08:56:05 +00:00
|
|
|
if [[ $SRS_SSL_1_0 == YES ]]; then
|
2021-03-01 12:47:57 +00:00
|
|
|
OPENSSL_AR="$SRS_TOOL_AR -r" # For openssl 1.0, MUST specifies the args for ar or build faild.
|
2022-11-18 15:02:35 +00:00
|
|
|
OPENSSL_CANDIDATE="openssl-OpenSSL_1_0_2u" &&
|
|
|
|
OPENSSL_UNZIP="tar xf ${SRS_WORKDIR}/3rdparty/$OPENSSL_CANDIDATE.tar.gz -C ${SRS_OBJS}/${SRS_PLATFORM}"
|
2021-03-01 12:47:57 +00:00
|
|
|
else
|
|
|
|
OPENSSL_AR="$SRS_TOOL_AR"
|
2022-11-18 15:02:35 +00:00
|
|
|
OPENSSL_CANDIDATE="openssl-1.1-fit" &&
|
|
|
|
OPENSSL_UNZIP="cp -R ${SRS_WORKDIR}/3rdparty/$OPENSSL_CANDIDATE ${SRS_OBJS}/${SRS_PLATFORM}/"
|
2021-03-01 12:47:57 +00:00
|
|
|
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"
|
|
|
|
#
|
2020-01-21 05:59:43 +00:00
|
|
|
# cross build not specified, if exists flag, need to rebuild for no-arm platform.
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl/lib/libssl.a ]]; then
|
|
|
|
rm -rf ${SRS_OBJS}/openssl && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl ${SRS_OBJS}/ &&
|
|
|
|
echo "The $OPENSSL_CANDIDATE is ok."
|
2020-01-21 05:59:43 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
echo "Building $OPENSSL_CANDIDATE." &&
|
|
|
|
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl \
|
|
|
|
${SRS_OBJS}/openssl &&
|
|
|
|
${OPENSSL_UNZIP} &&
|
2020-01-21 05:59:43 +00:00
|
|
|
(
|
2022-11-18 15:02:35 +00:00
|
|
|
cd ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} &&
|
|
|
|
${OPENSSL_CONFIG} --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdpatry/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}/3rdpatry/openssl ${SRS_OBJS}/ &&
|
|
|
|
echo "The $OPENSSL_CANDIDATE is ok."
|
2020-04-03 06:37:48 +00:00
|
|
|
fi
|
2020-01-21 05:59:43 +00:00
|
|
|
# check status
|
2020-04-03 06:37:48 +00:00
|
|
|
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build $OPENSSL_CANDIDATE failed, ret=$ret"; exit $ret; fi
|
2014-02-28 14:42:25 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-28 16:16:37 +00:00
|
|
|
#####################################################################################
|
|
|
|
# srtp
|
|
|
|
#####################################################################################
|
2021-10-03 11:32:06 +00:00
|
|
|
if [[ $SRS_RTC == YES ]]; then
|
|
|
|
SRTP_OPTIONS=""
|
2022-02-16 03:34:05 +00:00
|
|
|
# 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
|
2021-10-03 11:32:06 +00:00
|
|
|
# If use ASM for SRTP, we enable openssl(with ASM).
|
|
|
|
if [[ $SRS_SRTP_ASM == YES ]]; then
|
|
|
|
SRTP_OPTIONS="--enable-openssl"
|
2022-11-18 15:02:35 +00:00
|
|
|
SRTP_CONFIGURE="env PKG_CONFIG_PATH=${SRS_DEPENDS_LIBS}/openssl/lib/pkgconfig ./configure"
|
2021-10-03 11:32:06 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
SRTP_OPTIONS="--disable-openssl"
|
2021-10-03 11:32:06 +00:00
|
|
|
SRTP_CONFIGURE="./configure"
|
|
|
|
fi
|
|
|
|
if [[ $SRS_CROSS_BUILD == YES ]]; then
|
|
|
|
SRTP_OPTIONS="$SRTP_OPTIONS --host=$SRS_CROSS_BUILD_HOST"
|
|
|
|
fi
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ $OS_IS_LOONGARCH64 == YES ]]; then
|
2021-10-25 23:15:11 +00:00
|
|
|
SRTP_OPTIONS="$SRTP_OPTIONS --build=loongarch64-unknown-linux-gnu"
|
|
|
|
fi
|
2022-11-18 15:02:35 +00:00
|
|
|
# Copy and patch source files, then build and install libsrtp.
|
|
|
|
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srtp2/lib/libsrtp2.a ]]; then
|
|
|
|
rm -rf ${SRS_OBJS}/srtp2 &&
|
|
|
|
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srtp2 ${SRS_OBJS} &&
|
|
|
|
echo "The libsrtp-2-fit is ok."
|
2021-10-03 11:32:06 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
echo "Building libsrtp-2-fit."
|
|
|
|
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srtp2 \
|
|
|
|
${SRS_OBJS}/srtp2 &&
|
|
|
|
cp -rf ${SRS_WORKDIR}/3rdparty/libsrtp-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
|
2022-11-20 04:29:57 +00:00
|
|
|
# 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 &&
|
2021-10-03 11:32:06 +00:00
|
|
|
(
|
2022-11-18 15:02:35 +00:00
|
|
|
cd ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit &&
|
|
|
|
$SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdpatry/srtp2
|
|
|
|
) &&
|
2022-11-20 07:02:08 +00:00
|
|
|
# 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 &&
|
2022-11-18 15:02:35 +00:00
|
|
|
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}/3rdpatry/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
|
2020-05-27 06:20:40 +00:00
|
|
|
fi
|
2020-03-28 16:16:37 +00:00
|
|
|
|
2020-03-22 06:03:48 +00:00
|
|
|
#####################################################################################
|
|
|
|
# libopus, for WebRTC to transcode AAC with Opus.
|
|
|
|
#####################################################################################
|
2021-06-21 23:49:48 +00:00
|
|
|
# For cross build, we use opus of FFmpeg, so we don't build the libopus.
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ $SRS_RTC == YES && $SRS_CROSS_BUILD != YES ]]; then
|
2021-06-01 07:39:37 +00:00
|
|
|
# Only build static libraries if no shared FFmpeg.
|
|
|
|
if [[ $SRS_SHARED_FFMPEG == NO ]]; then
|
2021-06-21 23:49:48 +00:00
|
|
|
OPUS_OPTIONS="--disable-shared --disable-doc"
|
2021-06-01 07:39:37 +00:00
|
|
|
fi
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ $OS_IS_LOONGARCH64 == YES ]]; then
|
2021-10-25 23:15:11 +00:00
|
|
|
OPUS_OPTIONS="$OPUS_OPTIONS --build=loongarch64-unknown-linux-gnu"
|
|
|
|
fi
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/opus/lib/libopus.a ]]; then
|
|
|
|
rm -rf ${SRS_OBJS}/opus && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/opus ${SRS_OBJS}/ &&
|
|
|
|
echo "The opus-1.3.1 is ok."
|
2020-03-22 06:03:48 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
echo "Building opus-1.3.1." &&
|
|
|
|
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/opus ${SRS_OBJS}/opus &&
|
|
|
|
tar xf ${SRS_WORKDIR}/3rdparty/opus-1.3.1.tar.gz -C ${SRS_OBJS}/${SRS_PLATFORM} &&
|
2020-03-22 06:03:48 +00:00
|
|
|
(
|
2022-11-18 15:02:35 +00:00
|
|
|
cd ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 &&
|
|
|
|
./configure --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdpatry/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}/3rdpatry/opus ${SRS_OBJS}/ &&
|
|
|
|
echo "The opus-1.3.1 is ok."
|
2020-03-22 06:03:48 +00:00
|
|
|
fi
|
|
|
|
if [ ! -f ${SRS_OBJS}/opus/lib/libopus.a ]; then echo "Build opus-1.3.1 failed."; exit -1; fi
|
|
|
|
fi
|
|
|
|
|
2020-03-22 08:34:54 +00:00
|
|
|
#####################################################################################
|
2021-06-01 04:29:22 +00:00
|
|
|
# ffmpeg-fit, for WebRTC to transcode AAC with Opus.
|
2020-03-22 08:34:54 +00:00
|
|
|
#####################################################################################
|
2020-06-24 04:44:13 +00:00
|
|
|
if [[ $SRS_FFMPEG_FIT == YES ]]; then
|
2020-03-22 11:26:26 +00:00
|
|
|
FFMPEG_OPTIONS=""
|
2021-06-21 23:49:48 +00:00
|
|
|
if [[ $SRS_CROSS_BUILD == YES ]]; then
|
|
|
|
FFMPEG_CONFIGURE=./configure
|
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
FFMPEG_CONFIGURE="env PKG_CONFIG_PATH=${SRS_DEPENDS_LIBS}/opus/lib/pkgconfig ./configure"
|
2021-06-21 23:49:48 +00:00
|
|
|
fi
|
2020-04-15 02:35:38 +00:00
|
|
|
|
2022-06-15 13:13:49 +00:00
|
|
|
# Disable all asm for FFmpeg, to compatible with ARM CPU.
|
|
|
|
FFMPEG_OPTIONS="--disable-asm --disable-x86asm --disable-inline-asm"
|
2021-06-01 07:39:37 +00:00
|
|
|
# Only build static libraries if no shared FFmpeg.
|
|
|
|
if [[ $SRS_SHARED_FFMPEG == YES ]]; then
|
|
|
|
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-shared"
|
|
|
|
fi
|
2022-08-09 14:44:10 +00:00
|
|
|
# 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
|
2021-06-21 23:49:48 +00:00
|
|
|
# For cross-build.
|
|
|
|
if [[ $SRS_CROSS_BUILD == YES ]]; then
|
2021-10-03 06:35:03 +00:00
|
|
|
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-cross-compile --target-os=linux --disable-pthreads"
|
2021-10-03 06:17:53 +00:00
|
|
|
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
|
2021-06-21 23:49:48 +00:00
|
|
|
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}"
|
2022-08-09 02:02:36 +00:00
|
|
|
fi
|
|
|
|
# For cross-build.
|
|
|
|
if [[ $SRS_CROSS_BUILD == YES ]]; then
|
|
|
|
# Note that the audio might be corrupted, if use FFmpeg native opus.
|
2021-06-21 23:49:48 +00:00
|
|
|
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=opus --enable-encoder=opus"
|
|
|
|
else
|
|
|
|
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=libopus --enable-encoder=libopus --enable-libopus"
|
|
|
|
fi
|
2020-04-15 02:35:38 +00:00
|
|
|
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/ffmpeg/lib/libavcodec.a ]]; then
|
|
|
|
rm -rf ${SRS_OBJS}/ffmpeg && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/ffmpeg ${SRS_OBJS}/ &&
|
|
|
|
echo "The ffmpeg-4-fit is ok."
|
2020-03-22 08:34:54 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
echo "Building ffmpeg-4-fit." &&
|
|
|
|
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/ffmpeg \
|
|
|
|
${SRS_OBJS}/ffmpeg &&
|
|
|
|
cp -rf ${SRS_WORKDIR}/3rdparty/ffmpeg-4-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
|
2020-03-22 08:34:54 +00:00
|
|
|
(
|
2022-11-18 15:02:35 +00:00
|
|
|
cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit &&
|
2021-06-21 23:49:48 +00:00
|
|
|
$FFMPEG_CONFIGURE \
|
2022-11-18 15:02:35 +00:00
|
|
|
--prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdpatry/ffmpeg --pkg-config=pkg-config \
|
2021-06-27 23:51:02 +00:00
|
|
|
--pkg-config-flags="--static" --extra-libs="-lpthread" --extra-libs="-lm" \
|
|
|
|
--disable-everything ${FFMPEG_OPTIONS} \
|
2020-03-22 09:14:07 +00:00
|
|
|
--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 \
|
2021-06-21 23:49:48 +00:00
|
|
|
--disable-hwaccels --disable-devices --disable-audiotoolbox --disable-videotoolbox --disable-cuvid \
|
2020-04-10 00:55:04 +00:00
|
|
|
--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 \
|
2021-06-27 23:51:02 +00:00
|
|
|
--disable-lzma --disable-sdl2 --enable-decoder=aac --enable-decoder=aac_fixed --enable-decoder=aac_latm \
|
2022-11-18 15:02:35 +00:00
|
|
|
--enable-encoder=aac
|
|
|
|
) &&
|
|
|
|
# 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" ]]; 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}/3rdpatry/ffmpeg ${SRS_OBJS}/ &&
|
|
|
|
echo "The ffmpeg-4-fit is ok."
|
2020-03-22 08:34:54 +00:00
|
|
|
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-22 08:34:54 +00:00
|
|
|
fi
|
|
|
|
|
2013-11-30 03:59:21 +00:00
|
|
|
#####################################################################################
|
2018-11-27 13:17:42 +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
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
# Guess where is the ffmpeg.
|
|
|
|
SYSTEMP_FFMPEG_BIN=`which ffmpeg`
|
2020-01-21 07:22:55 +00:00
|
|
|
# Always link the ffmpeg tools if exists.
|
2022-11-18 15:02:35 +00:00
|
|
|
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/
|
2020-01-21 07:22:55 +00:00
|
|
|
fi
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ $SRS_FFMPEG_TOOL == YES ]]; then
|
|
|
|
if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then
|
|
|
|
cp -f $SYSTEMP_FFMPEG_BIN ${SRS_OBJS}/ffmpeg/bin/ &&
|
2018-11-27 13:17:42 +00:00
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
2020-01-23 23:06:30 +00:00
|
|
|
#####################################################################################
|
|
|
|
# SRT module, https://github.com/ossrs/srs/issues/1147#issuecomment-577469119
|
|
|
|
#####################################################################################
|
|
|
|
if [[ $SRS_SRT == YES ]]; then
|
2022-11-18 15:02:35 +00:00
|
|
|
# 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"
|
2020-01-23 23:06:30 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --enable-shared=0"
|
|
|
|
fi
|
2022-11-20 04:29:57 +00:00
|
|
|
# For windows build, over cygwin
|
|
|
|
if [[ $SRS_CYGWIN64 == YES ]]; then
|
|
|
|
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix"
|
|
|
|
fi
|
2022-11-18 15:02:35 +00:00
|
|
|
# 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}/3rdpatry/srt/lib/libsrt.a ]]; then
|
|
|
|
rm -rf ${SRS_OBJS}/srt && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt ${SRS_OBJS}/ &&
|
|
|
|
echo "libsrt-1-fit is ok."
|
|
|
|
else
|
|
|
|
if [[ ! -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}/3rdpatry/srt ${SRS_OBJS}/srt &&
|
|
|
|
cp -rf ${SRS_WORKDIR}/3rdparty/srt-1-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
|
|
|
|
(
|
|
|
|
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}/3rdpatry/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}/3rdpatry/srt/lib64 ]]; then
|
|
|
|
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt/lib64 ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt/lib
|
|
|
|
fi &&
|
|
|
|
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/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
|
2020-01-23 23:06:30 +00:00
|
|
|
fi
|
|
|
|
|
2014-03-03 10:28:50 +00:00
|
|
|
#####################################################################################
|
|
|
|
# build utest code
|
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ $SRS_UTEST == YES ]]; then
|
|
|
|
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gtest/googletest/include/gtest/gtest.h ]]; then
|
|
|
|
rm -rf ${SRS_OBJS}/gtest && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gtest ${SRS_OBJS}/ &&
|
|
|
|
echo "The gtest-fit is ok."
|
2014-03-04 08:13:12 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
echo "Build gtest-fit" &&
|
|
|
|
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}gtest-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gtest ${SRS_OBJS}/gtest &&
|
|
|
|
cp -rf ${SRS_WORKDIR}/3rdparty/gtest-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gtest &&
|
|
|
|
cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gtest ${SRS_OBJS}/ &&
|
|
|
|
echo "The gtest-fit is ok."
|
2014-03-04 08:13:12 +00:00
|
|
|
fi
|
|
|
|
# check status
|
2022-11-18 15:02:35 +00:00
|
|
|
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gtest-1.6.0 failed, ret=$ret"; exit $ret; fi
|
2014-03-03 10:28:50 +00:00
|
|
|
fi
|
2014-03-06 06:10:45 +00:00
|
|
|
|
|
|
|
#####################################################################################
|
|
|
|
# build gperf code
|
|
|
|
#####################################################################################
|
2022-11-18 15:02:35 +00:00
|
|
|
if [[ $SRS_GPERF == YES ]]; then
|
|
|
|
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gperf/bin/pprof ]]; then
|
|
|
|
rm -rf ${SRS_OBJS}/gperf && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gperf ${SRS_OBJS}/ &&
|
|
|
|
cp -f ${SRS_OBJS}/gperf/bin/pprof ${SRS_OBJS}/ &&
|
|
|
|
echo "The gperftools-2-fit is ok."
|
2014-03-06 06:10:45 +00:00
|
|
|
else
|
2022-11-18 15:02:35 +00:00
|
|
|
echo "Build gperftools-2-fit" &&
|
|
|
|
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gperf \
|
|
|
|
${SRS_OBJS}/gperf ${SRS_OBJS}/pprof &&
|
|
|
|
cp -rf ${SRS_WORKDIR}/3rdparty/gperftools-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
|
2014-03-06 06:10:45 +00:00
|
|
|
(
|
2022-11-18 15:02:35 +00:00
|
|
|
cd ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2-fit &&
|
|
|
|
./configure --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdpatry/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}/3rdpatry/gperf ${SRS_OBJS}/ &&
|
|
|
|
cp -f ${SRS_OBJS}/gperf/bin/pprof ${SRS_OBJS}/ &&
|
|
|
|
echo "The gperftools-2-fit is ok."
|
2014-03-06 06:10:45 +00:00
|
|
|
fi
|
|
|
|
# check status
|
2021-12-26 09:30:51 +00:00
|
|
|
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gperftools-2-fit failed, ret=$ret"; exit $ret; fi
|
2014-03-06 06:10:45 +00:00
|
|
|
fi
|