1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix #155, #135, support osx(darwin) for mac pro. 2.0.137.

This commit is contained in:
winlin 2015-03-10 12:50:27 +08:00
parent 20fb5f3e8e
commit db7ddfd510
16 changed files with 1075 additions and 52 deletions

View file

@ -16,8 +16,28 @@ echo "#define SRS_AUTO_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUT
echo "#define SRS_AUTO_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
# export the preset.
if [ $SRS_OSX = YES ]; then
echo "#define SRS_OSX" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_X86_X64 = YES ]; then
echo "#define SRS_X86_X64" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_ARM_UBUNTU12 = YES ]; then
echo "#define SRS_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
echo "#define SRS_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_PI = YES ]; then
echo "#define SRS_PI" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_CUBIE = YES ]; then
echo "#define SRS_CUBIE" >> $SRS_AUTO_HEADERS_H
fi
# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################

View file

@ -41,6 +41,24 @@ function Ubuntu_prepare()
return 0;
fi
fi
# for arm, install the cross build tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
require_sudoer "sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi success"
fi
fi
# for mips, user must installed the tool chain.
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "user must install the tool chain: $SrsArmCC"
return 2
fi
fi
OS_IS_UBUNTU=YES
echo "Ubuntu detected, install tools if needed"
@ -110,24 +128,6 @@ function Ubuntu_prepare()
fi
fi
# for arm, install the cross build tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
require_sudoer "sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi success"
fi
fi
# for mips, user must installed the tool chain.
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "user must install the tool chain: $SrsArmCC"
return 2
fi
fi
echo "Ubuntu install tools success"
return 0
}
@ -144,6 +144,12 @@ function Centos_prepare()
if [[ ! -f /etc/redhat-release ]]; then
return 0;
fi
# for arm, install the cross build tool chain.
if [ $SRS_EMBEDED_CPU = YES ]; then
echo "embeded(arm/mips) is invalid for CentOS"
return 1
fi
OS_IS_CENTOS=YES
echo "Centos detected, install tools if needed"
@ -220,12 +226,6 @@ function Centos_prepare()
fi
fi
# for arm, install the cross build tool chain.
if [ $SRS_EMBEDED_CPU = YES ]; then
echo "embeded(arm/mips) is invalid for CentOS"
return 1
fi
echo "Centos install tools success"
return 0
}
@ -233,13 +233,142 @@ function Centos_prepare()
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "CentOS prepare failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# for Centos, auto install tools by yum
#####################################################################################
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
# for arm, install the cross build tool chain.
if [ $SRS_EMBEDED_CPU = YES ]; then
echo "embeded(arm/mips) is invalid for OSX"
return 1
fi
OS_IS_OSX=YES
echo "OSX detected, install tools if needed"
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
if [ $SRS_FFMPEG_TOOL = YES ]; then
automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install automake"
echo "brew install automake"
brew install automake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install automake success"
fi
autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install autoconf"
echo "brew install autoconf"
brew install autoconf; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install autoconf success"
fi
libtool --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install libtool"
echo "brew install libtool"
brew install libtool; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install libtool success"
fi
if [[ ! -f /usr/include/pcre.h ]]; then
echo "install pcre-devel"
echo "brew install pcre-devel"
brew install pcre-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install pcre-devel success"
fi
if [[ ! -f /usr/include/zlib.h ]]; then
echo "install zlib-devel"
echo "brew install zlib-devel"
brew install zlib-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install zlib-devel success"
fi
fi
echo "OSX install tools success"
return 0
}
# donot prepare tools, for srs-librtmp depends only gcc and g++.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$ret"; exit $ret; fi
fi
# requires the osx when os
if [ $OS_IS_OSX = YES ]; then
if [ $SRS_OSX = NO ]; then
echo "OSX detected, must specifies the --osx"
exit 1
fi
if [ $SRS_HTTP_API = YES ]; then
echo "OSX does not support http-api, use --without-http-api"
exit 1
fi
if [ $SRS_STAT = YES ]; then
echo "OSX does not support stat, use --without-stat"
exit 1
fi
fi
#####################################################################################
# st-1.9
#####################################################################################
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
# check the arm flag file, if flag changed, need to rebuild the st.
_ST_MAKE=linux-debug
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL"
# for osx, use darwin for st, donot use epoll.
if [ $OS_IS_OSX = YES ]; then
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS=""
fi
# memory leak for linux-optimized
# @see: https://github.com/winlinvip/simple-rtmp-server/issues/197
if [ $SRS_EMBEDED_CPU = YES ]; then
@ -253,9 +382,9 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 &&
patch -p0 < ../../3rdparty/patches/1.st.arm.patch &&
patch -p0 -R < ../../3rdparty/patches/1.st.arm.patch &&
make CC=${SrsArmCC} AR=${SrsArmAR} LD=${SrsArmLD} RANDLIB=${SrsArmRANDLIB} \
EXTRA_CFLAGS="-DMD_HAVE_EPOLL" ${_ST_MAKE} &&
EXTRA_CFLAGS=${_ST_EXTRA_CFLAGS} ${_ST_MAKE} &&
cd .. && rm -rf st && ln -sf st-1.9/obj st &&
cd .. && touch ${SRS_OBJS}/_flag.st.arm.tmp
)
@ -268,7 +397,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 &&
make ${_ST_MAKE} EXTRA_CFLAGS="-DMD_HAVE_EPOLL" &&
make ${_ST_MAKE} ${_ST_EXTRA_CFLAGS} &&
cd .. && rm -rf st && ln -sf st-1.9/obj st &&
cd .. && rm -f ${SRS_OBJS}/_flag.st.arm.tmp
)
@ -293,6 +422,7 @@ if [ $SRS_HTTP_PARSER = YES ]; then
(
rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
patch -p0 -R < ../../3rdparty/patches/2.http.parser.patch &&
sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&
sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&
make CC=${SrsArmCC} AR=${SrsArmAR} package &&
@ -309,8 +439,7 @@ if [ $SRS_HTTP_PARSER = YES ]; then
(
rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&
sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&
patch -p0 -R < ../../3rdparty/patches/2.http.parser.patch &&
make package &&
cd .. && rm -rf hp && ln -sf http-parser-2.1 hp &&
cd .. && rm -f ${SRS_OBJS}/_flag.st.hp.tmp
@ -402,7 +531,7 @@ if [ $SRS_HTTP_CALLBACK = YES ]; then
if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then
echo "CherryPy-3.2.4 is ok.";
else
require_sudoer "configure --with-http-callback"
require_sudoer "install CherryPy-3.2.4"
echo "install CherryPy-3.2.4";
(
sudo rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} &&
@ -454,9 +583,11 @@ fi
#####################################################################################
# extra configure options
CONFIGURE_TOOL="./config"
EXTRA_CONFIGURE=""
if [ $SRS_EMBEDED_CPU = YES ]; then
CONFIGURE_TOOL="./Configure"
CONFIGURE_TOOL="./Configure linux-armv4"
fi
if [ $SRS_OSX = YES ]; then
CONFIGURE_TOOL="./Configure darwin64-`uname -m`-cc"
fi
# @see http://www.openssl.org/news/secadv_20140407.txt
# Affected users should upgrade to OpenSSL 1.0.1g. Users unable to immediately
@ -475,7 +606,7 @@ if [ $SRS_SSL = YES ]; then
(
rm -rf ${SRS_OBJS}/openssl-1.0.1f && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/openssl-1.0.1f.zip && cd openssl-1.0.1f &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared no-asm linux-armv4 -DOPENSSL_NO_HEARTBEATS ${EXTRA_CONFIGURE} &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared no-asm &&
make CC=${SrsArmCC} GCC=${SrsArmGCC} AR="${SrsArmAR} r" \
LD=${SrsArmLD} LINK=${SrsArmGCC} RANDLIB=${SrsArmRANDLIB} &&
make install_sw &&
@ -492,7 +623,7 @@ if [ $SRS_SSL = YES ]; then
(
rm -rf ${SRS_OBJS}/openssl-1.0.1f && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/openssl-1.0.1f.zip && cd openssl-1.0.1f &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared -DOPENSSL_NO_HEARTBEATS ${EXTRA_CONFIGURE} &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared &&
make && make install_sw &&
cd .. && rm -rf openssl && ln -sf openssl-1.0.1f/_release openssl &&
cd .. && rm -f ${SRS_OBJS}/_flag.ssl.arm.tmp

View file

@ -68,6 +68,8 @@ SRS_EXPORT_LIBRTMP_SINGLE=NO
# presets
# for x86/x64 pc/servers
SRS_X86_X64=NO
# for osx system
SRS_OSX=NO
# armhf(v7cpu) built on ubuntu12
SRS_ARM_UBUNTU12=NO
# mips built on ubuntu12
@ -166,6 +168,7 @@ Options:
Presets:
--x86-x64 [default] for x86/x64 cpu, common pc and servers.
--osx for osx(darwin) system to build SRS.
--pi for raspberry-pi(directly build), open features hls/ssl/static.
--cubie for cubieboard(directly build), open features except ffmpeg/nginx.
--arm alias for --with-arm-ubuntu12, for ubuntu12, arm crossbuild
@ -260,6 +263,7 @@ function parse_user_option() {
--log-trace) SRS_LOG_TRACE=YES ;;
--x86-x64) SRS_X86_X64=YES ;;
--osx) SRS_OSX=YES ;;
--arm) SRS_ARM_UBUNTU12=YES ;;
--mips) SRS_MIPS_UBUNTU12=YES ;;
--pi) SRS_PI=YES ;;
@ -331,7 +335,9 @@ function apply_user_presets() {
if [ $SRS_PI = NO ]; then
if [ $SRS_CUBIE = NO ]; then
if [ $SRS_X86_X64 = NO ]; then
SRS_X86_X64=YES; opt="--x86-x64 $opt";
if [ $SRS_OSX = NO ]; then
SRS_X86_X64=YES; opt="--x86-x64 $opt";
fi
fi
fi
fi
@ -551,7 +557,7 @@ function apply_user_presets() {
SRS_HTTP_CALLBACK=YES
SRS_HTTP_SERVER=YES
SRS_STREAM_CASTER=YES
SRS_HTTP_API=YES
SRS_HTTP_API=NO
SRS_LIBRTMP=YES
SRS_RESEARCH=NO
SRS_UTEST=YES
@ -563,6 +569,32 @@ function apply_user_presets() {
SRS_STATIC=NO
fi
# for osx(darwin)
if [ $SRS_OSX = YES ]; then
SRS_HLS=YES
SRS_DVR=YES
SRS_NGINX=NO
SRS_SSL=YES
SRS_FFMPEG_TOOL=NO
SRS_TRANSCODE=YES
SRS_INGEST=YES
SRS_STAT=NO
SRS_HTTP_PARSER=YES
SRS_HTTP_CALLBACK=YES
SRS_HTTP_SERVER=YES
SRS_STREAM_CASTER=YES
SRS_HTTP_API=NO
SRS_LIBRTMP=YES
SRS_RESEARCH=NO
SRS_UTEST=NO
SRS_GPERF=NO
SRS_GPERF_MC=NO
SRS_GPERF_MP=NO
SRS_GPERF_CP=NO
SRS_GPROF=NO
SRS_STATIC=NO
fi
# if dev specified, open features if possible.
if [ $SRS_DEV = YES ]; then
SRS_HLS=YES