2
0

configure 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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_WORKDIR="."
  7. SRS_OBJS_DIR="objs"
  8. SRS_OBJS="${SRS_WORKDIR}/${SRS_OBJS_DIR}"
  9. SRS_MAKEFILE="Makefile"
  10. # linux shell color support.
  11. RED="\\033[31m"
  12. GREEN="\\033[32m"
  13. YELLOW="\\033[33m"
  14. BLACK="\\033[0m"
  15. #####################################################################################
  16. # parse user options, set the variables like:
  17. # srs features: SRS_SSL/SRS_HLS/SRS_HTTP_CALLBACK/......
  18. # build options: SRS_JOBS
  19. #####################################################################################
  20. # parse options, exit with error when parse options invalid.
  21. . auto/options.sh
  22. # setup variables when options parsed.
  23. . auto/setup_variables.sh
  24. # We don't need to cleanup the exists files.
  25. rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE}
  26. # create objs
  27. mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}
  28. # for export srs-librtmp, change target to it.
  29. . auto/generate-srs-librtmp-project.sh
  30. # apply user options.
  31. . auto/depends.sh
  32. # the auto generated variables.
  33. . auto/auto_headers.sh
  34. #####################################################################################
  35. # generate Makefile.
  36. #####################################################################################
  37. # ubuntu echo in Makefile cannot display color, use bash instead
  38. SRS_BUILD_SUMMARY="_srs_build_summary.sh"
  39. # srs-librtmp sample entry
  40. SrsLibrtmpSampleEntry="nossl"
  41. if [ $SRS_SSL = YES ]; then SrsLibrtmpSampleEntry="ssl";fi
  42. # utest make entry, (cd utest; make)
  43. SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\""
  44. if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM}/utest && \$(MAKE))"; fi
  45. #####################################################################################
  46. # finger out modules to install.
  47. # where srs module is a dir which contains a config file.
  48. SRS_MODULES=()
  49. __mfiles=`find modules -name "config"` && for __mfile in $__mfiles; do
  50. SRS_MODULES+=("`dirname $__mfile`")
  51. done
  52. # variables for makefile for all modules.
  53. __mphonys="" && __mdefaults="" && __mcleanups="" && __makefiles=""
  54. # add each modules for application
  55. for SRS_MODULE in ${SRS_MODULES[*]}; do
  56. echo "install module at: $SRS_MODULE"
  57. . $SRS_MODULE/config
  58. if [[ $SRS_MODULE_MAKEFILE != "" ]]; then
  59. __makefiles="$__makefiles $SRS_MODULE_MAKEFILE"
  60. fi
  61. if [[ 0 -ne ${#SRS_MODULE_MAIN[@]} ]]; then
  62. __mphonys="$__mphonys $SRS_MODULE_NAME"
  63. __mdefaults="$__mdefaults $SRS_MODULE_NAME"
  64. __mcleanups="$__mcleanups $SRS_MODULE_NAME"
  65. fi
  66. done
  67. # generate extra phony for each modules.
  68. cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}
  69. .PHONY: $__mphonys
  70. END
  71. #####################################################################################
  72. # build tools or compiler args.
  73. # enable gdb debug
  74. GDBDebug=" -g -O0"
  75. # the warning level.
  76. WarnLevel=" -Wall"
  77. # the compile standard.
  78. CppStd="-ansi"
  79. # for library compile
  80. if [[ $SRS_EXPORT_LIBRTMP_PROJECT == YES ]]; then
  81. LibraryCompile=" -fPIC"
  82. fi
  83. # performance of gprof
  84. SrsGprof=""; SrsGprofLink=""; if [ $SRS_GPROF = YES ]; then SrsGprof=" -pg -lc_p"; SrsGprofLink=" -pg"; fi
  85. # performance of gperf
  86. SrsGperf=""; SrsGperfLink=""; if [ $SRS_GPERF = YES ]; then SrsGperfLink=" -lpthread"; fi
  87. # the cxx flag generated.
  88. CXXFLAGS="${CXXFLAGS} ${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}"
  89. if [ $SRS_GPERF = YES ]; then
  90. CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free";
  91. fi
  92. # For coverage.
  93. if [[ $SRS_GCOV == YES ]]; then
  94. SrsGcov="-fprofile-arcs -ftest-coverage"
  95. fi
  96. if [[ $SRS_GCOV == YES ]]; then
  97. CXXFLAGS="${CXXFLAGS} ${SrsGcov}";
  98. fi
  99. # User configed options.
  100. if [[ $SRS_EXTRA_FLAGS != '' ]]; then
  101. CXXFLAGS="${CXXFLAGS} $SRS_EXTRA_FLAGS";
  102. fi
  103. # Start to generate the Makefile.
  104. cat << END >> ${SRS_OBJS}/${SRS_MAKEFILE}
  105. GCC = ${SRS_TOOL_CC}
  106. CXX = ${SRS_TOOL_CXX}
  107. AR = ${SRS_TOOL_AR}
  108. ARFLAGS = -rs
  109. LINK = ${SRS_TOOL_CXX}
  110. CXXFLAGS = ${CXXFLAGS}
  111. .PHONY: default srs srs_ingest_hls librtmp
  112. default:
  113. END
  114. #####################################################################################
  115. # Libraries, external library to build in srs,
  116. # header(.h): add to ModuleLibIncs if need the specified library. for example, LibSTRoot
  117. # library(.a): add to ModuleLibFiles if binary need the specifeid library. for example, LibSTfile
  118. #
  119. # st(state-threads) the basic network library for SRS.
  120. LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a"
  121. if [[ $SRS_SHARED_ST == YES ]]; then LibSTfile="-lst"; fi
  122. # openssl-1.1.0e, for the RTMP complex handshake.
  123. LibSSLRoot="";LibSSLfile=""
  124. if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == NO ]]; then
  125. LibSSLRoot="${SRS_OBJS_DIR}/openssl/include"; LibSSLfile="${SRS_OBJS_DIR}/openssl/lib/libssl.a ${SRS_OBJS_DIR}/openssl/lib/libcrypto.a";
  126. fi
  127. # gperftools-2.1, for mem check and mem/cpu profile
  128. LibGperfRoot=""; LibGperfFile=""
  129. if [ $SRS_GPERF = YES ]; then
  130. LibGperfRoot="${SRS_OBJS_DIR}/gperf/include"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_and_profiler.a";
  131. fi
  132. if [ $SRS_GPERF_MD = YES ]; then
  133. LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a";
  134. fi
  135. # the link options, always use static link
  136. SrsLinkOptions="-ldl";
  137. if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then
  138. SrsLinkOptions="${SrsLinkOptions} -lssl -lcrypto";
  139. fi
  140. # if static specified, add static
  141. # TODO: FIXME: remove static.
  142. if [ $SRS_STATIC = YES ]; then
  143. SrsLinkOptions="${SrsLinkOptions} -static";
  144. fi
  145. # For coverage.
  146. if [[ $SRS_GCOV == YES ]]; then
  147. SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}";
  148. fi
  149. #####################################################################################
  150. # Modules, compile each module, then link to binary
  151. #
  152. #Core, depends only on system apis.
  153. MODULE_ID="CORE"
  154. MODULE_DEPENDS=()
  155. ModuleLibIncs=(${SRS_OBJS_DIR})
  156. MODULE_FILES=("srs_core" "srs_core_version3" "srs_core_autofree" "srs_core_performance"
  157. "srs_core_mem_watch" "srs_core_time")
  158. CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh
  159. CORE_OBJS="${MODULE_OBJS[@]}"
  160. #
  161. #Kernel, depends on core, provides error/log/config, nothing about stream information.
  162. MODULE_ID="KERNEL"
  163. MODULE_DEPENDS=("CORE")
  164. ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
  165. MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_buffer"
  166. "srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_io"
  167. "srs_kernel_consts" "srs_kernel_aac" "srs_kernel_mp3" "srs_kernel_ts"
  168. "srs_kernel_stream" "srs_kernel_balance" "srs_kernel_mp4" "srs_kernel_file")
  169. KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh
  170. KERNEL_OBJS="${MODULE_OBJS[@]}"
  171. #
  172. #RTMP/HTTP/Raw Protocol, depends on core/kernel, provides rtmp/htttp protocol features.
  173. MODULE_ID="PROTOCOL"
  174. MODULE_DEPENDS=("CORE" "KERNEL")
  175. ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
  176. MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_rtmp_stack"
  177. "srs_rtmp_handshake" "srs_protocol_utility" "srs_rtmp_msg_array" "srs_protocol_stream"
  178. "srs_raw_avc" "srs_rtsp_stack" "srs_http_stack" "srs_protocol_kbps" "srs_protocol_json"
  179. "srs_protocol_format")
  180. PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh
  181. PROTOCOL_OBJS="${MODULE_OBJS[@]}"
  182. #
  183. #Service Module, for both Server and Client Modules.
  184. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  185. MODULE_ID="SERVICE"
  186. MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL")
  187. ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot})
  188. MODULE_FILES=("srs_service_log" "srs_service_st" "srs_service_http_client"
  189. "srs_service_http_conn" "srs_service_rtmp_conn" "srs_service_utility"
  190. "srs_service_conn")
  191. DEFINES=""
  192. SERVICE_INCS="src/service"; MODULE_DIR=${SERVICE_INCS} . auto/modules.sh
  193. SERVICE_OBJS="${MODULE_OBJS[@]}"
  194. fi
  195. #
  196. #App Module, for SRS server only.
  197. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  198. MODULE_ID="APP"
  199. MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE")
  200. ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot})
  201. MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_source"
  202. "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http_stream"
  203. "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
  204. "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" "srs_app_http_conn" "srs_app_http_hooks"
  205. "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_edge"
  206. "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_http_static"
  207. "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds"
  208. "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call"
  209. "srs_app_caster_flv" "srs_app_latest_version" "srs_app_uuid" "srs_app_process" "srs_app_ng_exec"
  210. "srs_app_hourglass" "srs_app_dash" "srs_app_fragment" "srs_app_dvr"
  211. "srs_app_coworkers")
  212. DEFINES=""
  213. # add each modules for app
  214. for SRS_MODULE in ${SRS_MODULES[*]}; do
  215. . $SRS_MODULE/config
  216. MODULE_FILES+=("${SRS_MODULE_APP[*]}")
  217. DEFINES="${DEFINES} ${SRS_MODULE_DEFINES}"
  218. done
  219. APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
  220. APP_OBJS="${MODULE_OBJS[@]}"
  221. fi
  222. #
  223. #LIBS Module, build libsrs.a for static link.
  224. MODULE_ID="LIBS"
  225. MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL")
  226. ModuleLibIncs=(${SRS_OBJS_DIR})
  227. MODULE_FILES=("srs_librtmp" "srs_lib_simple_socket" "srs_lib_bandwidth")
  228. LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh
  229. LIBS_OBJS="${MODULE_OBJS[@]}"
  230. #
  231. #Server Module, for SRS only.
  232. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  233. MODULE_ID="SERVER"
  234. MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP")
  235. ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot})
  236. MODULE_FILES=("srs_main_server")
  237. SERVER_INCS="src/main"; MODULE_DIR=${SERVER_INCS} . auto/modules.sh
  238. SERVER_OBJS="${MODULE_OBJS[@]}"
  239. fi
  240. #
  241. #Main Module, for app from modules.
  242. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  243. MODULE_ID="MAIN"
  244. MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE")
  245. ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot})
  246. MODULE_FILES=()
  247. DEFINES=""
  248. # add each modules for main
  249. for SRS_MODULE in ${SRS_MODULES[*]}; do
  250. . $SRS_MODULE/config
  251. MODULE_FILES+=("${SRS_MODULE_MAIN[*]}")
  252. DEFINES="${DEFINES} ${SRS_MODULE_DEFINES}"
  253. done
  254. MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
  255. MAIN_OBJS="${MODULE_OBJS[@]}"
  256. fi
  257. #####################################################################################
  258. # Binaries, main entrances, link the module and its depends modules,
  259. # then link to a binary, for example, objs/srs
  260. #
  261. # Disable SRS application for exporting librtmp.
  262. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  263. # all main entrances
  264. MAIN_ENTRANCES=("srs_main_server")
  265. for SRS_MODULE in ${SRS_MODULES[*]}; do
  266. . $SRS_MODULE/config
  267. MAIN_ENTRANCES+=("${SRS_MODULE_MAIN[*]}")
  268. done
  269. #
  270. # all depends libraries
  271. ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile})
  272. # all depends objects
  273. MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}"
  274. LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}"
  275. #
  276. # srs: srs(simple rtmp server) over st(state-threads)
  277. BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
  278. #
  279. # For modules, without the app module.
  280. MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${MAIN_OBJS[@]}"
  281. #
  282. for SRS_MODULE in ${SRS_MODULES[*]}; do
  283. . $SRS_MODULE/config
  284. # no SRS_MODULE_MAIN
  285. if [[ 0 -eq ${#SRS_MODULE_MAIN[@]} ]]; then continue; fi
  286. BUILD_KEY="$SRS_MODULE_NAME" APP_MAIN="${SRS_MODULE_MAIN[0]}" APP_NAME="$SRS_MODULE_NAME" . auto/apps.sh
  287. done
  288. fi
  289. # srs librtmp
  290. if [ $SRS_LIBRTMP = YES ]; then
  291. MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${LIBS_OBJS[@]}"
  292. BUILD_KEY="librtmp" LIB_NAME="lib/srs_librtmp" . auto/libs.sh
  293. fi
  294. # For utest on mac.
  295. # @see https://github.com/protocolbuffers/protobuf/issues/51#issuecomment-111044468
  296. if [[ $SRS_OSX == YES ]]; then
  297. EXTRA_DEFINES="-DGTEST_USE_OWN_TR1_TUPLE=1"
  298. fi
  299. #
  300. # utest, the unit-test cases of srs, base on gtest1.6
  301. if [ $SRS_UTEST = YES ]; then
  302. MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol" "srs_utest_kernel" "srs_utest_core"
  303. "srs_utest_config" "srs_utest_rtmp" "srs_utest_http" "srs_utest_avc" "srs_utest_reload"
  304. "srs_utest_mp4" "srs_utest_service" "srs_utest_app")
  305. ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
  306. ModuleLibFiles=(${LibSTfile} ${LibSSLfile})
  307. MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP")
  308. MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]}"
  309. LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
  310. fi
  311. #####################################################################################
  312. # generate colorful summary script
  313. . auto/summary.sh
  314. #####################################################################################
  315. # makefile
  316. echo "Generate Makefile"
  317. # backup old makefile.
  318. rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk &&
  319. mv ${SRS_WORKDIR}/${SRS_MAKEFILE} ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk
  320. # generate phony header
  321. cat << END > ${SRS_WORKDIR}/${SRS_MAKEFILE}
  322. .PHONY: default _default install help clean destroy server srs_ingest_hls librtmp utest _prepare_dir $__mphonys
  323. .PHONY: clean_srs clean_modules clean_st clean_openssl clean_ffmpeg clean_nginx clean_cherrypy
  324. .PHONY: st
  325. # install prefix.
  326. SRS_PREFIX=${SRS_PREFIX}
  327. __REAL_INSTALL=\$(DESTDIR)\$(SRS_PREFIX)
  328. default:
  329. \$(MAKE) _default
  330. END
  331. # the real entry for all platform:
  332. # the server, librtmp and utest
  333. # where the bellow will check and disable some entry by only echo.
  334. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  335. _default: server srs_ingest_hls librtmp utest __modules $__mdefaults
  336. @bash objs/_srs_build_summary.sh
  337. help:
  338. @echo "Usage: make <help>|<clean>|<destroy>|<server>|<librtmp>|<utest>|<install>|<uninstall>"
  339. @echo " help display this help menu"
  340. @echo " clean cleanup project and all depends"
  341. @echo " destroy Cleanup all files for this platform in ${SRS_OBJS_DIR}/${SRS_PLATFORM}"
  342. @echo " server build the srs(simple rtmp server) over st(state-threads)"
  343. @echo " librtmp build the client publish/play library, and samples"
  344. @echo " utest build the utest for srs"
  345. @echo " install install srs to the prefix path"
  346. @echo " uninstall uninstall srs from prefix path"
  347. @echo "To clean special module:"
  348. @echo " clean_st Clean depend st-srs in ${SRS_OBJS_DIR}/${SRS_PLATFORM}/st-srs"
  349. @echo " clean_openssl Clean depend openssl in objs"
  350. @echo " clean_ffmpeg Clean depend ffmpeg in objs"
  351. @echo "@remark all modules will auto genearted and build"
  352. @echo "For example:"
  353. @echo " make"
  354. @echo " make help"
  355. doclean:
  356. (cd ${SRS_OBJS_DIR} && rm -rf srs srs_utest $__mcleanups)
  357. (cd ${SRS_OBJS_DIR} && rm -rf src/* include lib)
  358. (mkdir -p ${SRS_OBJS_DIR}/utest && cd ${SRS_OBJS_DIR}/utest && rm -rf *.o *.a)
  359. (cd research/librtmp && make clean)
  360. (cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players)
  361. clean: clean_srs clean_modules
  362. @echo "You can clean each some components, see make help"
  363. destroy: clean_st clean_openssl clean_ffmpeg clean_nginx clean_cherrypy
  364. (cd ${SRS_OBJS_DIR} && rm -rf ${SRS_PLATFORM})
  365. clean_srs:
  366. (cd ${SRS_OBJS_DIR} && rm -rf srs srs_utest)
  367. (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf src/* include/* lib/* utest/*)
  368. clean_modules:
  369. (cd ${SRS_OBJS_DIR} && rm -rf $__mdefaults)
  370. clean_st:
  371. (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM}/st-srs && make clean)
  372. clean_openssl:
  373. (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf openssl*)
  374. clean_ffmpeg:
  375. (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf ffmpeg)
  376. clean_nginx:
  377. (cd ${SRS_OBJS_DIR} && rm -rf nginx)
  378. clean_cherrypy:
  379. (cd research/librtmp && make clean)
  380. (cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players)
  381. END
  382. # for Makefile of all modules.
  383. # depends on server, for some modules maybe use srs files.
  384. echo "__modules: server" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  385. for MMF in ${__makefiles[*]}; do
  386. echo " \$(MAKE) -f $MMF" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  387. done
  388. echo "" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  389. # if export librtmp, donot build the srs server.
  390. if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
  391. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  392. server: _prepare_dir
  393. @echo "Ingore srs(simple rtmp server) for srs-librtmp"
  394. END
  395. else
  396. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  397. server: _prepare_dir
  398. @echo "Build the srs(simple rtmp server) over ST(state-threads)"
  399. \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} srs
  400. END
  401. fi
  402. # generate all modules entry
  403. for SRS_MODULE in ${SRS_MODULES[*]}; do
  404. . $SRS_MODULE/config
  405. # if export librtmp, donot build the bravo-ingest.
  406. if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
  407. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  408. $SRS_MODULE_NAME: _prepare_dir server
  409. @echo "Ingore the $SRS_MODULE_NAME for srs-librtmp"
  410. END
  411. else
  412. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  413. $SRS_MODULE_NAME: _prepare_dir server
  414. @echo "Build the $SRS_MODULE_NAME over SRS"
  415. \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} $SRS_MODULE_NAME
  416. END
  417. fi
  418. done
  419. # disable install entry for srs-librtmp
  420. if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
  421. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  422. uninstall:
  423. @echo "Disable uninstall for srs-librtmp"
  424. install:
  425. @echo "Disable install for srs-librtmp"
  426. END
  427. else
  428. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  429. uninstall:
  430. @echo "rmdir \$(SRS_PREFIX)"
  431. @rm -rf \$(SRS_PREFIX)
  432. install:
  433. @echo "Now mkdir \$(__REAL_INSTALL)"
  434. @mkdir -p \$(__REAL_INSTALL)
  435. @echo "Now make the http root dir"
  436. @mkdir -p \$(__REAL_INSTALL)/objs/nginx/html
  437. @cp -f research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/objs/nginx/html
  438. @echo "Now copy binary files"
  439. @mkdir -p \$(__REAL_INSTALL)/objs
  440. @cp -f objs/srs \$(__REAL_INSTALL)/objs
  441. @echo "Now copy srs conf files"
  442. @mkdir -p \$(__REAL_INSTALL)/conf
  443. @cp -f conf/*.conf \$(__REAL_INSTALL)/conf
  444. @echo "Now copy init.d script files"
  445. @mkdir -p \$(__REAL_INSTALL)/etc/init.d
  446. @cp -f etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d
  447. @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs
  448. @echo "Now copy systemctl service files"
  449. @mkdir -p \$(__REAL_INSTALL)/usr/lib/systemd/system
  450. @cp -f usr/lib/systemd/system/srs.service \$(__REAL_INSTALL)/usr/lib/systemd/system/srs.service
  451. @echo ""
  452. @echo "The api installed, to link and start srs, please"
  453. @echo "For CentOS6:"
  454. @echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs &&"
  455. @echo " /etc/init.d/srs start"
  456. @echo "For CentOS7:"
  457. @echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs &&"
  458. @echo " sudo cp -f \$(SRS_PREFIX)/usr/lib/systemd/system/srs.service /usr/lib/systemd/system/srs.service && sudo systemctl daemon-reload && sudo systemctl enable srs &&"
  459. @echo " sudo systemctl start srs"
  460. @echo "@see: https://github.com/ossrs/srs/wiki/v3_CN_LinuxService"
  461. END
  462. fi
  463. # generate srs-librtmp entry
  464. if [ $SRS_LIBRTMP = YES ]; then
  465. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  466. librtmp: server
  467. @echo "Building the client publish/play library."
  468. \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} librtmp
  469. @echo "Building the srs-librtmp example."
  470. (cd research/librtmp && \$(MAKE) EXTRA_CXXFLAGS="${SrsGcov}" ${SrsLibrtmpSampleEntry})
  471. END
  472. else
  473. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  474. librtmp: server
  475. @echo "Ignore srs-librtmp for it's disabled."
  476. END
  477. fi
  478. if [ $SRS_UTEST = YES ]; then
  479. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  480. utest: server
  481. @echo "Building the utest for srs"
  482. ${SrsUtestMakeEntry}
  483. @echo "The utest is built ok."
  484. END
  485. else
  486. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  487. utest: server
  488. @echo "Ignore utest for it's disabled."
  489. END
  490. fi
  491. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  492. # the ./configure will generate it.
  493. _prepare_dir:
  494. @mkdir -p ${SRS_OBJS_DIR}
  495. END
  496. # generate makefile ok, append the tails.
  497. cat ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk >> ${SRS_WORKDIR}/${SRS_MAKEFILE} &&
  498. rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk
  499. echo 'Configure ok! '
  500. #####################################################################################
  501. # when configure success, prepare build
  502. #####################################################################################
  503. # create objs/logs for ffmpeg to write log.
  504. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  505. mkdir -p ${SRS_OBJS}/logs
  506. fi
  507. #####################################################################################
  508. # configure summary
  509. #####################################################################################
  510. # summary
  511. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  512. echo ""
  513. echo "Configure summary:"
  514. echo " ${SRS_AUTO_USER_CONFIGURE}"
  515. echo " ${SRS_AUTO_CONFIGURE}"
  516. if [ $SRS_HLS = YES ]; then
  517. echo -e "${GREEN}HLS is enabled.${BLACK}"
  518. else
  519. echo -e "${YELLOW}Warning: HLS is disabled.${BLACK}"
  520. fi
  521. if [ $SRS_STREAM_CASTER = YES ]; then
  522. echo -e "${YELLOW}Experiment: StreamCaster is enabled.${BLACK}"
  523. else
  524. echo -e "${GREEN}Note: StreamCaster is disabled.${BLACK}"
  525. fi
  526. if [ $SRS_HDS = YES ]; then
  527. echo -e "${YELLOW}Experiment: HDS is enabled.${BLACK}"
  528. else
  529. echo -e "${GREEN}Warning: HDS is disabled.${BLACK}"
  530. fi
  531. if [ $SRS_DVR = YES ]; then
  532. echo -e "${GREEN}DVR is enabled.${BLACK}"
  533. else
  534. echo -e "${YELLOW}Warning: DVR is disabled.${BLACK}"
  535. fi
  536. if [ $SRS_SSL = YES ]; then
  537. echo -e "${GREEN}RTMP complex handshake is enabled${BLACK}"
  538. else
  539. echo -e "${YELLOW}Warning: RTMP complex handshake is disabled, flash cann't play h264/aac.${BLACK}"
  540. fi
  541. if [ $SRS_TRANSCODE = YES ]; then
  542. echo -e "${GREEN}The transcoding is enabled${BLACK}"
  543. else
  544. echo -e "${YELLOW}Warning: The transcoding is disabled.${BLACK}"
  545. fi
  546. if [ $SRS_INGEST = YES ]; then
  547. echo -e "${GREEN}The ingesting is enabled.${BLACK}"
  548. else
  549. echo -e "${YELLOW}Warning: The ingesting is disabled.${BLACK}"
  550. fi
  551. if [ $SRS_HTTP_CALLBACK = YES ]; then
  552. echo -e "${GREEN}The http-callback is enabled${BLACK}"
  553. else
  554. echo -e "${YELLOW}Warning: The http-callback is disabled.${BLACK}"
  555. fi
  556. if [ $SRS_HTTP_SERVER = YES ]; then
  557. echo -e "${GREEN}Embeded HTTP server for HTTP-FLV/HLS is enabled.${BLACK}"
  558. else
  559. echo -e "${YELLOW}Warning: Embeded HTTP server is disabled, HTTP-FLV is disabled, please use nginx to delivery HLS.${BLACK}"
  560. fi
  561. if [ $SRS_HTTP_API = YES ]; then
  562. echo -e "${GREEN}The HTTP API is enabled${BLACK}"
  563. else
  564. echo -e "${YELLOW}Warning: The HTTP API is disabled.${BLACK}"
  565. fi
  566. if [ $SRS_LIBRTMP = YES ]; then
  567. echo -e "${GREEN}The client-side srs-librtmp is enabled.${BLACK}"
  568. else
  569. echo -e "${YELLOW}Note: The client-side srs-librtmp is disabled.${BLACK}"
  570. fi
  571. if [ $SRS_RESEARCH = YES ]; then
  572. echo -e "${GREEN}The research tools are enabled.${BLACK}"
  573. else
  574. echo -e "${GREEN}Note: The research tools are disabled.${BLACK}"
  575. fi
  576. if [ $SRS_UTEST = YES ]; then
  577. echo -e "${GREEN}The utests are enabled.${BLACK}"
  578. else
  579. echo -e "${YELLOW}Note: The utests are disabled.${BLACK}"
  580. fi
  581. if [ $SRS_GPERF = YES ]; then
  582. echo -e "${GREEN}The gperf(tcmalloc) is enabled.${BLACK}"
  583. else
  584. echo -e "${GREEN}Note: The gperf(tcmalloc) is disabled.${BLACK}"
  585. fi
  586. if [ $SRS_GPERF_MC = YES ]; then
  587. echo -e "${YELLOW}The gmc(gperf memory check) is enabled, performance may suffer.${BLACK}"
  588. else
  589. echo -e "${GREEN}Note: The gmc(gperf memory check) is disabled.${BLACK}"
  590. fi
  591. if [ $SRS_GPERF_MD = YES ]; then
  592. echo -e "${YELLOW}The gmd(gperf memory defense) is enabled, performance may suffer.${BLACK}"
  593. else
  594. echo -e "${GREEN}Note: The gmd(gperf memory defense) is disabled.${BLACK}"
  595. fi
  596. if [ $SRS_GPERF_MP = YES ]; then
  597. echo -e "${YELLOW}The gmp(gperf memory profile) is enabled, performance may suffer.${BLACK}"
  598. else
  599. echo -e "${GREEN}Note: The gmp(gperf memory profile) is disabled.${BLACK}"
  600. fi
  601. if [ $SRS_GPERF_CP = YES ]; then
  602. echo -e "${YELLOW}The gcp(gperf cpu profile) is enabled, performance may suffer.${BLACK}"
  603. else
  604. echo -e "${GREEN}Note: The gcp(gperf cpu profile) is disabled.${BLACK}"
  605. fi
  606. if [ $SRS_GPROF = YES ]; then
  607. echo -e "${YELLOW}The gprof(GNU profile tool) is enabled, performance may suffer.${BLACK}"
  608. else
  609. echo -e "${GREEN}Note: The gprof(GNU profile tool) is disabled.${BLACK}"
  610. fi
  611. if [ $SRS_VALGRIND = YES ]; then
  612. echo -e "${GREEN}The valgrind is enabled.${BLACK}"
  613. else
  614. echo -e "${GREEN}Note: The valgrind is disabled.${BLACK}"
  615. fi
  616. # add each modules for application
  617. for SRS_MODULE in ${SRS_MODULES[*]}; do
  618. echo -e "${GREEN}Enable module: $SRS_MODULE${BLACK}"
  619. done
  620. fi
  621. #####################################################################################
  622. # next step
  623. #####################################################################################
  624. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  625. ip=`ifconfig|grep "inet addr"| grep -v "127.0.0.1"|awk '{print $2}'|awk -F ':' 'NR==1 {print $2}'`
  626. echo ""
  627. echo "You can run 3rdparty applications:"
  628. if [ $SRS_HTTP_CALLBACK = YES ]; then
  629. echo -e "\" python ./research/api-server/server.py 8085 \" to start the api-server"
  630. fi
  631. echo ""
  632. echo "You can build SRS:"
  633. echo "\" make \" to build the srs(simple rtmp server)."
  634. echo "\" make help \" to get the usage of make"
  635. else
  636. # for srs-librtmp single file,
  637. # package the whole project to srs_librtmp.h and srs_librtmp.cpp
  638. if [ $SRS_EXPORT_LIBRTMP_SINGLE != NO ]; then
  639. echo "Packaging the whole project to srs_librtmp.h and srs_librtmp.cpp"
  640. . $SRS_EXPORT_LIBRTMP_SINGLE/auto/generate-srs-librtmp-single.sh
  641. echo -e "${GREEN}Please use the srs-librtmp files: ${BLACK}"
  642. echo -e "${GREEN} $SRS_EXPORT_LIBRTMP_PROJECT/srs_librtmp.h ${BLACK}"
  643. echo -e "${GREEN} $SRS_EXPORT_LIBRTMP_PROJECT/srs_librtmp.cpp ${BLACK}"
  644. echo -e "${GREEN} $SRS_EXPORT_LIBRTMP_PROJECT/example.c ${BLACK}"
  645. echo -e "${GREEN}To compile the example: ${BLACK}"
  646. echo -e "${GREEN} cd $SRS_EXPORT_LIBRTMP_PROJECT && $SRS_SINGLE_LIBRTMP_COMPILE ${BLACK}"
  647. # for srs-librtmp project.
  648. else
  649. echo -e "${GREEN}Please use the srs-librtmp project: ${BLACK}"
  650. echo -e "${GREEN} cd $SRS_EXPORT_LIBRTMP_PROJECT && make ${BLACK}"
  651. fi
  652. # Change to experiment.
  653. echo -e "${YELLOW}Warning: Notice srs-librtmp is deprecated and maybe removed in future.${BLACK}"
  654. fi