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