1#!/bin/sh 2## 3## configure.sh 4## 5## This script is sourced by the main configure script and contains 6## utility functions and other common bits that aren't strictly libvpx 7## related. 8## 9## This build system is based in part on the FFmpeg configure script. 10## 11 12 13# 14# Logging / Output Functions 15# 16die_unknown(){ 17 echo "Unknown option \"$1\"." 18 echo "See $0 --help for available options." 19 clean_temp_files 20 exit 1 21} 22 23die() { 24 echo "$@" 25 echo 26 echo "Configuration failed. This could reflect a misconfiguration of your" 27 echo "toolchains, improper options selected, or another problem. If you" 28 echo "don't see any useful error messages above, the next step is to look" 29 echo "at the configure error log file ($logfile) to determine what" 30 echo "configure was trying to do when it died." 31 clean_temp_files 32 exit 1 33} 34 35log(){ 36 echo "$@" >>$logfile 37} 38 39log_file(){ 40 log BEGIN $1 41 cat -n $1 >>$logfile 42 log END $1 43} 44 45log_echo() { 46 echo "$@" 47 log "$@" 48} 49 50fwrite () { 51 outfile=$1 52 shift 53 echo "$@" >> ${outfile} 54} 55 56show_help_pre(){ 57 for opt in ${CMDLINE_SELECT}; do 58 opt2=`echo $opt | sed -e 's;_;-;g'` 59 if enabled $opt; then 60 eval "toggle_${opt}=\"--disable-${opt2}\"" 61 else 62 eval "toggle_${opt}=\"--enable-${opt2} \"" 63 fi 64 done 65 66 cat <<EOF 67Usage: configure [options] 68Options: 69 70Build options: 71 --help print this message 72 --log=yes|no|FILE file configure log is written to [config.log] 73 --target=TARGET target platform tuple [generic-gnu] 74 --cpu=CPU optimize for a specific cpu rather than a family 75 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS] 76 --extra-cxxflags=ECXXFLAGS add ECXXFLAGS to CXXFLAGS [$CXXFLAGS] 77 ${toggle_extra_warnings} emit harmless warnings (always non-fatal) 78 ${toggle_werror} treat warnings as errors, if possible 79 (not available with all compilers) 80 ${toggle_optimizations} turn on/off compiler optimization flags 81 ${toggle_pic} turn on/off Position Independent Code 82 ${toggle_ccache} turn on/off compiler cache 83 ${toggle_debug} enable/disable debug mode 84 ${toggle_gprof} enable/disable gprof profiling instrumentation 85 ${toggle_gcov} enable/disable gcov coverage instrumentation 86 ${toggle_thumb} enable/disable building arm assembly in thumb mode 87 ${toggle_dependency_tracking} 88 disable to speed up one-time build 89 90Install options: 91 ${toggle_install_docs} control whether docs are installed 92 ${toggle_install_bins} control whether binaries are installed 93 ${toggle_install_libs} control whether libraries are installed 94 ${toggle_install_srcs} control whether sources are installed 95 96 97EOF 98} 99 100show_help_post(){ 101 cat <<EOF 102 103 104NOTES: 105 Object files are built at the place where configure is launched. 106 107 All boolean options can be negated. The default value is the opposite 108 of that shown above. If the option --disable-foo is listed, then 109 the default value for foo is enabled. 110 111Supported targets: 112EOF 113 show_targets ${all_platforms} 114 echo 115 exit 1 116} 117 118show_targets() { 119 while [ -n "$*" ]; do 120 if [ "${1%%-*}" = "${2%%-*}" ]; then 121 if [ "${2%%-*}" = "${3%%-*}" ]; then 122 printf " %-24s %-24s %-24s\n" "$1" "$2" "$3" 123 shift; shift; shift 124 else 125 printf " %-24s %-24s\n" "$1" "$2" 126 shift; shift 127 fi 128 else 129 printf " %-24s\n" "$1" 130 shift 131 fi 132 done 133} 134 135show_help() { 136 show_help_pre 137 show_help_post 138} 139 140# 141# List Processing Functions 142# 143set_all(){ 144 value=$1 145 shift 146 for var in $*; do 147 eval $var=$value 148 done 149} 150 151is_in(){ 152 value=$1 153 shift 154 for var in $*; do 155 [ $var = $value ] && return 0 156 done 157 return 1 158} 159 160add_cflags() { 161 CFLAGS="${CFLAGS} $@" 162 CXXFLAGS="${CXXFLAGS} $@" 163} 164 165add_cflags_only() { 166 CFLAGS="${CFLAGS} $@" 167} 168 169add_cxxflags_only() { 170 CXXFLAGS="${CXXFLAGS} $@" 171} 172 173add_ldflags() { 174 LDFLAGS="${LDFLAGS} $@" 175} 176 177add_asflags() { 178 ASFLAGS="${ASFLAGS} $@" 179} 180 181add_extralibs() { 182 extralibs="${extralibs} $@" 183} 184 185# 186# Boolean Manipulation Functions 187# 188 189enable_feature(){ 190 set_all yes $* 191} 192 193disable_feature(){ 194 set_all no $* 195} 196 197enabled(){ 198 eval test "x\$$1" = "xyes" 199} 200 201disabled(){ 202 eval test "x\$$1" = "xno" 203} 204 205enable_codec(){ 206 enabled "${1}" || echo " enabling ${1}" 207 enable_feature "${1}" 208 209 is_in "${1}" vp8 vp9 && enable_feature "${1}_encoder" "${1}_decoder" 210} 211 212disable_codec(){ 213 disabled "${1}" || echo " disabling ${1}" 214 disable_feature "${1}" 215 216 is_in "${1}" vp8 vp9 && disable_feature "${1}_encoder" "${1}_decoder" 217} 218 219# Iterates through positional parameters, checks to confirm the parameter has 220# not been explicitly (force) disabled, and enables the setting controlled by 221# the parameter when the setting is not disabled. 222# Note: Does NOT alter RTCD generation options ($RTCD_OPTIONS). 223soft_enable() { 224 for var in $*; do 225 if ! disabled $var; then 226 enabled $var || log_echo " enabling $var" 227 enable_feature $var 228 fi 229 done 230} 231 232# Iterates through positional parameters, checks to confirm the parameter has 233# not been explicitly (force) enabled, and disables the setting controlled by 234# the parameter when the setting is not enabled. 235# Note: Does NOT alter RTCD generation options ($RTCD_OPTIONS). 236soft_disable() { 237 for var in $*; do 238 if ! enabled $var; then 239 disabled $var || log_echo " disabling $var" 240 disable_feature $var 241 fi 242 done 243} 244 245# 246# Text Processing Functions 247# 248toupper(){ 249 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 250} 251 252tolower(){ 253 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 254} 255 256# 257# Temporary File Functions 258# 259source_path=${0%/*} 260enable_feature source_path_used 261if [ -z "$source_path" ] || [ "$source_path" = "." ]; then 262 source_path="`pwd`" 263 disable_feature source_path_used 264fi 265 266if test ! -z "$TMPDIR" ; then 267 TMPDIRx="${TMPDIR}" 268elif test ! -z "$TEMPDIR" ; then 269 TMPDIRx="${TEMPDIR}" 270else 271 TMPDIRx="/tmp" 272fi 273RAND=$(awk 'BEGIN { srand(); printf "%d\n",(rand() * 32768)}') 274TMP_H="${TMPDIRx}/vpx-conf-$$-${RAND}.h" 275TMP_C="${TMPDIRx}/vpx-conf-$$-${RAND}.c" 276TMP_CC="${TMPDIRx}/vpx-conf-$$-${RAND}.cc" 277TMP_O="${TMPDIRx}/vpx-conf-$$-${RAND}.o" 278TMP_X="${TMPDIRx}/vpx-conf-$$-${RAND}.x" 279TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RAND}.asm" 280 281clean_temp_files() { 282 rm -f ${TMP_C} ${TMP_CC} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM} 283 enabled gcov && rm -f ${TMP_C%.c}.gcno ${TMP_CC%.cc}.gcno 284} 285 286# 287# Toolchain Check Functions 288# 289check_cmd() { 290 enabled external_build && return 291 log "$@" 292 "$@" >>${logfile} 2>&1 293} 294 295check_cc() { 296 log check_cc "$@" 297 cat >${TMP_C} 298 log_file ${TMP_C} 299 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C} 300} 301 302check_cxx() { 303 log check_cxx "$@" 304 cat >${TMP_CC} 305 log_file ${TMP_CC} 306 check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_CC} 307} 308 309check_cpp() { 310 log check_cpp "$@" 311 cat > ${TMP_C} 312 log_file ${TMP_C} 313 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C} 314} 315 316check_ld() { 317 log check_ld "$@" 318 check_cc $@ \ 319 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs} 320} 321 322check_lib() { 323 log check_lib "$@" 324 check_cc $@ \ 325 && check_cmd ${LD} ${LDFLAGS} -o ${TMP_X} ${TMP_O} "$@" ${extralibs} 326} 327 328check_header(){ 329 log check_header "$@" 330 header=$1 331 shift 332 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'` 333 disable_feature $var 334 check_cpp "$@" <<EOF && enable_feature $var 335#include "$header" 336int x; 337EOF 338} 339 340check_cflags() { 341 log check_cflags "$@" 342 check_cc -Werror "$@" <<EOF 343int x; 344EOF 345} 346 347check_cxxflags() { 348 log check_cxxflags "$@" 349 350 # Catch CFLAGS that trigger CXX warnings 351 case "$CXX" in 352 *c++-analyzer|*clang++|*g++*) 353 check_cxx -Werror "$@" <<EOF 354int x; 355EOF 356 ;; 357 *) 358 check_cxx -Werror "$@" <<EOF 359int x; 360EOF 361 ;; 362 esac 363} 364 365check_add_cflags() { 366 check_cxxflags "$@" && add_cxxflags_only "$@" 367 check_cflags "$@" && add_cflags_only "$@" 368} 369 370check_add_cxxflags() { 371 check_cxxflags "$@" && add_cxxflags_only "$@" 372} 373 374check_add_asflags() { 375 log add_asflags "$@" 376 add_asflags "$@" 377} 378 379check_add_ldflags() { 380 log add_ldflags "$@" 381 add_ldflags "$@" 382} 383 384check_asm_align() { 385 log check_asm_align "$@" 386 cat >${TMP_ASM} <<EOF 387section .rodata 388align 16 389EOF 390 log_file ${TMP_ASM} 391 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM} 392 readelf -WS ${TMP_O} >${TMP_X} 393 log_file ${TMP_X} 394 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then 395 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)" 396 fi 397} 398 399# tests for -m$1 toggling the feature given in $2. If $2 is empty $1 is used. 400check_gcc_machine_option() { 401 opt="$1" 402 feature="$2" 403 [ -n "$feature" ] || feature="$opt" 404 405 if enabled gcc && ! disabled "$feature" && ! check_cflags "-m$opt"; then 406 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature " 407 else 408 soft_enable "$feature" 409 fi 410} 411 412# tests for -m$2, -m$3, -m$4... toggling the feature given in $1. 413check_gcc_machine_options() { 414 feature="$1" 415 shift 416 flags="-m$1" 417 shift 418 for opt in $*; do 419 flags="$flags -m$opt" 420 done 421 422 if enabled gcc && ! disabled "$feature" && ! check_cflags $flags; then 423 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature " 424 else 425 soft_enable "$feature" 426 fi 427} 428 429check_gcc_avx512_compiles() { 430 if disabled gcc; then 431 return 432 fi 433 434 check_cc -mavx512f <<EOF 435#include <immintrin.h> 436void f(void) { 437 __m512i x = _mm512_set1_epi16(0); 438 (void)x; 439} 440EOF 441 compile_result=$? 442 if [ ${compile_result} -ne 0 ]; then 443 log_echo " disabling avx512: not supported by compiler" 444 disable_feature avx512 445 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx512 " 446 fi 447} 448 449write_common_config_banner() { 450 print_webm_license config.mk "##" "" 451 echo '# This file automatically generated by configure. Do not edit!' >> config.mk 452 echo "TOOLCHAIN := ${toolchain}" >> config.mk 453 454 case ${toolchain} in 455 *-linux-rvct) 456 echo "ALT_LIBC := ${alt_libc}" >> config.mk 457 ;; 458 esac 459} 460 461write_common_config_targets() { 462 for t in ${all_targets}; do 463 if enabled ${t}; then 464 if enabled child; then 465 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}" 466 else 467 fwrite config.mk "ALL_TARGETS += ${t}" 468 fi 469 fi 470 true; 471 done 472 true 473} 474 475write_common_target_config_mk() { 476 saved_CC="${CC}" 477 saved_CXX="${CXX}" 478 enabled ccache && CC="ccache ${CC}" 479 enabled ccache && CXX="ccache ${CXX}" 480 print_webm_license $1 "##" "" 481 482 cat >> $1 << EOF 483# This file automatically generated by configure. Do not edit! 484SRC_PATH="$source_path" 485SRC_PATH_BARE=$source_path 486BUILD_PFX=${BUILD_PFX} 487TOOLCHAIN=${toolchain} 488ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl} 489GEN_VCPROJ=${gen_vcproj_cmd} 490MSVS_ARCH_DIR=${msvs_arch_dir} 491 492CC=${CC} 493CXX=${CXX} 494AR=${AR} 495LD=${LD} 496AS=${AS} 497STRIP=${STRIP} 498NM=${NM} 499 500CFLAGS = ${CFLAGS} 501CXXFLAGS = ${CXXFLAGS} 502ARFLAGS = -crs\$(if \$(quiet),,v) 503LDFLAGS = ${LDFLAGS} 504ASFLAGS = ${ASFLAGS} 505extralibs = ${extralibs} 506AS_SFX = ${AS_SFX:-.asm} 507EXE_SFX = ${EXE_SFX} 508VCPROJ_SFX = ${VCPROJ_SFX} 509RTCD_OPTIONS = ${RTCD_OPTIONS} 510LIBYUV_CXXFLAGS = ${LIBYUV_CXXFLAGS} 511EOF 512 513 if enabled rvct; then cat >> $1 << EOF 514fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide 515EOF 516 else cat >> $1 << EOF 517fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;' 518EOF 519 fi 520 521 print_config_mk ARCH "${1}" ${ARCH_LIST} 522 print_config_mk HAVE "${1}" ${HAVE_LIST} 523 print_config_mk CONFIG "${1}" ${CONFIG_LIST} 524 print_config_mk HAVE "${1}" gnu_strip 525 526 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}" 527 528 CC="${saved_CC}" 529 CXX="${saved_CXX}" 530} 531 532write_common_target_config_h() { 533 print_webm_license ${TMP_H} "/*" " */" 534 cat >> ${TMP_H} << EOF 535/* This file automatically generated by configure. Do not edit! */ 536#ifndef VPX_CONFIG_H 537#define VPX_CONFIG_H 538#define RESTRICT ${RESTRICT} 539#define INLINE ${INLINE} 540EOF 541 print_config_h ARCH "${TMP_H}" ${ARCH_LIST} 542 print_config_h HAVE "${TMP_H}" ${HAVE_LIST} 543 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST} 544 print_config_vars_h "${TMP_H}" ${VAR_LIST} 545 echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H} 546 mkdir -p `dirname "$1"` 547 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1" 548} 549 550write_win_arm64_neon_h_workaround() { 551 print_webm_license ${TMP_H} "/*" " */" 552 cat >> ${TMP_H} << EOF 553/* This file automatically generated by configure. Do not edit! */ 554#ifndef VPX_WIN_ARM_NEON_H_WORKAROUND 555#define VPX_WIN_ARM_NEON_H_WORKAROUND 556/* The Windows SDK has arm_neon.h, but unlike on other platforms it is 557 * ARM32-only. ARM64 NEON support is provided by arm64_neon.h, a proper 558 * superset of arm_neon.h. Work around this by providing a more local 559 * arm_neon.h that simply #includes arm64_neon.h. 560 */ 561#include <arm64_neon.h> 562#endif /* VPX_WIN_ARM_NEON_H_WORKAROUND */ 563EOF 564 mkdir -p `dirname "$1"` 565 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1" 566} 567 568process_common_cmdline() { 569 for opt in "$@"; do 570 optval="${opt#*=}" 571 case "$opt" in 572 --child) 573 enable_feature child 574 ;; 575 --log*) 576 logging="$optval" 577 if ! disabled logging ; then 578 enabled logging || logfile="$logging" 579 else 580 logfile=/dev/null 581 fi 582 ;; 583 --target=*) 584 toolchain="${toolchain:-${optval}}" 585 ;; 586 --force-target=*) 587 toolchain="${toolchain:-${optval}}" 588 enable_feature force_toolchain 589 ;; 590 --cpu=*) 591 tune_cpu="$optval" 592 ;; 593 --extra-cflags=*) 594 extra_cflags="${optval}" 595 ;; 596 --extra-cxxflags=*) 597 extra_cxxflags="${optval}" 598 ;; 599 --enable-?*|--disable-?*) 600 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` 601 if is_in ${option} ${ARCH_EXT_LIST}; then 602 [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${option} " 603 elif [ $action = "disable" ] && ! disabled $option ; then 604 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt 605 log_echo " disabling $option" 606 elif [ $action = "enable" ] && ! enabled $option ; then 607 is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt 608 log_echo " enabling $option" 609 fi 610 ${action}_feature $option 611 ;; 612 --require-?*) 613 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` 614 if is_in ${option} ${ARCH_EXT_LIST}; then 615 RTCD_OPTIONS="${RTCD_OPTIONS}${opt} " 616 else 617 die_unknown $opt 618 fi 619 ;; 620 --force-enable-?*|--force-disable-?*) 621 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'` 622 ${action}_feature $option 623 ;; 624 --libc=*) 625 [ -d "${optval}" ] || die "Not a directory: ${optval}" 626 disable_feature builtin_libc 627 alt_libc="${optval}" 628 ;; 629 --as=*) 630 [ "${optval}" = yasm ] || [ "${optval}" = nasm ] \ 631 || [ "${optval}" = auto ] \ 632 || die "Must be yasm, nasm or auto: ${optval}" 633 alt_as="${optval}" 634 ;; 635 --size-limit=*) 636 w="${optval%%x*}" 637 h="${optval##*x}" 638 VAR_LIST="DECODE_WIDTH_LIMIT ${w} DECODE_HEIGHT_LIMIT ${h}" 639 [ ${w} -gt 0 ] && [ ${h} -gt 0 ] || die "Invalid size-limit: too small." 640 [ ${w} -lt 65536 ] && [ ${h} -lt 65536 ] \ 641 || die "Invalid size-limit: too big." 642 enable_feature size_limit 643 ;; 644 --prefix=*) 645 prefix="${optval}" 646 ;; 647 --libdir=*) 648 libdir="${optval}" 649 ;; 650 --libc|--as|--prefix|--libdir) 651 die "Option ${opt} requires argument" 652 ;; 653 --help|-h) 654 show_help 655 ;; 656 *) 657 die_unknown $opt 658 ;; 659 esac 660 done 661} 662 663process_cmdline() { 664 for opt do 665 optval="${opt#*=}" 666 case "$opt" in 667 *) 668 process_common_cmdline $opt 669 ;; 670 esac 671 done 672} 673 674post_process_common_cmdline() { 675 prefix="${prefix:-/usr/local}" 676 prefix="${prefix%/}" 677 libdir="${libdir:-${prefix}/lib}" 678 libdir="${libdir%/}" 679 if [ "${libdir#${prefix}}" = "${libdir}" ]; then 680 die "Libdir ${libdir} must be a subdirectory of ${prefix}" 681 fi 682} 683 684post_process_cmdline() { 685 true; 686} 687 688setup_gnu_toolchain() { 689 CC=${CC:-${CROSS}gcc} 690 CXX=${CXX:-${CROSS}g++} 691 AR=${AR:-${CROSS}ar} 692 LD=${LD:-${CROSS}${link_with_cc:-ld}} 693 AS=${AS:-${CROSS}as} 694 STRIP=${STRIP:-${CROSS}strip} 695 NM=${NM:-${CROSS}nm} 696 AS_SFX=.S 697 EXE_SFX= 698} 699 700# Reliably find the newest available Darwin SDKs. (Older versions of 701# xcrun don't support --show-sdk-path.) 702show_darwin_sdk_path() { 703 xcrun --sdk $1 --show-sdk-path 2>/dev/null || 704 xcodebuild -sdk $1 -version Path 2>/dev/null 705} 706 707# Print the major version number of the Darwin SDK specified by $1. 708show_darwin_sdk_major_version() { 709 xcrun --sdk $1 --show-sdk-version 2>/dev/null | cut -d. -f1 710} 711 712# Print the Xcode version. 713show_xcode_version() { 714 xcodebuild -version | head -n1 | cut -d' ' -f2 715} 716 717# Fails when Xcode version is less than 6.3. 718check_xcode_minimum_version() { 719 xcode_major=$(show_xcode_version | cut -f1 -d.) 720 xcode_minor=$(show_xcode_version | cut -f2 -d.) 721 xcode_min_major=6 722 xcode_min_minor=3 723 if [ ${xcode_major} -lt ${xcode_min_major} ]; then 724 return 1 725 fi 726 if [ ${xcode_major} -eq ${xcode_min_major} ] \ 727 && [ ${xcode_minor} -lt ${xcode_min_minor} ]; then 728 return 1 729 fi 730} 731 732process_common_toolchain() { 733 if [ -z "$toolchain" ]; then 734 gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}" 735 # detect tgt_isa 736 case "$gcctarget" in 737 aarch64*) 738 tgt_isa=arm64 739 ;; 740 armv7*-hardfloat* | armv7*-gnueabihf | arm-*-gnueabihf) 741 tgt_isa=armv7 742 float_abi=hard 743 ;; 744 armv7*) 745 tgt_isa=armv7 746 float_abi=softfp 747 ;; 748 *x86_64*|*amd64*) 749 tgt_isa=x86_64 750 ;; 751 *i[3456]86*) 752 tgt_isa=x86 753 ;; 754 *sparc*) 755 tgt_isa=sparc 756 ;; 757 power*64le*-*) 758 tgt_isa=ppc64le 759 ;; 760 *mips64el*) 761 tgt_isa=mips64 762 ;; 763 *mips32el*) 764 tgt_isa=mips32 765 ;; 766 esac 767 768 # detect tgt_os 769 case "$gcctarget" in 770 *darwin10*) 771 tgt_isa=x86_64 772 tgt_os=darwin10 773 ;; 774 *darwin11*) 775 tgt_isa=x86_64 776 tgt_os=darwin11 777 ;; 778 *darwin12*) 779 tgt_isa=x86_64 780 tgt_os=darwin12 781 ;; 782 *darwin13*) 783 tgt_isa=x86_64 784 tgt_os=darwin13 785 ;; 786 *darwin14*) 787 tgt_isa=x86_64 788 tgt_os=darwin14 789 ;; 790 *darwin15*) 791 tgt_isa=x86_64 792 tgt_os=darwin15 793 ;; 794 *darwin16*) 795 tgt_isa=x86_64 796 tgt_os=darwin16 797 ;; 798 *darwin17*) 799 tgt_isa=x86_64 800 tgt_os=darwin17 801 ;; 802 *darwin18*) 803 tgt_isa=x86_64 804 tgt_os=darwin18 805 ;; 806 *darwin19*) 807 tgt_isa=x86_64 808 tgt_os=darwin19 809 ;; 810 x86_64*mingw32*) 811 tgt_os=win64 812 ;; 813 x86_64*cygwin*) 814 tgt_os=win64 815 ;; 816 *mingw32*|*cygwin*) 817 [ -z "$tgt_isa" ] && tgt_isa=x86 818 tgt_os=win32 819 ;; 820 *linux*|*bsd*) 821 tgt_os=linux 822 ;; 823 *solaris2.10) 824 tgt_os=solaris 825 ;; 826 *os2*) 827 tgt_os=os2 828 ;; 829 esac 830 831 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then 832 toolchain=${tgt_isa}-${tgt_os}-gcc 833 fi 834 fi 835 836 toolchain=${toolchain:-generic-gnu} 837 838 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \ 839 || die "Unrecognized toolchain '${toolchain}'" 840 841 enabled child || log_echo "Configuring for target '${toolchain}'" 842 843 # 844 # Set up toolchain variables 845 # 846 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}') 847 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}') 848 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}') 849 850 # Mark the specific ISA requested as enabled 851 soft_enable ${tgt_isa} 852 enable_feature ${tgt_os} 853 enable_feature ${tgt_cc} 854 855 # Enable the architecture family 856 case ${tgt_isa} in 857 arm*) 858 enable_feature arm 859 ;; 860 mips*) 861 enable_feature mips 862 ;; 863 ppc*) 864 enable_feature ppc 865 ;; 866 esac 867 868 # PIC is probably what we want when building shared libs 869 enabled shared && soft_enable pic 870 871 # Minimum iOS version for all target platforms (darwin and iphonesimulator). 872 # Shared library framework builds are only possible on iOS 8 and later. 873 if enabled shared; then 874 IOS_VERSION_OPTIONS="--enable-shared" 875 IOS_VERSION_MIN="8.0" 876 else 877 IOS_VERSION_OPTIONS="" 878 IOS_VERSION_MIN="7.0" 879 fi 880 881 # Handle darwin variants. Newer SDKs allow targeting older 882 # platforms, so use the newest one available. 883 case ${toolchain} in 884 arm*-darwin*) 885 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}" 886 iphoneos_sdk_dir="$(show_darwin_sdk_path iphoneos)" 887 if [ -d "${iphoneos_sdk_dir}" ]; then 888 add_cflags "-isysroot ${iphoneos_sdk_dir}" 889 add_ldflags "-isysroot ${iphoneos_sdk_dir}" 890 fi 891 ;; 892 x86*-darwin*) 893 osx_sdk_dir="$(show_darwin_sdk_path macosx)" 894 if [ -d "${osx_sdk_dir}" ]; then 895 add_cflags "-isysroot ${osx_sdk_dir}" 896 add_ldflags "-isysroot ${osx_sdk_dir}" 897 fi 898 ;; 899 esac 900 901 case ${toolchain} in 902 *-darwin8-*) 903 add_cflags "-mmacosx-version-min=10.4" 904 add_ldflags "-mmacosx-version-min=10.4" 905 ;; 906 *-darwin9-*) 907 add_cflags "-mmacosx-version-min=10.5" 908 add_ldflags "-mmacosx-version-min=10.5" 909 ;; 910 *-darwin10-*) 911 add_cflags "-mmacosx-version-min=10.6" 912 add_ldflags "-mmacosx-version-min=10.6" 913 ;; 914 *-darwin11-*) 915 add_cflags "-mmacosx-version-min=10.7" 916 add_ldflags "-mmacosx-version-min=10.7" 917 ;; 918 *-darwin12-*) 919 add_cflags "-mmacosx-version-min=10.8" 920 add_ldflags "-mmacosx-version-min=10.8" 921 ;; 922 *-darwin13-*) 923 add_cflags "-mmacosx-version-min=10.9" 924 add_ldflags "-mmacosx-version-min=10.9" 925 ;; 926 *-darwin14-*) 927 add_cflags "-mmacosx-version-min=10.10" 928 add_ldflags "-mmacosx-version-min=10.10" 929 ;; 930 *-darwin15-*) 931 add_cflags "-mmacosx-version-min=10.11" 932 add_ldflags "-mmacosx-version-min=10.11" 933 ;; 934 *-darwin16-*) 935 add_cflags "-mmacosx-version-min=10.12" 936 add_ldflags "-mmacosx-version-min=10.12" 937 ;; 938 *-darwin17-*) 939 add_cflags "-mmacosx-version-min=10.13" 940 add_ldflags "-mmacosx-version-min=10.13" 941 ;; 942 *-darwin18-*) 943 add_cflags "-mmacosx-version-min=10.14" 944 add_ldflags "-mmacosx-version-min=10.14" 945 ;; 946 *-darwin19-*) 947 add_cflags "-mmacosx-version-min=10.15" 948 add_ldflags "-mmacosx-version-min=10.15" 949 ;; 950 *-iphonesimulator-*) 951 add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}" 952 add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}" 953 iossim_sdk_dir="$(show_darwin_sdk_path iphonesimulator)" 954 if [ -d "${iossim_sdk_dir}" ]; then 955 add_cflags "-isysroot ${iossim_sdk_dir}" 956 add_ldflags "-isysroot ${iossim_sdk_dir}" 957 fi 958 ;; 959 esac 960 961 # Handle Solaris variants. Solaris 10 needs -lposix4 962 case ${toolchain} in 963 sparc-solaris-*) 964 add_extralibs -lposix4 965 ;; 966 *-solaris-*) 967 add_extralibs -lposix4 968 ;; 969 esac 970 971 # Process ARM architecture variants 972 case ${toolchain} in 973 arm*) 974 # on arm, isa versions are supersets 975 case ${tgt_isa} in 976 arm64|armv8) 977 soft_enable neon 978 ;; 979 armv7|armv7s) 980 soft_enable neon 981 # Only enable neon_asm when neon is also enabled. 982 enabled neon && soft_enable neon_asm 983 # If someone tries to force it through, die. 984 if disabled neon && enabled neon_asm; then 985 die "Disabling neon while keeping neon-asm is not supported" 986 fi 987 ;; 988 esac 989 990 asm_conversion_cmd="cat" 991 992 case ${tgt_cc} in 993 gcc) 994 link_with_cc=gcc 995 setup_gnu_toolchain 996 arch_int=${tgt_isa##armv} 997 arch_int=${arch_int%%te} 998 tune_cflags="-mtune=" 999 if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then 1000 if [ -z "${float_abi}" ]; then 1001 check_cpp <<EOF && float_abi=hard || float_abi=softfp 1002#ifndef __ARM_PCS_VFP 1003#error "not hardfp" 1004#endif 1005EOF 1006 fi 1007 check_add_cflags -march=armv7-a -mfloat-abi=${float_abi} 1008 check_add_asflags -march=armv7-a -mfloat-abi=${float_abi} 1009 1010 if enabled neon || enabled neon_asm; then 1011 check_add_cflags -mfpu=neon #-ftree-vectorize 1012 check_add_asflags -mfpu=neon 1013 fi 1014 elif [ ${tgt_isa} = "arm64" ] || [ ${tgt_isa} = "armv8" ]; then 1015 check_add_cflags -march=armv8-a 1016 check_add_asflags -march=armv8-a 1017 else 1018 check_add_cflags -march=${tgt_isa} 1019 check_add_asflags -march=${tgt_isa} 1020 fi 1021 1022 enabled debug && add_asflags -g 1023 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl" 1024 1025 case ${tgt_os} in 1026 win*) 1027 asm_conversion_cmd="$asm_conversion_cmd -noelf" 1028 AS="$CC -c" 1029 EXE_SFX=.exe 1030 enable_feature thumb 1031 ;; 1032 esac 1033 1034 if enabled thumb; then 1035 asm_conversion_cmd="$asm_conversion_cmd -thumb" 1036 check_add_cflags -mthumb 1037 check_add_asflags -mthumb -mimplicit-it=always 1038 fi 1039 ;; 1040 vs*) 1041 # A number of ARM-based Windows platforms are constrained by their 1042 # respective SDKs' limitations. Fortunately, these are all 32-bit ABIs 1043 # and so can be selected as 'win32'. 1044 if [ ${tgt_os} = "win32" ]; then 1045 asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl" 1046 AS_SFX=.S 1047 msvs_arch_dir=arm-msvs 1048 disable_feature multithread 1049 disable_feature unit_tests 1050 if [ ${tgt_cc##vs} -ge 12 ]; then 1051 # MSVC 2013 doesn't allow doing plain .exe projects for ARM32, 1052 # only "AppContainerApplication" which requires an AppxManifest. 1053 # Therefore disable the examples, just build the library. 1054 disable_feature examples 1055 disable_feature tools 1056 fi 1057 else 1058 # Windows 10 on ARM, on the other hand, has full Windows SDK support 1059 # for building Win32 ARM64 applications in addition to ARM64 1060 # Windows Store apps. It is the only 64-bit ARM ABI that 1061 # Windows supports, so it is the default definition of 'win64'. 1062 # ARM64 build support officially shipped in Visual Studio 15.9.0. 1063 1064 # Because the ARM64 Windows SDK's arm_neon.h is ARM32-specific 1065 # while LLVM's is not, probe its validity. 1066 if enabled neon; then 1067 if [ -n "${CC}" ]; then 1068 check_header arm_neon.h || check_header arm64_neon.h && \ 1069 enable_feature win_arm64_neon_h_workaround 1070 else 1071 # If a probe is not possible, assume this is the pure Windows 1072 # SDK and so the workaround is necessary. 1073 enable_feature win_arm64_neon_h_workaround 1074 fi 1075 fi 1076 fi 1077 ;; 1078 rvct) 1079 CC=armcc 1080 AR=armar 1081 AS=armasm 1082 LD="${source_path}/build/make/armlink_adapter.sh" 1083 STRIP=arm-none-linux-gnueabi-strip 1084 NM=arm-none-linux-gnueabi-nm 1085 tune_cflags="--cpu=" 1086 tune_asflags="--cpu=" 1087 if [ -z "${tune_cpu}" ]; then 1088 if [ ${tgt_isa} = "armv7" ]; then 1089 if enabled neon || enabled neon_asm 1090 then 1091 check_add_cflags --fpu=softvfp+vfpv3 1092 check_add_asflags --fpu=softvfp+vfpv3 1093 fi 1094 check_add_cflags --cpu=Cortex-A8 1095 check_add_asflags --cpu=Cortex-A8 1096 else 1097 check_add_cflags --cpu=${tgt_isa##armv} 1098 check_add_asflags --cpu=${tgt_isa##armv} 1099 fi 1100 fi 1101 arch_int=${tgt_isa##armv} 1102 arch_int=${arch_int%%te} 1103 enabled debug && add_asflags -g 1104 add_cflags --gnu 1105 add_cflags --enum_is_int 1106 add_cflags --wchar32 1107 ;; 1108 esac 1109 1110 case ${tgt_os} in 1111 none*) 1112 disable_feature multithread 1113 disable_feature os_support 1114 ;; 1115 1116 android*) 1117 echo "Assuming standalone build with NDK toolchain." 1118 echo "See build/make/Android.mk for details." 1119 check_add_ldflags -static 1120 soft_enable unit_tests 1121 ;; 1122 1123 darwin*) 1124 XCRUN_FIND="xcrun --sdk iphoneos --find" 1125 CXX="$(${XCRUN_FIND} clang++)" 1126 CC="$(${XCRUN_FIND} clang)" 1127 AR="$(${XCRUN_FIND} ar)" 1128 AS="$(${XCRUN_FIND} as)" 1129 STRIP="$(${XCRUN_FIND} strip)" 1130 NM="$(${XCRUN_FIND} nm)" 1131 RANLIB="$(${XCRUN_FIND} ranlib)" 1132 AS_SFX=.S 1133 LD="${CXX:-$(${XCRUN_FIND} ld)}" 1134 1135 # ASFLAGS is written here instead of using check_add_asflags 1136 # because we need to overwrite all of ASFLAGS and purge the 1137 # options that were put in above 1138 ASFLAGS="-arch ${tgt_isa} -g" 1139 1140 add_cflags -arch ${tgt_isa} 1141 add_ldflags -arch ${tgt_isa} 1142 1143 alt_libc="$(show_darwin_sdk_path iphoneos)" 1144 if [ -d "${alt_libc}" ]; then 1145 add_cflags -isysroot ${alt_libc} 1146 fi 1147 1148 if [ "${LD}" = "${CXX}" ]; then 1149 add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}" 1150 else 1151 add_ldflags -ios_version_min "${IOS_VERSION_MIN}" 1152 fi 1153 1154 for d in lib usr/lib usr/lib/system; do 1155 try_dir="${alt_libc}/${d}" 1156 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}" 1157 done 1158 1159 case ${tgt_isa} in 1160 armv7|armv7s|armv8|arm64) 1161 if enabled neon && ! check_xcode_minimum_version; then 1162 soft_disable neon 1163 log_echo " neon disabled: upgrade Xcode (need v6.3+)." 1164 if enabled neon_asm; then 1165 soft_disable neon_asm 1166 log_echo " neon_asm disabled: upgrade Xcode (need v6.3+)." 1167 fi 1168 fi 1169 ;; 1170 esac 1171 1172 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl" 1173 1174 if [ "$(show_darwin_sdk_major_version iphoneos)" -gt 8 ]; then 1175 check_add_cflags -fembed-bitcode 1176 check_add_asflags -fembed-bitcode 1177 check_add_ldflags -fembed-bitcode 1178 fi 1179 ;; 1180 1181 linux*) 1182 enable_feature linux 1183 if enabled rvct; then 1184 # Check if we have CodeSourcery GCC in PATH. Needed for 1185 # libraries 1186 which arm-none-linux-gnueabi-gcc 2>&- || \ 1187 die "Couldn't find CodeSourcery GCC from PATH" 1188 1189 # Use armcc as a linker to enable translation of 1190 # some gcc specific options such as -lm and -lpthread. 1191 LD="armcc --translate_gcc" 1192 1193 # create configuration file (uses path to CodeSourcery GCC) 1194 armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg 1195 1196 add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg 1197 add_asflags --no_hide_all --apcs=/interwork 1198 add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg 1199 enabled pic && add_cflags --apcs=/fpic 1200 enabled pic && add_asflags --apcs=/fpic 1201 enabled shared && add_cflags --shared 1202 fi 1203 ;; 1204 esac 1205 ;; 1206 mips*) 1207 link_with_cc=gcc 1208 setup_gnu_toolchain 1209 tune_cflags="-mtune=" 1210 if enabled dspr2; then 1211 check_add_cflags -mips32r2 -mdspr2 1212 fi 1213 1214 if enabled runtime_cpu_detect; then 1215 disable_feature runtime_cpu_detect 1216 fi 1217 1218 if [ -n "${tune_cpu}" ]; then 1219 case ${tune_cpu} in 1220 p5600) 1221 check_add_cflags -mips32r5 -mload-store-pairs 1222 check_add_cflags -msched-weight -mhard-float -mfp64 1223 check_add_asflags -mips32r5 -mhard-float -mfp64 1224 check_add_ldflags -mfp64 1225 ;; 1226 i6400|p6600) 1227 check_add_cflags -mips64r6 -mabi=64 -msched-weight 1228 check_add_cflags -mload-store-pairs -mhard-float -mfp64 1229 check_add_asflags -mips64r6 -mabi=64 -mhard-float -mfp64 1230 check_add_ldflags -mips64r6 -mabi=64 -mfp64 1231 ;; 1232 esac 1233 1234 if enabled msa; then 1235 # TODO(libyuv:793) 1236 # The new mips functions in libyuv do not build 1237 # with the toolchains we currently use for testing. 1238 soft_disable libyuv 1239 1240 add_cflags -mmsa 1241 add_asflags -mmsa 1242 add_ldflags -mmsa 1243 fi 1244 fi 1245 1246 if enabled mmi; then 1247 tgt_isa=loongson3a 1248 check_add_ldflags -march=loongson3a 1249 fi 1250 1251 check_add_cflags -march=${tgt_isa} 1252 check_add_asflags -march=${tgt_isa} 1253 check_add_asflags -KPIC 1254 ;; 1255 ppc64le*) 1256 link_with_cc=gcc 1257 setup_gnu_toolchain 1258 # Do not enable vsx by default. 1259 # https://bugs.chromium.org/p/webm/issues/detail?id=1522 1260 enabled vsx || RTCD_OPTIONS="${RTCD_OPTIONS}--disable-vsx " 1261 if [ -n "${tune_cpu}" ]; then 1262 case ${tune_cpu} in 1263 power?) 1264 tune_cflags="-mcpu=" 1265 ;; 1266 esac 1267 fi 1268 ;; 1269 x86*) 1270 case ${tgt_os} in 1271 android) 1272 soft_enable realtime_only 1273 ;; 1274 win*) 1275 enabled gcc && add_cflags -fno-common 1276 ;; 1277 solaris*) 1278 CC=${CC:-${CROSS}gcc} 1279 CXX=${CXX:-${CROSS}g++} 1280 LD=${LD:-${CROSS}gcc} 1281 CROSS=${CROSS-g} 1282 ;; 1283 os2) 1284 disable_feature pic 1285 AS=${AS:-nasm} 1286 add_ldflags -Zhigh-mem 1287 ;; 1288 esac 1289 1290 AS="${alt_as:-${AS:-auto}}" 1291 case ${tgt_cc} in 1292 icc*) 1293 CC=${CC:-icc} 1294 LD=${LD:-icc} 1295 setup_gnu_toolchain 1296 add_cflags -use-msasm # remove -use-msasm too? 1297 # add -no-intel-extensions to suppress warning #10237 1298 # refer to http://software.intel.com/en-us/forums/topic/280199 1299 add_ldflags -i-static -no-intel-extensions 1300 enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div 1301 enabled x86_64 && AR=xiar 1302 case ${tune_cpu} in 1303 atom*) 1304 tune_cflags="-x" 1305 tune_cpu="SSE3_ATOM" 1306 ;; 1307 *) 1308 tune_cflags="-march=" 1309 ;; 1310 esac 1311 ;; 1312 gcc*) 1313 link_with_cc=gcc 1314 tune_cflags="-march=" 1315 setup_gnu_toolchain 1316 #for 32 bit x86 builds, -O3 did not turn on this flag 1317 enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer 1318 ;; 1319 vs*) 1320 # When building with Microsoft Visual Studio the assembler is 1321 # invoked directly. Checking at configure time is unnecessary. 1322 # Skip the check by setting AS arbitrarily 1323 AS=msvs 1324 msvs_arch_dir=x86-msvs 1325 case ${tgt_cc##vs} in 1326 14) 1327 echo "${tgt_cc} does not support avx512, disabling....." 1328 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx512 " 1329 soft_disable avx512 1330 ;; 1331 esac 1332 ;; 1333 esac 1334 1335 bits=32 1336 enabled x86_64 && bits=64 1337 check_cpp <<EOF && bits=x32 1338#if !defined(__ILP32__) || !defined(__x86_64__) 1339#error "not x32" 1340#endif 1341EOF 1342 case ${tgt_cc} in 1343 gcc*) 1344 add_cflags -m${bits} 1345 add_ldflags -m${bits} 1346 ;; 1347 esac 1348 1349 soft_enable runtime_cpu_detect 1350 # We can't use 'check_cflags' until the compiler is configured and CC is 1351 # populated. 1352 for ext in ${ARCH_EXT_LIST_X86}; do 1353 # disable higher order extensions to simplify asm dependencies 1354 if [ "$disable_exts" = "yes" ]; then 1355 if ! disabled $ext; then 1356 RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${ext} " 1357 disable_feature $ext 1358 fi 1359 elif disabled $ext; then 1360 disable_exts="yes" 1361 else 1362 if [ "$ext" = "avx512" ]; then 1363 check_gcc_machine_options $ext avx512f avx512cd avx512bw avx512dq avx512vl 1364 check_gcc_avx512_compiles 1365 else 1366 # use the shortened version for the flag: sse4_1 -> sse4 1367 check_gcc_machine_option ${ext%_*} $ext 1368 fi 1369 fi 1370 done 1371 1372 if enabled external_build; then 1373 log_echo " skipping assembler detection" 1374 else 1375 case "${AS}" in 1376 auto|"") 1377 which nasm >/dev/null 2>&1 && AS=nasm 1378 which yasm >/dev/null 2>&1 && AS=yasm 1379 if [ "${AS}" = nasm ] ; then 1380 # Apple ships version 0.98 of nasm through at least Xcode 6. Revisit 1381 # this check if they start shipping a compatible version. 1382 apple=`nasm -v | grep "Apple"` 1383 [ -n "${apple}" ] \ 1384 && echo "Unsupported version of nasm: ${apple}" \ 1385 && AS="" 1386 fi 1387 [ "${AS}" = auto ] || [ -z "${AS}" ] \ 1388 && die "Neither yasm nor nasm have been found." \ 1389 "See the prerequisites section in the README for more info." 1390 ;; 1391 esac 1392 log_echo " using $AS" 1393 fi 1394 AS_SFX=.asm 1395 case ${tgt_os} in 1396 win32) 1397 add_asflags -f win32 1398 enabled debug && add_asflags -g cv8 1399 EXE_SFX=.exe 1400 ;; 1401 win64) 1402 add_asflags -f win64 1403 enabled debug && add_asflags -g cv8 1404 EXE_SFX=.exe 1405 ;; 1406 linux*|solaris*|android*) 1407 add_asflags -f elf${bits} 1408 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2 1409 enabled debug && [ "${AS}" = nasm ] && add_asflags -g 1410 [ "${AS##*/}" = nasm ] && check_asm_align 1411 ;; 1412 darwin*) 1413 add_asflags -f macho${bits} 1414 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64" 1415 add_cflags ${darwin_arch} 1416 add_ldflags ${darwin_arch} 1417 # -mdynamic-no-pic is still a bit of voodoo -- it was required at 1418 # one time, but does not seem to be now, and it breaks some of the 1419 # code that still relies on inline assembly. 1420 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic 1421 enabled icc && ! enabled pic && add_cflags -fno-pic 1422 ;; 1423 iphonesimulator) 1424 add_asflags -f macho${bits} 1425 enabled x86 && sim_arch="-arch i386" || sim_arch="-arch x86_64" 1426 add_cflags ${sim_arch} 1427 add_ldflags ${sim_arch} 1428 1429 if [ "$(disabled external_build)" ] && 1430 [ "$(show_darwin_sdk_major_version iphonesimulator)" -gt 8 ]; then 1431 # yasm v1.3.0 doesn't know what -fembed-bitcode means, so turning it 1432 # on is pointless (unless building a C-only lib). Warn the user, but 1433 # do nothing here. 1434 log "Warning: Bitcode embed disabled for simulator targets." 1435 fi 1436 ;; 1437 os2) 1438 add_asflags -f aout 1439 enabled debug && add_asflags -g 1440 EXE_SFX=.exe 1441 ;; 1442 *) 1443 log "Warning: Unknown os $tgt_os while setting up $AS flags" 1444 ;; 1445 esac 1446 ;; 1447 *-gcc|generic-gnu) 1448 link_with_cc=gcc 1449 enable_feature gcc 1450 setup_gnu_toolchain 1451 ;; 1452 esac 1453 1454 # Try to enable CPU specific tuning 1455 if [ -n "${tune_cpu}" ]; then 1456 if [ -n "${tune_cflags}" ]; then 1457 check_add_cflags ${tune_cflags}${tune_cpu} || \ 1458 die "Requested CPU '${tune_cpu}' not supported by compiler" 1459 fi 1460 if [ -n "${tune_asflags}" ]; then 1461 check_add_asflags ${tune_asflags}${tune_cpu} || \ 1462 die "Requested CPU '${tune_cpu}' not supported by assembler" 1463 fi 1464 if [ -z "${tune_cflags}${tune_asflags}" ]; then 1465 log_echo "Warning: CPU tuning not supported by this toolchain" 1466 fi 1467 fi 1468 1469 if enabled debug; then 1470 check_add_cflags -g && check_add_ldflags -g 1471 else 1472 check_add_cflags -DNDEBUG 1473 fi 1474 1475 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg 1476 enabled gcov && 1477 check_add_cflags -fprofile-arcs -ftest-coverage && 1478 check_add_ldflags -fprofile-arcs -ftest-coverage 1479 1480 if enabled optimizations; then 1481 if enabled rvct; then 1482 enabled small && check_add_cflags -Ospace || check_add_cflags -Otime 1483 else 1484 enabled small && check_add_cflags -O2 || check_add_cflags -O3 1485 fi 1486 fi 1487 1488 # Position Independent Code (PIC) support, for building relocatable 1489 # shared objects 1490 enabled gcc && enabled pic && check_add_cflags -fPIC 1491 1492 # Work around longjmp interception on glibc >= 2.11, to improve binary 1493 # compatibility. See http://code.google.com/p/webm/issues/detail?id=166 1494 enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 1495 1496 # Check for strip utility variant 1497 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip 1498 1499 # Try to determine target endianness 1500 check_cc <<EOF 1501unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E'; 1502EOF 1503 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' | 1504 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian 1505 1506 # Try to find which inline keywords are supported 1507 check_cc <<EOF && INLINE="inline" 1508static inline function() {} 1509EOF 1510 1511 # Almost every platform uses pthreads. 1512 if enabled multithread; then 1513 case ${toolchain} in 1514 *-win*-vs*) 1515 ;; 1516 *-android-gcc) 1517 # bionic includes basic pthread functionality, obviating -lpthread. 1518 ;; 1519 *) 1520 check_header pthread.h && check_lib -lpthread <<EOF && add_extralibs -lpthread || disable_feature pthread_h 1521#include <pthread.h> 1522#include <stddef.h> 1523void *thread_check (void *); 1524void *thread_check (void *obj){ return obj;}; 1525int main(void) { pthread_t thread_id; return pthread_create(&thread_id, NULL, thread_check, NULL); } 1526EOF 1527 ;; 1528 esac 1529 fi 1530 1531 # only for MIPS platforms 1532 case ${toolchain} in 1533 mips*) 1534 if enabled big_endian; then 1535 if enabled dspr2; then 1536 echo "dspr2 optimizations are available only for little endian platforms" 1537 disable_feature dspr2 1538 fi 1539 if enabled msa; then 1540 echo "msa optimizations are available only for little endian platforms" 1541 disable_feature msa 1542 fi 1543 if enabled mmi; then 1544 echo "mmi optimizations are available only for little endian platforms" 1545 disable_feature mmi 1546 fi 1547 fi 1548 ;; 1549 esac 1550 1551 # glibc needs these 1552 if enabled linux; then 1553 add_cflags -D_LARGEFILE_SOURCE 1554 add_cflags -D_FILE_OFFSET_BITS=64 1555 fi 1556} 1557 1558process_toolchain() { 1559 process_common_toolchain 1560} 1561 1562print_config_mk() { 1563 saved_prefix="${prefix}" 1564 prefix=$1 1565 makefile=$2 1566 shift 2 1567 for cfg; do 1568 if enabled $cfg; then 1569 upname="`toupper $cfg`" 1570 echo "${prefix}_${upname}=yes" >> $makefile 1571 fi 1572 done 1573 prefix="${saved_prefix}" 1574} 1575 1576print_config_h() { 1577 saved_prefix="${prefix}" 1578 prefix=$1 1579 header=$2 1580 shift 2 1581 for cfg; do 1582 upname="`toupper $cfg`" 1583 if enabled $cfg; then 1584 echo "#define ${prefix}_${upname} 1" >> $header 1585 else 1586 echo "#define ${prefix}_${upname} 0" >> $header 1587 fi 1588 done 1589 prefix="${saved_prefix}" 1590} 1591 1592print_config_vars_h() { 1593 header=$1 1594 shift 1595 while [ $# -gt 0 ]; do 1596 upname="`toupper $1`" 1597 echo "#define ${upname} $2" >> $header 1598 shift 2 1599 done 1600} 1601 1602print_webm_license() { 1603 saved_prefix="${prefix}" 1604 destination=$1 1605 prefix="$2" 1606 suffix="$3" 1607 shift 3 1608 cat <<EOF > ${destination} 1609${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix} 1610${prefix} ${suffix} 1611${prefix} Use of this source code is governed by a BSD-style license${suffix} 1612${prefix} that can be found in the LICENSE file in the root of the source${suffix} 1613${prefix} tree. An additional intellectual property rights grant can be found${suffix} 1614${prefix} in the file PATENTS. All contributing project authors may${suffix} 1615${prefix} be found in the AUTHORS file in the root of the source tree.${suffix} 1616EOF 1617 prefix="${saved_prefix}" 1618} 1619 1620process_targets() { 1621 true; 1622} 1623 1624process_detect() { 1625 true; 1626} 1627 1628enable_feature logging 1629logfile="config.log" 1630self=$0 1631process() { 1632 cmdline_args="$@" 1633 process_cmdline "$@" 1634 if enabled child; then 1635 echo "# ${self} $@" >> ${logfile} 1636 else 1637 echo "# ${self} $@" > ${logfile} 1638 fi 1639 post_process_common_cmdline 1640 post_process_cmdline 1641 process_toolchain 1642 process_detect 1643 process_targets 1644 1645 OOT_INSTALLS="${OOT_INSTALLS}" 1646 if enabled source_path_used; then 1647 # Prepare the PWD for building. 1648 for f in ${OOT_INSTALLS}; do 1649 install -D "${source_path}/$f" "$f" 1650 done 1651 fi 1652 cp "${source_path}/build/make/Makefile" . 1653 1654 clean_temp_files 1655 true 1656} 1657