1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 19:31:53 +00:00
srs/trunk/configure

254 lines
9.1 KiB
Text
Raw Normal View History

2013-10-17 12:58:04 +00:00
#!/bin/bash
2014-02-28 05:17:31 +00:00
#####################################################################################
# the main output dir, all configure and make output are in this dir.
#####################################################################################
# create the main objs
2013-11-27 14:41:58 +00:00
SRS_OBJS="objs"
mkdir -p ${SRS_OBJS}
2013-10-17 12:58:04 +00:00
2014-02-28 05:17:31 +00:00
#####################################################################################
# parse user options, set the variables like SRS_SSL/SRS_HLS/SRS_FFMPEG/SRS_HTTP
#####################################################################################
# parse options, exit with error when parse options invalid.
. auto/options.sh
2013-11-27 14:41:58 +00:00
# clean the exists
2014-02-28 05:17:31 +00:00
# do this only when the options is ok.
2013-11-27 14:41:58 +00:00
if [[ -f Makefile ]]; then
make clean
2013-11-26 08:45:50 +00:00
fi
2014-02-28 05:17:31 +00:00
#####################################################################################
# generate auto headers file, depends on the finished of options.sh
#####################################################################################
# write user options to headers
SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
2013-11-27 14:41:58 +00:00
echo "#define SRS_CONFIGURE \"${SRS_CONFIGURE}\"" > $SRS_AUTO_HEADERS_H
2013-12-07 11:27:31 +00:00
echo "#define SRS_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
2013-11-27 14:41:58 +00:00
# apply user options.
. auto/depends.sh
# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H
2013-11-26 08:45:50 +00:00
2013-10-17 12:58:04 +00:00
#####################################################################################
# generate Makefile.
#####################################################################################
2014-02-28 07:42:35 +00:00
#####################################################################################
echo "generate Makefile"
2014-02-28 05:17:31 +00:00
SRS_MAKEFILE="Makefile"
2013-11-27 14:41:58 +00:00
cat << END > ${SRS_MAKEFILE}
.PHONY: default help clean server bandwidth _prepare_dir
default: server bandwidth
2013-10-17 12:58:04 +00:00
help:
@echo "Usage: make <help>|<clean>|<server>|<bandwidth>"
2013-10-17 12:58:04 +00:00
@echo " help display this help menu"
@echo " clean cleanup project"
@echo " server build the srs(simple rtmp server) over st(state-threads)"
@echo " bandwidth build the bandwidth test client tool."
2013-10-17 12:58:04 +00:00
clean:
2014-02-28 06:38:27 +00:00
(rm -f Makefile; cd ${SRS_OBJS}; rm -rf srs bandwidth Makefile *.hpp src st_*_load research)
2013-10-17 12:58:04 +00:00
server: _prepare_dir
@echo "build the srs(simple rtmp server) over st(state-threads)"
2013-12-15 04:44:09 +00:00
\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} srs
2013-10-17 12:58:04 +00:00
bandwidth: _prepare_dir
@echo "build the bandwidth test client tool"
\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} bandwidth
2013-10-17 12:58:04 +00:00
# the ./configure will generate it.
_prepare_dir:
2013-11-27 14:41:58 +00:00
@mkdir -p ${SRS_OBJS}
2013-10-17 12:58:04 +00:00
END
2014-02-28 07:42:35 +00:00
#####################################################################################
# build tools or compiler args.
2013-10-17 12:58:04 +00:00
# the performance analysis, uncomments the following when use gperf to analysis the performance. see third-party/readme.txt
Performance="-pg"
2013-10-17 12:58:04 +00:00
# enable gdb debug
GDBDebug="-g -O0"
# the warning level.
WarnLevel="-Wall"
2013-10-17 12:58:04 +00:00
# the compile standard.
CppStd="-ansi"
2013-10-17 12:58:04 +00:00
# the cxx flag generated.
CXXFLAGS="${CppStd} ${WarnLevel} ${GDBDebug}"
#CXXFLAGS="${CppStd} ${WarnLevel} ${GDBDebug} ${Performance}"
2013-11-27 14:41:58 +00:00
cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}
CC ?= gcc
GCC ?= gcc
2014-02-28 06:38:27 +00:00
CXX ?= g++
AR ?= ar
CXXFLAGS = ${CXXFLAGS}
LINK = g++
2013-10-17 12:58:04 +00:00
.PHONY: default srs bandwidth
2013-10-17 12:58:04 +00:00
default:
END
2014-02-28 07:42:35 +00:00
#####################################################################################
# Libraries, external library to build in srs,
# header(.h): add to ModuleLibIncs if need the specified library. for example, LibSTRoot
# library(.a): add to ModuleLibFiles if binary need the specifeid library. for example, LibSTfile
#
# st(state-threads) the basic network library for SRS.
2013-11-27 14:41:58 +00:00
LibSTRoot="${SRS_OBJS}/st"
2013-10-17 12:58:04 +00:00
LibSTfile="${LibSTRoot}/libst.a"
2014-02-28 07:42:35 +00:00
# hp(http-parser) the http request/url parser, for SRS to support HTTP callback.
LibHttpParserRoot=""
LibHttpParserfile=""
if [ $SRS_HTTP = YES ]; then
LibHttpParserRoot="${SRS_OBJS}/hp"
LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"
fi
# openssl-1.0.1f, for the RTMP complex handshake.
LibSSLRoot=""
LibSSLfile=""
if [ $SRS_SSL = YES ]; then
LibSSLRoot="${SRS_OBJS}/openssl/include"
LibSSLfile="${SRS_OBJS}/openssl/lib/libssl.a ${SRS_OBJS}/openssl/lib/libcrypto.a"
fi
2013-10-17 12:58:04 +00:00
2014-02-28 07:42:35 +00:00
#####################################################################################
# Modules, compile each module, then link to binary
#
#Core, depends only on system apis.
2013-10-17 12:58:04 +00:00
MODULE_ID="CORE"
MODULE_DEPENDS=()
2014-03-01 02:14:25 +00:00
ModuleLibIncs=(${SRS_OBJS})
2014-03-01 02:19:11 +00:00
MODULE_FILES=("srs_core" "srs_core_autofree")
2014-03-01 02:05:14 +00:00
MODULE_DIR="src/core" . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}"
#
#Kernel, depends on core, provides error/log/config, nothing about stream information.
MODULE_ID="KERNEL"
MODULE_DEPENDS=("CORE")
ModuleLibIncs=(${SRS_OBJS})
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_reload" "srs_kernel_stream"
"srs_kernel_buffer")
MODULE_DIR="src/kernel" . auto/modules.sh
KERNEL_OBJS="${MODULE_OBJS[@]}"
#
2014-03-01 06:05:58 +00:00
#RTMP Protocol, depends on core/kernel, provides rtmp/htttp protocol features.
MODULE_ID="RTMP"
MODULE_DEPENDS=("CORE" "KERNEL")
ModuleLibIncs=(${SRS_OBJS} ${LibSSLRoot})
MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_protocol_rtmp_stack" "srs_protocol_rtmp"
"srs_protocol_handshake" "srs_protocol_utility")
2014-03-01 06:05:58 +00:00
MODULE_DIR="src/rtmp" . auto/modules.sh
RTMP_OBJS="${MODULE_OBJS[@]}"
#
2014-03-01 02:05:14 +00:00
#App Module
MODULE_ID="APP"
2014-03-01 06:05:58 +00:00
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS})
MODULE_FILES=("srs_core_server" "srs_core_conn" "srs_core_client" "srs_core_socket" "srs_core_source"
"srs_core_codec" "srs_core_refer" "srs_core_hls" "srs_core_forward" "srs_core_encoder"
2014-03-01 10:06:20 +00:00
"srs_core_http" "srs_core_thread" "srs_core_bandwidth" "srs_core_st" "srs_core_log"
"srs_core_config" "srs_core_pithy_print")
2014-03-01 01:56:48 +00:00
MODULE_DIR="src/app" . auto/modules.sh
2014-03-01 02:05:14 +00:00
APP_OBJS="${MODULE_OBJS[@]}"
2014-02-28 07:42:35 +00:00
#
2013-10-17 12:58:04 +00:00
#Main Module
MODULE_ID="MAIN"
2014-03-01 06:05:58 +00:00
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
2013-11-27 14:41:58 +00:00
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS})
MODULE_FILES=("srs_main_server" "srs_main_bandcheck")
2013-10-17 12:58:04 +00:00
MODULE_DIR="src/main" . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@].o}"
2014-02-28 07:42:35 +00:00
#####################################################################################
# Binaries, main entrances, link the module and its depends modules,
# then link to a binary, for example, objs/srs
#
2013-10-17 12:58:04 +00:00
# all main entrances
MAIN_ENTRANCES=("srs_main_server" "srs_main_bandcheck")
2014-03-01 01:52:41 +00:00
#
2014-02-28 07:42:35 +00:00
# all depends libraries
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile})
2014-02-28 07:42:35 +00:00
# all depends objects
2014-03-01 06:05:58 +00:00
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
LINK_OPTIONS="-ldl"
2014-03-01 01:52:41 +00:00
#
# srs:
2014-02-28 07:42:35 +00:00
# srs(simple rtmp server) over st(state-threads)
BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
2014-03-01 01:52:41 +00:00
#
# bandwidth
2014-02-28 07:42:35 +00:00
# bandwidth test tool, to test the bandwidth to server
BUILD_KEY="bandwidth" APP_MAIN="srs_main_bandcheck" APP_NAME="bandwidth" . auto/apps.sh
2013-10-17 12:58:04 +00:00
echo 'configure ok! '
2014-02-28 13:07:46 +00:00
#####################################################################################
# when configure success, prepare build
#####################################################################################
# create objs/logs for ffmpeg to write log.
mkdir -p ${SRS_OBJS}/logs
#####################################################################################
# configure summary
#####################################################################################
2014-02-28 05:17:31 +00:00
# linux shell color support.
RED="\\e[31m"
GREEN="\\e[32m"
YELLOW="\\e[33m"
BLACK="\\e[0m"
2013-11-30 06:12:19 +00:00
# summary
echo ""
echo "configure summary:"
if [ $SRS_HLS = YES ]; then
echo -e "${GREEN}HLS over nginx is enabled${BLACK}"
else
2014-01-05 07:58:17 +00:00
echo -e "${YELLOW}warning: without HLS support${BLACK}"
2013-11-30 06:12:19 +00:00
fi
if [ $SRS_SSL = YES ]; then
echo -e "${GREEN}rtmp complex handshake is enabled${BLACK}"
else
echo -e "${YELLOW}warning: without rtmp complex handshake support, donot support h264/aac to adobe flash player${BLACK}"
fi
if [ $SRS_FFMPEG = YES ]; then
echo -e "${GREEN}live stream transcoding over FFMPEG is enabled${BLACK}"
else
echo -e "${YELLOW}warning: without live stream transcoding over FFMPEG support${BLACK}"
fi
2013-12-07 11:27:31 +00:00
if [ $SRS_HTTP = YES ]; then
echo -e "${GREEN}http hooks callback over CherryPy is enabled${BLACK}"
else
echo -e "${YELLOW}warning: without http hooks callback over CherryPy support${BLACK}"
fi
2014-02-28 06:38:27 +00:00
if [ $SRS_RESEARCH = YES ]; then
echo -e "${GREEN}research tools are builded${BLACK}"
else
echo -e "${BLACK}note: research tools are not builded${BLACK}"
fi
2013-11-30 06:12:19 +00:00
#####################################################################################
# next step
#####################################################################################
2014-01-05 07:58:17 +00:00
ip=`ifconfig|grep "inet addr"| grep -v "127.0.0.1"|awk '{print $2}'|awk -F ':' 'NR==1 {print $2}'`
2013-11-30 06:12:19 +00:00
echo ""
2013-10-17 12:58:04 +00:00
echo "you can:"
echo "\" make \" to build the srs(simple rtmp server)."
echo "\" make help \" to get the usage of make"
2013-11-27 14:41:58 +00:00
if [ $SRS_HLS = YES ]; then
echo "\" sudo ./objs/nginx/sbin/nginx \" to start the nginx http server for hls"
2014-01-05 07:58:17 +00:00
echo "\" http://$ip \" rtmp players(OSMF/JWPlayer)"
2013-11-27 14:41:58 +00:00
fi
2013-11-30 06:12:19 +00:00
if [ $SRS_FFMPEG = YES ]; then
echo -e "\" ./objs/ffmpeg/bin/ffmpeg \" is used for live stream transcoding"
fi
2013-12-07 12:34:42 +00:00
if [ $SRS_HTTP = YES ]; then
echo -e "\" python ./research/api-server/server.py 8085 \" to start the api-server"
fi
2013-12-15 04:44:09 +00:00
echo "\" ./objs/srs -c conf/srs.conf \" to start the srs live server"