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 test -z "$source_path" -o "$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}"
476 write_common_target_config_h() {
477 print_webm_license ${TMP_H} "/*" " */"
478 cat >> ${TMP_H} << EOF
479 /* This file automatically generated by configure. Do not edit! */
482 #define RESTRICT ${RESTRICT}
483 #define INLINE ${INLINE}
485 print_config_h ARCH "${TMP_H}" ${ARCH_LIST}
486 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
487 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
488 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
489 mkdir -p `dirname "$1"`
490 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
493 process_common_cmdline() {
497 --child) enable_feature child
501 if ! disabled logging ; then
502 enabled logging || logfile="$logging"
507 --target=*) toolchain="${toolchain:-${optval}}"
509 --force-target=*) toolchain="${toolchain:-${optval}}"; enable_feature force_toolchain
513 --cpu=*) tune_cpu="$optval"
516 extra_cflags="${optval}"
518 --enable-?*|--disable-?*)
519 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
520 if echo "${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null; then
521 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
522 elif [ $action = "disable" ] && ! disabled $option ; then
523 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
525 elif [ $action = "enable" ] && ! enabled $option ; then
526 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
529 ${action}_feature $option
532 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
533 if echo "${ARCH_EXT_LIST}" none | grep "^ *$option\$" >/dev/null; then
534 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
539 --force-enable-?*|--force-disable-?*)
540 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
541 ${action}_feature $option
544 [ -d "${optval}" ] || die "Not a directory: ${optval}"
545 disable_feature builtin_libc
549 [ "${optval}" = yasm -o "${optval}" = nasm -o "${optval}" = auto ] \
550 || die "Must be yasm, nasm or auto: ${optval}"
560 [ -d "${optval}" ] || die "Not a directory: ${optval}"
563 --libc|--as|--prefix|--libdir|--sdk-path)
564 die "Option ${opt} requires argument"
578 *) process_common_cmdline $opt
585 post_process_common_cmdline() {
586 prefix="${prefix:-/usr/local}"
588 libdir="${libdir:-${prefix}/lib}"
590 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
591 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
596 post_process_cmdline() {
600 setup_gnu_toolchain() {
601 CC=${CC:-${CROSS}gcc}
602 CXX=${CXX:-${CROSS}g++}
604 LD=${LD:-${CROSS}${link_with_cc:-ld}}
606 STRIP=${STRIP:-${CROSS}strip}
612 process_common_toolchain() {
613 if [ -z "$toolchain" ]; then
614 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
679 [ -z "$tgt_isa" ] && tgt_isa=x86
693 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
694 toolchain=${tgt_isa}-${tgt_os}-gcc
698 toolchain=${toolchain:-generic-gnu}
700 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
701 || die "Unrecognized toolchain '${toolchain}'"
703 enabled child || log_echo "Configuring for target '${toolchain}'"
706 # Set up toolchain variables
708 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
709 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
710 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
712 # Mark the specific ISA requested as enabled
713 soft_enable ${tgt_isa}
714 enable_feature ${tgt_os}
715 enable_feature ${tgt_cc}
717 # Enable the architecture family
719 arm*) enable_feature arm;;
720 mips*) enable_feature mips;;
723 # PIC is probably what we want when building shared libs
724 enabled shared && soft_enable pic
726 # Handle darwin variants. Newer SDKs allow targeting older
727 # platforms, so find the newest SDK available.
730 if [ -z "${DEVELOPER_DIR}" ]; then
731 DEVELOPER_DIR=`xcode-select -print-path 2> /dev/null`
732 [ $? -ne 0 ] && OSX_SKIP_DIR_CHECK=1
734 if [ -z "${OSX_SKIP_DIR_CHECK}" ]; then
735 OSX_SDK_ROOTS="${DEVELOPER_DIR}/SDKs"
736 OSX_SDK_VERSIONS="MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk"
737 OSX_SDK_VERSIONS="${OSX_SDK_VERSIONS} MacOSX10.7.sdk"
738 for v in ${OSX_SDK_VERSIONS}; do
739 if [ -d "${OSX_SDK_ROOTS}/${v}" ]; then
740 osx_sdk_dir="${OSX_SDK_ROOTS}/${v}"
747 if [ -d "${osx_sdk_dir}" ]; then
748 add_cflags "-isysroot ${osx_sdk_dir}"
749 add_ldflags "-isysroot ${osx_sdk_dir}"
754 add_cflags "-mmacosx-version-min=10.4"
755 add_ldflags "-mmacosx-version-min=10.4"
758 add_cflags "-mmacosx-version-min=10.5"
759 add_ldflags "-mmacosx-version-min=10.5"
762 add_cflags "-mmacosx-version-min=10.6"
763 add_ldflags "-mmacosx-version-min=10.6"
766 add_cflags "-mmacosx-version-min=10.7"
767 add_ldflags "-mmacosx-version-min=10.7"
770 add_cflags "-mmacosx-version-min=10.8"
771 add_ldflags "-mmacosx-version-min=10.8"
774 add_cflags "-mmacosx-version-min=10.9"
775 add_ldflags "-mmacosx-version-min=10.9"
779 # Handle Solaris variants. Solaris 10 needs -lposix4
782 add_extralibs -lposix4
783 disable_feature fast_unaligned
786 add_extralibs -lposix4
790 # Process ARM architecture variants
793 # on arm, isa versions are supersets
799 soft_enable fast_unaligned
804 soft_enable fast_unaligned
808 disable_feature fast_unaligned
812 asm_conversion_cmd="cat"
816 CROSS=${CROSS:-arm-none-linux-gnueabi-}
819 arch_int=${tgt_isa##armv}
820 arch_int=${arch_int%%te}
821 check_add_asflags --defsym ARCHITECTURE=${arch_int}
822 tune_cflags="-mtune="
823 if [ ${tgt_isa} = "armv7" ]; then
824 if [ -z "${float_abi}" ]; then
825 check_cpp <<EOF && float_abi=hard || float_abi=softfp
826 #ifndef __ARM_PCS_VFP
831 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
832 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
836 check_add_cflags -mfpu=neon #-ftree-vectorize
837 check_add_asflags -mfpu=neon
840 if [ -z "${tune_cpu}" ]; then
844 check_add_cflags -march=${tgt_isa}
845 check_add_asflags -march=${tgt_isa}
848 enabled debug && add_asflags -g
849 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
850 if enabled thumb; then
851 asm_conversion_cmd="$asm_conversion_cmd -thumb"
852 check_add_cflags -mthumb
853 check_add_asflags -mthumb -mimplicit-it=always
857 asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
859 msvs_arch_dir=arm-msvs
860 disable_feature multithread
861 disable_feature unit_tests
862 vs_version=${tgt_cc##vs}
863 if [ $vs_version -ge 12 ]; then
864 # MSVC 2013 doesn't allow doing plain .exe projects for ARM,
865 # only "AppContainerApplication" which requires an AppxManifest.
866 # Therefore disable the examples, just build the library.
867 disable_feature examples
874 LD="${source_path}/build/make/armlink_adapter.sh"
875 STRIP=arm-none-linux-gnueabi-strip
876 NM=arm-none-linux-gnueabi-nm
878 tune_asflags="--cpu="
879 if [ -z "${tune_cpu}" ]; then
880 if [ ${tgt_isa} = "armv7" ]; then
883 check_add_cflags --fpu=softvfp+vfpv3
884 check_add_asflags --fpu=softvfp+vfpv3
886 check_add_cflags --cpu=Cortex-A8
887 check_add_asflags --cpu=Cortex-A8
889 check_add_cflags --cpu=${tgt_isa##armv}
890 check_add_asflags --cpu=${tgt_isa##armv}
893 arch_int=${tgt_isa##armv}
894 arch_int=${arch_int%%te}
895 check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
896 enabled debug && add_asflags -g
898 add_cflags --enum_is_int
905 disable_feature multithread
906 disable_feature os_support
911 COMPILER_LOCATION=`find "${SDK_PATH}" \
912 -name "arm-linux-androideabi-gcc*" -print -quit`
913 TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
914 CC=${TOOLCHAIN_PATH}gcc
915 CXX=${TOOLCHAIN_PATH}g++
916 AR=${TOOLCHAIN_PATH}ar
917 LD=${TOOLCHAIN_PATH}gcc
918 AS=${TOOLCHAIN_PATH}as
919 STRIP=${TOOLCHAIN_PATH}strip
920 NM=${TOOLCHAIN_PATH}nm
922 if [ -z "${alt_libc}" ]; then
923 alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
924 awk '{n = split($0,a,"/"); \
925 split(a[n-1],b,"-"); \
926 print $0 " " b[2]}' | \
928 awk '{ print $1 }' | tail -1`
931 add_cflags "--sysroot=${alt_libc}"
932 add_ldflags "--sysroot=${alt_libc}"
934 # linker flag that routes around a CPU bug in some
935 # Cortex-A8 implementations (NDK Dev Guide)
936 add_ldflags "-Wl,--fix-cortex-a8"
939 soft_enable realtime_only
940 if [ ${tgt_isa} = "armv7" ]; then
941 soft_enable runtime_cpu_detect
943 if enabled runtime_cpu_detect; then
944 add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
950 XCRUN_FIND="xcrun --sdk iphoneos -find"
951 CXX="$(${XCRUN_FIND} clang++)"
952 CC="$(${XCRUN_FIND} clang)"
953 AR="$(${XCRUN_FIND} ar)"
954 LD="$(${XCRUN_FIND} ld)"
955 AS="$(${XCRUN_FIND} as)"
956 STRIP="$(${XCRUN_FIND} strip)"
957 NM="$(${XCRUN_FIND} nm)"
958 RANLIB="$(${XCRUN_FIND} ranlib)"
961 # ASFLAGS is written here instead of using check_add_asflags
962 # because we need to overwrite all of ASFLAGS and purge the
963 # options that were put in above
964 ASFLAGS="-arch ${tgt_isa} -g"
966 alt_libc="$(xcrun --sdk iphoneos --show-sdk-path)"
967 add_cflags -arch ${tgt_isa} -isysroot ${alt_libc}
968 add_ldflags -arch ${tgt_isa} -ios_version_min 7.0
970 for d in lib usr/lib usr/lib/system; do
971 try_dir="${alt_libc}/${d}"
972 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
975 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
980 if enabled rvct; then
981 # Check if we have CodeSourcery GCC in PATH. Needed for
983 hash arm-none-linux-gnueabi-gcc 2>&- || \
984 die "Couldn't find CodeSourcery GCC from PATH"
986 # Use armcc as a linker to enable translation of
987 # some gcc specific options such as -lm and -lpthread.
988 LD="armcc --translate_gcc"
990 # create configuration file (uses path to CodeSourcery GCC)
991 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
993 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
994 add_asflags --no_hide_all --apcs=/interwork
995 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
996 enabled pic && add_cflags --apcs=/fpic
997 enabled pic && add_asflags --apcs=/fpic
998 enabled shared && add_cflags --shared
1007 tune_cflags="-mtune="
1008 if enabled dspr2; then
1009 check_add_cflags -mips32r2 -mdspr2
1010 disable_feature fast_unaligned
1012 check_add_cflags -march=${tgt_isa}
1013 check_add_asflags -march=${tgt_isa}
1014 check_add_asflags -KPIC
1018 bits=${tgt_isa##ppc}
1021 add_asflags -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
1023 enabled altivec && add_cflags -maltivec
1027 add_asflags -maltivec -mregnames -I"\$(dir \$<)linux"
1030 darwin_arch="-arch ppc"
1031 enabled ppc64 && darwin_arch="${darwin_arch}64"
1032 add_cflags ${darwin_arch} -m${bits} -fasm-blocks
1033 add_asflags ${darwin_arch} -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
1034 add_ldflags ${darwin_arch} -m${bits}
1035 enabled altivec && add_cflags -faltivec
1041 enabled x86_64 && bits=64
1042 check_cpp <<EOF && bits=x32
1050 enabled gcc && add_cflags -fno-common
1053 CC=${CC:-${CROSS}gcc}
1054 CXX=${CXX:-${CROSS}g++}
1055 LD=${LD:-${CROSS}gcc}
1063 AS="${alt_as:-${AS:-auto}}"
1069 add_cflags -use-msasm # remove -use-msasm too?
1070 # add -no-intel-extensions to suppress warning #10237
1071 # refer to http://software.intel.com/en-us/forums/topic/280199
1072 add_ldflags -i-static -no-intel-extensions
1073 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
1074 enabled x86_64 && AR=xiar
1078 tune_cpu="SSE3_ATOM"
1081 tune_cflags="-march="
1086 add_cflags -m${bits}
1087 add_ldflags -m${bits}
1089 tune_cflags="-march="
1091 #for 32 bit x86 builds, -O3 did not turn on this flag
1092 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
1095 # When building with Microsoft Visual Studio the assembler is
1096 # invoked directly. Checking at configure time is unnecessary.
1097 # Skip the check by setting AS arbitrarily
1099 msvs_arch_dir=x86-msvs
1100 vc_version=${tgt_cc##vs}
1103 echo "${tgt_cc} does not support avx/avx2, disabling....."
1104 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx --disable-avx2 "
1112 soft_enable runtime_cpu_detect
1113 # We can't use 'check_cflags' until the compiler is configured and CC is
1115 check_gcc_machine_option mmx
1116 check_gcc_machine_option sse
1117 check_gcc_machine_option sse2
1118 check_gcc_machine_option sse3
1119 check_gcc_machine_option ssse3
1120 check_gcc_machine_option sse4 sse4_1
1121 check_gcc_machine_option avx
1122 check_gcc_machine_option avx2
1126 which nasm >/dev/null 2>&1 && AS=nasm
1127 which yasm >/dev/null 2>&1 && AS=yasm
1128 [ "${AS}" = auto -o -z "${AS}" ] \
1129 && die "Neither yasm nor nasm have been found"
1132 log_echo " using $AS"
1133 [ "${AS##*/}" = nasm ] && add_asflags -Ox
1137 add_asflags -f win32
1138 enabled debug && add_asflags -g cv8
1143 enabled debug && add_asflags -g cv8
1146 linux*|solaris*|android*)
1147 add_asflags -f elf${bits}
1148 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1149 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1150 [ "${AS##*/}" = nasm ] && check_asm_align
1153 add_asflags -f macho${bits}
1154 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1155 add_cflags ${darwin_arch}
1156 add_ldflags ${darwin_arch}
1157 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1158 # one time, but does not seem to be now, and it breaks some of the
1159 # code that still relies on inline assembly.
1160 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1161 enabled icc && ! enabled pic && add_cflags -fno-pic
1165 enabled debug && add_asflags -g
1168 *) log "Warning: Unknown os $tgt_os while setting up $AS flags"
1172 universal*|*-gcc|generic-gnu)
1179 # Try to enable CPU specific tuning
1180 if [ -n "${tune_cpu}" ]; then
1181 if [ -n "${tune_cflags}" ]; then
1182 check_add_cflags ${tune_cflags}${tune_cpu} || \
1183 die "Requested CPU '${tune_cpu}' not supported by compiler"
1185 if [ -n "${tune_asflags}" ]; then
1186 check_add_asflags ${tune_asflags}${tune_cpu} || \
1187 die "Requested CPU '${tune_cpu}' not supported by assembler"
1189 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1190 log_echo "Warning: CPU tuning not supported by this toolchain"
1194 enabled debug && check_add_cflags -g && check_add_ldflags -g
1195 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1197 check_add_cflags -fprofile-arcs -ftest-coverage &&
1198 check_add_ldflags -fprofile-arcs -ftest-coverage
1200 if enabled optimizations; then
1201 if enabled rvct; then
1202 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1204 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1208 # default use_x86inc to yes if pic is no or 64bit or we are not on darwin
1209 if [ ${tgt_isa} = x86_64 -o ! "$pic" = "yes" -o \
1210 "${tgt_os#darwin}" = "${tgt_os}" ]; then
1211 soft_enable use_x86inc
1214 # Position Independent Code (PIC) support, for building relocatable
1216 enabled gcc && enabled pic && check_add_cflags -fPIC
1218 # Work around longjmp interception on glibc >= 2.11, to improve binary
1219 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1220 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1222 # Check for strip utility variant
1223 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
1225 # Try to determine target endianness
1227 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1229 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1230 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
1232 # Try to find which inline keywords are supported
1233 check_cc <<EOF && INLINE="inline"
1234 static inline function() {}
1236 check_cc <<EOF && INLINE="__inline__ __attribute__((always_inline))"
1237 static __attribute__((always_inline)) function() {}
1240 # Almost every platform uses pthreads.
1241 if enabled multithread; then
1242 case ${toolchain} in
1245 *) check_header pthread.h && add_extralibs -lpthread
1249 # only for MIPS platforms
1250 case ${toolchain} in
1252 if enabled dspr2; then
1253 if enabled big_endian; then
1254 echo "dspr2 optimizations are available only for little endian platforms"
1255 disable_feature dspr2
1262 if enabled linux; then
1263 add_cflags -D_LARGEFILE_SOURCE
1264 add_cflags -D_FILE_OFFSET_BITS=64
1267 # append any user defined extra cflags
1268 if [ -n "${extra_cflags}" ] ; then
1269 check_add_cflags ${extra_cflags} || \
1270 die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler"
1274 process_toolchain() {
1275 process_common_toolchain
1283 upname="`toupper $cfg`"
1284 if enabled $cfg; then
1285 echo "${prefix}_${upname}=yes" >> $makefile
1295 upname="`toupper $cfg`"
1296 if enabled $cfg; then
1297 echo "#define ${prefix}_${upname} 1" >> $header
1299 echo "#define ${prefix}_${upname} 0" >> $header
1304 print_webm_license() {
1305 local destination=$1
1309 cat <<EOF > ${destination}
1310 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1312 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1313 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1314 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1315 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1316 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1328 enable_feature logging
1329 logfile="config.log"
1333 process_cmdline "$@"
1334 if enabled child; then
1335 echo "# ${self} $@" >> ${logfile}
1337 echo "# ${self} $@" > ${logfile}
1339 post_process_common_cmdline
1340 post_process_cmdline
1345 OOT_INSTALLS="${OOT_INSTALLS}"
1346 if enabled source_path_used; then
1347 # Prepare the PWD for building.
1348 for f in ${OOT_INSTALLS}; do
1349 install -D "${source_path}/$f" "$f"
1352 cp "${source_path}/build/make/Makefile" .