2
0

configure 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. #!/bin/sh
  2. ##
  3. ## configure
  4. ##
  5. ## This script is the front-end to the build system. It provides a similar
  6. ## interface to standard configure scripts with some extra bits for dealing
  7. ## with toolchains that differ from the standard POSIX interface and
  8. ## for extracting subsets of the source tree. In theory, reusable parts
  9. ## of this script were intended to live in build/make/configure.sh,
  10. ## but in practice, the line is pretty blurry.
  11. ##
  12. ## This build system is based in part on the FFmpeg configure script.
  13. ##
  14. #source_path="`dirname \"$0\"`"
  15. source_path=${0%/*}
  16. . "${source_path}/build/make/configure.sh"
  17. show_help(){
  18. show_help_pre
  19. cat << EOF
  20. Advanced options:
  21. ${toggle_libs} libraries
  22. ${toggle_examples} examples
  23. ${toggle_tools} tools
  24. ${toggle_docs} documentation
  25. ${toggle_unit_tests} unit tests
  26. ${toggle_decode_perf_tests} build decoder perf tests with unit tests
  27. ${toggle_encode_perf_tests} build encoder perf tests with unit tests
  28. --cpu=CPU tune for the specified CPU (ARM: cortex-a8, X86: sse3)
  29. --libc=PATH path to alternate libc
  30. --size-limit=WxH max size to allow in the decoder
  31. --as={yasm|nasm|auto} use specified assembler [auto, yasm preferred]
  32. ${toggle_codec_srcs} in/exclude codec library source code
  33. ${toggle_debug_libs} in/exclude debug version of libraries
  34. ${toggle_static_msvcrt} use static MSVCRT (VS builds only)
  35. ${toggle_vp9_highbitdepth} use VP9 high bit depth (10/12) profiles
  36. ${toggle_better_hw_compatibility}
  37. enable encoder to produce streams with better
  38. hardware decoder compatibility
  39. ${toggle_vp8} VP8 codec support
  40. ${toggle_vp9} VP9 codec support
  41. ${toggle_internal_stats} output of encoder internal stats for debug, if supported (encoders)
  42. ${toggle_postproc} postprocessing
  43. ${toggle_vp9_postproc} vp9 specific postprocessing
  44. ${toggle_multithread} multithreaded encoding and decoding
  45. ${toggle_spatial_resampling} spatial sampling (scaling) support
  46. ${toggle_realtime_only} enable this option while building for real-time encoding
  47. ${toggle_onthefly_bitpacking} enable on-the-fly bitpacking in real-time encoding
  48. ${toggle_error_concealment} enable this option to get a decoder which is able to conceal losses
  49. ${toggle_coefficient_range_checking}
  50. enable decoder to check if intermediate
  51. transform coefficients are in valid range
  52. ${toggle_runtime_cpu_detect} runtime cpu detection
  53. ${toggle_shared} shared library support
  54. ${toggle_static} static library support
  55. ${toggle_small} favor smaller size over speed
  56. ${toggle_postproc_visualizer} macro block / block level visualizers
  57. ${toggle_multi_res_encoding} enable multiple-resolution encoding
  58. ${toggle_temporal_denoising} enable temporal denoising and disable the spatial denoiser
  59. ${toggle_vp9_temporal_denoising}
  60. enable vp9 temporal denoising
  61. ${toggle_webm_io} enable input from and output to WebM container
  62. ${toggle_libyuv} enable libyuv
  63. Codecs:
  64. Codecs can be selectively enabled or disabled individually, or by family:
  65. --disable-<codec>
  66. is equivalent to:
  67. --disable-<codec>-encoder
  68. --disable-<codec>-decoder
  69. Codecs available in this distribution:
  70. EOF
  71. #restore editor state '
  72. family="";
  73. last_family="";
  74. c="";
  75. str="";
  76. for c in ${CODECS}; do
  77. family=${c%_*}
  78. if [ "${family}" != "${last_family}" ]; then
  79. [ -z "${str}" ] || echo "${str}"
  80. str="$(printf ' %10s:' ${family})"
  81. fi
  82. str="${str} $(printf '%10s' ${c#*_})"
  83. last_family=${family}
  84. done
  85. echo "${str}"
  86. show_help_post
  87. }
  88. ##
  89. ## BEGIN APPLICATION SPECIFIC CONFIGURATION
  90. ##
  91. # all_platforms is a list of all supported target platforms. Maintain
  92. # alphabetically by architecture, generic-gnu last.
  93. all_platforms="${all_platforms} arm64-android-gcc"
  94. all_platforms="${all_platforms} arm64-darwin-gcc"
  95. all_platforms="${all_platforms} arm64-linux-gcc"
  96. all_platforms="${all_platforms} arm64-win64-gcc"
  97. all_platforms="${all_platforms} arm64-win64-vs15"
  98. all_platforms="${all_platforms} armv7-android-gcc" #neon Cortex-A8
  99. all_platforms="${all_platforms} armv7-darwin-gcc" #neon Cortex-A8
  100. all_platforms="${all_platforms} armv7-linux-rvct" #neon Cortex-A8
  101. all_platforms="${all_platforms} armv7-linux-gcc" #neon Cortex-A8
  102. all_platforms="${all_platforms} armv7-none-rvct" #neon Cortex-A8
  103. all_platforms="${all_platforms} armv7-win32-gcc"
  104. all_platforms="${all_platforms} armv7-win32-vs14"
  105. all_platforms="${all_platforms} armv7-win32-vs15"
  106. all_platforms="${all_platforms} armv7s-darwin-gcc"
  107. all_platforms="${all_platforms} armv8-linux-gcc"
  108. all_platforms="${all_platforms} mips32-linux-gcc"
  109. all_platforms="${all_platforms} mips64-linux-gcc"
  110. all_platforms="${all_platforms} ppc64le-linux-gcc"
  111. all_platforms="${all_platforms} sparc-solaris-gcc"
  112. all_platforms="${all_platforms} x86-android-gcc"
  113. all_platforms="${all_platforms} x86-darwin8-gcc"
  114. all_platforms="${all_platforms} x86-darwin8-icc"
  115. all_platforms="${all_platforms} x86-darwin9-gcc"
  116. all_platforms="${all_platforms} x86-darwin9-icc"
  117. all_platforms="${all_platforms} x86-darwin10-gcc"
  118. all_platforms="${all_platforms} x86-darwin11-gcc"
  119. all_platforms="${all_platforms} x86-darwin12-gcc"
  120. all_platforms="${all_platforms} x86-darwin13-gcc"
  121. all_platforms="${all_platforms} x86-darwin14-gcc"
  122. all_platforms="${all_platforms} x86-darwin15-gcc"
  123. all_platforms="${all_platforms} x86-darwin16-gcc"
  124. all_platforms="${all_platforms} x86-darwin17-gcc"
  125. all_platforms="${all_platforms} x86-darwin18-gcc"
  126. all_platforms="${all_platforms} x86-iphonesimulator-gcc"
  127. all_platforms="${all_platforms} x86-linux-gcc"
  128. all_platforms="${all_platforms} x86-linux-icc"
  129. all_platforms="${all_platforms} x86-os2-gcc"
  130. all_platforms="${all_platforms} x86-solaris-gcc"
  131. all_platforms="${all_platforms} x86-win32-gcc"
  132. all_platforms="${all_platforms} x86-win32-vs14"
  133. all_platforms="${all_platforms} x86-win32-vs15"
  134. all_platforms="${all_platforms} x86_64-android-gcc"
  135. all_platforms="${all_platforms} x86_64-darwin9-gcc"
  136. all_platforms="${all_platforms} x86_64-darwin10-gcc"
  137. all_platforms="${all_platforms} x86_64-darwin11-gcc"
  138. all_platforms="${all_platforms} x86_64-darwin12-gcc"
  139. all_platforms="${all_platforms} x86_64-darwin13-gcc"
  140. all_platforms="${all_platforms} x86_64-darwin14-gcc"
  141. all_platforms="${all_platforms} x86_64-darwin15-gcc"
  142. all_platforms="${all_platforms} x86_64-darwin16-gcc"
  143. all_platforms="${all_platforms} x86_64-darwin17-gcc"
  144. all_platforms="${all_platforms} x86_64-darwin18-gcc"
  145. all_platforms="${all_platforms} x86_64-darwin19-gcc"
  146. all_platforms="${all_platforms} x86_64-iphonesimulator-gcc"
  147. all_platforms="${all_platforms} x86_64-linux-gcc"
  148. all_platforms="${all_platforms} x86_64-linux-icc"
  149. all_platforms="${all_platforms} x86_64-solaris-gcc"
  150. all_platforms="${all_platforms} x86_64-win64-gcc"
  151. all_platforms="${all_platforms} x86_64-win64-vs14"
  152. all_platforms="${all_platforms} x86_64-win64-vs15"
  153. all_platforms="${all_platforms} generic-gnu"
  154. # all_targets is a list of all targets that can be configured
  155. # note that these should be in dependency order for now.
  156. all_targets="libs examples tools docs"
  157. # all targets available are enabled, by default.
  158. for t in ${all_targets}; do
  159. [ -f "${source_path}/${t}.mk" ] && enable_feature ${t}
  160. done
  161. if ! diff --version >/dev/null; then
  162. die "diff missing: Try installing diffutils via your package manager."
  163. fi
  164. if ! perl --version >/dev/null; then
  165. die "Perl is required to build"
  166. fi
  167. if [ "`cd \"${source_path}\" && pwd`" != "`pwd`" ]; then
  168. # test to see if source_path already configured
  169. if [ -f "${source_path}/vpx_config.h" ]; then
  170. die "source directory already configured; run 'make distclean' there first"
  171. fi
  172. fi
  173. # check installed doxygen version
  174. doxy_version=$(doxygen --version 2>/dev/null)
  175. doxy_major=${doxy_version%%.*}
  176. if [ ${doxy_major:-0} -ge 1 ]; then
  177. doxy_version=${doxy_version#*.}
  178. doxy_minor=${doxy_version%%.*}
  179. doxy_patch=${doxy_version##*.}
  180. [ $doxy_major -gt 1 ] && enable_feature doxygen
  181. [ $doxy_minor -gt 5 ] && enable_feature doxygen
  182. [ $doxy_minor -eq 5 ] && [ $doxy_patch -ge 3 ] && enable_feature doxygen
  183. fi
  184. # disable codecs when their source directory does not exist
  185. [ -d "${source_path}/vp8" ] || disable_codec vp8
  186. [ -d "${source_path}/vp9" ] || disable_codec vp9
  187. # install everything except the sources, by default. sources will have
  188. # to be enabled when doing dist builds, since that's no longer a common
  189. # case.
  190. enabled doxygen && enable_feature install_docs
  191. enable_feature install_bins
  192. enable_feature install_libs
  193. enable_feature static
  194. enable_feature optimizations
  195. enable_feature dependency_tracking
  196. enable_feature spatial_resampling
  197. enable_feature multithread
  198. enable_feature os_support
  199. enable_feature temporal_denoising
  200. CODECS="
  201. vp8_encoder
  202. vp8_decoder
  203. vp9_encoder
  204. vp9_decoder
  205. "
  206. CODEC_FAMILIES="
  207. vp8
  208. vp9
  209. "
  210. ARCH_LIST="
  211. arm
  212. mips
  213. x86
  214. x86_64
  215. ppc
  216. "
  217. ARCH_EXT_LIST_X86="
  218. mmx
  219. sse
  220. sse2
  221. sse3
  222. ssse3
  223. sse4_1
  224. avx
  225. avx2
  226. avx512
  227. "
  228. ARCH_EXT_LIST_LOONGSON="
  229. mmi
  230. "
  231. ARCH_EXT_LIST="
  232. neon
  233. neon_asm
  234. mips32
  235. dspr2
  236. msa
  237. mips64
  238. ${ARCH_EXT_LIST_X86}
  239. vsx
  240. ${ARCH_EXT_LIST_LOONGSON}
  241. "
  242. HAVE_LIST="
  243. ${ARCH_EXT_LIST}
  244. vpx_ports
  245. pthread_h
  246. unistd_h
  247. "
  248. EXPERIMENT_LIST="
  249. fp_mb_stats
  250. emulate_hardware
  251. non_greedy_mv
  252. "
  253. CONFIG_LIST="
  254. dependency_tracking
  255. external_build
  256. install_docs
  257. install_bins
  258. install_libs
  259. install_srcs
  260. debug
  261. gprof
  262. gcov
  263. rvct
  264. gcc
  265. msvs
  266. pic
  267. big_endian
  268. codec_srcs
  269. debug_libs
  270. dequant_tokens
  271. dc_recon
  272. runtime_cpu_detect
  273. postproc
  274. vp9_postproc
  275. multithread
  276. internal_stats
  277. ${CODECS}
  278. ${CODEC_FAMILIES}
  279. encoders
  280. decoders
  281. static_msvcrt
  282. spatial_resampling
  283. realtime_only
  284. onthefly_bitpacking
  285. error_concealment
  286. shared
  287. static
  288. small
  289. postproc_visualizer
  290. os_support
  291. unit_tests
  292. webm_io
  293. libyuv
  294. decode_perf_tests
  295. encode_perf_tests
  296. multi_res_encoding
  297. temporal_denoising
  298. vp9_temporal_denoising
  299. consistent_recode
  300. coefficient_range_checking
  301. vp9_highbitdepth
  302. better_hw_compatibility
  303. experimental
  304. size_limit
  305. always_adjust_bpm
  306. bitstream_debug
  307. mismatch_debug
  308. ${EXPERIMENT_LIST}
  309. "
  310. CMDLINE_SELECT="
  311. dependency_tracking
  312. external_build
  313. extra_warnings
  314. werror
  315. install_docs
  316. install_bins
  317. install_libs
  318. install_srcs
  319. debug
  320. gprof
  321. gcov
  322. pic
  323. optimizations
  324. ccache
  325. runtime_cpu_detect
  326. thumb
  327. libs
  328. examples
  329. tools
  330. docs
  331. libc
  332. as
  333. size_limit
  334. codec_srcs
  335. debug_libs
  336. dequant_tokens
  337. dc_recon
  338. postproc
  339. vp9_postproc
  340. multithread
  341. internal_stats
  342. ${CODECS}
  343. ${CODEC_FAMILIES}
  344. static_msvcrt
  345. spatial_resampling
  346. realtime_only
  347. onthefly_bitpacking
  348. error_concealment
  349. shared
  350. static
  351. small
  352. postproc_visualizer
  353. unit_tests
  354. webm_io
  355. libyuv
  356. decode_perf_tests
  357. encode_perf_tests
  358. multi_res_encoding
  359. temporal_denoising
  360. vp9_temporal_denoising
  361. consistent_recode
  362. coefficient_range_checking
  363. better_hw_compatibility
  364. vp9_highbitdepth
  365. experimental
  366. always_adjust_bpm
  367. bitstream_debug
  368. mismatch_debug
  369. "
  370. process_cmdline() {
  371. for opt do
  372. optval="${opt#*=}"
  373. case "$opt" in
  374. --disable-codecs)
  375. for c in ${CODEC_FAMILIES}; do disable_codec $c; done
  376. ;;
  377. --enable-?*|--disable-?*)
  378. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  379. if is_in ${option} ${EXPERIMENT_LIST}; then
  380. if enabled experimental; then
  381. ${action}_feature $option
  382. else
  383. log_echo "Ignoring $opt -- not in experimental mode."
  384. fi
  385. elif is_in ${option} "${CODECS} ${CODEC_FAMILIES}"; then
  386. ${action}_codec ${option}
  387. else
  388. process_common_cmdline $opt
  389. fi
  390. ;;
  391. *) process_common_cmdline "$opt"
  392. ;;
  393. esac
  394. done
  395. }
  396. post_process_cmdline() {
  397. if enabled coefficient_range_checking; then
  398. echo "coefficient-range-checking is for decoders only, disabling encoders:"
  399. soft_disable vp8_encoder
  400. soft_disable vp9_encoder
  401. fi
  402. c=""
  403. # Enable all detected codecs, if they haven't been disabled
  404. for c in ${CODECS}; do soft_enable $c; done
  405. # Enable the codec family if any component of that family is enabled
  406. for c in ${CODECS}; do
  407. enabled $c && enable_feature ${c%_*}
  408. done
  409. # Set the {en,de}coders variable if any algorithm in that class is enabled
  410. for c in ${CODECS}; do
  411. enabled ${c} && enable_feature ${c##*_}s
  412. done
  413. }
  414. process_targets() {
  415. enabled child || write_common_config_banner
  416. write_common_target_config_h ${BUILD_PFX}vpx_config.h
  417. write_common_config_targets
  418. enabled win_arm64_neon_h_workaround && write_win_arm64_neon_h_workaround ${BUILD_PFX}arm_neon.h
  419. # Calculate the default distribution name, based on the enabled features
  420. cf=""
  421. DIST_DIR=vpx
  422. for cf in $CODEC_FAMILIES; do
  423. if enabled ${cf}_encoder && enabled ${cf}_decoder; then
  424. DIST_DIR="${DIST_DIR}-${cf}"
  425. elif enabled ${cf}_encoder; then
  426. DIST_DIR="${DIST_DIR}-${cf}cx"
  427. elif enabled ${cf}_decoder; then
  428. DIST_DIR="${DIST_DIR}-${cf}dx"
  429. fi
  430. done
  431. enabled debug_libs && DIST_DIR="${DIST_DIR}-debug"
  432. enabled codec_srcs && DIST_DIR="${DIST_DIR}-src"
  433. ! enabled postproc && ! enabled vp9_postproc && DIST_DIR="${DIST_DIR}-nopost"
  434. ! enabled multithread && DIST_DIR="${DIST_DIR}-nomt"
  435. ! enabled install_docs && DIST_DIR="${DIST_DIR}-nodocs"
  436. DIST_DIR="${DIST_DIR}-${tgt_isa}-${tgt_os}"
  437. case "${tgt_os}" in
  438. win*) enabled static_msvcrt && DIST_DIR="${DIST_DIR}mt" || DIST_DIR="${DIST_DIR}md"
  439. DIST_DIR="${DIST_DIR}-${tgt_cc}"
  440. ;;
  441. esac
  442. if [ -f "${source_path}/build/make/version.sh" ]; then
  443. ver=`"$source_path/build/make/version.sh" --bare "$source_path"`
  444. DIST_DIR="${DIST_DIR}-${ver}"
  445. VERSION_STRING=${ver}
  446. ver=${ver%%-*}
  447. VERSION_PATCH=${ver##*.}
  448. ver=${ver%.*}
  449. VERSION_MINOR=${ver##*.}
  450. ver=${ver#v}
  451. VERSION_MAJOR=${ver%.*}
  452. fi
  453. enabled child || cat <<EOF >> config.mk
  454. PREFIX=${prefix}
  455. ifeq (\$(MAKECMDGOALS),dist)
  456. DIST_DIR?=${DIST_DIR}
  457. else
  458. DIST_DIR?=\$(DESTDIR)${prefix}
  459. endif
  460. LIBSUBDIR=${libdir##${prefix}/}
  461. VERSION_STRING=${VERSION_STRING}
  462. VERSION_MAJOR=${VERSION_MAJOR}
  463. VERSION_MINOR=${VERSION_MINOR}
  464. VERSION_PATCH=${VERSION_PATCH}
  465. CONFIGURE_ARGS=${CONFIGURE_ARGS}
  466. EOF
  467. enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
  468. #
  469. # Write makefiles for all enabled targets
  470. #
  471. for tgt in libs examples tools docs solution; do
  472. tgt_fn="$tgt-$toolchain.mk"
  473. if enabled $tgt; then
  474. echo "Creating makefiles for ${toolchain} ${tgt}"
  475. write_common_target_config_mk $tgt_fn ${BUILD_PFX}vpx_config.h
  476. #write_${tgt}_config
  477. fi
  478. done
  479. }
  480. process_detect() {
  481. if enabled shared; then
  482. # Can only build shared libs on a subset of platforms. Doing this check
  483. # here rather than at option parse time because the target auto-detect
  484. # magic happens after the command line has been parsed.
  485. case "${tgt_os}" in
  486. linux|os2|solaris|darwin*|iphonesimulator*)
  487. # Supported platforms
  488. ;;
  489. *)
  490. if enabled gnu; then
  491. echo "--enable-shared is only supported on ELF; assuming this is OK"
  492. else
  493. die "--enable-shared only supported on ELF, OS/2, and Darwin for now"
  494. fi
  495. ;;
  496. esac
  497. fi
  498. if [ -z "$CC" ] || enabled external_build; then
  499. echo "Bypassing toolchain for environment detection."
  500. enable_feature external_build
  501. check_header() {
  502. log fake_check_header "$@"
  503. header=$1
  504. shift
  505. var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
  506. disable_feature $var
  507. # Headers common to all environments
  508. case $header in
  509. stdio.h)
  510. true;
  511. ;;
  512. *)
  513. result=false
  514. for d in "$@"; do
  515. [ -f "${d##-I}/$header" ] && result=true && break
  516. done
  517. ${result:-true}
  518. esac && enable_feature $var
  519. # Specialize windows and POSIX environments.
  520. case $toolchain in
  521. *-win*-*)
  522. # Don't check for any headers in Windows builds.
  523. false
  524. ;;
  525. *)
  526. case $header in
  527. pthread.h) true;;
  528. unistd.h) true;;
  529. *) false;;
  530. esac && enable_feature $var
  531. esac
  532. enabled $var
  533. }
  534. check_ld() {
  535. true
  536. }
  537. check_lib() {
  538. true
  539. }
  540. fi
  541. check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
  542. check_ld <<EOF || die "Toolchain is unable to link executables"
  543. int main(void) {return 0;}
  544. EOF
  545. # check system headers
  546. # Use both check_header and check_lib here, since check_lib
  547. # could be a stub that always returns true.
  548. check_header pthread.h && check_lib -lpthread <<EOF || disable_feature pthread_h
  549. #include <pthread.h>
  550. #include <stddef.h>
  551. void *thread_check (void *);
  552. void *thread_check (void *obj){ return obj;};
  553. int main(void) { pthread_t thread_id; return pthread_create(&thread_id, NULL, thread_check, NULL); }
  554. EOF
  555. check_header unistd.h # for sysconf(3) and friends.
  556. check_header vpx/vpx_integer.h -I${source_path} && enable_feature vpx_ports
  557. if enabled neon && ! enabled external_build; then
  558. check_header arm_neon.h || die "Unable to find arm_neon.h"
  559. fi
  560. }
  561. process_toolchain() {
  562. process_common_toolchain
  563. # Enable some useful compiler flags
  564. if enabled gcc; then
  565. enabled werror && check_add_cflags -Werror
  566. check_add_cflags -Wall
  567. check_add_cflags -Wdeclaration-after-statement
  568. check_add_cflags -Wdisabled-optimization
  569. check_add_cflags -Wfloat-conversion
  570. check_add_cflags -Wparentheses-equality
  571. check_add_cflags -Wpointer-arith
  572. check_add_cflags -Wtype-limits
  573. check_add_cflags -Wcast-qual
  574. check_add_cflags -Wvla
  575. check_add_cflags -Wimplicit-function-declaration
  576. check_add_cflags -Wmissing-declarations
  577. check_add_cflags -Wmissing-prototypes
  578. check_add_cflags -Wuninitialized
  579. check_add_cflags -Wunused
  580. check_add_cflags -Wextra
  581. # check_add_cflags also adds to cxxflags. gtest does not do well with
  582. # these flags so add them explicitly to CFLAGS only.
  583. check_cflags -Wundef && add_cflags_only -Wundef
  584. check_cflags -Wframe-larger-than=52000 && \
  585. add_cflags_only -Wframe-larger-than=52000
  586. if enabled mips || [ -z "${INLINE}" ]; then
  587. enabled extra_warnings || check_add_cflags -Wno-unused-function
  588. fi
  589. # Enforce c89 for c files. Don't be too strict about it though. Allow
  590. # gnu extensions like "//" for comments.
  591. check_cflags -std=gnu89 && add_cflags_only -std=gnu89
  592. # Avoid this warning for third_party C++ sources. Some reorganization
  593. # would be needed to apply this only to test/*.cc.
  594. check_cflags -Wshorten-64-to-32 && add_cflags_only -Wshorten-64-to-32
  595. # Quiet gcc 6 vs 7 abi warnings:
  596. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
  597. if enabled arm; then
  598. check_add_cxxflags -Wno-psabi
  599. fi
  600. # disable some warnings specific to libyuv.
  601. check_cxxflags -Wno-missing-declarations \
  602. && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-missing-declarations"
  603. check_cxxflags -Wno-missing-prototypes \
  604. && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-missing-prototypes"
  605. check_cxxflags -Wno-unused-parameter \
  606. && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-unused-parameter"
  607. fi
  608. if enabled icc; then
  609. enabled werror && check_add_cflags -Werror
  610. check_add_cflags -Wall
  611. check_add_cflags -Wpointer-arith
  612. # ICC has a number of floating point optimizations that we disable
  613. # in favor of deterministic output WRT to other compilers
  614. add_cflags -fp-model precise
  615. fi
  616. # Enable extra, harmless warnings. These might provide additional insight
  617. # to what the compiler is doing and why, but in general, but they shouldn't
  618. # be treated as fatal, even if we're treating warnings as errors.
  619. GCC_EXTRA_WARNINGS="
  620. -Wdisabled-optimization
  621. -Winline
  622. "
  623. enabled gcc && EXTRA_WARNINGS="${GCC_EXTRA_WARNINGS}"
  624. RVCT_EXTRA_WARNINGS="
  625. --remarks
  626. "
  627. enabled rvct && EXTRA_WARNINGS="${RVCT_EXTRA_WARNINGS}"
  628. if enabled extra_warnings; then
  629. for w in ${EXTRA_WARNINGS}; do
  630. check_add_cflags ${w}
  631. enabled gcc && enabled werror && check_add_cflags -Wno-error=${w}
  632. done
  633. fi
  634. # ccache only really works on gcc toolchains
  635. enabled gcc || soft_disable ccache
  636. if enabled mips; then
  637. enable_feature dequant_tokens
  638. enable_feature dc_recon
  639. fi
  640. if enabled internal_stats; then
  641. enable_feature vp9_postproc
  642. fi
  643. # Enable the postbuild target if building for visual studio.
  644. case "$tgt_cc" in
  645. vs*) enable_feature msvs
  646. enable_feature solution
  647. vs_version=${tgt_cc##vs}
  648. VCPROJ_SFX=vcxproj
  649. gen_vcproj_cmd=${source_path}/build/make/gen_msvs_vcxproj.sh
  650. enabled werror && gen_vcproj_cmd="${gen_vcproj_cmd} --enable-werror"
  651. all_targets="${all_targets} solution"
  652. INLINE="__inline"
  653. ;;
  654. esac
  655. # Other toolchain specific defaults
  656. case $toolchain in x86*) soft_enable postproc;; esac
  657. if enabled postproc_visualizer; then
  658. enabled postproc || die "postproc_visualizer requires postproc to be enabled"
  659. fi
  660. # Enable unit tests by default if we have a working C++ compiler.
  661. case "$toolchain" in
  662. *-vs*)
  663. soft_enable unit_tests
  664. soft_enable webm_io
  665. soft_enable libyuv
  666. ;;
  667. *-android-*)
  668. check_add_cxxflags -std=c++11 && soft_enable webm_io
  669. soft_enable libyuv
  670. # GTestLog must be modified to use Android logging utilities.
  671. ;;
  672. *-darwin-*)
  673. # iOS/ARM builds do not work with gtest. This does not match
  674. # x86 targets.
  675. ;;
  676. *-iphonesimulator-*)
  677. check_add_cxxflags -std=c++11 && soft_enable webm_io
  678. soft_enable libyuv
  679. ;;
  680. *-win*)
  681. # Some mingw toolchains don't have pthread available by default.
  682. # Treat these more like visual studio where threading in gtest
  683. # would be disabled for the same reason.
  684. check_add_cxxflags -std=c++11 && soft_enable unit_tests \
  685. && soft_enable webm_io
  686. check_cxx "$@" <<EOF && soft_enable libyuv
  687. int z;
  688. EOF
  689. ;;
  690. *)
  691. enabled pthread_h && check_add_cxxflags -std=c++11 \
  692. && soft_enable unit_tests
  693. check_add_cxxflags -std=c++11 && soft_enable webm_io
  694. check_cxx "$@" <<EOF && soft_enable libyuv
  695. int z;
  696. EOF
  697. ;;
  698. esac
  699. # libwebm needs to be linked with C++ standard library
  700. enabled webm_io && LD=${CXX}
  701. # append any user defined extra cflags
  702. if [ -n "${extra_cflags}" ] ; then
  703. check_add_cflags ${extra_cflags} || \
  704. die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler"
  705. fi
  706. if [ -n "${extra_cxxflags}" ]; then
  707. check_add_cxxflags ${extra_cxxflags} || \
  708. die "Requested extra CXXFLAGS '${extra_cxxflags}' not supported by compiler"
  709. fi
  710. }
  711. ##
  712. ## END APPLICATION SPECIFIC CONFIGURATION
  713. ##
  714. CONFIGURE_ARGS="$@"
  715. process "$@"
  716. print_webm_license ${BUILD_PFX}vpx_config.c "/*" " */"
  717. cat <<EOF >> ${BUILD_PFX}vpx_config.c
  718. #include "vpx/vpx_codec.h"
  719. static const char* const cfg = "$CONFIGURE_ARGS";
  720. const char *vpx_codec_build_config(void) {return cfg;}
  721. EOF