1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-14 20:31:56 +00:00
This commit is contained in:
winlin 2014-05-04 18:38:08 +08:00
parent f8e8c81e50
commit 1e9561150a
5 changed files with 148 additions and 40 deletions

View file

@ -107,7 +107,7 @@ function Ubuntu_prepare()
# for arm, install the cross build tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
arm-linux-gnueabi-gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; 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
@ -115,6 +115,14 @@ function Ubuntu_prepare()
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
}
@ -203,8 +211,8 @@ function Centos_prepare()
fi
# for arm, install the cross build tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
echo "arm-ubuntu12 is invalid for CentOS"
if [ $SRS_EMBEDED_CPU = YES ]; then
echo "embeded(arm/mips) is invalid for CentOS"
return 1
fi
@ -217,7 +225,7 @@ Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "CentOS prepare failed, r
# st-1.9
#####################################################################################
# check the arm flag file, if flag changed, need to rebuild the st.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
if [ $SRS_EMBEDED_CPU = YES ]; then
# ok, arm specified, if the flag filed does not exists, need to rebuild.
if [[ -f ${SRS_OBJS}/_flag.st.arm.tmp && -f ${SRS_OBJS}/st/libst.a && -f ${SRS_OBJS}/st/libst.so ]]; then
echo "st-1.9t for arm is ok.";
@ -263,7 +271,7 @@ if [ ! -f ${SRS_OBJS}/st/libst.so ]; then echo "build st-1.9 failed."; exit -1;
# check the arm flag file, if flag changed, need to rebuild the st.
if [ $SRS_HTTP_PARSER = YES ]; then
# ok, arm specified, if the flag filed does not exists, need to rebuild.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
if [ $SRS_EMBEDED_CPU = YES ]; then
if [[ -f ${SRS_OBJS}/_flag.st.hp.tmp && -f ${SRS_OBJS}/hp/http_parser.h && -f ${SRS_OBJS}/hp/libhttp_parser.a ]]; then
echo "http-parser-2.1 for arm is ok.";
else
@ -336,7 +344,7 @@ END
# create the nginx dir, for http-server if not build nginx
rm -rf ${SRS_OBJS}/nginx && mkdir -p ${SRS_OBJS}/nginx
# make nginx
__SRS_BUILD_NGINX=NO; if [ $SRS_ARM_UBUNTU12 = NO ]; then if [ $SRS_NGINX = YES ]; then __SRS_BUILD_NGINX=YES; fi fi
__SRS_BUILD_NGINX=NO; if [ $SRS_EMBEDED_CPU = NO ]; then if [ $SRS_NGINX = YES ]; then __SRS_BUILD_NGINX=YES; fi fi
if [ $__SRS_BUILD_NGINX = YES ]; then
if [[ -f ${SRS_OBJS}/nginx/sbin/nginx ]]; then
echo "nginx-1.5.7 is ok.";
@ -473,7 +481,7 @@ if [ $SRS_SSL = YES ]; then
echo "warning: donot compile ssl, use system ssl"
else
# check the arm flag file, if flag changed, need to rebuild the st.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
if [ $SRS_EMBEDED_CPU = YES ]; then
# ok, arm specified, if the flag filed does not exists, need to rebuild.
if [[ -f ${SRS_OBJS}/_flag.ssl.arm.tmp && -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then
echo "openssl-1.0.1f for arm is ok.";
@ -633,15 +641,30 @@ else
fi
#####################################################################################
# for arm.
# for embeded.
#####################################################################################
if [ $SRS_EMBEDED_CPU = YES ]; then
echo "#define SRS_AUTO_EMBEDED_CPU" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_EMBEDED_CPU" >> $SRS_AUTO_HEADERS_H
fi
# arm
if [ $SRS_ARM_UBUNTU12 = YES ]; then
echo "#define SRS_AUTO_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
# mips
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
echo "#define SRS_AUTO_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
echo "" >> $SRS_AUTO_HEADERS_H
# prefix
echo "#define SRS_AUTO_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H

View file

@ -56,6 +56,8 @@ SRS_USE_SYS_SSL=NO
SRS_X86_X64=NO
# armhf(v7cpu) built on ubuntu12
SRS_ARM_UBUNTU12=NO
# mips built on ubuntu12
SRS_MIPS_UBUNTU12=NO
# dev, open all features for dev, no gperf/prof/arm.
SRS_DEV=NO
# raspberry-pi, open hls/ssl/static
@ -68,6 +70,10 @@ SRS_PURE_RTMP=NO
SRS_RTMP_HLS=NO
# the most fast compile, nothing, only support vp6 RTMP.
SRS_DISABLE_ALL=NO
#
# calc
# whether embed cpu, arm/mips
SRS_EMBEDED_CPU=NO
#####################################################################################
# menu
@ -187,6 +193,7 @@ function parse_user_option() {
--with-gcp) SRS_GPERF_CP=YES ;;
--with-gprof) SRS_GPROF=YES ;;
--with-arm-ubuntu12) SRS_ARM_UBUNTU12=YES ;;
--with-mips-ubuntu12) SRS_MIPS_UBUNTU12=YES ;;
--without-ssl) SRS_SSL=NO ;;
--without-hls) SRS_HLS=NO ;;
@ -208,6 +215,7 @@ function parse_user_option() {
--without-gcp) SRS_GPERF_CP=NO ;;
--without-gprof) SRS_GPROF=NO ;;
--without-arm-ubuntu12) SRS_ARM_UBUNTU12=NO ;;
--without-mips-ubuntu12) SRS_MIPS_UBUNTU12=NO ;;
--jobs) SRS_JOBS=${value} ;;
--prefix) SRS_PREFIX=${value} ;;
@ -215,6 +223,7 @@ function parse_user_option() {
--x86-x64) SRS_X86_X64=YES ;;
--arm) SRS_ARM_UBUNTU12=YES ;;
--mips) SRS_MIPS_UBUNTU12=YES ;;
--pi) SRS_PI=YES ;;
--dev) SRS_DEV=YES ;;
--fast) SRS_FAST=YES ;;
@ -266,9 +275,11 @@ function apply_user_presets() {
if [ $SRS_DISABLE_ALL = NO ]; then
if [ $SRS_DEV = NO ]; then
if [ $SRS_ARM_UBUNTU12 = NO ]; then
if [ $SRS_PI = NO ]; then
if [ $SRS_X86_X64 = NO ]; then
SRS_X86_X64=YES; opt="--x86-x64 $opt";
if [ $SRS_MIPS_UBUNTU12 = NO ]; then
if [ $SRS_PI = NO ]; then
if [ $SRS_X86_X64 = NO ]; then
SRS_X86_X64=YES; opt="--x86-x64 $opt";
fi
fi
fi
fi
@ -277,6 +288,14 @@ function apply_user_presets() {
fi
fi
fi
# whether embeded cpu.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
SRS_EMBEDED_CPU=YES
fi
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
SRS_EMBEDED_CPU=YES
fi
# all disabled.
if [ $SRS_DISABLE_ALL = YES ]; then
@ -400,9 +419,35 @@ function apply_user_presets() {
SRS_GPERF_MP=NO
SRS_GPERF_CP=NO
SRS_GPROF=NO
# TODO: FIXME: need static? maybe donot.
SRS_STATIC=YES
fi
# if mips specified, set some default to disabled.
if [ $SRS_MIPS_UBUNTU12 = 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_HTTP_PARSER=YES
SRS_HTTP_CALLBACK=YES
SRS_HTTP_SERVER=YES
SRS_HTTP_API=YES
SRS_LIBRTMP=YES
SRS_BWTC=NO
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
# defaults for x86/x64
if [ $SRS_X86_X64 = YES ]; then
SRS_HLS=YES
@ -535,6 +580,7 @@ function regenerate_options() {
if [ $SRS_GPERF_CP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gcp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gcp"; fi
if [ $SRS_GPROF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gprof"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gprof"; fi
if [ $SRS_ARM_UBUNTU12 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-arm-ubuntu12"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-arm-ubuntu12"; fi
if [ $SRS_MIPS_UBUNTU12 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-mips-ubuntu12"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-mips-ubuntu12"; fi
if [ $SRS_STATIC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --static"; fi
echo "regenerate config: ${SRS_AUTO_CONFIGURE}"
}
@ -568,9 +614,9 @@ function check_option_conflicts() {
echo "gmc/gmp/gcp not compatible with gprof, see: ./configure --help"; __check_ok=NO;
fi fi
# check arm, if arm enabled, only allow st/ssl/librtmp,
# check embeded(arm/mips), if embeded enabled, only allow st/ssl/librtmp,
# user should disable all other features
if [ $SRS_ARM_UBUNTU12 = YES ]; then
if [ $SRS_EMBEDED_CPU = YES ]; then
if [ $SRS_FFMPEG_TOOL = YES ]; then echo "ffmpeg for arm is not available, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_BWTC = YES ]; then echo "bwtc for arm is not available, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_RESEARCH = YES ]; then echo "research for arm is not available, see: ./configure --help"; __check_ok=NO; fi
@ -582,11 +628,9 @@ function check_option_conflicts() {
fi
# if x86/x64 or directly build, never use static
if [ $SRS_ARM_UBUNTU12 = NO ]; then
if [ $SRS_PI = NO ]; then
if [ $SRS_STATIC = YES ]; then
echo "x86/x64 should never use static, see: ./configure --help"; __check_ok=NO;
fi
if [ $SRS_X86_X64 = YES ]; then
if [ $SRS_STATIC = YES ]; then
echo "x86/x64 should never use static, see: ./configure --help"; __check_ok=NO;
fi
fi
@ -609,6 +653,7 @@ function check_option_conflicts() {
if [ $SRS_GPERF_CP = RESERVED ]; then echo "you must specifies the gperf-cp, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_GPROF = RESERVED ]; then echo "you must specifies the gprof, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_ARM_UBUNTU12 = RESERVED ]; then echo "you must specifies the arm-ubuntu12, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_MIPS_UBUNTU12 = RESERVED ]; then echo "you must specifies the mips-ubuntu12, see: ./configure --help"; __check_ok=NO; fi
if [[ -z $SRS_PREFIX ]]; then echo "you must specifies the prefix, see: ./configure --prefix"; __check_ok=NO; fi
if [ $__check_ok = NO ]; then
exit 1;

61
trunk/configure vendored
View file

@ -47,15 +47,35 @@ echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
# generate auto headers file, depends on the finished of options.sh
#####################################################################################
if [ $SRS_ARM_UBUNTU12 = YES ]; then
__SrsArmCC="arm-linux-gnueabi-gcc";
__SrsArmGCC="arm-linux-gnueabi-gcc";
__SrsArmCXX="arm-linux-gnueabi-g++";
__SrsArmAR="arm-linux-gnueabi-ar";
__SrsArmLD="arm-linux-gnueabi-ld";
__SrsArmRANDLIB="arm-linux-gnueabi-ranlib";
fi
__SrsArmCC="mipsel-openwrt-linux-gcc";
__SrsArmGCC="mipsel-openwrt-linux-gcc";
__SrsArmCXX="mipsel-openwrt-linux-g++";
__SrsArmAR="mipsel-openwrt-linux-ar";
__SrsArmLD="mipsel-openwrt-linux-ld";
__SrsArmRANDLIB="mipsel-openwrt-linux-ranlib";
fi
# the arm-ubuntu12 options for make for depends
if [[ -z $SrsArmCC ]]; then SrsArmCC="arm-linux-gnueabi-gcc"; fi
if [[ -z $SrsArmGCC ]]; then SrsArmGCC="arm-linux-gnueabi-gcc"; fi
if [[ -z $SrsArmCXX ]]; then SrsArmCXX="arm-linux-gnueabi-g++"; fi
if [[ -z $SrsArmAR ]]; then SrsArmAR="arm-linux-gnueabi-ar"; fi
if [[ -z $SrsArmLD ]]; then SrsArmLD="arm-linux-gnueabi-ld"; fi
if [[ -z $SrsArmRANDLIB ]]; then SrsArmRANDLIB="arm-linux-gnueabi-ranlib"; fi
echo "cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB"
echo "#define SRS_AUTO_ARM_TOOL_CHAIN \"cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB\"" >> $SRS_AUTO_HEADERS_H
if [[ -z $SrsArmCC ]]; then SrsArmCC=__SrsArmCC; fi
if [[ -z $SrsArmGCC ]]; then SrsArmGCC=__SrsArmGCC; fi
if [[ -z $SrsArmCXX ]]; then SrsArmCXX=__SrsArmCXX; fi
if [[ -z $SrsArmAR ]]; then SrsArmAR=__SrsArmAR; fi
if [[ -z $SrsArmLD ]]; then SrsArmLD=__SrsArmLD; fi
if [[ -z $SrsArmRANDLIB ]]; then SrsArmRANDLIB=__SrsArmRANDLIB; fi
# write to source file
if [ $SRS_EMBEDED_CPU = YES ]; then
echo "cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB"
echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB\"" >> $SRS_AUTO_HEADERS_H
else
echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"normal x86/x64 gcc\"" >> $SRS_AUTO_HEADERS_H
fi
echo "" >> $SRS_AUTO_HEADERS_H
# apply user options.
@ -185,8 +205,8 @@ DESTDIR=\$(SRS_PREFIX)
END
# arm, ubuntu12, use arm tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
# embeded, ubuntu12, use embeded tool chain.
if [ $SRS_EMBEDED_CPU = YES ]; then
cat << END >> ${SRS_MAKEFILE}
default:
\$(MAKE) GCC=${SrsArmGCC} CXX=${SrsArmCXX} AR=${SrsArmAR} LINK=${SrsArmCXX} _default
@ -401,15 +421,13 @@ if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS
LibGperfRoot=""; LibGperfFile=""
if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS}/gperf/include"; LibGperfFile="${SRS_OBJS}/gperf/lib/libtcmalloc_and_profiler.a"; fi
# the link options, always use static link
SrsLinkOptions="";
if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="-lssl"; fi fi
if [ $SRS_ARM_UBUNTU12 = YES ]; then
# for arm cross build tool chain, always use static and ldl.
SrsLinkOptions="${SrsLinkOptions} -static -ldl";
else
# for x86/64/arm directly build, use static or ldl.
if [ $SRS_STATIC = YES ]; then SrsLinkOptions="${SrsLinkOptions} -static"; else SrsLinkOptions="${SrsLinkOptions} -ldl"; fi
fi
SrsLinkOptions="-ldl";
if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lssl"; fi fi
# if static specified, add static
# TODO: FIXME: remove static.
if [ $SRS_STATIC = YES ]; then SrsLinkOptions="${SrsLinkOptions} -static"; fi
# if mips, add -lgcc_eh, or stl compile failed.
if [ $SRS_MIPS_UBUNTU12 = NO ]; then SrsLinkOptions="${SrsLinkOptions} -lgcc_eh"; fi
#####################################################################################
# Modules, compile each module, then link to binary
@ -618,6 +636,11 @@ if [ $SRS_ARM_UBUNTU12 = YES ]; then
else
echo -e "${GREEN}note: arm-ubuntu12(armhf, v7cpu) for srs are not builded${BLACK}"
fi
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
echo -e "${GREEN}mips-ubuntu12 for srs are builded${BLACK}"
else
echo -e "${GREEN}note: mips-ubuntu12 for srs are not builded${BLACK}"
fi
#####################################################################################
# next step

View file

@ -13,6 +13,9 @@ help=NO
X86_X64=NO
ARM=NO
PI=NO
MIPS=NO
#
EMBEDED=NO
##################################################################################
##################################################################################
@ -32,6 +35,7 @@ do
--help) help=yes ;;
--x86-x64) X86_X64=YES ;;
--mips) MIPS=YES ;;
--arm) ARM=YES ;;
--pi) PI=YES ;;
@ -48,11 +52,16 @@ if [ $help = yes ]; then
--x86-x64 for x86-x64 platform, configure/make/package.
--arm for arm cross-build platform, configure/make/package.
--mips for mips cross-build platform, configure/make/package.
--pi for pi platform, configure/make/package.
END
exit 0
fi
# embeded(arm/mips)
if [ $ARM = YES ]; then EMBEDED=YES; fi
if [ $MIPS = YES ]; then EMBEDED=YES; fi
# discover the current work dir, the log and access.
echo "argv[0]=$0"
if [[ ! -f $0 ]]; then
@ -93,6 +102,11 @@ if [ $ARM = YES ]; then
cd $work_dir &&
./configure --arm --prefix=$INSTALL && make
) >> $log 2>&1
elif [ $MIPS = YES ]; then
(
cd $work_dir &&
./configure --mips --prefix=$INSTALL && make
) >> $log 2>&1
elif [ $PI = YES ]; then
(
cd $work_dir &&
@ -104,7 +118,7 @@ elif [ $X86_X64 = YES ]; then
./configure --x86-x64 --prefix=$INSTALL && make
) >> $log 2>&1
else
failed_msg "invalid option, must be --x86-x64/--arm/--pi, see --help"; exit 1;
failed_msg "invalid option, must be --x86-x64/--arm/--mips/--pi, see --help"; exit 1;
fi
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "build srs failed"; exit $ret; fi
ok_msg "build srs success"
@ -134,10 +148,13 @@ if [ $ARM = YES ]; then
arm_cpu=`arm-linux-gnueabi-readelf --arch-specific ${build_objs}/srs|grep Tag_CPU_arch:|awk '{print $2}'`
os_machine=arm${arm_cpu}cpu
fi
if [ $MIPS = YES ]; then
os_machine=mips
fi
ok_msg "machine: $os_machine"
# generate zip dir and zip filename
if [ $ARM = YES ]; then
if [ $EMBEDED = YES ]; then
srs_version_major=`cat $work_dir/src/core/srs_core.hpp| grep '#define VERSION_MAJOR'| awk '{print $3}'|xargs echo` &&
srs_version_minor=`cat $work_dir/src/core/srs_core.hpp| grep '#define VERSION_MINOR'| awk '{print $3}'|xargs echo` &&
srs_version_revision=`cat $work_dir/src/core/srs_core.hpp| grep '#define VERSION_REVISION'| awk '{print $3}'|xargs echo` &&

View file

@ -96,7 +96,7 @@ int main(int argc, char** argv)
srs_trace("configure: "SRS_AUTO_USER_CONFIGURE);
srs_trace("features: "SRS_AUTO_CONFIGURE);
#ifdef SRS_AUTO_ARM_UBUNTU12
srs_trace("arm tool chain: "SRS_AUTO_ARM_TOOL_CHAIN);
srs_trace("arm tool chain: "SRS_AUTO_EMBEDED_TOOL_CHAIN);
#endif
if ((ret = _srs_server->initialize()) != ERROR_SUCCESS) {