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
197 eval test "x\$$1" = "xyes"
201 eval test "x\$$1" = "xno"
206 if ! disabled $var; then
207 enabled $var || log_echo " enabling $var"
215 if ! enabled $var; then
216 disabled $var || log_echo " disabling $var"
223 # Text Processing Functions
226 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
230 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
234 # Temporary File Functions
237 enable_feature source_path_used
238 if [ -z "$source_path" ] || [ "$source_path" = "." ]; then
240 disable_feature source_path_used
243 if test ! -z "$TMPDIR" ; then
245 elif test ! -z "$TEMPDIR" ; then
250 RAND=$(awk 'BEGIN { srand(); printf "%d\n",(rand() * 32768)}')
251 TMP_H="${TMPDIRx}/vpx-conf-$$-${RAND}.h"
252 TMP_C="${TMPDIRx}/vpx-conf-$$-${RAND}.c"
253 TMP_CC="${TMPDIRx}/vpx-conf-$$-${RAND}.cc"
254 TMP_O="${TMPDIRx}/vpx-conf-$$-${RAND}.o"
255 TMP_X="${TMPDIRx}/vpx-conf-$$-${RAND}.x"
256 TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RAND}.asm"
259 rm -f ${TMP_C} ${TMP_CC} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM}
260 enabled gcov && rm -f ${TMP_C%.c}.gcno ${TMP_CC%.cc}.gcno
264 # Toolchain Check Functions
267 enabled external_build && return
269 "$@" >>${logfile} 2>&1
276 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
283 check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_CC}
290 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
296 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
300 log check_header "$@"
303 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
305 check_cpp "$@" <<EOF && enable_feature $var
312 log check_cflags "$@"
313 check_cc -Werror "$@" <<EOF
319 log check_cxxflags "$@"
321 # Catch CFLAGS that trigger CXX warnings
323 *c++-analyzer|*clang++|*g++*)
324 check_cxx -Werror "$@" <<EOF
329 check_cxx -Werror "$@" <<EOF
337 check_cxxflags "$@" && add_cxxflags_only "$@"
338 check_cflags "$@" && add_cflags_only "$@"
341 check_add_cxxflags() {
342 check_cxxflags "$@" && add_cxxflags_only "$@"
345 check_add_asflags() {
350 check_add_ldflags() {
356 log check_asm_align "$@"
357 cat >${TMP_ASM} <<EOF
362 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
363 readelf -WS ${TMP_O} >${TMP_X}
365 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
366 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
370 # tests for -m$1 toggling the feature given in $2. If $2 is empty $1 is used.
371 check_gcc_machine_option() {
374 [ -n "$feature" ] || feature="$opt"
376 if enabled gcc && ! disabled "$feature" && ! check_cflags "-m$opt"; then
377 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
379 soft_enable "$feature"
383 write_common_config_banner() {
384 print_webm_license config.mk "##" ""
385 echo '# This file automatically generated by configure. Do not edit!' >> config.mk
386 echo "TOOLCHAIN := ${toolchain}" >> config.mk
390 echo "ALT_LIBC := ${alt_libc}" >> config.mk
395 write_common_config_targets() {
396 for t in ${all_targets}; do
397 if enabled ${t}; then
398 if enabled child; then
399 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
401 fwrite config.mk "ALL_TARGETS += ${t}"
409 write_common_target_config_mk() {
412 enabled ccache && CC="ccache ${CC}"
413 enabled ccache && CXX="ccache ${CXX}"
414 print_webm_license $1 "##" ""
417 # This file automatically generated by configure. Do not edit!
418 SRC_PATH="$source_path"
419 SRC_PATH_BARE=$source_path
420 BUILD_PFX=${BUILD_PFX}
421 TOOLCHAIN=${toolchain}
422 ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
423 GEN_VCPROJ=${gen_vcproj_cmd}
424 MSVS_ARCH_DIR=${msvs_arch_dir}
435 CXXFLAGS = ${CXXFLAGS}
436 ARFLAGS = -crs\$(if \$(quiet),,v)
439 extralibs = ${extralibs}
440 AS_SFX = ${AS_SFX:-.asm}
442 VCPROJ_SFX = ${VCPROJ_SFX}
443 RTCD_OPTIONS = ${RTCD_OPTIONS}
446 if enabled rvct; then cat >> $1 << EOF
447 fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide
449 else cat >> $1 << EOF
450 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;'
454 print_config_mk ARCH "${1}" ${ARCH_LIST}
455 print_config_mk HAVE "${1}" ${HAVE_LIST}
456 print_config_mk CONFIG "${1}" ${CONFIG_LIST}
457 print_config_mk HAVE "${1}" gnu_strip
459 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
465 write_common_target_config_h() {
466 print_webm_license ${TMP_H} "/*" " */"
467 cat >> ${TMP_H} << EOF
468 /* This file automatically generated by configure. Do not edit! */
471 #define RESTRICT ${RESTRICT}
472 #define INLINE ${INLINE}
474 print_config_h ARCH "${TMP_H}" ${ARCH_LIST}
475 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
476 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
477 print_config_vars_h "${TMP_H}" ${VAR_LIST}
478 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
479 mkdir -p `dirname "$1"`
480 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
483 process_common_cmdline() {
492 if ! disabled logging ; then
493 enabled logging || logfile="$logging"
499 toolchain="${toolchain:-${optval}}"
502 toolchain="${toolchain:-${optval}}"
503 enable_feature force_toolchain
509 extra_cflags="${optval}"
512 extra_cxxflags="${optval}"
514 --enable-?*|--disable-?*)
515 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
516 if echo "${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null; then
517 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${option} "
518 elif [ $action = "disable" ] && ! disabled $option ; then
519 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
521 log_echo " disabling $option"
522 elif [ $action = "enable" ] && ! enabled $option ; then
523 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
525 log_echo " enabling $option"
527 ${action}_feature $option
530 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
531 if echo "${ARCH_EXT_LIST}" none | grep "^ *$option\$" >/dev/null; then
532 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
537 --force-enable-?*|--force-disable-?*)
538 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
539 ${action}_feature $option
542 [ -d "${optval}" ] || die "Not a directory: ${optval}"
543 disable_feature builtin_libc
547 [ "${optval}" = yasm ] || [ "${optval}" = nasm ] \
548 || [ "${optval}" = auto ] \
549 || die "Must be yasm, nasm or auto: ${optval}"
555 VAR_LIST="DECODE_WIDTH_LIMIT ${w} DECODE_HEIGHT_LIMIT ${h}"
556 [ ${w} -gt 0 ] && [ ${h} -gt 0 ] || die "Invalid size-limit: too small."
557 [ ${w} -lt 65536 ] && [ ${h} -lt 65536 ] \
558 || die "Invalid size-limit: too big."
559 enable_feature size_limit
568 [ -d "${optval}" ] || die "Not a directory: ${optval}"
571 --libc|--as|--prefix|--libdir|--sdk-path)
572 die "Option ${opt} requires argument"
589 process_common_cmdline $opt
595 post_process_common_cmdline() {
596 prefix="${prefix:-/usr/local}"
598 libdir="${libdir:-${prefix}/lib}"
600 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
601 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
605 post_process_cmdline() {
609 setup_gnu_toolchain() {
610 CC=${CC:-${CROSS}gcc}
611 CXX=${CXX:-${CROSS}g++}
613 LD=${LD:-${CROSS}${link_with_cc:-ld}}
615 STRIP=${STRIP:-${CROSS}strip}
621 # Reliably find the newest available Darwin SDKs. (Older versions of
622 # xcrun don't support --show-sdk-path.)
623 show_darwin_sdk_path() {
624 xcrun --sdk $1 --show-sdk-path 2>/dev/null ||
625 xcodebuild -sdk $1 -version Path 2>/dev/null
628 process_common_toolchain() {
629 if [ -z "$toolchain" ]; then
630 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
682 [ -z "$tgt_isa" ] && tgt_isa=x86
696 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
697 toolchain=${tgt_isa}-${tgt_os}-gcc
701 toolchain=${toolchain:-generic-gnu}
703 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
704 || die "Unrecognized toolchain '${toolchain}'"
706 enabled child || log_echo "Configuring for target '${toolchain}'"
709 # Set up toolchain variables
711 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
712 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
713 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
715 # Mark the specific ISA requested as enabled
716 soft_enable ${tgt_isa}
717 enable_feature ${tgt_os}
718 enable_feature ${tgt_cc}
720 # Enable the architecture family
730 # PIC is probably what we want when building shared libs
731 enabled shared && soft_enable pic
733 # Minimum iOS version for all target platforms (darwin and iphonesimulator).
734 IOS_VERSION_MIN="6.0"
736 # Handle darwin variants. Newer SDKs allow targeting older
737 # platforms, so use the newest one available.
740 osx_sdk_dir="$(show_darwin_sdk_path macosx)"
741 if [ -d "${osx_sdk_dir}" ]; then
742 add_cflags "-isysroot ${osx_sdk_dir}"
743 add_ldflags "-isysroot ${osx_sdk_dir}"
750 add_cflags "-mmacosx-version-min=10.4"
751 add_ldflags "-mmacosx-version-min=10.4"
754 add_cflags "-mmacosx-version-min=10.5"
755 add_ldflags "-mmacosx-version-min=10.5"
758 add_cflags "-mmacosx-version-min=10.6"
759 add_ldflags "-mmacosx-version-min=10.6"
762 add_cflags "-mmacosx-version-min=10.7"
763 add_ldflags "-mmacosx-version-min=10.7"
766 add_cflags "-mmacosx-version-min=10.8"
767 add_ldflags "-mmacosx-version-min=10.8"
770 add_cflags "-mmacosx-version-min=10.9"
771 add_ldflags "-mmacosx-version-min=10.9"
774 add_cflags "-mmacosx-version-min=10.10"
775 add_ldflags "-mmacosx-version-min=10.10"
778 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
779 add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
780 iossim_sdk_dir="$(show_darwin_sdk_path iphonesimulator)"
781 if [ -d "${iossim_sdk_dir}" ]; then
782 add_cflags "-isysroot ${iossim_sdk_dir}"
783 add_ldflags "-isysroot ${iossim_sdk_dir}"
788 # Handle Solaris variants. Solaris 10 needs -lposix4
791 add_extralibs -lposix4
794 add_extralibs -lposix4
798 # Process ARM architecture variants
801 # on arm, isa versions are supersets
808 # Only enable neon_asm when neon is also enabled.
809 enabled neon && soft_enable neon_asm
810 # If someone tries to force it through, die.
811 if disabled neon && enabled neon_asm; then
812 die "Disabling neon while keeping neon-asm is not supported"
821 asm_conversion_cmd="cat"
825 CROSS=${CROSS:-arm-none-linux-gnueabi-}
828 arch_int=${tgt_isa##armv}
829 arch_int=${arch_int%%te}
830 check_add_asflags --defsym ARCHITECTURE=${arch_int}
831 tune_cflags="-mtune="
832 if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then
833 if [ -z "${float_abi}" ]; then
834 check_cpp <<EOF && float_abi=hard || float_abi=softfp
835 #ifndef __ARM_PCS_VFP
840 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
841 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
843 if enabled neon || enabled neon_asm; then
844 check_add_cflags -mfpu=neon #-ftree-vectorize
845 check_add_asflags -mfpu=neon
848 check_add_cflags -march=${tgt_isa}
849 check_add_asflags -march=${tgt_isa}
852 enabled debug && add_asflags -g
853 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
854 if enabled thumb; then
855 asm_conversion_cmd="$asm_conversion_cmd -thumb"
856 check_add_cflags -mthumb
857 check_add_asflags -mthumb -mimplicit-it=always
861 asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
863 msvs_arch_dir=arm-msvs
864 disable_feature multithread
865 disable_feature unit_tests
866 vs_version=${tgt_cc##vs}
867 if [ $vs_version -ge 12 ]; then
868 # MSVC 2013 doesn't allow doing plain .exe projects for ARM,
869 # only "AppContainerApplication" which requires an AppxManifest.
870 # Therefore disable the examples, just build the library.
871 disable_feature examples
878 LD="${source_path}/build/make/armlink_adapter.sh"
879 STRIP=arm-none-linux-gnueabi-strip
880 NM=arm-none-linux-gnueabi-nm
882 tune_asflags="--cpu="
883 if [ -z "${tune_cpu}" ]; then
884 if [ ${tgt_isa} = "armv7" ]; then
885 if enabled neon || enabled neon_asm
887 check_add_cflags --fpu=softvfp+vfpv3
888 check_add_asflags --fpu=softvfp+vfpv3
890 check_add_cflags --cpu=Cortex-A8
891 check_add_asflags --cpu=Cortex-A8
893 check_add_cflags --cpu=${tgt_isa##armv}
894 check_add_asflags --cpu=${tgt_isa##armv}
897 arch_int=${tgt_isa##armv}
898 arch_int=${arch_int%%te}
899 check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
900 enabled debug && add_asflags -g
902 add_cflags --enum_is_int
909 disable_feature multithread
910 disable_feature os_support
915 COMPILER_LOCATION=`find "${SDK_PATH}" \
916 -name "arm-linux-androideabi-gcc*" -print -quit`
917 TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
918 CC=${TOOLCHAIN_PATH}gcc
919 CXX=${TOOLCHAIN_PATH}g++
920 AR=${TOOLCHAIN_PATH}ar
921 LD=${TOOLCHAIN_PATH}gcc
922 AS=${TOOLCHAIN_PATH}as
923 STRIP=${TOOLCHAIN_PATH}strip
924 NM=${TOOLCHAIN_PATH}nm
926 if [ -z "${alt_libc}" ]; then
927 alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
928 awk '{n = split($0,a,"/"); \
929 split(a[n-1],b,"-"); \
930 print $0 " " b[2]}' | \
932 awk '{ print $1 }' | tail -1`
935 add_cflags "--sysroot=${alt_libc}"
936 add_ldflags "--sysroot=${alt_libc}"
938 # linker flag that routes around a CPU bug in some
939 # Cortex-A8 implementations (NDK Dev Guide)
940 add_ldflags "-Wl,--fix-cortex-a8"
943 soft_enable realtime_only
944 if [ ${tgt_isa} = "armv7" ]; then
945 soft_enable runtime_cpu_detect
947 if enabled runtime_cpu_detect; then
948 add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
953 XCRUN_FIND="xcrun --sdk iphoneos --find"
954 CXX="$(${XCRUN_FIND} clang++)"
955 CC="$(${XCRUN_FIND} clang)"
956 AR="$(${XCRUN_FIND} ar)"
957 AS="$(${XCRUN_FIND} as)"
958 STRIP="$(${XCRUN_FIND} strip)"
959 NM="$(${XCRUN_FIND} nm)"
960 RANLIB="$(${XCRUN_FIND} ranlib)"
963 # Special handling of ld for armv6 because libclang_rt.ios.a does
964 # not contain armv6 support in Apple's clang package:
965 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn).
966 # TODO(tomfinegan): Remove this. Our minimum iOS version (6.0)
967 # renders support for armv6 unnecessary because the 3GS and up
969 if [ "${tgt_isa}" = "armv6" ]; then
970 LD="$(${XCRUN_FIND} ld)"
972 LD="${CXX:-$(${XCRUN_FIND} ld)}"
975 # ASFLAGS is written here instead of using check_add_asflags
976 # because we need to overwrite all of ASFLAGS and purge the
977 # options that were put in above
978 ASFLAGS="-arch ${tgt_isa} -g"
980 add_cflags -arch ${tgt_isa}
981 add_ldflags -arch ${tgt_isa}
983 alt_libc="$(show_darwin_sdk_path iphoneos)"
984 if [ -d "${alt_libc}" ]; then
985 add_cflags -isysroot ${alt_libc}
988 if [ "${LD}" = "${CXX}" ]; then
989 add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}"
991 add_ldflags -ios_version_min "${IOS_VERSION_MIN}"
994 for d in lib usr/lib usr/lib/system; do
995 try_dir="${alt_libc}/${d}"
996 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
999 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
1003 enable_feature linux
1004 if enabled rvct; then
1005 # Check if we have CodeSourcery GCC in PATH. Needed for
1007 hash arm-none-linux-gnueabi-gcc 2>&- || \
1008 die "Couldn't find CodeSourcery GCC from PATH"
1010 # Use armcc as a linker to enable translation of
1011 # some gcc specific options such as -lm and -lpthread.
1012 LD="armcc --translate_gcc"
1014 # create configuration file (uses path to CodeSourcery GCC)
1015 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
1017 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1018 add_asflags --no_hide_all --apcs=/interwork
1019 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1020 enabled pic && add_cflags --apcs=/fpic
1021 enabled pic && add_asflags --apcs=/fpic
1022 enabled shared && add_cflags --shared
1030 tune_cflags="-mtune="
1031 if enabled dspr2; then
1032 check_add_cflags -mips32r2 -mdspr2
1035 if enabled runtime_cpu_detect; then
1036 disable_feature runtime_cpu_detect
1039 if [ -n "${tune_cpu}" ]; then
1042 check_add_cflags -mips32r5 -funroll-loops -mload-store-pairs
1043 check_add_cflags -msched-weight -mhard-float -mfp64
1044 check_add_asflags -mips32r5 -mhard-float -mfp64
1045 check_add_ldflags -mfp64
1048 check_add_cflags -mips64r6 -mabi=64 -funroll-loops -msched-weight
1049 check_add_cflags -mload-store-pairs -mhard-float -mfp64
1050 check_add_asflags -mips64r6 -mabi=64 -mhard-float -mfp64
1051 check_add_ldflags -mips64r6 -mabi=64 -mfp64
1055 if enabled msa; then
1062 check_add_cflags -march=${tgt_isa}
1063 check_add_asflags -march=${tgt_isa}
1064 check_add_asflags -KPIC
1069 enabled gcc && add_cflags -fno-common
1072 CC=${CC:-${CROSS}gcc}
1073 CXX=${CXX:-${CROSS}g++}
1074 LD=${LD:-${CROSS}gcc}
1080 add_ldflags -Zhigh-mem
1084 AS="${alt_as:-${AS:-auto}}"
1090 add_cflags -use-msasm # remove -use-msasm too?
1091 # add -no-intel-extensions to suppress warning #10237
1092 # refer to http://software.intel.com/en-us/forums/topic/280199
1093 add_ldflags -i-static -no-intel-extensions
1094 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
1095 enabled x86_64 && AR=xiar
1099 tune_cpu="SSE3_ATOM"
1102 tune_cflags="-march="
1108 tune_cflags="-march="
1110 #for 32 bit x86 builds, -O3 did not turn on this flag
1111 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
1114 # When building with Microsoft Visual Studio the assembler is
1115 # invoked directly. Checking at configure time is unnecessary.
1116 # Skip the check by setting AS arbitrarily
1118 msvs_arch_dir=x86-msvs
1119 vc_version=${tgt_cc##vs}
1122 echo "${tgt_cc} does not support avx/avx2, disabling....."
1123 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx --disable-avx2 "
1132 enabled x86_64 && bits=64
1133 check_cpp <<EOF && bits=x32
1134 #if !defined(__ILP32__) || !defined(__x86_64__)
1140 add_cflags -m${bits}
1141 add_ldflags -m${bits}
1145 soft_enable runtime_cpu_detect
1146 # We can't use 'check_cflags' until the compiler is configured and CC is
1148 check_gcc_machine_option mmx
1149 check_gcc_machine_option sse
1150 check_gcc_machine_option sse2
1151 check_gcc_machine_option sse3
1152 check_gcc_machine_option ssse3
1153 check_gcc_machine_option sse4 sse4_1
1154 check_gcc_machine_option avx
1155 check_gcc_machine_option avx2
1159 which nasm >/dev/null 2>&1 && AS=nasm
1160 which yasm >/dev/null 2>&1 && AS=yasm
1161 if [ "${AS}" = nasm ] ; then
1162 # Apple ships version 0.98 of nasm through at least Xcode 6. Revisit
1163 # this check if they start shipping a compatible version.
1164 apple=`nasm -v | grep "Apple"`
1166 && echo "Unsupported version of nasm: ${apple}" \
1169 [ "${AS}" = auto ] || [ -z "${AS}" ] \
1170 && die "Neither yasm nor nasm have been found"
1173 log_echo " using $AS"
1174 [ "${AS##*/}" = nasm ] && add_asflags -Ox
1178 add_asflags -f win32
1179 enabled debug && add_asflags -g cv8
1184 enabled debug && add_asflags -g cv8
1187 linux*|solaris*|android*)
1188 add_asflags -f elf${bits}
1189 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1190 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1191 [ "${AS##*/}" = nasm ] && check_asm_align
1194 add_asflags -f macho${bits}
1195 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1196 add_cflags ${darwin_arch}
1197 add_ldflags ${darwin_arch}
1198 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1199 # one time, but does not seem to be now, and it breaks some of the
1200 # code that still relies on inline assembly.
1201 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1202 enabled icc && ! enabled pic && add_cflags -fno-pic
1205 add_asflags -f macho${bits}
1206 enabled x86 && sim_arch="-arch i386" || sim_arch="-arch x86_64"
1207 add_cflags ${sim_arch}
1208 add_ldflags ${sim_arch}
1212 enabled debug && add_asflags -g
1216 log "Warning: Unknown os $tgt_os while setting up $AS flags"
1227 # Try to enable CPU specific tuning
1228 if [ -n "${tune_cpu}" ]; then
1229 if [ -n "${tune_cflags}" ]; then
1230 check_add_cflags ${tune_cflags}${tune_cpu} || \
1231 die "Requested CPU '${tune_cpu}' not supported by compiler"
1233 if [ -n "${tune_asflags}" ]; then
1234 check_add_asflags ${tune_asflags}${tune_cpu} || \
1235 die "Requested CPU '${tune_cpu}' not supported by assembler"
1237 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1238 log_echo "Warning: CPU tuning not supported by this toolchain"
1242 if enabled debug; then
1243 check_add_cflags -g && check_add_ldflags -g
1245 check_add_cflags -DNDEBUG
1248 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1250 check_add_cflags -fprofile-arcs -ftest-coverage &&
1251 check_add_ldflags -fprofile-arcs -ftest-coverage
1253 if enabled optimizations; then
1254 if enabled rvct; then
1255 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1257 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1261 if [ "${tgt_isa}" = "x86_64" ] || [ "${tgt_isa}" = "x86" ]; then
1262 soft_enable use_x86inc
1265 # Position Independent Code (PIC) support, for building relocatable
1267 enabled gcc && enabled pic && check_add_cflags -fPIC
1269 # Work around longjmp interception on glibc >= 2.11, to improve binary
1270 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1271 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1273 # Check for strip utility variant
1274 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
1276 # Try to determine target endianness
1278 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1280 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1281 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
1283 # Try to find which inline keywords are supported
1284 check_cc <<EOF && INLINE="inline"
1285 static inline function() {}
1288 # Almost every platform uses pthreads.
1289 if enabled multithread; then
1290 case ${toolchain} in
1296 check_header pthread.h && add_extralibs -lpthread
1301 # only for MIPS platforms
1302 case ${toolchain} in
1304 if enabled big_endian; then
1305 if enabled dspr2; then
1306 echo "dspr2 optimizations are available only for little endian platforms"
1307 disable_feature dspr2
1309 if enabled msa; then
1310 echo "msa optimizations are available only for little endian platforms"
1318 if enabled linux; then
1319 add_cflags -D_LARGEFILE_SOURCE
1320 add_cflags -D_FILE_OFFSET_BITS=64
1324 process_toolchain() {
1325 process_common_toolchain
1329 saved_prefix="${prefix}"
1334 if enabled $cfg; then
1335 upname="`toupper $cfg`"
1336 echo "${prefix}_${upname}=yes" >> $makefile
1339 prefix="${saved_prefix}"
1343 saved_prefix="${prefix}"
1348 upname="`toupper $cfg`"
1349 if enabled $cfg; then
1350 echo "#define ${prefix}_${upname} 1" >> $header
1352 echo "#define ${prefix}_${upname} 0" >> $header
1355 prefix="${saved_prefix}"
1358 print_config_vars_h() {
1361 while [ $# -gt 0 ]; do
1362 upname="`toupper $1`"
1363 echo "#define ${upname} $2" >> $header
1368 print_webm_license() {
1369 saved_prefix="${prefix}"
1374 cat <<EOF > ${destination}
1375 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1377 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1378 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1379 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1380 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1381 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1383 prefix="${saved_prefix}"
1394 enable_feature logging
1395 logfile="config.log"
1399 process_cmdline "$@"
1400 if enabled child; then
1401 echo "# ${self} $@" >> ${logfile}
1403 echo "# ${self} $@" > ${logfile}
1405 post_process_common_cmdline
1406 post_process_cmdline
1411 OOT_INSTALLS="${OOT_INSTALLS}"
1412 if enabled source_path_used; then
1413 # Prepare the PWD for building.
1414 for f in ${OOT_INSTALLS}; do
1415 install -D "${source_path}/$f" "$f"
1418 cp "${source_path}/build/make/Makefile" .