5 ## This script is sourced by the main configure script and contains
6 ## utility functions and other common bits that aren't strictly libvpx
9 ## This build system is based in part on the FFmpeg configure script.
14 # Logging / Output Functions
17 echo "Unknown option \"$1\"."
18 echo "See $0 --help for available options."
26 echo "Configuration failed. This could reflect a misconfiguration of your"
27 echo "toolchains, improper options selected, or another problem. If you"
28 echo "don't see any useful error messages above, the next step is to look"
29 echo "at the configure error log file ($logfile) to determine what"
30 echo "configure was trying to do when it died."
53 echo "$@" >> ${outfile}
57 for opt in ${CMDLINE_SELECT}; do
58 opt2=`echo $opt | sed -e 's;_;-;g'`
60 eval "toggle_${opt}=\"--disable-${opt2}\""
62 eval "toggle_${opt}=\"--enable-${opt2} \""
67 Usage: configure [options]
71 --help print this message
72 --log=yes|no|FILE file configure log is written to [config.log]
73 --target=TARGET target platform tuple [generic-gnu]
74 --cpu=CPU optimize for a specific cpu rather than a family
75 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
76 --extra-cxxflags=ECXXFLAGS add ECXXFLAGS to CXXFLAGS [$CXXFLAGS]
77 ${toggle_extra_warnings} emit harmless warnings (always non-fatal)
78 ${toggle_werror} treat warnings as errors, if possible
79 (not available with all compilers)
80 ${toggle_optimizations} turn on/off compiler optimization flags
81 ${toggle_pic} turn on/off Position Independent Code
82 ${toggle_ccache} turn on/off compiler cache
83 ${toggle_debug} enable/disable debug mode
84 ${toggle_gprof} enable/disable gprof profiling instrumentation
85 ${toggle_gcov} enable/disable gcov coverage instrumentation
86 ${toggle_thumb} enable/disable building arm assembly in thumb mode
87 ${toggle_dependency_tracking}
88 disable to speed up one-time build
91 ${toggle_install_docs} control whether docs are installed
92 ${toggle_install_bins} control whether binaries are installed
93 ${toggle_install_libs} control whether libraries are installed
94 ${toggle_install_srcs} control whether sources are installed
105 Object files are built at the place where configure is launched.
107 All boolean options can be negated. The default value is the opposite
108 of that shown above. If the option --disable-foo is listed, then
109 the default value for foo is enabled.
113 show_targets ${all_platforms}
119 while [ -n "$*" ]; do
120 if [ "${1%%-*}" = "${2%%-*}" ]; then
121 if [ "${2%%-*}" = "${3%%-*}" ]; then
122 printf " %-24s %-24s %-24s\n" "$1" "$2" "$3"
125 printf " %-24s %-24s\n" "$1" "$2"
129 printf " %-24s\n" "$1"
141 # List Processing Functions
155 [ $var = $value ] && return 0
161 CFLAGS="${CFLAGS} $@"
162 CXXFLAGS="${CXXFLAGS} $@"
166 CFLAGS="${CFLAGS} $@"
169 add_cxxflags_only() {
170 CXXFLAGS="${CXXFLAGS} $@"
174 LDFLAGS="${LDFLAGS} $@"
178 ASFLAGS="${ASFLAGS} $@"
182 extralibs="${extralibs} $@"
186 # Boolean Manipulation Functions
198 eval test "x\$$1" = "xyes"
202 eval test "x\$$1" = "xno"
206 enabled "${1}" || echo " enabling ${1}"
207 enable_feature "${1}"
209 is_in "${1}" vp8 vp9 && enable_feature "${1}_encoder" "${1}_decoder"
213 disabled "${1}" || echo " disabling ${1}"
214 disable_feature "${1}"
216 is_in "${1}" vp8 vp9 && disable_feature "${1}_encoder" "${1}_decoder"
219 # Iterates through positional parameters, checks to confirm the parameter has
220 # not been explicitly (force) disabled, and enables the setting controlled by
221 # the parameter when the setting is not disabled.
222 # Note: Does NOT alter RTCD generation options ($RTCD_OPTIONS).
225 if ! disabled $var; then
226 enabled $var || log_echo " enabling $var"
232 # Iterates through positional parameters, checks to confirm the parameter has
233 # not been explicitly (force) enabled, and disables the setting controlled by
234 # the parameter when the setting is not enabled.
235 # Note: Does NOT alter RTCD generation options ($RTCD_OPTIONS).
238 if ! enabled $var; then
239 disabled $var || log_echo " disabling $var"
246 # Text Processing Functions
249 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
253 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
257 # Temporary File Functions
260 enable_feature source_path_used
261 if [ -z "$source_path" ] || [ "$source_path" = "." ]; then
263 disable_feature source_path_used
266 if test ! -z "$TMPDIR" ; then
268 elif test ! -z "$TEMPDIR" ; then
273 RAND=$(awk 'BEGIN { srand(); printf "%d\n",(rand() * 32768)}')
274 TMP_H="${TMPDIRx}/vpx-conf-$$-${RAND}.h"
275 TMP_C="${TMPDIRx}/vpx-conf-$$-${RAND}.c"
276 TMP_CC="${TMPDIRx}/vpx-conf-$$-${RAND}.cc"
277 TMP_O="${TMPDIRx}/vpx-conf-$$-${RAND}.o"
278 TMP_X="${TMPDIRx}/vpx-conf-$$-${RAND}.x"
279 TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RAND}.asm"
282 rm -f ${TMP_C} ${TMP_CC} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM}
283 enabled gcov && rm -f ${TMP_C%.c}.gcno ${TMP_CC%.cc}.gcno
287 # Toolchain Check Functions
290 enabled external_build && return
292 "$@" >>${logfile} 2>&1
299 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
306 check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_CC}
313 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
319 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
325 && check_cmd ${LD} ${LDFLAGS} -o ${TMP_X} ${TMP_O} "$@" ${extralibs}
329 log check_header "$@"
332 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
334 check_cpp "$@" <<EOF && enable_feature $var
341 log check_cflags "$@"
342 check_cc -Werror "$@" <<EOF
348 log check_cxxflags "$@"
350 # Catch CFLAGS that trigger CXX warnings
352 *c++-analyzer|*clang++|*g++*)
353 check_cxx -Werror "$@" <<EOF
358 check_cxx -Werror "$@" <<EOF
366 check_cxxflags "$@" && add_cxxflags_only "$@"
367 check_cflags "$@" && add_cflags_only "$@"
370 check_add_cxxflags() {
371 check_cxxflags "$@" && add_cxxflags_only "$@"
374 check_add_asflags() {
379 check_add_ldflags() {
385 log check_asm_align "$@"
386 cat >${TMP_ASM} <<EOF
391 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
392 readelf -WS ${TMP_O} >${TMP_X}
394 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
395 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
399 # tests for -m$1 toggling the feature given in $2. If $2 is empty $1 is used.
400 check_gcc_machine_option() {
403 [ -n "$feature" ] || feature="$opt"
405 if enabled gcc && ! disabled "$feature" && ! check_cflags "-m$opt"; then
406 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
408 soft_enable "$feature"
412 # tests for -m$2, -m$3, -m$4... toggling the feature given in $1.
413 check_gcc_machine_options() {
419 flags="$flags -m$opt"
422 if enabled gcc && ! disabled "$feature" && ! check_cflags $flags; then
423 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
425 soft_enable "$feature"
429 check_gcc_avx512_compiles() {
430 if disabled gcc; then
434 check_cc -mavx512f <<EOF
435 #include <immintrin.h>
437 __m512i x = _mm512_set1_epi16(0);
442 if [ ${compile_result} -ne 0 ]; then
443 log_echo " disabling avx512: not supported by compiler"
444 disable_feature avx512
445 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx512 "
449 write_common_config_banner() {
450 print_webm_license config.mk "##" ""
451 echo '# This file automatically generated by configure. Do not edit!' >> config.mk
452 echo "TOOLCHAIN := ${toolchain}" >> config.mk
456 echo "ALT_LIBC := ${alt_libc}" >> config.mk
461 write_common_config_targets() {
462 for t in ${all_targets}; do
463 if enabled ${t}; then
464 if enabled child; then
465 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
467 fwrite config.mk "ALL_TARGETS += ${t}"
475 write_common_target_config_mk() {
478 enabled ccache && CC="ccache ${CC}"
479 enabled ccache && CXX="ccache ${CXX}"
480 print_webm_license $1 "##" ""
483 # This file automatically generated by configure. Do not edit!
484 SRC_PATH="$source_path"
485 SRC_PATH_BARE=$source_path
486 BUILD_PFX=${BUILD_PFX}
487 TOOLCHAIN=${toolchain}
488 ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
489 GEN_VCPROJ=${gen_vcproj_cmd}
490 MSVS_ARCH_DIR=${msvs_arch_dir}
501 CXXFLAGS = ${CXXFLAGS}
502 ARFLAGS = -crs\$(if \$(quiet),,v)
505 extralibs = ${extralibs}
506 AS_SFX = ${AS_SFX:-.asm}
508 VCPROJ_SFX = ${VCPROJ_SFX}
509 RTCD_OPTIONS = ${RTCD_OPTIONS}
510 LIBYUV_CXXFLAGS = ${LIBYUV_CXXFLAGS}
513 if enabled rvct; then cat >> $1 << EOF
514 fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide
516 else cat >> $1 << EOF
517 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;'
521 print_config_mk VPX_ARCH "${1}" ${ARCH_LIST}
522 print_config_mk HAVE "${1}" ${HAVE_LIST}
523 print_config_mk CONFIG "${1}" ${CONFIG_LIST}
524 print_config_mk HAVE "${1}" gnu_strip
526 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
532 write_common_target_config_h() {
533 print_webm_license ${TMP_H} "/*" " */"
534 cat >> ${TMP_H} << EOF
535 /* This file automatically generated by configure. Do not edit! */
538 #define RESTRICT ${RESTRICT}
539 #define INLINE ${INLINE}
541 print_config_h VPX_ARCH "${TMP_H}" ${ARCH_LIST}
542 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
543 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
544 print_config_vars_h "${TMP_H}" ${VAR_LIST}
545 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
546 mkdir -p `dirname "$1"`
547 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
550 write_win_arm64_neon_h_workaround() {
551 print_webm_license ${TMP_H} "/*" " */"
552 cat >> ${TMP_H} << EOF
553 /* This file automatically generated by configure. Do not edit! */
554 #ifndef VPX_WIN_ARM_NEON_H_WORKAROUND
555 #define VPX_WIN_ARM_NEON_H_WORKAROUND
556 /* The Windows SDK has arm_neon.h, but unlike on other platforms it is
557 * ARM32-only. ARM64 NEON support is provided by arm64_neon.h, a proper
558 * superset of arm_neon.h. Work around this by providing a more local
559 * arm_neon.h that simply #includes arm64_neon.h.
561 #include <arm64_neon.h>
562 #endif /* VPX_WIN_ARM_NEON_H_WORKAROUND */
564 mkdir -p `dirname "$1"`
565 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
568 process_common_cmdline() {
577 if ! disabled logging ; then
578 enabled logging || logfile="$logging"
584 toolchain="${toolchain:-${optval}}"
587 toolchain="${toolchain:-${optval}}"
588 enable_feature force_toolchain
594 extra_cflags="${optval}"
597 extra_cxxflags="${optval}"
599 --enable-?*|--disable-?*)
600 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
601 if is_in ${option} ${ARCH_EXT_LIST}; then
602 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${option} "
603 elif [ $action = "disable" ] && ! disabled $option ; then
604 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
605 log_echo " disabling $option"
606 elif [ $action = "enable" ] && ! enabled $option ; then
607 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
608 log_echo " enabling $option"
610 ${action}_feature $option
613 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
614 if is_in ${option} ${ARCH_EXT_LIST}; then
615 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
620 --force-enable-?*|--force-disable-?*)
621 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
622 ${action}_feature $option
625 [ -d "${optval}" ] || die "Not a directory: ${optval}"
626 disable_feature builtin_libc
630 [ "${optval}" = yasm ] || [ "${optval}" = nasm ] \
631 || [ "${optval}" = auto ] \
632 || die "Must be yasm, nasm or auto: ${optval}"
638 VAR_LIST="DECODE_WIDTH_LIMIT ${w} DECODE_HEIGHT_LIMIT ${h}"
639 [ ${w} -gt 0 ] && [ ${h} -gt 0 ] || die "Invalid size-limit: too small."
640 [ ${w} -lt 65536 ] && [ ${h} -lt 65536 ] \
641 || die "Invalid size-limit: too big."
642 enable_feature size_limit
650 --libc|--as|--prefix|--libdir)
651 die "Option ${opt} requires argument"
668 process_common_cmdline $opt
674 post_process_common_cmdline() {
675 prefix="${prefix:-/usr/local}"
677 libdir="${libdir:-${prefix}/lib}"
679 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
680 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
684 post_process_cmdline() {
688 setup_gnu_toolchain() {
689 CC=${CC:-${CROSS}gcc}
690 CXX=${CXX:-${CROSS}g++}
692 LD=${LD:-${CROSS}${link_with_cc:-ld}}
694 STRIP=${STRIP:-${CROSS}strip}
700 # Reliably find the newest available Darwin SDKs. (Older versions of
701 # xcrun don't support --show-sdk-path.)
702 show_darwin_sdk_path() {
703 xcrun --sdk $1 --show-sdk-path 2>/dev/null ||
704 xcodebuild -sdk $1 -version Path 2>/dev/null
707 # Print the major version number of the Darwin SDK specified by $1.
708 show_darwin_sdk_major_version() {
709 xcrun --sdk $1 --show-sdk-version 2>/dev/null | cut -d. -f1
712 # Print the Xcode version.
713 show_xcode_version() {
714 xcodebuild -version | head -n1 | cut -d' ' -f2
717 # Fails when Xcode version is less than 6.3.
718 check_xcode_minimum_version() {
719 xcode_major=$(show_xcode_version | cut -f1 -d.)
720 xcode_minor=$(show_xcode_version | cut -f2 -d.)
723 if [ ${xcode_major} -lt ${xcode_min_major} ]; then
726 if [ ${xcode_major} -eq ${xcode_min_major} ] \
727 && [ ${xcode_minor} -lt ${xcode_min_minor} ]; then
732 process_common_toolchain() {
733 if [ -z "$toolchain" ]; then
734 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
740 armv7*-hardfloat* | armv7*-gnueabihf | arm-*-gnueabihf)
772 tgt_os=`echo $gcctarget | sed 's/.*\(darwin1[0-8]\).*/\1/'`
781 [ -z "$tgt_isa" ] && tgt_isa=x86
795 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
796 toolchain=${tgt_isa}-${tgt_os}-gcc
800 toolchain=${toolchain:-generic-gnu}
802 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
803 || die "Unrecognized toolchain '${toolchain}'"
805 enabled child || log_echo "Configuring for target '${toolchain}'"
808 # Set up toolchain variables
810 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
811 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
812 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
814 # Mark the specific ISA requested as enabled
815 soft_enable ${tgt_isa}
816 enable_feature ${tgt_os}
817 enable_feature ${tgt_cc}
819 # Enable the architecture family
832 # PIC is probably what we want when building shared libs
833 enabled shared && soft_enable pic
835 # Minimum iOS version for all target platforms (darwin and iphonesimulator).
836 # Shared library framework builds are only possible on iOS 8 and later.
837 if enabled shared; then
838 IOS_VERSION_OPTIONS="--enable-shared"
839 IOS_VERSION_MIN="8.0"
841 IOS_VERSION_OPTIONS=""
842 IOS_VERSION_MIN="7.0"
845 # Handle darwin variants. Newer SDKs allow targeting older
846 # platforms, so use the newest one available.
849 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
850 iphoneos_sdk_dir="$(show_darwin_sdk_path iphoneos)"
851 if [ -d "${iphoneos_sdk_dir}" ]; then
852 add_cflags "-isysroot ${iphoneos_sdk_dir}"
853 add_ldflags "-isysroot ${iphoneos_sdk_dir}"
857 osx_sdk_dir="$(show_darwin_sdk_path macosx)"
858 if [ -d "${osx_sdk_dir}" ]; then
859 add_cflags "-isysroot ${osx_sdk_dir}"
860 add_ldflags "-isysroot ${osx_sdk_dir}"
867 add_cflags "-mmacosx-version-min=10.4"
868 add_ldflags "-mmacosx-version-min=10.4"
871 add_cflags "-mmacosx-version-min=10.5"
872 add_ldflags "-mmacosx-version-min=10.5"
875 add_cflags "-mmacosx-version-min=10.6"
876 add_ldflags "-mmacosx-version-min=10.6"
879 add_cflags "-mmacosx-version-min=10.7"
880 add_ldflags "-mmacosx-version-min=10.7"
883 add_cflags "-mmacosx-version-min=10.8"
884 add_ldflags "-mmacosx-version-min=10.8"
887 add_cflags "-mmacosx-version-min=10.9"
888 add_ldflags "-mmacosx-version-min=10.9"
891 add_cflags "-mmacosx-version-min=10.10"
892 add_ldflags "-mmacosx-version-min=10.10"
895 add_cflags "-mmacosx-version-min=10.11"
896 add_ldflags "-mmacosx-version-min=10.11"
899 add_cflags "-mmacosx-version-min=10.12"
900 add_ldflags "-mmacosx-version-min=10.12"
903 add_cflags "-mmacosx-version-min=10.13"
904 add_ldflags "-mmacosx-version-min=10.13"
907 add_cflags "-mmacosx-version-min=10.14"
908 add_ldflags "-mmacosx-version-min=10.14"
911 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
912 add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
913 iossim_sdk_dir="$(show_darwin_sdk_path iphonesimulator)"
914 if [ -d "${iossim_sdk_dir}" ]; then
915 add_cflags "-isysroot ${iossim_sdk_dir}"
916 add_ldflags "-isysroot ${iossim_sdk_dir}"
921 # Handle Solaris variants. Solaris 10 needs -lposix4
924 add_extralibs -lposix4
927 add_extralibs -lposix4
931 # Process ARM architecture variants
934 # on arm, isa versions are supersets
941 # Only enable neon_asm when neon is also enabled.
942 enabled neon && soft_enable neon_asm
943 # If someone tries to force it through, die.
944 if disabled neon && enabled neon_asm; then
945 die "Disabling neon while keeping neon-asm is not supported"
950 asm_conversion_cmd="cat"
956 arch_int=${tgt_isa##armv}
957 arch_int=${arch_int%%te}
958 tune_cflags="-mtune="
959 if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then
960 if [ -z "${float_abi}" ]; then
961 check_cpp <<EOF && float_abi=hard || float_abi=softfp
962 #ifndef __ARM_PCS_VFP
967 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
968 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
970 if enabled neon || enabled neon_asm; then
971 check_add_cflags -mfpu=neon #-ftree-vectorize
972 check_add_asflags -mfpu=neon
974 elif [ ${tgt_isa} = "arm64" ] || [ ${tgt_isa} = "armv8" ]; then
975 check_add_cflags -march=armv8-a
976 check_add_asflags -march=armv8-a
978 check_add_cflags -march=${tgt_isa}
979 check_add_asflags -march=${tgt_isa}
982 enabled debug && add_asflags -g
983 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
987 asm_conversion_cmd="$asm_conversion_cmd -noelf"
994 if enabled thumb; then
995 asm_conversion_cmd="$asm_conversion_cmd -thumb"
996 check_add_cflags -mthumb
997 check_add_asflags -mthumb -mimplicit-it=always
1001 # A number of ARM-based Windows platforms are constrained by their
1002 # respective SDKs' limitations. Fortunately, these are all 32-bit ABIs
1003 # and so can be selected as 'win32'.
1004 if [ ${tgt_os} = "win32" ]; then
1005 asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
1007 msvs_arch_dir=arm-msvs
1008 disable_feature multithread
1009 disable_feature unit_tests
1010 if [ ${tgt_cc##vs} -ge 12 ]; then
1011 # MSVC 2013 doesn't allow doing plain .exe projects for ARM32,
1012 # only "AppContainerApplication" which requires an AppxManifest.
1013 # Therefore disable the examples, just build the library.
1014 disable_feature examples
1015 disable_feature tools
1018 # Windows 10 on ARM, on the other hand, has full Windows SDK support
1019 # for building Win32 ARM64 applications in addition to ARM64
1020 # Windows Store apps. It is the only 64-bit ARM ABI that
1021 # Windows supports, so it is the default definition of 'win64'.
1022 # ARM64 build support officially shipped in Visual Studio 15.9.0.
1024 # Because the ARM64 Windows SDK's arm_neon.h is ARM32-specific
1025 # while LLVM's is not, probe its validity.
1026 if enabled neon; then
1027 if [ -n "${CC}" ]; then
1028 check_header arm_neon.h || check_header arm64_neon.h && \
1029 enable_feature win_arm64_neon_h_workaround
1031 # If a probe is not possible, assume this is the pure Windows
1032 # SDK and so the workaround is necessary.
1033 enable_feature win_arm64_neon_h_workaround
1042 LD="${source_path}/build/make/armlink_adapter.sh"
1043 STRIP=arm-none-linux-gnueabi-strip
1044 NM=arm-none-linux-gnueabi-nm
1045 tune_cflags="--cpu="
1046 tune_asflags="--cpu="
1047 if [ -z "${tune_cpu}" ]; then
1048 if [ ${tgt_isa} = "armv7" ]; then
1049 if enabled neon || enabled neon_asm
1051 check_add_cflags --fpu=softvfp+vfpv3
1052 check_add_asflags --fpu=softvfp+vfpv3
1054 check_add_cflags --cpu=Cortex-A8
1055 check_add_asflags --cpu=Cortex-A8
1057 check_add_cflags --cpu=${tgt_isa##armv}
1058 check_add_asflags --cpu=${tgt_isa##armv}
1061 arch_int=${tgt_isa##armv}
1062 arch_int=${arch_int%%te}
1063 enabled debug && add_asflags -g
1065 add_cflags --enum_is_int
1066 add_cflags --wchar32
1072 disable_feature multithread
1073 disable_feature os_support
1077 echo "Assuming standalone build with NDK toolchain."
1078 echo "See build/make/Android.mk for details."
1079 check_add_ldflags -static
1080 soft_enable unit_tests
1084 if ! enabled external_build; then
1085 XCRUN_FIND="xcrun --sdk iphoneos --find"
1086 CXX="$(${XCRUN_FIND} clang++)"
1087 CC="$(${XCRUN_FIND} clang)"
1088 AR="$(${XCRUN_FIND} ar)"
1089 AS="$(${XCRUN_FIND} as)"
1090 STRIP="$(${XCRUN_FIND} strip)"
1091 NM="$(${XCRUN_FIND} nm)"
1092 RANLIB="$(${XCRUN_FIND} ranlib)"
1094 LD="${CXX:-$(${XCRUN_FIND} ld)}"
1096 # ASFLAGS is written here instead of using check_add_asflags
1097 # because we need to overwrite all of ASFLAGS and purge the
1098 # options that were put in above
1099 ASFLAGS="-arch ${tgt_isa} -g"
1101 add_cflags -arch ${tgt_isa}
1102 add_ldflags -arch ${tgt_isa}
1104 alt_libc="$(show_darwin_sdk_path iphoneos)"
1105 if [ -d "${alt_libc}" ]; then
1106 add_cflags -isysroot ${alt_libc}
1109 if [ "${LD}" = "${CXX}" ]; then
1110 add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}"
1112 add_ldflags -ios_version_min "${IOS_VERSION_MIN}"
1115 for d in lib usr/lib usr/lib/system; do
1116 try_dir="${alt_libc}/${d}"
1117 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
1121 armv7|armv7s|armv8|arm64)
1122 if enabled neon && ! check_xcode_minimum_version; then
1124 log_echo " neon disabled: upgrade Xcode (need v6.3+)."
1125 if enabled neon_asm; then
1126 soft_disable neon_asm
1127 log_echo " neon_asm disabled: upgrade Xcode (need v6.3+)."
1133 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
1135 if [ "$(show_darwin_sdk_major_version iphoneos)" -gt 8 ]; then
1136 check_add_cflags -fembed-bitcode
1137 check_add_asflags -fembed-bitcode
1138 check_add_ldflags -fembed-bitcode
1144 enable_feature linux
1145 if enabled rvct; then
1146 # Check if we have CodeSourcery GCC in PATH. Needed for
1148 which arm-none-linux-gnueabi-gcc 2>&- || \
1149 die "Couldn't find CodeSourcery GCC from PATH"
1151 # Use armcc as a linker to enable translation of
1152 # some gcc specific options such as -lm and -lpthread.
1153 LD="armcc --translate_gcc"
1155 # create configuration file (uses path to CodeSourcery GCC)
1156 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
1158 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1159 add_asflags --no_hide_all --apcs=/interwork
1160 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1161 enabled pic && add_cflags --apcs=/fpic
1162 enabled pic && add_asflags --apcs=/fpic
1163 enabled shared && add_cflags --shared
1171 tune_cflags="-mtune="
1172 if enabled dspr2; then
1173 check_add_cflags -mips32r2 -mdspr2
1176 if enabled runtime_cpu_detect; then
1177 disable_feature runtime_cpu_detect
1180 if [ -n "${tune_cpu}" ]; then
1183 check_add_cflags -mips32r5 -mload-store-pairs
1184 check_add_cflags -msched-weight -mhard-float -mfp64
1185 check_add_asflags -mips32r5 -mhard-float -mfp64
1186 check_add_ldflags -mfp64
1189 check_add_cflags -mips64r6 -mabi=64 -msched-weight
1190 check_add_cflags -mload-store-pairs -mhard-float -mfp64
1191 check_add_asflags -mips64r6 -mabi=64 -mhard-float -mfp64
1192 check_add_ldflags -mips64r6 -mabi=64 -mfp64
1196 if enabled msa; then
1198 # The new mips functions in libyuv do not build
1199 # with the toolchains we currently use for testing.
1208 if enabled mmi; then
1210 check_add_ldflags -march=loongson3a
1213 check_add_cflags -march=${tgt_isa}
1214 check_add_asflags -march=${tgt_isa}
1215 check_add_asflags -KPIC
1220 # Do not enable vsx by default.
1221 # https://bugs.chromium.org/p/webm/issues/detail?id=1522
1222 enabled vsx || RTCD_OPTIONS="${RTCD_OPTIONS}--disable-vsx "
1223 if [ -n "${tune_cpu}" ]; then
1226 tune_cflags="-mcpu="
1234 soft_enable realtime_only
1237 enabled gcc && add_cflags -fno-common
1240 CC=${CC:-${CROSS}gcc}
1241 CXX=${CXX:-${CROSS}g++}
1242 LD=${LD:-${CROSS}gcc}
1248 add_ldflags -Zhigh-mem
1252 AS="${alt_as:-${AS:-auto}}"
1258 add_cflags -use-msasm # remove -use-msasm too?
1259 # add -no-intel-extensions to suppress warning #10237
1260 # refer to http://software.intel.com/en-us/forums/topic/280199
1261 add_ldflags -i-static -no-intel-extensions
1262 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
1263 enabled x86_64 && AR=xiar
1267 tune_cpu="SSE3_ATOM"
1270 tune_cflags="-march="
1276 tune_cflags="-march="
1278 #for 32 bit x86 builds, -O3 did not turn on this flag
1279 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
1282 # When building with Microsoft Visual Studio the assembler is
1283 # invoked directly. Checking at configure time is unnecessary.
1284 # Skip the check by setting AS arbitrarily
1286 msvs_arch_dir=x86-msvs
1287 case ${tgt_cc##vs} in
1289 echo "${tgt_cc} does not support avx512, disabling....."
1290 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx512 "
1298 enabled x86_64 && bits=64
1299 check_cpp <<EOF && bits=x32
1300 #if !defined(__ILP32__) || !defined(__x86_64__)
1306 add_cflags -m${bits}
1307 add_ldflags -m${bits}
1311 soft_enable runtime_cpu_detect
1312 # We can't use 'check_cflags' until the compiler is configured and CC is
1314 for ext in ${ARCH_EXT_LIST_X86}; do
1315 # disable higher order extensions to simplify asm dependencies
1316 if [ "$disable_exts" = "yes" ]; then
1317 if ! disabled $ext; then
1318 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${ext} "
1319 disable_feature $ext
1321 elif disabled $ext; then
1324 if [ "$ext" = "avx512" ]; then
1325 check_gcc_machine_options $ext avx512f avx512cd avx512bw avx512dq avx512vl
1326 check_gcc_avx512_compiles
1328 # use the shortened version for the flag: sse4_1 -> sse4
1329 check_gcc_machine_option ${ext%_*} $ext
1334 if enabled external_build; then
1335 log_echo " skipping assembler detection"
1339 which nasm >/dev/null 2>&1 && AS=nasm
1340 which yasm >/dev/null 2>&1 && AS=yasm
1341 if [ "${AS}" = nasm ] ; then
1342 # Apple ships version 0.98 of nasm through at least Xcode 6. Revisit
1343 # this check if they start shipping a compatible version.
1344 apple=`nasm -v | grep "Apple"`
1346 && echo "Unsupported version of nasm: ${apple}" \
1349 [ "${AS}" = auto ] || [ -z "${AS}" ] \
1350 && die "Neither yasm nor nasm have been found." \
1351 "See the prerequisites section in the README for more info."
1354 log_echo " using $AS"
1359 add_asflags -f win32
1360 enabled debug && add_asflags -g cv8
1364 add_asflags -f win64
1365 enabled debug && add_asflags -g cv8
1368 linux*|solaris*|android*)
1369 add_asflags -f elf${bits}
1370 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1371 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1372 [ "${AS##*/}" = nasm ] && check_asm_align
1375 add_asflags -f macho${bits}
1376 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1377 add_cflags ${darwin_arch}
1378 add_ldflags ${darwin_arch}
1379 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1380 # one time, but does not seem to be now, and it breaks some of the
1381 # code that still relies on inline assembly.
1382 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1383 enabled icc && ! enabled pic && add_cflags -fno-pic
1386 add_asflags -f macho${bits}
1387 enabled x86 && sim_arch="-arch i386" || sim_arch="-arch x86_64"
1388 add_cflags ${sim_arch}
1389 add_ldflags ${sim_arch}
1391 if [ "$(disabled external_build)" ] &&
1392 [ "$(show_darwin_sdk_major_version iphonesimulator)" -gt 8 ]; then
1393 # yasm v1.3.0 doesn't know what -fembed-bitcode means, so turning it
1394 # on is pointless (unless building a C-only lib). Warn the user, but
1396 log "Warning: Bitcode embed disabled for simulator targets."
1401 enabled debug && add_asflags -g
1405 log "Warning: Unknown os $tgt_os while setting up $AS flags"
1416 # Try to enable CPU specific tuning
1417 if [ -n "${tune_cpu}" ]; then
1418 if [ -n "${tune_cflags}" ]; then
1419 check_add_cflags ${tune_cflags}${tune_cpu} || \
1420 die "Requested CPU '${tune_cpu}' not supported by compiler"
1422 if [ -n "${tune_asflags}" ]; then
1423 check_add_asflags ${tune_asflags}${tune_cpu} || \
1424 die "Requested CPU '${tune_cpu}' not supported by assembler"
1426 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1427 log_echo "Warning: CPU tuning not supported by this toolchain"
1431 if enabled debug; then
1432 check_add_cflags -g && check_add_ldflags -g
1434 check_add_cflags -DNDEBUG
1437 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1439 check_add_cflags -fprofile-arcs -ftest-coverage &&
1440 check_add_ldflags -fprofile-arcs -ftest-coverage
1442 if enabled optimizations; then
1443 if enabled rvct; then
1444 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1446 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1450 # Position Independent Code (PIC) support, for building relocatable
1452 enabled gcc && enabled pic && check_add_cflags -fPIC
1454 # Work around longjmp interception on glibc >= 2.11, to improve binary
1455 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1456 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1458 # Check for strip utility variant
1459 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
1461 # Try to determine target endianness
1463 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1465 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1466 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
1468 # Try to find which inline keywords are supported
1469 check_cc <<EOF && INLINE="inline"
1470 static inline function() {}
1473 # Almost every platform uses pthreads.
1474 if enabled multithread; then
1475 case ${toolchain} in
1479 # bionic includes basic pthread functionality, obviating -lpthread.
1482 check_header pthread.h && check_lib -lpthread <<EOF && add_extralibs -lpthread || disable_feature pthread_h
1483 #include <pthread.h>
1485 int main(void) { return pthread_create(NULL, NULL, NULL, NULL); }
1491 # only for MIPS platforms
1492 case ${toolchain} in
1494 if enabled big_endian; then
1495 if enabled dspr2; then
1496 echo "dspr2 optimizations are available only for little endian platforms"
1497 disable_feature dspr2
1499 if enabled msa; then
1500 echo "msa optimizations are available only for little endian platforms"
1503 if enabled mmi; then
1504 echo "mmi optimizations are available only for little endian platforms"
1512 if enabled linux; then
1513 add_cflags -D_LARGEFILE_SOURCE
1514 add_cflags -D_FILE_OFFSET_BITS=64
1518 process_toolchain() {
1519 process_common_toolchain
1523 saved_prefix="${prefix}"
1528 if enabled $cfg; then
1529 upname="`toupper $cfg`"
1530 echo "${prefix}_${upname}=yes" >> $makefile
1533 prefix="${saved_prefix}"
1537 saved_prefix="${prefix}"
1542 upname="`toupper $cfg`"
1543 if enabled $cfg; then
1544 echo "#define ${prefix}_${upname} 1" >> $header
1546 echo "#define ${prefix}_${upname} 0" >> $header
1549 prefix="${saved_prefix}"
1552 print_config_vars_h() {
1555 while [ $# -gt 0 ]; do
1556 upname="`toupper $1`"
1557 echo "#define ${upname} $2" >> $header
1562 print_webm_license() {
1563 saved_prefix="${prefix}"
1568 cat <<EOF > ${destination}
1569 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1571 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1572 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1573 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1574 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1575 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1577 prefix="${saved_prefix}"
1588 enable_feature logging
1589 logfile="config.log"
1593 process_cmdline "$@"
1594 if enabled child; then
1595 echo "# ${self} $@" >> ${logfile}
1597 echo "# ${self} $@" > ${logfile}
1599 post_process_common_cmdline
1600 post_process_cmdline
1605 OOT_INSTALLS="${OOT_INSTALLS}"
1606 if enabled source_path_used; then
1607 # Prepare the PWD for building.
1608 for f in ${OOT_INSTALLS}; do
1609 install -D "${source_path}/$f" "$f"
1612 cp "${source_path}/build/make/Makefile" .