Blame view

trunk/configure 5.3 KB
winlin authored
1 2
#!/bin/bash
3 4 5
SRS_MAKEFILE="Makefile"
SRS_OBJS="objs"
SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
winlin authored
6
7
mkdir -p ${SRS_OBJS}
winlin authored
8
winlin authored
9 10 11 12 13 14
# linux shell color support.
RED="\\e[31m"
GREEN="\\e[32m"
YELLOW="\\e[33m"
BLACK="\\e[0m"
15 16 17
# parse user options.
. auto/options.sh
18 19
function require_sudoer()
{
20
    sudo echo "" >/dev/null 2>&1
21 22 23
    
    ret=$?; if [[ 0 -ne $ret ]]; then 
        echo "\"$1\" require sudoer failed. ret=$ret";
24 25
        exit $ret; 
    fi
26
}
27
28 29 30
# clean the exists
if [[ -f Makefile ]]; then
    make clean
31 32
fi
33 34
# generate the audo headers file.
echo "#define SRS_CONFIGURE \"${SRS_CONFIGURE}\"" > $SRS_AUTO_HEADERS_H
35 36
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
37 38 39 40 41 42

# apply user options.
. auto/depends.sh

# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H
43
winlin authored
44 45 46 47 48
#####################################################################################
# generate Makefile.
#####################################################################################
echo "generate Makefile"
49
cat << END > ${SRS_MAKEFILE}
winlin authored
50 51 52 53 54 55 56 57 58 59
.PHONY: default help clean server _prepare_dir
default: server

help:
	@echo "Usage: make <help>|<clean>|<server>"
	@echo "  help       display this help menu"
	@echo "  clean      cleanup project"
	@echo "  server     build the srs(simple rtmp server) over st(state-threads)"

clean: 
winlin authored
60
	(rm -f Makefile; cd ${SRS_OBJS}; rm -rf srs Makefile *.hpp src st_*_load)
winlin authored
61 62 63

server: _prepare_dir
	@echo "build the srs(simple rtmp server) over st(state-threads)"
winlin authored
64
	\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} srs
winlin authored
65 66 67

# the ./configure will generate it.
_prepare_dir:
68
	@mkdir -p ${SRS_OBJS}
winlin authored
69 70 71 72 73
END

echo 'generate Makefile ok!'

# the performance analysis, uncomments the following when use gperf to analysis the performance. see third-party/readme.txt
74
Performance="-pg"
winlin authored
75 76 77
# enable gdb debug
GDBDebug="-g -O0"
# the warning level.
78
WarnLevel="-Wall"
winlin authored
79
# the compile standard.
80
CppStd="-ansi"
winlin authored
81
# the cxx flag generated.
82 83
CXXFLAGS="${CppStd} ${WarnLevel} ${GDBDebug}"
#CXXFLAGS="${CppStd} ${WarnLevel} ${GDBDebug} ${Performance}"
84
cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}
winlin authored
85 86 87 88 89
CXXFLAGS = ${CXXFLAGS}
GCC = g++
LINK = \$(GCC)
AR = ar
winlin authored
90
.PHONY: default srs 
winlin authored
91 92 93 94 95 96

default:

END

# Libraries
97
LibSTRoot="${SRS_OBJS}/st"
winlin authored
98
LibSTfile="${LibSTRoot}/libst.a"
99 100 101 102
if [ $SRS_HTTP = YES ]; then
    LibHttpParserRoot="${SRS_OBJS}/hp"
    LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"
fi
winlin authored
103 104 105 106

#Core Module
MODULE_ID="CORE" 
MODULE_DEPENDS=() 
107 108 109 110
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS})
if [ $SRS_HTTP = YES ]; then
    ModuleLibIncs="${ModuleLibIncs[@]} ${LibHttpParserRoot}"
fi
111 112
MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" 
        "srs_core_error" "srs_core_conn" "srs_core_client" 
winlin authored
113
        "srs_core_rtmp" "srs_core_socket" "srs_core_buffer"
114
        "srs_core_autofree" "srs_core_protocol" "srs_core_amf0"
115
        "srs_core_stream" "srs_core_source" "srs_core_codec"
116
        "srs_core_handshake" "srs_core_pithy_print"
117
        "srs_core_config" "srs_core_refer" "srs_core_reload"
118
        "srs_core_hls" "srs_core_forward" "srs_core_encoder"
119
        "srs_core_http" "srs_core_thread")
winlin authored
120 121 122 123 124 125
MODULE_DIR="src/core" . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}"

#Main Module
MODULE_ID="MAIN" 
MODULE_DEPENDS=("CORE")
126
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS})
winlin authored
127 128 129 130 131 132 133 134
MODULE_FILES=("srs_main_server")
MODULE_DIR="src/main" . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@].o}"

# all main entrances
MAIN_ENTRANCES=("srs_main_server")

# srs(simple rtmp server) over st(state-threads)
135 136 137 138
ModuleLibFiles=(${LibSTfile})
if [ $SRS_HTTP = YES ]; then
    ModuleLibFiles="${ModuleLibFiles[@]} ${LibHttpParserfile}"
fi
winlin authored
139
MODULE_OBJS="${CORE_OBJS[@]} ${CONFIG_OBJS[@]} ${PROTOCOL_OBJS[@]} ${MAIN_OBJS[@]}"
140 141 142 143 144
if [ $SRS_SSL = YES ]; then
    LINK_OPTIONS="-ldl -lssl -lcrypto"
else
    LINK_OPTIONS="-ldl"
fi
winlin authored
145
BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" SO_PATH="" . auto/apps.sh
winlin authored
146 147 148

echo 'configure ok! '
winlin authored
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
# summary
echo ""
echo "configure summary:"
if [ $SRS_HLS = YES ]; then
    echo -e "${GREEN}HLS over nginx is enabled${BLACK}"
else
    echo -e "warning: without HLS support"
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
167 168 169 170 171
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
winlin authored
172
winlin authored
173 174 175
# mkdir dirs
mkdir -p ${SRS_OBJS}/logs
winlin authored
176
# next step.
winlin authored
177
echo ""
winlin authored
178 179 180
echo "you can:"
echo "\" make \" to build the srs(simple rtmp server)."
echo "\" make help \" to get the usage of make"
181 182 183
if [ $SRS_HLS = YES ]; then
    echo "\" sudo ./objs/nginx/sbin/nginx  \" to start the nginx http server for hls"
fi
winlin authored
184 185 186
if [ $SRS_FFMPEG = YES ]; then
    echo -e "\" ./objs/ffmpeg/bin/ffmpeg  \" is used for live stream transcoding"
fi
winlin authored
187 188 189
if [ $SRS_HTTP = YES ]; then
    echo -e "\" python ./research/api-server/server.py 8085  \" to start the api-server"
fi
winlin authored
190
echo "\" ./objs/srs -c conf/srs.conf \" to start the srs live server"