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