Changeset 530f2de in mainline
- Timestamp:
- 2018-03-15T20:50:54Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 973be387
- Parents:
- 67f11a0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/toolchain.sh
r67f11a0 r530f2de 29 29 # 30 30 31 GMP_MAIN=<<EOF32 #define GCC_GMP_VERSION_NUM(a, b, c) \33 (((a) << 16L) | ((b) << 8) | (c))34 35 #define GCC_GMP_VERSION \36 GCC_GMP_VERSION_NUM(__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL)37 38 #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4, 3, 2)39 choke me40 #endif41 EOF42 43 MPFR_MAIN=<<EOF44 #if MPFR_VERSION < MPFR_VERSION_NUM(2, 4, 2)45 choke me46 #endif47 EOF48 49 MPC_MAIN=<<EOF50 #if MPC_VERSION < MPC_VERSION_NUM(0, 8, 1)51 choke me52 #endif53 EOF54 55 ISL_MAIN=<<EOF56 isl_ctx_get_max_operations (isl_ctx_alloc ());57 EOF58 59 31 BINUTILS_VERSION="2.28" 60 32 BINUTILS_RELEASE="" … … 64 36 GDB_VERSION="7.12.1" 65 37 ## GDB_PATCHES="toolchain-gdb-7.6.1.patch" 66 ISL_VERSION="0.18"67 38 68 39 BASEDIR="`pwd`" … … 71 42 GCC="gcc-${GCC_VERSION}.tar.bz2" 72 43 GDB="gdb-${GDB_VERSION}.tar.gz" 73 ISL="isl-${ISL_VERSION}.tar.bz2"74 44 75 45 REAL_INSTALL=true 76 46 USE_HELENOS_TARGET=false 77 BUILD_ISL=false78 79 #80 # Check if the library described in the argument81 # exists and has acceptable version.82 #83 check_dependency() {84 DEPENDENCY="$1"85 HEADER="$2"86 BODY="$3"87 88 FNAME="/tmp/conftest-$$"89 90 echo "#include ${HEADER}" > "${FNAME}.c"91 echo >> "${FNAME}.c"92 echo "int main()" >> "${FNAME}.c"93 echo "{" >> "${FNAME}.c"94 echo "${BODY}" >> "${FNAME}.c"95 echo " return 0;" >> "${FNAME}.c"96 echo "}" >> "${FNAME}.c"97 98 cc $CFLAGS -c -o "${FNAME}.o" "${FNAME}.c" 2> "${FNAME}.log"99 RC="$?"100 101 if [ "$RC" -ne "0" ] ; then102 if [ "${DEPENDENCY}" == "isl" ]; then103 BUILD_ISL=true104 105 echo " isl not found. Will be downloaded and built with GCC."106 else107 echo " ${DEPENDENCY} not found, too old or compiler error."108 echo " Please recheck manually the source file \"${FNAME}.c\"."109 echo " The compilation of the toolchain is probably going to fail,"110 echo " you have been warned."111 echo112 echo " ===== Compiler output ====="113 cat "${FNAME}.log"114 echo " ==========================="115 echo116 fi117 else118 echo " ${DEPENDENCY} found"119 rm -f "${FNAME}.log" "${FNAME}.o" "${FNAME}.c"120 fi121 }122 123 check_dependecies() {124 echo ">>> Basic dependency check"125 check_dependency "GMP" "<gmp.h>" "${GMP_MAIN}"126 check_dependency "MPFR" "<mpfr.h>" "${MPFR_MAIN}"127 check_dependency "MPC" "<mpc.h>" "${MPC_MAIN}"128 check_dependency "isl" "<isl/ctx.h>" "${ISL_MAIN}"129 echo130 }131 47 132 48 check_error() { … … 230 146 echo " - gettext, zlib, Texinfo, libelf, libgomp" 231 147 echo " - GNU Make, Coreutils, Sharutils, tar" 232 echo " - GNU Multiple Precision Library (GMP)"233 echo " - MPFR"234 echo " - MPC"235 echo " - integer point manipulation library (isl)"236 148 echo " - native C and C++ compiler, assembler and linker" 237 149 echo " - native C and C++ standard library with headers" … … 355 267 prepare() { 356 268 show_dependencies 357 check_dependecies358 269 show_countdown 10 270 271 mkdir -p "${BASEDIR}/downloads" 272 cd "${BASEDIR}/downloads" 273 check_error $? "Change directory failed." 359 274 360 275 BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/" 361 276 GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/" 362 277 GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/" 363 ISL_SOURCE="http://isl.gforge.inria.fr/" 278 279 echo ">>> Downloading tarballs" 364 280 365 281 download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "9e8340c96626b469a603c15c9d843727" … … 367 283 download_fetch "${GDB_SOURCE}" "${GDB}" "06c8f40521ed65fe36ebc2be29b56942" 368 284 369 if $BUILD_ISL ; then370 download_fetch "${ISL_SOURCE}" "${ISL}" "11436d6b205e516635b666090b94ab32"371 fi372 }373 374 set_target_from_platform() {375 case "$1" in376 "amd64")377 LINUX_TARGET="amd64-unknown-elf"378 HELENOS_TARGET="amd64-helenos"379 ;;380 "arm32")381 LINUX_TARGET="arm-linux-gnueabi"382 HELENOS_TARGET="arm-helenos-gnueabi"383 ;;384 "ia32")385 LINUX_TARGET="i686-pc-linux-gnu"386 HELENOS_TARGET="i686-pc-helenos"387 ;;388 "ia64")389 LINUX_TARGET="ia64-pc-linux-gnu"390 HELENOS_TARGET="ia64-pc-helenos"391 ;;392 "mips32")393 LINUX_TARGET="mipsel-linux-gnu"394 HELENOS_TARGET="mipsel-helenos"395 ;;396 "mips32eb")397 LINUX_TARGET="mips-linux-gnu"398 HELENOS_TARGET="mips-helenos"399 ;;400 "mips64")401 LINUX_TARGET="mips64el-linux-gnu"402 HELENOS_TARGET="mips64el-helenos"403 ;;404 "ppc32")405 LINUX_TARGET="ppc-linux-gnu"406 HELENOS_TARGET="ppc-helenos"407 ;;408 "ppc64")409 LINUX_TARGET="ppc64-linux-gnu"410 HELENOS_TARGET="ppc64-helenos"411 ;;412 "riscv64")413 LINUX_TARGET="riscv64-unknown-linux-gnu"414 HELENOS_TARGET="riscv64-helenos"415 ;;416 "sparc64")417 LINUX_TARGET="sparc64-linux-gnu"418 HELENOS_TARGET="sparc64-helenos"419 ;;420 *)421 check_error 1 "No target known for $1."422 ;;423 esac424 }425 426 build_target() {427 PLATFORM="$1"428 429 # This sets the *_TARGET variables430 set_target_from_platform "$PLATFORM"431 if $USE_HELENOS_TARGET ; then432 TARGET="$HELENOS_TARGET"433 else434 TARGET="$LINUX_TARGET"435 fi436 437 WORKDIR="${BASEDIR}/${TARGET}"438 INSTALL_DIR="${WORKDIR}/PKG"439 BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"440 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"441 ISLDIR="${WORKDIR}/isl-${ISL_VERSION}"442 OBJDIR="${WORKDIR}/gcc-obj"443 GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"444 445 if [ -z "${CROSS_PREFIX}" ] ; then446 CROSS_PREFIX="/usr/local/cross"447 fi448 449 PREFIX="${CROSS_PREFIX}/${TARGET}"450 451 echo ">>> Downloading tarballs"452 source_check "${BASEDIR}/${BINUTILS}"453 source_check "${BASEDIR}/${GCC}"454 source_check "${BASEDIR}/${GDB}"455 if $BUILD_ISL ; then456 source_check "${BASEDIR}/${ISL}"457 fi458 459 echo ">>> Removing previous content"460 cleanup_dir "${WORKDIR}"461 462 create_dir "${OBJDIR}" "GCC object directory"463 464 check_dirs "${PREFIX}" "${WORKDIR}"465 466 285 echo ">>> Unpacking tarballs" 467 286 cd "${WORKDIR}" 468 287 check_error $? "Change directory failed." 469 288 470 unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils" 471 unpack_tarball "${BASEDIR}/${GCC}" "GCC" 472 unpack_tarball "${BASEDIR}/${GDB}" "GDB" 473 if $BUILD_ISL ; then 474 unpack_tarball "${BASEDIR}/${ISL}" "isl" 475 mv "${ISLDIR}" "${GCCDIR}"/isl 476 fi 289 unpack_tarball "${BASEDIR}/downloads/${BINUTILS}" "binutils" 290 unpack_tarball "${BASEDIR}/downloads/${GCC}" "GCC" 291 unpack_tarball "${BASEDIR}/downloads/${GDB}" "GDB" 477 292 478 293 echo ">>> Applying patches" … … 487 302 done 488 303 304 echo ">>> Downloading GCC prerequisites" 305 cd "gcc-${GCC_VERSION}" 306 ./contrib/download_prerequisites 307 cd .. 308 } 309 310 set_target_from_platform() { 311 case "$1" in 312 "amd64") 313 LINUX_TARGET="amd64-unknown-elf" 314 HELENOS_TARGET="amd64-helenos" 315 ;; 316 "arm32") 317 LINUX_TARGET="arm-linux-gnueabi" 318 HELENOS_TARGET="arm-helenos-gnueabi" 319 ;; 320 "ia32") 321 LINUX_TARGET="i686-pc-linux-gnu" 322 HELENOS_TARGET="i686-pc-helenos" 323 ;; 324 "ia64") 325 LINUX_TARGET="ia64-pc-linux-gnu" 326 HELENOS_TARGET="ia64-pc-helenos" 327 ;; 328 "mips32") 329 LINUX_TARGET="mipsel-linux-gnu" 330 HELENOS_TARGET="mipsel-helenos" 331 ;; 332 "mips32eb") 333 LINUX_TARGET="mips-linux-gnu" 334 HELENOS_TARGET="mips-helenos" 335 ;; 336 "mips64") 337 LINUX_TARGET="mips64el-linux-gnu" 338 HELENOS_TARGET="mips64el-helenos" 339 ;; 340 "ppc32") 341 LINUX_TARGET="ppc-linux-gnu" 342 HELENOS_TARGET="ppc-helenos" 343 ;; 344 "ppc64") 345 LINUX_TARGET="ppc64-linux-gnu" 346 HELENOS_TARGET="ppc64-helenos" 347 ;; 348 "riscv64") 349 LINUX_TARGET="riscv64-unknown-linux-gnu" 350 HELENOS_TARGET="riscv64-helenos" 351 ;; 352 "sparc64") 353 LINUX_TARGET="sparc64-linux-gnu" 354 HELENOS_TARGET="sparc64-helenos" 355 ;; 356 *) 357 check_error 1 "No target known for $1." 358 ;; 359 esac 360 } 361 362 build_target() { 363 PLATFORM="$1" 364 365 # This sets the *_TARGET variables 366 set_target_from_platform "$PLATFORM" 367 if $USE_HELENOS_TARGET ; then 368 TARGET="$HELENOS_TARGET" 369 else 370 TARGET="$LINUX_TARGET" 371 fi 372 373 WORKDIR="${BASEDIR}/${TARGET}" 374 INSTALL_DIR="${WORKDIR}/PKG" 375 BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}" 376 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" 377 GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}" 378 379 if [ -z "${CROSS_PREFIX}" ] ; then 380 CROSS_PREFIX="/usr/local/cross" 381 fi 382 383 PREFIX="${CROSS_PREFIX}/${TARGET}" 384 385 echo ">>> Removing previous content" 386 cleanup_dir "${WORKDIR}" 387 mkdir -p "${WORKDIR}" 388 check_dirs "${PREFIX}" "${WORKDIR}" 389 489 390 echo ">>> Processing binutils (${PLATFORM})" 391 mkdir -p "${BINUTILSDIR}" 490 392 cd "${BINUTILSDIR}" 491 393 check_error $? "Change directory failed." 492 394 493 395 change_title "binutils: configure (${PLATFORM})" 494 CFLAGS=-Wno-error ./configure\396 CFLAGS=-Wno-error "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \ 495 397 "--target=${TARGET}" \ 496 398 "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \ … … 509 411 510 412 echo ">>> Processing GCC (${PLATFORM})" 511 cd "${OBJDIR}" 413 mkdir -p "${GCCDIR}" 414 cd "${GCCDIR}" 512 415 check_error $? "Change directory failed." 513 416 514 417 change_title "GCC: configure (${PLATFORM})" 515 PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${ GCCDIR}/configure" \418 PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \ 516 419 "--target=${TARGET}" \ 517 420 "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \ … … 534 437 if [ "$PLATFORM" != "riscv64" ] ; then 535 438 echo ">>> Processing GDB (${PLATFORM})" 439 mkdir -p "${GDBDIR}" 536 440 cd "${GDBDIR}" 537 441 check_error $? "Change directory failed." 538 442 539 443 change_title "GDB: configure (${PLATFORM})" 540 PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./configure\444 PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \ 541 445 "--target=${TARGET}" \ 542 446 "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
Note:
See TracChangeset
for help on using the changeset viewer.