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."
27 echo "Configuration failed. This could reflect a misconfiguration of your"
28 echo "toolchains, improper options selected, or another problem. If you"
29 echo "don't see any useful error messages above, the next step is to look"
30 echo "at the configure error log file ($logfile) to determine what"
31 echo "configure was trying to do when it died."
58 echo "$@" >> ${outfile}
63 for opt in ${CMDLINE_SELECT}; do
64 opt2=`echo $opt | sed -e 's;_;-;g'`
66 eval "toggle_${opt}=\"--disable-${opt2}\""
68 eval "toggle_${opt}=\"--enable-${opt2} \""
73 Usage: configure [options]
77 --help print this message
78 --log=yes|no|FILE file configure log is written to [config.log]
79 --target=TARGET target platform tuple [generic-gnu]
80 --cpu=CPU optimize for a specific cpu rather than a family
81 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
82 ${toggle_extra_warnings} emit harmless warnings (always non-fatal)
83 ${toggle_werror} treat warnings as errors, if possible
84 (not available with all compilers)
85 ${toggle_optimizations} turn on/off compiler optimization flags
86 ${toggle_pic} turn on/off Position Independent Code
87 ${toggle_ccache} turn on/off compiler cache
88 ${toggle_debug} enable/disable debug mode
89 ${toggle_gprof} enable/disable gprof profiling instrumentation
90 ${toggle_gcov} enable/disable gcov coverage instrumentation
91 ${toggle_thumb} enable/disable building arm assembly in thumb mode
94 ${toggle_install_docs} control whether docs are installed
95 ${toggle_install_bins} control whether binaries are installed
96 ${toggle_install_libs} control whether libraries are installed
97 ${toggle_install_srcs} control whether sources are installed
109 Object files are built at the place where configure is launched.
111 All boolean options can be negated. The default value is the opposite
112 of that shown above. If the option --disable-foo is listed, then
113 the default value for foo is enabled.
117 show_targets ${all_platforms}
124 while [ -n "$*" ]; do
125 if [ "${1%%-*}" = "${2%%-*}" ]; then
126 if [ "${2%%-*}" = "${3%%-*}" ]; then
127 printf " %-24s %-24s %-24s\n" "$1" "$2" "$3"
130 printf " %-24s %-24s\n" "$1" "$2"
134 printf " %-24s\n" "$1"
147 # List Processing Functions
162 [ $var = $value ] && return 0
169 CFLAGS="${CFLAGS} $@"
170 CXXFLAGS="${CXXFLAGS} $@"
175 CFLAGS="${CFLAGS} $@"
179 add_cxxflags_only() {
180 CXXFLAGS="${CXXFLAGS} $@"
185 LDFLAGS="${LDFLAGS} $@"
190 ASFLAGS="${ASFLAGS} $@"
195 extralibs="${extralibs} $@"
199 # Boolean Manipulation Functions
210 eval test "x\$$1" = "xyes"
214 eval test "x\$$1" = "xno"
220 if ! disabled $var; then
221 log_echo " enabling $var"
229 if ! enabled $var; then
230 log_echo " disabling $var"
238 # Text Processing Functions
241 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
246 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
251 # Temporary File Functions
254 enable_feature source_path_used
255 if [ -z "$source_path" ] || [ "$source_path" = "." ]; then
257 disable_feature source_path_used
260 if test ! -z "$TMPDIR" ; then
262 elif test ! -z "$TEMPDIR" ; then
267 RAND=$(awk 'BEGIN { srand(); printf "%d\n",(rand() * 32768)}')
268 TMP_H="${TMPDIRx}/vpx-conf-$$-${RAND}.h"
269 TMP_C="${TMPDIRx}/vpx-conf-$$-${RAND}.c"
270 TMP_CC="${TMPDIRx}/vpx-conf-$$-${RAND}.cc"
271 TMP_O="${TMPDIRx}/vpx-conf-$$-${RAND}.o"
272 TMP_X="${TMPDIRx}/vpx-conf-$$-${RAND}.x"
273 TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RAND}.asm"
276 rm -f ${TMP_C} ${TMP_CC} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM}
277 enabled gcov && rm -f ${TMP_C%.c}.gcno ${TMP_CC%.cc}.gcno
281 # Toolchain Check Functions
284 enabled external_build && return
286 "$@" >>${logfile} 2>&1
293 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
300 check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_CC}
307 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
313 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
317 log check_header "$@"
320 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
322 check_cpp "$@" <<EOF && enable_feature $var
330 log check_cflags "$@"
331 check_cc -Werror "$@" <<EOF
337 log check_cxxflags "$@"
339 # Catch CFLAGS that trigger CXX warnings
341 *c++-analyzer|*clang++|*g++*) check_cxx -Werror "$@" <<EOF
345 *) check_cxx -Werror "$@" <<EOF
353 check_cxxflags "$@" && add_cxxflags_only "$@"
354 check_cflags "$@" && add_cflags_only "$@"
357 check_add_asflags() {
362 check_add_ldflags() {
368 log check_asm_align "$@"
369 cat >${TMP_ASM} <<EOF
374 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
375 readelf -WS ${TMP_O} >${TMP_X}
377 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
378 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
382 # tests for -m$1 toggling the feature given in $2. If $2 is empty $1 is used.
383 check_gcc_machine_option() {
386 [ -n "$feature" ] || feature="$opt"
388 if enabled gcc && ! disabled "$feature" && ! check_cflags "-m$opt"; then
389 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
391 soft_enable "$feature"
395 write_common_config_banner() {
396 print_webm_license config.mk "##" ""
397 echo '# This file automatically generated by configure. Do not edit!' >> config.mk
398 echo "TOOLCHAIN := ${toolchain}" >> config.mk
402 echo "ALT_LIBC := ${alt_libc}" >> config.mk
407 write_common_config_targets() {
408 for t in ${all_targets}; do
409 if enabled ${t}; then
410 if enabled universal || enabled child; then
411 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
413 fwrite config.mk "ALL_TARGETS += ${t}"
421 write_common_target_config_mk() {
424 enabled ccache && CC="ccache ${CC}"
425 enabled ccache && CXX="ccache ${CXX}"
426 print_webm_license $1 "##" ""
429 # This file automatically generated by configure. Do not edit!
430 SRC_PATH="$source_path"
431 SRC_PATH_BARE=$source_path
432 BUILD_PFX=${BUILD_PFX}
433 TOOLCHAIN=${toolchain}
434 ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
435 GEN_VCPROJ=${gen_vcproj_cmd}
436 MSVS_ARCH_DIR=${msvs_arch_dir}
447 CXXFLAGS = ${CXXFLAGS}
448 ARFLAGS = -rus\$(if \$(quiet),c,v)
451 extralibs = ${extralibs}
452 AS_SFX = ${AS_SFX:-.asm}
454 VCPROJ_SFX = ${VCPROJ_SFX}
455 RTCD_OPTIONS = ${RTCD_OPTIONS}
458 if enabled rvct; then cat >> $1 << EOF
459 fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide
461 else cat >> $1 << EOF
462 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;'
466 print_config_mk ARCH "${1}" ${ARCH_LIST}
467 print_config_mk HAVE "${1}" ${HAVE_LIST}
468 print_config_mk CONFIG "${1}" ${CONFIG_LIST}
469 print_config_mk HAVE "${1}" gnu_strip
471 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
478 write_common_target_config_h() {
479 print_webm_license ${TMP_H} "/*" " */"
480 cat >> ${TMP_H} << EOF
481 /* This file automatically generated by configure. Do not edit! */
484 #define RESTRICT ${RESTRICT}
485 #define INLINE ${INLINE}
487 print_config_h ARCH "${TMP_H}" ${ARCH_LIST}
488 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
489 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
490 print_config_vars_h "${TMP_H}" ${VAR_LIST}
491 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
492 mkdir -p `dirname "$1"`
493 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
496 process_common_cmdline() {
500 --child) enable_feature child
504 if ! disabled logging ; then
505 enabled logging || logfile="$logging"
510 --target=*) toolchain="${toolchain:-${optval}}"
512 --force-target=*) toolchain="${toolchain:-${optval}}"; enable_feature force_toolchain
516 --cpu=*) tune_cpu="$optval"
519 extra_cflags="${optval}"
521 --enable-?*|--disable-?*)
522 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
523 if echo "${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null; then
524 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${option} "
525 elif [ $action = "disable" ] && ! disabled $option ; then
526 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
528 elif [ $action = "enable" ] && ! enabled $option ; then
529 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
532 ${action}_feature $option
535 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
536 if echo "${ARCH_EXT_LIST}" none | grep "^ *$option\$" >/dev/null; then
537 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
542 --force-enable-?*|--force-disable-?*)
543 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
544 ${action}_feature $option
547 [ -d "${optval}" ] || die "Not a directory: ${optval}"
548 disable_feature builtin_libc
552 [ "${optval}" = yasm ] || [ "${optval}" = nasm ] \
553 || [ "${optval}" = auto ] \
554 || die "Must be yasm, nasm or auto: ${optval}"
560 VAR_LIST="DECODE_WIDTH_LIMIT ${w} DECODE_HEIGHT_LIMIT ${h}"
561 [ ${w} -gt 0 ] && [ ${h} -gt 0 ] || die "Invalid size-limit: too small."
562 [ ${w} -lt 65536 ] && [ ${h} -lt 65536 ] \
563 || die "Invalid size-limit: too big."
564 enable_feature size_limit
573 [ -d "${optval}" ] || die "Not a directory: ${optval}"
576 --libc|--as|--prefix|--libdir|--sdk-path)
577 die "Option ${opt} requires argument"
591 *) process_common_cmdline $opt
598 post_process_common_cmdline() {
599 prefix="${prefix:-/usr/local}"
601 libdir="${libdir:-${prefix}/lib}"
603 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
604 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
609 post_process_cmdline() {
613 setup_gnu_toolchain() {
614 CC=${CC:-${CROSS}gcc}
615 CXX=${CXX:-${CROSS}g++}
617 LD=${LD:-${CROSS}${link_with_cc:-ld}}
619 STRIP=${STRIP:-${CROSS}strip}
625 process_common_toolchain() {
626 if [ -z "$toolchain" ]; then
627 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
692 [ -z "$tgt_isa" ] && tgt_isa=x86
706 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
707 toolchain=${tgt_isa}-${tgt_os}-gcc
711 toolchain=${toolchain:-generic-gnu}
713 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
714 || die "Unrecognized toolchain '${toolchain}'"
716 enabled child || log_echo "Configuring for target '${toolchain}'"
719 # Set up toolchain variables
721 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
722 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
723 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
725 # Mark the specific ISA requested as enabled
726 soft_enable ${tgt_isa}
727 enable_feature ${tgt_os}
728 enable_feature ${tgt_cc}
730 # Enable the architecture family
732 arm*) enable_feature arm;;
733 mips*) enable_feature mips;;
736 # PIC is probably what we want when building shared libs
737 enabled shared && soft_enable pic
739 # Minimum iOS version for all target platforms (darwin and iphonesimulator).
740 IOS_VERSION_MIN="6.0"
742 # Handle darwin variants. Newer SDKs allow targeting older
743 # platforms, so find the newest SDK available.
746 if [ -z "${DEVELOPER_DIR}" ]; then
747 DEVELOPER_DIR=`xcode-select -print-path 2> /dev/null`
748 [ $? -ne 0 ] && OSX_SKIP_DIR_CHECK=1
750 if [ -z "${OSX_SKIP_DIR_CHECK}" ]; then
751 OSX_SDK_ROOTS="${DEVELOPER_DIR}/SDKs"
752 OSX_SDK_VERSIONS="MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk"
753 OSX_SDK_VERSIONS="${OSX_SDK_VERSIONS} MacOSX10.7.sdk"
754 for v in ${OSX_SDK_VERSIONS}; do
755 if [ -d "${OSX_SDK_ROOTS}/${v}" ]; then
756 osx_sdk_dir="${OSX_SDK_ROOTS}/${v}"
763 if [ -d "${osx_sdk_dir}" ]; then
764 add_cflags "-isysroot ${osx_sdk_dir}"
765 add_ldflags "-isysroot ${osx_sdk_dir}"
770 add_cflags "-mmacosx-version-min=10.4"
771 add_ldflags "-mmacosx-version-min=10.4"
774 add_cflags "-mmacosx-version-min=10.5"
775 add_ldflags "-mmacosx-version-min=10.5"
778 add_cflags "-mmacosx-version-min=10.6"
779 add_ldflags "-mmacosx-version-min=10.6"
782 add_cflags "-mmacosx-version-min=10.7"
783 add_ldflags "-mmacosx-version-min=10.7"
786 add_cflags "-mmacosx-version-min=10.8"
787 add_ldflags "-mmacosx-version-min=10.8"
790 add_cflags "-mmacosx-version-min=10.9"
791 add_ldflags "-mmacosx-version-min=10.9"
794 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
795 add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
796 osx_sdk_dir="$(xcrun --sdk iphonesimulator --show-sdk-path)"
797 add_cflags "-isysroot ${osx_sdk_dir}"
798 add_ldflags "-isysroot ${osx_sdk_dir}"
802 # Handle Solaris variants. Solaris 10 needs -lposix4
805 add_extralibs -lposix4
806 disable_feature fast_unaligned
809 add_extralibs -lposix4
813 # Process ARM architecture variants
816 # on arm, isa versions are supersets
826 soft_enable fast_unaligned
831 soft_enable fast_unaligned
835 disable_feature fast_unaligned
839 asm_conversion_cmd="cat"
843 CROSS=${CROSS:-arm-none-linux-gnueabi-}
846 arch_int=${tgt_isa##armv}
847 arch_int=${arch_int%%te}
848 check_add_asflags --defsym ARCHITECTURE=${arch_int}
849 tune_cflags="-mtune="
850 if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then
851 if [ -z "${float_abi}" ]; then
852 check_cpp <<EOF && float_abi=hard || float_abi=softfp
853 #ifndef __ARM_PCS_VFP
858 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
859 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
861 if enabled neon || enabled neon_asm
863 check_add_cflags -mfpu=neon #-ftree-vectorize
864 check_add_asflags -mfpu=neon
867 if [ -z "${tune_cpu}" ]; then
871 check_add_cflags -march=${tgt_isa}
872 check_add_asflags -march=${tgt_isa}
875 enabled debug && add_asflags -g
876 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
877 if enabled thumb; then
878 asm_conversion_cmd="$asm_conversion_cmd -thumb"
879 check_add_cflags -mthumb
880 check_add_asflags -mthumb -mimplicit-it=always
884 asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
886 msvs_arch_dir=arm-msvs
887 disable_feature multithread
888 disable_feature unit_tests
889 vs_version=${tgt_cc##vs}
890 if [ $vs_version -ge 12 ]; then
891 # MSVC 2013 doesn't allow doing plain .exe projects for ARM,
892 # only "AppContainerApplication" which requires an AppxManifest.
893 # Therefore disable the examples, just build the library.
894 disable_feature examples
901 LD="${source_path}/build/make/armlink_adapter.sh"
902 STRIP=arm-none-linux-gnueabi-strip
903 NM=arm-none-linux-gnueabi-nm
905 tune_asflags="--cpu="
906 if [ -z "${tune_cpu}" ]; then
907 if [ ${tgt_isa} = "armv7" ]; then
908 if enabled neon || enabled neon_asm
910 check_add_cflags --fpu=softvfp+vfpv3
911 check_add_asflags --fpu=softvfp+vfpv3
913 check_add_cflags --cpu=Cortex-A8
914 check_add_asflags --cpu=Cortex-A8
916 check_add_cflags --cpu=${tgt_isa##armv}
917 check_add_asflags --cpu=${tgt_isa##armv}
920 arch_int=${tgt_isa##armv}
921 arch_int=${arch_int%%te}
922 check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
923 enabled debug && add_asflags -g
925 add_cflags --enum_is_int
932 disable_feature multithread
933 disable_feature os_support
938 COMPILER_LOCATION=`find "${SDK_PATH}" \
939 -name "arm-linux-androideabi-gcc*" -print -quit`
940 TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
941 CC=${TOOLCHAIN_PATH}gcc
942 CXX=${TOOLCHAIN_PATH}g++
943 AR=${TOOLCHAIN_PATH}ar
944 LD=${TOOLCHAIN_PATH}gcc
945 AS=${TOOLCHAIN_PATH}as
946 STRIP=${TOOLCHAIN_PATH}strip
947 NM=${TOOLCHAIN_PATH}nm
949 if [ -z "${alt_libc}" ]; then
950 alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
951 awk '{n = split($0,a,"/"); \
952 split(a[n-1],b,"-"); \
953 print $0 " " b[2]}' | \
955 awk '{ print $1 }' | tail -1`
958 add_cflags "--sysroot=${alt_libc}"
959 add_ldflags "--sysroot=${alt_libc}"
961 # linker flag that routes around a CPU bug in some
962 # Cortex-A8 implementations (NDK Dev Guide)
963 add_ldflags "-Wl,--fix-cortex-a8"
966 soft_enable realtime_only
967 if [ ${tgt_isa} = "armv7" ]; then
968 soft_enable runtime_cpu_detect
970 if enabled runtime_cpu_detect; then
971 add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
976 XCRUN_FIND="xcrun --sdk iphoneos -find"
977 CXX="$(${XCRUN_FIND} clang++)"
978 CC="$(${XCRUN_FIND} clang)"
979 AR="$(${XCRUN_FIND} ar)"
980 AS="$(${XCRUN_FIND} as)"
981 STRIP="$(${XCRUN_FIND} strip)"
982 NM="$(${XCRUN_FIND} nm)"
983 RANLIB="$(${XCRUN_FIND} ranlib)"
986 # Special handling of ld for armv6 because libclang_rt.ios.a does
987 # not contain armv6 support in Apple's clang package:
988 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn).
989 # TODO(tomfinegan): Remove this. Our minimum iOS version (6.0)
990 # renders support for armv6 unnecessary because the 3GS and up
992 if [ "${tgt_isa}" = "armv6" ]; then
993 LD="$(${XCRUN_FIND} ld)"
995 LD="${CXX:-$(${XCRUN_FIND} ld)}"
998 # ASFLAGS is written here instead of using check_add_asflags
999 # because we need to overwrite all of ASFLAGS and purge the
1000 # options that were put in above
1001 ASFLAGS="-arch ${tgt_isa} -g"
1003 alt_libc="$(xcrun --sdk iphoneos --show-sdk-path)"
1004 add_cflags -arch ${tgt_isa} -isysroot ${alt_libc}
1005 add_ldflags -arch ${tgt_isa}
1007 if [ "${LD}" = "${CXX}" ]; then
1008 add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}"
1010 add_ldflags -ios_version_min "${IOS_VERSION_MIN}"
1013 for d in lib usr/lib usr/lib/system; do
1014 try_dir="${alt_libc}/${d}"
1015 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
1018 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
1022 enable_feature linux
1023 if enabled rvct; then
1024 # Check if we have CodeSourcery GCC in PATH. Needed for
1026 hash arm-none-linux-gnueabi-gcc 2>&- || \
1027 die "Couldn't find CodeSourcery GCC from PATH"
1029 # Use armcc as a linker to enable translation of
1030 # some gcc specific options such as -lm and -lpthread.
1031 LD="armcc --translate_gcc"
1033 # create configuration file (uses path to CodeSourcery GCC)
1034 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
1036 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1037 add_asflags --no_hide_all --apcs=/interwork
1038 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
1039 enabled pic && add_cflags --apcs=/fpic
1040 enabled pic && add_asflags --apcs=/fpic
1041 enabled shared && add_cflags --shared
1050 tune_cflags="-mtune="
1051 if enabled dspr2; then
1052 check_add_cflags -mips32r2 -mdspr2
1053 disable_feature fast_unaligned
1055 check_add_cflags -march=${tgt_isa}
1056 check_add_asflags -march=${tgt_isa}
1057 check_add_asflags -KPIC
1061 bits=${tgt_isa##ppc}
1064 add_asflags -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
1066 enabled altivec && add_cflags -maltivec
1070 add_asflags -maltivec -mregnames -I"\$(dir \$<)linux"
1073 darwin_arch="-arch ppc"
1074 enabled ppc64 && darwin_arch="${darwin_arch}64"
1075 add_cflags ${darwin_arch} -m${bits} -fasm-blocks
1076 add_asflags ${darwin_arch} -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
1077 add_ldflags ${darwin_arch} -m${bits}
1078 enabled altivec && add_cflags -faltivec
1085 enabled gcc && add_cflags -fno-common
1088 CC=${CC:-${CROSS}gcc}
1089 CXX=${CXX:-${CROSS}g++}
1090 LD=${LD:-${CROSS}gcc}
1098 AS="${alt_as:-${AS:-auto}}"
1104 add_cflags -use-msasm # remove -use-msasm too?
1105 # add -no-intel-extensions to suppress warning #10237
1106 # refer to http://software.intel.com/en-us/forums/topic/280199
1107 add_ldflags -i-static -no-intel-extensions
1108 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
1109 enabled x86_64 && AR=xiar
1113 tune_cpu="SSE3_ATOM"
1116 tune_cflags="-march="
1122 tune_cflags="-march="
1124 #for 32 bit x86 builds, -O3 did not turn on this flag
1125 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
1128 # When building with Microsoft Visual Studio the assembler is
1129 # invoked directly. Checking at configure time is unnecessary.
1130 # Skip the check by setting AS arbitrarily
1132 msvs_arch_dir=x86-msvs
1133 vc_version=${tgt_cc##vs}
1136 echo "${tgt_cc} does not support avx/avx2, disabling....."
1137 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx --disable-avx2 "
1146 enabled x86_64 && bits=64
1147 check_cpp <<EOF && bits=x32
1154 add_cflags -m${bits}
1155 add_ldflags -m${bits}
1159 soft_enable runtime_cpu_detect
1160 # We can't use 'check_cflags' until the compiler is configured and CC is
1162 check_gcc_machine_option mmx
1163 check_gcc_machine_option sse
1164 check_gcc_machine_option sse2
1165 check_gcc_machine_option sse3
1166 check_gcc_machine_option ssse3
1167 check_gcc_machine_option sse4 sse4_1
1168 check_gcc_machine_option avx
1169 check_gcc_machine_option avx2
1173 which nasm >/dev/null 2>&1 && AS=nasm
1174 which yasm >/dev/null 2>&1 && AS=yasm
1175 [ "${AS}" = auto ] || [ -z "${AS}" ] \
1176 && die "Neither yasm nor nasm have been found"
1179 log_echo " using $AS"
1180 [ "${AS##*/}" = nasm ] && add_asflags -Ox
1184 add_asflags -f win32
1185 enabled debug && add_asflags -g cv8
1190 enabled debug && add_asflags -g cv8
1193 linux*|solaris*|android*)
1194 add_asflags -f elf${bits}
1195 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1196 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1197 [ "${AS##*/}" = nasm ] && check_asm_align
1200 add_asflags -f macho${bits}
1201 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1202 add_cflags ${darwin_arch}
1203 add_ldflags ${darwin_arch}
1204 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1205 # one time, but does not seem to be now, and it breaks some of the
1206 # code that still relies on inline assembly.
1207 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1208 enabled icc && ! enabled pic && add_cflags -fno-pic
1211 add_asflags -f macho${bits}
1212 enabled x86 && sim_arch="-arch i386" || sim_arch="-arch x86_64"
1213 add_cflags ${sim_arch}
1214 add_ldflags ${sim_arch}
1218 enabled debug && add_asflags -g
1221 *) log "Warning: Unknown os $tgt_os while setting up $AS flags"
1225 universal*|*-gcc|generic-gnu)
1232 # Try to enable CPU specific tuning
1233 if [ -n "${tune_cpu}" ]; then
1234 if [ -n "${tune_cflags}" ]; then
1235 check_add_cflags ${tune_cflags}${tune_cpu} || \
1236 die "Requested CPU '${tune_cpu}' not supported by compiler"
1238 if [ -n "${tune_asflags}" ]; then
1239 check_add_asflags ${tune_asflags}${tune_cpu} || \
1240 die "Requested CPU '${tune_cpu}' not supported by assembler"
1242 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1243 log_echo "Warning: CPU tuning not supported by this toolchain"
1247 if enabled debug; then
1248 check_add_cflags -g && check_add_ldflags -g
1250 check_add_cflags -DNDEBUG
1253 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1255 check_add_cflags -fprofile-arcs -ftest-coverage &&
1256 check_add_ldflags -fprofile-arcs -ftest-coverage
1258 if enabled optimizations; then
1259 if enabled rvct; then
1260 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1262 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1266 tgt_os_no_version=$(echo "${tgt_os}" | tr -d "[0-9]")
1267 # Default use_x86inc to yes when we are 64 bit, non-pic, or on any
1268 # non-Darwin target.
1269 if [ "${tgt_isa}" = "x86_64" ] || [ "${pic}" != "yes" ] || \
1270 [ "${tgt_os_no_version}" != "darwin" ]; then
1271 soft_enable use_x86inc
1274 # Position Independent Code (PIC) support, for building relocatable
1276 enabled gcc && enabled pic && check_add_cflags -fPIC
1278 # Work around longjmp interception on glibc >= 2.11, to improve binary
1279 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1280 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1282 # Check for strip utility variant
1283 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
1285 # Try to determine target endianness
1287 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1289 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1290 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
1292 # Try to find which inline keywords are supported
1293 check_cc <<EOF && INLINE="inline"
1294 static inline function() {}
1296 check_cc <<EOF && INLINE="__inline__ __attribute__((always_inline))"
1297 static __attribute__((always_inline)) function() {}
1300 # Almost every platform uses pthreads.
1301 if enabled multithread; then
1302 case ${toolchain} in
1305 *) check_header pthread.h && add_extralibs -lpthread
1309 # only for MIPS platforms
1310 case ${toolchain} in
1312 if enabled dspr2; then
1313 if enabled big_endian; then
1314 echo "dspr2 optimizations are available only for little endian platforms"
1315 disable_feature dspr2
1322 if enabled linux; then
1323 add_cflags -D_LARGEFILE_SOURCE
1324 add_cflags -D_FILE_OFFSET_BITS=64
1327 # append any user defined extra cflags
1328 if [ -n "${extra_cflags}" ] ; then
1329 check_add_cflags ${extra_cflags} || \
1330 die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler"
1334 process_toolchain() {
1335 process_common_toolchain
1339 saved_prefix="${prefix}"
1344 if enabled $cfg; then
1345 upname="`toupper $cfg`"
1346 echo "${prefix}_${upname}=yes" >> $makefile
1349 prefix="${saved_prefix}"
1353 saved_prefix="${prefix}"
1358 upname="`toupper $cfg`"
1359 if enabled $cfg; then
1360 echo "#define ${prefix}_${upname} 1" >> $header
1362 echo "#define ${prefix}_${upname} 0" >> $header
1365 prefix="${saved_prefix}"
1368 print_config_vars_h() {
1371 while [ $# -gt 0 ]; do
1372 upname="`toupper $1`"
1373 echo "#define ${upname} $2" >> $header
1378 print_webm_license() {
1379 saved_prefix="${prefix}"
1384 cat <<EOF > ${destination}
1385 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1387 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1388 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1389 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1390 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1391 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1393 prefix="${saved_prefix}"
1404 enable_feature logging
1405 logfile="config.log"
1409 process_cmdline "$@"
1410 if enabled child; then
1411 echo "# ${self} $@" >> ${logfile}
1413 echo "# ${self} $@" > ${logfile}
1415 post_process_common_cmdline
1416 post_process_cmdline
1421 OOT_INSTALLS="${OOT_INSTALLS}"
1422 if enabled source_path_used; then
1423 # Prepare the PWD for building.
1424 for f in ${OOT_INSTALLS}; do
1425 install -D "${source_path}/$f" "$f"
1428 cp "${source_path}/build/make/Makefile" .