Blame view

trunk/configure 29.8 KB
winlin authored
1 2
#!/bin/bash
3 4 5 6
#####################################################################################
# the main output dir, all configure and make output are in this dir.
#####################################################################################
# create the main objs
7 8
SRS_OBJS="objs"
mkdir -p ${SRS_OBJS}
winlin authored
9
10
#####################################################################################
11 12 13 14 15 16 17
# linux shell color support.
RED="\\e[31m"
GREEN="\\e[32m"
YELLOW="\\e[33m"
BLACK="\\e[0m"

#####################################################################################
winlin authored
18
# parse user options, set the variables like:
19
# srs features: SRS_SSL/SRS_HLS/SRS_NGINX/SRS_FFMPEG_TOOL/SRS_HTTP_CALLBACK/......
winlin authored
20
# build options: SRS_JOBS
21
#####################################################################################
22
SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
23
# parse options, exit with error when parse options invalid.
24 25
. auto/options.sh
26
# clean the exists
27
# do this only when the options is ok.
28 29
if [[ -f Makefile ]]; then
    make clean
30 31
fi
32
# write user options to headers
33
echo "// auto generated by configure" > $SRS_AUTO_HEADERS_H
winlin authored
34 35 36 37
echo "#ifndef SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
38 39 40
echo "#define SRS_AUTO_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
41
echo "#define SRS_AUTO_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
42
echo "#define SRS_AUTO_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
43 44 45

# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H
46
47 48 49
#####################################################################################
# generate auto headers file, depends on the finished of options.sh
#####################################################################################
50
# the arm-ubuntu12 options for make for depends
winlin authored
51 52 53 54 55 56 57
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"
58
echo "#define SRS_AUTO_ARM_TOOL_CHAIN \"cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB\"" >> $SRS_AUTO_HEADERS_H
winlin authored
59
echo "" >> $SRS_AUTO_HEADERS_H
60
61 62 63
# apply user options.
. auto/depends.sh
winlin authored
64 65 66 67
# auto header EOF.
echo "#endif" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
winlin authored
68 69 70
#####################################################################################
# generate Makefile.
#####################################################################################
71
SRS_MAKEFILE="Makefile"
72 73
# ubuntu echo in Makefile cannot display color, use bash instead
SRS_BUILD_SUMMARY="_srs_build_summary.sh"
winlin authored
74
winlin authored
75
#####################################################################################
76
# srs-librtmp sample entry
77 78
SrsLibrtmpSampleEntry="nossl"
if [ $SRS_SSL = YES ]; then SrsLibrtmpSampleEntry="ssl";fi
winlin authored
79
# utest make entry, (cd utest; make)
80
SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\""
81
if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS}/utest; \$(MAKE))"; fi
winlin authored
82
83 84
#####################################################################################
# colorful summary
85
SrsHlsSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HLS = YES ]; then SrsHlsSummaryColor="\${GREEN}"; fi
86
SrsDvrSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_DVR = YES ]; then SrsDvrSummaryColor="\${GREEN}"; fi
87
SrsNginxSummaryColor="\${GREEN}{disabled} "; if [ $SRS_NGINX = YES ]; then SrsNginxSummaryColor="\${GREEN}"; fi
88
SrsSslSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_SSL = YES ]; then SrsSslSummaryColor="\${GREEN}"; fi
89
SrsFfmpegSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_FFMPEG_TOOL = YES ]; then SrsFfmpegSummaryColor="\${GREEN}"; fi
90
SrsTranscodeSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_TRANSCODE = YES ]; then SrsTranscodeSummaryColor="\${GREEN}"; fi
winlin authored
91
SrsIngestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_INGEST = YES ]; then SrsIngestSummaryColor="\${GREEN}"; fi
92
SrsHttpCallbackSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_CALLBACK = YES ]; then SrsHttpCallbackSummaryColor="\${GREEN}"; fi
winlin authored
93
SrsHttpServerSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_SERVER = YES ]; then SrsHttpServerSummaryColor="\${GREEN}"; fi
winlin authored
94
SrsHttpApiSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_API = YES ]; then SrsHttpApiSummaryColor="\${GREEN}"; fi
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
SrsLibrtmpSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_LIBRTMP = YES ]; then SrsLibrtmpSummaryColor="\${GREEN}"; fi
SrsLibrtmpSSLSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_LIBRTMP = YES ]; then if [ $SRS_SSL = YES ]; then SrsLibrtmpSSLSummaryColor="\${GREEN}"; fi fi
SrsBWTCSummaryColor="\${GREEN}{disabled} "; if [ $SRS_BWTC = YES ]; then SrsBWTCSummaryColor="\${GREEN}"; fi
SrsResearchSummaryColor="\${GREEN}{disabled} "; if [ $SRS_RESEARCH = YES ]; then SrsResearchSummaryColor="\${GREEN}"; fi
SrsUtestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\${GREEN}"; fi
SrsGperfSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\${GREEN}"; fi
SrsGperfMCSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\${YELLOW}"; fi
SrsGperfMPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MP = YES ]; then SrsGperfMPSummaryColor="\${YELLOW}"; fi
SrsGperfCPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi
SrsGprofSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi
cat <<END > ${SRS_OBJS}/${SRS_BUILD_SUMMARY}
#!/bin/bash

