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.err]
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
93 ${toggle_install_docs} control whether docs are installed
94 ${toggle_install_bins} control whether binaries are installed
95 ${toggle_install_libs} control whether libraries are installed
96 ${toggle_install_srcs} control whether sources are installed
108 Object files are built at the place where configure is launched.
110 All boolean options can be negated. The default value is the opposite
111 of that shown above. If the option --disable-foo is listed, then
112 the default value for foo is enabled.
116 show_targets ${all_platforms}
123 while [ -n "$*" ]; do
124 if [ "${1%%-*}" = "${2%%-*}" ]; then
125 if [ "${2%%-*}" = "${3%%-*}" ]; then
126 printf " %-24s %-24s %-24s\n" "$1" "$2" "$3"
129 printf " %-24s %-24s\n" "$1" "$2"
133 printf " %-24s\n" "$1"
146 # List Processing Functions
161 [ $var = $value ] && return 0
168 CFLAGS="${CFLAGS} $@"
169 CXXFLAGS="${CXXFLAGS} $@"
174 CFLAGS="${CFLAGS} $@"
178 add_cxxflags_only() {
179 CXXFLAGS="${CXXFLAGS} $@"
184 LDFLAGS="${LDFLAGS} $@"
189 ASFLAGS="${ASFLAGS} $@"
194 extralibs="${extralibs} $@"
198 # Boolean Manipulation Functions
209 eval test "x\$$1" = "xyes"
213 eval test "x\$$1" = "xno"
219 if ! disabled $var; then
220 log_echo " enabling $var"
228 if ! enabled $var; then
229 log_echo " disabling $var"
237 # Text Processing Functions
240 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
245 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
250 # Temporary File Functions
253 enable source_path_used
254 if test -z "$source_path" -o "$source_path" = "." ; then
256 disable source_path_used
259 if test ! -z "$TMPDIR" ; then
261 elif test ! -z "$TEMPDIR" ; then
266 TMP_H="${TMPDIRx}/vpx-conf-$$-${RANDOM}.h"
267 TMP_C="${TMPDIRx}/vpx-conf-$$-${RANDOM}.c"
268 TMP_O="${TMPDIRx}/vpx-conf-$$-${RANDOM}.o"
269 TMP_X="${TMPDIRx}/vpx-conf-$$-${RANDOM}.x"
270 TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RANDOM}.asm"
273 rm -f ${TMP_C} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM}
277 # Toolchain Check Functions
280 enabled external_build && return
282 "$@" >>${logfile} 2>&1
289 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
296 check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
303 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
309 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
313 log check_header "$@"
316 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
318 check_cpp "$@" <<EOF && enable $var
326 log check_cflags "$@"
333 log check_cxxflags "$@"
335 # Catch CFLAGS that trigger CXX warnings
337 *g++*) check_cxx -Werror "$@" <<EOF
341 *) check_cxx "$@" <<EOF
349 check_cxxflags "$@" && add_cxxflags_only "$@"
350 check_cflags "$@" && add_cflags_only "$@"
353 check_add_asflags() {
358 check_add_ldflags() {
364 log check_asm_align "$@"
365 cat >${TMP_ASM} <<EOF
370 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
371 readelf -WS ${TMP_O} >${TMP_X}
373 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
374 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
378 write_common_config_banner() {
379 print_webm_license config.mk "##" ""
380 echo '# This file automatically generated by configure. Do not edit!' >> config.mk
381 echo "TOOLCHAIN := ${toolchain}" >> config.mk
385 echo "ALT_LIBC := ${alt_libc}" >> config.mk
390 write_common_config_targets() {
391 for t in ${all_targets}; do
392 if enabled ${t}; then
393 if enabled universal || enabled child; then
394 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
396 fwrite config.mk "ALL_TARGETS += ${t}"
404 write_common_target_config_mk() {
407 enabled ccache && CC="ccache ${CC}"
408 enabled ccache && CXX="ccache ${CXX}"
409 print_webm_license $1 "##" ""
412 # This file automatically generated by configure. Do not edit!
413 SRC_PATH="$source_path"
414 SRC_PATH_BARE=$source_path
415 BUILD_PFX=${BUILD_PFX}
416 TOOLCHAIN=${toolchain}
417 ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
428 CXXFLAGS = ${CXXFLAGS}
429 ARFLAGS = -rus\$(if \$(quiet),c,v)
432 extralibs = ${extralibs}
433 AS_SFX = ${AS_SFX:-.asm}
435 RTCD_OPTIONS = ${RTCD_OPTIONS}
438 if enabled rvct; then cat >> $1 << EOF
439 fmt_deps = sed -e 's;^__image.axf;\$\${@:.d=.o} \$\$@;' #hide
441 else cat >> $1 << EOF
442 fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\$\${@:.d=.o} \$\$@;'
446 print_config_mk ARCH "${1}" ${ARCH_LIST}
447 print_config_mk HAVE "${1}" ${HAVE_LIST}
448 print_config_mk CONFIG "${1}" ${CONFIG_LIST}
449 print_config_mk HAVE "${1}" gnu_strip
451 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
456 write_common_target_config_h() {
457 print_webm_license ${TMP_H} "/*" " */"
458 cat >> ${TMP_H} << EOF
459 /* This file automatically generated by configure. Do not edit! */
462 #define RESTRICT ${RESTRICT}
464 print_config_h ARCH "${TMP_H}" ${ARCH_LIST}
465 print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
466 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
467 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
468 mkdir -p `dirname "$1"`
469 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
472 process_common_cmdline() {
476 --child) enable child
480 if ! disabled logging ; then
481 enabled logging || logfile="$logging"
486 --target=*) toolchain="${toolchain:-${optval}}"
488 --force-target=*) toolchain="${toolchain:-${optval}}"; enable force_toolchain
492 --cpu=*) tune_cpu="$optval"
495 extra_cflags="${optval}"
497 --enable-?*|--disable-?*)
498 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
499 if echo "${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null; then
500 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
501 elif [ $action = "disable" ] && ! disabled $option ; then
502 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
504 elif [ $action = "enable" ] && ! enabled $option ; then
505 echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
511 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
512 if echo "${ARCH_EXT_LIST}" none | grep "^ *$option\$" >/dev/null; then
513 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
518 --force-enable-?*|--force-disable-?*)
519 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
523 [ -d "${optval}" ] || die "Not a directory: ${optval}"
528 [ "${optval}" = yasm -o "${optval}" = nasm -o "${optval}" = auto ] \
529 || die "Must be yasm, nasm or auto: ${optval}"
539 [ -d "${optval}" ] || die "Not a directory: ${optval}"
542 --libc|--as|--prefix|--libdir|--sdk-path)
543 die "Option ${opt} requires argument"
557 *) process_common_cmdline $opt
564 post_process_common_cmdline() {
565 prefix="${prefix:-/usr/local}"
567 libdir="${libdir:-${prefix}/lib}"
569 if [ "${libdir#${prefix}}" = "${libdir}" ]; then
570 die "Libdir ${libdir} must be a subdirectory of ${prefix}"
575 post_process_cmdline() {
579 setup_gnu_toolchain() {
580 CC=${CC:-${CROSS}gcc}
581 CXX=${CXX:-${CROSS}g++}
583 LD=${LD:-${CROSS}${link_with_cc:-ld}}
585 STRIP=${STRIP:-${CROSS}strip}
591 process_common_toolchain() {
592 if [ -z "$toolchain" ]; then
593 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
654 [ -z "$tgt_isa" ] && tgt_isa=x86
668 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
669 toolchain=${tgt_isa}-${tgt_os}-gcc
673 toolchain=${toolchain:-generic-gnu}
675 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
676 || die "Unrecognized toolchain '${toolchain}'"
678 enabled child || log_echo "Configuring for target '${toolchain}'"
681 # Set up toolchain variables
683 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
684 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
685 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
687 # Mark the specific ISA requested as enabled
688 soft_enable ${tgt_isa}
692 # Enable the architecture family
698 # PIC is probably what we want when building shared libs
699 enabled shared && soft_enable pic
701 # Handle darwin variants. Newer SDKs allow targeting older
702 # platforms, so find the newest SDK available.
705 if [ -z "${DEVELOPER_DIR}" ]; then
706 DEVELOPER_DIR=`xcode-select -print-path 2> /dev/null`
707 [ $? -ne 0 ] && OSX_SKIP_DIR_CHECK=1
709 if [ -z "${OSX_SKIP_DIR_CHECK}" ]; then
710 OSX_SDK_ROOTS="${DEVELOPER_DIR}/SDKs"
711 OSX_SDK_VERSIONS="MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk"
712 OSX_SDK_VERSIONS="${OSX_SDK_VERSIONS} MacOSX10.7.sdk"
713 for v in ${OSX_SDK_VERSIONS}; do
714 if [ -d "${OSX_SDK_ROOTS}/${v}" ]; then
715 osx_sdk_dir="${OSX_SDK_ROOTS}/${v}"
722 if [ -d "${osx_sdk_dir}" ]; then
723 add_cflags "-isysroot ${osx_sdk_dir}"
724 add_ldflags "-isysroot ${osx_sdk_dir}"
729 add_cflags "-mmacosx-version-min=10.4"
730 add_ldflags "-mmacosx-version-min=10.4"
733 add_cflags "-mmacosx-version-min=10.5"
734 add_ldflags "-mmacosx-version-min=10.5"
737 add_cflags "-mmacosx-version-min=10.6"
738 add_ldflags "-mmacosx-version-min=10.6"
741 add_cflags "-mmacosx-version-min=10.7"
742 add_ldflags "-mmacosx-version-min=10.7"
745 add_cflags "-mmacosx-version-min=10.8"
746 add_ldflags "-mmacosx-version-min=10.8"
750 # Handle Solaris variants. Solaris 10 needs -lposix4
753 add_extralibs -lposix4
754 disable fast_unaligned
757 add_extralibs -lposix4
761 # Process ARM architecture variants
764 # on arm, isa versions are supersets
770 soft_enable fast_unaligned
775 soft_enable fast_unaligned
779 disable fast_unaligned
783 asm_conversion_cmd="cat"
787 CROSS=${CROSS:-arm-none-linux-gnueabi-}
790 arch_int=${tgt_isa##armv}
791 arch_int=${arch_int%%te}
792 check_add_asflags --defsym ARCHITECTURE=${arch_int}
793 tune_cflags="-mtune="
794 if [ ${tgt_isa} == "armv7" ]; then
795 [ -z "${float_abi}" ] && float_abi=softfp
796 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
797 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
801 check_add_cflags -mfpu=neon #-ftree-vectorize
802 check_add_asflags -mfpu=neon
805 if [ -z "${tune_cpu}" ]; then
809 check_add_cflags -march=${tgt_isa}
810 check_add_asflags -march=${tgt_isa}
813 enabled debug && add_asflags -g
814 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
820 LD=${source_path}/build/make/armlink_adapter.sh
821 STRIP=arm-none-linux-gnueabi-strip
822 NM=arm-none-linux-gnueabi-nm
824 tune_asflags="--cpu="
825 if [ -z "${tune_cpu}" ]; then
826 if [ ${tgt_isa} == "armv7" ]; then
829 check_add_cflags --fpu=softvfp+vfpv3
830 check_add_asflags --fpu=softvfp+vfpv3
832 check_add_cflags --cpu=Cortex-A8
833 check_add_asflags --cpu=Cortex-A8
835 check_add_cflags --cpu=${tgt_isa##armv}
836 check_add_asflags --cpu=${tgt_isa##armv}
839 arch_int=${tgt_isa##armv}
840 arch_int=${arch_int%%te}
841 check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
842 enabled debug && add_asflags -g
844 add_cflags --enum_is_int
857 COMPILER_LOCATION=`find "${SDK_PATH}" \
858 -name "arm-linux-androideabi-gcc*" -print -quit`
859 TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
860 CC=${TOOLCHAIN_PATH}gcc
861 CXX=${TOOLCHAIN_PATH}g++
862 AR=${TOOLCHAIN_PATH}ar
863 LD=${TOOLCHAIN_PATH}gcc
864 AS=${TOOLCHAIN_PATH}as
865 STRIP=${TOOLCHAIN_PATH}strip
866 NM=${TOOLCHAIN_PATH}nm
868 if [ -z "${alt_libc}" ]; then
869 alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
870 awk '{n = split($0,a,"/"); \
871 split(a[n-1],b,"-"); \
872 print $0 " " b[2]}' | \
874 awk '{ print $1 }' | tail -1`
877 add_cflags "--sysroot=${alt_libc}"
878 add_ldflags "--sysroot=${alt_libc}"
880 # linker flag that routes around a CPU bug in some
881 # Cortex-A8 implementations (NDK Dev Guide)
882 add_ldflags "-Wl,--fix-cortex-a8"
885 soft_enable realtime_only
886 if [ ${tgt_isa} == "armv7" ]; then
887 soft_enable runtime_cpu_detect
889 if enabled runtime_cpu_detect; then
890 add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
895 if [ -z "${sdk_path}" ]; then
896 SDK_PATH=`xcode-select -print-path 2> /dev/null`
897 SDK_PATH=${SDK_PATH}/Platforms/iPhoneOS.platform/Developer
901 TOOLCHAIN_PATH=${SDK_PATH}/usr/bin
902 CXX=${TOOLCHAIN_PATH}/g++
903 CC=${TOOLCHAIN_PATH}/gcc
904 AR=${TOOLCHAIN_PATH}/ar
905 LD=${TOOLCHAIN_PATH}/arm-apple-darwin10-llvm-gcc-4.2
906 AS=${TOOLCHAIN_PATH}/as
907 STRIP=${TOOLCHAIN_PATH}/strip
908 NM=${TOOLCHAIN_PATH}/nm
911 # ASFLAGS is written here instead of using check_add_asflags
912 # because we need to overwrite all of ASFLAGS and purge the
913 # options that were put in above
914 ASFLAGS="-version -arch ${tgt_isa} -g"
916 add_cflags -arch ${tgt_isa}
917 add_ldflags -arch_only ${tgt_isa}
919 if [ -z "${alt_libc}" ]; then
920 alt_libc=${SDK_PATH}/SDKs/iPhoneOS5.1.sdk
923 add_cflags "-isysroot ${alt_libc}"
925 # Add the paths for the alternate libc
926 for d in usr/include; do
927 try_dir="${alt_libc}/${d}"
928 [ -d "${try_dir}" ] && add_cflags -I"${try_dir}"
931 for d in lib usr/lib usr/lib/system; do
932 try_dir="${alt_libc}/${d}"
933 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
936 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
941 if enabled rvct; then
942 # Check if we have CodeSourcery GCC in PATH. Needed for
944 hash arm-none-linux-gnueabi-gcc 2>&- || \
945 die "Couldn't find CodeSourcery GCC from PATH"
947 # Use armcc as a linker to enable translation of
948 # some gcc specific options such as -lm and -lpthread.
949 LD="armcc --translate_gcc"
951 # create configuration file (uses path to CodeSourcery GCC)
952 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
954 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
955 add_asflags --no_hide_all --apcs=/interwork
956 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
957 enabled pic && add_cflags --apcs=/fpic
958 enabled pic && add_asflags --apcs=/fpic
959 enabled shared && add_cflags --shared
968 tune_cflags="-mtune="
969 if enabled dspr2; then
970 check_add_cflags -mips32r2 -mdspr2
971 disable fast_unaligned
973 check_add_cflags -march=${tgt_isa}
974 check_add_asflags -march=${tgt_isa}
975 check_add_asflags -KPIC
982 add_asflags -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
984 enabled altivec && add_cflags -maltivec
988 add_asflags -maltivec -mregnames -I"\$(dir \$<)linux"
991 darwin_arch="-arch ppc"
992 enabled ppc64 && darwin_arch="${darwin_arch}64"
993 add_cflags ${darwin_arch} -m${bits} -fasm-blocks
994 add_asflags ${darwin_arch} -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
995 add_ldflags ${darwin_arch} -m${bits}
996 enabled altivec && add_cflags -faltivec
1002 enabled x86_64 && bits=64
1003 check_cpp <<EOF && bits=x32
1008 soft_enable runtime_cpu_detect
1014 if enabled gcc && ! disabled sse4_1 && ! check_cflags -msse4; then
1015 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-sse4_1 "
1022 enabled gcc && add_cflags -fno-common
1025 CC=${CC:-${CROSS}gcc}
1026 CXX=${CXX:-${CROSS}g++}
1027 LD=${LD:-${CROSS}gcc}
1035 AS="${alt_as:-${AS:-auto}}"
1041 add_cflags -use-msasm -use-asm
1042 add_ldflags -i-static
1043 enabled x86_64 && add_cflags -ipo -no-prec-div -static -xSSE2 -axSSE2
1044 enabled x86_64 && AR=xiar
1048 tune_cpu="SSE3_ATOM"
1051 tune_cflags="-march="
1056 add_cflags -m${bits}
1057 add_ldflags -m${bits}
1059 tune_cflags="-march="
1061 #for 32 bit x86 builds, -O3 did not turn on this flag
1062 enabled optimizations && check_add_cflags -fomit-frame-pointer
1065 # When building with Microsoft Visual Studio the assembler is
1066 # invoked directly. Checking at configure time is unnecessary.
1067 # Skip the check by setting AS arbitrarily
1074 which nasm >/dev/null 2>&1 && AS=nasm
1075 which yasm >/dev/null 2>&1 && AS=yasm
1076 [ "${AS}" = auto -o -z "${AS}" ] \
1077 && die "Neither yasm nor nasm have been found"
1080 log_echo " using $AS"
1081 [ "${AS##*/}" = nasm ] && add_asflags -Ox
1085 add_asflags -f win32
1086 enabled debug && add_asflags -g cv8
1090 enabled debug && add_asflags -g cv8
1093 add_asflags -f elf${bits}
1094 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
1095 enabled debug && [ "${AS}" = nasm ] && add_asflags -g
1096 [ "${AS##*/}" = nasm ] && check_asm_align
1099 add_asflags -f macho${bits}
1100 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
1101 add_cflags ${darwin_arch}
1102 add_ldflags ${darwin_arch}
1103 # -mdynamic-no-pic is still a bit of voodoo -- it was required at
1104 # one time, but does not seem to be now, and it breaks some of the
1105 # code that still relies on inline assembly.
1106 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
1107 enabled icc && ! enabled pic && add_cflags -fno-pic
1111 enabled debug && add_asflags -g
1114 *) log "Warning: Unknown os $tgt_os while setting up $AS flags"
1118 universal*|*-gcc|generic-gnu)
1125 # Try to enable CPU specific tuning
1126 if [ -n "${tune_cpu}" ]; then
1127 if [ -n "${tune_cflags}" ]; then
1128 check_add_cflags ${tune_cflags}${tune_cpu} || \
1129 die "Requested CPU '${tune_cpu}' not supported by compiler"
1131 if [ -n "${tune_asflags}" ]; then
1132 check_add_asflags ${tune_asflags}${tune_cpu} || \
1133 die "Requested CPU '${tune_cpu}' not supported by assembler"
1135 if [ -z "${tune_cflags}${tune_asflags}" ]; then
1136 log_echo "Warning: CPU tuning not supported by this toolchain"
1140 enabled debug && check_add_cflags -g && check_add_ldflags -g
1141 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
1143 check_add_cflags -fprofile-arcs -ftest-coverage &&
1144 check_add_ldflags -fprofile-arcs -ftest-coverage
1146 if enabled optimizations; then
1147 if enabled rvct; then
1148 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
1150 enabled small && check_add_cflags -O2 || check_add_cflags -O3
1154 # Position Independent Code (PIC) support, for building relocatable
1156 enabled gcc && enabled pic && check_add_cflags -fPIC
1158 # Work around longjmp interception on glibc >= 2.11, to improve binary
1159 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
1160 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
1162 # Check for strip utility variant
1163 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable gnu_strip
1165 # Try to determine target endianness
1167 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
1169 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
1170 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable big_endian
1172 # Almost every platform uses pthreads.
1173 if enabled multithread; then
1174 case ${toolchain} in
1177 *) check_header pthread.h && add_extralibs -lpthread
1181 # only for MIPS platforms
1182 case ${toolchain} in
1184 if enabled dspr2; then
1185 if enabled big_endian; then
1186 echo "dspr2 optimizations are available only for little endian platforms"
1194 if enabled linux; then
1195 add_cflags -D_LARGEFILE_SOURCE
1196 add_cflags -D_FILE_OFFSET_BITS=64
1199 # append any user defined extra cflags
1200 if [ -n "${extra_cflags}" ] ; then
1201 check_add_cflags ${extra_cflags} || \
1202 die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler"
1206 process_toolchain() {
1207 process_common_toolchain
1215 upname="`toupper $cfg`"
1216 if enabled $cfg; then
1217 echo "${prefix}_${upname}=yes" >> $makefile
1227 upname="`toupper $cfg`"
1228 if enabled $cfg; then
1229 echo "#define ${prefix}_${upname} 1" >> $header
1231 echo "#define ${prefix}_${upname} 0" >> $header
1236 print_webm_license() {
1237 local destination=$1
1241 cat <<EOF > ${destination}
1242 ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
1244 ${prefix} Use of this source code is governed by a BSD-style license${suffix}
1245 ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
1246 ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
1247 ${prefix} in the file PATENTS. All contributing project authors may${suffix}
1248 ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
1261 logfile="config.err"
1265 process_cmdline "$@"
1266 if enabled child; then
1267 echo "# ${self} $@" >> ${logfile}
1269 echo "# ${self} $@" > ${logfile}
1271 post_process_common_cmdline
1272 post_process_cmdline
1277 OOT_INSTALLS="${OOT_INSTALLS}"
1278 if enabled source_path_used; then
1279 # Prepare the PWD for building.
1280 for f in ${OOT_INSTALLS}; do
1281 install -D ${source_path}/$f $f
1284 cp ${source_path}/build/make/Makefile .