2
0

options.sh 46 KB

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