options.sh 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. #!/bin/bash
  2. # variables, parent script must set it:
  3. #####################################################################################
  4. #####################################################################################
  5. # parse user options, do this at first
  6. #####################################################################################
  7. #####################################################################################
  8. #####################################################################################
  9. # output variables
  10. #####################################################################################
  11. help=no
  12. ################################################################
  13. # feature options
  14. SRS_HDS=NO
  15. SRS_NGINX=NO
  16. SRS_FFMPEG_TOOL=NO
  17. SRS_LIBRTMP=NO
  18. SRS_RESEARCH=NO
  19. SRS_UTEST=NO
  20. SRS_GPERF=NO # Performance test: tcmalloc
  21. SRS_GPERF_MC=NO # Performance test: gperf memory check
  22. SRS_GPERF_MD=NO # Performance test: gperf memory defence
  23. SRS_GPERF_MP=NO # Performance test: gperf memory profile
  24. SRS_GPERF_CP=NO # Performance test: gperf cpu profile
  25. SRS_GPROF=NO # Performance test: gprof
  26. # Always enable the bellow features.
  27. SRS_STREAM_CASTER=YES
  28. SRS_INGEST=YES
  29. SRS_SSL=YES
  30. SRS_STAT=YES
  31. SRS_TRANSCODE=YES
  32. SRS_HTTP_CALLBACK=YES
  33. SRS_HTTP_SERVER=YES
  34. SRS_HTTP_API=YES
  35. SRS_HTTP_CORE=YES
  36. SRS_HLS=YES
  37. SRS_DVR=YES
  38. #
  39. ################################################################
  40. # libraries
  41. SRS_FFMPEG_STUB=NO
  42. # arguments
  43. SRS_PREFIX=/usr/local/srs
  44. SRS_JOBS=1
  45. SRS_STATIC=NO
  46. # If enabled, link shared libraries for libst.so which uses MPL license.
  47. SRS_SHARED_ST=NO
  48. # whether enable the gcov
  49. SRS_GCOV=NO
  50. # whether enable the log verbose/info/trace level.
  51. # always enable the warn/error level.
  52. SRS_LOG_VERBOSE=NO
  53. SRS_LOG_INFO=NO
  54. SRS_LOG_TRACE=NO
  55. #
  56. ################################################################
  57. # experts
  58. # donot compile ssl, use system ssl(-lssl) if required.
  59. SRS_USE_SYS_SSL=NO
  60. # enable memory watch, detect memory leak,
  61. # similar to gmc, should disable in release version for hurts performance.
  62. SRS_MEM_WATCH=NO
  63. # export the srs-librtmp to specified project, NO to disable it.
  64. SRS_EXPORT_LIBRTMP_PROJECT=NO
  65. # export the srs-librtmp to a single .h and .c, NO to disable it.
  66. SRS_EXPORT_LIBRTMP_SINGLE=NO
  67. # valgrind
  68. SRS_VALGRIND=NO
  69. #
  70. ################################################################
  71. # presets
  72. # for x86/x64 pc/servers
  73. SRS_X86_X64=NO
  74. # for osx system
  75. SRS_OSX=NO
  76. # dev, open all features for dev, no gperf/prof/arm.
  77. SRS_DEV=NO
  78. # dev, open main server feature for dev, no utest/research/librtmp
  79. SRS_FAST_DEV=NO
  80. # demo, for the demo of srs, @see: https://github.com/ossrs/srs/wiki/v1_CN_SampleDemo
  81. SRS_DEMO=NO
  82. # raspberry-pi, open hls/ssl/static
  83. SRS_PI=NO
  84. # cubieboard, donot open ffmpeg/nginx.
  85. SRS_CUBIE=NO
  86. # the most fast compile, nothing, only support vp6 RTMP.
  87. SRS_FAST=NO
  88. # only support RTMP with ssl.
  89. SRS_PURE_RTMP=NO
  90. # the most fast compile, nothing, only support vp6 RTMP.
  91. SRS_DISABLE_ALL=NO
  92. # all features is on
  93. SRS_ENABLE_ALL=NO
  94. #
  95. #####################################################################################
  96. # Toolchain crossbuild for ARM or MIPS.
  97. SRS_CROSS_BUILD=NO
  98. SRS_TOOL_CC=gcc
  99. SRS_TOOL_CXX=g++
  100. SRS_TOOL_AR=ar
  101. SRS_TOOL_LD=ld
  102. SRS_TOOL_RANDLIB=randlib
  103. SRS_EXTRA_FLAGS=
  104. # Set the object files tag name.
  105. SRS_BUILD_TAG=
  106. #####################################################################################
  107. # menu
  108. #####################################################################################
  109. function show_help() {
  110. cat << END
  111. Presets:
  112. --x86-64, --x86-x64 [default] For x86/x64 cpu, common pc and servers.
  113. --arm Enable crossbuild for ARM, should also set bellow toolchain options.
  114. --mips Enable crossbuild for MIPS
  115. Features:
  116. -h, --help Print this message and exit 0.
  117. --with-ssl Enable rtmp complex handshake, requires openssl-devel installed.
  118. --with-hds Enable hds streaming, mux RTMP to F4M/F4V files.
  119. --with-stream-caster Enable stream caster to serve other stream over other protocol.
  120. --with-stat Enable the data statistic, for http api.
  121. --with-librtmp Enable srs-librtmp, library for client.
  122. --with-research Build the research tools.
  123. --with-utest Build the utest for SRS.
  124. --without-ssl Disable rtmp complex handshake.
  125. --without-hds Disable hds, the adobe http dynamic streaming.
  126. --without-stream-caster Disable stream caster, only listen and serve RTMP/HTTP.
  127. --without-stat Disable the data statistic feature.
  128. --without-librtmp Disable srs-librtmp, library for client.
  129. --without-research Do not build the research tools.
  130. --without-utest Do not build the utest for SRS.
  131. --prefix=<path> The absolute installation path for srs. Default: $SRS_PREFIX
  132. --static Whether add '-static' to link options.
  133. --gcov Whether enable the GCOV compiler options.
  134. --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
  135. Used for make in the configure, for example, to make ffmpeg.
  136. --log-verbose Whether enable the log verbose level. default: no.
  137. --log-info Whether enable the log info level. default: no.
  138. --log-trace Whether enable the log trace level. default: yes.
  139. Performance: @see https://blog.csdn.net/win_lin/article/details/53503869
  140. --with-valgrind Support valgrind for memory check.
  141. --with-gperf Build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only).
  142. --with-gmc Build memory check for SRS with gperf tools.
  143. --with-gmd Build memory defense(corrupt memory) for SRS with gperf tools.
  144. --with-gmp Build memory profile for SRS with gperf tools.
  145. --with-gcp Build cpu profile for SRS with gperf tools.
  146. --with-gprof Build SRS with gprof(GNU profile tool).
  147. --without-valgrind Do not support valgrind for memory check.
  148. --without-gperf Do not build SRS with gperf tools(without tcmalloc and gmd/gmc/gmp/gcp).
  149. --without-gmc Do not build memory check for SRS with gperf tools.
  150. --without-gmd Do not build memory defense for SRS with gperf tools.
  151. --without-gmp Do not build memory profile for SRS with gperf tools.
  152. --without-gcp Do not build cpu profile for SRS with gperf tools.
  153. --without-gprof Do not build srs with gprof(GNU profile tool).
  154. Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuecomment-576078411
  155. --arm Enable crossbuild for ARM.
  156. --mips Enable crossbuild for MIPS.
  157. --cc=<CC> Use c compiler CC, default is gcc.
  158. --cxx=<CXX> Use c++ compiler CXX, default is g++.
  159. --ar=<AR> Use archive tool AR, default is ar.
  160. --ld=<LD> Use linker tool LD, default is ld.
  161. --randlib=<RANDLIB> Use randlib tool RANDLIB, default is randlib.
  162. --extra-flags=<EFLAGS> Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS.
  163. --build-tag=<TAG> Set the build object directory suffix.
  164. Conflicts:
  165. 1. --with-gmc vs --with-gmp:
  166. @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html
  167. 2. --with-gperf/gmc/gmp vs --with-gprof:
  168. The gperftools not compatible with gprof.
  169. 3. --arm vs --with-ffmpeg/gperf/gmc/gmp/gprof:
  170. The complex tools not available for arm.
  171. Experts:
  172. --use-sys-ssl Do not compile ssl, use system ssl(-lssl) if required.
  173. --use-shared-st Use link shared libraries for ST which uses MPL license.
  174. --export-librtmp-project=<path> Export srs-librtmp to specified project in path.
  175. --export-librtmp-single=<path> Export srs-librtmp to a single file(.h+.cpp) in path.
  176. Workflow:
  177. 1. Apply "Presets". if not specified, use default preset.
  178. 2. Apply "Features", "Performance" and others. user specified option will override the preset.
  179. 3. Check conflicts, fail if exists conflicts.
  180. 4. Generate Makefile.
  181. Remark:
  182. 1. For performance improving, read https://blog.csdn.net/win_lin/article/details/53503869
  183. END
  184. }
  185. function parse_user_option() {
  186. case "$option" in
  187. -h) help=yes ;;
  188. --help) help=yes ;;
  189. --with-ssl) SRS_SSL=YES ;;
  190. --with-hds) SRS_HDS=YES ;;
  191. --with-nginx) SRS_NGINX=YES ;;
  192. --with-ffmpeg) SRS_FFMPEG_TOOL=YES ;;
  193. --with-transcode) SRS_TRANSCODE=YES ;;
  194. --with-ingest) SRS_INGEST=YES ;;
  195. --with-stat) SRS_STAT=YES ;;
  196. --with-stream-caster) SRS_STREAM_CASTER=YES ;;
  197. --with-librtmp) SRS_LIBRTMP=YES ;;
  198. --with-research) SRS_RESEARCH=YES ;;
  199. --with-utest) SRS_UTEST=YES ;;
  200. --with-gperf) SRS_GPERF=YES ;;
  201. --with-gmc) SRS_GPERF_MC=YES ;;
  202. --with-gmd) SRS_GPERF_MD=YES ;;
  203. --with-gmp) SRS_GPERF_MP=YES ;;
  204. --with-gcp) SRS_GPERF_CP=YES ;;
  205. --with-gprof) SRS_GPROF=YES ;;
  206. --with-arm-ubuntu12) SRS_CROSS_BUILD=YES ;;
  207. --with-mips-ubuntu12) SRS_CROSS_BUILD=YES ;;
  208. --without-hds) SRS_HDS=NO ;;
  209. --without-nginx) SRS_NGINX=NO ;;
  210. --without-ffmpeg) SRS_FFMPEG_TOOL=NO ;;
  211. --without-librtmp) SRS_LIBRTMP=NO ;;
  212. --without-research) SRS_RESEARCH=NO ;;
  213. --without-utest) SRS_UTEST=NO ;;
  214. --without-gperf) SRS_GPERF=NO ;;
  215. --without-gmc) SRS_GPERF_MC=NO ;;
  216. --without-gmd) SRS_GPERF_MD=NO ;;
  217. --without-gmp) SRS_GPERF_MP=NO ;;
  218. --without-gcp) SRS_GPERF_CP=NO ;;
  219. --without-gprof) SRS_GPROF=NO ;;
  220. --without-arm-ubuntu12) SRS_CROSS_BUILD=NO ;;
  221. --without-mips-ubuntu12) SRS_CROSS_BUILD=NO ;;
  222. --jobs) SRS_JOBS=${value} ;;
  223. --prefix) SRS_PREFIX=${value} ;;
  224. --static) SRS_STATIC=YES ;;
  225. --log-verbose) SRS_LOG_VERBOSE=YES ;;
  226. --log-info) SRS_LOG_INFO=YES ;;
  227. --log-trace) SRS_LOG_TRACE=YES ;;
  228. --gcov) SRS_GCOV=YES ;;
  229. --arm) SRS_CROSS_BUILD=YES ;;
  230. --mips) SRS_CROSS_BUILD=YES ;;
  231. --cc) SRS_TOOL_CC=${value} ;;
  232. --cxx) SRS_TOOL_CXX=${value} ;;
  233. --ar) SRS_TOOL_AR=${value} ;;
  234. --ld) SRS_TOOL_LD=${value} ;;
  235. --randlib) SRS_TOOL_RANDLIB=${value} ;;
  236. --extra-flags) SRS_EXTRA_FLAGS=${value} ;;
  237. --build-tag) SRS_BUILD_TAG=${value} ;;
  238. --x86-x64) SRS_X86_X64=YES ;;
  239. --x86-64) SRS_X86_X64=YES ;;
  240. --osx) SRS_OSX=YES ;;
  241. --allow-osx) SRS_OSX=YES ;;
  242. --pi) SRS_PI=YES ;;
  243. --cubie) SRS_CUBIE=YES ;;
  244. --dev) SRS_DEV=YES ;;
  245. --fast-dev) SRS_FAST_DEV=YES ;;
  246. --demo) SRS_DEMO=YES ;;
  247. --fast) SRS_FAST=YES ;;
  248. --disable-all) SRS_DISABLE_ALL=YES ;;
  249. --pure-rtmp) SRS_PURE_RTMP=YES ;;
  250. --full) SRS_ENABLE_ALL=YES ;;
  251. --use-sys-ssl) SRS_USE_SYS_SSL=YES ;;
  252. --use-shared-st) SRS_SHARED_ST=YES ;;
  253. --memory-watch) SRS_MEM_WATCH=YES ;;
  254. --export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;;
  255. --export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;;
  256. --with-valgrind) SRS_VALGRIND=YES ;;
  257. --without-valgrind) SRS_VALGRIND=NO ;;
  258. --with-http-callback) SRS_HTTP_CALLBACK=YES ;;
  259. --with-http-api) SRS_HTTP_API=YES ;;
  260. --with-http-server) SRS_HTTP_SERVER=YES ;;
  261. --with-hls) SRS_HLS=YES ;;
  262. --with-dvr) SRS_DVR=YES ;;
  263. --without-stream-caster) echo "ignore option \"$option\"" ;;
  264. --without-ingest) echo "ignore option \"$option\"" ;;
  265. --without-ssl) echo "ignore option \"$option\"" ;;
  266. --without-stat) echo "ignore option \"$option\"" ;;
  267. --without-transcode) echo "ignore option \"$option\"" ;;
  268. --without-http-callback) echo "ignore option \"$option\"" ;;
  269. --without-http-server) echo "ignore option \"$option\"" ;;
  270. --without-http-api) echo "ignore option \"$option\"" ;;
  271. --without-hls) echo "ignore option \"$option\"" ;;
  272. --without-dvr) echo "ignore option \"$option\"" ;;
  273. *)
  274. echo "$0: error: invalid option \"$option\""
  275. exit 1
  276. ;;
  277. esac
  278. }
  279. function parse_user_option_to_value_and_option() {
  280. case "$option" in
  281. -*=*)
  282. value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'`
  283. option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/. +]*||'`
  284. ;;
  285. *) value="" ;;
  286. esac
  287. }
  288. #####################################################################################
  289. # parse preset options
  290. #####################################################################################
  291. opt=
  292. for option
  293. do
  294. opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"
  295. parse_user_option_to_value_and_option
  296. parse_user_option
  297. done
  298. if [ $help = yes ]; then
  299. show_help
  300. exit 0
  301. fi
  302. function apply_user_presets() {
  303. # always set the log level for all presets.
  304. SRS_LOG_VERBOSE=NO
  305. SRS_LOG_INFO=NO
  306. SRS_LOG_TRACE=YES
  307. # set default preset if not specifies
  308. if [[ $SRS_PURE_RTMP == NO && $SRS_FAST == NO && $SRS_DISABLE_ALL == NO && $SRS_ENABLE_ALL == NO && \
  309. $SRS_DEV == NO && $SRS_FAST_DEV == NO && $SRS_DEMO == NO && $SRS_PI == NO && $SRS_CUBIE == NO && \
  310. $SRS_X86_X64 == NO && $SRS_OSX == NO && $SRS_CROSS_BUILD == NO \
  311. ]]; then
  312. SRS_X86_X64=YES; opt="--x86-x64 $opt";
  313. fi
  314. # all disabled.
  315. if [ $SRS_DISABLE_ALL = YES ]; then
  316. SRS_HDS=NO
  317. SRS_LIBRTMP=NO
  318. SRS_RESEARCH=NO
  319. SRS_UTEST=NO
  320. SRS_STATIC=NO
  321. fi
  322. # all enabled.
  323. if [ $SRS_ENABLE_ALL = YES ]; then
  324. SRS_HDS=YES
  325. SRS_LIBRTMP=YES
  326. SRS_RESEARCH=YES
  327. SRS_UTEST=YES
  328. SRS_STATIC=NO
  329. fi
  330. # only rtmp vp6
  331. if [ $SRS_FAST = YES ]; then
  332. SRS_HDS=NO
  333. SRS_LIBRTMP=NO
  334. SRS_RESEARCH=NO
  335. SRS_UTEST=NO
  336. SRS_STATIC=NO
  337. fi
  338. # only ssl for RTMP with complex handshake.
  339. if [ $SRS_PURE_RTMP = YES ]; then
  340. SRS_HDS=NO
  341. SRS_LIBRTMP=NO
  342. SRS_RESEARCH=NO
  343. SRS_UTEST=NO
  344. SRS_STATIC=NO
  345. fi
  346. # defaults for x86/x64
  347. if [ $SRS_X86_X64 = YES ]; then
  348. SRS_HDS=YES
  349. SRS_LIBRTMP=YES
  350. SRS_RESEARCH=NO
  351. SRS_UTEST=NO
  352. SRS_STATIC=NO
  353. fi
  354. # if dev specified, open features if possible.
  355. if [ $SRS_DEV = YES ]; then
  356. SRS_HDS=YES
  357. SRS_LIBRTMP=YES
  358. SRS_RESEARCH=YES
  359. SRS_UTEST=YES
  360. SRS_STATIC=NO
  361. fi
  362. # if fast dev specified, open main server features.
  363. if [ $SRS_FAST_DEV = YES ]; then
  364. SRS_HDS=YES
  365. SRS_LIBRTMP=NO
  366. SRS_RESEARCH=NO
  367. SRS_UTEST=NO
  368. SRS_STATIC=NO
  369. fi
  370. # for srs demo
  371. if [ $SRS_DEMO = YES ]; then
  372. SRS_HDS=YES
  373. SRS_LIBRTMP=YES
  374. SRS_RESEARCH=NO
  375. SRS_UTEST=NO
  376. SRS_STATIC=NO
  377. fi
  378. # if raspberry-pi specified, open ssl/hls/static features
  379. if [ $SRS_PI = YES ]; then
  380. SRS_HDS=YES
  381. SRS_LIBRTMP=YES
  382. SRS_RESEARCH=NO
  383. SRS_UTEST=NO
  384. SRS_STATIC=NO
  385. fi
  386. # if cubieboard specified, open features except ffmpeg/nginx.
  387. if [ $SRS_CUBIE = YES ]; then
  388. SRS_HDS=YES
  389. SRS_LIBRTMP=YES
  390. SRS_RESEARCH=NO
  391. SRS_UTEST=NO
  392. SRS_STATIC=NO
  393. fi
  394. # if crossbuild, disable research and librtmp.
  395. if [[ $SRS_CROSS_BUILD == YES ]]; then
  396. SRS_LIBRTMP=NO
  397. SRS_RESEARCH=NO
  398. SRS_UTEST=NO
  399. SRS_STATIC=NO
  400. fi
  401. }
  402. apply_user_presets
  403. #####################################################################################
  404. # parse detail feature options
  405. #####################################################################################
  406. for option
  407. do
  408. parse_user_option_to_value_and_option
  409. parse_user_option
  410. done
  411. function apply_user_detail_options() {
  412. # if transcode/ingest specified, requires the ffmpeg stub classes.
  413. SRS_FFMPEG_STUB=NO
  414. if [ $SRS_TRANSCODE = YES ]; then SRS_FFMPEG_STUB=YES; fi
  415. if [ $SRS_INGEST = YES ]; then SRS_FFMPEG_STUB=YES; fi
  416. # Always enable HTTP utilies.
  417. if [ $SRS_HTTP_CORE = NO ]; then SRS_HTTP_CORE=YES; echo -e "${YELLOW}[WARN] Always enable HTTP utilies.${BLACK}"; fi
  418. if [ $SRS_STREAM_CASTER = NO ]; then SRS_STREAM_CASTER=YES; echo -e "${YELLOW}[WARN] Always enable StreamCaster.${BLACK}"; fi
  419. if [ $SRS_INGEST = NO ]; then SRS_INGEST=YES; echo -e "${YELLOW}[WARN] Always enable Ingest.${BLACK}"; fi
  420. if [ $SRS_SSL = NO ]; then SRS_SSL=YES; echo -e "${YELLOW}[WARN] Always enable SSL.${BLACK}"; fi
  421. if [ $SRS_STAT = NO ]; then SRS_STAT=YES; echo -e "${YELLOW}[WARN] Always enable Statistic.${BLACK}"; fi
  422. if [ $SRS_TRANSCODE = NO ]; then SRS_TRANSCODE=YES; echo -e "${YELLOW}[WARN] Always enable Transcode.${BLACK}"; fi
  423. if [ $SRS_HTTP_CALLBACK = NO ]; then SRS_HTTP_CALLBACK=YES; echo -e "${YELLOW}[WARN] Always enable HTTP callback.${BLACK}"; fi
  424. if [ $SRS_HTTP_SERVER = NO ]; then SRS_HTTP_SERVER=YES; echo -e "${YELLOW}[WARN] Always enable HTTP server.${BLACK}"; fi
  425. if [ $SRS_HTTP_API = NO ]; then SRS_HTTP_API=YES; echo -e "${YELLOW}[WARN] Always enable HTTP API.${BLACK}"; fi
  426. if [ $SRS_HLS = NO ]; then SRS_HLS=YES; echo -e "${YELLOW}[WARN] Always enable HLS.${BLACK}"; fi
  427. if [ $SRS_DVR = NO ]; then SRS_DVR=YES; echo -e "${YELLOW}[WARN] Always enable DVR.${BLACK}"; fi
  428. # parse the jobs for make
  429. if [[ "" -eq SRS_JOBS ]]; then
  430. export SRS_JOBS="--jobs=1"
  431. else
  432. export SRS_JOBS="--jobs=${SRS_JOBS}"
  433. fi
  434. # if specified export single file, export project first.
  435. if [ $SRS_EXPORT_LIBRTMP_SINGLE != NO ]; then
  436. SRS_EXPORT_LIBRTMP_PROJECT=$SRS_EXPORT_LIBRTMP_SINGLE
  437. fi
  438. # disable almost all features for export srs-librtmp.
  439. if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
  440. SRS_HDS=NO
  441. SRS_SSL=NO
  442. SRS_TRANSCODE=NO
  443. SRS_HTTP_CALLBACK=NO
  444. SRS_INGEST=NO
  445. SRS_STAT=NO
  446. SRS_STREAM_CASTER=NO
  447. SRS_LIBRTMP=YES
  448. SRS_RESEARCH=YES
  449. SRS_UTEST=NO
  450. SRS_GPERF=NO
  451. SRS_GPERF_MC=NO
  452. SRS_GPERF_MD=NO
  453. SRS_GPERF_MP=NO
  454. SRS_GPERF_CP=NO
  455. SRS_GPROF=NO
  456. SRS_STATIC=NO
  457. fi
  458. }
  459. apply_user_detail_options
  460. function regenerate_options() {
  461. # save all config options to macro to write to auto headers file
  462. SRS_AUTO_USER_CONFIGURE="$opt"
  463. # regenerate the options for default values.
  464. SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}"
  465. if [ $SRS_HLS = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-hls"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-hls"; fi
  466. if [ $SRS_HDS = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-hds"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-hds"; fi
  467. if [ $SRS_DVR = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-dvr"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-dvr"; fi
  468. if [ $SRS_SSL = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-ssl"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-ssl"; fi
  469. if [ $SRS_TRANSCODE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-transcode"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-transcode"; fi
  470. if [ $SRS_INGEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-ingest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-ingest"; fi
  471. if [ $SRS_STAT = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-stat"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-stat"; fi
  472. if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-http-callback"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-http-callback"; fi
  473. if [ $SRS_HTTP_SERVER = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-http-server"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-http-server"; fi
  474. if [ $SRS_STREAM_CASTER = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-stream-caster"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-stream-caster"; fi
  475. if [ $SRS_HTTP_API = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-http-api"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-http-api"; fi
  476. if [ $SRS_LIBRTMP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-librtmp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-librtmp"; fi
  477. if [ $SRS_RESEARCH = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-research"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-research"; fi
  478. if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-utest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-utest"; fi
  479. if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi
  480. if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi
  481. if [ $SRS_GPERF_MD = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmd"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmd"; fi
  482. if [ $SRS_GPERF_MP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmp"; fi
  483. if [ $SRS_GPERF_CP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gcp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gcp"; fi
  484. if [ $SRS_GPROF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gprof"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gprof"; fi
  485. if [ $SRS_STATIC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --static"; fi
  486. if [ $SRS_SHARED_ST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --use-shared-st"; fi
  487. if [ $SRS_LOG_VERBOSE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-verbose"; fi
  488. if [ $SRS_LOG_INFO = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-info"; fi
  489. if [ $SRS_LOG_TRACE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace"; fi
  490. if [ $SRS_GCOV = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcov"; fi
  491. if [[ $SRS_EXTRA_FLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_FLAGS\\\""; fi
  492. if [[ $SRS_BUILD_TAG != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --build-tag=\\\"$SRS_BUILD_TAG\\\""; fi
  493. if [[ $SRS_TOOL_CC != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cc=$SRS_TOOL_CC"; fi
  494. if [[ $SRS_TOOL_CXX != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx=$SRS_TOOL_CXX"; fi
  495. if [[ $SRS_TOOL_AR != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ar=$SRS_TOOL_AR"; fi
  496. if [[ $SRS_TOOL_LD != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ld=$SRS_TOOL_LD"; fi
  497. if [[ $SRS_TOOL_RANDLIB != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --randlib=$SRS_TOOL_RANDLIB"; fi
  498. echo "User config: $SRS_AUTO_USER_CONFIGURE"
  499. echo "Detail config: ${SRS_AUTO_CONFIGURE}"
  500. }
  501. regenerate_options
  502. #####################################################################################
  503. # check user options
  504. #####################################################################################
  505. function check_option_conflicts() {
  506. if [[ $SRS_TOOL_CC == '' || $SRS_TOOL_CXX == '' || $SRS_TOOL_AR == '' || $SRS_TOOL_LD == '' || $SRS_TOOL_RANDLIB == '' ]]; then
  507. echo "No crossbuild tools, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR, ld: $SRS_TOOL_LD, randlib: $SRS_TOOL_RANDLIB"; exit -1
  508. fi
  509. if [[ $SRS_CROSS_BUILD == YES && ($SRS_TOOL_CC == 'gcc' || $SRS_TOOL_CXX == 'g++' || $SRS_TOOL_AR == 'ar') ]]; then
  510. echo "For crossbuild, must not use default toolchain, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR"; exit -1
  511. fi
  512. if [[ $SRS_NGINX == YES ]]; then
  513. echo "Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker"; exit -1;
  514. fi
  515. # TODO: FIXME: check more os.
  516. __check_ok=YES
  517. # check conflict
  518. if [ $SRS_GPERF = NO ]; then
  519. if [ $SRS_GPERF_MC = YES ]; then echo "gperf-mc depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  520. if [ $SRS_GPERF_MD = YES ]; then echo "gperf-md depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  521. if [ $SRS_GPERF_MP = YES ]; then echo "gperf-mp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  522. if [ $SRS_GPERF_CP = YES ]; then echo "gperf-cp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  523. fi
  524. if [[ $SRS_GPERF_MC = YES && $SRS_GPERF_MP = YES ]]; then
  525. echo "gperf-mc not compatible with gperf-mp, see: ./configure --help";
  526. echo "@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html";
  527. echo "Note that since the heap-checker uses the heap-profiling framework internally, it is not possible to run both the heap-checker and heap profiler at the same time";
  528. __check_ok=NO
  529. fi
  530. # generate the group option: SRS_GPERF
  531. __gperf_slow=NO
  532. if [ $SRS_GPERF_MC = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  533. if [ $SRS_GPERF_MD = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  534. if [ $SRS_GPERF_MP = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  535. if [ $SRS_GPERF_CP = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  536. if [ $__gperf_slow = YES ]; then if [ $SRS_GPROF = YES ]; then
  537. echo "gmc/gmp/gcp not compatible with gprof, see: ./configure --help"; __check_ok=NO;
  538. fi fi
  539. # check variable neccessary
  540. if [ $SRS_HDS = RESERVED ]; then echo "you must specifies the hds, see: ./configure --help"; __check_ok=NO; fi
  541. if [ $SRS_SSL = RESERVED ]; then echo "you must specifies the ssl, see: ./configure --help"; __check_ok=NO; fi
  542. if [ $SRS_STREAM_CASTER = RESERVED ]; then echo "you must specifies the stream-caster, see: ./configure --help"; __check_ok=NO; fi
  543. if [ $SRS_LIBRTMP = RESERVED ]; then echo "you must specifies the librtmp, see: ./configure --help"; __check_ok=NO; fi
  544. if [ $SRS_RESEARCH = RESERVED ]; then echo "you must specifies the research, see: ./configure --help"; __check_ok=NO; fi
  545. if [ $SRS_UTEST = RESERVED ]; then echo "you must specifies the utest, see: ./configure --help"; __check_ok=NO; fi
  546. if [ $SRS_GPERF = RESERVED ]; then echo "you must specifies the gperf, see: ./configure --help"; __check_ok=NO; fi
  547. if [ $SRS_GPERF_MC = RESERVED ]; then echo "you must specifies the gperf-mc, see: ./configure --help"; __check_ok=NO; fi
  548. if [ $SRS_GPERF_MD = RESERVED ]; then echo "you must specifies the gperf-md, see: ./configure --help"; __check_ok=NO; fi
  549. if [ $SRS_GPERF_MP = RESERVED ]; then echo "you must specifies the gperf-mp, see: ./configure --help"; __check_ok=NO; fi
  550. if [ $SRS_GPERF_CP = RESERVED ]; then echo "you must specifies the gperf-cp, see: ./configure --help"; __check_ok=NO; fi
  551. if [ $SRS_GPROF = RESERVED ]; then echo "you must specifies the gprof, see: ./configure --help"; __check_ok=NO; fi
  552. if [[ -z $SRS_PREFIX ]]; then echo "you must specifies the prefix, see: ./configure --prefix"; __check_ok=NO; fi
  553. if [ $__check_ok = NO ]; then
  554. exit 1;
  555. fi
  556. }
  557. check_option_conflicts