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}
323 log check_header "$@"
326 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
328 check_cpp "$@" <<EOF && enable_feature $var
335 log check_cflags "$@"
336 check_cc -Werror "$@" <<EOF
342 log check_cxxflags "$@"
344 # Catch CFLAGS that trigger CXX warnings
346 *c++-analyzer|*clang++|*g++*)
347 check_cxx -Werror "$@" <<EOF
352 check_cxx -Werror "$@" <<EOF
360 check_cxxflags "$@" && add_cxxflags_only "$@"
361 check_cflags "$@" && add_cflags_only "$@"
364 check_add_cxxflags() {
365 check_cxxflags "$@" && add_cxxflags_only "$@"
368 check_add_asflags() {
373 check_add_ldflags() {
379 log check_asm_align "$@"
380 cat >${TMP_ASM} <<EOF
385 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
386 readelf -WS ${TMP_O} >${TMP_X}
388 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
389 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
393 # tests for -m$1 toggling the feature given in $2. If $2 is empty $1 is used.
394 check_gcc_machine_option() {
397 [ -n "$feature" ] || feature="$opt"
399 if enabled gcc && ! disabled "$feature" && ! check_cflags "-m$opt"; then
400 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
402 soft_enable "$feature"
406 write_common_config_banner() {
407 print_webm_license config.mk "##" ""
408 echo '# This file automatically generated by configure. Do not edit!' >> config.mk
409 echo "TOOLCHAIN := ${toolchain}" >> config.mk
413 echo "ALT_LIBC := ${alt_libc}" >> config.mk
418 write_common_config_targets() {
419 for t in ${all_targets}; do
420 if enabled ${t}; then
421 if enabled child; then
422 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
424 fwrite config.mk "ALL_TARGETS += ${t}"
432 write_common_target_config_mk() {
435 enabled ccache && CC="ccache ${CC}"
436 enabled ccache && CXX="ccache ${CXX}"
437 print_webm_license $1 "##" ""
440 # This file automatically generated by configure. Do not edit!
441 SRC_PATH="$source_path"
442 SRC_PATH_BARE=$source_path
443 BUILD_PFX=${BUILD_PFX}
444 TOOLCHAIN=${toolchain}
445 ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
446 GEN_VCPROJ=${gen_vcproj_cmd}
447 MSVS_ARCH_DIR=${msvs_arch_dir}
458 CXXFLAGS = ${CXXFLAGS}
459 ARFLAGS = -crs\$(if \$(quiet),,v)
462 extralibs = ${extralibs}
463 AS_SFX = ${AS_SFX:-.asm}
465 VCPROJ_SFX = ${VCPROJ_SFX}
466 RTCD_OPTIONS = ${RTCD_OPTIONS}
469 if enabled rvct; then cat >> $1 << EOF
470 fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide
472 else cat >> $1 << EOF
473 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;'
477 print_config_mk ARCH "${1}" ${ARCH_LIST}
478 print_config_mk HAVE "${1}" ${HAVE_LIST}
479 print_config_mk CONFIG "${1}" ${CONFIG_LIST}
480 print_config_mk HAVE "${1}" gnu_strip
482 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
488 write_common_target_config_h() {
489 print_webm_license ${TMP_H} "/*" " */"
490 cat >> ${TMP_H} << EOF
491 /* This file automatically generated by configure. Do not edit! */
494 #define RESTRICT ${RESTRICT}
495 #define INLINE ${INLINE}
497 print_config_h ARCH "${TMP_H}" ${ARCH_LIST}
498 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
499 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
500 print_config_vars_h "${TMP_H}" ${VAR_LIST}
501 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
502 mkdir -p `dirname "$1"`
503 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
506 process_common_cmdline() {
515 if ! disabled logging ; then
516 enabled logging || logfile="$logging"
522 toolchain="${toolchain:-${optval}}"
525 toolchain="${toolchain:-${optval}}"
526 enable_feature force_toolchain
532 extra_cflags="${optval}"
535 extra_cxxflags="${optval}"
537 --enable-?*|--disable-?*)
538 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
539 if is_in ${option} ${ARCH_EXT_LIST}; then
540 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${option} "
541 elif [ $action = "disable" ] && ! disabled $option ; then
542 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
543 log_echo " disabling $option"
544 elif [ $action = "enable" ] && ! enabled $option ; then
545 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
546 log_echo " enabling $option"
548 ${action}_feature $option
551 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
552 if is_in ${option} ${ARCH_EXT_LIST}; then
553 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
558 --force-enable-?*|--force-disable-?*)
559 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
560 ${action}_feature $option
563 [ -d "${optval}" ] || die "Not a directory: ${optval}"
564 disable_feature builtin_libc
568 [ "${optval}" = yasm ] || [ "${optval}" = nasm ] \
569 || [ "${optval}" = auto ] \
570 || die "Must be yasm, nasm or auto: ${optval}"
576 VAR_LIST="DECODE_WIDTH_LIMIT ${w} DECODE_HEIGHT_LIMIT ${h}"
577 [ ${w} -gt 0 ] && [ ${h} -gt 0 ] || die "Invalid size-limit: too small."
578 [ ${w} -lt 65536 ] && [ ${h} -lt 65536 ] \
579 || die "Invalid size-limit: too big."
580 enable_feature size_limit
589 [ -d "${optval}" ] || die "Not a directory: ${optval}"
592 --libc|--as|--prefix|--libdir|--sdk-path)
593 die "Option ${opt} requires argument"
610 process_common_cmdline $opt
616 post_process_common_cmdline() {
617 prefix="${prefix:-/usr/local}"
619 libdir="${libdir:-${prefix}/lib}"
621 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
622 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
626 post_process_cmdline() {
630 setup_gnu_toolchain() {
631 CC=${CC:-${CROSS}gcc}
632 CXX=${CXX:-${CROSS}g++}
634 LD=${LD:-${CROSS}${link_with_cc:-ld}}
636 STRIP=${STRIP:-${CROSS}strip}
642 # Reliably find the newest available Darwin SDKs. (Older versions of
643 # xcrun don't support --show-sdk-path.)
644 show_darwin_sdk_path() {
645 xcrun --sdk $1 --show-sdk-path 2>/dev/null ||
646 xcodebuild -sdk $1 -version Path 2>/dev/null
649 # Print the major version number of the Darwin SDK specified by $1.
650 show_darwin_sdk_major_version() {
651 xcrun --sdk $1 --show-sdk-version 2>/dev/null | cut -d. -f1
654 # Print the Xcode version.
655 show_xcode_version() {
656 xcodebuild -version | head -n1 | cut -d' ' -f2
659 # Fails when Xcode version is less than 6.3.
660 check_xcode_minimum_version() {
661 xcode_major=$(show_xcode_version | cut -f1 -d.)
662 xcode_minor=$(show_xcode_version | cut -f2 -d.)
665 if [ ${xcode_major} -lt ${xcode_min_major} ]; then
668 if [ ${xcode_major} -eq ${xcode_min_major} ] \
669 && [ ${xcode_minor} -lt ${xcode_min_minor} ]; then
674 process_common_toolchain() {
675 if [ -z "$toolchain" ]; then
676 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
683 armv7*-hardfloat* | armv7*-gnueabihf | arm-*-gnueabihf)
742 [ -z "$tgt_isa" ] && tgt_isa=x86
756 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
757 toolchain=${tgt_isa}-${tgt_os}-gcc
761 toolchain=${toolchain:-generic-gnu}
763 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
764 || die "Unrecognized toolchain '${toolchain}'"
766 enabled child || log_echo "Configuring for target '${toolchain}'"
769 # Set up toolchain variables
771 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
772 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
773 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
775 # Mark the specific ISA requested as enabled
776 soft_enable ${tgt_isa}
777 enable_feature ${tgt_os}
778 enable_feature ${tgt_cc}
780 # Enable the architecture family
793 # PIC is probably what we want when building shared libs
794 enabled shared && soft_enable pic
796 # Minimum iOS version for all target platforms (darwin and iphonesimulator).
797 # Shared library framework builds are only possible on iOS 8 and later.
798 if enabled shared; then
799 IOS_VERSION_OPTIONS="--enable-shared"
800 IOS_VERSION_MIN="8.0"
802 IOS_VERSION_OPTIONS=""
803 IOS_VERSION_MIN="6.0"
806 # Handle darwin variants. Newer SDKs allow targeting older
807 # platforms, so use the newest one available.
810 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
811 iphoneos_sdk_dir="$(show_darwin_sdk_path iphoneos)"
812 if [ -d "${iphoneos_sdk_dir}" ]; then
813 add_cflags "-isysroot ${iphoneos_sdk_dir}"
814 add_ldflags "-isysroot ${iphoneos_sdk_dir}"
818 osx_sdk_dir="$(show_darwin_sdk_path macosx)"
819 if [ -d "${osx_sdk_dir}" ]; then
820 add_cflags "-isysroot ${osx_sdk_dir}"
821 add_ldflags "-isysroot ${osx_sdk_dir}"
828 add_cflags "-mmacosx-version-min=10.4"
829 add_ldflags "-mmacosx-version-min=10.4"
832 add_cflags "-mmacosx-version-min=10.5"
833 add_ldflags "-mmacosx-version-min=10.5"
836 add_cflags "-mmacosx-version-min=10.6"
837 add_ldflags "-mmacosx-version-min=10.6"
840 add_cflags "-mmacosx-version-min=10.7"
841 add_ldflags "-mmacosx-version-min=10.7"
844 add_cflags "-mmacosx-version-min=10.8"
845 add_ldflags "-mmacosx-version-min=10.8"
848 add_cflags "-mmacosx-version-min=10.9"
849 add_ldflags "-mmacosx-version-min=10.9"
852 add_cflags "-mmacosx-version-min=10.10"
853 add_ldflags "-mmacosx-version-min=10.10"
856 add_cflags "-mmacosx-version-min=10.11"
857 add_ldflags "-mmacosx-version-min=10.11"
860 add_cflags "-mmacosx-version-min=10.12"
861 add_ldflags "-mmacosx-version-min=10.12"
864 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
865 add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
866 iossim_sdk_dir="$(show_darwin_sdk_path iphonesimulator)"
867 if [ -d "${iossim_sdk_dir}" ]; then
868 add_cflags "-isysroot ${iossim_sdk_dir}"
869 add_ldflags "-isysroot ${iossim_sdk_dir}"
874 # Handle Solaris variants. Solaris 10 needs -lposix4
877 add_extralibs -lposix4
880 add_extralibs -lposix4
884 # Process ARM architecture variants
887 # on arm, isa versions are supersets
894 # Only enable neon_asm when neon is also enabled.
895 enabled neon && soft_enable neon_asm
896 # If someone tries to force it through, die.
897 if disabled neon && enabled neon_asm; then
898 die "Disabling neon while keeping neon-asm is not supported"
903 asm_conversion_cmd="cat"
909 arch_int=${tgt_isa##armv}
910 arch_int=${arch_int%%te}
911 check_add_asflags --defsym ARCHITECTURE=${arch_int}
912 tune_cflags="-mtune="
913 if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then
914 if [ -z "${float_abi}" ]; then
915 check_cpp <<EOF && float_abi=hard || float_abi=softfp
916 #ifndef __ARM_PCS_VFP
921 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
922 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
924 if enabled neon || enabled neon_asm; then
925 check_add_cflags -mfpu=neon #-ftree-vectorize
926 check_add_asflags -mfpu=neon
928 elif [ ${tgt_isa} = "arm64" ] || [ ${tgt_isa} = "armv8" ]; then
929 check_add_cflags -march=armv8-a
930 check_add_asflags -march=armv8-a
932 check_add_cflags -march=${tgt_isa}
933 check_add_asflags -march=${tgt_isa}
936 enabled debug && add_asflags -g
937 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
938 if enabled thumb; then
939 asm_conversion_cmd="$asm_conversion_cmd -thumb"
940 check_add_cflags -mthumb
941 check_add_asflags -mthumb -mimplicit-it=always
945 asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
947 msvs_arch_dir=arm-msvs
948 disable_feature multithread
949 disable_feature unit_tests
950 vs_version=${tgt_cc##vs}
951 if [ $vs_version -ge 12 ]; then
952 # MSVC 2013 doesn't allow doing plain .exe projects for ARM,
953 # only "AppContainerApplication" which requires an AppxManifest.
954 # Therefore disable the examples, just build the library.
955 disable_feature examples
956 disable_feature tools
963 LD="${source_path}/build/make/armlink_adapter.sh"
964 STRIP=arm-none-linux-gnueabi-strip
965 NM=arm-none-linux-gnueabi-nm
967 tune_asflags="--cpu="
968 if [ -z "${tune_cpu}" ]; then
969 if [ ${tgt_isa} = "armv7" ]; then
970 if enabled neon || enabled neon_asm
972 check_add_cflags --fpu=softvfp+vfpv3
973 check_add_asflags --fpu=softvfp+vfpv3
975 check_add_cflags --cpu=Cortex-A8
976 check_add_asflags --cpu=Cortex-A8
978 check_add_cflags --cpu=${tgt_isa##armv}
979 check_add_asflags --cpu=${tgt_isa##armv}
982 arch_int=${tgt_isa##armv}
983 arch_int=${arch_int%%te}
984 check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
985 enabled debug && add_asflags -g
987 add_cflags --enum_is_int
994 disable_feature multithread
995 disable_feature os_support
999 if [ -n "${sdk_path}" ]; then
1000 SDK_PATH=${sdk_path}
1001 COMPILER_LOCATION=`find "${SDK_PATH}" \
1002 -name "arm-linux-androideabi-gcc*" -print -quit`
1003 TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
1004 CC=${TOOLCHAIN_PATH}gcc
1005 CXX=${TOOLCHAIN_PATH}g++
1006 AR=${TOOLCHAIN_PATH}ar
1007 LD=${TOOLCHAIN_PATH}gcc
1008 AS=${TOOLCHAIN_PATH}as
1009 STRIP=${TOOLCHAIN_PATH}strip
1010 NM=${TOOLCHAIN_PATH}nm
1012 if [ -z "${alt_libc}" ]; then
1013 alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
1014 awk '{n = split($0,a,"/"); \
1015 split(a[n-1],b,"-"); \
1016 print $0 " " b[2]}' | \
1018 awk '{ print $1 }' | tail -1`
1021 if [ -d "${alt_libc}" ]; then
1022 add_cflags "--sysroot=${alt_libc}"
1023 add_ldflags "--sysroot=${alt_libc}"
1026 # linker flag that routes around a CPU bug in some
1027 # Cortex-A8 implementations (NDK Dev Guide)
1028 add_ldflags "-Wl,--fix-cortex-a8"
1031 soft_enable realtime_only
1032 if [ ${tgt_isa} = "armv7" ]; then
1033 soft_enable runtime_cpu_detect
1035 if enabled runtime_cpu_detect; then
1036 add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
1039 echo "Assuming standalone build with NDK toolchain."
1040 echo "See build/make/Android.mk for details."
1041 check_add_ldflags -static
1042 soft_enable unit_tests
1047 XCRUN_FIND="xcrun --sdk iphoneos --find"
1048 CXX="$(${XCRUN_FIND} clang++)"
1049 CC="$(${XCRUN_FIND} clang)"
1050 AR="$(${XCRUN_FIND} ar)"
1051 AS="$(${XCRUN_FIND} as)"
1052 STRIP="$(${XCRUN_FIND} strip)"
1053 NM="$(${XCRUN_FIND} nm)"
1054 RANLIB="$(${XCRUN_FIND} ranlib)"
1056 LD="${CXX:-$(${XCRUN_FIND} ld)}"
1058 # ASFLAGS is written here instead of using check_add_asflags
1059 # because we need to overwrite all of ASFLAGS and purge the
1060 # options that were put in above
1061 ASFLAGS="-arch ${tgt_isa} -g"
1063 add_cflags -arch ${tgt_isa}
1064 add_ldflags -arch ${tgt_isa}
1066 alt_libc="$(show_darwin_sdk_path iphoneos)"
1067 if [ -d "${alt_libc}" ]; then
1068 add_cflags -isysroot ${alt_libc}
1071 if [ "${LD}" = "${CXX}" ]; then
1072 add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}"
1074 add_ldflags -ios_version_min "${IOS_VERSION_MIN}"
1077 for d in lib usr/lib usr/lib/system; do
1078 try_dir="${alt_libc}/${d}"
1079 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
1083 armv7|armv7s|armv8|arm64)
1084 if enabled neon && ! check_xcode_minimum_version; then
1086 log_echo " neon disabled: upgrade Xcode (need v6.3+)."
1087 if enabled neon_asm; then
1088 soft_disable neon_asm
1089 log_echo " neon_asm disabled: upgrade Xcode (need v6.3+)."
1095 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
1097 if [ "$(show_darwin_sdk_major_version iphoneos)" -gt 8 ]; then
1098 check_add_cflags -fembed-bitcode
1099 check_add_asflags -fembed-bitcode
1100 check_add_ldflags -fembed-bitcode
1105 enable_feature linux
1106 if enabled rvct; then
1107 # Check if we have CodeSourcery GCC in PATH. Needed for
1109 which arm-none-linux-gnueabi-gcc 2>&- || \
1110 die "Couldn't find CodeSourcery GCC from PATH"
1112 # Use armcc as a linker to enable translation of
1113 # some gcc specific options such as -lm and -lpthread.
1114 LD="armcc --translate_gcc"
1116 # create configuration file (uses path to CodeSourcery GCC)
1117 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
1119 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1120 add_asflags --no_hide_all --apcs=/interwork
1121 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1122 enabled pic && add_cflags --apcs=/fpic
1123 enabled pic && add_asflags --apcs=/fpic
1124 enabled shared && add_cflags --shared
1132 tune_cflags="-mtune="
1133 if enabled dspr2; then
1134 check_add_cflags -mips32r2 -mdspr2
1137 if enabled runtime_cpu_detect; then
1138 disable_feature runtime_cpu_detect
1141 if [ -n "${tune_cpu}" ]; then
1144 check_add_cflags -mips32r5 -mload-store-pairs
1145 check_add_cflags -msched-weight -mhard-float -mfp64
1146 check_add_asflags -mips32r5 -mhard-float -mfp64
1147 check_add_ldflags -mfp64
1150 check_add_cflags -mips64r6 -mabi=64 -msched-weight
1151 check_add_cflags -mload-store-pairs -mhard-float -mfp64
1152 check_add_asflags -mips64r6 -mabi=64 -mhard-float -mfp64
1153 check_add_ldflags -mips64r6 -mabi=64 -mfp64
1157 if enabled msa; then
1164 check_add_cflags -march=${tgt_isa}
1165 check_add_asflags -march=${tgt_isa}
1166 check_add_asflags -KPIC
1171 check_gcc_machine_option "vsx"
1176 enabled gcc && add_cflags -fno-common
1179 CC=${CC:-${CROSS}gcc}
1180 CXX=${CXX:-${CROSS}g++}
1181 LD=${LD:-${CROSS}gcc}
1187 add_ldflags -Zhigh-mem
1191 AS="${alt_as:-${AS:-auto}}"
1197 add_cflags -use-msasm # remove -use-msasm too?
1198 # add -no-intel-extensions to suppress warning #10237
1199 # refer to http://software.intel.com/en-us/forums/topic/280199
1200 add_ldflags -i-static -no-intel-extensions
1201 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
1202 enabled x86_64 && AR=xiar
1206 tune_cpu="SSE3_ATOM"
1209 tune_cflags="-march="
1215 tune_cflags="-march="
1217 #for 32 bit x86 builds, -O3 did not turn on this flag
1218 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
1221 # When building with Microsoft Visual Studio the assembler is
1222 # invoked directly. Checking at configure time is unnecessary.
1223 # Skip the check by setting AS arbitrarily
1225 msvs_arch_dir=x86-msvs
1226 vc_version=${tgt_cc##vs}
1229 echo "${tgt_cc} does not support avx/avx2, disabling....."
1230 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx --disable-avx2 "
1237 echo "${tgt_cc} omits stdint.h, disabling webm-io..."
1238 soft_disable webm_io
1245 enabled x86_64 && bits=64
1246 check_cpp <<EOF && bits=x32
1247 #if !defined(__ILP32__) || !defined(__x86_64__)
1253 add_cflags -m${bits}
1254 add_ldflags -m${bits}
1258 soft_enable runtime_cpu_detect
1259 # We can't use 'check_cflags' until the compiler is configured and CC is
1261 for ext in ${ARCH_EXT_LIST_X86}; do
1262 # disable higher order extensions to simplify asm dependencies
1263 if [ "$disable_exts" = "yes" ]; then
1264 if ! disabled $ext; then
1265 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${ext} "
1266 disable_feature $ext
1268 elif disabled $ext; then
1271 # use the shortened version for the flag: sse4_1 -> sse4
1272 check_gcc_machine_option ${ext%_*} $ext
1276 if enabled external_build; then
1277 log_echo " skipping assembler detection"
1281 which nasm >/dev/null 2>&1 && AS=nasm
1282 which yasm >/dev/null 2>&1 && AS=yasm
1283 if [ "${AS}" = nasm ] ; then
1284 # Apple ships version 0.98 of nasm through at least Xcode 6. Revisit
1285 # this check if they start shipping a compatible version.
1286 apple=`nasm -v | grep "Apple"`
1288 && echo "Unsupported version of nasm: ${apple}" \
1291 [ "${AS}" = auto ] || [ -z "${AS}" ] \
1292 && die "Neither yasm nor nasm have been found." \
1293 "See the prerequisites section in the README for more info."
1296 log_echo " using $AS"
1298 [ "${AS##*/}" = nasm ] && add_asflags -Ox
1302 add_asflags -f win32
1303 enabled debug && add_asflags -g cv8
1308 enabled debug && add_asflags -g cv8
1311 linux*|solaris*|android*)
1312 add_asflags -f elf${bits}
1313 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1314 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1315 [ "${AS##*/}" = nasm ] && check_asm_align
1318 add_asflags -f macho${bits}
1319 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1320 add_cflags ${darwin_arch}
1321 add_ldflags ${darwin_arch}
1322 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1323 # one time, but does not seem to be now, and it breaks some of the
1324 # code that still relies on inline assembly.
1325 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1326 enabled icc && ! enabled pic && add_cflags -fno-pic
1329 add_asflags -f macho${bits}
1330 enabled x86 && sim_arch="-arch i386" || sim_arch="-arch x86_64"
1331 add_cflags ${sim_arch}
1332 add_ldflags ${sim_arch}
1334 if [ "$(show_darwin_sdk_major_version iphonesimulator)" -gt 8 ]; then
1335 # yasm v1.3.0 doesn't know what -fembed-bitcode means, so turning it
1336 # on is pointless (unless building a C-only lib). Warn the user, but
1338 log "Warning: Bitcode embed disabled for simulator targets."
1343 enabled debug && add_asflags -g
1347 log "Warning: Unknown os $tgt_os while setting up $AS flags"
1358 # Try to enable CPU specific tuning
1359 if [ -n "${tune_cpu}" ]; then
1360 if [ -n "${tune_cflags}" ]; then
1361 check_add_cflags ${tune_cflags}${tune_cpu} || \
1362 die "Requested CPU '${tune_cpu}' not supported by compiler"
1364 if [ -n "${tune_asflags}" ]; then
1365 check_add_asflags ${tune_asflags}${tune_cpu} || \
1366 die "Requested CPU '${tune_cpu}' not supported by assembler"
1368 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1369 log_echo "Warning: CPU tuning not supported by this toolchain"
1373 if enabled debug; then
1374 check_add_cflags -g && check_add_ldflags -g
1376 check_add_cflags -DNDEBUG
1379 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1381 check_add_cflags -fprofile-arcs -ftest-coverage &&
1382 check_add_ldflags -fprofile-arcs -ftest-coverage
1384 if enabled optimizations; then
1385 if enabled rvct; then
1386 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1388 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1392 # Position Independent Code (PIC) support, for building relocatable
1394 enabled gcc && enabled pic && check_add_cflags -fPIC
1396 # Work around longjmp interception on glibc >= 2.11, to improve binary
1397 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1398 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1400 # Check for strip utility variant
1401 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
1403 # Try to determine target endianness
1405 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1407 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1408 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
1410 # Try to find which inline keywords are supported
1411 check_cc <<EOF && INLINE="inline"
1412 static inline function() {}
1415 # Almost every platform uses pthreads.
1416 if enabled multithread; then
1417 case ${toolchain} in
1421 # bionic includes basic pthread functionality, obviating -lpthread.
1424 check_header pthread.h && add_extralibs -lpthread
1429 # only for MIPS platforms
1430 case ${toolchain} in
1432 if enabled big_endian; then
1433 if enabled dspr2; then
1434 echo "dspr2 optimizations are available only for little endian platforms"
1435 disable_feature dspr2
1437 if enabled msa; then
1438 echo "msa optimizations are available only for little endian platforms"
1446 if enabled linux; then
1447 add_cflags -D_LARGEFILE_SOURCE
1448 add_cflags -D_FILE_OFFSET_BITS=64
1452 process_toolchain() {
1453 process_common_toolchain
1457 saved_prefix="${prefix}"
1462 if enabled $cfg; then
1463 upname="`toupper $cfg`"
1464 echo "${prefix}_${upname}=yes" >> $makefile
1467 prefix="${saved_prefix}"
1471 saved_prefix="${prefix}"
1476 upname="`toupper $cfg`"
1477 if enabled $cfg; then
1478 echo "#define ${prefix}_${upname} 1" >> $header
1480 echo "#define ${prefix}_${upname} 0" >> $header
1483 prefix="${saved_prefix}"
1486 print_config_vars_h() {
1489 while [ $# -gt 0 ]; do
1490 upname="`toupper $1`"
1491 echo "#define ${upname} $2" >> $header
1496 print_webm_license() {
1497 saved_prefix="${prefix}"
1502 cat <<EOF > ${destination}
1503 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1505 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1506 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1507 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1508 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1509 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1511 prefix="${saved_prefix}"
1522 enable_feature logging
1523 logfile="config.log"
1527 process_cmdline "$@"
1528 if enabled child; then
1529 echo "# ${self} $@" >> ${logfile}
1531 echo "# ${self} $@" > ${logfile}
1533 post_process_common_cmdline
1534 post_process_cmdline
1539 OOT_INSTALLS="${OOT_INSTALLS}"
1540 if enabled source_path_used; then
1541 # Prepare the PWD for building.
1542 for f in ${OOT_INSTALLS}; do
1543 install -D "${source_path}/$f" "$f"
1546 cp "${source_path}/build/make/Makefile" .