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