Changeset a35b458 in mainline for tools/toolchain.sh
- Timestamp:
- 2018-03-02T20:10:49Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/toolchain.sh
r3061bc1 ra35b458 85 85 HEADER="$2" 86 86 BODY="$3" 87 87 88 88 FNAME="/tmp/conftest-$$" 89 89 90 90 echo "#include ${HEADER}" > "${FNAME}.c" 91 91 echo >> "${FNAME}.c" … … 95 95 echo " return 0;" >> "${FNAME}.c" 96 96 echo "}" >> "${FNAME}.c" 97 97 98 98 cc $CFLAGS -c -o "${FNAME}.o" "${FNAME}.c" 2> "${FNAME}.log" 99 99 RC="$?" 100 100 101 101 if [ "$RC" -ne "0" ] ; then 102 102 if [ "${DEPENDENCY}" == "isl" ]; then 103 103 BUILD_ISL=true 104 104 105 105 echo " isl not found. Will be downloaded and built with GCC." 106 106 else … … 134 134 echo 135 135 echo "Script failed: $2" 136 136 137 137 exit 1 138 138 fi … … 142 142 FILE="$1" 143 143 SUM="$2" 144 144 145 145 COMPUTED="`md5sum "${FILE}" | cut -d' ' -f1`" 146 146 if [ "${SUM}" != "${COMPUTED}" ] ; then 147 147 echo 148 148 echo "Checksum of ${FILE} does not match." 149 149 150 150 exit 2 151 151 fi … … 193 193 echo "feature that is not fully supported." 194 194 echo 195 195 196 196 exit 3 197 197 } … … 203 203 show_countdown() { 204 204 TM="$1" 205 205 206 206 if [ "${TM}" -eq 0 ] ; then 207 207 echo 208 208 return 0 209 209 fi 210 210 211 211 echo -n "${TM} " 212 212 change_title "${TM}" 213 213 sleep 1 214 214 215 215 TM="`expr "${TM}" - 1`" 216 216 show_countdown "${TM}" … … 243 243 FILE="$2" 244 244 CHECKSUM="$3" 245 245 246 246 if [ ! -f "${FILE}" ] ; then 247 247 change_title "Downloading ${FILE}" 248 248 wget -c "${SOURCE}${FILE}" -O "${FILE}".part 249 249 check_error $? "Error downloading ${FILE}." 250 250 251 251 mv "${FILE}".part "${FILE}" 252 252 fi 253 253 254 254 check_md5 "${FILE}" "${CHECKSUM}" 255 255 } … … 257 257 source_check() { 258 258 FILE="$1" 259 259 260 260 if [ ! -f "${FILE}" ] ; then 261 261 echo 262 262 echo "File ${FILE} not found." 263 263 264 264 exit 4 265 265 fi … … 268 268 cleanup_dir() { 269 269 DIR="$1" 270 270 271 271 if [ -d "${DIR}" ] ; then 272 272 change_title "Removing ${DIR}" … … 279 279 DIR="$1" 280 280 DESC="$2" 281 281 282 282 change_title "Creating ${DESC}" 283 283 echo ">>> Creating ${DESC}" 284 284 285 285 mkdir -p "${DIR}" 286 286 test -d "${DIR}" … … 292 292 BASE="$2" 293 293 ORIGINAL="`pwd`" 294 294 295 295 mkdir -p "${OUTSIDE}" 296 296 297 297 cd "${OUTSIDE}" 298 298 check_error $? "Unable to change directory to ${OUTSIDE}." 299 299 ABS_OUTSIDE="`pwd`" 300 300 301 301 cd "${BASE}" 302 302 check_error $? "Unable to change directory to ${BASE}." 303 303 ABS_BASE="`pwd`" 304 304 305 305 cd "${ORIGINAL}" 306 306 check_error $? "Unable to change directory to ${ORIGINAL}." 307 307 308 308 BASE_LEN="${#ABS_BASE}" 309 309 OUTSIDE_TRIM="${ABS_OUTSIDE:0:${BASE_LEN}}" 310 310 311 311 if [ "${OUTSIDE_TRIM}" == "${ABS_BASE}" ] ; then 312 312 echo 313 313 echo "CROSS_PREFIX cannot reside within the working directory." 314 314 315 315 exit 5 316 316 fi … … 320 320 FILE="$1" 321 321 DESC="$2" 322 322 323 323 change_title "Unpacking ${DESC}" 324 324 echo " >>> Unpacking ${DESC}" 325 325 326 326 case "${FILE}" in 327 327 *.gz) … … 345 345 PATCH_STRIP="$2" 346 346 DESC="$3" 347 347 348 348 change_title "Patching ${DESC}" 349 349 echo " >>> Patching ${DESC} with ${PATCH_FILE}" 350 350 351 351 patch -t "-p${PATCH_STRIP}" <"$PATCH_FILE" 352 352 check_error $? "Error patching ${DESC}." … … 357 357 check_dependecies 358 358 show_countdown 10 359 359 360 360 BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/" 361 361 GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/" 362 362 GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/" 363 363 ISL_SOURCE="http://isl.gforge.inria.fr/" 364 364 365 365 download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "9e8340c96626b469a603c15c9d843727" 366 366 download_fetch "${GCC_SOURCE}" "${GCC}" "6bf56a2bca9dac9dbbf8e8d1036964a8" 367 367 download_fetch "${GDB_SOURCE}" "${GDB}" "06c8f40521ed65fe36ebc2be29b56942" 368 368 369 369 if $BUILD_ISL ; then 370 370 download_fetch "${ISL_SOURCE}" "${ISL}" "11436d6b205e516635b666090b94ab32" … … 426 426 build_target() { 427 427 PLATFORM="$1" 428 428 429 429 # This sets the *_TARGET variables 430 430 set_target_from_platform "$PLATFORM" … … 434 434 TARGET="$LINUX_TARGET" 435 435 fi 436 436 437 437 WORKDIR="${BASEDIR}/${TARGET}" 438 438 INSTALL_DIR="${WORKDIR}/PKG" … … 442 442 OBJDIR="${WORKDIR}/gcc-obj" 443 443 GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}" 444 444 445 445 if [ -z "${CROSS_PREFIX}" ] ; then 446 446 CROSS_PREFIX="/usr/local/cross" 447 447 fi 448 448 449 449 PREFIX="${CROSS_PREFIX}/${TARGET}" 450 450 451 451 echo ">>> Downloading tarballs" 452 452 source_check "${BASEDIR}/${BINUTILS}" … … 456 456 source_check "${BASEDIR}/${ISL}" 457 457 fi 458 458 459 459 echo ">>> Removing previous content" 460 460 cleanup_dir "${WORKDIR}" 461 461 462 462 create_dir "${OBJDIR}" "GCC object directory" 463 463 464 464 check_dirs "${PREFIX}" "${WORKDIR}" 465 465 466 466 echo ">>> Unpacking tarballs" 467 467 cd "${WORKDIR}" 468 468 check_error $? "Change directory failed." 469 469 470 470 unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils" 471 471 unpack_tarball "${BASEDIR}/${GCC}" "GCC" … … 475 475 mv "${ISLDIR}" "${GCCDIR}"/isl 476 476 fi 477 477 478 478 echo ">>> Applying patches" 479 479 for p in $BINUTILS_PATCHES ; do … … 486 486 patch_sources "${SRCDIR}/${p}" 0 "GDB" 487 487 done 488 488 489 489 echo ">>> Processing binutils (${PLATFORM})" 490 490 cd "${BINUTILSDIR}" 491 491 check_error $? "Change directory failed." 492 492 493 493 change_title "binutils: configure (${PLATFORM})" 494 494 CFLAGS=-Wno-error ./configure \ … … 498 498 --enable-deterministic-archives 499 499 check_error $? "Error configuring binutils." 500 500 501 501 change_title "binutils: make (${PLATFORM})" 502 502 make all 503 503 check_error $? "Error compiling binutils." 504 504 505 505 change_title "binutils: install (${PLATFORM})" 506 506 make install "DESTDIR=${INSTALL_DIR}" 507 507 check_error $? "Error installing binutils." 508 509 508 509 510 510 echo ">>> Processing GCC (${PLATFORM})" 511 511 cd "${OBJDIR}" 512 512 check_error $? "Change directory failed." 513 513 514 514 change_title "GCC: configure (${PLATFORM})" 515 515 PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${GCCDIR}/configure" \ … … 521 521 --disable-shared --enable-lto --disable-werror 522 522 check_error $? "Error configuring GCC." 523 523 524 524 change_title "GCC: make (${PLATFORM})" 525 525 PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc 526 526 check_error $? "Error compiling GCC." 527 527 528 528 change_title "GCC: install (${PLATFORM})" 529 529 PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}" 530 530 check_error $? "Error installing GCC." 531 532 531 532 533 533 # No GDB support for RISC-V so far 534 534 if [ "$PLATFORM" != "riscv64" ] ; then … … 536 536 cd "${GDBDIR}" 537 537 check_error $? "Change directory failed." 538 538 539 539 change_title "GDB: configure (${PLATFORM})" 540 540 PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./configure \ … … 543 543 --enable-werror=no --without-guile 544 544 check_error $? "Error configuring GDB." 545 545 546 546 change_title "GDB: make (${PLATFORM})" 547 547 PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all 548 548 check_error $? "Error compiling GDB." 549 549 550 550 change_title "GDB: make (${PLATFORM})" 551 551 PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install "DESTDIR=${INSTALL_DIR}" 552 552 check_error $? "Error installing GDB." 553 553 fi 554 554 555 555 # Symlink clang and lld to the install path. 556 556 CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`" 557 557 LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`" 558 558 559 559 ln -s $CLANG "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-clang" 560 560 ln -s $LLD "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-ld.lld" 561 561 562 562 if $REAL_INSTALL ; then 563 563 echo ">>> Moving to the destination directory." … … 566 566 mv "${INSTALL_DIR}/${PREFIX}" "${PREFIX}" 567 567 fi 568 568 569 569 cd "${BASEDIR}" 570 570 check_error $? "Change directory failed." 571 571 572 572 echo ">>> Cleaning up" 573 573 cleanup_dir "${WORKDIR}" 574 574 575 575 echo 576 576 echo ">>> Cross-compiler for ${TARGET} installed." … … 647 647 build_target "arm32" & 648 648 wait 649 649 650 650 build_target "ia32" & 651 651 build_target "ia64" & 652 652 wait 653 653 654 654 build_target "mips32" & 655 655 build_target "mips32eb" & 656 656 wait 657 657 658 658 build_target "mips64" & 659 659 build_target "ppc32" & 660 660 wait 661 661 662 662 build_target "riscv64" & 663 663 build_target "ppc64" & 664 664 wait 665 665 666 666 build_target "sparc64" & 667 667 wait
Note:
See TracChangeset
for help on using the changeset viewer.