options.sh 45 KB

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