configure 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. #!/bin/bash
  2. #####################################################################################
  3. # the main output dir, all configure and make output are in this dir.
  4. #####################################################################################
  5. # create the main objs
  6. SRS_OBJS="objs"
  7. mkdir -p ${SRS_OBJS}
  8. #####################################################################################
  9. # linux shell color support.
  10. RED="\\e[31m"
  11. GREEN="\\e[32m"
  12. YELLOW="\\e[33m"
  13. BLACK="\\e[0m"
  14. #####################################################################################
  15. # parse user options, set the variables like:
  16. # srs features: SRS_SSL/SRS_HLS/SRS_NGINX/SRS_FFMPEG_TOOL/SRS_HTTP_CALLBACK/......
  17. # build options: SRS_JOBS
  18. #####################################################################################
  19. SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
  20. # parse options, exit with error when parse options invalid.
  21. . auto/options.sh
  22. # clean the exists
  23. # do this only when the options is ok.
  24. if [[ -f Makefile ]]; then
  25. make clean
  26. fi
  27. # write user options to headers
  28. echo "// auto generated by configure" > $SRS_AUTO_HEADERS_H
  29. echo "#ifndef SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
  30. echo "#define SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
  31. echo "" >> $SRS_AUTO_HEADERS_H
  32. echo "#define SRS_AUTO_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
  33. echo "#define SRS_AUTO_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
  34. echo "#define SRS_AUTO_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
  35. echo "#define SRS_AUTO_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
  36. echo "#define SRS_AUTO_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
  37. # new empty line to auto headers file.
  38. echo "" >> $SRS_AUTO_HEADERS_H
  39. #####################################################################################
  40. # generate auto headers file, depends on the finished of options.sh
  41. #####################################################################################
  42. if [ $SRS_ARM_UBUNTU12 = YES ]; then
  43. __SrsArmCC="arm-linux-gnueabi-gcc";
  44. __SrsArmGCC="arm-linux-gnueabi-gcc";
  45. __SrsArmCXX="arm-linux-gnueabi-g++";
  46. __SrsArmAR="arm-linux-gnueabi-ar";
  47. __SrsArmLD="arm-linux-gnueabi-ld";
  48. __SrsArmRANDLIB="arm-linux-gnueabi-ranlib";
  49. fi
  50. if [ $SRS_MIPS_UBUNTU12 = YES ]; then
  51. __SrsArmCC="mipsel-openwrt-linux-gcc";
  52. __SrsArmGCC="mipsel-openwrt-linux-gcc";
  53. __SrsArmCXX="mipsel-openwrt-linux-g++";
  54. __SrsArmAR="mipsel-openwrt-linux-ar";
  55. __SrsArmLD="mipsel-openwrt-linux-ld";
  56. __SrsArmRANDLIB="mipsel-openwrt-linux-ranlib";
  57. fi
  58. # the arm-ubuntu12 options for make for depends
  59. if [[ -z $SrsArmCC ]]; then SrsArmCC=$__SrsArmCC; fi
  60. if [[ -z $SrsArmGCC ]]; then SrsArmGCC=$__SrsArmGCC; fi
  61. if [[ -z $SrsArmCXX ]]; then SrsArmCXX=$__SrsArmCXX; fi
  62. if [[ -z $SrsArmAR ]]; then SrsArmAR=$__SrsArmAR; fi
  63. if [[ -z $SrsArmLD ]]; then SrsArmLD=$__SrsArmLD; fi
  64. if [[ -z $SrsArmRANDLIB ]]; then SrsArmRANDLIB=$__SrsArmRANDLIB; fi
  65. # write to source file
  66. if [ $SRS_EMBEDED_CPU = YES ]; then
  67. echo "cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB"
  68. echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB\"" >> $SRS_AUTO_HEADERS_H
  69. else
  70. echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"normal x86/x64 gcc\"" >> $SRS_AUTO_HEADERS_H
  71. fi
  72. echo "" >> $SRS_AUTO_HEADERS_H
  73. # apply user options.
  74. . auto/depends.sh
  75. # auto header EOF.
  76. echo "#endif" >> $SRS_AUTO_HEADERS_H
  77. echo "" >> $SRS_AUTO_HEADERS_H
  78. #####################################################################################
  79. # generate Makefile.
  80. #####################################################################################
  81. SRS_MAKEFILE="Makefile"
  82. # ubuntu echo in Makefile cannot display color, use bash instead
  83. SRS_BUILD_SUMMARY="_srs_build_summary.sh"
  84. #####################################################################################
  85. # srs-librtmp sample entry
  86. SrsLibrtmpSampleEntry="nossl"
  87. if [ $SRS_SSL = YES ]; then SrsLibrtmpSampleEntry="ssl";fi
  88. # utest make entry, (cd utest; make)
  89. SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\""
  90. if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS}/utest; \$(MAKE))"; fi
  91. #####################################################################################
  92. # colorful summary
  93. SrsHlsSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HLS = YES ]; then SrsHlsSummaryColor="\${GREEN}"; fi
  94. SrsDvrSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_DVR = YES ]; then SrsDvrSummaryColor="\${GREEN}"; fi
  95. SrsNginxSummaryColor="\${GREEN}{disabled} "; if [ $SRS_NGINX = YES ]; then SrsNginxSummaryColor="\${GREEN}"; fi
  96. SrsSslSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_SSL = YES ]; then SrsSslSummaryColor="\${GREEN}"; fi
  97. SrsFfmpegSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_FFMPEG_TOOL = YES ]; then SrsFfmpegSummaryColor="\${GREEN}"; fi
  98. SrsTranscodeSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_TRANSCODE = YES ]; then SrsTranscodeSummaryColor="\${GREEN}"; fi
  99. SrsIngestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_INGEST = YES ]; then SrsIngestSummaryColor="\${GREEN}"; fi
  100. SrsHttpCallbackSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_CALLBACK = YES ]; then SrsHttpCallbackSummaryColor="\${GREEN}"; fi
  101. SrsHttpServerSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_SERVER = YES ]; then SrsHttpServerSummaryColor="\${GREEN}"; fi
  102. SrsHttpApiSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_API = YES ]; then SrsHttpApiSummaryColor="\${GREEN}"; fi
  103. SrsLibrtmpSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_LIBRTMP = YES ]; then SrsLibrtmpSummaryColor="\${GREEN}"; fi
  104. SrsLibrtmpSSLSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_LIBRTMP = YES ]; then if [ $SRS_SSL = YES ]; then SrsLibrtmpSSLSummaryColor="\${GREEN}"; fi fi
  105. SrsResearchSummaryColor="\${GREEN}{disabled} "; if [ $SRS_RESEARCH = YES ]; then SrsResearchSummaryColor="\${GREEN}"; fi
  106. SrsUtestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\${GREEN}"; fi
  107. SrsGperfSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\${GREEN}"; fi
  108. SrsGperfMCSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\${YELLOW}"; fi
  109. SrsGperfMPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MP = YES ]; then SrsGperfMPSummaryColor="\${YELLOW}"; fi
  110. SrsGperfCPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi
  111. SrsGprofSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi
  112. cat <<END > ${SRS_OBJS}/${SRS_BUILD_SUMMARY}
  113. #!/bin/bash
  114. #####################################################################################
  115. # linux shell color support.
  116. RED="\\${RED}"
  117. GREEN="\\${GREEN}"
  118. YELLOW="\\${YELLOW}"
  119. BLACK="\\${BLACK}"
  120. echo -e "\${GREEN}build summary:\${BLACK}"
  121. echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
  122. echo -e " |${SrsGperfSummaryColor}gperf @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_GPERF\${BLACK}"
  123. echo -e " | ${SrsGperfMCSummaryColor}gmc @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\${BLACK}"
  124. echo -e " | ${SrsGperfMCSummaryColor}gmc: gperf memory check\${BLACK}"
  125. echo -e " | ${SrsGperfMCSummaryColor}env PPROF_PATH=./objs/pprof HEAPCHECK=normal ./objs/srs -c conf/console.conf # start gmc\${BLACK}"
  126. echo -e " | ${SrsGperfMCSummaryColor}killall -2 srs # or CTRL+C to stop gmc\${BLACK}"
  127. echo -e " | ${SrsGperfMPSummaryColor}gmp @see: http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html\${BLACK}"
  128. echo -e " | ${SrsGperfMPSummaryColor}gmp: gperf memory profile\${BLACK}"
  129. echo -e " | ${SrsGperfMPSummaryColor}rm -f gperf.srs.gmp*; ./objs/srs -c conf/console.conf # start gmp\${BLACK}"
  130. echo -e " | ${SrsGperfMPSummaryColor}killall -2 srs # or CTRL+C to stop gmp\${BLACK}"
  131. echo -e " | ${SrsGperfMPSummaryColor}./objs/pprof --text objs/srs gperf.srs.gmp* # to analysis memory profile\${BLACK}"
  132. echo -e " | ${SrsGperfCPSummaryColor}gcp @see: http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html\${BLACK}"
  133. echo -e " | ${SrsGperfCPSummaryColor}gcp: gperf cpu profile\${BLACK}"
  134. echo -e " | ${SrsGperfCPSummaryColor}rm -f gperf.srs.gcp*; ./objs/srs -c conf/console.conf # start gcp\${BLACK}"
  135. echo -e " | ${SrsGperfCPSummaryColor}killall -2 srs # or CTRL+C to stop gcp\${BLACK}"
  136. echo -e " | ${SrsGperfCPSummaryColor}./objs/pprof --text objs/srs gperf.srs.gcp* # to analysis cpu profile\${BLACK}"
  137. echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
  138. echo -e " |${SrsGprofSummaryColor}gprof @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_GPROF\${BLACK}"
  139. echo -e " |${SrsGprofSummaryColor}gprof: GNU profile tool, @see: http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html\${BLACK}"
  140. echo -e " | ${SrsGprofSummaryColor}rm -f gmon.out; ./objs/srs -c conf/console.conf # start gprof\${BLACK}"
  141. echo -e " | ${SrsGprofSummaryColor}killall -2 srs # or CTRL+C to stop gprof\${BLACK}"
  142. echo -e " | ${SrsGprofSummaryColor}gprof -b ./objs/srs gmon.out > gprof.srs.log && rm -f gmon.out # gprof report to gprof.srs.log\${BLACK}"
  143. echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
  144. echo -e " |${SrsResearchSummaryColor}research: ./objs/research, api server, players, ts info, librtmp.\${BLACK}"
  145. echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
  146. echo -e " |${SrsUtestSummaryColor}utest: ./objs/srs_utest, the utest for srs\${BLACK}"
  147. echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
  148. echo -e " |${SrsLibrtmpSummaryColor}librtmp @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SrsLibrtmp\${BLACK}"
  149. echo -e " |${SrsLibrtmpSummaryColor}librtmp: ./objs/include, ./objs/lib, the srs-librtmp library\${BLACK}"
  150. echo -e " | ${SrsLibrtmpSummaryColor}simple handshake: publish/play stream with simple handshake to server\${BLACK}"
  151. echo -e " | ${SrsLibrtmpSSLSummaryColor}complex handshake: it's not required for client, recommend disable it\${BLACK}"
  152. echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp, the srs-librtmp client sample\${BLACK}"
  153. echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp/objs/srs_ingest_flv\${BLACK}"
  154. echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp/objs/srs_ingest_rtmp\${BLACK}"
  155. echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp/objs/srs_detect_rtmp\${BLACK}"
  156. echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp/objs/srs_bandwidth_check\${BLACK}"
  157. echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
  158. echo -e " |\${GREEN}server: ./objs/srs -c conf/srs.conf, start the srs server\${BLACK}"
  159. echo -e " | ${SrsHlsSummaryColor}hls @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DeliveryHLS\${BLACK}"
  160. echo -e " | ${SrsHlsSummaryColor}hls: generate m3u8 and ts from rtmp stream\${BLACK}"
  161. echo -e " | ${SrsDvrSummaryColor}dvr @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DVR\${BLACK}"
  162. echo -e " | ${SrsDvrSummaryColor}dvr: record RTMP stream to flv files.\${BLACK}"
  163. echo -e " | ${SrsNginxSummaryColor}nginx @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DeliveryHLS\${BLACK}"
  164. echo -e " | ${SrsNginxSummaryColor}nginx: delivery HLS stream by nginx\${BLACK}"
  165. echo -e " | ${SrsNginxSummaryColor}nginx: sudo ./objs/nginx/sbin/nginx\${BLACK}"
  166. echo -e " | ${SrsSslSummaryColor}ssl @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_RTMPHandshake\${BLACK}"
  167. echo -e " | ${SrsSslSummaryColor}ssl: support RTMP complex handshake for client required, for instance, flash\${BLACK}"
  168. echo -e " | ${SrsFfmpegSummaryColor}ffmpeg @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_FFMPEG\${BLACK}"
  169. echo -e " | ${SrsFfmpegSummaryColor}ffmpeg: transcode, mux, ingest tool\${BLACK}"
  170. echo -e " | ${SrsFfmpegSummaryColor}ffmpeg: ./objs/ffmpeg/bin/ffmpeg\${BLACK}"
  171. echo -e " | ${SrsTranscodeSummaryColor}transcode @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_FFMPEG\${BLACK}"
  172. echo -e " | ${SrsTranscodeSummaryColor}transcode: support transcoding RTMP stream\${BLACK}"
  173. echo -e " | ${SrsIngestSummaryColor}ingest @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Ingest\${BLACK}"
  174. echo -e " | ${SrsIngestSummaryColor}ingest: support ingest file/stream/device then push to SRS by RTMP stream\${BLACK}"
  175. echo -e " | ${SrsHttpCallbackSummaryColor}http-callback @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPCallback\${BLACK}"
  176. echo -e " | ${SrsHttpCallbackSummaryColor}http-callback: support http callback for authentication and event injection\${BLACK}"
  177. echo -e " | ${SrsHttpServerSummaryColor}http-server @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPServer\${BLACK}"
  178. echo -e " | ${SrsHttpServerSummaryColor}http-server: support http server to delivery http stream\${BLACK}"
  179. echo -e " | ${SrsHttpApiSummaryColor}http-api @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPApi\${BLACK}"
  180. echo -e " | ${SrsHttpApiSummaryColor}http-api: support http api to manage server\${BLACK}"
  181. echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
  182. echo -e "\${GREEN}binaries @see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Build\${BLACK}"
  183. echo "you can:"
  184. echo " ./objs/srs -c conf/srs.conf"
  185. echo " to start the srs server, with config conf/srs.conf."
  186. END
  187. #####################################################################################
  188. # makefile
  189. echo "generate Makefile"
  190. cat << END > ${SRS_MAKEFILE}
  191. .PHONY: default _default install install-api help clean server librtmp utest _prepare_dir
  192. # install prefix.
  193. SRS_PREFIX=${SRS_PREFIX}
  194. __REAL_INSTALL=\$(DESTDIR)\$(SRS_PREFIX)
  195. END
  196. # embeded, ubuntu12, use embeded tool chain.
  197. if [ $SRS_EMBEDED_CPU = YES ]; then
  198. cat << END >> ${SRS_MAKEFILE}
  199. default:
  200. \$(MAKE) GCC=${SrsArmGCC} CXX=${SrsArmCXX} AR=${SrsArmAR} LINK=${SrsArmCXX} _default
  201. END
  202. # x86/x64, use gnu-gcc/g++ tool chain.
  203. else
  204. cat << END >> ${SRS_MAKEFILE}
  205. default:
  206. \$(MAKE) _default
  207. END
  208. fi
  209. # the real entry for all platform.
  210. cat << END >> ${SRS_MAKEFILE}
  211. _default: server librtmp utest
  212. @bash objs/_srs_build_summary.sh
  213. help:
  214. @echo "Usage: make <help>|<clean>|<server>|<librtmp>|<utest>|<install>|<install-api>|<uninstall>"
  215. @echo " help display this help menu"
  216. @echo " clean cleanup project"
  217. @echo " server build the srs(simple rtmp server) over st(state-threads)"
  218. @echo " librtmp build the client publish/play library, and samples"
  219. @echo " utest build the utest for srs"
  220. @echo " install install srs to the prefix path"
  221. @echo " install-api install srs and api-server to the prefix path"
  222. @echo " uninstall uninstall srs from prefix path"
  223. clean:
  224. (cd ${SRS_OBJS}; rm -rf srs srs_utest)
  225. (cd ${SRS_OBJS}; rm -rf src research include lib)
  226. (cd ${SRS_OBJS}/utest; rm -rf *.o *.a)
  227. (cd research/librtmp; make clean)
  228. (cd research/api-server/static-dir; rm -rf crossdomain.xml forward live players)
  229. server: _prepare_dir
  230. @echo "build the srs(simple rtmp server) over st(state-threads)"
  231. \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} srs
  232. END
  233. # install entry
  234. cat << END >> ${SRS_MAKEFILE}
  235. uninstall:
  236. @echo "rmdir \$(SRS_PREFIX)"
  237. @rm -rf \$(SRS_PREFIX)
  238. install-api: install
  239. @echo "mkdir \$(__REAL_INSTALL)"
  240. @mkdir -p \$(__REAL_INSTALL)
  241. @echo "copy binary files"
  242. @mkdir -p \$(__REAL_INSTALL)/research/api-server
  243. @cp research/api-server/server.py \$(__REAL_INSTALL)/research/api-server
  244. @mkdir -p \$(__REAL_INSTALL)/objs/ffmpeg/bin
  245. @cp objs/ffmpeg/bin/ffmpeg \$(__REAL_INSTALL)/objs/ffmpeg/bin
  246. @echo "copy html files"
  247. @mkdir -p \$(__REAL_INSTALL)/research/api-server/static-dir/players
  248. @cp research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/research/api-server/static-dir
  249. @cp research/api-server/static-dir/index.html \$(__REAL_INSTALL)/research/api-server/static-dir
  250. @cp -r research/api-server/static-dir/players/* \$(__REAL_INSTALL)/research/api-server/static-dir/players
  251. @echo "copy init.d script files"
  252. @mkdir -p \$(__REAL_INSTALL)/etc/init.d
  253. @cp etc/init.d/srs-api \$(__REAL_INSTALL)/etc/init.d
  254. @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs-api
  255. @echo ""
  256. @echo "api installed, to link and start api:"
  257. @echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs-api /etc/init.d/srs-api"
  258. @echo " /etc/init.d/srs-api start"
  259. @echo " http://\$(shell bash auto/local_ip.sh):8085"
  260. @echo "@see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_LinuxService"
  261. install:
  262. @echo "mkdir \$(__REAL_INSTALL)"
  263. @mkdir -p \$(__REAL_INSTALL)
  264. @echo "make the http root dir"
  265. @mkdir -p \$(__REAL_INSTALL)/objs/nginx/html
  266. @cp research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/objs/nginx/html
  267. @echo "copy binary files"
  268. @mkdir -p \$(__REAL_INSTALL)/objs
  269. @cp objs/srs \$(__REAL_INSTALL)/objs
  270. @echo "copy srs conf files"
  271. @mkdir -p \$(__REAL_INSTALL)/conf
  272. @cp conf/*.conf \$(__REAL_INSTALL)/conf
  273. @echo "copy init.d script files"
  274. @mkdir -p \$(__REAL_INSTALL)/etc/init.d
  275. @cp etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d
  276. @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs
  277. @echo ""
  278. @echo "srs installed, to link and start srs:"
  279. @echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs"
  280. @echo " /etc/init.d/srs start"
  281. @echo "@see: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_LinuxService"
  282. END
  283. if [ $SRS_LIBRTMP = YES ]; then
  284. cat << END >> ${SRS_MAKEFILE}
  285. librtmp: server
  286. @echo "build the client publish/play library."
  287. \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} librtmp
  288. @echo "build the srs-librtmp sample"
  289. (cd research/librtmp; \$(MAKE) ${SrsLibrtmpSampleEntry})
  290. END
  291. else
  292. cat << END >> ${SRS_MAKEFILE}
  293. librtmp: server
  294. @echo "srs-librtmp is disabled, ignore."
  295. END
  296. fi
  297. if [ $SRS_UTEST = YES ]; then
  298. cat << END >> ${SRS_MAKEFILE}
  299. utest: server
  300. @echo "build the utest for srs"
  301. ${SrsUtestMakeEntry}
  302. @echo "utest for srs build success"
  303. END
  304. else
  305. cat << END >> ${SRS_MAKEFILE}
  306. utest: server
  307. @echo "utest is disabled, ignore"
  308. END
  309. fi
  310. cat << END >> ${SRS_MAKEFILE}
  311. # the ./configure will generate it.
  312. _prepare_dir:
  313. @mkdir -p ${SRS_OBJS}
  314. END
  315. #####################################################################################
  316. # build tools or compiler args.
  317. # enable gdb debug
  318. GDBDebug=" -g -O0"
  319. # the warning level.
  320. WarnLevel=" -Wall"
  321. # the compile standard.
  322. CppStd="-ansi"
  323. # for library compile
  324. LibraryCompile=" -fPIC"
  325. # performance of gprof
  326. SrsGprof=""; SrsGprofLink=""; if [ $SRS_GPROF = YES ]; then SrsGprof=" -pg -lc_p"; SrsGprofLink=" -pg"; fi
  327. # performance of gperf
  328. SrsGperf=""; SrsGperfLink=""; if [ $SRS_GPERF = YES ]; then SrsGperfLink=" -lpthread"; fi
  329. # the cxx flag generated.
  330. CXXFLAGS="${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}"
  331. if [ $SRS_GPERF = YES ]; then CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"; fi
  332. cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}
  333. GCC = gcc
  334. CXX = g++
  335. AR = ar
  336. LINK = g++
  337. CXXFLAGS = ${CXXFLAGS}
  338. .PHONY: default srs librtmp
  339. default:
  340. END
  341. #####################################################################################
  342. # Libraries, external library to build in srs,
  343. # header(.h): add to ModuleLibIncs if need the specified library. for example, LibSTRoot
  344. # library(.a): add to ModuleLibFiles if binary need the specifeid library. for example, LibSTfile
  345. #
  346. # st(state-threads) the basic network library for SRS.
  347. LibSTRoot="${SRS_OBJS}/st"; LibSTfile="${LibSTRoot}/libst.a"
  348. # hp(http-parser) the http request/url parser, for SRS to support HTTP callback.
  349. LibHttpParserRoot=""; LibHttpParserfile=""
  350. if [ $SRS_HTTP_PARSER = YES ]; then LibHttpParserRoot="${SRS_OBJS}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi
  351. # openssl-1.0.1f, for the RTMP complex handshake.
  352. LibSSLRoot="";LibSSLfile=""
  353. 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
  354. # gperftools-2.1, for mem check and mem/cpu profile
  355. LibGperfRoot=""; LibGperfFile=""
  356. if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS}/gperf/include"; LibGperfFile="${SRS_OBJS}/gperf/lib/libtcmalloc_and_profiler.a"; fi
  357. # the link options, always use static link
  358. SrsLinkOptions="-ldl";
  359. if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lssl"; fi fi
  360. # if static specified, add static
  361. # TODO: FIXME: remove static.
  362. if [ $SRS_STATIC = YES ]; then SrsLinkOptions="${SrsLinkOptions} -static"; fi
  363. # if mips, add -lgcc_eh, or stl compile failed.
  364. if [ $SRS_MIPS_UBUNTU12 = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lgcc_eh"; fi
  365. #####################################################################################
  366. # Modules, compile each module, then link to binary
  367. #
  368. #Core, depends only on system apis.
  369. MODULE_ID="CORE"
  370. MODULE_DEPENDS=()
  371. ModuleLibIncs=(${SRS_OBJS})
  372. MODULE_FILES=("srs_core" "srs_core_autofree")
  373. CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh
  374. CORE_OBJS="${MODULE_OBJS[@]}"
  375. #
  376. #Kernel, depends on core, provides error/log/config, nothing about stream information.
  377. MODULE_ID="KERNEL"
  378. MODULE_DEPENDS=("CORE")
  379. ModuleLibIncs=(${SRS_OBJS})
  380. MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream" "srs_kernel_buffer"
  381. "srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_file"
  382. "srs_kernel_consts")
  383. KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh
  384. KERNEL_OBJS="${MODULE_OBJS[@]}"
  385. #
  386. #RTMP Protocol, depends on core/kernel, provides rtmp/htttp protocol features.
  387. MODULE_ID="RTMP"
  388. MODULE_DEPENDS=("CORE" "KERNEL")
  389. ModuleLibIncs=(${SRS_OBJS} ${LibSSLRoot})
  390. MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_protocol_stack" "srs_protocol_rtmp"
  391. "srs_protocol_handshake" "srs_protocol_utility" "srs_protocol_msg_array")
  392. RTMP_INCS="src/rtmp"; MODULE_DIR=${RTMP_INCS} . auto/modules.sh
  393. RTMP_OBJS="${MODULE_OBJS[@]}"
  394. #
  395. #App Module
  396. MODULE_ID="APP"
  397. MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
  398. ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS})
  399. MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_st_socket" "srs_app_source"
  400. "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http"
  401. "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
  402. "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" "srs_app_http_conn" "srs_app_http_hooks"
  403. "srs_app_json" "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge"
  404. "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_avc_aac")
  405. APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
  406. APP_OBJS="${MODULE_OBJS[@]}"
  407. #
  408. #LIBS Module, build libsrs.a for static link.
  409. MODULE_ID="LIBS"
  410. MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
  411. ModuleLibIncs=(${SRS_OBJS})
  412. MODULE_FILES=("srs_librtmp" "srs_lib_simple_socket" "srs_lib_bandwidth")
  413. LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh
  414. LIBS_OBJS="${MODULE_OBJS[@]}"
  415. #
  416. #Main Module
  417. MODULE_ID="MAIN"
  418. MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
  419. ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS} ${LibGperfRoot})
  420. MODULE_FILES=("srs_main_server")
  421. MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
  422. MAIN_OBJS="${MODULE_OBJS[@]}"
  423. #####################################################################################
  424. # Binaries, main entrances, link the module and its depends modules,
  425. # then link to a binary, for example, objs/srs
  426. #
  427. # all main entrances
  428. MAIN_ENTRANCES=("srs_main_server")
  429. #
  430. # all depends libraries
  431. ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile} ${LibGperfFile})
  432. # all depends objects
  433. MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
  434. LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}"
  435. #
  436. # srs:
  437. # srs(simple rtmp server) over st(state-threads)
  438. BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
  439. # srs librtmp
  440. if [ $SRS_LIBRTMP = YES ]; then
  441. MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${LIBS_OBJS[@]}"
  442. BUILD_KEY="librtmp" LIB_NAME="lib/srs_librtmp" . auto/libs.sh
  443. fi
  444. #
  445. # utest, the unit-test cases of srs, base on gtest1.6
  446. MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol"
  447. "srs_utest_kernel" "srs_utest_core" "srs_utest_config"
  448. "srs_utest_reload")
  449. ModuleLibIncs=(${SRS_OBJS} ${LibSTRoot} ${LibSSLRoot})
  450. ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile})
  451. MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
  452. MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]}"
  453. LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
  454. echo 'configure ok! '
  455. #####################################################################################
  456. # when configure success, prepare build
  457. #####################################################################################
  458. # create objs/logs for ffmpeg to write log.
  459. mkdir -p ${SRS_OBJS}/logs
  460. #####################################################################################
  461. # configure summary
  462. #####################################################################################
  463. # summary
  464. echo ""
  465. echo "configure summary:"
  466. echo " ${SRS_AUTO_USER_CONFIGURE}"
  467. echo " ${SRS_AUTO_CONFIGURE}"
  468. if [ $SRS_HLS = YES ]; then
  469. echo -e "${GREEN}HLS is enabled${BLACK}"
  470. else
  471. echo -e "${YELLOW}warning: without HLS support${BLACK}"
  472. fi
  473. if [ $SRS_NGINX = YES ]; then
  474. echo -e "${GREEN}Nginx http server is enabled${BLACK}"
  475. else
  476. echo -e "${GREEN}note: Nginx http server is disabled${BLACK}"
  477. fi
  478. if [ $SRS_DVR = YES ]; then
  479. echo -e "${GREEN}DVR is enabled${BLACK}"
  480. else
  481. echo -e "${YELLOW}warning: without DVR support${BLACK}"
  482. fi
  483. if [ $SRS_SSL = YES ]; then
  484. echo -e "${GREEN}rtmp complex handshake is enabled${BLACK}"
  485. else
  486. echo -e "${YELLOW}warning: without rtmp complex handshake support, donot support h264/aac to adobe flash player${BLACK}"
  487. fi
  488. if [ $SRS_FFMPEG_TOOL = YES ]; then
  489. echo -e "${GREEN}transcode/mux/ingest tool FFMPEG is enabled${BLACK}"
  490. else
  491. echo -e "${YELLOW}warning: without transcode/mux/ingest tool FFMPEG support${BLACK}"
  492. fi
  493. if [ $SRS_TRANSCODE = YES ]; then
  494. echo -e "${GREEN}transcoding RTMP stream is enabled${BLACK}"
  495. else
  496. echo -e "${YELLOW}warning: without transcoding RTMP stream support${BLACK}"
  497. fi
  498. if [ $SRS_INGEST = YES ]; then
  499. echo -e "${GREEN}ingest file/stream/device is enabled${BLACK}"
  500. else
  501. echo -e "${YELLOW}warning: without ingest file/stream/device support${BLACK}"
  502. fi
  503. if [ $SRS_HTTP_CALLBACK = YES ]; then
  504. echo -e "${GREEN}http hooks callback over CherryPy is enabled${BLACK}"
  505. else
  506. echo -e "${YELLOW}warning: without http hooks callback over CherryPy support${BLACK}"
  507. fi
  508. if [ $SRS_HTTP_SERVER = YES ]; then
  509. echo -e "${GREEN}http server to delivery http stream is enabled${BLACK}"
  510. else
  511. echo -e "${YELLOW}warning: without http server to delivery http stream support${BLACK}"
  512. fi
  513. if [ $SRS_HTTP_API = YES ]; then
  514. echo -e "${GREEN}http api to manage server is enabled${BLACK}"
  515. else
  516. echo -e "${YELLOW}warning: without http api to manage server support${BLACK}"
  517. fi
  518. if [ $SRS_LIBRTMP = YES ]; then
  519. echo -e "${GREEN}srs-librtmp for client is enabled${BLACK}"
  520. else
  521. echo -e "${YELLOW}note: srs-librtmp for client is disabled${BLACK}"
  522. fi
  523. if [ $SRS_RESEARCH = YES ]; then
  524. echo -e "${GREEN}research tools are builded${BLACK}"
  525. else
  526. echo -e "${GREEN}note: research tools are not builded${BLACK}"
  527. fi
  528. if [ $SRS_UTEST = YES ]; then
  529. echo -e "${GREEN}utest for srs are builded${BLACK}"
  530. else
  531. echo -e "${YELLOW}note: utest for srs are not builded${BLACK}"
  532. fi
  533. if [ $SRS_GPERF = YES ]; then
  534. echo -e "${GREEN}gperf(tcmalloc) for srs are builded${BLACK}"
  535. else
  536. echo -e "${GREEN}note: gperf(tcmalloc) for srs are not builded${BLACK}"
  537. fi
  538. if [ $SRS_GPERF_MC = YES ]; then
  539. echo -e "${YELLOW}gmc(gperf memory check) for srs are builded -- Performance may suffer${BLACK}"
  540. else
  541. echo -e "${GREEN}note: gmc(gperf memory check) for srs are not builded${BLACK}"
  542. fi
  543. if [ $SRS_GPERF_MP = YES ]; then
  544. echo -e "${YELLOW}gmp(gperf memory profile) for srs are builded -- Performance may suffer${BLACK}"
  545. else
  546. echo -e "${GREEN}note: gmp(gperf memory profile) for srs are not builded${BLACK}"
  547. fi
  548. if [ $SRS_GPERF_CP = YES ]; then
  549. echo -e "${YELLOW}gcp(gperf cpu profile) for srs are builded -- Performance may suffer${BLACK}"
  550. else
  551. echo -e "${GREEN}note: gcp(gperf cpu profile) for srs are not builded${BLACK}"
  552. fi
  553. if [ $SRS_GPROF = YES ]; then
  554. echo -e "${YELLOW}gprof(GNU profile tool) for srs are builded -- Performance may suffer${BLACK}"
  555. else
  556. echo -e "${GREEN}note: gprof(GNU profile tool) for srs are not builded${BLACK}"
  557. fi
  558. if [ $SRS_ARM_UBUNTU12 = YES ]; then
  559. echo -e "${GREEN}arm-ubuntu12(armhf, v7cpu) for srs are builded${BLACK}"
  560. else
  561. echo -e "${GREEN}note: arm-ubuntu12(armhf, v7cpu) for srs are not builded${BLACK}"
  562. fi
  563. if [ $SRS_MIPS_UBUNTU12 = YES ]; then
  564. echo -e "${GREEN}mips-ubuntu12 for srs are builded${BLACK}"
  565. else
  566. echo -e "${GREEN}note: mips-ubuntu12 for srs are not builded${BLACK}"
  567. fi
  568. #####################################################################################
  569. # next step
  570. #####################################################################################
  571. ip=`ifconfig|grep "inet addr"| grep -v "127.0.0.1"|awk '{print $2}'|awk -F ':' 'NR==1 {print $2}'`
  572. echo ""
  573. echo "to run 3rdparty application:"
  574. if [ $SRS_NGINX = YES ]; then
  575. echo "\" sudo ./objs/nginx/sbin/nginx \" to start the nginx http server for hls"
  576. fi
  577. if [ $SRS_FFMPEG_TOOL = YES ]; then
  578. echo -e "\" ./objs/ffmpeg/bin/ffmpeg \" is used for live stream transcoding"
  579. fi
  580. if [ $SRS_HTTP_CALLBACK = YES ]; then
  581. echo -e "\" python ./research/api-server/server.py 8085 \" to start the api-server"
  582. fi
  583. echo ""
  584. echo "to build:"
  585. echo "\" make \" to build the srs(simple rtmp server)."
  586. echo "\" make help \" to get the usage of make"