options.sh 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. #!/bin/bash
  2. ################################################################
  3. help=no
  4. # feature options
  5. SRS_HDS=NO
  6. SRS_SRT=YES
  7. SRS_RTC=YES
  8. SRS_H265=YES
  9. SRS_GB28181=NO
  10. SRS_CXX11=YES
  11. SRS_CXX14=NO
  12. SRS_BACKTRACE=YES
  13. SRS_NGINX=NO
  14. SRS_UTEST=NO
  15. # Always enable the bellow features.
  16. SRS_STREAM_CASTER=YES
  17. SRS_INGEST=YES
  18. SRS_SSL=YES
  19. SRS_SSL_1_0=NO
  20. SRS_SSL_LOCAL=NO
  21. SRS_HTTPS=YES
  22. SRS_STAT=YES
  23. SRS_TRANSCODE=YES
  24. SRS_HTTP_CALLBACK=YES
  25. SRS_HTTP_SERVER=YES
  26. SRS_HTTP_API=YES
  27. SRS_HTTP_CORE=YES
  28. SRS_HLS=YES
  29. SRS_DVR=YES
  30. #
  31. ################################################################
  32. # FFmpeg stub is the stub code in SRS for ingester or encoder.
  33. SRS_FFMPEG_STUB=NO
  34. # FFmpeg tool is the binary for FFmpeg tool, to exec ingest or transcode.
  35. SRS_FFMPEG_TOOL=NO
  36. # FFmpeg fit is the source code for RTC, to transcode audio or video in SRS.
  37. SRS_FFMPEG_FIT=RESERVED
  38. # Whether use FFmpeg native opus codec for RTC. If not, use libopus instead.
  39. # Should disable it by default, because the cost of it is very high, see https://github.com/ossrs/srs/pull/3868
  40. SRS_FFMPEG_OPUS=NO
  41. # arguments
  42. SRS_PREFIX=/usr/local/srs
  43. SRS_DEFAULT_CONFIG=conf/srs.conf
  44. SRS_JOBS=1
  45. # If enabled, force to use SRS_JOBS for make on linux, however you're able to overwrite by -jN on macOS.
  46. SRS_FORCE_MAKE_JOBS=YES
  47. SRS_STATIC=NO
  48. # If enabled, link shared libraries for libst.so which uses MPL license.
  49. # See https://ossrs.net/lts/zh-cn/license#state-threads
  50. SRS_SHARED_ST=NO
  51. # If enabled, link shared libraries for libsrt.so which uses MPL license.
  52. # See https://ossrs.net/lts/zh-cn/license#srt
  53. SRS_SHARED_SRT=RESERVED
  54. # If enabled, link shared libraries for FFmpeg which is LGPL license.
  55. # See https://ossrs.net/lts/zh-cn/license#ffmpeg
  56. SRS_SHARED_FFMPEG=RESERVED
  57. # If enabled, link shared libraries for SRTP which is BSD license.
  58. # See https://ossrs.net/lts/zh-cn/license#srtp
  59. SRS_SHARED_SRTP=RESERVED
  60. # whether enable the gcov
  61. SRS_GCOV=NO
  62. # Whether enable cloud logging and APM(Application Performance Monitor).
  63. SRS_APM=NO
  64. # whether enable the log verbose/info/trace level.
  65. # always enable the warn/error level.
  66. SRS_LOG_VERBOSE=NO
  67. SRS_LOG_INFO=NO
  68. SRS_LOG_TRACE=YES
  69. # Whether use new level definition, see https://stackoverflow.com/a/2031209/17679565
  70. SRS_LOG_LEVEL_V2=YES
  71. #
  72. ################################################################
  73. # Experts options.
  74. SRS_USE_SYS_SSL=NO # Use system ssl(-lssl) if required.
  75. SRS_USE_SYS_FFMPEG=NO # Use system ffmpeg if required.
  76. SRS_USE_SYS_SRT=NO # Use system srt(-lsrt) if required.
  77. SRS_USE_SYS_SRTP=NO # Use system srtp(-lsrtp) if required.
  78. SRS_VALGRIND=NO
  79. SRS_SANITIZER=RESERVED
  80. SRS_SANITIZER_STATIC=NO
  81. SRS_SANITIZER_LOG=NO
  82. SRS_BUILD_TAG= # Set the object files tag name.
  83. SRS_CLEAN=YES # Whether do "make clean" when configure.
  84. SRS_SIMULATOR=NO # Whether enable RTC simulate API.
  85. SRS_GENERATE_OBJS=NO # Whether generate objs and quit.
  86. SRS_SINGLE_THREAD=YES # Whether force single thread mode.
  87. SRS_SIGNAL_API=NO # Use http API to simulate sending signal to SRS, for debugging.
  88. #
  89. ################################################################
  90. # Performance options.
  91. SRS_GPERF=NO # Performance test: tcmalloc
  92. SRS_GPERF_MC=NO # Performance test: gperf memory check
  93. SRS_GPERF_MD=NO # Performance test: gperf memory defence
  94. SRS_GPERF_MP=NO # Performance test: gperf memory profile
  95. SRS_GPERF_CP=NO # Performance test: gperf cpu profile
  96. SRS_GPROF=NO # Performance test: gprof
  97. #
  98. ################################################################
  99. # Preset options
  100. SRS_GENERIC_LINUX= # Try to run as generic linux, not CentOS or Ubuntu.
  101. SRS_OSX= #For OSX/macOS/Darwin PC.
  102. SRS_CYGWIN64= # For Cygwin64 for Windows PC or servers.
  103. SRS_CROSS_BUILD= #For cross build, for example, on Ubuntu.
  104. # For cross build, the cpu, for example(FFmpeg), --cpu=24kc
  105. SRS_CROSS_BUILD_CPU=
  106. # For cross build, the arch, for example(FFmpeg), --arch=aarch64
  107. SRS_CROSS_BUILD_ARCH=
  108. # For cross build, the host, for example(libsrtp), --host=aarch64-linux-gnu
  109. SRS_CROSS_BUILD_HOST=
  110. # For cross build, the cross prefix, for example(FFmpeg), --cross-prefix=aarch64-linux-gnu-
  111. SRS_CROSS_BUILD_PREFIX=
  112. # For cache build
  113. SRS_BUILD_CACHE=YES
  114. # Only support MacOS 10.12+ for clock_gettime, see https://github.com/ossrs/srs/issues/3978
  115. SRS_OSX_HAS_CLOCK_GETTIME=YES
  116. #
  117. #####################################################################################
  118. # Toolchain for cross-build on Ubuntu for ARM or MIPS.
  119. SRS_TOOL_CC=gcc
  120. SRS_TOOL_CXX=g++
  121. SRS_TOOL_AR=ar
  122. SRS_TOOL_LD=ld
  123. SRS_TOOL_RANDLIB=randlib
  124. SRS_EXTRA_FLAGS=
  125. SRS_EXTRA_LDFLAGS=
  126. #
  127. #####################################################################################
  128. # Performance optimize.
  129. SRS_NASM=YES
  130. SRS_SRTP_ASM=YES
  131. SRS_DEBUG=NO
  132. SRS_DEBUG_STATS=NO
  133. #####################################################################################
  134. function apply_system_options() {
  135. OS_IS_OSX=$(uname -s |grep -q Darwin && echo YES)
  136. OS_IS_LINUX=$(uname -s |grep -q Linux && echo YES)
  137. OS_IS_CYGWIN=$(uname -s |grep -q CYGWIN && echo YES)
  138. OS_IS_CENTOS=$(yum --version >/dev/null 2>&1 && echo YES)
  139. # For Debian, we think it's ubuntu also.
  140. # For example, the wheezy/sid which is debian armv7 linux, can not identified by uname -v.
  141. OS_IS_UBUNTU=$(apt-get --version >/dev/null 2>&1 && echo YES)
  142. OS_IS_LOONGSON=$(uname -r |grep -q loongson && echo YES)
  143. # Use gcc to detect the CPU arch.
  144. gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then echo "Please install gcc"; exit 1; fi
  145. OS_IS_LOONGARCH64=$(gcc -dM -E - </dev/null |grep '#define __loongarch64 1' -q && echo YES)
  146. OS_IS_MIPS64=$(gcc -dM -E - </dev/null |grep '#define __mips64 1' -q && echo YES)
  147. OS_IS_X86_64=$(gcc -dM -E - </dev/null |grep -q '#define __x86_64 1' && echo YES)
  148. OS_IS_RISCV=$(gcc -dM -E - </dev/null |grep -q '#define __riscv 1' && echo YES)
  149. # Set the os option automatically.
  150. if [[ $OS_IS_OSX == YES ]]; then
  151. SRS_OSX=YES;
  152. fi
  153. if [[ $OS_IS_CYGWIN == YES ]]; then SRS_CYGWIN64=YES; fi
  154. if [[ $OS_IS_OSX == YES ]]; then SRS_JOBS=$(sysctl -n hw.ncpu 2>/dev/null || echo 1); fi
  155. if [[ $OS_IS_LINUX == YES || $OS_IS_CYGWIN == YES ]]; then
  156. SRS_JOBS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || echo 1)
  157. fi
  158. if [[ $OS_IS_UBUNTU != YES && $OS_IS_CENTOS != YES && $OS_IS_OSX != YES && $SRS_CYGWIN64 != YES ]]; then
  159. echo "Warning: Your OS is not Ubuntu(no apt-get), CentOS(no yum), maxOS(not Darwin), Windows(not CYGWIN)"
  160. fi
  161. }
  162. apply_system_options
  163. #####################################################################################
  164. # Show help menu.
  165. #####################################################################################
  166. function show_help() {
  167. cat << END
  168. Configure to generate Makefile.
  169. -h, --help Print this message and exit 0.
  170. Features:
  171. --https=on|off Whether enable HTTPS client and server. Default: $(value2switch $SRS_HTTPS)
  172. --utest=on|off Whether build the utest. Default: $(value2switch $SRS_UTEST)
  173. --srt=on|off Whether build the SRT. Default: $(value2switch $SRS_SRT)
  174. --rtc=on|off Whether build the WebRTC. Default: $(value2switch $SRS_RTC)
  175. --gb28181=on|off Whether build the GB28181. Default: $(value2switch $SRS_GB28181)
  176. --cxx11=on|off Whether enable the C++11. Default: $(value2switch $SRS_CXX11)
  177. --cxx14=on|off Whether enable the C++14. Default: $(value2switch $SRS_CXX14)
  178. --ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
  179. --ffmpeg-opus=on|off Whether enable the FFmpeg native opus codec. Default: $(value2switch $SRS_FFMPEG_OPUS)
  180. --apm=on|off Whether enable cloud logging and APM(Application Performance Monitor). Default: $(value2switch $SRS_APM)
  181. --h265=on|off Whether build the HEVC(H.265) support. Default: $(value2switch $SRS_H265)
  182. --prefix=<path> The absolute installation path. Default: $SRS_PREFIX
  183. --jobs[=N] Allow N jobs at once; infinite jobs with no arg. Default: $SRS_JOBS
  184. --config=<path> The default config file for SRS. Default: $SRS_DEFAULT_CONFIG
  185. Performance: @see https://ossrs.net/lts/zh-cn/docs/v5/doc/performance
  186. --valgrind=on|off Whether build valgrind for memory check. Default: $(value2switch $SRS_VALGRIND)
  187. --gperf=on|off Whether build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only). Default: $(value2switch $SRS_GPERF)
  188. --gmc=on|off Whether build memory check with gperf tools. Default: $(value2switch $SRS_GPERF_MC)
  189. --gmd=on|off Whether build memory defense(corrupt memory) with gperf tools. Default: $(value2switch $SRS_GPERF_MD)
  190. --gmp=on|off Whether build memory profile with gperf tools. Default: $(value2switch $SRS_GPERF_MP)
  191. --gcp=on|off Whether build cpu profile with gperf tools. Default: $(value2switch $SRS_GPERF_CP)
  192. --gprof=on|off Whether build SRS with gprof(GNU profile tool). Default: $(value2switch $SRS_GPROF)
  193. --sanitizer=on|off Whether build SRS with address sanitizer(asan). Default: $(value2switch $SRS_SANITIZER)
  194. --sanitizer-static=on|off Whether build SRS with static libasan(asan). Default: $(value2switch $SRS_SANITIZER_STATIC)
  195. --sanitizer-log=on|off Whether hijack the log for libasan(asan). Default: $(value2switch $SRS_SANITIZER_LOG)
  196. --nasm=on|off Whether build FFMPEG for RTC with nasm. Default: $(value2switch $SRS_NASM)
  197. --srtp-nasm=on|off Whether build SRTP with ASM(openssl-asm), requires RTC and openssl-1.0.*. Default: $(value2switch $SRS_SRTP_ASM)
  198. Toolchain options:
  199. --static=on|off Whether add '-static' to link options. Default: $(value2switch $SRS_STATIC)
  200. --cc=<CC> Toolchain: Use c compiler CC. Default: $SRS_TOOL_CC
  201. --cxx=<CXX> Toolchain: Use c++ compiler CXX. Default: $SRS_TOOL_CXX
  202. --ar=<AR> Toolchain: Use archive tool AR. Default: $SRS_TOOL_CXX
  203. --ld=<LD> Toolchain: Use linker tool LD. Default: $SRS_TOOL_CXX
  204. --randlib=<RANDLIB> Toolchain: Use randlib tool RANDLIB. Default: $SRS_TOOL_CXX
  205. --extra-flags=<EFLAGS> Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS.
  206. --extra-ldflags=<ELDFLAGS> Set ELDFLAGS as LDFLAGS.
  207. Cross Build options: @see https://ossrs.net/lts/zh-cn/docs/v4/doc/arm#ubuntu-cross-build-srs
  208. --cross=on|off Enable cross-build, please set bellow Toolchain also. Default: $(value2switch $SRS_CROSS_BUILD)
  209. --cpu=<CPU> Toolchain: Select the minimum required CPU for cross-build. For example: --cpu=24kc
  210. --arch=<ARCH> Toolchain: Select architecture for cross-build. For example: --arch=aarch64
  211. --host=<BUILD> Toolchain: Cross-compile to build programs to run on HOST. For example: --host=aarch64-linux-gnu
  212. --cross-prefix=<PREFIX> Toolchain: Use PREFIX for compilation tools. For example: --cross-prefix=aarch64-linux-gnu-
  213. Experts:
  214. --sys-ssl=on|off Do not compile ssl, use system ssl(-lssl) if required. Default: $(value2switch $SRS_USE_SYS_SSL)
  215. --ssl-1-0=on|off Whether use openssl-1.0.*. Default: $(value2switch $SRS_SSL_1_0)
  216. --ssl-local=on|off Whether use local openssl, not system even exists. Default: $(value2switch $SRS_SSL_LOCAL)
  217. --shared-st=on|off Use shared libraries for ST which is MPL license. Default: $(value2switch $SRS_SHARED_ST)
  218. --shared-srt=on|off Use shared libraries for SRT which is MPL license. Default: $(value2switch $SRS_SHARED_SRT)
  219. --sys-srt=on|off Do not compile srt, use system srt(-lsrt) if required. Default: $(value2switch $SRS_USE_SYS_SRT)
  220. --shared-ffmpeg=on|off Use shared libraries for FFmpeg which is LGPL license. Default: $(value2switch $SRS_SHARED_FFMPEG)
  221. --sys-ffmpeg=on|off Do not compile ffmpeg, use system ffmpeg if required. Default: $(value2switch $SRS_USE_SYS_FFMPEG)
  222. --sys-srtp=on|off Do not compile srtp, use system srtp(-lsrtp) if required. Default: $(value2switch $SRS_USE_SYS_SRTP)
  223. --shared-srtp=on|off Use shared libraries for SRTP which is BSD license. Default: $(value2switch $SRS_SHARED_SRTP)
  224. --clean=on|off Whether do 'make clean' when configure. Default: $(value2switch $SRS_CLEAN)
  225. --simulator=on|off RTC: Whether enable network simulator. Default: $(value2switch $SRS_SIMULATOR)
  226. --generate-objs=on|off RTC: Whether generate objs and quit. Default: $(value2switch $SRS_GENERATE_OBJS)
  227. --single-thread=on|off Whether force single thread mode. Default: $(value2switch $SRS_SINGLE_THREAD)
  228. --signal-api=on|off Whether support sending signal by HTTP API. Default: $(value2switch $SRS_SIGNAL_API)
  229. --build-tag=<TAG> Set the build object directory suffix.
  230. --debug=on|off Whether enable the debug code, may hurt performance. Default: $(value2switch $SRS_DEBUG)
  231. --debug-stats=on|off Whether enable the debug stats, may hurt performance. Default: $(value2switch $SRS_DEBUG_STATS)
  232. --gcov=on|off Whether enable the GCOV for coverage. Default: $(value2switch $SRS_GCOV)
  233. --log-verbose=on|off Whether enable the log verbose level. Default: $(value2switch $SRS_LOG_VERBOSE)
  234. --log-info=on|off Whether enable the log info level. Default: $(value2switch $SRS_LOG_INFO)
  235. --log-trace=on|off Whether enable the log trace level. Default: $(value2switch $SRS_LOG_TRACE)
  236. --log-level_v2=on|off Whether use v2.0 log level definition, see log4j specs. Default: $(value2switch $SRS_LOG_LEVEL_V2)
  237. --backtrace=on|off Whether show backtrace when crashing. Default: $(value2switch $SRS_BACKTRACE)
  238. --generic-linux=on|off Whether run as generic linux, if not CentOS or Ubuntu. Default: $(value2switch $SRS_GENERIC_LINUX)
  239. Deprecated:
  240. --cross-build Enable cross-build, please set bellow Toolchain also. Default: $(value2switch $SRS_CROSS_BUILD)
  241. --hds=on|off Whether build the hds streaming, mux RTMP to F4M/F4V files. Default: $(value2switch $SRS_HDS)
  242. --osx Enable build for OSX/Darwin AppleOS. Deprecated for automatically detecting the OS.
  243. --x86-64 Enable build for __x86_64 systems. Deprecated for automatically detecting the OS.
  244. --x86-x64 Enable build for __x86_64 systems. Deprecated for automatically detecting the OS.
  245. --cygwin64 Use cygwin64 to build for Windows. Deprecated for automatically detecting the OS.
  246. --nginx Build nginx tool. Deprecated for not depends on it.
  247. --ffmpeg Build FFmpeg tool. Deprecated for not build it, user should do it.
  248. For example:
  249. ./configure
  250. END
  251. }
  252. #####################################################################################
  253. # Parse user options
  254. #####################################################################################
  255. function parse_user_option() {
  256. # Ignore the options.
  257. if [[ $option == '--demo' || $option == '--dev' || $option == '--fast-dev' || $option == '--pi'
  258. || $option == '--cubie' || $option == '--fast' || $option == '--pure-rtmp' || $option == '--disable-all'
  259. || $option == '--full' || $option == '--with-http-callback' || $option == '--without-http-callback'
  260. || $option == '--http-callback' || $option == '--with-http-api' || $option == '--without-http-api'
  261. || $option == '--http-api' || $option == '--with-http-server' || $option == '--without-http-server'
  262. || $option == '--http-server' || $option == '--with-hls' || $option == '--without-hls'
  263. || $option == '--hls' || $option == '--with-dvr' || $option == '--without-dvr'
  264. || $option == '--dvr' || $option == '--without-transcode' || $option == '--without-ingest'
  265. || $option == '--without-stat' || $option == '--without-stream-caster' || $option == '--without-ssl'
  266. || $option == '--without-librtmp' || ($option == '--librtmp' && $(switch2value $value) == NO)
  267. || $option == '--without-research' || ($option == '--research' && $(switch2value $value) == NO)
  268. ]]; then
  269. echo "Ignore option $option $value"; return 0;
  270. fi
  271. # if specified export single file, export project first.
  272. if [[ $option == '--export-librtmp-single' || $option == '--export-librtmp-project' || $option == '--with-librtmp' || $option == '--librtmp' ]]; then
  273. echo "Error: The $option is not supported yet, please read https://github.com/ossrs/srs-librtmp/issues/32"; exit 1
  274. fi
  275. if [[ $option == '--with-research' || $option == '--research' ]]; then
  276. echo "Error: The $option is not supported yet"; exit 1
  277. fi
  278. if [[ $option == '--arm' || $option == '--mips' || $option == '--with-arm-ubuntu12' || $option == '--with-mips-ubuntu12' ]]; then
  279. echo "Error: Removed misleading option $option, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/arm#ubuntu-cross-build-srs"
  280. exit -1
  281. fi
  282. # Parse options to variables.
  283. case "$option" in
  284. -h) help=YES ;;
  285. --help) help=YES ;;
  286. --jobs) SRS_JOBS=${value} ;;
  287. --force-make-jobs) SRS_FORCE_MAKE_JOBS=${value} ;;
  288. --prefix) SRS_PREFIX=${value} ;;
  289. --config) SRS_DEFAULT_CONFIG=${value} ;;
  290. --static) SRS_STATIC=$(switch2value $value) ;;
  291. --cpu) SRS_CROSS_BUILD_CPU=${value} ;;
  292. --arch) SRS_CROSS_BUILD_ARCH=${value} ;;
  293. --host) SRS_CROSS_BUILD_HOST=${value} ;;
  294. --cross-prefix) SRS_CROSS_BUILD_PREFIX=${value} ;;
  295. --cc) SRS_TOOL_CC=${value} ;;
  296. --cxx) SRS_TOOL_CXX=${value} ;;
  297. --ar) SRS_TOOL_AR=${value} ;;
  298. --ld) SRS_TOOL_LD=${value} ;;
  299. --randlib) SRS_TOOL_RANDLIB=${value} ;;
  300. --extra-flags) SRS_EXTRA_FLAGS=${value} ;;
  301. --extra-ldflags) SRS_EXTRA_LDFLAGS=${value} ;;
  302. --build-tag) SRS_BUILD_TAG=${value} ;;
  303. --srtp-nasm) SRS_SRTP_ASM=$(switch2value $value) ;;
  304. --nasm) SRS_NASM=$(switch2value $value) ;;
  305. --ssl) SRS_SSL=$(switch2value $value) ;;
  306. --https) SRS_HTTPS=$(switch2value $value) ;;
  307. --ssl-1-0) SRS_SSL_1_0=$(switch2value $value) ;;
  308. --ssl-local) SRS_SSL_LOCAL=$(switch2value $value) ;;
  309. --hds) SRS_HDS=$(switch2value $value) ;;
  310. --transcode) SRS_TRANSCODE=$(switch2value $value) ;;
  311. --ingest) SRS_INGEST=$(switch2value $value) ;;
  312. --stat) SRS_STAT=$(switch2value $value) ;;
  313. --stream-caster) SRS_STREAM_CASTER=$(switch2value $value) ;;
  314. --stream-converter) SRS_STREAM_CASTER=$(switch2value $value) ;;
  315. --utest) SRS_UTEST=$(switch2value $value) ;;
  316. --gcov) SRS_GCOV=$(switch2value $value) ;;
  317. --apm) SRS_APM=$(switch2value $value) ;;
  318. --srt) SRS_SRT=$(switch2value $value) ;;
  319. --rtc) SRS_RTC=$(switch2value $value) ;;
  320. --simulator) SRS_SIMULATOR=$(switch2value $value) ;;
  321. --generate-objs) SRS_GENERATE_OBJS=$(switch2value $value) ;;
  322. --single-thread) SRS_SINGLE_THREAD=$(switch2value $value) ;;
  323. --signal-api) SRS_SIGNAL_API=$(switch2value $value) ;;
  324. --ffmpeg-fit) SRS_FFMPEG_FIT=$(switch2value $value) ;;
  325. --ffmpeg-opus) SRS_FFMPEG_OPUS=$(switch2value $value) ;;
  326. --h265) SRS_H265=$(switch2value $value) ;;
  327. --gb28181) SRS_GB28181=$(switch2value $value) ;;
  328. --cxx11) SRS_CXX11=$(switch2value $value) ;;
  329. --cxx14) SRS_CXX14=$(switch2value $value) ;;
  330. --backtrace) SRS_BACKTRACE=$(switch2value $value) ;;
  331. --clean) SRS_CLEAN=$(switch2value $value) ;;
  332. --gperf) SRS_GPERF=$(switch2value $value) ;;
  333. --gmc) SRS_GPERF_MC=$(switch2value $value) ;;
  334. --gmd) SRS_GPERF_MD=$(switch2value $value) ;;
  335. --gmp) SRS_GPERF_MP=$(switch2value $value) ;;
  336. --gcp) SRS_GPERF_CP=$(switch2value $value) ;;
  337. --gprof) SRS_GPROF=$(switch2value $value) ;;
  338. --sanitizer) SRS_SANITIZER=$(switch2value $value) ;;
  339. --sanitizer-static) SRS_SANITIZER_STATIC=$(switch2value $value) ;;
  340. --sanitizer-log) SRS_SANITIZER_LOG=$(switch2value $value) ;;
  341. --use-sys-ssl) SRS_USE_SYS_SSL=YES ;;
  342. --sys-ssl) SRS_USE_SYS_SSL=$(switch2value $value) ;;
  343. --use-shared-st) SRS_SHARED_ST=YES ;;
  344. --use-shared-srt) SRS_SHARED_SRT=YES ;;
  345. --shared-st) SRS_SHARED_ST=$(switch2value $value) ;;
  346. --shared-srt) SRS_SHARED_SRT=$(switch2value $value) ;;
  347. --use-sys-srt) SRS_USE_SYS_SRT=YES ;;
  348. --sys-srt) SRS_USE_SYS_SRT=$(switch2value $value) ;;
  349. --shared-ffmpeg) SRS_SHARED_FFMPEG=$(switch2value $value) ;;
  350. --use-sys-ffmpeg) SRS_USE_SYS_FFMPEG=YES ;;
  351. --sys-ffmpeg) SRS_USE_SYS_FFMPEG=$(switch2value $value) ;;
  352. --shared-srtp) SRS_SHARED_SRTP=$(switch2value $value) ;;
  353. --use-sys-srtp) SRS_USE_SYS_SRTP=YES ;;
  354. --sys-srtp) SRS_USE_SYS_SRTP=$(switch2value $value) ;;
  355. --valgrind) SRS_VALGRIND=$(switch2value $value) ;;
  356. --log-verbose) SRS_LOG_VERBOSE=$(switch2value $value) ;;
  357. --log-info) SRS_LOG_INFO=$(switch2value $value) ;;
  358. --log-trace) SRS_LOG_TRACE=$(switch2value $value) ;;
  359. --log-level_v2) SRS_LOG_LEVEL_V2=$(switch2value $value) ;;
  360. --debug) SRS_DEBUG=$(switch2value $value) ;;
  361. --debug-stats) SRS_DEBUG_STATS=$(switch2value $value) ;;
  362. --cross-build) SRS_CROSS_BUILD=YES ;;
  363. --generic-linux) SRS_GENERIC_LINUX=$(switch2value $value) ;;
  364. --build-cache) SRS_BUILD_CACHE=$(switch2value $value) ;;
  365. ##########################################################################################
  366. --without-srtp-nasm) SRS_SRTP_ASM=NO ;; # Deprecated, might be removed in future.
  367. --with-srtp-nasm) SRS_SRTP_ASM=YES ;; # Deprecated, might be removed in future.
  368. --without-nasm) SRS_NASM=NO ;; # Deprecated, might be removed in future.
  369. --with-nasm) SRS_NASM=YES ;; # Deprecated, might be removed in future.
  370. --with-ssl) SRS_SSL=YES ;; # Deprecated, might be removed in future.
  371. --with-hds) SRS_HDS=YES ;; # Deprecated, might be removed in future.
  372. --without-hds) SRS_HDS=NO ;; # Deprecated, might be removed in future.
  373. --with-transcode) SRS_TRANSCODE=YES ;; # Deprecated, might be removed in future.
  374. --with-ingest) SRS_INGEST=YES ;; # Deprecated, might be removed in future.
  375. --with-stat) SRS_STAT=YES ;; # Deprecated, might be removed in future.
  376. --with-stream-caster) SRS_STREAM_CASTER=YES ;; # Deprecated, might be removed in future.
  377. --with-utest) SRS_UTEST=YES ;; # Deprecated, might be removed in future.
  378. --without-utest) SRS_UTEST=NO ;; # Deprecated, might be removed in future.
  379. --with-srt) SRS_SRT=YES ;; # Deprecated, might be removed in future.
  380. --without-srt) SRS_SRT=NO ;; # Deprecated, might be removed in future.
  381. --with-rtc) SRS_RTC=YES ;; # Deprecated, might be removed in future.
  382. --without-rtc) SRS_RTC=NO ;; # Deprecated, might be removed in future.
  383. --with-clean) SRS_CLEAN=YES ;; # Deprecated, might be removed in future.
  384. --without-clean) SRS_CLEAN=NO ;; # Deprecated, might be removed in future.
  385. --with-gperf) SRS_GPERF=YES ;; # Deprecated, might be removed in future.
  386. --without-gperf) SRS_GPERF=NO ;; # Deprecated, might be removed in future.
  387. --with-gmc) SRS_GPERF_MC=YES ;; # Deprecated, might be removed in future.
  388. --without-gmc) SRS_GPERF_MC=NO ;; # Deprecated, might be removed in future.
  389. --with-gmd) SRS_GPERF_MD=YES ;; # Deprecated, might be removed in future.
  390. --without-gmd) SRS_GPERF_MD=NO ;; # Deprecated, might be removed in future.
  391. --with-gmp) SRS_GPERF_MP=YES ;; # Deprecated, might be removed in future.
  392. --without-gmp) SRS_GPERF_MP=NO ;; # Deprecated, might be removed in future.
  393. --with-gcp) SRS_GPERF_CP=YES ;; # Deprecated, might be removed in future.
  394. --without-gcp) SRS_GPERF_CP=NO ;; # Deprecated, might be removed in future.
  395. --with-gprof) SRS_GPROF=YES ;; # Deprecated, might be removed in future.
  396. --without-gprof) SRS_GPROF=NO ;; # Deprecated, might be removed in future.
  397. --with-valgrind) SRS_VALGRIND=YES ;; # Deprecated, might be removed in future.
  398. --without-valgrind) SRS_VALGRIND=NO ;; # Deprecated, might be removed in future.
  399. --cross) SRS_CROSS_BUILD=$(switch2value $value) ;; # Deprecated, might be removed in future.
  400. --enable-cross-compile) SRS_CROSS_BUILD=YES ;; # Deprecated, might be removed in future.
  401. ##########################################################################################
  402. --osx) SRS_OSX=YES ;; # Deprecated, might be removed in future.
  403. --cygwin64) SRS_CYGWIN64=YES ;; # Deprecated, might be removed in future.
  404. --x86-x64) SRS_X86_X64=YES ;; # Deprecated, might be removed in future.
  405. --x86-64) SRS_X86_X64=YES ;; # Deprecated, might be removed in future.
  406. --with-nginx) SRS_NGINX=YES ;; # Deprecated, might be removed in future.
  407. --without-nginx) SRS_NGINX=NO ;; # Deprecated, might be removed in future.
  408. --nginx) SRS_NGINX=$(switch2value $value) ;; # Deprecated, might be removed in future.
  409. --with-ffmpeg) SRS_FFMPEG_TOOL=YES ;; # Deprecated, might be removed in future.
  410. --without-ffmpeg) SRS_FFMPEG_TOOL=NO ;; # Deprecated, might be removed in future.
  411. --ffmpeg) SRS_FFMPEG_TOOL=$(switch2value $value) ;; # Deprecated, might be removed in future.
  412. --ffmpeg-tool) SRS_FFMPEG_TOOL=$(switch2value $value) ;; # Deprecated, might be removed in future.
  413. *)
  414. echo "$0: error: invalid option \"$option\""
  415. exit 1
  416. ;;
  417. esac
  418. }
  419. function parse_user_option_to_value_and_option() {
  420. case "$option" in
  421. -*=*)
  422. value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'`
  423. option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/. +,=]*||'`
  424. ;;
  425. *) value="" ;;
  426. esac
  427. }
  428. # For variable values, might be three values: YES, RESERVED, NO(by default).
  429. function value2switch() {
  430. if [[ $1 == YES ]]; then
  431. echo on;
  432. elif [[ $1 == RESERVED ]]; then
  433. echo reserved;
  434. else
  435. echo off;
  436. fi
  437. }
  438. # For user options, only off or on(by default).
  439. function switch2value() {
  440. if [[ $1 == off ]]; then
  441. echo NO;
  442. else
  443. echo YES;
  444. fi
  445. }
  446. opt=
  447. for option
  448. do
  449. opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"
  450. parse_user_option_to_value_and_option
  451. parse_user_option
  452. done
  453. if [[ $help == YES ]]; then
  454. show_help
  455. exit 0
  456. fi
  457. #####################################################################################
  458. # Apply auto options
  459. #####################################################################################
  460. function apply_auto_options() {
  461. if [[ $OS_IS_CYGWIN == YES ]]; then
  462. SRS_CYGWIN64=YES
  463. fi
  464. if [[ $SRS_CROSS_BUILD == YES ]]; then
  465. if [[ $SRS_CROSS_BUILD_PREFIX != "" && $SRS_CROSS_BUILD_HOST == "" ]]; then
  466. SRS_CROSS_BUILD_HOST=$(echo $SRS_CROSS_BUILD_PREFIX| sed 's/-$//g')
  467. fi
  468. if [[ $SRS_TOOL_CC != "" && $SRS_CROSS_BUILD_HOST == "" ]]; then
  469. SRS_CROSS_BUILD_HOST=$(echo $SRS_TOOL_CC| sed 's/-gcc$//g')
  470. fi
  471. if [[ $SRS_CROSS_BUILD_PREFIX == "" ]]; then
  472. SRS_CROSS_BUILD_PREFIX="${SRS_CROSS_BUILD_HOST}-"
  473. fi
  474. SRS_TOOL_CC=${SRS_CROSS_BUILD_PREFIX}gcc
  475. SRS_TOOL_CXX=${SRS_CROSS_BUILD_PREFIX}g++
  476. SRS_TOOL_AR=${SRS_CROSS_BUILD_PREFIX}ar
  477. SRS_TOOL_LD=${SRS_CROSS_BUILD_PREFIX}ld
  478. SRS_TOOL_RANDLIB=${SRS_CROSS_BUILD_PREFIX}randlib
  479. if [[ $SRS_CROSS_BUILD_ARCH == "" ]]; then
  480. echo $SRS_TOOL_CC| grep arm >/dev/null 2>&1 && SRS_CROSS_BUILD_ARCH="arm"
  481. echo $SRS_TOOL_CC| grep aarch64 >/dev/null 2>&1 && SRS_CROSS_BUILD_ARCH="aarch64"
  482. echo $SRS_TOOL_CC| grep mipsel >/dev/null 2>&1 && SRS_CROSS_BUILD_ARCH="mipsel"
  483. fi
  484. echo "For cross build, host: $SRS_CROSS_BUILD_HOST, prefix: $SRS_CROSS_BUILD_PREFIX, arch: $SRS_CROSS_BUILD_ARCH, cpu: $SRS_CROSS_BUILD_CPU gcc: $SRS_TOOL_CC"
  485. fi
  486. if [[ $SRS_OSX == YES ]]; then
  487. SRS_TOOL_LD=$SRS_TOOL_CC
  488. fi
  489. # Enable FFmpeg fit for RTC to transcode audio from AAC to OPUS, if user enabled it.
  490. if [[ $SRS_RTC == YES && $SRS_FFMPEG_FIT == RESERVED ]]; then
  491. SRS_FFMPEG_FIT=YES
  492. fi
  493. if [[ $SRS_USE_SYS_FFMPEG == YES && $SRS_SHARED_FFMPEG == RESERVED ]]; then
  494. SRS_SHARED_FFMPEG=YES
  495. fi
  496. if [[ $SRS_CROSS_BUILD == YES && $SRS_FFMPEG_OPUS != YES ]]; then
  497. echo "Enable FFmpeg native opus for cross building"
  498. SRS_FFMPEG_OPUS=YES
  499. fi
  500. if [[ $SRS_USE_SYS_SRT == YES && $SRS_SHARED_SRT == RESERVED ]]; then
  501. SRS_SHARED_SRT=YES
  502. fi
  503. if [[ $SRS_USE_SYS_SRTP == YES && $SRS_SHARED_SRTP == RESERVED ]]; then
  504. SRS_SHARED_SRTP=YES
  505. fi
  506. # Enable asan, but disable for Centos
  507. # @see https://github.com/ossrs/srs/issues/3347
  508. if [[ $SRS_SANITIZER == RESERVED && $OS_IS_CENTOS != YES ]]; then
  509. echo "Enable asan by auto options."
  510. SRS_SANITIZER=YES
  511. fi
  512. # If enable gperf, disable sanitizer.
  513. if [[ $SRS_GPERF == YES && $SRS_SANITIZER == YES ]]; then
  514. echo "Disable sanitizer for gperf"
  515. SRS_SANITIZER=NO
  516. fi
  517. # if transcode/ingest specified, requires the ffmpeg stub classes.
  518. SRS_FFMPEG_STUB=NO
  519. if [[ $SRS_TRANSCODE == YES ]]; then SRS_FFMPEG_STUB=YES; fi
  520. if [[ $SRS_INGEST == YES ]]; then SRS_FFMPEG_STUB=YES; fi
  521. if [[ $SRS_SRTP_ASM == YES && $SRS_RTC == NO ]]; then
  522. echo "Disable SRTP-ASM, because RTC is disabled."
  523. SRS_SRTP_ASM=NO
  524. fi
  525. if [[ $SRS_SRTP_ASM == YES && $SRS_NASM == NO ]]; then
  526. echo "Disable SRTP-ASM, because NASM is disabled."
  527. SRS_SRTP_ASM=NO
  528. fi
  529. # TODO: FIXME: Should build address sanitizer for cygwin64.
  530. # See https://github.com/ossrs/srs/issues/3252
  531. if [[ $SRS_CYGWIN64 == YES && $SRS_SANITIZER == YES ]]; then
  532. echo "Disable address sanitizer for cygwin64"
  533. SRS_SANITIZER=NO
  534. fi
  535. # TODO: FIXME: Should fix bug for SRT for cygwin64. Build ok, but fail in SrsSrtSocket::accept.
  536. # See https://github.com/ossrs/srs/issues/3251
  537. if [[ $SRS_CYGWIN64 == YES && $SRS_SRT == YES ]]; then
  538. echo "Disable SRT for cygwin64"
  539. SRS_SRT=NO
  540. fi
  541. # TODO: FIXME: Cygwin: ST stuck when working in multiple threads mode.
  542. # See https://github.com/ossrs/srs/issues/3253
  543. if [[ $SRS_CYGWIN64 == YES && $SRS_SINGLE_THREAD != YES ]]; then
  544. echo "Force single thread for cygwin64"
  545. SRS_SINGLE_THREAD=YES
  546. fi
  547. # parse the jobs for make
  548. if [[ ! -z SRS_JOBS ]]; then
  549. export SRS_JOBS="--jobs=${SRS_JOBS}"
  550. fi
  551. }
  552. apply_auto_options
  553. #####################################################################################
  554. # Apply detail options
  555. #####################################################################################
  556. function apply_detail_options() {
  557. # Always enable HTTP utilies.
  558. if [[ $SRS_HTTP_CORE == NO ]]; then SRS_HTTP_CORE=YES; echo -e "${YELLOW}[WARN] Always enable HTTP utilies.${BLACK}"; fi
  559. if [[ $SRS_STREAM_CASTER == NO ]]; then SRS_STREAM_CASTER=YES; echo -e "${YELLOW}[WARN] Always enable StreamConverter.${BLACK}"; fi
  560. if [[ $SRS_INGEST == NO ]]; then SRS_INGEST=YES; echo -e "${YELLOW}[WARN] Always enable Ingest.${BLACK}"; fi
  561. if [[ $SRS_SSL == NO ]]; then SRS_SSL=YES; echo -e "${YELLOW}[WARN] Always enable SSL.${BLACK}"; fi
  562. if [[ $SRS_STAT == NO ]]; then SRS_STAT=YES; echo -e "${YELLOW}[WARN] Always enable Statistic.${BLACK}"; fi
  563. if [[ $SRS_TRANSCODE == NO ]]; then SRS_TRANSCODE=YES; echo -e "${YELLOW}[WARN] Always enable Transcode.${BLACK}"; fi
  564. if [[ $SRS_HTTP_CALLBACK == NO ]]; then SRS_HTTP_CALLBACK=YES; echo -e "${YELLOW}[WARN] Always enable HTTP callback.${BLACK}"; fi
  565. if [[ $SRS_HTTP_SERVER == NO ]]; then SRS_HTTP_SERVER=YES; echo -e "${YELLOW}[WARN] Always enable HTTP server.${BLACK}"; fi
  566. if [[ $SRS_HTTP_API == NO ]]; then SRS_HTTP_API=YES; echo -e "${YELLOW}[WARN] Always enable HTTP API.${BLACK}"; fi
  567. if [[ $SRS_HLS == NO ]]; then SRS_HLS=YES; echo -e "${YELLOW}[WARN] Always enable HLS.${BLACK}"; fi
  568. if [[ $SRS_DVR == NO ]]; then SRS_DVR=YES; echo -e "${YELLOW}[WARN] Always enable DVR.${BLACK}"; fi
  569. if [[ $SRS_SANITIZER == RESERVED ]]; then SRS_SANITIZER=NO; fi
  570. }
  571. apply_detail_options
  572. #####################################################################################
  573. # Regenerate options for tracing.
  574. #####################################################################################
  575. function regenerate_options() {
  576. # save all config options to macro to write to auto headers file
  577. SRS_AUTO_USER_CONFIGURE=`echo $opt`
  578. # regenerate the options for default values.
  579. SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}"
  580. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --config=$SRS_DEFAULT_CONFIG"
  581. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --osx=$(value2switch $SRS_OSX)"
  582. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --hls=$(value2switch $SRS_HLS)"
  583. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --hds=$(value2switch $SRS_HDS)"
  584. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --dvr=$(value2switch $SRS_DVR)"
  585. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ssl=$(value2switch $SRS_SSL)"
  586. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --https=$(value2switch $SRS_HTTPS)"
  587. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ssl-1-0=$(value2switch $SRS_SSL_1_0)"
  588. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ssl-local=$(value2switch $SRS_SSL_LOCAL)"
  589. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sys-ssl=$(value2switch $SRS_USE_SYS_SSL)"
  590. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --transcode=$(value2switch $SRS_TRANSCODE)"
  591. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ingest=$(value2switch $SRS_INGEST)"
  592. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --stat=$(value2switch $SRS_STAT)"
  593. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-callback=$(value2switch $SRS_HTTP_CALLBACK)"
  594. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-server=$(value2switch $SRS_HTTP_SERVER)"
  595. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --stream-converter=$(value2switch $SRS_STREAM_CASTER)"
  596. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-api=$(value2switch $SRS_HTTP_API)"
  597. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --utest=$(value2switch $SRS_UTEST)"
  598. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srt=$(value2switch $SRS_SRT)"
  599. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sys-srt=$(value2switch $SRS_USE_SYS_SRT)"
  600. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=$(value2switch $SRS_RTC)"
  601. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --h265=$(value2switch $SRS_H265)"
  602. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=$(value2switch $SRS_GB28181)"
  603. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=$(value2switch $SRS_SIMULATOR)"
  604. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=$(value2switch $SRS_CXX11)"
  605. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=$(value2switch $SRS_CXX14)"
  606. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --backtrace=$(value2switch $SRS_BACKTRACE)"
  607. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-fit=$(value2switch $SRS_FFMPEG_FIT)"
  608. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sys-ffmpeg=$(value2switch $SRS_USE_SYS_FFMPEG)"
  609. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-opus=$(value2switch $SRS_FFMPEG_OPUS)"
  610. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=$(value2switch $SRS_NASM)"
  611. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=$(value2switch $SRS_SRTP_ASM)"
  612. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sys-srtp=$(value2switch $SRS_USE_SYS_SRTP)"
  613. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=$(value2switch $SRS_CLEAN)"
  614. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gperf=$(value2switch $SRS_GPERF)"
  615. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmc=$(value2switch $SRS_GPERF_MC)"
  616. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmd=$(value2switch $SRS_GPERF_MD)"
  617. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmp=$(value2switch $SRS_GPERF_MP)"
  618. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcp=$(value2switch $SRS_GPERF_CP)"
  619. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gprof=$(value2switch $SRS_GPROF)"
  620. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --static=$(value2switch $SRS_STATIC)"
  621. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --shared-st=$(value2switch $SRS_SHARED_ST)"
  622. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --shared-srt=$(value2switch $SRS_SHARED_SRT)"
  623. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --shared-ffmpeg=$(value2switch $SRS_SHARED_FFMPEG)"
  624. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --shared-srtp=$(value2switch $SRS_SHARED_SRTP)"
  625. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-verbose=$(value2switch $SRS_LOG_VERBOSE)"
  626. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-info=$(value2switch $SRS_LOG_INFO)"
  627. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace=$(value2switch $SRS_LOG_TRACE)"
  628. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-level_v2=$(value2switch $SRS_LOG_LEVEL_V2)"
  629. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcov=$(value2switch $SRS_GCOV)"
  630. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --apm=$(value2switch $SRS_APM)"
  631. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug=$(value2switch $SRS_DEBUG)"
  632. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug-stats=$(value2switch $SRS_DEBUG_STATS)"
  633. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cross-build=$(value2switch $SRS_CROSS_BUILD)"
  634. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer=$(value2switch $SRS_SANITIZER)"
  635. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer-static=$(value2switch $SRS_SANITIZER_STATIC)"
  636. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer-log=$(value2switch $SRS_SANITIZER_LOG)"
  637. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cygwin64=$(value2switch $SRS_CYGWIN64)"
  638. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --single-thread=$(value2switch $SRS_SINGLE_THREAD)"
  639. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --signal-api=$(value2switch $SRS_SIGNAL_API)"
  640. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --generic-linux=$(value2switch $SRS_GENERIC_LINUX)"
  641. SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --build-cache=$(value2switch $SRS_BUILD_CACHE)"
  642. if [[ $SRS_CROSS_BUILD_ARCH != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --arch=$SRS_CROSS_BUILD_ARCH"; fi
  643. if [[ $SRS_CROSS_BUILD_CPU != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --cpu=$SRS_CROSS_BUILD_CPU"; fi
  644. if [[ $SRS_CROSS_BUILD_HOST != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --host=$SRS_CROSS_BUILD_HOST"; fi
  645. if [[ $SRS_CROSS_BUILD_PREFIX != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --cross-prefix=$SRS_CROSS_BUILD_PREFIX"; fi
  646. if [[ $SRS_EXTRA_FLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_FLAGS\\\""; fi
  647. if [[ $SRS_EXTRA_LDFLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-ldflags=\\\"$SRS_EXTRA_LDFLAGS\\\""; fi
  648. if [[ $SRS_BUILD_TAG != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --build-tag=\\\"$SRS_BUILD_TAG\\\""; fi
  649. if [[ $SRS_TOOL_CC != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cc=$SRS_TOOL_CC"; fi
  650. if [[ $SRS_TOOL_CXX != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx=$SRS_TOOL_CXX"; fi
  651. if [[ $SRS_TOOL_AR != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ar=$SRS_TOOL_AR"; fi
  652. if [[ $SRS_TOOL_LD != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ld=$SRS_TOOL_LD"; fi
  653. if [[ $SRS_TOOL_RANDLIB != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --randlib=$SRS_TOOL_RANDLIB"; fi
  654. echo "User config: $SRS_AUTO_USER_CONFIGURE"
  655. echo "Detail config: ${SRS_AUTO_CONFIGURE}"
  656. }
  657. regenerate_options
  658. #####################################################################################
  659. # Check conflicted options
  660. #####################################################################################
  661. function check_option_conflicts() {
  662. if [[ $SRS_TOOL_CC == '' || $SRS_TOOL_CXX == '' || $SRS_TOOL_AR == '' || $SRS_TOOL_LD == '' || $SRS_TOOL_RANDLIB == '' ]]; then
  663. echo "Error: No build toolchain, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR, ld: $SRS_TOOL_LD, randlib: $SRS_TOOL_RANDLIB"; exit -1
  664. fi
  665. if [[ $SRS_CROSS_BUILD == YES && ($SRS_TOOL_CC == 'gcc' || $SRS_TOOL_CXX == 'g++' || $SRS_TOOL_AR == 'ar') ]]; then
  666. echo "Error: For cross build, should setup the toolchain(./configure -h|grep -i toolchain), cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR"; exit 1
  667. fi
  668. if [[ $SRS_NGINX == YES ]]; then
  669. echo "Warning: Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker"
  670. SRS_NGINX=NO
  671. fi
  672. # TODO: FIXME: check more os.
  673. __check_ok=YES
  674. # check conflict
  675. if [[ $SRS_GPERF == NO ]]; then
  676. if [[ $SRS_GPERF_MC == YES ]]; then echo "gperf-mc depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  677. if [[ $SRS_GPERF_MD == YES ]]; then echo "gperf-md depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  678. if [[ $SRS_GPERF_MP == YES ]]; then echo "gperf-mp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  679. if [[ $SRS_GPERF_CP == YES ]]; then echo "gperf-cp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  680. fi
  681. if [[ $SRS_GPERF_MC == YES && $SRS_GPERF_MP == YES ]]; then
  682. echo "gperf-mc not compatible with gperf-mp, see: ./configure --help";
  683. echo "@see: https://gperftools.github.io/gperftools/heap_checker.html";
  684. 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";
  685. __check_ok=NO
  686. fi
  687. # generate the group option: SRS_GPERF
  688. __gperf_slow=NO
  689. if [[ $SRS_GPERF_MC == YES ]]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  690. if [[ $SRS_GPERF_MD == YES ]]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  691. if [[ $SRS_GPERF_MP == YES ]]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  692. if [[ $SRS_GPERF_CP == YES ]]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  693. if [[ $__gperf_slow == YES ]]; then if [[ $SRS_GPROF == YES ]]; then
  694. echo "gmc/gmp/gcp not compatible with gprof, see: ./configure --help"; __check_ok=NO;
  695. fi fi
  696. # check variable neccessary
  697. if [[ $SRS_HDS == RESERVED ]]; then echo "you must specifies the hds, see: ./configure --help"; __check_ok=NO; fi
  698. if [[ $SRS_SSL == RESERVED ]]; then echo "you must specifies the ssl, see: ./configure --help"; __check_ok=NO; fi
  699. if [[ $SRS_STREAM_CASTER == RESERVED ]]; then echo "you must specifies the stream-converter, see: ./configure --help"; __check_ok=NO; fi
  700. if [[ $SRS_UTEST == RESERVED ]]; then echo "you must specifies the utest, see: ./configure --help"; __check_ok=NO; fi
  701. if [[ $SRS_GPERF == RESERVED ]]; then echo "you must specifies the gperf, see: ./configure --help"; __check_ok=NO; fi
  702. if [[ $SRS_GPERF_MC == RESERVED ]]; then echo "you must specifies the gperf-mc, see: ./configure --help"; __check_ok=NO; fi
  703. if [[ $SRS_GPERF_MD == RESERVED ]]; then echo "you must specifies the gperf-md, see: ./configure --help"; __check_ok=NO; fi
  704. if [[ $SRS_GPERF_MP == RESERVED ]]; then echo "you must specifies the gperf-mp, see: ./configure --help"; __check_ok=NO; fi
  705. if [[ $SRS_GPERF_CP == RESERVED ]]; then echo "you must specifies the gperf-cp, see: ./configure --help"; __check_ok=NO; fi
  706. if [[ $SRS_GPROF == RESERVED ]]; then echo "you must specifies the gprof, see: ./configure --help"; __check_ok=NO; fi
  707. if [[ -z $SRS_PREFIX ]]; then echo "you must specifies the prefix, see: ./configure --prefix"; __check_ok=NO; fi
  708. if [[ $__check_ok == NO ]]; then
  709. exit 1;
  710. fi
  711. }
  712. check_option_conflicts