configure 26 KB

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