5 kx #!/bin/sh
5 kx ##
5 kx ## configure
5 kx ##
5 kx ## This script is the front-end to the build system. It provides a similar
5 kx ## interface to standard configure scripts with some extra bits for dealing
5 kx ## with toolchains that differ from the standard POSIX interface and
5 kx ## for extracting subsets of the source tree. In theory, reusable parts
5 kx ## of this script were intended to live in build/make/configure.sh,
5 kx ## but in practice, the line is pretty blurry.
5 kx ##
5 kx ## This build system is based in part on the FFmpeg configure script.
5 kx ##
5 kx
5 kx #source_path="`dirname \"$0\"`"
5 kx source_path=${0%/*}
5 kx . "${source_path}/build/make/configure.sh"
5 kx
5 kx show_help(){
5 kx show_help_pre
5 kx cat << EOF
5 kx Advanced options:
5 kx ${toggle_libs} libraries
5 kx ${toggle_examples} examples
5 kx ${toggle_tools} tools
5 kx ${toggle_docs} documentation
5 kx ${toggle_unit_tests} unit tests
5 kx ${toggle_decode_perf_tests} build decoder perf tests with unit tests
5 kx ${toggle_encode_perf_tests} build encoder perf tests with unit tests
5 kx --cpu=CPU tune for the specified CPU (ARM: cortex-a8, X86: sse3)
5 kx --libc=PATH path to alternate libc
5 kx --size-limit=WxH max size to allow in the decoder
5 kx --as={yasm|nasm|auto} use specified assembler [auto, yasm preferred]
5 kx ${toggle_codec_srcs} in/exclude codec library source code
5 kx ${toggle_debug_libs} in/exclude debug version of libraries
5 kx ${toggle_static_msvcrt} use static MSVCRT (VS builds only)
5 kx ${toggle_vp9_highbitdepth} use VP9 high bit depth (10/12) profiles
5 kx ${toggle_better_hw_compatibility}
5 kx enable encoder to produce streams with better
5 kx hardware decoder compatibility
5 kx ${toggle_vp8} VP8 codec support
5 kx ${toggle_vp9} VP9 codec support
5 kx ${toggle_internal_stats} output of encoder internal stats for debug, if supported (encoders)
5 kx ${toggle_postproc} postprocessing
5 kx ${toggle_vp9_postproc} vp9 specific postprocessing
5 kx ${toggle_multithread} multithreaded encoding and decoding
5 kx ${toggle_spatial_resampling} spatial sampling (scaling) support
5 kx ${toggle_realtime_only} enable this option while building for real-time encoding
5 kx ${toggle_onthefly_bitpacking} enable on-the-fly bitpacking in real-time encoding
5 kx ${toggle_error_concealment} enable this option to get a decoder which is able to conceal losses
5 kx ${toggle_coefficient_range_checking}
5 kx enable decoder to check if intermediate
5 kx transform coefficients are in valid range
5 kx ${toggle_runtime_cpu_detect} runtime cpu detection
5 kx ${toggle_shared} shared library support
5 kx ${toggle_static} static library support
5 kx ${toggle_small} favor smaller size over speed
5 kx ${toggle_postproc_visualizer} macro block / block level visualizers
5 kx ${toggle_multi_res_encoding} enable multiple-resolution encoding
5 kx ${toggle_temporal_denoising} enable temporal denoising and disable the spatial denoiser
5 kx ${toggle_vp9_temporal_denoising}
5 kx enable vp9 temporal denoising
5 kx ${toggle_webm_io} enable input from and output to WebM container
5 kx ${toggle_libyuv} enable libyuv
5 kx
5 kx Codecs:
5 kx Codecs can be selectively enabled or disabled individually, or by family:
5 kx --disable-<codec>
5 kx is equivalent to:
5 kx --disable-<codec>-encoder
5 kx --disable-<codec>-decoder
5 kx
5 kx Codecs available in this distribution:
5 kx EOF
5 kx #restore editor state '
5 kx
5 kx family="";
5 kx last_family="";
5 kx c="";
5 kx str="";
5 kx for c in ${CODECS}; do
5 kx family=${c%_*}
5 kx if [ "${family}" != "${last_family}" ]; then
5 kx [ -z "${str}" ] || echo "${str}"
5 kx str="$(printf ' %10s:' ${family})"
5 kx fi
5 kx str="${str} $(printf '%10s' ${c#*_})"
5 kx last_family=${family}
5 kx done
5 kx echo "${str}"
5 kx show_help_post
5 kx }
5 kx
5 kx ##
5 kx ## BEGIN APPLICATION SPECIFIC CONFIGURATION
5 kx ##
5 kx
5 kx # all_platforms is a list of all supported target platforms. Maintain
5 kx # alphabetically by architecture, generic-gnu last.
5 kx all_platforms="${all_platforms} arm64-android-gcc"
5 kx all_platforms="${all_platforms} arm64-darwin-gcc"
5 kx all_platforms="${all_platforms} arm64-darwin20-gcc"
5 kx all_platforms="${all_platforms} arm64-darwin21-gcc"
5 kx all_platforms="${all_platforms} arm64-linux-gcc"
5 kx all_platforms="${all_platforms} arm64-win64-gcc"
5 kx all_platforms="${all_platforms} arm64-win64-vs15"
5 kx all_platforms="${all_platforms} armv7-android-gcc" #neon Cortex-A8
5 kx all_platforms="${all_platforms} armv7-darwin-gcc" #neon Cortex-A8
5 kx all_platforms="${all_platforms} armv7-linux-rvct" #neon Cortex-A8
5 kx all_platforms="${all_platforms} armv7-linux-gcc" #neon Cortex-A8
5 kx all_platforms="${all_platforms} armv7-none-rvct" #neon Cortex-A8
5 kx all_platforms="${all_platforms} armv7-win32-gcc"
5 kx all_platforms="${all_platforms} armv7-win32-vs14"
5 kx all_platforms="${all_platforms} armv7-win32-vs15"
5 kx all_platforms="${all_platforms} armv7s-darwin-gcc"
5 kx all_platforms="${all_platforms} armv8-linux-gcc"
5 kx all_platforms="${all_platforms} loongarch32-linux-gcc"
5 kx all_platforms="${all_platforms} loongarch64-linux-gcc"
5 kx all_platforms="${all_platforms} mips32-linux-gcc"
5 kx all_platforms="${all_platforms} mips32r2-linux-gcc"
5 kx all_platforms="${all_platforms} mips32r5-linux-gcc"
5 kx all_platforms="${all_platforms} mips64-linux-gcc"
5 kx all_platforms="${all_platforms} ppc64le-linux-gcc"
5 kx all_platforms="${all_platforms} riscv64-linux-gcc"
5 kx all_platforms="${all_platforms} sparc-solaris-gcc"
5 kx all_platforms="${all_platforms} x86-android-gcc"
5 kx all_platforms="${all_platforms} x86-darwin8-gcc"
5 kx all_platforms="${all_platforms} x86-darwin8-icc"
5 kx all_platforms="${all_platforms} x86-darwin9-gcc"
5 kx all_platforms="${all_platforms} x86-darwin9-icc"
5 kx all_platforms="${all_platforms} x86-darwin10-gcc"
5 kx all_platforms="${all_platforms} x86-darwin11-gcc"
5 kx all_platforms="${all_platforms} x86-darwin12-gcc"
5 kx all_platforms="${all_platforms} x86-darwin13-gcc"
5 kx all_platforms="${all_platforms} x86-darwin14-gcc"
5 kx all_platforms="${all_platforms} x86-darwin15-gcc"
5 kx all_platforms="${all_platforms} x86-darwin16-gcc"
5 kx all_platforms="${all_platforms} x86-darwin17-gcc"
5 kx all_platforms="${all_platforms} x86-iphonesimulator-gcc"
5 kx all_platforms="${all_platforms} x86-linux-gcc"
5 kx all_platforms="${all_platforms} x86-linux-icc"
5 kx all_platforms="${all_platforms} x86-os2-gcc"
5 kx all_platforms="${all_platforms} x86-solaris-gcc"
5 kx all_platforms="${all_platforms} x86-win32-gcc"
5 kx all_platforms="${all_platforms} x86-win32-vs14"
5 kx all_platforms="${all_platforms} x86-win32-vs15"
5 kx all_platforms="${all_platforms} x86-win32-vs16"
5 kx all_platforms="${all_platforms} x86-win32-vs17"
5 kx all_platforms="${all_platforms} x86_64-android-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin9-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin10-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin11-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin12-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin13-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin14-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin15-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin16-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin17-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin18-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin19-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin20-gcc"
5 kx all_platforms="${all_platforms} x86_64-darwin21-gcc"
5 kx all_platforms="${all_platforms} x86_64-iphonesimulator-gcc"
5 kx all_platforms="${all_platforms} x86_64-linux-gcc"
5 kx all_platforms="${all_platforms} x86_64-linux-icc"
5 kx all_platforms="${all_platforms} x86_64-solaris-gcc"
5 kx all_platforms="${all_platforms} x86_64-win64-gcc"
5 kx all_platforms="${all_platforms} x86_64-win64-vs14"
5 kx all_platforms="${all_platforms} x86_64-win64-vs15"
5 kx all_platforms="${all_platforms} x86_64-win64-vs16"
5 kx all_platforms="${all_platforms} x86_64-win64-vs17"
5 kx all_platforms="${all_platforms} generic-gnu"
5 kx
5 kx # all_targets is a list of all targets that can be configured
5 kx # note that these should be in dependency order for now.
5 kx all_targets="libs examples tools docs"
5 kx
5 kx # all targets available are enabled, by default.
5 kx for t in ${all_targets}; do
5 kx [ -f "${source_path}/${t}.mk" ] && enable_feature ${t}
5 kx done
5 kx
5 kx if ! diff --version >/dev/null; then
5 kx die "diff missing: Try installing diffutils via your package manager."
5 kx fi
5 kx
5 kx if ! perl --version >/dev/null; then
5 kx die "Perl is required to build"
5 kx fi
5 kx
5 kx if [ "`cd \"${source_path}\" && pwd`" != "`pwd`" ]; then
5 kx # test to see if source_path already configured
5 kx if [ -f "${source_path}/vpx_config.h" ]; then
5 kx die "source directory already configured; run 'make distclean' there first"
5 kx fi
5 kx fi
5 kx
5 kx # check installed doxygen version
5 kx doxy_version=$(doxygen --version 2>/dev/null)
5 kx doxy_major=${doxy_version%%.*}
5 kx if [ ${doxy_major:-0} -ge 1 ]; then
5 kx doxy_version=${doxy_version#*.}
5 kx doxy_minor=${doxy_version%%.*}
5 kx doxy_patch=${doxy_version##*.}
5 kx
5 kx [ $doxy_major -gt 1 ] && enable_feature doxygen
5 kx [ $doxy_minor -gt 5 ] && enable_feature doxygen
5 kx [ $doxy_minor -eq 5 ] && [ $doxy_patch -ge 3 ] && enable_feature doxygen
5 kx fi
5 kx
5 kx # disable codecs when their source directory does not exist
5 kx [ -d "${source_path}/vp8" ] || disable_codec vp8
5 kx [ -d "${source_path}/vp9" ] || disable_codec vp9
5 kx
5 kx # install everything except the sources, by default. sources will have
5 kx # to be enabled when doing dist builds, since that's no longer a common
5 kx # case.
5 kx enabled doxygen && enable_feature install_docs
5 kx enable_feature install_bins
5 kx enable_feature install_libs
5 kx
5 kx enable_feature static
5 kx enable_feature optimizations
5 kx enable_feature dependency_tracking
5 kx enable_feature spatial_resampling
5 kx enable_feature multithread
5 kx enable_feature os_support
5 kx enable_feature temporal_denoising
5 kx
5 kx CODECS="
5 kx vp8_encoder
5 kx vp8_decoder
5 kx vp9_encoder
5 kx vp9_decoder
5 kx "
5 kx CODEC_FAMILIES="
5 kx vp8
5 kx vp9
5 kx "
5 kx
5 kx ARCH_LIST="
5 kx arm
5 kx mips
5 kx x86
5 kx x86_64
5 kx ppc
5 kx loongarch
5 kx "
5 kx ARCH_EXT_LIST_X86="
5 kx mmx
5 kx sse
5 kx sse2
5 kx sse3
5 kx ssse3
5 kx sse4_1
5 kx avx
5 kx avx2
5 kx avx512
5 kx "
5 kx
5 kx ARCH_EXT_LIST_LOONGSON="
5 kx mmi
5 kx lsx
5 kx lasx
5 kx "
5 kx
5 kx ARCH_EXT_LIST="
5 kx neon
5 kx neon_asm
5 kx
5 kx mips32
5 kx dspr2
5 kx msa
5 kx mips64
5 kx
5 kx ${ARCH_EXT_LIST_X86}
5 kx
5 kx vsx
5 kx
5 kx ${ARCH_EXT_LIST_LOONGSON}
5 kx "
5 kx HAVE_LIST="
5 kx ${ARCH_EXT_LIST}
5 kx vpx_ports
5 kx pthread_h
5 kx unistd_h
5 kx "
5 kx EXPERIMENT_LIST="
5 kx fp_mb_stats
5 kx emulate_hardware
5 kx non_greedy_mv
5 kx rate_ctrl
5 kx "
5 kx CONFIG_LIST="
5 kx dependency_tracking
5 kx external_build
5 kx install_docs
5 kx install_bins
5 kx install_libs
5 kx install_srcs
5 kx debug
5 kx gprof
5 kx gcov
5 kx rvct
5 kx gcc
5 kx msvs
5 kx pic
5 kx big_endian
5 kx
5 kx codec_srcs
5 kx debug_libs
5 kx
5 kx dequant_tokens
5 kx dc_recon
5 kx runtime_cpu_detect
5 kx postproc
5 kx vp9_postproc
5 kx multithread
5 kx internal_stats
5 kx ${CODECS}
5 kx ${CODEC_FAMILIES}
5 kx encoders
5 kx decoders
5 kx static_msvcrt
5 kx spatial_resampling
5 kx realtime_only
5 kx onthefly_bitpacking
5 kx error_concealment
5 kx shared
5 kx static
5 kx small
5 kx postproc_visualizer
5 kx os_support
5 kx unit_tests
5 kx webm_io
5 kx libyuv
5 kx decode_perf_tests
5 kx encode_perf_tests
5 kx multi_res_encoding
5 kx temporal_denoising
5 kx vp9_temporal_denoising
5 kx consistent_recode
5 kx coefficient_range_checking
5 kx vp9_highbitdepth
5 kx better_hw_compatibility
5 kx experimental
5 kx size_limit
5 kx always_adjust_bpm
5 kx bitstream_debug
5 kx mismatch_debug
5 kx ${EXPERIMENT_LIST}
5 kx "
5 kx CMDLINE_SELECT="
5 kx dependency_tracking
5 kx external_build
5 kx extra_warnings
5 kx werror
5 kx install_docs
5 kx install_bins
5 kx install_libs
5 kx install_srcs
5 kx debug
5 kx gprof
5 kx gcov
5 kx pic
5 kx optimizations
5 kx ccache
5 kx runtime_cpu_detect
5 kx thumb
5 kx
5 kx libs
5 kx examples
5 kx tools
5 kx docs
5 kx libc
5 kx as
5 kx size_limit
5 kx codec_srcs
5 kx debug_libs
5 kx
5 kx dequant_tokens
5 kx dc_recon
5 kx postproc
5 kx vp9_postproc
5 kx multithread
5 kx internal_stats
5 kx ${CODECS}
5 kx ${CODEC_FAMILIES}
5 kx static_msvcrt
5 kx spatial_resampling
5 kx realtime_only
5 kx onthefly_bitpacking
5 kx error_concealment
5 kx shared
5 kx static
5 kx small
5 kx postproc_visualizer
5 kx unit_tests
5 kx webm_io
5 kx libyuv
5 kx decode_perf_tests
5 kx encode_perf_tests
5 kx multi_res_encoding
5 kx temporal_denoising
5 kx vp9_temporal_denoising
5 kx consistent_recode
5 kx coefficient_range_checking
5 kx better_hw_compatibility
5 kx vp9_highbitdepth
5 kx experimental
5 kx always_adjust_bpm
5 kx bitstream_debug
5 kx mismatch_debug
5 kx "
5 kx
5 kx process_cmdline() {
5 kx for opt do
5 kx optval="${opt#*=}"
5 kx case "$opt" in
5 kx --disable-codecs)
5 kx for c in ${CODEC_FAMILIES}; do disable_codec $c; done
5 kx ;;
5 kx --enable-?*|--disable-?*)
5 kx eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
5 kx if is_in ${option} ${EXPERIMENT_LIST}; then
5 kx if enabled experimental; then
5 kx ${action}_feature $option
5 kx else
5 kx log_echo "Ignoring $opt -- not in experimental mode."
5 kx fi
5 kx elif is_in ${option} "${CODECS} ${CODEC_FAMILIES}"; then
5 kx ${action}_codec ${option}
5 kx else
5 kx process_common_cmdline $opt
5 kx fi
5 kx ;;
5 kx *) process_common_cmdline "$opt"
5 kx ;;
5 kx esac
5 kx done
5 kx }
5 kx
5 kx post_process_cmdline() {
5 kx if enabled coefficient_range_checking; then
5 kx echo "coefficient-range-checking is for decoders only, disabling encoders:"
5 kx soft_disable vp8_encoder
5 kx soft_disable vp9_encoder
5 kx fi
5 kx
5 kx c=""
5 kx
5 kx # Enable all detected codecs, if they haven't been disabled
5 kx for c in ${CODECS}; do soft_enable $c; done
5 kx
5 kx # Enable the codec family if any component of that family is enabled
5 kx for c in ${CODECS}; do
5 kx enabled $c && enable_feature ${c%_*}
5 kx done
5 kx
5 kx # Set the {en,de}coders variable if any algorithm in that class is enabled
5 kx for c in ${CODECS}; do
5 kx enabled ${c} && enable_feature ${c##*_}s
5 kx done
5 kx }
5 kx
5 kx
5 kx process_targets() {
5 kx enabled child || write_common_config_banner
5 kx write_common_target_config_h ${BUILD_PFX}vpx_config.h
5 kx write_common_config_targets
5 kx enabled win_arm64_neon_h_workaround && write_win_arm64_neon_h_workaround ${BUILD_PFX}arm_neon.h
5 kx
5 kx # Calculate the default distribution name, based on the enabled features
5 kx cf=""
5 kx DIST_DIR=vpx
5 kx for cf in $CODEC_FAMILIES; do
5 kx if enabled ${cf}_encoder && enabled ${cf}_decoder; then
5 kx DIST_DIR="${DIST_DIR}-${cf}"
5 kx elif enabled ${cf}_encoder; then
5 kx DIST_DIR="${DIST_DIR}-${cf}cx"
5 kx elif enabled ${cf}_decoder; then
5 kx DIST_DIR="${DIST_DIR}-${cf}dx"
5 kx fi
5 kx done
5 kx enabled debug_libs && DIST_DIR="${DIST_DIR}-debug"
5 kx enabled codec_srcs && DIST_DIR="${DIST_DIR}-src"
5 kx ! enabled postproc && ! enabled vp9_postproc && DIST_DIR="${DIST_DIR}-nopost"
5 kx ! enabled multithread && DIST_DIR="${DIST_DIR}-nomt"
5 kx ! enabled install_docs && DIST_DIR="${DIST_DIR}-nodocs"
5 kx DIST_DIR="${DIST_DIR}-${tgt_isa}-${tgt_os}"
5 kx case "${tgt_os}" in
5 kx win*) enabled static_msvcrt && DIST_DIR="${DIST_DIR}mt" || DIST_DIR="${DIST_DIR}md"
5 kx DIST_DIR="${DIST_DIR}-${tgt_cc}"
5 kx ;;
5 kx esac
5 kx if [ -f "${source_path}/build/make/version.sh" ]; then
5 kx ver=`"$source_path/build/make/version.sh" --bare "$source_path"`
5 kx DIST_DIR="${DIST_DIR}-${ver}"
5 kx VERSION_STRING=${ver}
5 kx ver=${ver%%-*}
5 kx VERSION_PATCH=${ver##*.}
5 kx ver=${ver%.*}
5 kx VERSION_MINOR=${ver##*.}
5 kx ver=${ver#v}
5 kx VERSION_MAJOR=${ver%.*}
5 kx fi
5 kx enabled child || cat <<EOF >> config.mk
5 kx
5 kx PREFIX=${prefix}
5 kx ifeq (\$(MAKECMDGOALS),dist)
5 kx DIST_DIR?=${DIST_DIR}
5 kx else
5 kx DIST_DIR?=\$(DESTDIR)${prefix}
5 kx endif
5 kx LIBSUBDIR=${libdir##${prefix}/}
5 kx
5 kx VERSION_STRING=${VERSION_STRING}
5 kx
5 kx VERSION_MAJOR=${VERSION_MAJOR}
5 kx VERSION_MINOR=${VERSION_MINOR}
5 kx VERSION_PATCH=${VERSION_PATCH}
5 kx
5 kx CONFIGURE_ARGS=${CONFIGURE_ARGS}
5 kx EOF
5 kx enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
5 kx
5 kx #
5 kx # Write makefiles for all enabled targets
5 kx #
5 kx for tgt in libs examples tools docs solution; do
5 kx tgt_fn="$tgt-$toolchain.mk"
5 kx
5 kx if enabled $tgt; then
5 kx echo "Creating makefiles for ${toolchain} ${tgt}"
5 kx write_common_target_config_mk $tgt_fn ${BUILD_PFX}vpx_config.h
5 kx #write_${tgt}_config
5 kx fi
5 kx done
5 kx
5 kx }
5 kx
5 kx process_detect() {
5 kx if enabled shared; then
5 kx # Can only build shared libs on a subset of platforms. Doing this check
5 kx # here rather than at option parse time because the target auto-detect
5 kx # magic happens after the command line has been parsed.
5 kx case "${tgt_os}" in
5 kx linux|os2|solaris|darwin*|iphonesimulator*)
5 kx # Supported platforms
5 kx ;;
5 kx *)
5 kx if enabled gnu; then
5 kx echo "--enable-shared is only supported on ELF; assuming this is OK"
5 kx else
5 kx die "--enable-shared only supported on ELF, OS/2, and Darwin for now"
5 kx fi
5 kx ;;
5 kx esac
5 kx fi
5 kx if [ -z "$CC" ] || enabled external_build; then
5 kx echo "Bypassing toolchain for environment detection."
5 kx enable_feature external_build
5 kx check_header() {
5 kx log fake_check_header "$@"
5 kx header=$1
5 kx shift
5 kx var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
5 kx disable_feature $var
5 kx # Headers common to all environments
5 kx case $header in
5 kx stdio.h)
5 kx true;
5 kx ;;
5 kx *)
5 kx result=false
5 kx for d in "$@"; do
5 kx [ -f "${d##-I}/$header" ] && result=true && break
5 kx done
5 kx ${result:-true}
5 kx esac && enable_feature $var
5 kx
5 kx # Specialize windows and POSIX environments.
5 kx case $toolchain in
5 kx *-win*-*)
5 kx # Don't check for any headers in Windows builds.
5 kx false
5 kx ;;
5 kx *)
5 kx case $header in
5 kx pthread.h) true;;
5 kx unistd.h) true;;
5 kx *) false;;
5 kx esac && enable_feature $var
5 kx esac
5 kx enabled $var
5 kx }
5 kx check_ld() {
5 kx true
5 kx }
5 kx check_lib() {
5 kx true
5 kx }
5 kx fi
5 kx check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
5 kx check_ld <<EOF || die "Toolchain is unable to link executables"
5 kx int main(void) {return 0;}
5 kx EOF
5 kx # check system headers
5 kx
5 kx # Use both check_header and check_lib here, since check_lib
5 kx # could be a stub that always returns true.
5 kx check_header pthread.h && check_lib -lpthread <<EOF || disable_feature pthread_h
5 kx #include <pthread.h>
5 kx #include <stddef.h>
5 kx int main(void) { return pthread_create(NULL, NULL, NULL, NULL); }
5 kx EOF
5 kx check_header unistd.h # for sysconf(3) and friends.
5 kx
5 kx check_header vpx/vpx_integer.h -I${source_path} && enable_feature vpx_ports
5 kx
5 kx if enabled neon && ! enabled external_build; then
5 kx check_header arm_neon.h || die "Unable to find arm_neon.h"
5 kx fi
5 kx }
5 kx
5 kx process_toolchain() {
5 kx process_common_toolchain
5 kx
5 kx # Enable some useful compiler flags
5 kx if enabled gcc; then
5 kx enabled werror && check_add_cflags -Werror
5 kx check_add_cflags -Wall
5 kx check_add_cflags -Wdeclaration-after-statement
5 kx check_add_cflags -Wdisabled-optimization
5 kx check_add_cflags -Wextra-semi
5 kx check_add_cflags -Wextra-semi-stmt
5 kx check_add_cflags -Wfloat-conversion
5 kx check_add_cflags -Wformat=2
5 kx check_add_cflags -Wparentheses-equality
5 kx check_add_cflags -Wpointer-arith
5 kx check_add_cflags -Wtype-limits
5 kx check_add_cflags -Wcast-qual
5 kx check_add_cflags -Wvla
5 kx check_add_cflags -Wimplicit-function-declaration
5 kx check_add_cflags -Wmissing-declarations
5 kx check_add_cflags -Wmissing-prototypes
5 kx check_add_cflags -Wuninitialized
5 kx check_add_cflags -Wunreachable-code-loop-increment
5 kx check_add_cflags -Wunused
5 kx check_add_cflags -Wextra
5 kx # check_add_cflags also adds to cxxflags. gtest does not do well with
5 kx # these flags so add them explicitly to CFLAGS only.
5 kx check_cflags -Wundef && add_cflags_only -Wundef
5 kx check_cflags -Wframe-larger-than=52000 && \
5 kx add_cflags_only -Wframe-larger-than=52000
5 kx if enabled mips || [ -z "${INLINE}" ]; then
5 kx enabled extra_warnings || check_add_cflags -Wno-unused-function
5 kx fi
5 kx # Enforce c89 for c files. Don't be too strict about it though. Allow
5 kx # gnu extensions like "//" for comments.
5 kx check_cflags -std=gnu89 && add_cflags_only -std=gnu89
5 kx # Avoid this warning for third_party C++ sources. Some reorganization
5 kx # would be needed to apply this only to test/*.cc.
5 kx check_cflags -Wshorten-64-to-32 && add_cflags_only -Wshorten-64-to-32
5 kx
5 kx # Quiet gcc 6 vs 7 abi warnings:
5 kx # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
5 kx if enabled arm; then
5 kx check_add_cxxflags -Wno-psabi
5 kx fi
5 kx
5 kx # disable some warnings specific to libyuv.
5 kx check_cxxflags -Wno-missing-declarations \
5 kx && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-missing-declarations"
5 kx check_cxxflags -Wno-missing-prototypes \
5 kx && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-missing-prototypes"
5 kx check_cxxflags -Wno-unused-parameter \
5 kx && LIBYUV_CXXFLAGS="${LIBYUV_CXXFLAGS} -Wno-unused-parameter"
5 kx fi
5 kx
5 kx if enabled icc; then
5 kx enabled werror && check_add_cflags -Werror
5 kx check_add_cflags -Wall
5 kx check_add_cflags -Wpointer-arith
5 kx
5 kx # ICC has a number of floating point optimizations that we disable
5 kx # in favor of deterministic output WRT to other compilers
5 kx add_cflags -fp-model precise
5 kx fi
5 kx
5 kx # Enable extra, harmless warnings. These might provide additional insight
5 kx # to what the compiler is doing and why, but in general, but they shouldn't
5 kx # be treated as fatal, even if we're treating warnings as errors.
5 kx GCC_EXTRA_WARNINGS="
5 kx -Wdisabled-optimization
5 kx -Winline
5 kx "
5 kx enabled gcc && EXTRA_WARNINGS="${GCC_EXTRA_WARNINGS}"
5 kx RVCT_EXTRA_WARNINGS="
5 kx --remarks
5 kx "
5 kx enabled rvct && EXTRA_WARNINGS="${RVCT_EXTRA_WARNINGS}"
5 kx if enabled extra_warnings; then
5 kx for w in ${EXTRA_WARNINGS}; do
5 kx check_add_cflags ${w}
5 kx enabled gcc && enabled werror && check_add_cflags -Wno-error=${w}
5 kx done
5 kx fi
5 kx
5 kx # ccache only really works on gcc toolchains
5 kx enabled gcc || soft_disable ccache
5 kx if enabled mips; then
5 kx enable_feature dequant_tokens
5 kx enable_feature dc_recon
5 kx fi
5 kx
5 kx if enabled internal_stats; then
5 kx enable_feature vp9_postproc
5 kx fi
5 kx
5 kx # Enable the postbuild target if building for visual studio.
5 kx case "$tgt_cc" in
5 kx vs*) enable_feature msvs
5 kx enable_feature solution
5 kx vs_version=${tgt_cc##vs}
5 kx VCPROJ_SFX=vcxproj
5 kx gen_vcproj_cmd=${source_path}/build/make/gen_msvs_vcxproj.sh
5 kx enabled werror && gen_vcproj_cmd="${gen_vcproj_cmd} --enable-werror"
5 kx all_targets="${all_targets} solution"
5 kx INLINE="__inline"
5 kx ;;
5 kx esac
5 kx
5 kx # Other toolchain specific defaults
5 kx case $toolchain in x86*) soft_enable postproc;; esac
5 kx
5 kx if enabled postproc_visualizer; then
5 kx enabled postproc || die "postproc_visualizer requires postproc to be enabled"
5 kx fi
5 kx
5 kx # Enable unit tests by default if we have a working C++ compiler.
5 kx case "$toolchain" in
5 kx *-vs*)
5 kx soft_enable unit_tests
5 kx soft_enable webm_io
5 kx soft_enable libyuv
5 kx ;;
5 kx *-android-*)
5 kx check_add_cxxflags -std=gnu++11 && soft_enable webm_io
5 kx soft_enable libyuv
5 kx # GTestLog must be modified to use Android logging utilities.
5 kx ;;
5 kx *-darwin-*)
5 kx check_add_cxxflags -std=gnu++11
5 kx # iOS/ARM builds do not work with gtest. This does not match
5 kx # x86 targets.
5 kx ;;
5 kx *-iphonesimulator-*)
5 kx check_add_cxxflags -std=gnu++11 && soft_enable webm_io
5 kx soft_enable libyuv
5 kx ;;
5 kx *-win*)
5 kx # Some mingw toolchains don't have pthread available by default.
5 kx # Treat these more like visual studio where threading in gtest
5 kx # would be disabled for the same reason.
5 kx check_add_cxxflags -std=gnu++11 && soft_enable unit_tests \
5 kx && soft_enable webm_io
5 kx check_cxx "$@" <<EOF && soft_enable libyuv
5 kx int z;
5 kx EOF
5 kx ;;
5 kx *)
5 kx enabled pthread_h && check_add_cxxflags -std=gnu++11 \
5 kx && soft_enable unit_tests
5 kx check_add_cxxflags -std=gnu++11 && soft_enable webm_io
5 kx check_cxx "$@" <<EOF && soft_enable libyuv
5 kx int z;
5 kx EOF
5 kx ;;
5 kx esac
5 kx # libwebm needs to be linked with C++ standard library
5 kx enabled webm_io && LD=${CXX}
5 kx
5 kx # append any user defined extra cflags
5 kx if [ -n "${extra_cflags}" ] ; then
5 kx check_add_cflags ${extra_cflags} || \
5 kx die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler"
5 kx fi
5 kx if [ -n "${extra_cxxflags}" ]; then
5 kx check_add_cxxflags ${extra_cxxflags} || \
5 kx die "Requested extra CXXFLAGS '${extra_cxxflags}' not supported by compiler"
5 kx fi
5 kx }
5 kx
5 kx
5 kx ##
5 kx ## END APPLICATION SPECIFIC CONFIGURATION
5 kx ##
5 kx CONFIGURE_ARGS="$@"
5 kx process "$@"
5 kx print_webm_license ${BUILD_PFX}vpx_config.c "/*" " */"
5 kx cat <<EOF >> ${BUILD_PFX}vpx_config.c
5 kx #include "vpx/vpx_codec.h"
5 kx static const char* const cfg = "$CONFIGURE_ARGS";
5 kx const char *vpx_codec_build_config(void) {return cfg;}
5 kx EOF