#####################################################################################
# linux shell color support.
RED="\\${RED}"
GREEN="\\${GREEN}"
YELLOW="\\${YELLOW}"
BLACK="\\${BLACK}"

echo -e "\${GREEN}build summary:\${BLACK}"
echo -e "     \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e "     |${SrsGperfSummaryColor}gperf @see: https://github.com/winlinvip/simple-rtmp-server/wiki/GPERF\${BLACK}"
echo -e "     |     ${SrsGperfMCSummaryColor}gmc @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\${BLACK}"
echo -e "     |     ${SrsGperfMCSummaryColor}gmc: gperf memory check\${BLACK}"
echo -e "     |             ${SrsGperfMCSummaryColor}env PPROF_PATH=./objs/pprof HEAPCHECK=normal ./objs/srs -c conf/srs.conf # start gmc\${BLACK}"
echo -e "     |             ${SrsGperfMCSummaryColor}killall -2 srs # or CTRL+C to stop gmc\${BLACK}"
echo -e "     |     ${SrsGperfMPSummaryColor}gmp @see: http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html\${BLACK}"
echo -e "     |     ${SrsGperfMPSummaryColor}gmp: gperf memory profile\${BLACK}"
echo -e "     |             ${SrsGperfMPSummaryColor}rm -f gperf.srs.gmp*; ./objs/srs -c conf/srs.conf # start gmp\${BLACK}"
echo -e "     |             ${SrsGperfMPSummaryColor}killall -2 srs # or CTRL+C to stop gmp\${BLACK}"
echo -e "     |             ${SrsGperfMPSummaryColor}./objs/pprof --text objs/srs gperf.srs.gmp* # to analysis memory profile\${BLACK}"
echo -e "     |     ${SrsGperfCPSummaryColor}gcp @see: http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html\${BLACK}"
echo -e "     |     ${SrsGperfCPSummaryColor}gcp: gperf cpu profile\${BLACK}"
echo -e "     |             ${SrsGperfCPSummaryColor}rm -f gperf.srs.gcp*; ./objs/srs -c conf/srs.conf # start gcp\${BLACK}"
echo -e "     |             ${SrsGperfCPSummaryColor}killall -2 srs # or CTRL+C to stop gcp\${BLACK}"
echo -e "     |             ${SrsGperfCPSummaryColor}./objs/pprof --text objs/srs gperf.srs.gcp* # to analysis cpu profile\${BLACK}"
echo -e "     \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e "     |${SrsGprofSummaryColor}gprof @see: https://github.com/winlinvip/simple-rtmp-server/wiki/GPROF\${BLACK}"
echo -e "     |${SrsGprofSummaryColor}gprof: GNU profile tool, @see: http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html\${BLACK}"
echo -e "     |     ${SrsGprofSummaryColor}rm -f gmon.out; ./objs/srs -c conf/srs.conf # start gprof\${BLACK}"
echo -e "     |     ${SrsGprofSummaryColor}killall -2 srs # or CTRL+C to stop gprof\${BLACK}"
echo -e "     |     ${SrsGprofSummaryColor}gprof -b ./objs/srs gmon.out > gprof.srs.log && rm -f gmon.out # gprof report to gprof.srs.log\${BLACK}"
echo -e "     \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e "     |${SrsResearchSummaryColor}research: ./objs/research, api server, players, ts info.\${BLACK}"
echo -e "     \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e "     |${SrsBWTCSummaryColor}bandwidth: ./objs/bandwidth, the bandwidth test client\${BLACK}"
echo -e "     \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
143 144
echo -e "     |${SrsUtestSummaryColor}utest: ./objs/srs_utest, the utest for srs\${BLACK}"
echo -e "     \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
145 146 147 148 149 150
echo -e "     |${SrsLibrtmpSummaryColor}librtmp @see: https://github.com/winlinvip/simple-rtmp-server/wiki/SrsLibrtmp\${BLACK}"
echo -e "     |${SrsLibrtmpSummaryColor}librtmp: ./objs/include, ./objs/lib, the srs-librtmp library\${BLACK}"
echo -e "     |     ${SrsLibrtmpSummaryColor}simple handshake: publish/play stream with simple handshake to server\${BLACK}"
echo -e "     |     ${SrsLibrtmpSSLSummaryColor}complex handshake: it's not required for client, recommend disable it\${BLACK}"
echo -e "     |     ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp, the srs-librtmp client sample\${BLACK}"
echo -e "     \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
151
echo -e "     |\${GREEN}server: ./objs/srs -c conf/srs.conf, start the srs server\${BLACK}"
152
echo -e "     |     ${SrsHlsSummaryColor}hls @see: https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryHLS\${BLACK}"
153
echo -e "     |     ${SrsHlsSummaryColor}hls: generate m3u8 and ts from rtmp stream\${BLACK}"
154 155
echo -e "     |     ${SrsDvrSummaryColor}dvr @see: https://github.com/winlinvip/simple-rtmp-server/wiki/DVR\${BLACK}"
echo -e "     |     ${SrsDvrSummaryColor}dvr: record RTMP stream to flv files.\${BLACK}"
156 157
echo -e "     |     ${SrsNginxSummaryColor}nginx @see: https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryHLS\${BLACK}"
echo -e "     |     ${SrsNginxSummaryColor}nginx: delivery HLS stream by nginx\${BLACK}"
158 159 160
echo -e "     |     ${SrsSslSummaryColor}ssl @see: https://github.com/winlinvip/simple-rtmp-server/wiki/RTMPHandshake\${BLACK}"
echo -e "     |     ${SrsSslSummaryColor}ssl: support RTMP complex handshake for client required, for instance, flash\${BLACK}"
echo -e "     |     ${SrsFfmpegSummaryColor}ffmpeg @see: https://github.com/winlinvip/simple-rtmp-server/wiki/FFMPEG\${BLACK}"
161 162 163
echo -e "     |     ${SrsFfmpegSummaryColor}ffmpeg: transcode, mux, ingest tool\${BLACK}"
echo -e "     |     ${SrsTranscodeSummaryColor}transcode @see: https://github.com/winlinvip/simple-rtmp-server/wiki/FFMPEG\${BLACK}"
echo -e "     |     ${SrsTranscodeSummaryColor}transcode: support transcoding RTMP stream\${BLACK}"
winlin authored
164 165
echo -e "     |     ${SrsIngestSummaryColor}ingest @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Ingest\${BLACK}"
echo -e "     |     ${SrsIngestSummaryColor}ingest: support ingest file/stream/device then push to SRS by RTMP stream\${BLACK}"
winlin authored
166 167 168 169
echo -e "     |     ${SrsHttpCallbackSummaryColor}http-callback @see: https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPCallback\${BLACK}"
echo -e "     |     ${SrsHttpCallbackSummaryColor}http-callback: support http callback for authentication and event injection\${BLACK}"
echo -e "     |     ${SrsHttpServerSummaryColor}http-server @see: https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPServer\${BLACK}"
echo -e "     |     ${SrsHttpServerSummaryColor}http-server: support http server to delivery http stream\${BLACK}"
winlin authored
170 171
echo -e "     |     ${SrsHttpApiSummaryColor}http-api @see: https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPApi\${BLACK}"
echo -e "     |     ${SrsHttpApiSummaryColor}http-api: support http api to manage server\${BLACK}"
172 173 174
echo -e "     \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e "\${GREEN}binaries @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Build\${BLACK}"
END
175 176

