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