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}
512 if enabled rvct; then cat >> $1 << EOF
513 fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide
515 else cat >> $1 << EOF
516 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;'
520 print_config_mk ARCH "${1}" ${ARCH_LIST}
521 print_config_mk HAVE "${1}" ${HAVE_LIST}
522 print_config_mk CONFIG "${1}" ${CONFIG_LIST}
523 print_config_mk HAVE "${1}" gnu_strip
525 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
531 write_common_target_config_h() {
532 print_webm_license ${TMP_H} "/*" " */"
533 cat >> ${TMP_H} << EOF
534 /* This file automatically generated by configure. Do not edit! */
537 #define RESTRICT ${RESTRICT}
538 #define INLINE ${INLINE}
540 print_config_h ARCH "${TMP_H}" ${ARCH_LIST}
541 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
542 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
543 print_config_vars_h "${TMP_H}" ${VAR_LIST}
544 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
545 mkdir -p `dirname "$1"`
546 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
549 process_common_cmdline() {
558 if ! disabled logging ; then
559 enabled logging || logfile="$logging"
565 toolchain="${toolchain:-${optval}}"
568 toolchain="${toolchain:-${optval}}"
569 enable_feature force_toolchain
575 extra_cflags="${optval}"
578 extra_cxxflags="${optval}"
580 --enable-?*|--disable-?*)
581 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
582 if is_in ${option} ${ARCH_EXT_LIST}; then
583 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${option} "
584 elif [ $action = "disable" ] && ! disabled $option ; then
585 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
586 log_echo " disabling $option"
587 elif [ $action = "enable" ] && ! enabled $option ; then
588 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
589 log_echo " enabling $option"
591 ${action}_feature $option
594 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
595 if is_in ${option} ${ARCH_EXT_LIST}; then
596 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
601 --force-enable-?*|--force-disable-?*)
602 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
603 ${action}_feature $option
606 [ -d "${optval}" ] || die "Not a directory: ${optval}"
607 disable_feature builtin_libc
611 [ "${optval}" = yasm ] || [ "${optval}" = nasm ] \
612 || [ "${optval}" = auto ] \
613 || die "Must be yasm, nasm or auto: ${optval}"
619 VAR_LIST="DECODE_WIDTH_LIMIT ${w} DECODE_HEIGHT_LIMIT ${h}"
620 [ ${w} -gt 0 ] && [ ${h} -gt 0 ] || die "Invalid size-limit: too small."
621 [ ${w} -lt 65536 ] && [ ${h} -lt 65536 ] \
622 || die "Invalid size-limit: too big."
623 enable_feature size_limit
632 [ -d "${optval}" ] || die "Not a directory: ${optval}"
635 --libc|--as|--prefix|--libdir|--sdk-path)
636 die "Option ${opt} requires argument"
653 process_common_cmdline $opt
659 post_process_common_cmdline() {
660 prefix="${prefix:-/usr/local}"
662 libdir="${libdir:-${prefix}/lib}"
664 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
665 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
669 post_process_cmdline() {
673 setup_gnu_toolchain() {
674 CC=${CC:-${CROSS}gcc}
675 CXX=${CXX:-${CROSS}g++}
677 LD=${LD:-${CROSS}${link_with_cc:-ld}}
679 STRIP=${STRIP:-${CROSS}strip}
685 # Reliably find the newest available Darwin SDKs. (Older versions of
686 # xcrun don't support --show-sdk-path.)
687 show_darwin_sdk_path() {
688 xcrun --sdk $1 --show-sdk-path 2>/dev/null ||
689 xcodebuild -sdk $1 -version Path 2>/dev/null
692 # Print the major version number of the Darwin SDK specified by $1.
693 show_darwin_sdk_major_version() {
694 xcrun --sdk $1 --show-sdk-version 2>/dev/null | cut -d. -f1
697 # Print the Xcode version.
698 show_xcode_version() {
699 xcodebuild -version | head -n1 | cut -d' ' -f2
702 # Fails when Xcode version is less than 6.3.
703 check_xcode_minimum_version() {
704 xcode_major=$(show_xcode_version | cut -f1 -d.)
705 xcode_minor=$(show_xcode_version | cut -f2 -d.)
708 if [ ${xcode_major} -lt ${xcode_min_major} ]; then
711 if [ ${xcode_major} -eq ${xcode_min_major} ] \
712 && [ ${xcode_minor} -lt ${xcode_min_minor} ]; then
717 process_common_toolchain() {
718 if [ -z "$toolchain" ]; then
719 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
725 armv7*-hardfloat* | armv7*-gnueabihf | arm-*-gnueabihf)
794 [ -z "$tgt_isa" ] && tgt_isa=x86
808 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
809 toolchain=${tgt_isa}-${tgt_os}-gcc
813 toolchain=${toolchain:-generic-gnu}
815 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
816 || die "Unrecognized toolchain '${toolchain}'"
818 enabled child || log_echo "Configuring for target '${toolchain}'"
821 # Set up toolchain variables
823 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
824 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
825 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
827 # Mark the specific ISA requested as enabled
828 soft_enable ${tgt_isa}
829 enable_feature ${tgt_os}
830 enable_feature ${tgt_cc}
832 # Enable the architecture family
845 # PIC is probably what we want when building shared libs
846 enabled shared && soft_enable pic
848 # Minimum iOS version for all target platforms (darwin and iphonesimulator).
849 # Shared library framework builds are only possible on iOS 8 and later.
850 if enabled shared; then
851 IOS_VERSION_OPTIONS="--enable-shared"
852 IOS_VERSION_MIN="8.0"
854 IOS_VERSION_OPTIONS=""
855 IOS_VERSION_MIN="7.0"
858 # Handle darwin variants. Newer SDKs allow targeting older
859 # platforms, so use the newest one available.
862 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
863 iphoneos_sdk_dir="$(show_darwin_sdk_path iphoneos)"
864 if [ -d "${iphoneos_sdk_dir}" ]; then
865 add_cflags "-isysroot ${iphoneos_sdk_dir}"
866 add_ldflags "-isysroot ${iphoneos_sdk_dir}"
870 osx_sdk_dir="$(show_darwin_sdk_path macosx)"
871 if [ -d "${osx_sdk_dir}" ]; then
872 add_cflags "-isysroot ${osx_sdk_dir}"
873 add_ldflags "-isysroot ${osx_sdk_dir}"
880 add_cflags "-mmacosx-version-min=10.4"
881 add_ldflags "-mmacosx-version-min=10.4"
884 add_cflags "-mmacosx-version-min=10.5"
885 add_ldflags "-mmacosx-version-min=10.5"
888 add_cflags "-mmacosx-version-min=10.6"
889 add_ldflags "-mmacosx-version-min=10.6"
892 add_cflags "-mmacosx-version-min=10.7"
893 add_ldflags "-mmacosx-version-min=10.7"
896 add_cflags "-mmacosx-version-min=10.8"
897 add_ldflags "-mmacosx-version-min=10.8"
900 add_cflags "-mmacosx-version-min=10.9"
901 add_ldflags "-mmacosx-version-min=10.9"
904 add_cflags "-mmacosx-version-min=10.10"
905 add_ldflags "-mmacosx-version-min=10.10"
908 add_cflags "-mmacosx-version-min=10.11"
909 add_ldflags "-mmacosx-version-min=10.11"
912 add_cflags "-mmacosx-version-min=10.12"
913 add_ldflags "-mmacosx-version-min=10.12"
916 add_cflags "-mmacosx-version-min=10.13"
917 add_ldflags "-mmacosx-version-min=10.13"
920 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
921 add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
922 iossim_sdk_dir="$(show_darwin_sdk_path iphonesimulator)"
923 if [ -d "${iossim_sdk_dir}" ]; then
924 add_cflags "-isysroot ${iossim_sdk_dir}"
925 add_ldflags "-isysroot ${iossim_sdk_dir}"
930 # Handle Solaris variants. Solaris 10 needs -lposix4
933 add_extralibs -lposix4
936 add_extralibs -lposix4
940 # Process ARM architecture variants
943 # on arm, isa versions are supersets
950 # Only enable neon_asm when neon is also enabled.
951 enabled neon && soft_enable neon_asm
952 # If someone tries to force it through, die.
953 if disabled neon && enabled neon_asm; then
954 die "Disabling neon while keeping neon-asm is not supported"
959 asm_conversion_cmd="cat"
965 arch_int=${tgt_isa##armv}
966 arch_int=${arch_int%%te}
967 tune_cflags="-mtune="
968 if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then
969 if [ -z "${float_abi}" ]; then
970 check_cpp <<EOF && float_abi=hard || float_abi=softfp
971 #ifndef __ARM_PCS_VFP
976 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
977 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
979 if enabled neon || enabled neon_asm; then
980 check_add_cflags -mfpu=neon #-ftree-vectorize
981 check_add_asflags -mfpu=neon
983 elif [ ${tgt_isa} = "arm64" ] || [ ${tgt_isa} = "armv8" ]; then
984 check_add_cflags -march=armv8-a
985 check_add_asflags -march=armv8-a
987 check_add_cflags -march=${tgt_isa}
988 check_add_asflags -march=${tgt_isa}
991 enabled debug && add_asflags -g
992 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
996 asm_conversion_cmd="$asm_conversion_cmd -noelf"
1002 check_add_asflags --defsym ARCHITECTURE=${arch_int}
1006 if enabled thumb; then
1007 asm_conversion_cmd="$asm_conversion_cmd -thumb"
1008 check_add_cflags -mthumb
1009 check_add_asflags -mthumb -mimplicit-it=always
1013 asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
1015 msvs_arch_dir=arm-msvs
1016 disable_feature multithread
1017 disable_feature unit_tests
1018 vs_version=${tgt_cc##vs}
1019 if [ $vs_version -ge 12 ]; then
1020 # MSVC 2013 doesn't allow doing plain .exe projects for ARM,
1021 # only "AppContainerApplication" which requires an AppxManifest.
1022 # Therefore disable the examples, just build the library.
1023 disable_feature examples
1024 disable_feature tools
1031 LD="${source_path}/build/make/armlink_adapter.sh"
1032 STRIP=arm-none-linux-gnueabi-strip
1033 NM=arm-none-linux-gnueabi-nm
1034 tune_cflags="--cpu="
1035 tune_asflags="--cpu="
1036 if [ -z "${tune_cpu}" ]; then
1037 if [ ${tgt_isa} = "armv7" ]; then
1038 if enabled neon || enabled neon_asm
1040 check_add_cflags --fpu=softvfp+vfpv3
1041 check_add_asflags --fpu=softvfp+vfpv3
1043 check_add_cflags --cpu=Cortex-A8
1044 check_add_asflags --cpu=Cortex-A8
1046 check_add_cflags --cpu=${tgt_isa##armv}
1047 check_add_asflags --cpu=${tgt_isa##armv}
1050 arch_int=${tgt_isa##armv}
1051 arch_int=${arch_int%%te}
1052 check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
1053 enabled debug && add_asflags -g
1055 add_cflags --enum_is_int
1056 add_cflags --wchar32
1062 disable_feature multithread
1063 disable_feature os_support
1067 if [ -n "${sdk_path}" ]; then
1068 SDK_PATH=${sdk_path}
1069 COMPILER_LOCATION=`find "${SDK_PATH}" \
1070 -name "arm-linux-androideabi-gcc*" -print -quit`
1071 TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
1072 CC=${TOOLCHAIN_PATH}gcc
1073 CXX=${TOOLCHAIN_PATH}g++
1074 AR=${TOOLCHAIN_PATH}ar
1075 LD=${TOOLCHAIN_PATH}gcc
1076 AS=${TOOLCHAIN_PATH}as
1077 STRIP=${TOOLCHAIN_PATH}strip
1078 NM=${TOOLCHAIN_PATH}nm
1080 if [ -z "${alt_libc}" ]; then
1081 alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
1082 awk '{n = split($0,a,"/"); \
1083 split(a[n-1],b,"-"); \
1084 print $0 " " b[2]}' | \
1086 awk '{ print $1 }' | tail -1`
1089 if [ -d "${alt_libc}" ]; then
1090 add_cflags "--sysroot=${alt_libc}"
1091 add_ldflags "--sysroot=${alt_libc}"
1094 # linker flag that routes around a CPU bug in some
1095 # Cortex-A8 implementations (NDK Dev Guide)
1096 add_ldflags "-Wl,--fix-cortex-a8"
1099 soft_enable realtime_only
1100 if [ ${tgt_isa} = "armv7" ]; then
1101 soft_enable runtime_cpu_detect
1103 if enabled runtime_cpu_detect; then
1104 add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
1107 echo "Assuming standalone build with NDK toolchain."
1108 echo "See build/make/Android.mk for details."
1109 check_add_ldflags -static
1110 soft_enable unit_tests
1115 XCRUN_FIND="xcrun --sdk iphoneos --find"
1116 CXX="$(${XCRUN_FIND} clang++)"
1117 CC="$(${XCRUN_FIND} clang)"
1118 AR="$(${XCRUN_FIND} ar)"
1119 AS="$(${XCRUN_FIND} as)"
1120 STRIP="$(${XCRUN_FIND} strip)"
1121 NM="$(${XCRUN_FIND} nm)"
1122 RANLIB="$(${XCRUN_FIND} ranlib)"
1124 LD="${CXX:-$(${XCRUN_FIND} ld)}"
1126 # ASFLAGS is written here instead of using check_add_asflags
1127 # because we need to overwrite all of ASFLAGS and purge the
1128 # options that were put in above
1129 ASFLAGS="-arch ${tgt_isa} -g"
1131 add_cflags -arch ${tgt_isa}
1132 add_ldflags -arch ${tgt_isa}
1134 alt_libc="$(show_darwin_sdk_path iphoneos)"
1135 if [ -d "${alt_libc}" ]; then
1136 add_cflags -isysroot ${alt_libc}
1139 if [ "${LD}" = "${CXX}" ]; then
1140 add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}"
1142 add_ldflags -ios_version_min "${IOS_VERSION_MIN}"
1145 for d in lib usr/lib usr/lib/system; do
1146 try_dir="${alt_libc}/${d}"
1147 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
1151 armv7|armv7s|armv8|arm64)
1152 if enabled neon && ! check_xcode_minimum_version; then
1154 log_echo " neon disabled: upgrade Xcode (need v6.3+)."
1155 if enabled neon_asm; then
1156 soft_disable neon_asm
1157 log_echo " neon_asm disabled: upgrade Xcode (need v6.3+)."
1163 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
1165 if [ "$(show_darwin_sdk_major_version iphoneos)" -gt 8 ]; then
1166 check_add_cflags -fembed-bitcode
1167 check_add_asflags -fembed-bitcode
1168 check_add_ldflags -fembed-bitcode
1173 enable_feature linux
1174 if enabled rvct; then
1175 # Check if we have CodeSourcery GCC in PATH. Needed for
1177 which arm-none-linux-gnueabi-gcc 2>&- || \
1178 die "Couldn't find CodeSourcery GCC from PATH"
1180 # Use armcc as a linker to enable translation of
1181 # some gcc specific options such as -lm and -lpthread.
1182 LD="armcc --translate_gcc"
1184 # create configuration file (uses path to CodeSourcery GCC)
1185 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
1187 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1188 add_asflags --no_hide_all --apcs=/interwork
1189 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1190 enabled pic && add_cflags --apcs=/fpic
1191 enabled pic && add_asflags --apcs=/fpic
1192 enabled shared && add_cflags --shared
1200 tune_cflags="-mtune="
1201 if enabled dspr2; then
1202 check_add_cflags -mips32r2 -mdspr2
1205 if enabled runtime_cpu_detect; then
1206 disable_feature runtime_cpu_detect
1209 if [ -n "${tune_cpu}" ]; then
1212 check_add_cflags -mips32r5 -mload-store-pairs
1213 check_add_cflags -msched-weight -mhard-float -mfp64
1214 check_add_asflags -mips32r5 -mhard-float -mfp64
1215 check_add_ldflags -mfp64
1218 check_add_cflags -mips64r6 -mabi=64 -msched-weight
1219 check_add_cflags -mload-store-pairs -mhard-float -mfp64
1220 check_add_asflags -mips64r6 -mabi=64 -mhard-float -mfp64
1221 check_add_ldflags -mips64r6 -mabi=64 -mfp64
1225 if enabled msa; then
1227 # The new mips functions in libyuv do not build
1228 # with the toolchains we currently use for testing.
1237 if enabled mmi; then
1239 check_add_ldflags -march=loongson3a
1242 check_add_cflags -march=${tgt_isa}
1243 check_add_asflags -march=${tgt_isa}
1244 check_add_asflags -KPIC
1249 check_gcc_machine_option "vsx"
1250 if [ -n "${tune_cpu}" ]; then
1253 tune_cflags="-mcpu="
1261 soft_enable realtime_only
1264 enabled gcc && add_cflags -fno-common
1267 CC=${CC:-${CROSS}gcc}
1268 CXX=${CXX:-${CROSS}g++}
1269 LD=${LD:-${CROSS}gcc}
1275 add_ldflags -Zhigh-mem
1279 AS="${alt_as:-${AS:-auto}}"
1285 add_cflags -use-msasm # remove -use-msasm too?
1286 # add -no-intel-extensions to suppress warning #10237
1287 # refer to http://software.intel.com/en-us/forums/topic/280199
1288 add_ldflags -i-static -no-intel-extensions
1289 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
1290 enabled x86_64 && AR=xiar
1294 tune_cpu="SSE3_ATOM"
1297 tune_cflags="-march="
1303 tune_cflags="-march="
1305 #for 32 bit x86 builds, -O3 did not turn on this flag
1306 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
1309 # When building with Microsoft Visual Studio the assembler is
1310 # invoked directly. Checking at configure time is unnecessary.
1311 # Skip the check by setting AS arbitrarily
1313 msvs_arch_dir=x86-msvs
1314 vc_version=${tgt_cc##vs}
1316 7|8|9|10|11|12|13|14)
1317 echo "${tgt_cc} does not support avx512, disabling....."
1318 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx512 "
1324 echo "${tgt_cc} does not support avx/avx2, disabling....."
1325 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx --disable-avx2 "
1332 echo "${tgt_cc} omits stdint.h, disabling webm-io..."
1333 soft_disable webm_io
1340 enabled x86_64 && bits=64
1341 check_cpp <<EOF && bits=x32
1342 #if !defined(__ILP32__) || !defined(__x86_64__)
1348 add_cflags -m${bits}
1349 add_ldflags -m${bits}
1353 soft_enable runtime_cpu_detect
1354 # We can't use 'check_cflags' until the compiler is configured and CC is
1356 for ext in ${ARCH_EXT_LIST_X86}; do
1357 # disable higher order extensions to simplify asm dependencies
1358 if [ "$disable_exts" = "yes" ]; then
1359 if ! disabled $ext; then
1360 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${ext} "
1361 disable_feature $ext
1363 elif disabled $ext; then
1366 if [ "$ext" = "avx512" ]; then
1367 check_gcc_machine_options $ext avx512f avx512cd avx512bw avx512dq avx512vl
1368 check_gcc_avx512_compiles
1370 # use the shortened version for the flag: sse4_1 -> sse4
1371 check_gcc_machine_option ${ext%_*} $ext
1376 if enabled external_build; then
1377 log_echo " skipping assembler detection"
1381 which nasm >/dev/null 2>&1 && AS=nasm
1382 which yasm >/dev/null 2>&1 && AS=yasm
1383 if [ "${AS}" = nasm ] ; then
1384 # Apple ships version 0.98 of nasm through at least Xcode 6. Revisit
1385 # this check if they start shipping a compatible version.
1386 apple=`nasm -v | grep "Apple"`
1388 && echo "Unsupported version of nasm: ${apple}" \
1391 [ "${AS}" = auto ] || [ -z "${AS}" ] \
1392 && die "Neither yasm nor nasm have been found." \
1393 "See the prerequisites section in the README for more info."
1396 log_echo " using $AS"
1401 add_asflags -f win32
1402 enabled debug && add_asflags -g cv8
1406 add_asflags -f win64
1407 enabled debug && add_asflags -g cv8
1410 linux*|solaris*|android*)
1411 add_asflags -f elf${bits}
1412 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1413 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1414 [ "${AS##*/}" = nasm ] && check_asm_align
1417 add_asflags -f macho${bits}
1418 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1419 add_cflags ${darwin_arch}
1420 add_ldflags ${darwin_arch}
1421 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1422 # one time, but does not seem to be now, and it breaks some of the
1423 # code that still relies on inline assembly.
1424 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1425 enabled icc && ! enabled pic && add_cflags -fno-pic
1428 add_asflags -f macho${bits}
1429 enabled x86 && sim_arch="-arch i386" || sim_arch="-arch x86_64"
1430 add_cflags ${sim_arch}
1431 add_ldflags ${sim_arch}
1433 if [ "$(disabled external_build)" ] &&
1434 [ "$(show_darwin_sdk_major_version iphonesimulator)" -gt 8 ]; then
1435 # yasm v1.3.0 doesn't know what -fembed-bitcode means, so turning it
1436 # on is pointless (unless building a C-only lib). Warn the user, but
1438 log "Warning: Bitcode embed disabled for simulator targets."
1443 enabled debug && add_asflags -g
1447 log "Warning: Unknown os $tgt_os while setting up $AS flags"
1458 # Try to enable CPU specific tuning
1459 if [ -n "${tune_cpu}" ]; then
1460 if [ -n "${tune_cflags}" ]; then
1461 check_add_cflags ${tune_cflags}${tune_cpu} || \
1462 die "Requested CPU '${tune_cpu}' not supported by compiler"
1464 if [ -n "${tune_asflags}" ]; then
1465 check_add_asflags ${tune_asflags}${tune_cpu} || \
1466 die "Requested CPU '${tune_cpu}' not supported by assembler"
1468 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1469 log_echo "Warning: CPU tuning not supported by this toolchain"
1473 if enabled debug; then
1474 check_add_cflags -g && check_add_ldflags -g
1476 check_add_cflags -DNDEBUG
1479 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1481 check_add_cflags -fprofile-arcs -ftest-coverage &&
1482 check_add_ldflags -fprofile-arcs -ftest-coverage
1484 if enabled optimizations; then
1485 if enabled rvct; then
1486 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1488 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1492 # Position Independent Code (PIC) support, for building relocatable
1494 enabled gcc && enabled pic && check_add_cflags -fPIC
1496 # Work around longjmp interception on glibc >= 2.11, to improve binary
1497 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1498 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1500 # Check for strip utility variant
1501 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
1503 # Try to determine target endianness
1505 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1507 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1508 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
1510 # Try to find which inline keywords are supported
1511 check_cc <<EOF && INLINE="inline"
1512 static inline function() {}
1515 # Almost every platform uses pthreads.
1516 if enabled multithread; then
1517 case ${toolchain} in
1521 # bionic includes basic pthread functionality, obviating -lpthread.
1524 check_header pthread.h && check_lib -lpthread <<EOF && add_extralibs -lpthread || disable_feature pthread_h
1525 #include <pthread.h>
1527 int main(void) { return pthread_create(NULL, NULL, NULL, NULL); }
1533 # only for MIPS platforms
1534 case ${toolchain} in
1536 if enabled big_endian; then
1537 if enabled dspr2; then
1538 echo "dspr2 optimizations are available only for little endian platforms"
1539 disable_feature dspr2
1541 if enabled msa; then
1542 echo "msa optimizations are available only for little endian platforms"
1545 if enabled mmi; then
1546 echo "mmi optimizations are available only for little endian platforms"
1554 if enabled linux; then
1555 add_cflags -D_LARGEFILE_SOURCE
1556 add_cflags -D_FILE_OFFSET_BITS=64
1560 process_toolchain() {
1561 process_common_toolchain
1565 saved_prefix="${prefix}"
1570 if enabled $cfg; then
1571 upname="`toupper $cfg`"
1572 echo "${prefix}_${upname}=yes" >> $makefile
1575 prefix="${saved_prefix}"
1579 saved_prefix="${prefix}"
1584 upname="`toupper $cfg`"
1585 if enabled $cfg; then
1586 echo "#define ${prefix}_${upname} 1" >> $header
1588 echo "#define ${prefix}_${upname} 0" >> $header
1591 prefix="${saved_prefix}"
1594 print_config_vars_h() {
1597 while [ $# -gt 0 ]; do
1598 upname="`toupper $1`"
1599 echo "#define ${upname} $2" >> $header
1604 print_webm_license() {
1605 saved_prefix="${prefix}"
1610 cat <<EOF > ${destination}
1611 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1613 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1614 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1615 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1616 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1617 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1619 prefix="${saved_prefix}"
1630 enable_feature logging
1631 logfile="config.log"
1635 process_cmdline "$@"
1636 if enabled child; then
1637 echo "# ${self} $@" >> ${logfile}
1639 echo "# ${self} $@" > ${logfile}
1641 post_process_common_cmdline
1642 post_process_cmdline
1647 OOT_INSTALLS="${OOT_INSTALLS}"
1648 if enabled source_path_used; then
1649 # Prepare the PWD for building.
1650 for f in ${OOT_INSTALLS}; do
1651 install -D "${source_path}/$f" "$f"
1654 cp "${source_path}/build/make/Makefile" .