#####################################################################################
177
# makefile
winlin authored
178
echo "generate Makefile"
179
cat << END > ${SRS_MAKEFILE}
winlin authored
180
.PHONY: default _default install install-api help clean server bandwidth librtmp librtmp-sample utest _prepare_dir
181 182 183

# install prefix.
SRS_PREFIX=${SRS_PREFIX}
184
DESTDIR=\$(SRS_PREFIX)
185
186 187 188 189 190 191 192 193 194 195 196 197 198 199
END

# arm, ubuntu12, use arm tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
    cat << END >> ${SRS_MAKEFILE}
default:
	\$(MAKE) GCC=${SrsArmGCC} CXX=${SrsArmCXX} AR=${SrsArmAR} LINK=${SrsArmCXX} _default

END
# x86/x64, use gnu-gcc/g++ tool chain.
else
    cat << END >> ${SRS_MAKEFILE}
default:
	\$(MAKE) _default
200
201 202 203 204 205 206 207
END
fi

# the real entry for all platform.
cat << END >> ${SRS_MAKEFILE}
_default: bandwidth librtmp-sample utest
	@bash objs/_srs_build_summary.sh
winlin authored
208 209

help:
winlin authored
210
	@echo "Usage: make <help>|<clean>|<server>|<bandwidth>|<librtmp>|<librtmp-sample>|<utest>|<install>|<install-api>|<uninstall>"
