1#!/bin/bash 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 23 24die() { 25 echo "$@" 26 echo 27 echo "Configuration failed. This could reflect a misconfiguration of your" 28 echo "toolchains, improper options selected, or another problem. If you" 29 echo "don't see any useful error messages above, the next step is to look" 30 echo "at the configure error log file ($logfile) to determine what" 31 echo "configure was trying to do when it died." 32 clean_temp_files 33 exit 1 34} 35 36 37log(){ 38 echo "$@" >>$logfile 39} 40 41 42log_file(){ 43 log BEGIN $1 44 pr -n -t $1 >>$logfile 45 log END $1 46} 47 48 49log_echo() { 50 echo "$@" 51 log "$@" 52} 53 54 55fwrite () { 56 outfile=$1 57 shift 58 echo "$@" >> ${outfile} 59} 60 61 62show_help_pre(){ 63 for opt in ${CMDLINE_SELECT}; do 64 opt2=`echo $opt | sed -e 's;_;-;g'` 65 if enabled $opt; then 66 eval "toggle_${opt}=\"--disable-${opt2}\"" 67 else 68 eval "toggle_${opt}=\"--enable-${opt2} \"" 69 fi 70 done 71 72 cat <<EOF 73Usage: configure [options] 74Options: 75 76Build options: 77 --help print this message 78 --log=yes|no|FILE file configure log is written to [config.err] 79 --target=TARGET target platform tuple [generic-gnu] 80 --cpu=CPU optimize for a specific cpu rather than a family 81 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS] 82 ${toggle_extra_warnings} emit harmless warnings (always non-fatal) 83 ${toggle_werror} treat warnings as errors, if possible 84 (not available with all compilers) 85 ${toggle_optimizations} turn on/off compiler optimization flags 86 ${toggle_pic} turn on/off Position Independent Code 87 ${toggle_ccache} turn on/off compiler cache 88 ${toggle_debug} enable/disable debug mode 89 ${toggle_gprof} enable/disable gprof profiling instrumentation 90 ${toggle_gcov} enable/disable gcov coverage instrumentation 91 92Install options: 93 ${toggle_install_docs} control whether docs are installed 94 ${toggle_install_bins} control whether binaries are installed 95 ${toggle_install_libs} control whether libraries are installed 96 ${toggle_install_srcs} control whether sources are installed 97 98 99EOF 100} 101 102 103show_help_post(){ 104 cat <<EOF 105 106 107NOTES: 108 Object files are built at the place where configure is launched. 109 110 All boolean options can be negated. The default value is the opposite 111 of that shown above. If the option --disable-foo is listed, then 112 the default value for foo is enabled. 113 114Supported targets: 115EOF 116 show_targets ${all_platforms} 117 echo 118 exit 1 119} 120 121 122show_targets() { 123 while [ -n "$*" ]; do 124 if [ "${1%%-*}" = "${2%%-*}" ]; then 125 if [ "${2%%-*}" = "${3%%-*}" ]; then 126 printf " %-24s %-24s %-24s\n" "$1" "$2" "$3" 127 shift; shift; shift 128 else 129 printf " %-24s %-24s\n" "$1" "$2" 130 shift; shift 131 fi 132 else 133 printf " %-24s\n" "$1" 134 shift 135 fi 136 done 137} 138 139 140show_help() { 141 show_help_pre 142 show_help_post 143} 144 145# 146# List Processing Functions 147# 148set_all(){ 149 value=$1 150 shift 151 for var in $*; do 152 eval $var=$value 153 done 154} 155 156 157is_in(){ 158 value=$1 159 shift 160 for var in $*; do 161 [ $var = $value ] && return 0 162 done 163 return 1 164} 165 166 167add_cflags() { 168 CFLAGS="${CFLAGS} $@" 169} 170 171 172add_ldflags() { 173 LDFLAGS="${LDFLAGS} $@" 174} 175 176 177add_asflags() { 178 ASFLAGS="${ASFLAGS} $@" 179} 180 181 182add_extralibs() { 183 extralibs="${extralibs} $@" 184} 185 186# 187# Boolean Manipulation Functions 188# 189enable(){ 190 set_all yes $* 191} 192 193disable(){ 194 set_all no $* 195} 196 197enabled(){ 198 eval test "x\$$1" = "xyes" 199} 200 201disabled(){ 202 eval test "x\$$1" = "xno" 203} 204 205 206soft_enable() { 207 for var in $*; do 208 if ! disabled $var; then 209 log_echo " enabling $var" 210 enable $var 211 fi 212 done 213} 214 215soft_disable() { 216 for var in $*; do 217 if ! enabled $var; then 218 log_echo " disabling $var" 219 disable $var 220 fi 221 done 222} 223 224 225# 226# Text Processing Functions 227# 228toupper(){ 229 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 230} 231 232 233tolower(){ 234 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 235} 236 237 238# 239# Temporary File Functions 240# 241source_path=${0%/*} 242enable source_path_used 243if test -z "$source_path" -o "$source_path" = "." ; then 244 source_path="`pwd`" 245 disable source_path_used 246fi 247 248if test ! -z "$TMPDIR" ; then 249 TMPDIRx="${TMPDIR}" 250elif test ! -z "$TEMPDIR" ; then 251 TMPDIRx="${TEMPDIR}" 252else 253 TMPDIRx="/tmp" 254fi 255TMP_H="${TMPDIRx}/vpx-conf-$$-${RANDOM}.h" 256TMP_C="${TMPDIRx}/vpx-conf-$$-${RANDOM}.c" 257TMP_O="${TMPDIRx}/vpx-conf-$$-${RANDOM}.o" 258TMP_X="${TMPDIRx}/vpx-conf-$$-${RANDOM}.x" 259TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RANDOM}.asm" 260 261clean_temp_files() { 262 rm -f ${TMP_C} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM} 263} 264 265# 266# Toolchain Check Functions 267# 268check_cmd() { 269 log "$@" 270 "$@" >>${logfile} 2>&1 271} 272 273check_cc() { 274 log check_cc "$@" 275 cat >${TMP_C} 276 log_file ${TMP_C} 277 check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C} 278} 279 280check_cpp() { 281 log check_cpp "$@" 282 cat > ${TMP_C} 283 log_file ${TMP_C} 284 check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C} 285} 286 287check_ld() { 288 log check_ld "$@" 289 check_cc $@ \ 290 && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs} 291} 292 293check_header(){ 294 log check_header "$@" 295 header=$1 296 shift 297 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'` 298 disable $var 299 check_cpp "$@" <<EOF && enable $var 300#include "$header" 301int x; 302EOF 303} 304 305 306check_cflags() { 307 log check_cflags "$@" 308 check_cc "$@" <<EOF 309int x; 310EOF 311} 312 313check_add_cflags() { 314 check_cflags "$@" && add_cflags "$@" 315} 316 317check_add_asflags() { 318 log add_asflags "$@" 319 add_asflags "$@" 320} 321 322check_add_ldflags() { 323 log add_ldflags "$@" 324 add_ldflags "$@" 325} 326 327check_asm_align() { 328 log check_asm_align "$@" 329 cat >${TMP_ASM} <<EOF 330section .rodata 331align 16 332EOF 333 log_file ${TMP_ASM} 334 check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM} 335 readelf -WS ${TMP_O} >${TMP_X} 336 log_file ${TMP_X} 337 if ! grep -q '\.rodata .* 16$' ${TMP_X}; then 338 die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)" 339 fi 340} 341 342write_common_config_banner() { 343 echo '# This file automatically generated by configure. Do not edit!' > config.mk 344 echo "TOOLCHAIN := ${toolchain}" >> config.mk 345 346 case ${toolchain} in 347 *-linux-rvct) 348 echo "ALT_LIBC := ${alt_libc}" >> config.mk 349 ;; 350 esac 351} 352 353write_common_config_targets() { 354 for t in ${all_targets}; do 355 if enabled ${t}; then 356 if enabled universal || enabled child; then 357 fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}" 358 else 359 fwrite config.mk "ALL_TARGETS += ${t}" 360 fi 361 fi 362 true; 363 done 364true 365} 366 367write_common_target_config_mk() { 368 local CC=${CC} 369 enabled ccache && CC="ccache ${CC}" 370 371 cat > $1 << EOF 372# This file automatically generated by configure. Do not edit! 373SRC_PATH="$source_path" 374SRC_PATH_BARE=$source_path 375BUILD_PFX=${BUILD_PFX} 376TOOLCHAIN=${toolchain} 377ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl} 378 379CC=${CC} 380AR=${AR} 381LD=${LD} 382AS=${AS} 383STRIP=${STRIP} 384NM=${NM} 385 386CFLAGS = ${CFLAGS} 387ARFLAGS = -rus\$(if \$(quiet),c,v) 388LDFLAGS = ${LDFLAGS} 389ASFLAGS = ${ASFLAGS} 390extralibs = ${extralibs} 391AS_SFX = ${AS_SFX:-.asm} 392EOF 393 394 if enabled rvct; then cat >> $1 << EOF 395fmt_deps = sed -e 's;^__image.axf;\$(dir \$@)\$(notdir \$<).o \$@;' #hide 396EOF 397 else cat >> $1 << EOF 398fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\$(dir \$@)\1\$(suffix \$<).o \$@;' 399EOF 400 fi 401 402 print_config_mk ARCH "${1}" ${ARCH_LIST} 403 print_config_mk HAVE "${1}" ${HAVE_LIST} 404 print_config_mk CONFIG "${1}" ${CONFIG_LIST} 405 print_config_mk HAVE "${1}" gnu_strip 406 407 enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}" 408 409} 410 411 412write_common_target_config_h() { 413 cat > ${TMP_H} << EOF 414/* This file automatically generated by configure. Do not edit! */ 415#define RESTRICT ${RESTRICT} 416EOF 417 print_config_h ARCH "${TMP_H}" ${ARCH_LIST} 418 print_config_h HAVE "${TMP_H}" ${HAVE_LIST} 419 print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST} 420 mkdir -p `dirname "$1"` 421 cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1" 422} 423 424process_common_cmdline() { 425 for opt in "$@"; do 426 optval="${opt#*=}" 427 case "$opt" in 428 --child) enable child 429 ;; 430 --log*) 431 logging="$optval" 432 if ! disabled logging ; then 433 enabled logging || logfile="$logging" 434 else 435 logfile=/dev/null 436 fi 437 ;; 438 --target=*) toolchain="${toolchain:-${optval}}" 439 ;; 440 --force-target=*) toolchain="${toolchain:-${optval}}"; enable force_toolchain 441 ;; 442 --cpu) 443 ;; 444 --cpu=*) tune_cpu="$optval" 445 ;; 446 --extra-cflags=*) 447 extra_cflags="${optval}" 448 ;; 449 --enable-?*|--disable-?*) 450 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` 451 echo "${CMDLINE_SELECT} ${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null || die_unknown $opt 452 $action $option 453 ;; 454 --force-enable-?*|--force-disable-?*) 455 eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'` 456 $action $option 457 ;; 458 --libc=*) 459 [ -d "${optval}" ] || die "Not a directory: ${optval}" 460 disable builtin_libc 461 alt_libc="${optval}" 462 ;; 463 --as=*) 464 [ "${optval}" = yasm -o "${optval}" = nasm -o "${optval}" = auto ] \ 465 || die "Must be yasm, nasm or auto: ${optval}" 466 alt_as="${optval}" 467 ;; 468 --prefix=*) 469 prefix="${optval}" 470 ;; 471 --libdir=*) 472 libdir="${optval}" 473 ;; 474 --libc|--as|--prefix|--libdir) 475 die "Option ${opt} requires argument" 476 ;; 477 --help|-h) show_help 478 ;; 479 *) die_unknown $opt 480 ;; 481 esac 482 done 483} 484 485process_cmdline() { 486 for opt do 487 optval="${opt#*=}" 488 case "$opt" in 489 *) process_common_cmdline $opt 490 ;; 491 esac 492 done 493} 494 495 496post_process_common_cmdline() { 497 prefix="${prefix:-/usr/local}" 498 prefix="${prefix%/}" 499 libdir="${libdir:-${prefix}/lib}" 500 libdir="${libdir%/}" 501 if [ "${libdir#${prefix}}" = "${libdir}" ]; then 502 die "Libdir ${libdir} must be a subdirectory of ${prefix}" 503 fi 504} 505 506 507post_process_cmdline() { 508 true; 509} 510 511setup_gnu_toolchain() { 512 CC=${CC:-${CROSS}gcc} 513 AR=${AR:-${CROSS}ar} 514 LD=${LD:-${CROSS}${link_with_cc:-ld}} 515 AS=${AS:-${CROSS}as} 516 STRIP=${STRIP:-${CROSS}strip} 517 NM=${NM:-${CROSS}nm} 518 AS_SFX=.s 519} 520 521process_common_toolchain() { 522 if [ -z "$toolchain" ]; then 523 gcctarget="$(gcc -dumpmachine 2> /dev/null)" 524 525 # detect tgt_isa 526 case "$gcctarget" in 527 *x86_64*|*amd64*) 528 tgt_isa=x86_64 529 ;; 530 *i[3456]86*) 531 tgt_isa=x86 532 ;; 533 *powerpc64*) 534 tgt_isa=ppc64 535 ;; 536 *powerpc*) 537 tgt_isa=ppc32 538 ;; 539 *sparc*) 540 tgt_isa=sparc 541 ;; 542 esac 543 544 # detect tgt_os 545 case "$gcctarget" in 546 *darwin8*) 547 tgt_isa=universal 548 tgt_os=darwin8 549 ;; 550 *darwin9*) 551 tgt_isa=universal 552 tgt_os=darwin9 553 ;; 554 *darwin10*) 555 tgt_isa=x86_64 556 tgt_os=darwin10 557 ;; 558 *mingw32*|*cygwin*) 559 [ -z "$tgt_isa" ] && tgt_isa=x86 560 tgt_os=win32 561 ;; 562 *linux*|*bsd*) 563 tgt_os=linux 564 ;; 565 *solaris2.10) 566 tgt_os=solaris 567 ;; 568 esac 569 570 if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then 571 toolchain=${tgt_isa}-${tgt_os}-gcc 572 fi 573 fi 574 575 toolchain=${toolchain:-generic-gnu} 576 577 is_in ${toolchain} ${all_platforms} || enabled force_toolchain \ 578 || die "Unrecognized toolchain '${toolchain}'" 579 580 enabled child || log_echo "Configuring for target '${toolchain}'" 581 582 # 583 # Set up toolchain variables 584 # 585 tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}') 586 tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}') 587 tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}') 588 589 # Mark the specific ISA requested as enabled 590 soft_enable ${tgt_isa} 591 enable ${tgt_os} 592 enable ${tgt_cc} 593 594 # Enable the architecture family 595 case ${tgt_isa} in 596 arm*|iwmmxt*) enable arm;; 597 mips*) enable mips;; 598 esac 599 600 # PIC is probably what we want when building shared libs 601 enabled shared && soft_enable pic 602 603 # Handle darwin variants 604 case ${toolchain} in 605 *-darwin8-*) 606 add_cflags "-isysroot /Developer/SDKs/MacOSX10.4u.sdk" 607 add_cflags "-mmacosx-version-min=10.4" 608 add_ldflags "-isysroot /Developer/SDKs/MacOSX10.4u.sdk" 609 add_ldflags "-mmacosx-version-min=10.4" 610 ;; 611 *-darwin9-*) 612 add_cflags "-isysroot /Developer/SDKs/MacOSX10.5.sdk" 613 add_cflags "-mmacosx-version-min=10.5" 614 add_ldflags "-isysroot /Developer/SDKs/MacOSX10.5.sdk" 615 add_ldflags "-mmacosx-version-min=10.5" 616 ;; 617 *-darwin10-*) 618 add_cflags "-isysroot /Developer/SDKs/MacOSX10.6.sdk" 619 add_cflags "-mmacosx-version-min=10.6" 620 add_ldflags "-isysroot /Developer/SDKs/MacOSX10.6.sdk" 621 add_ldflags "-mmacosx-version-min=10.6" 622 ;; 623 esac 624 625 # Handle Solaris variants. Solaris 10 needs -lposix4 626 case ${toolchain} in 627 sparc-solaris-*) 628 add_extralibs -lposix4 629 add_cflags "-DMUST_BE_ALIGNED" 630 ;; 631 *-solaris-*) 632 add_extralibs -lposix4 633 ;; 634 esac 635 636 # Process ARM architecture variants 637 case ${toolchain} in 638 arm*|iwmmxt*) 639 # on arm, isa versions are supersets 640 enabled armv7a && soft_enable armv7 ### DEBUG 641 enabled armv7 && soft_enable armv6 642 enabled armv6 && soft_enable armv5te 643 enabled armv6 && soft_enable fast_unaligned 644 enabled iwmmxt2 && soft_enable iwmmxt 645 enabled iwmmxt && soft_enable armv5te 646 647 asm_conversion_cmd="cat" 648 649 case ${tgt_cc} in 650 gcc) 651 if enabled iwmmxt || enabled iwmmxt2 652 then 653 CROSS=${CROSS:-arm-iwmmxt-linux-gnueabi-} 654 elif enabled symbian; then 655 CROSS=${CROSS:-arm-none-symbianelf-} 656 else 657 CROSS=${CROSS:-arm-none-linux-gnueabi-} 658 fi 659 link_with_cc=gcc 660 setup_gnu_toolchain 661 arch_int=${tgt_isa##armv} 662 arch_int=${arch_int%%te} 663 check_add_asflags --defsym ARCHITECTURE=${arch_int} 664 tune_cflags="-mtune=" 665 if enabled iwmmxt || enabled iwmmxt2 666 then 667 check_add_asflags -mcpu=${tgt_isa} 668 elif enabled armv7 669 then 670 check_add_cflags -march=armv7-a -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp #-ftree-vectorize 671 check_add_asflags -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp #-march=armv7-a 672 else 673 check_add_cflags -march=${tgt_isa} 674 check_add_asflags -march=${tgt_isa} 675 fi 676 enabled debug && add_asflags -g 677 asm_conversion_cmd="${source_path}/build/make/ads2gas.pl" 678 ;; 679 rvct) 680 CC=armcc 681 AR=armar 682 AS=armasm 683 LD=${source_path}/build/make/armlink_adapter.sh 684 STRIP=arm-none-linux-gnueabi-strip 685 NM=arm-none-linux-gnueabi-nm 686 tune_cflags="--cpu=" 687 tune_asflags="--cpu=" 688 if [ -z "${tune_cpu}" ]; then 689 if enabled armv7 690 then 691 check_add_cflags --cpu=Cortex-A8 --fpu=softvfp+vfpv3 692 check_add_asflags --cpu=Cortex-A8 --fpu=none 693 else 694 check_add_cflags --cpu=${tgt_isa##armv} 695 check_add_asflags --cpu=${tgt_isa##armv} 696 fi 697 fi 698 arch_int=${tgt_isa##armv} 699 arch_int=${arch_int%%te} 700 check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\"" 701 enabled debug && add_asflags -g 702 add_cflags --gnu 703 add_cflags --enum_is_int 704 add_cflags --wchar32 705 ;; 706 esac 707 708 case ${tgt_os} in 709 none*) 710 disable multithread 711 disable os_support 712 ;; 713 darwin*) 714 SDK_PATH=/Developer/Platforms/iPhoneOS.platform/Developer 715 TOOLCHAIN_PATH=${SDK_PATH}/usr/bin 716 CC=${TOOLCHAIN_PATH}/gcc 717 AR=${TOOLCHAIN_PATH}/ar 718 LD=${TOOLCHAIN_PATH}/arm-apple-darwin10-gcc-4.2.1 719 AS=${TOOLCHAIN_PATH}/as 720 STRIP=${TOOLCHAIN_PATH}/strip 721 NM=${TOOLCHAIN_PATH}/nm 722 AS_SFX=.s 723 724 # ASFLAGS is written here instead of using check_add_asflags 725 # because we need to overwrite all of ASFLAGS and purge the 726 # options that were put in above 727 ASFLAGS="-version -arch ${tgt_isa} -g" 728 729 add_cflags -arch ${tgt_isa} 730 add_ldflags -arch_only ${tgt_isa} 731 732 add_cflags "-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk" 733 734 # This should be overridable 735 alt_libc=${SDK_PATH}/SDKs/iPhoneOS4.2.sdk 736 737 # Add the paths for the alternate libc 738# for d in usr/include usr/include/gcc/darwin/4.0/; do 739 for d in usr/include usr/include/gcc/darwin/4.0/ usr/lib/gcc/arm-apple-darwin10/4.2.1/include/; do 740 try_dir="${alt_libc}/${d}" 741 [ -d "${try_dir}" ] && add_cflags -I"${try_dir}" 742 done 743 744 for d in lib usr/lib; do 745 try_dir="${alt_libc}/${d}" 746 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}" 747 done 748 749 asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl" 750 ;; 751 752 linux*) 753 enable linux 754 if enabled rvct; then 755 # Compiling with RVCT requires an alternate libc (glibc) when 756 # targetting linux. 757 disabled builtin_libc \ 758 || die "Must supply --libc when targetting *-linux-rvct" 759 760 # Set up compiler 761 add_cflags --library_interface=aeabi_glibc 762 add_cflags --no_hide_all 763 add_cflags --dwarf2 764 765 # Set up linker 766 add_ldflags --sysv --no_startup --no_ref_cpp_init 767 add_ldflags --entry=_start 768 add_ldflags --keep '"*(.init)"' --keep '"*(.fini)"' 769 add_ldflags --keep '"*(.init_array)"' --keep '"*(.fini_array)"' 770 add_ldflags --dynamiclinker=/lib/ld-linux.so.3 771 add_extralibs libc.so.6 -lc_nonshared crt1.o crti.o crtn.o 772 773 # Add the paths for the alternate libc 774 for d in usr/include; do 775 try_dir="${alt_libc}/${d}" 776 [ -d "${try_dir}" ] && add_cflags -J"${try_dir}" 777 done 778 add_cflags -J"${RVCT31INC}" 779 for d in lib usr/lib; do 780 try_dir="${alt_libc}/${d}" 781 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}" 782 done 783 784 785 # glibc has some struct members named __align, which is a 786 # storage modifier in RVCT. If we need to use this modifier, 787 # we'll have to #undef it in our code. Note that this must 788 # happen AFTER all libc inclues. 789 add_cflags -D__align=x_align_x 790 fi 791 ;; 792 793 symbian*) 794 enable symbian 795 # Add the paths for the alternate libc 796 for d in include/libc; do 797 try_dir="${alt_libc}/${d}" 798 [ -d "${try_dir}" ] && add_cflags -I"${try_dir}" 799 done 800 for d in release/armv5/urel; do 801 try_dir="${alt_libc}/${d}" 802 [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}" 803 done 804 add_cflags -DIMPORT_C= 805 806 esac 807 ;; 808 mips*) 809 CROSS=${CROSS:-mipsel-linux-uclibc-} 810 link_with_cc=gcc 811 setup_gnu_toolchain 812 tune_cflags="-mtune=" 813 check_add_cflags -march=${tgt_isa} 814 check_add_asflags -march=${tgt_isa} 815 check_add_asflags -KPIC 816 ;; 817 ppc*) 818 enable ppc 819 bits=${tgt_isa##ppc} 820 link_with_cc=gcc 821 setup_gnu_toolchain 822 add_asflags -force_cpusubtype_ALL -I"\$(dir \$<)darwin" 823 soft_enable altivec 824 enabled altivec && add_cflags -maltivec 825 826 case "$tgt_os" in 827 linux*) 828 add_asflags -maltivec -mregnames -I"\$(dir \$<)linux" 829 ;; 830 darwin*) 831 darwin_arch="-arch ppc" 832 enabled ppc64 && darwin_arch="${darwin_arch}64" 833 add_cflags ${darwin_arch} -m${bits} -fasm-blocks 834 add_asflags ${darwin_arch} -force_cpusubtype_ALL -I"\$(dir \$<)darwin" 835 add_ldflags ${darwin_arch} -m${bits} 836 enabled altivec && add_cflags -faltivec 837 ;; 838 esac 839 ;; 840 x86*) 841 bits=32 842 enabled x86_64 && bits=64 843 soft_enable runtime_cpu_detect 844 soft_enable mmx 845 soft_enable sse 846 soft_enable sse2 847 soft_enable sse3 848 soft_enable ssse3 849 soft_enable sse4_1 850 851 case ${tgt_os} in 852 win*) 853 enabled gcc && add_cflags -fno-common 854 ;; 855 solaris*) 856 CC=${CC:-${CROSS}gcc} 857 LD=${LD:-${CROSS}gcc} 858 CROSS=${CROSS:-g} 859 ;; 860 esac 861 862 AS="${alt_as:-${AS:-auto}}" 863 case ${tgt_cc} in 864 icc*) 865 CC=${CC:-icc} 866 LD=${LD:-icc} 867 setup_gnu_toolchain 868 add_cflags -use-msasm -use-asm 869 add_ldflags -i-static 870 enabled x86_64 && add_cflags -ipo -no-prec-div -static -xSSE2 -axSSE2 871 enabled x86_64 && AR=xiar 872 case ${tune_cpu} in 873 atom*) 874 tune_cflags="-x" 875 tune_cpu="SSE3_ATOM" 876 ;; 877 *) 878 tune_cflags="-march=" 879 ;; 880 esac 881 ;; 882 gcc*) 883 add_cflags -m${bits} 884 add_ldflags -m${bits} 885 link_with_cc=gcc 886 tune_cflags="-march=" 887 setup_gnu_toolchain 888 ;; 889 esac 890 891 case "${AS}" in 892 auto|"") 893 which nasm >/dev/null 2>&1 && AS=nasm 894 which yasm >/dev/null 2>&1 && AS=yasm 895 [ "${AS}" = auto -o -z "${AS}" ] \ 896 && die "Neither yasm nor nasm have been found" 897 ;; 898 esac 899 log_echo " using $AS" 900 [ "${AS##*/}" = nasm ] && add_asflags -Ox 901 AS_SFX=.asm 902 case ${tgt_os} in 903 win*) 904 add_asflags -f win${bits} 905 enabled debug && add_asflags -g cv8 906 ;; 907 linux*|solaris*) 908 add_asflags -f elf${bits} 909 enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2 910 enabled debug && [ "${AS}" = nasm ] && add_asflags -g 911 [ "${AS##*/}" = nasm ] && check_asm_align 912 ;; 913 darwin*) 914 add_asflags -f macho${bits} 915 enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64" 916 add_cflags ${darwin_arch} 917 add_ldflags ${darwin_arch} 918 # -mdynamic-no-pic is still a bit of voodoo -- it was required at 919 # one time, but does not seem to be now, and it breaks some of the 920 # code that still relies on inline assembly. 921 # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic 922 enabled icc && ! enabled pic && add_cflags -fno-pic 923 ;; 924 *) log "Warning: Unknown os $tgt_os while setting up $AS flags" 925 ;; 926 esac 927 ;; 928 universal*|*-gcc|generic-gnu) 929 link_with_cc=gcc 930 enable gcc 931 setup_gnu_toolchain 932 ;; 933 esac 934 935 # Try to enable CPU specific tuning 936 if [ -n "${tune_cpu}" ]; then 937 if [ -n "${tune_cflags}" ]; then 938 check_add_cflags ${tune_cflags}${tune_cpu} || \ 939 die "Requested CPU '${tune_cpu}' not supported by compiler" 940 fi 941 if [ -n "${tune_asflags}" ]; then 942 check_add_asflags ${tune_asflags}${tune_cpu} || \ 943 die "Requested CPU '${tune_cpu}' not supported by assembler" 944 fi 945 if [ -z "${tune_cflags}${tune_asflags}" ]; then 946 log_echo "Warning: CPU tuning not supported by this toolchain" 947 fi 948 fi 949 950 enabled debug && check_add_cflags -g && check_add_ldflags -g 951 enabled gprof && check_add_cflags -pg && check_add_ldflags -pg 952 enabled gcov && 953 check_add_cflags -fprofile-arcs -ftest-coverage && 954 check_add_ldflags -fprofile-arcs -ftest-coverage 955 if enabled optimizations; then 956 enabled rvct && check_add_cflags -Otime 957 enabled small && check_add_cflags -O2 || check_add_cflags -O3 958 fi 959 960 # Position Independent Code (PIC) support, for building relocatable 961 # shared objects 962 enabled gcc && enabled pic && check_add_cflags -fPIC 963 964 # Check for strip utility variant 965 ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable gnu_strip 966 967 # Try to determine target endianness 968 check_cc <<EOF 969 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E'; 970EOF 971 [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' | 972 grep '4f *32 *42 *45' >/dev/null 2>&1 && enable big_endian 973 974 # Almost every platform uses pthreads. 975 if enabled multithread; then 976 case ${toolchain} in 977 *-win*);; 978 *) check_header pthread.h && add_extralibs -lpthread 979 esac 980 fi 981 982 # glibc needs these 983 if enabled linux; then 984 add_cflags -D_LARGEFILE_SOURCE 985 add_cflags -D_FILE_OFFSET_BITS=64 986 fi 987 988 # append any user defined extra cflags 989 if [ -n "${extra_cflags}" ] ; then 990 check_add_cflags ${extra_cflags} || \ 991 die "Requested extra CFLAGS '${extra_cflags}' not supported by compiler" 992 fi 993} 994 995process_toolchain() { 996 process_common_toolchain 997} 998 999print_config_mk() { 1000 local prefix=$1 1001 local makefile=$2 1002 shift 2 1003 for cfg; do 1004 upname="`toupper $cfg`" 1005 if enabled $cfg; then 1006 echo "${prefix}_${upname}=yes" >> $makefile 1007 fi 1008 done 1009} 1010 1011print_config_h() { 1012 local prefix=$1 1013 local header=$2 1014 shift 2 1015 for cfg; do 1016 upname="`toupper $cfg`" 1017 if enabled $cfg; then 1018 echo "#define ${prefix}_${upname} 1" >> $header 1019 else 1020 echo "#define ${prefix}_${upname} 0" >> $header 1021 fi 1022 done 1023} 1024 1025process_targets() { 1026 true; 1027} 1028 1029process_detect() { 1030 true; 1031} 1032 1033enable logging 1034logfile="config.err" 1035self=$0 1036process() { 1037 cmdline_args="$@" 1038 process_cmdline "$@" 1039 if enabled child; then 1040 echo "# ${self} $@" >> ${logfile} 1041 else 1042 echo "# ${self} $@" > ${logfile} 1043 fi 1044 post_process_common_cmdline 1045 post_process_cmdline 1046 process_toolchain 1047 process_detect 1048 process_targets 1049 1050 OOT_INSTALLS="${OOT_INSTALLS}" 1051 if enabled source_path_used; then 1052 # Prepare the PWD for building. 1053 for f in ${OOT_INSTALLS}; do 1054 install -D ${source_path}/$f $f 1055 done 1056 fi 1057 cp ${source_path}/build/make/Makefile . 1058 1059 clean_temp_files 1060 true 1061} 1062