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