xref: /aosp_15_r20/external/libvpx/configure (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
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    sve2
264"
265
266ARCH_EXT_LIST_X86="
267    mmx
268    sse
269    sse2
270    sse3
271    ssse3
272    sse4_1
273    avx
274    avx2
275    avx512
276"
277
278ARCH_EXT_LIST_LOONGSON="
279    mmi
280    lsx
281    lasx
282"
283
284ARCH_EXT_LIST="
285    neon_asm
286    ${ARCH_EXT_LIST_AARCH64}
287
288    mips32
289    dspr2
290    msa
291    mips64
292
293    ${ARCH_EXT_LIST_X86}
294
295    vsx
296
297    ${ARCH_EXT_LIST_LOONGSON}
298"
299HAVE_LIST="
300    ${ARCH_EXT_LIST}
301    vpx_ports
302    pthread_h
303    unistd_h
304"
305EXPERIMENT_LIST="
306    fp_mb_stats
307    emulate_hardware
308    non_greedy_mv
309    rate_ctrl
310    collect_component_timing
311"
312CONFIG_LIST="
313    dependency_tracking
314    external_build
315    install_docs
316    install_bins
317    install_libs
318    install_srcs
319    debug
320    gprof
321    gcov
322    rvct
323    gcc
324    msvs
325    pic
326    big_endian
327
328    codec_srcs
329    debug_libs
330
331    dequant_tokens
332    dc_recon
333    runtime_cpu_detect
334    postproc
335    vp9_postproc
336    multithread
337    internal_stats
338    ${CODECS}
339    ${CODEC_FAMILIES}
340    encoders
341    decoders
342    static_msvcrt
343    spatial_resampling
344    realtime_only
345    onthefly_bitpacking
346    error_concealment
347    shared
348    static
349    small
350    postproc_visualizer
351    os_support
352    unit_tests
353    webm_io
354    libyuv
355    decode_perf_tests
356    encode_perf_tests
357    multi_res_encoding
358    temporal_denoising
359    vp9_temporal_denoising
360    coefficient_range_checking
361    vp9_highbitdepth
362    better_hw_compatibility
363    experimental
364    size_limit
365    always_adjust_bpm
366    bitstream_debug
367    mismatch_debug
368    ${EXPERIMENT_LIST}
369"
370CMDLINE_SELECT="
371    dependency_tracking
372    external_build
373    extra_warnings
374    werror
375    install_docs
376    install_bins
377    install_libs
378    install_srcs
379    debug
380    profile
381    gprof
382    gcov
383    pic
384    optimizations
385    ccache
386    runtime_cpu_detect
387    thumb
388
389    libs
390    examples
391    tools
392    docs
393    libc
394    as
395    size_limit
396    codec_srcs
397    debug_libs
398
399    dequant_tokens
400    dc_recon
401    postproc
402    vp9_postproc
403    multithread
404    internal_stats
405    ${CODECS}
406    ${CODEC_FAMILIES}
407    static_msvcrt
408    spatial_resampling
409    realtime_only
410    onthefly_bitpacking
411    error_concealment
412    shared
413    static
414    small
415    postproc_visualizer
416    unit_tests
417    webm_io
418    libyuv
419    decode_perf_tests
420    encode_perf_tests
421    multi_res_encoding
422    temporal_denoising
423    vp9_temporal_denoising
424    coefficient_range_checking
425    better_hw_compatibility
426    vp9_highbitdepth
427    experimental
428    always_adjust_bpm
429    bitstream_debug
430    mismatch_debug
431"
432
433process_cmdline() {
434    for opt do
435        optval="${opt#*=}"
436        case "$opt" in
437        --disable-codecs)
438          for c in ${CODEC_FAMILIES}; do disable_codec $c; done
439          ;;
440        --enable-?*|--disable-?*)
441        eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
442        if is_in ${option} ${EXPERIMENT_LIST}; then
443            if enabled experimental; then
444                ${action}_feature $option
445            else
446                log_echo "Ignoring $opt -- not in experimental mode."
447            fi
448        elif is_in ${option} "${CODECS} ${CODEC_FAMILIES}"; then
449            ${action}_codec ${option}
450        else
451            process_common_cmdline $opt
452        fi
453        ;;
454        *) process_common_cmdline "$opt"
455        ;;
456        esac
457    done
458}
459
460post_process_cmdline() {
461    if enabled coefficient_range_checking; then
462      echo "coefficient-range-checking is for decoders only, disabling encoders:"
463      soft_disable vp8_encoder
464      soft_disable vp9_encoder
465    fi
466
467    c=""
468
469    # Enable all detected codecs, if they haven't been disabled
470    for c in ${CODECS}; do soft_enable $c; done
471
472    # Enable the codec family if any component of that family is enabled
473    for c in ${CODECS}; do
474        enabled $c && enable_feature ${c%_*}
475    done
476
477    # Set the {en,de}coders variable if any algorithm in that class is enabled
478    for c in ${CODECS}; do
479        enabled ${c} && enable_feature ${c##*_}s
480    done
481}
482
483
484process_targets() {
485    enabled child || write_common_config_banner
486    write_common_target_config_h ${BUILD_PFX}vpx_config.h
487    write_common_config_targets
488    enabled win_arm64_neon_h_workaround && write_win_arm64_neon_h_workaround ${BUILD_PFX}arm_neon.h
489
490    # Calculate the default distribution name, based on the enabled features
491    cf=""
492    DIST_DIR=vpx
493    for cf in $CODEC_FAMILIES; do
494        if enabled ${cf}_encoder && enabled ${cf}_decoder; then
495            DIST_DIR="${DIST_DIR}-${cf}"
496        elif enabled ${cf}_encoder; then
497            DIST_DIR="${DIST_DIR}-${cf}cx"
498        elif enabled ${cf}_decoder; then
499            DIST_DIR="${DIST_DIR}-${cf}dx"
500        fi
501    done
502    enabled debug_libs && DIST_DIR="${DIST_DIR}-debug"
503    enabled codec_srcs && DIST_DIR="${DIST_DIR}-src"
504    ! enabled postproc && ! enabled vp9_postproc && DIST_DIR="${DIST_DIR}-nopost"
505    ! enabled multithread && DIST_DIR="${DIST_DIR}-nomt"
506    ! enabled install_docs && DIST_DIR="${DIST_DIR}-nodocs"
507    DIST_DIR="${DIST_DIR}-${tgt_isa}-${tgt_os}"
508    case "${tgt_os}" in
509    win*) enabled static_msvcrt && DIST_DIR="${DIST_DIR}mt" || DIST_DIR="${DIST_DIR}md"
510          DIST_DIR="${DIST_DIR}-${tgt_cc}"
511          ;;
512    esac
513    if [ -f "${source_path}/build/make/version.sh" ]; then
514        ver=`"$source_path/build/make/version.sh" --bare "$source_path"`
515        DIST_DIR="${DIST_DIR}-${ver}"
516        VERSION_STRING=${ver}
517        ver=${ver%%-*}
518        VERSION_PATCH=${ver##*.}
519        ver=${ver%.*}
520        VERSION_MINOR=${ver##*.}
521        ver=${ver#v}
522        VERSION_MAJOR=${ver%.*}
523    fi
524    enabled child || cat <<EOF >> config.mk
525
526PREFIX=${prefix}
527ifeq (\$(MAKECMDGOALS),dist)
528DIST_DIR?=${DIST_DIR}
529else
530DIST_DIR?=\$(DESTDIR)${prefix}
531endif
532LIBSUBDIR=${libdir##${prefix}/}
533
534VERSION_STRING=${VERSION_STRING}
535
536VERSION_MAJOR=${VERSION_MAJOR}
537VERSION_MINOR=${VERSION_MINOR}
538VERSION_PATCH=${VERSION_PATCH}
539
540CONFIGURE_ARGS=${CONFIGURE_ARGS}
541EOF
542    enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
543
544    #
545    # Write makefiles for all enabled targets
546    #
547    for tgt in libs examples tools docs solution; do
548        tgt_fn="$tgt-$toolchain.mk"
549
550        if enabled $tgt; then
551            echo "Creating makefiles for ${toolchain} ${tgt}"
552            write_common_target_config_mk $tgt_fn ${BUILD_PFX}vpx_config.h
553            #write_${tgt}_config
554        fi
555    done
556
557}
558
559process_detect() {
560    if enabled shared; then
561        # Can only build shared libs on a subset of platforms. Doing this check
562        # here rather than at option parse time because the target auto-detect
563        # magic happens after the command line has been parsed.
564        case "${tgt_os}" in
565        linux|os2|solaris|darwin*|iphonesimulator*)
566            # Supported platforms
567            ;;
568        *)
569            if enabled gnu; then
570                echo "--enable-shared is only supported on ELF; assuming this is OK"
571            else
572                die "--enable-shared only supported on ELF, OS/2, and Darwin for now"
573            fi
574            ;;
575        esac
576    fi
577    if [ -z "$CC" ] || enabled external_build; then
578        echo "Bypassing toolchain for environment detection."
579        enable_feature external_build
580        check_header() {
581            log fake_check_header "$@"
582            header=$1
583            shift
584            var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
585            disable_feature $var
586            # Headers common to all environments
587            case $header in
588                stdio.h)
589                    true;
590                ;;
591                *)
592                    result=false
593                    for d in "$@"; do
594                        [ -f "${d##-I}/$header" ] && result=true && break
595                    done
596                    ${result:-true}
597            esac && enable_feature $var
598
599            # Specialize windows and POSIX environments.
600            case $toolchain in
601                *-win*-*)
602                    # Don't check for any headers in Windows builds.
603                    false
604                ;;
605                *)
606                    case $header in
607                        pthread.h) true;;
608                        unistd.h) true;;
609                        *) false;;
610                    esac && enable_feature $var
611            esac
612            enabled $var
613        }
614        check_ld() {
615            true
616        }
617        check_lib() {
618            true
619        }
620    fi
621    check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
622    check_ld <<EOF || die "Toolchain is unable to link executables"
623int main(void) {return 0;}
624EOF
625    # check system headers
626
627    # Use both check_header and check_lib here, since check_lib
628    # could be a stub that always returns true.
629    check_header pthread.h && check_lib -lpthread <<EOF || disable_feature pthread_h
630#include <pthread.h>
631#include <stddef.h>
632int main(void) { return pthread_create(NULL, NULL, NULL, NULL); }
633EOF
634    check_header unistd.h # for sysconf(3) and friends.
635
636    check_header vpx/vpx_integer.h -I${source_path} && enable_feature vpx_ports
637
638    if enabled neon && ! enabled external_build; then
639      check_header arm_neon.h || die "Unable to find arm_neon.h"
640    fi
641}
642
643process_toolchain() {
644    process_common_toolchain
645
646    # Enable some useful compiler flags
647    if enabled gcc; then
648        enabled werror && check_add_cflags -Werror
649        check_add_cflags -Wall
650        check_add_cflags -Wdisabled-optimization
651        check_add_cflags -Wextra-semi
652        check_add_cflags -Wextra-semi-stmt
653        check_add_cflags -Wfloat-conversion
654        check_add_cflags -Wformat=2
655        check_add_cflags -Wparentheses-equality
656        check_add_cflags -Wpointer-arith
657        check_add_cflags -Wtype-limits
658        check_add_cflags -Wcast-qual
659        check_add_cflags -Wvla
660        check_add_cflags -Wimplicit-function-declaration
661        check_add_cflags -Wmissing-declarations
662        check_add_cflags -Wmissing-prototypes
663        check_add_cflags -Wshadow
664        check_add_cflags -Wstrict-prototypes
665        check_add_cflags -Wuninitialized
666        check_add_cflags -Wunreachable-code-aggressive
667        check_add_cflags -Wunused
668        check_add_cflags -Wextra
669        # check_add_cflags also adds to cxxflags. gtest does not do well with
670        # these flags so add them explicitly to CFLAGS only.
671        check_cflags -Wundef && add_cflags_only -Wundef
672        check_cflags -Wframe-larger-than=52000 && \
673          add_cflags_only -Wframe-larger-than=52000
674        if enabled mips || [ -z "${INLINE}" ]; then
675          enabled extra_warnings || check_add_cflags -Wno-unused-function
676        fi
677        # Enforce C99 for C files. Allow GNU extensions.
678        check_cflags -std=gnu99 && add_cflags_only -std=gnu99
679        # Avoid this warning for third_party C++ sources. Some reorganization
680        # would be needed to apply this only to test/*.cc.
681        check_cflags -Wshorten-64-to-32 && add_cflags_only -Wshorten-64-to-32
682
683        # Do not allow implicit vector type conversions on Clang builds (this
684        # is already the default on GCC builds).
685        check_add_cflags -flax-vector-conversions=none
686
687        # Quiet gcc 6 vs 7 abi warnings:
688        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
689        if enabled arm; then
690          check_add_cxxflags -Wno-psabi
691        fi
692
693        # Enforce C++11 compatibility.
694        check_add_cxxflags -Wc++14-extensions
695        check_add_cxxflags -Wc++17-extensions
696        check_add_cxxflags -Wc++20-extensions
697        check_add_cxxflags -Wnon-virtual-dtor
698
699        # disable some warnings specific to libyuv / libwebm.
700        check_cxxflags -Wno-missing-declarations \
701          && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-missing-declarations"
702        check_cxxflags -Wno-missing-prototypes \
703          && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-missing-prototypes"
704        check_cxxflags -Wno-pass-failed \
705          && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-pass-failed"
706        check_cxxflags -Wno-shadow \
707          && LIBWEBM_CXXFLAGS="${LIBWEBM_CXXFLAGS} -Wno-shadow" \
708          && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-shadow"
709        check_cxxflags -Wno-unused-parameter \
710          && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-unused-parameter"
711    fi
712
713    if enabled icc; then
714        enabled werror && check_add_cflags -Werror
715        check_add_cflags -Wall
716        check_add_cflags -Wpointer-arith
717
718        # ICC has a number of floating point optimizations that we disable
719        # in favor of deterministic output WRT to other compilers
720        add_cflags -fp-model precise
721    fi
722
723    # Enable extra, harmless warnings. These might provide additional insight
724    # to what the compiler is doing and why, but in general, but they shouldn't
725    # be treated as fatal, even if we're treating warnings as errors.
726    GCC_EXTRA_WARNINGS="
727        -Wdisabled-optimization
728        -Winline
729    "
730    enabled gcc && EXTRA_WARNINGS="${GCC_EXTRA_WARNINGS}"
731    RVCT_EXTRA_WARNINGS="
732        --remarks
733    "
734    enabled rvct && EXTRA_WARNINGS="${RVCT_EXTRA_WARNINGS}"
735    if enabled extra_warnings; then
736        for w in ${EXTRA_WARNINGS}; do
737            check_add_cflags ${w}
738            enabled gcc && enabled werror && check_add_cflags -Wno-error=${w}
739        done
740    fi
741
742    # ccache only really works on gcc toolchains
743    enabled gcc || soft_disable ccache
744    if enabled mips; then
745        enable_feature dequant_tokens
746        enable_feature dc_recon
747    fi
748
749    if enabled internal_stats; then
750        enable_feature vp9_postproc
751    fi
752
753    # Enable the postbuild target if building for visual studio.
754    case "$tgt_cc" in
755        vs*) enable_feature msvs
756             enable_feature solution
757             vs_version=${tgt_cc##vs}
758             VCPROJ_SFX=vcxproj
759             gen_vcproj_cmd=${source_path}/build/make/gen_msvs_vcxproj.sh
760             enabled werror && gen_vcproj_cmd="${gen_vcproj_cmd} --enable-werror"
761             all_targets="${all_targets} solution"
762             INLINE="__inline"
763        ;;
764    esac
765
766    # Other toolchain specific defaults
767    case $toolchain in x86*) soft_enable postproc;; esac
768
769    if enabled postproc_visualizer; then
770        enabled postproc || die "postproc_visualizer requires postproc to be enabled"
771    fi
772
773    # Enable unit tests by default if we have a working C++ compiler.
774    case "$toolchain" in
775        *-vs*)
776            soft_enable unit_tests
777            soft_enable webm_io
778            soft_enable libyuv
779        ;;
780        *-android-*)
781            check_add_cxxflags -std=gnu++11 && soft_enable webm_io
782            soft_enable libyuv
783            # GTestLog must be modified to use Android logging utilities.
784        ;;
785        *-darwin-*)
786            check_add_cxxflags -std=gnu++11
787            # iOS/ARM builds do not work with gtest. This does not match
788            # x86 targets.
789        ;;
790        *-iphonesimulator-*)
791            check_add_cxxflags -std=gnu++11 && soft_enable webm_io
792            soft_enable libyuv
793        ;;
794        *-win*)
795            # Some mingw toolchains don't have pthread available by default.
796            # Treat these more like visual studio where threading in gtest
797            # would be disabled for the same reason.
798            check_add_cxxflags -std=gnu++11 && soft_enable unit_tests \
799              && soft_enable webm_io
800            check_cxx "$@" <<EOF && soft_enable libyuv
801int z;
802EOF
803        ;;
804        *)
805            enabled pthread_h && check_add_cxxflags -std=gnu++11 \
806              && soft_enable unit_tests
807            check_add_cxxflags -std=gnu++11 && soft_enable webm_io
808            check_cxx "$@" <<EOF && soft_enable libyuv
809int z;
810EOF
811        ;;
812    esac
813    # libwebm needs to be linked with C++ standard library
814    enabled webm_io && LD=${CXX}
815
816    # append any user defined extra cflags
817    if [ -n "${extra_cflags}" ] ; then
818        check_add_cflags ${extra_cflags} || \
819        die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler"
820    fi
821    if [ -n "${extra_cxxflags}" ]; then
822        check_add_cxxflags ${extra_cxxflags} || \
823        die "Requested extra CXXFLAGS '${extra_cxxflags}' not supported by compiler"
824    fi
825}
826
827
828##
829## END APPLICATION SPECIFIC CONFIGURATION
830##
831CONFIGURE_ARGS="$@"
832process "$@"
833print_webm_license ${BUILD_PFX}vpx_config.c "/*" " */"
834cat <<EOF >> ${BUILD_PFX}vpx_config.c
835#include "vpx/vpx_codec.h"
836static const char* const cfg = "$CONFIGURE_ARGS";
837const char *vpx_codec_build_config(void) {return cfg;}
838EOF
839