winlin authored
211 212 213 214 215 216
	@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."
	@echo "  librtmp            build the client publish/play library."
	@echo "  librtmp-sample     build the srs-librtmp sample"
winlin authored
217
	@echo "  utest              build the utest for srs"
218
	@echo "  install            install srs to the prefix path"
winlin authored
219
	@echo "  install-api        install srs api to the prefix path"
220
	@echo "  uninstall          uninstall srs from prefix path"
winlin authored
221 222

clean: 
223 224 225
	(cd ${SRS_OBJS}; rm -rf srs bandwidth srs_utest)
	(cd ${SRS_OBJS}; rm -rf src research include lib)
	(cd ${SRS_OBJS}/utest; rm -rf *.o *.a)
winlin authored
226
	(cd research/librtmp; make clean)
winlin authored
227
	(cd research/api-server/static-dir; rm -rf crossdomain.xml forward live players)
winlin authored
228 229 230

server: _prepare_dir
	@echo "build the srs(simple rtmp server) over st(state-threads)"
winlin authored
231
	\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} srs
winlin authored
232
233 234
END
235 236 237 238 239 240
# install entry
cat << END >> ${SRS_MAKEFILE}
uninstall:
	@echo "rmdir \$(SRS_PREFIX)"
	@rm -rf \$(SRS_PREFIX)
winlin authored
241
install-api: install
242 243
	@echo "mkdir \$(DESTDIR)"
	@mkdir -p \$(DESTDIR)
winlin authored
244
	@echo "copy binary files"
245 246 247 248
	@mkdir -p \$(DESTDIR)/research/api-server
	@cp research/api-server/server.py \$(DESTDIR)/research/api-server
	@mkdir -p \$(DESTDIR)/objs/ffmpeg/bin
	@cp objs/ffmpeg/bin/ffmpeg \$(DESTDIR)/objs/ffmpeg/bin
winlin authored
249
	@echo "copy html files"
