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."
44 pr -n -t $1 >>$logfile
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}
280 # Toolchain Check Functions
283 enabled external_build && return
285 "$@" >>${logfile} 2>&1
292 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
299 check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_CC}
306 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
312 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
316 log check_header "$@"
319 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
321 check_cpp "$@" <<EOF && enable_feature $var
329 log check_cflags "$@"
336 log check_cxxflags "$@"
338 # Catch CFLAGS that trigger CXX warnings
340 *c++-analyzer|*clang++|*g++*) check_cxx -Werror "$@" <<EOF
344 *) check_cxx "$@" <<EOF
352 check_cxxflags "$@" && add_cxxflags_only "$@"
353 check_cflags "$@" && add_cflags_only "$@"
356 check_add_asflags() {
361 check_add_ldflags() {
367 log check_asm_align "$@"
368 cat >${TMP_ASM} <<EOF
373 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
374 readelf -WS ${TMP_O} >${TMP_X}
376 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
377 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
381 write_common_config_banner() {
382 print_webm_license config.mk "##" ""
383 echo '# This file automatically generated by configure. Do not edit!' >> config.mk
384 echo "TOOLCHAIN := ${toolchain}" >> config.mk
388 echo "ALT_LIBC := ${alt_libc}" >> config.mk
393 write_common_config_targets() {
394 for t in ${all_targets}; do
395 if enabled ${t}; then
396 if enabled universal || enabled child; then
397 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
399 fwrite config.mk "ALL_TARGETS += ${t}"
407 write_common_target_config_mk() {
410 enabled ccache && CC="ccache ${CC}"
411 enabled ccache && CXX="ccache ${CXX}"
412 print_webm_license $1 "##" ""
415 # This file automatically generated by configure. Do not edit!
416 SRC_PATH="$source_path"
417 SRC_PATH_BARE=$source_path
418 BUILD_PFX=${BUILD_PFX}
419 TOOLCHAIN=${toolchain}
420 ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
421 GEN_VCPROJ=${gen_vcproj_cmd}
422 MSVS_ARCH_DIR=${msvs_arch_dir}
433 CXXFLAGS = ${CXXFLAGS}
434 ARFLAGS = -rus\$(if \$(quiet),c,v)
437 extralibs = ${extralibs}
438 AS_SFX = ${AS_SFX:-.asm}
440 VCPROJ_SFX = ${VCPROJ_SFX}
441 RTCD_OPTIONS = ${RTCD_OPTIONS}
444 if enabled rvct; then cat >> $1 << EOF
445 fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide
447 else cat >> $1 << EOF
448 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;'
452 print_config_mk ARCH "${1}" ${ARCH_LIST}
453 print_config_mk HAVE "${1}" ${HAVE_LIST}
454 print_config_mk CONFIG "${1}" ${CONFIG_LIST}
455 print_config_mk HAVE "${1}" gnu_strip
457 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
462 write_common_target_config_h() {
463 print_webm_license ${TMP_H} "/*" " */"
464 cat >> ${TMP_H} << EOF
465 /* This file automatically generated by configure. Do not edit! */
468 #define RESTRICT ${RESTRICT}
469 #define INLINE ${INLINE}
471 print_config_h ARCH "${TMP_H}" ${ARCH_LIST}
472 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
473 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
474 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
475 mkdir -p `dirname "$1"`
476 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
479 process_common_cmdline() {
483 --child) enable_feature child
487 if ! disabled logging ; then
488 enabled logging || logfile="$logging"
493 --target=*) toolchain="${toolchain:-${optval}}"
495 --force-target=*) toolchain="${toolchain:-${optval}}"; enable_feature force_toolchain
499 --cpu=*) tune_cpu="$optval"
502 extra_cflags="${optval}"
504 --enable-?*|--disable-?*)
505 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
506 if echo "${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null; then
507 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
508 elif [ $action = "disable" ] && ! disabled $option ; then
509 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
511 elif [ $action = "enable" ] && ! enabled $option ; then
512 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
515 ${action}_feature $option
518 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
519 if echo "${ARCH_EXT_LIST}" none | grep "^ *$option\$" >/dev/null; then
520 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
525 --force-enable-?*|--force-disable-?*)
526 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
527 ${action}_feature $option
530 [ -d "${optval}" ] || die "Not a directory: ${optval}"
531 disable_feature builtin_libc
535 [ "${optval}" = yasm -o "${optval}" = nasm -o "${optval}" = auto ] \
536 || die "Must be yasm, nasm or auto: ${optval}"
546 [ -d "${optval}" ] || die "Not a directory: ${optval}"
549 --libc|--as|--prefix|--libdir|--sdk-path)
550 die "Option ${opt} requires argument"
564 *) process_common_cmdline $opt
571 post_process_common_cmdline() {
572 prefix="${prefix:-/usr/local}"
574 libdir="${libdir:-${prefix}/lib}"
576 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
577 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
582 post_process_cmdline() {
586 setup_gnu_toolchain() {
587 CC=${CC:-${CROSS}gcc}
588 CXX=${CXX:-${CROSS}g++}
590 LD=${LD:-${CROSS}${link_with_cc:-ld}}
592 STRIP=${STRIP:-${CROSS}strip}
598 process_common_toolchain() {
599 if [ -z "$toolchain" ]; then
600 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
665 [ -z "$tgt_isa" ] && tgt_isa=x86
679 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
680 toolchain=${tgt_isa}-${tgt_os}-gcc
684 toolchain=${toolchain:-generic-gnu}
686 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
687 || die "Unrecognized toolchain '${toolchain}'"
689 enabled child || log_echo "Configuring for target '${toolchain}'"
692 # Set up toolchain variables
694 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
695 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
696 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
698 # Mark the specific ISA requested as enabled
699 soft_enable ${tgt_isa}
700 enable_feature ${tgt_os}
701 enable_feature ${tgt_cc}
703 # Enable the architecture family
705 arm*) enable_feature arm;;
706 mips*) enable_feature mips;;
709 # PIC is probably what we want when building shared libs
710 enabled shared && soft_enable pic
712 # Handle darwin variants. Newer SDKs allow targeting older
713 # platforms, so find the newest SDK available.
716 if [ -z "${DEVELOPER_DIR}" ]; then
717 DEVELOPER_DIR=`xcode-select -print-path 2> /dev/null`
718 [ $? -ne 0 ] && OSX_SKIP_DIR_CHECK=1
720 if [ -z "${OSX_SKIP_DIR_CHECK}" ]; then
721 OSX_SDK_ROOTS="${DEVELOPER_DIR}/SDKs"
722 OSX_SDK_VERSIONS="MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk"
723 OSX_SDK_VERSIONS="${OSX_SDK_VERSIONS} MacOSX10.7.sdk"
724 for v in ${OSX_SDK_VERSIONS}; do
725 if [ -d "${OSX_SDK_ROOTS}/${v}" ]; then
726 osx_sdk_dir="${OSX_SDK_ROOTS}/${v}"
733 if [ -d "${osx_sdk_dir}" ]; then
734 add_cflags "-isysroot ${osx_sdk_dir}"
735 add_ldflags "-isysroot ${osx_sdk_dir}"
740 add_cflags "-mmacosx-version-min=10.4"
741 add_ldflags "-mmacosx-version-min=10.4"
744 add_cflags "-mmacosx-version-min=10.5"
745 add_ldflags "-mmacosx-version-min=10.5"
748 add_cflags "-mmacosx-version-min=10.6"
749 add_ldflags "-mmacosx-version-min=10.6"
752 add_cflags "-mmacosx-version-min=10.7"
753 add_ldflags "-mmacosx-version-min=10.7"
756 add_cflags "-mmacosx-version-min=10.8"
757 add_ldflags "-mmacosx-version-min=10.8"
760 add_cflags "-mmacosx-version-min=10.9"
761 add_ldflags "-mmacosx-version-min=10.9"
765 # Handle Solaris variants. Solaris 10 needs -lposix4
768 add_extralibs -lposix4
769 disable_feature fast_unaligned
772 add_extralibs -lposix4
776 # Process ARM architecture variants
779 # on arm, isa versions are supersets
785 soft_enable fast_unaligned
790 soft_enable fast_unaligned
794 disable_feature fast_unaligned
798 asm_conversion_cmd="cat"
802 CROSS=${CROSS:-arm-none-linux-gnueabi-}
805 arch_int=${tgt_isa##armv}
806 arch_int=${arch_int%%te}
807 check_add_asflags --defsym ARCHITECTURE=${arch_int}
808 tune_cflags="-mtune="
809 if [ ${tgt_isa} = "armv7" ]; then
810 if [ -z "${float_abi}" ]; then
811 check_cpp <<EOF && float_abi=hard || float_abi=softfp
812 #ifndef __ARM_PCS_VFP
817 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
818 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
822 check_add_cflags -mfpu=neon #-ftree-vectorize
823 check_add_asflags -mfpu=neon
826 if [ -z "${tune_cpu}" ]; then
830 check_add_cflags -march=${tgt_isa}
831 check_add_asflags -march=${tgt_isa}
834 enabled debug && add_asflags -g
835 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
836 if enabled thumb; then
837 asm_conversion_cmd="$asm_conversion_cmd -thumb"
838 check_add_cflags -mthumb
839 check_add_asflags -mthumb -mimplicit-it=always
843 asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
845 msvs_arch_dir=arm-msvs
846 disable_feature multithread
847 disable_feature unit_tests
853 LD=${source_path}/build/make/armlink_adapter.sh
854 STRIP=arm-none-linux-gnueabi-strip
855 NM=arm-none-linux-gnueabi-nm
857 tune_asflags="--cpu="
858 if [ -z "${tune_cpu}" ]; then
859 if [ ${tgt_isa} = "armv7" ]; then
862 check_add_cflags --fpu=softvfp+vfpv3
863 check_add_asflags --fpu=softvfp+vfpv3
865 check_add_cflags --cpu=Cortex-A8
866 check_add_asflags --cpu=Cortex-A8
868 check_add_cflags --cpu=${tgt_isa##armv}
869 check_add_asflags --cpu=${tgt_isa##armv}
872 arch_int=${tgt_isa##armv}
873 arch_int=${arch_int%%te}
874 check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
875 enabled debug && add_asflags -g
877 add_cflags --enum_is_int
884 disable_feature multithread
885 disable_feature os_support
890 COMPILER_LOCATION=`find "${SDK_PATH}" \
891 -name "arm-linux-androideabi-gcc*" -print -quit`
892 TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
893 CC=${TOOLCHAIN_PATH}gcc
894 CXX=${TOOLCHAIN_PATH}g++
895 AR=${TOOLCHAIN_PATH}ar
896 LD=${TOOLCHAIN_PATH}gcc
897 AS=${TOOLCHAIN_PATH}as
898 STRIP=${TOOLCHAIN_PATH}strip
899 NM=${TOOLCHAIN_PATH}nm
901 if [ -z "${alt_libc}" ]; then
902 alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
903 awk '{n = split($0,a,"/"); \
904 split(a[n-1],b,"-"); \
905 print $0 " " b[2]}' | \
907 awk '{ print $1 }' | tail -1`
910 add_cflags "--sysroot=${alt_libc}"
911 add_ldflags "--sysroot=${alt_libc}"
913 # linker flag that routes around a CPU bug in some
914 # Cortex-A8 implementations (NDK Dev Guide)
915 add_ldflags "-Wl,--fix-cortex-a8"
918 soft_enable realtime_only
919 if [ ${tgt_isa} = "armv7" ]; then
920 soft_enable runtime_cpu_detect
922 if enabled runtime_cpu_detect; then
923 add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
929 XCRUN_FIND="xcrun --sdk iphoneos -find"
930 CXX="$(${XCRUN_FIND} clang++)"
931 CC="$(${XCRUN_FIND} clang)"
932 AR="$(${XCRUN_FIND} ar)"
933 LD="$(${XCRUN_FIND} ld)"
934 AS="$(${XCRUN_FIND} as)"
935 STRIP="$(${XCRUN_FIND} strip)"
936 NM="$(${XCRUN_FIND} nm)"
937 RANLIB="$(${XCRUN_FIND} ranlib)"
940 # ASFLAGS is written here instead of using check_add_asflags
941 # because we need to overwrite all of ASFLAGS and purge the
942 # options that were put in above
943 ASFLAGS="-arch ${tgt_isa} -g"
945 alt_libc="$(xcrun --sdk iphoneos --show-sdk-path)"
946 add_cflags -arch ${tgt_isa} -isysroot ${alt_libc}
947 add_ldflags -arch ${tgt_isa} -ios_version_min 7.0
949 for d in lib usr/lib usr/lib/system; do
950 try_dir="${alt_libc}/${d}"
951 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
954 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
959 if enabled rvct; then
960 # Check if we have CodeSourcery GCC in PATH. Needed for
962 hash arm-none-linux-gnueabi-gcc 2>&- || \
963 die "Couldn't find CodeSourcery GCC from PATH"
965 # Use armcc as a linker to enable translation of
966 # some gcc specific options such as -lm and -lpthread.
967 LD="armcc --translate_gcc"
969 # create configuration file (uses path to CodeSourcery GCC)
970 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
972 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
973 add_asflags --no_hide_all --apcs=/interwork
974 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
975 enabled pic && add_cflags --apcs=/fpic
976 enabled pic && add_asflags --apcs=/fpic
977 enabled shared && add_cflags --shared
986 tune_cflags="-mtune="
987 if enabled dspr2; then
988 check_add_cflags -mips32r2 -mdspr2
989 disable_feature fast_unaligned
991 check_add_cflags -march=${tgt_isa}
992 check_add_asflags -march=${tgt_isa}
993 check_add_asflags -KPIC
1000 add_asflags -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
1002 enabled altivec && add_cflags -maltivec
1006 add_asflags -maltivec -mregnames -I"\$(dir \$<)linux"
1009 darwin_arch="-arch ppc"
1010 enabled ppc64 && darwin_arch="${darwin_arch}64"
1011 add_cflags ${darwin_arch} -m${bits} -fasm-blocks
1012 add_asflags ${darwin_arch} -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
1013 add_ldflags ${darwin_arch} -m${bits}
1014 enabled altivec && add_cflags -faltivec
1020 enabled x86_64 && bits=64
1021 check_cpp <<EOF && bits=x32
1029 enabled gcc && add_cflags -fno-common
1032 CC=${CC:-${CROSS}gcc}
1033 CXX=${CXX:-${CROSS}g++}
1034 LD=${LD:-${CROSS}gcc}
1042 AS="${alt_as:-${AS:-auto}}"
1048 add_cflags -use-msasm # remove -use-msasm too?
1049 # add -no-intel-extensions to suppress warning #10237
1050 # refer to http://software.intel.com/en-us/forums/topic/280199
1051 add_ldflags -i-static -no-intel-extensions
1052 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
1053 enabled x86_64 && AR=xiar
1057 tune_cpu="SSE3_ATOM"
1060 tune_cflags="-march="
1065 add_cflags -m${bits}
1066 add_ldflags -m${bits}
1068 tune_cflags="-march="
1070 #for 32 bit x86 builds, -O3 did not turn on this flag
1071 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
1074 # When building with Microsoft Visual Studio the assembler is
1075 # invoked directly. Checking at configure time is unnecessary.
1076 # Skip the check by setting AS arbitrarily
1078 msvs_arch_dir=x86-msvs
1079 vc_version=${tgt_cc##vs}
1082 echo "${tgt_cc} does not support avx/avx2, disabling....."
1083 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx --disable-avx2 "
1091 soft_enable runtime_cpu_detect
1097 # We can't use 'check_cflags' until the compiler is configured and CC is
1099 if enabled gcc && ! disabled sse4_1 && ! check_cflags -msse4; then
1100 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-sse4_1 "
1105 if enabled gcc && ! disabled avx && ! check_cflags -mavx; then
1106 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx "
1111 if enabled gcc && ! disabled avx2 && ! check_cflags -mavx2; then
1112 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx2 "
1119 which nasm >/dev/null 2>&1 && AS=nasm
1120 which yasm >/dev/null 2>&1 && AS=yasm
1121 [ "${AS}" = auto -o -z "${AS}" ] \
1122 && die "Neither yasm nor nasm have been found"
1125 log_echo " using $AS"
1126 [ "${AS##*/}" = nasm ] && add_asflags -Ox
1130 add_asflags -f win32
1131 enabled debug && add_asflags -g cv8
1136 enabled debug && add_asflags -g cv8
1139 linux*|solaris*|android*)
1140 add_asflags -f elf${bits}
1141 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1142 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1143 [ "${AS##*/}" = nasm ] && check_asm_align
1146 add_asflags -f macho${bits}
1147 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1148 add_cflags ${darwin_arch}
1149 add_ldflags ${darwin_arch}
1150 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1151 # one time, but does not seem to be now, and it breaks some of the
1152 # code that still relies on inline assembly.
1153 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1154 enabled icc && ! enabled pic && add_cflags -fno-pic
1158 enabled debug && add_asflags -g
1161 *) log "Warning: Unknown os $tgt_os while setting up $AS flags"
1165 universal*|*-gcc|generic-gnu)
1172 # Try to enable CPU specific tuning
1173 if [ -n "${tune_cpu}" ]; then
1174 if [ -n "${tune_cflags}" ]; then
1175 check_add_cflags ${tune_cflags}${tune_cpu} || \
1176 die "Requested CPU '${tune_cpu}' not supported by compiler"
1178 if [ -n "${tune_asflags}" ]; then
1179 check_add_asflags ${tune_asflags}${tune_cpu} || \
1180 die "Requested CPU '${tune_cpu}' not supported by assembler"
1182 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1183 log_echo "Warning: CPU tuning not supported by this toolchain"
1187 enabled debug && check_add_cflags -g && check_add_ldflags -g
1188 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1190 check_add_cflags -fprofile-arcs -ftest-coverage &&
1191 check_add_ldflags -fprofile-arcs -ftest-coverage
1193 if enabled optimizations; then
1194 if enabled rvct; then
1195 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1197 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1201 # default use_x86inc to yes if pic is no or 64bit or we are not on darwin
1202 echo " checking here for x86inc \"${tgt_isa}\" \"$pic\" "
1203 if [ ${tgt_isa} = x86_64 -o ! "$pic" = "yes" -o "${tgt_os#darwin}" = "${tgt_os}" ]; then
1204 soft_enable use_x86inc
1207 # Position Independent Code (PIC) support, for building relocatable
1209 enabled gcc && enabled pic && check_add_cflags -fPIC
1211 # Work around longjmp interception on glibc >= 2.11, to improve binary
1212 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1213 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1215 # Check for strip utility variant
1216 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
1218 # Try to determine target endianness
1220 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1222 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1223 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
1225 # Try to find which inline keywords are supported
1226 check_cc <<EOF && INLINE="inline"
1227 static inline function() {}
1229 check_cc <<EOF && INLINE="__inline__ __attribute__((always_inline))"
1230 static __attribute__((always_inline)) function() {}
1233 # Almost every platform uses pthreads.
1234 if enabled multithread; then
1235 case ${toolchain} in
1238 *) check_header pthread.h && add_extralibs -lpthread
1242 # only for MIPS platforms
1243 case ${toolchain} in
1245 if enabled dspr2; then
1246 if enabled big_endian; then
1247 echo "dspr2 optimizations are available only for little endian platforms"
1248 disable_feature dspr2
1255 if enabled linux; then
1256 add_cflags -D_LARGEFILE_SOURCE
1257 add_cflags -D_FILE_OFFSET_BITS=64
1260 # append any user defined extra cflags
1261 if [ -n "${extra_cflags}" ] ; then
1262 check_add_cflags ${extra_cflags} || \
1263 die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler"
1267 process_toolchain() {
1268 process_common_toolchain
1276 upname="`toupper $cfg`"
1277 if enabled $cfg; then
1278 echo "${prefix}_${upname}=yes" >> $makefile
1288 upname="`toupper $cfg`"
1289 if enabled $cfg; then
1290 echo "#define ${prefix}_${upname} 1" >> $header
1292 echo "#define ${prefix}_${upname} 0" >> $header
1297 print_webm_license() {
1298 local destination=$1
1302 cat <<EOF > ${destination}
1303 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1305 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1306 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1307 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1308 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1309 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1321 enable_feature logging
1322 logfile="config.log"
1326 process_cmdline "$@"
1327 if enabled child; then
1328 echo "# ${self} $@" >> ${logfile}
1330 echo "# ${self} $@" > ${logfile}
1332 post_process_common_cmdline
1333 post_process_cmdline
1338 OOT_INSTALLS="${OOT_INSTALLS}"
1339 if enabled source_path_used; then
1340 # Prepare the PWD for building.
1341 for f in ${OOT_INSTALLS}; do
1342 install -D ${source_path}/$f $f
1345 cp ${source_path}/build/make/Makefile .