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
265 # Makefiles greedily process the '#' character as a comment, even if it is
266 # inside quotes. So, this character must be escaped in all paths in Makefiles.
267 source_path_mk=$(echo $source_path | sed -e 's;\#;\\\#;g')
269 if test ! -z "$TMPDIR" ; then
271 elif test ! -z "$TEMPDIR" ; then
276 RAND=$(awk 'BEGIN { srand(); printf "%d\n",(rand() * 32768)}')
277 TMP_H="${TMPDIRx}/vpx-conf-$$-${RAND}.h"
278 TMP_C="${TMPDIRx}/vpx-conf-$$-${RAND}.c"
279 TMP_CC="${TMPDIRx}/vpx-conf-$$-${RAND}.cc"
280 TMP_O="${TMPDIRx}/vpx-conf-$$-${RAND}.o"
281 TMP_X="${TMPDIRx}/vpx-conf-$$-${RAND}.x"
282 TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RAND}.asm"
285 rm -f ${TMP_C} ${TMP_CC} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM}
286 enabled gcov && rm -f ${TMP_C%.c}.gcno ${TMP_CC%.cc}.gcno
290 # Toolchain Check Functions
293 enabled external_build && return
295 "$@" >>${logfile} 2>&1
302 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
309 check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_CC}
316 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
322 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
328 && check_cmd ${LD} ${LDFLAGS} -o ${TMP_X} ${TMP_O} "$@" ${extralibs}
332 log check_header "$@"
335 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
337 check_cpp "$@" <<EOF && enable_feature $var
344 log check_cflags "$@"
345 check_cc -Werror "$@" <<EOF
351 log check_cxxflags "$@"
353 # Catch CFLAGS that trigger CXX warnings
355 *c++-analyzer|*clang++|*g++*)
356 check_cxx -Werror "$@" <<EOF
361 check_cxx -Werror "$@" <<EOF
369 check_cxxflags "$@" && add_cxxflags_only "$@"
370 check_cflags "$@" && add_cflags_only "$@"
373 check_add_cxxflags() {
374 check_cxxflags "$@" && add_cxxflags_only "$@"
377 check_add_asflags() {
382 check_add_ldflags() {
388 log check_asm_align "$@"
389 cat >${TMP_ASM} <<EOF
394 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
395 readelf -WS ${TMP_O} >${TMP_X}
397 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
398 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
402 # tests for -m$1 toggling the feature given in $2. If $2 is empty $1 is used.
403 check_gcc_machine_option() {
406 [ -n "$feature" ] || feature="$opt"
408 if enabled gcc && ! disabled "$feature" && ! check_cflags "-m$opt"; then
409 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
411 soft_enable "$feature"
415 # tests for -m$2, -m$3, -m$4... toggling the feature given in $1.
416 check_gcc_machine_options() {
422 flags="$flags -m$opt"
425 if enabled gcc && ! disabled "$feature" && ! check_cflags $flags; then
426 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
428 soft_enable "$feature"
432 check_gcc_avx512_compiles() {
433 if disabled gcc; then
437 check_cc -mavx512f <<EOF
438 #include <immintrin.h>
440 __m512i x = _mm512_set1_epi16(0);
445 if [ ${compile_result} -ne 0 ]; then
446 log_echo " disabling avx512: not supported by compiler"
447 disable_feature avx512
448 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx512 "
452 write_common_config_banner() {
453 print_webm_license config.mk "##" ""
454 echo '# This file automatically generated by configure. Do not edit!' >> config.mk
455 echo "TOOLCHAIN := ${toolchain}" >> config.mk
459 echo "ALT_LIBC := ${alt_libc}" >> config.mk
464 write_common_config_targets() {
465 for t in ${all_targets}; do
466 if enabled ${t}; then
467 if enabled child; then
468 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
470 fwrite config.mk "ALL_TARGETS += ${t}"
478 write_common_target_config_mk() {
481 enabled ccache && CC="ccache ${CC}"
482 enabled ccache && CXX="ccache ${CXX}"
483 print_webm_license $1 "##" ""
486 # This file automatically generated by configure. Do not edit!
487 SRC_PATH="$source_path_mk"
488 SRC_PATH_BARE=$source_path_mk
489 BUILD_PFX=${BUILD_PFX}
490 TOOLCHAIN=${toolchain}
491 ASM_CONVERSION=${asm_conversion_cmd:-${source_path_mk}/build/make/ads2gas.pl}
492 GEN_VCPROJ=${gen_vcproj_cmd}
493 MSVS_ARCH_DIR=${msvs_arch_dir}
504 CXXFLAGS = ${CXXFLAGS}
505 ARFLAGS = -crs\$(if \$(quiet),,v)
508 extralibs = ${extralibs}
509 AS_SFX = ${AS_SFX:-.asm}
511 VCPROJ_SFX = ${VCPROJ_SFX}
512 RTCD_OPTIONS = ${RTCD_OPTIONS}
513 LIBYUV_CXXFLAGS = ${LIBYUV_CXXFLAGS}
516 if enabled rvct; then cat >> $1 << EOF
517 fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide
519 else cat >> $1 << EOF
520 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;'
524 print_config_mk VPX_ARCH "${1}" ${ARCH_LIST}
525 print_config_mk HAVE "${1}" ${HAVE_LIST}
526 print_config_mk CONFIG "${1}" ${CONFIG_LIST}
527 print_config_mk HAVE "${1}" gnu_strip
529 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
535 write_common_target_config_h() {
536 print_webm_license ${TMP_H} "/*" " */"
537 cat >> ${TMP_H} << EOF
538 /* This file automatically generated by configure. Do not edit! */
541 #define RESTRICT ${RESTRICT}
542 #define INLINE ${INLINE}
544 print_config_h VPX_ARCH "${TMP_H}" ${ARCH_LIST}
545 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
546 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
547 print_config_vars_h "${TMP_H}" ${VAR_LIST}
548 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
549 mkdir -p `dirname "$1"`
550 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
553 write_win_arm64_neon_h_workaround() {
554 print_webm_license ${TMP_H} "/*" " */"
555 cat >> ${TMP_H} << EOF
556 /* This file automatically generated by configure. Do not edit! */
557 #ifndef VPX_WIN_ARM_NEON_H_WORKAROUND
558 #define VPX_WIN_ARM_NEON_H_WORKAROUND
559 /* The Windows SDK has arm_neon.h, but unlike on other platforms it is
560 * ARM32-only. ARM64 NEON support is provided by arm64_neon.h, a proper
561 * superset of arm_neon.h. Work around this by providing a more local
562 * arm_neon.h that simply #includes arm64_neon.h.
564 #include <arm64_neon.h>
565 #endif /* VPX_WIN_ARM_NEON_H_WORKAROUND */
567 mkdir -p `dirname "$1"`
568 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
571 process_common_cmdline() {
580 if ! disabled logging ; then
581 enabled logging || logfile="$logging"
587 toolchain="${toolchain:-${optval}}"
590 toolchain="${toolchain:-${optval}}"
591 enable_feature force_toolchain
597 extra_cflags="${optval}"
600 extra_cxxflags="${optval}"
602 --enable-?*|--disable-?*)
603 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
604 if is_in ${option} ${ARCH_EXT_LIST}; then
605 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${option} "
606 elif [ $action = "disable" ] && ! disabled $option ; then
607 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
608 log_echo " disabling $option"
609 elif [ $action = "enable" ] && ! enabled $option ; then
610 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
611 log_echo " enabling $option"
613 ${action}_feature $option
616 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
617 if is_in ${option} ${ARCH_EXT_LIST}; then
618 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
623 --force-enable-?*|--force-disable-?*)
624 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
625 ${action}_feature $option
628 [ -d "${optval}" ] || die "Not a directory: ${optval}"
629 disable_feature builtin_libc
633 [ "${optval}" = yasm ] || [ "${optval}" = nasm ] \
634 || [ "${optval}" = auto ] \
635 || die "Must be yasm, nasm or auto: ${optval}"
641 VAR_LIST="DECODE_WIDTH_LIMIT ${w} DECODE_HEIGHT_LIMIT ${h}"
642 [ ${w} -gt 0 ] && [ ${h} -gt 0 ] || die "Invalid size-limit: too small."
643 [ ${w} -lt 65536 ] && [ ${h} -lt 65536 ] \
644 || die "Invalid size-limit: too big."
645 enable_feature size_limit
653 --libc|--as|--prefix|--libdir)
654 die "Option ${opt} requires argument"
671 process_common_cmdline $opt
677 post_process_common_cmdline() {
678 prefix="${prefix:-/usr/local}"
680 libdir="${libdir:-${prefix}/lib}"
682 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
683 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
687 post_process_cmdline() {
691 setup_gnu_toolchain() {
692 CC=${CC:-${CROSS}gcc}
693 CXX=${CXX:-${CROSS}g++}
695 LD=${LD:-${CROSS}${link_with_cc:-ld}}
697 STRIP=${STRIP:-${CROSS}strip}
703 # Reliably find the newest available Darwin SDKs. (Older versions of
704 # xcrun don't support --show-sdk-path.)
705 show_darwin_sdk_path() {
706 xcrun --sdk $1 --show-sdk-path 2>/dev/null ||
707 xcodebuild -sdk $1 -version Path 2>/dev/null
710 # Print the major version number of the Darwin SDK specified by $1.
711 show_darwin_sdk_major_version() {
712 xcrun --sdk $1 --show-sdk-version 2>/dev/null | cut -d. -f1
715 # Print the Xcode version.
716 show_xcode_version() {
717 xcodebuild -version | head -n1 | cut -d' ' -f2
720 # Fails when Xcode version is less than 6.3.
721 check_xcode_minimum_version() {
722 xcode_major=$(show_xcode_version | cut -f1 -d.)
723 xcode_minor=$(show_xcode_version | cut -f2 -d.)
726 if [ ${xcode_major} -lt ${xcode_min_major} ]; then
729 if [ ${xcode_major} -eq ${xcode_min_major} ] \
730 && [ ${xcode_minor} -lt ${xcode_min_minor} ]; then
735 process_common_toolchain() {
736 if [ -z "$toolchain" ]; then
737 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
743 armv7*-hardfloat* | armv7*-gnueabihf | arm-*-gnueabihf)
775 tgt_os=`echo $gcctarget | sed 's/.*\(darwin1[0-9]\).*/\1/'`
784 [ -z "$tgt_isa" ] && tgt_isa=x86
798 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
799 toolchain=${tgt_isa}-${tgt_os}-gcc
803 toolchain=${toolchain:-generic-gnu}
805 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
806 || die "Unrecognized toolchain '${toolchain}'"
808 enabled child || log_echo "Configuring for target '${toolchain}'"
811 # Set up toolchain variables
813 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
814 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
815 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
817 # Mark the specific ISA requested as enabled
818 soft_enable ${tgt_isa}
819 enable_feature ${tgt_os}
820 enable_feature ${tgt_cc}
822 # Enable the architecture family
835 # PIC is probably what we want when building shared libs
836 enabled shared && soft_enable pic
838 # Minimum iOS version for all target platforms (darwin and iphonesimulator).
839 # Shared library framework builds are only possible on iOS 8 and later.
840 if enabled shared; then
841 IOS_VERSION_OPTIONS="--enable-shared"
842 IOS_VERSION_MIN="8.0"
844 IOS_VERSION_OPTIONS=""
845 IOS_VERSION_MIN="7.0"
848 # Handle darwin variants. Newer SDKs allow targeting older
849 # platforms, so use the newest one available.
852 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
853 iphoneos_sdk_dir="$(show_darwin_sdk_path iphoneos)"
854 if [ -d "${iphoneos_sdk_dir}" ]; then
855 add_cflags "-isysroot ${iphoneos_sdk_dir}"
856 add_ldflags "-isysroot ${iphoneos_sdk_dir}"
860 osx_sdk_dir="$(show_darwin_sdk_path macosx)"
861 if [ -d "${osx_sdk_dir}" ]; then
862 add_cflags "-isysroot ${osx_sdk_dir}"
863 add_ldflags "-isysroot ${osx_sdk_dir}"
870 add_cflags "-mmacosx-version-min=10.4"
871 add_ldflags "-mmacosx-version-min=10.4"
874 add_cflags "-mmacosx-version-min=10.5"
875 add_ldflags "-mmacosx-version-min=10.5"
878 add_cflags "-mmacosx-version-min=10.6"
879 add_ldflags "-mmacosx-version-min=10.6"
882 add_cflags "-mmacosx-version-min=10.7"
883 add_ldflags "-mmacosx-version-min=10.7"
886 add_cflags "-mmacosx-version-min=10.8"
887 add_ldflags "-mmacosx-version-min=10.8"
890 add_cflags "-mmacosx-version-min=10.9"
891 add_ldflags "-mmacosx-version-min=10.9"
894 add_cflags "-mmacosx-version-min=10.10"
895 add_ldflags "-mmacosx-version-min=10.10"
898 add_cflags "-mmacosx-version-min=10.11"
899 add_ldflags "-mmacosx-version-min=10.11"
902 add_cflags "-mmacosx-version-min=10.12"
903 add_ldflags "-mmacosx-version-min=10.12"
906 add_cflags "-mmacosx-version-min=10.13"
907 add_ldflags "-mmacosx-version-min=10.13"
910 add_cflags "-mmacosx-version-min=10.14"
911 add_ldflags "-mmacosx-version-min=10.14"
914 add_cflags "-mmacosx-version-min=10.15"
915 add_ldflags "-mmacosx-version-min=10.15"
918 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
919 add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
920 iossim_sdk_dir="$(show_darwin_sdk_path iphonesimulator)"
921 if [ -d "${iossim_sdk_dir}" ]; then
922 add_cflags "-isysroot ${iossim_sdk_dir}"
923 add_ldflags "-isysroot ${iossim_sdk_dir}"
928 # Handle Solaris variants. Solaris 10 needs -lposix4
931 add_extralibs -lposix4
934 add_extralibs -lposix4
938 # Process ARM architecture variants
941 # on arm, isa versions are supersets
948 # Only enable neon_asm when neon is also enabled.
949 enabled neon && soft_enable neon_asm
950 # If someone tries to force it through, die.
951 if disabled neon && enabled neon_asm; then
952 die "Disabling neon while keeping neon-asm is not supported"
957 asm_conversion_cmd="cat"
963 arch_int=${tgt_isa##armv}
964 arch_int=${arch_int%%te}
965 tune_cflags="-mtune="
966 if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then
967 if [ -z "${float_abi}" ]; then
968 check_cpp <<EOF && float_abi=hard || float_abi=softfp
969 #ifndef __ARM_PCS_VFP
974 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
975 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
977 if enabled neon || enabled neon_asm; then
978 check_add_cflags -mfpu=neon #-ftree-vectorize
979 check_add_asflags -mfpu=neon
981 elif [ ${tgt_isa} = "arm64" ] || [ ${tgt_isa} = "armv8" ]; then
982 check_add_cflags -march=armv8-a
983 check_add_asflags -march=armv8-a
985 check_add_cflags -march=${tgt_isa}
986 check_add_asflags -march=${tgt_isa}
989 enabled debug && add_asflags -g
990 asm_conversion_cmd="${source_path_mk}/build/make/ads2gas.pl"
994 asm_conversion_cmd="$asm_conversion_cmd -noelf"
1001 if enabled thumb; then
1002 asm_conversion_cmd="$asm_conversion_cmd -thumb"
1003 check_add_cflags -mthumb
1004 check_add_asflags -mthumb -mimplicit-it=always
1008 # A number of ARM-based Windows platforms are constrained by their
1009 # respective SDKs' limitations. Fortunately, these are all 32-bit ABIs
1010 # and so can be selected as 'win32'.
1011 if [ ${tgt_os} = "win32" ]; then
1012 asm_conversion_cmd="${source_path_mk}/build/make/ads2armasm_ms.pl"
1014 msvs_arch_dir=arm-msvs
1015 disable_feature multithread
1016 disable_feature unit_tests
1017 if [ ${tgt_cc##vs} -ge 12 ]; then
1018 # MSVC 2013 doesn't allow doing plain .exe projects for ARM32,
1019 # only "AppContainerApplication" which requires an AppxManifest.
1020 # Therefore disable the examples, just build the library.
1021 disable_feature examples
1022 disable_feature tools
1025 # Windows 10 on ARM, on the other hand, has full Windows SDK support
1026 # for building Win32 ARM64 applications in addition to ARM64
1027 # Windows Store apps. It is the only 64-bit ARM ABI that
1028 # Windows supports, so it is the default definition of 'win64'.
1029 # ARM64 build support officially shipped in Visual Studio 15.9.0.
1031 # Because the ARM64 Windows SDK's arm_neon.h is ARM32-specific
1032 # while LLVM's is not, probe its validity.
1033 if enabled neon; then
1034 if [ -n "${CC}" ]; then
1035 check_header arm_neon.h || check_header arm64_neon.h && \
1036 enable_feature win_arm64_neon_h_workaround
1038 # If a probe is not possible, assume this is the pure Windows
1039 # SDK and so the workaround is necessary.
1040 enable_feature win_arm64_neon_h_workaround
1049 LD="${source_path}/build/make/armlink_adapter.sh"
1050 STRIP=arm-none-linux-gnueabi-strip
1051 NM=arm-none-linux-gnueabi-nm
1052 tune_cflags="--cpu="
1053 tune_asflags="--cpu="
1054 if [ -z "${tune_cpu}" ]; then
1055 if [ ${tgt_isa} = "armv7" ]; then
1056 if enabled neon || enabled neon_asm
1058 check_add_cflags --fpu=softvfp+vfpv3
1059 check_add_asflags --fpu=softvfp+vfpv3
1061 check_add_cflags --cpu=Cortex-A8
1062 check_add_asflags --cpu=Cortex-A8
1064 check_add_cflags --cpu=${tgt_isa##armv}
1065 check_add_asflags --cpu=${tgt_isa##armv}
1068 arch_int=${tgt_isa##armv}
1069 arch_int=${arch_int%%te}
1070 enabled debug && add_asflags -g
1072 add_cflags --enum_is_int
1073 add_cflags --wchar32
1079 disable_feature multithread
1080 disable_feature os_support
1084 echo "Assuming standalone build with NDK toolchain."
1085 echo "See build/make/Android.mk for details."
1086 check_add_ldflags -static
1087 soft_enable unit_tests
1091 if ! enabled external_build; then
1092 XCRUN_FIND="xcrun --sdk iphoneos --find"
1093 CXX="$(${XCRUN_FIND} clang++)"
1094 CC="$(${XCRUN_FIND} clang)"
1095 AR="$(${XCRUN_FIND} ar)"
1096 AS="$(${XCRUN_FIND} as)"
1097 STRIP="$(${XCRUN_FIND} strip)"
1098 NM="$(${XCRUN_FIND} nm)"
1099 RANLIB="$(${XCRUN_FIND} ranlib)"
1101 LD="${CXX:-$(${XCRUN_FIND} ld)}"
1103 # ASFLAGS is written here instead of using check_add_asflags
1104 # because we need to overwrite all of ASFLAGS and purge the
1105 # options that were put in above
1106 ASFLAGS="-arch ${tgt_isa} -g"
1108 add_cflags -arch ${tgt_isa}
1109 add_ldflags -arch ${tgt_isa}
1111 alt_libc="$(show_darwin_sdk_path iphoneos)"
1112 if [ -d "${alt_libc}" ]; then
1113 add_cflags -isysroot ${alt_libc}
1116 if [ "${LD}" = "${CXX}" ]; then
1117 add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}"
1119 add_ldflags -ios_version_min "${IOS_VERSION_MIN}"
1122 for d in lib usr/lib usr/lib/system; do
1123 try_dir="${alt_libc}/${d}"
1124 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
1128 armv7|armv7s|armv8|arm64)
1129 if enabled neon && ! check_xcode_minimum_version; then
1131 log_echo " neon disabled: upgrade Xcode (need v6.3+)."
1132 if enabled neon_asm; then
1133 soft_disable neon_asm
1134 log_echo " neon_asm disabled: upgrade Xcode (need v6.3+)."
1140 if [ "$(show_darwin_sdk_major_version iphoneos)" -gt 8 ]; then
1141 check_add_cflags -fembed-bitcode
1142 check_add_asflags -fembed-bitcode
1143 check_add_ldflags -fembed-bitcode
1147 asm_conversion_cmd="${source_path_mk}/build/make/ads2gas_apple.pl"
1151 enable_feature linux
1152 if enabled rvct; then
1153 # Check if we have CodeSourcery GCC in PATH. Needed for
1155 which arm-none-linux-gnueabi-gcc 2>&- || \
1156 die "Couldn't find CodeSourcery GCC from PATH"
1158 # Use armcc as a linker to enable translation of
1159 # some gcc specific options such as -lm and -lpthread.
1160 LD="armcc --translate_gcc"
1162 # create configuration file (uses path to CodeSourcery GCC)
1163 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
1165 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1166 add_asflags --no_hide_all --apcs=/interwork
1167 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1168 enabled pic && add_cflags --apcs=/fpic
1169 enabled pic && add_asflags --apcs=/fpic
1170 enabled shared && add_cflags --shared
1178 tune_cflags="-mtune="
1179 if enabled dspr2; then
1180 check_add_cflags -mips32r2 -mdspr2
1183 if enabled runtime_cpu_detect; then
1184 disable_feature runtime_cpu_detect
1187 if [ -n "${tune_cpu}" ]; then
1190 check_add_cflags -mips32r5 -mload-store-pairs
1191 check_add_cflags -msched-weight -mhard-float -mfp64
1192 check_add_asflags -mips32r5 -mhard-float -mfp64
1193 check_add_ldflags -mfp64
1196 check_add_cflags -mips64r6 -mabi=64 -msched-weight
1197 check_add_cflags -mload-store-pairs -mhard-float -mfp64
1198 check_add_asflags -mips64r6 -mabi=64 -mhard-float -mfp64
1199 check_add_ldflags -mips64r6 -mabi=64 -mfp64
1202 check_cflags -march=loongson3a && soft_enable mmi \
1203 || disable_feature mmi
1204 check_cflags -mmsa && soft_enable msa \
1205 || disable_feature msa
1210 if enabled mmi || enabled msa; then
1211 soft_enable runtime_cpu_detect
1214 if enabled msa; then
1216 # The new mips functions in libyuv do not build
1217 # with the toolchains we currently use for testing.
1222 check_add_cflags -march=${tgt_isa}
1223 check_add_asflags -march=${tgt_isa}
1224 check_add_asflags -KPIC
1229 # Do not enable vsx by default.
1230 # https://bugs.chromium.org/p/webm/issues/detail?id=1522
1231 enabled vsx || RTCD_OPTIONS="${RTCD_OPTIONS}--disable-vsx "
1232 if [ -n "${tune_cpu}" ]; then
1235 tune_cflags="-mcpu="
1243 soft_enable realtime_only
1246 enabled gcc && add_cflags -fno-common
1249 CC=${CC:-${CROSS}gcc}
1250 CXX=${CXX:-${CROSS}g++}
1251 LD=${LD:-${CROSS}gcc}
1257 add_ldflags -Zhigh-mem
1261 AS="${alt_as:-${AS:-auto}}"
1267 add_cflags -use-msasm # remove -use-msasm too?
1268 # add -no-intel-extensions to suppress warning #10237
1269 # refer to http://software.intel.com/en-us/forums/topic/280199
1270 add_ldflags -i-static -no-intel-extensions
1271 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
1272 enabled x86_64 && AR=xiar
1276 tune_cpu="SSE3_ATOM"
1279 tune_cflags="-march="
1285 tune_cflags="-march="
1287 #for 32 bit x86 builds, -O3 did not turn on this flag
1288 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
1291 # When building with Microsoft Visual Studio the assembler is
1292 # invoked directly. Checking at configure time is unnecessary.
1293 # Skip the check by setting AS arbitrarily
1295 msvs_arch_dir=x86-msvs
1296 case ${tgt_cc##vs} in
1298 echo "${tgt_cc} does not support avx512, disabling....."
1299 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx512 "
1307 enabled x86_64 && bits=64
1308 check_cpp <<EOF && bits=x32
1309 #if !defined(__ILP32__) || !defined(__x86_64__)
1315 add_cflags -m${bits}
1316 add_ldflags -m${bits}
1320 soft_enable runtime_cpu_detect
1321 # We can't use 'check_cflags' until the compiler is configured and CC is
1323 for ext in ${ARCH_EXT_LIST_X86}; do
1324 # disable higher order extensions to simplify asm dependencies
1325 if [ "$disable_exts" = "yes" ]; then
1326 if ! disabled $ext; then
1327 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${ext} "
1328 disable_feature $ext
1330 elif disabled $ext; then
1333 if [ "$ext" = "avx512" ]; then
1334 check_gcc_machine_options $ext avx512f avx512cd avx512bw avx512dq avx512vl
1335 check_gcc_avx512_compiles
1337 # use the shortened version for the flag: sse4_1 -> sse4
1338 check_gcc_machine_option ${ext%_*} $ext
1343 if enabled external_build; then
1344 log_echo " skipping assembler detection"
1348 which nasm >/dev/null 2>&1 && AS=nasm
1349 which yasm >/dev/null 2>&1 && AS=yasm
1350 if [ "${AS}" = nasm ] ; then
1351 # Apple ships version 0.98 of nasm through at least Xcode 6. Revisit
1352 # this check if they start shipping a compatible version.
1353 apple=`nasm -v | grep "Apple"`
1355 && echo "Unsupported version of nasm: ${apple}" \
1358 [ "${AS}" = auto ] || [ -z "${AS}" ] \
1359 && die "Neither yasm nor nasm have been found." \
1360 "See the prerequisites section in the README for more info."
1363 log_echo " using $AS"
1368 add_asflags -f win32
1369 enabled debug && add_asflags -g cv8
1373 add_asflags -f win64
1374 enabled debug && add_asflags -g cv8
1377 linux*|solaris*|android*)
1378 add_asflags -f elf${bits}
1379 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1380 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1381 [ "${AS##*/}" = nasm ] && check_asm_align
1384 add_asflags -f macho${bits}
1385 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1386 add_cflags ${darwin_arch}
1387 add_ldflags ${darwin_arch}
1388 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1389 # one time, but does not seem to be now, and it breaks some of the
1390 # code that still relies on inline assembly.
1391 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1392 enabled icc && ! enabled pic && add_cflags -fno-pic
1395 add_asflags -f macho${bits}
1396 enabled x86 && sim_arch="-arch i386" || sim_arch="-arch x86_64"
1397 add_cflags ${sim_arch}
1398 add_ldflags ${sim_arch}
1400 if [ "$(disabled external_build)" ] &&
1401 [ "$(show_darwin_sdk_major_version iphonesimulator)" -gt 8 ]; then
1402 # yasm v1.3.0 doesn't know what -fembed-bitcode means, so turning it
1403 # on is pointless (unless building a C-only lib). Warn the user, but
1405 log "Warning: Bitcode embed disabled for simulator targets."
1410 enabled debug && add_asflags -g
1414 log "Warning: Unknown os $tgt_os while setting up $AS flags"
1425 # Try to enable CPU specific tuning
1426 if [ -n "${tune_cpu}" ]; then
1427 if [ -n "${tune_cflags}" ]; then
1428 check_add_cflags ${tune_cflags}${tune_cpu} || \
1429 die "Requested CPU '${tune_cpu}' not supported by compiler"
1431 if [ -n "${tune_asflags}" ]; then
1432 check_add_asflags ${tune_asflags}${tune_cpu} || \
1433 die "Requested CPU '${tune_cpu}' not supported by assembler"
1435 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1436 log_echo "Warning: CPU tuning not supported by this toolchain"
1440 if enabled debug; then
1441 check_add_cflags -g && check_add_ldflags -g
1443 check_add_cflags -DNDEBUG
1446 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1448 check_add_cflags -fprofile-arcs -ftest-coverage &&
1449 check_add_ldflags -fprofile-arcs -ftest-coverage
1451 if enabled optimizations; then
1452 if enabled rvct; then
1453 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1455 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1459 # Position Independent Code (PIC) support, for building relocatable
1461 enabled gcc && enabled pic && check_add_cflags -fPIC
1463 # Work around longjmp interception on glibc >= 2.11, to improve binary
1464 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1465 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1467 # Check for strip utility variant
1468 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
1470 # Try to determine target endianness
1472 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1474 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1475 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
1477 # Try to find which inline keywords are supported
1478 check_cc <<EOF && INLINE="inline"
1479 static inline function() {}
1482 # Almost every platform uses pthreads.
1483 if enabled multithread; then
1484 case ${toolchain} in
1488 # bionic includes basic pthread functionality, obviating -lpthread.
1491 check_header pthread.h && check_lib -lpthread <<EOF && add_extralibs -lpthread || disable_feature pthread_h
1492 #include <pthread.h>
1494 int main(void) { return pthread_create(NULL, NULL, NULL, NULL); }
1500 # only for MIPS platforms
1501 case ${toolchain} in
1503 if enabled big_endian; then
1504 if enabled dspr2; then
1505 echo "dspr2 optimizations are available only for little endian platforms"
1506 disable_feature dspr2
1508 if enabled msa; then
1509 echo "msa optimizations are available only for little endian platforms"
1512 if enabled mmi; then
1513 echo "mmi optimizations are available only for little endian platforms"
1521 if enabled linux; then
1522 add_cflags -D_LARGEFILE_SOURCE
1523 add_cflags -D_FILE_OFFSET_BITS=64
1527 process_toolchain() {
1528 process_common_toolchain
1532 saved_prefix="${prefix}"
1537 if enabled $cfg; then
1538 upname="`toupper $cfg`"
1539 echo "${prefix}_${upname}=yes" >> $makefile
1542 prefix="${saved_prefix}"
1546 saved_prefix="${prefix}"
1551 upname="`toupper $cfg`"
1552 if enabled $cfg; then
1553 echo "#define ${prefix}_${upname} 1" >> $header
1555 echo "#define ${prefix}_${upname} 0" >> $header
1558 prefix="${saved_prefix}"
1561 print_config_vars_h() {
1564 while [ $# -gt 0 ]; do
1565 upname="`toupper $1`"
1566 echo "#define ${upname} $2" >> $header
1571 print_webm_license() {
1572 saved_prefix="${prefix}"
1577 cat <<EOF > ${destination}
1578 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1580 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1581 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1582 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1583 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1584 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1586 prefix="${saved_prefix}"
1597 enable_feature logging
1598 logfile="config.log"
1602 process_cmdline "$@"
1603 if enabled child; then
1604 echo "# ${self} $@" >> ${logfile}
1606 echo "# ${self} $@" > ${logfile}
1608 post_process_common_cmdline
1609 post_process_cmdline
1614 OOT_INSTALLS="${OOT_INSTALLS}"
1615 if enabled source_path_used; then
1616 # Prepare the PWD for building.
1617 for f in ${OOT_INSTALLS}; do
1618 install -D "${source_path}/$f" "$f"
1621 cp "${source_path}/build/make/Makefile" .