250 251 252 253
	@mkdir -p \$(DESTDIR)/research/api-server/static-dir/players
	@cp research/api-server/static-dir/crossdomain.xml \$(DESTDIR)/research/api-server/static-dir
	@cp research/api-server/static-dir/index.html \$(DESTDIR)/research/api-server/static-dir
	@cp -r research/api-server/static-dir/players/* \$(DESTDIR)/research/api-server/static-dir/players
winlin authored
254
	@echo "copy init.d script files"
255 256 257
	@mkdir -p \$(DESTDIR)/etc/init.d
	@cp etc/init.d/srs-api \$(DESTDIR)/etc/init.d
	@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(DESTDIR)/etc/init.d/srs-api
winlin authored
258 259 260 261
	@echo ""
	@echo "api installed, to link and start api:"
	@echo "     sudo ln -sf /usr/local/srs/etc/init.d/srs-api /etc/init.d/srs-api"
	@echo "     /etc/init.d/srs-api start"
winlin authored
262
	@echo "     http://\$(shell bash auto/local_ip.sh):8085"
winlin authored
263
	@echo "@see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService"
winlin authored
264
265
install:
266 267
	@echo "mkdir \$(DESTDIR)"
	@mkdir -p \$(DESTDIR)
268 269
	@echo "make the http root dir"
	@mkdir -p \$(DESTDIR)/objs/nginx/html
270
	@echo "copy binary files"
271 272
	@mkdir -p \$(DESTDIR)/objs
	@cp objs/srs \$(DESTDIR)/objs
273
	@echo "copy srs conf files"
274 275
	@mkdir -p \$(DESTDIR)/conf
	@cp conf/*.conf \$(DESTDIR)/conf
276
	@echo "copy init.d script files"
277 278 279
	@mkdir -p \$(DESTDIR)/etc/init.d
	@cp etc/init.d/srs \$(DESTDIR)/etc/init.d
	@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(DESTDIR)/etc/init.d/srs
winlin authored
280 281 282 283 284
	@echo ""
	@echo "srs installed, to link and start srs:"
	@echo "     sudo ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs"
	@echo "     /etc/init.d/srs start"
	@echo "@see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService"
285 286 287

END
288 289
if [ $SRS_BWTC = YES ]; then
    cat << END >> ${SRS_MAKEFILE}
winlin authored
290
bandwidth: server
291 292 293
	@echo "build the bandwidth test client tool"
	\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} bandwidth
winlin authored
294
END
295 296 297 298 299 300 301
else
    cat << END >> ${SRS_MAKEFILE}
bandwidth: server
	@echo "bandwidth test client tool is disabled, ignore."

END
fi
winlin authored
302 303 304

if [ $SRS_LIBRTMP = YES ]; then
    cat << END >> ${SRS_MAKEFILE}
winlin authored
305
librtmp: server
winlin authored
306 307 308
	@echo "build the client publish/play library."
	\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} librtmp
winlin authored
309 310 311 312 313 314 315 316
END
else
    cat << END >> ${SRS_MAKEFILE}
librtmp: server
	@echo "srs-librtmp is disabled, ignore."

END
fi
317
if [ $SRS_LIBRTMP = YES ]; then
winlin authored
318 319
    cat << END >> ${SRS_MAKEFILE}
winlin authored
320
librtmp-sample: librtmp
winlin authored
321
	@echo "build the srs-librtmp sample"
winlin authored
322
	(cd research/librtmp; \$(MAKE) ${SrsLibrtmpSampleEntry})
winlin authored
323 324
	@echo "srs-librtmp sample build success"
winlin authored
325 326 327 328 329 330 331 332 333 334 335 336
END
else
    cat << END >> ${SRS_MAKEFILE}

librtmp-sample: librtmp
	@echo "srs-librtmp sample is disabled, ignore."

END
fi

if [ $SRS_UTEST = YES ]; then
    cat << END >> ${SRS_MAKEFILE}
winlin authored
337
utest: server
winlin authored
338 339 340 341
	@echo "build the utest for srs"
	${SrsUtestMakeEntry}
	@echo "utest for srs build success"
winlin authored
342 343 344 345 346 347 348 349 350 351
END
else
    cat << END >> ${SRS_MAKEFILE}
utest: server
	@echo "utest is disabled, ignore"

END
fi

cat << END >> ${SRS_MAKEFILE}
winlin authored
352 353
# the ./configure will generate it.
_prepare_dir:
354
	@mkdir -p ${SRS_OBJS}
winlin authored
355 356
END
winlin authored
357 358
#####################################################################################
# build tools or compiler args.
winlin authored
359
# enable gdb debug
winlin authored
360
GDBDebug=" -g -O0"
winlin authored
361
# the warning level.
winlin authored
362
WarnLevel=" -Wall"
winlin authored
363
# the compile standard.
364
CppStd="-ansi"
winlin authored
365
# for library compile
winlin authored
366 367 368 369 370
LibraryCompile=" -fPIC"
# performance of gprof
SrsGprof=""; SrsGprofLink=""; if [ $SRS_GPROF = YES ]; then SrsGprof=" -pg -lc_p"; SrsGprofLink=" -pg"; fi
# performance of gperf
SrsGperf=""; SrsGperfLink=""; if [ $SRS_GPERF = YES ]; then SrsGperfLink=" -lpthread"; fi
winlin authored
371
# the cxx flag generated.
winlin authored
372
CXXFLAGS="${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}"
373
if [ $SRS_GPERF = YES ]; then CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"; fi
374
cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}
375 376 377 378
GCC = gcc
CXX = g++
AR = ar
LINK = g++
379
CXXFLAGS = ${CXXFLAGS}
winlin authored
380
winlin authored
381
.PHONY: default srs bandwidth librtmp
winlin authored
382 383 384 385 386

default:

END
winlin authored
387 388 389 390 391 392
#####################################################################################
# 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.
393
LibSTRoot="${SRS_OBJS}/st"; LibSTfile="${LibSTRoot}/libst.a"
winlin authored
394
# hp(http-parser) the http request/url parser, for SRS to support HTTP callback.
395
LibHttpParserRoot=""; LibHttpParserfile=""
winlin authored
396
if [ $SRS_HTTP_PARSER = YES ]; then LibHttpParserRoot="${SRS_OBJS}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi
397
# openssl-1.0.1f, for the RTMP complex handshake.
398
LibSSLRoot="";LibSSLfile=""
399
if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS_OBJS}/openssl/include"; LibSSLfile="${SRS_OBJS}/openssl/lib/libssl.a ${SRS_OBJS}/openssl/lib/libcrypto.a"; fi fi
400 401 402
# gperftools-2.1, for mem check and mem/cpu profile
LibGperfRoot=""; LibGperfFile=""
if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS}/gperf/include"; LibGperfFile="${SRS_OBJS}/gperf/lib/libtcmalloc_and_profiler.a"; fi
403
# the link options, always use static link
404 405
SrsLinkOptions=""; 
if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="-lssl"; fi fi
winlin authored
406 407 408 409 410 411 412
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
winlin authored
413
winlin authored
414 415 416
#####################################################################################
# Modules, compile each module, then link to binary
#
417
#Core, depends only on system apis.
418 419
MODULE_ID="CORE"
MODULE_DEPENDS=()
winlin authored
420
ModuleLibIncs=(${SRS_OBJS})
421
MODULE_FILES=("srs_core" "srs_core_autofree")
422
CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh
423 424
CORE_OBJS="${MODULE_OBJS[@]}"
#
425 426 427 428
#Kernel, depends on core, provides error/log/config, nothing about stream information.
MODULE_ID="KERNEL" 
MODULE_DEPENDS=("CORE") 
ModuleLibIncs=(${SRS_OBJS})
429
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream" "srs_kernel_buffer" "srs_kernel_utility")
430
KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh
431 432
KERNEL_OBJS="${MODULE_OBJS[@]}"
#
winlin authored
433 434
#RTMP Protocol, depends on core/kernel, provides rtmp/htttp protocol features.
MODULE_ID="RTMP" 
435
MODULE_DEPENDS=("CORE" "KERNEL") 
436 437
ModuleLibIncs=(${SRS_OBJS} ${LibSSLRoot})
MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_protocol_rtmp_stack" "srs_protocol_rtmp"
438
        "srs_protocol_handshake" "srs_protocol_utility")
439
RTMP_INCS="src/rtmp"; MODULE_DIR=${RTMP_INCS} . auto/modules.sh
winlin authored
440
RTMP_OBJS="${MODULE_OBJS[@]}"
441
#
442 443
#App Module
MODULE_ID="APP" 
winlin authored
444
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP") 
445
ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS})
446
MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_socket" "srs_app_source" 
447 448
        "srs_app_codec" "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder"
        "srs_app_http" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log"
449
        "srs_app_config" "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api"
450
        "srs_app_http_conn" "srs_app_http_hooks" "srs_app_json" "srs_app_ingest"
winlin authored
451
        "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge")
452
APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
453
APP_OBJS="${MODULE_OBJS[@]}"
winlin authored
454
#
winlin authored
455 456 457
#LIBS Module, build libsrs.a for static link.
MODULE_ID="LIBS" 
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP") 
winlin authored
458
ModuleLibIncs=(${SRS_OBJS})
winlin authored
459
MODULE_FILES=("srs_librtmp" "srs_lib_simple_socket")
460
LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh
winlin authored
461 462
LIBS_OBJS="${MODULE_OBJS[@]}"
#
winlin authored
463 464
#Main Module
MODULE_ID="MAIN" 
winlin authored
465
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
466
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS} ${LibGperfRoot})
467
MODULE_FILES=("srs_main_server" "srs_main_bandcheck")
468 469
MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@]}"
470 471

#####################################################################################
winlin authored
472 473 474
# Binaries, main entrances, link the module and its depends modules,
# then link to a binary, for example, objs/srs
#
winlin authored
475
# all main entrances
476
MAIN_ENTRANCES=("srs_main_server" "srs_main_bandcheck")
winlin authored
477
# 
winlin authored
478
# all depends libraries
479
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile} ${LibGperfFile})
winlin authored
480
# all depends objects
winlin authored
481
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
482
LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}"
winlin authored
483 484
#
# srs:
winlin authored
485
# srs(simple rtmp server) over st(state-threads)
486
BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
487
# bandwidth test tool, to test the bandwidth to server
488 489 490
if [ $SRS_BWTC = YES ]; then
    BUILD_KEY="bandwidth" APP_MAIN="srs_main_bandcheck" APP_NAME="bandwidth" . auto/apps.sh
fi
491
# srs librtmp
winlin authored
492 493 494 495
if [ $SRS_LIBRTMP = YES ]; then
    MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${LIBS_OBJS[@]}"
    BUILD_KEY="librtmp" LIB_NAME="lib/srs_librtmp" . auto/libs.sh
fi
496 497
#
# utest, the unit-test cases of srs, base on gtest1.6
498
MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_handshake")
499 500 501 502
ModuleLibIncs=(${SRS_OBJS} ${LibSTRoot})
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile})
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]}"
winlin authored
503
LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
winlin authored
504 505 506

echo 'configure ok! '
507
#####################################################################################
winlin authored
508 509 510 511 512 513
# when configure success, prepare build
#####################################################################################
# create objs/logs for ffmpeg to write log.
mkdir -p ${SRS_OBJS}/logs

#####################################################################################
514 515
# configure summary
#####################################################################################
winlin authored
516 517 518
# summary
echo ""
echo "configure summary:"
519
echo "      ${SRS_AUTO_USER_CONFIGURE}"
520
echo "      ${SRS_AUTO_CONFIGURE}"
winlin authored
521
if [ $SRS_HLS = YES ]; then
522
    echo -e "${GREEN}HLS is enabled${BLACK}"
winlin authored
523
else
winlin authored
524
    echo -e "${YELLOW}warning: without HLS support${BLACK}"
winlin authored
525
fi
526 527 528
if [ $SRS_NGINX = YES ]; then
    echo -e "${GREEN}Nginx http server is enabled${BLACK}"
else
529
    echo -e "${GREEN}note: Nginx http server is disabled${BLACK}"
530
fi
531 532 533 534 535
if [ $SRS_DVR = YES ]; then
    echo -e "${GREEN}DVR is enabled${BLACK}"
else
    echo -e "${YELLOW}warning: without DVR support${BLACK}"
fi
winlin authored
536 537 538 539 540
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
541
if [ $SRS_FFMPEG_TOOL = YES ]; then
winlin authored
542
    echo -e "${GREEN}transcode/mux/ingest tool FFMPEG is enabled${BLACK}"
winlin authored
543
else
winlin authored
544 545 546 547 548 549 550 551 552 553 554
    echo -e "${YELLOW}warning: without transcode/mux/ingest tool FFMPEG support${BLACK}"
fi
if [ $SRS_TRANSCODE = YES ]; then
    echo -e "${GREEN}transcoding RTMP stream is enabled${BLACK}"
else
    echo -e "${YELLOW}warning: without transcoding RTMP stream support${BLACK}"
fi
if [ $SRS_INGEST = YES ]; then
    echo -e "${GREEN}ingest file/stream/device is enabled${BLACK}"
else
    echo -e "${YELLOW}warning: without ingest file/stream/device support${BLACK}"
winlin authored
555
fi
556
if [ $SRS_HTTP_CALLBACK = YES ]; then
557 558 559 560
    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
561 562 563 564 565
if [ $SRS_HTTP_SERVER = YES ]; then
    echo -e "${GREEN}http server to delivery http stream is enabled${BLACK}"
else
    echo -e "${YELLOW}warning: without http server to delivery http stream support${BLACK}"
fi
winlin authored
566 567 568 569 570
if [ $SRS_HTTP_API = YES ]; then
    echo -e "${GREEN}http api to manage server is enabled${BLACK}"
else
    echo -e "${YELLOW}warning: without http api to manage server support${BLACK}"
fi
winlin authored
571 572 573 574 575
if [ $SRS_LIBRTMP = YES ]; then
    echo -e "${GREEN}srs-librtmp for client is enabled${BLACK}"
else
    echo -e "${YELLOW}note: srs-librtmp for client is disabled${BLACK}"
fi
576 577 578
if [ $SRS_BWTC = YES ]; then
    echo -e "${GREEN}srs bandwidth test client is enabled${BLACK}"
else
579
    echo -e "${GREEN}note: srs bandwidth test client is disabled${BLACK}"
580
fi
581 582 583
if [ $SRS_RESEARCH = YES ]; then
    echo -e "${GREEN}research tools are builded${BLACK}"
else
584
    echo -e "${GREEN}note: research tools are not builded${BLACK}"
585 586 587 588 589
fi
if [ $SRS_UTEST = YES ]; then
    echo -e "${GREEN}utest for srs are builded${BLACK}"
else
    echo -e "${YELLOW}note: utest for srs are not builded${BLACK}"
590
fi
winlin authored
591 592 593
if [ $SRS_GPERF = YES ]; then
    echo -e "${GREEN}gperf(tcmalloc) for srs are builded${BLACK}"
else
winlin authored
594
    echo -e "${GREEN}note: gperf(tcmalloc) for srs are not builded${BLACK}"
winlin authored
595
fi
596
if [ $SRS_GPERF_MC = YES ]; then
winlin authored
597
    echo -e "${YELLOW}gmc(gperf memory check) for srs are builded -- Performance may suffer${BLACK}"
winlin authored
598
else
winlin authored
599
    echo -e "${GREEN}note: gmc(gperf memory check) for srs are not builded${BLACK}"
600 601
fi
if [ $SRS_GPERF_MP = YES ]; then
winlin authored
602
    echo -e "${YELLOW}gmp(gperf memory profile) for srs are builded -- Performance may suffer${BLACK}"
603
else
winlin authored
604
    echo -e "${GREEN}note: gmp(gperf memory profile) for srs are not builded${BLACK}"
605 606
fi
if [ $SRS_GPERF_CP = YES ]; then
winlin authored
607 608 609 610 611 612
    echo -e "${YELLOW}gcp(gperf cpu profile) for srs are builded -- Performance may suffer${BLACK}"
else
    echo -e "${GREEN}note: gcp(gperf cpu profile) for srs are not builded${BLACK}"
fi
if [ $SRS_GPROF = YES ]; then
    echo -e "${YELLOW}gprof(GNU profile tool) for srs are builded -- Performance may suffer${BLACK}"
613
else
winlin authored
614
    echo -e "${GREEN}note: gprof(GNU profile tool) for srs are not builded${BLACK}"
winlin authored
615
fi
616 617 618 619 620
if [ $SRS_ARM_UBUNTU12 = YES ]; then
    echo -e "${GREEN}arm-ubuntu12(armhf, v7cpu) for srs are builded${BLACK}"
else
    echo -e "${GREEN}note: arm-ubuntu12(armhf, v7cpu) for srs are not builded${BLACK}"
fi
winlin authored
621
622 623 624
#####################################################################################
# next step
#####################################################################################
winlin authored
625
ip=`ifconfig|grep "inet addr"| grep -v "127.0.0.1"|awk '{print $2}'|awk -F ':' 'NR==1 {print $2}'`
winlin authored
626
echo ""
winlin authored
627 628 629
echo "you can:"
echo "\" make \" to build the srs(simple rtmp server)."
echo "\" make help \" to get the usage of make"
630
if [ $SRS_NGINX = YES ]; then
631
    echo "\" sudo ./objs/nginx/sbin/nginx  \" to start the nginx http server for hls"
winlin authored
632
    echo "\" http://$ip \" rtmp players(OSMF/JWPlayer)"
633
fi
634
if [ $SRS_FFMPEG_TOOL = YES ]; then
winlin authored
635 636
    echo -e "\" ./objs/ffmpeg/bin/ffmpeg  \" is used for live stream transcoding"
fi
637
if [ $SRS_HTTP_CALLBACK = YES ]; then
winlin authored
638 639
    echo -e "\" python ./research/api-server/server.py 8085  \" to start the api-server"
fi
winlin authored
640
echo "\" ./objs/srs -c conf/srs.conf \" to start the srs live server"
641
echo "\" ./objs/srs.test \" to test srs"