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