Changeset f3a7b0d in mainline for tools/toolchain.sh
- Timestamp:
- 2021-04-20T18:21:55Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- de227aba
- Parents:
- 6186f9f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/toolchain.sh
r6186f9f rf3a7b0d 41 41 GCC_VERSION="8.2.0" 42 42 43 BASEDIR=" `pwd`"43 BASEDIR="$PWD" 44 44 SRCDIR="$(readlink -f $(dirname "$0"))" 45 45 46 SYSTEM_INSTALL=false 46 47 REAL_INSTALL=true 47 48 USE_HELENOS_TARGET=true … … 57 58 58 59 show_usage() { 59 echo " Cross-compiler toolchain build script"60 echo "HelenOS cross-compiler toolchain build script" 60 61 echo 61 62 echo "Syntax:" 62 echo " $0 [-- no-install] [--non-helenos-target] <platform>"63 echo " $0 --test-version [<platform>]"63 echo " $0 [--system-wide] [--no-install] [--non-helenos-target] <platform>" 64 echo " $0 [--system-wide] --test-version [<platform>]" 64 65 echo 65 66 echo "Possible target platforms are:" … … 79 80 echo " 2-way same as 'all', but 2-way parallel" 80 81 echo 81 echo "The toolchain is installed into directory specified by the" 82 echo "CROSS_PREFIX environment variable. If the variable is not" 83 echo "defined, /usr/local/cross/ is used as default." 84 echo 85 echo "If --no-install is present, the toolchain still uses the" 86 echo "CROSS_PREFIX as the target directory but the installation" 87 echo "copies the files into PKG/ subdirectory without affecting" 88 echo "the actual root file system. That is only useful if you do" 89 echo "not want to run the script under the super user." 90 echo 91 echo "The --non-helenos-target will build non-HelenOS-specific toolchain" 92 echo "(i.e. it will use *-linux-* triplet instead of *-helenos)." 82 echo "The toolchain target installation directory is determined by matching" 83 echo "the first of the following conditions:" 84 echo 85 echo " (1) If the \$CROSS_PREFIX environment variable is set, then it is" 86 echo " used as the target installation directory." 87 echo " (2) If the --system-wide option is used, then /opt/HelenOS/cross" 88 echo " is used as the target installation directory. This usually" 89 echo " requires running this script with super user privileges." 90 echo " (3) In other cases, \$XDG_DATA_HOME/HelenOS/cross is used as the" 91 echo " target installation directory. If the \$XDG_DATA_HOME environment" 92 echo " variable is not set, then the default value of \$HOME/.local/share" 93 echo " is assumed." 94 echo 95 echo "If the --no-install option is used, the toolchain still uses the" 96 echo "target installation directory as determined above, but the files" 97 echo "are actually copied into the PKG/ subdirectory during the installation" 98 echo "without affecting the actual target file system. This might be useful" 99 echo "when preparing a system-wide installation, but avoiding running this" 100 echo "script under the super user." 101 echo 102 echo "The --non-helenos-target option will build non-HelenOS-specific" 103 echo "toolchain (i.e. it will use *-linux-* triplet instead of *-helenos)." 93 104 echo "Using this toolchain for building HelenOS is not supported." 94 105 echo 106 echo "The --test-version mode tests the currently installed version of the" 107 echo "toolchain." 95 108 96 109 exit 3 97 110 } 98 111 112 set_cross_prefix() { 113 if [ -z "$CROSS_PREFIX" ] ; then 114 if $SYSTEM_INSTALL ; then 115 CROSS_PREFIX="/opt/HelenOS/cross" 116 else 117 if [ -z "$XDG_DATA_HOME" ] ; then 118 XDG_DATA_HOME="$HOME/.local/share" 119 fi 120 CROSS_PREFIX="$XDG_DATA_HOME/HelenOS/cross" 121 fi 122 fi 123 } 124 99 125 test_version() { 100 echo "Cross-compiler toolchain build script" 101 echo 102 echo "Start testing the version of the installed software" 103 echo 104 126 set_cross_prefix 127 128 echo "HelenOS cross-compiler toolchain build script" 129 echo 130 echo "Testing the version of the installed software in $CROSS_PREFIX" 131 echo 132 105 133 if [ -z "$1" ] || [ "$1" = "all" ] ; then 106 134 PLATFORMS='amd64 arm32 arm64 ia32 ia64 mips32 mips32eb ppc32 riscv64 sparc64' … … 108 136 PLATFORMS="$1" 109 137 fi 110 111 112 if [ -z "${CROSS_PREFIX}" ] ; then 113 CROSS_PREFIX="/usr/local/cross" 114 fi 115 116 for i in $PLATFORMS 117 do 118 PLATFORM="$i" 138 139 for PLATFORM in $PLATFORMS ; do 119 140 set_target_from_platform "$PLATFORM" 120 141 PREFIX="${CROSS_PREFIX}/bin/${HELENOS_TARGET}" … … 125 146 test_app_version "GDB" "gdb" "GNU gdb (.*)[[:space:]]\+\([.0-9]*\)" "$GDB_VERSION" 126 147 done 127 128 exit129 148 } 130 149 … … 135 154 INS_VERSION="$4" 136 155 137 138 156 APP="${PREFIX}-${APPNAME}" 139 157 if [ ! -e $APP ]; then … … 148 166 149 167 if [ "$INS_VERSION" = "$VERSION" ]; then 150 echo "+ $PKGNAME is up todate ($INS_VERSION)"168 echo "+ $PKGNAME is up-to-date ($INS_VERSION)" 151 169 else 152 170 echo "- $PKGNAME ($VERSION) is outdated ($INS_VERSION)" … … 155 173 } 156 174 157 158 159 175 change_title() { 160 176 printf "\e]0;$1\a" … … 178 194 179 195 show_dependencies() { 196 set_cross_prefix 197 198 echo "HelenOS cross-compiler toolchain build script" 199 echo 200 echo "Installing software to $CROSS_PREFIX" 201 echo 202 echo 180 203 echo "IMPORTANT NOTICE:" 181 204 echo … … 255 278 check_error $? "Change directory failed." 256 279 280 change_title "Downloading sources" 257 281 echo ">>> Downloading sources" 258 282 git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION" … … 265 289 git -C "gcc-$GCC_VERSION" pull 266 290 291 change_title "Downloading GCC prerequisites" 267 292 echo ">>> Downloading GCC prerequisites" 268 293 cd "gcc-${GCC_VERSION}" … … 325 350 GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}" 326 351 327 if [ -z "${CROSS_PREFIX}" ] ; then 328 CROSS_PREFIX="/usr/local/cross" 329 fi 352 # This sets the CROSS_PREFIX variable 353 set_cross_prefix 330 354 331 355 if [ -z "$JOBS" ] ; then 332 JOBS= `nproc`356 JOBS="`nproc`" 333 357 fi 334 358 … … 341 365 342 366 if $USE_HELENOS_TARGET ; then 367 change_title "Creating build sysroot" 343 368 echo ">>> Creating build sysroot" 344 369 mkdir -p "${WORKDIR}/sysroot/include" … … 355 380 check_error $? "Failed to create build sysroot." 356 381 fi 382 357 383 358 384 echo ">>> Processing binutils (${PLATFORM})" … … 416 442 PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libgcc -j$JOBS 417 443 check_error $? "Error compiling libgcc." 418 # TODO: needssome extra care419 # PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libatomic -j$JOBS420 # check_error $? "Error compiling libatomic."421 # PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libstdc++-v3 -j$JOBS422 # check_error $? "Error compiling libstdc++."444 # TODO: libatomic and libstdc++ need some extra care 445 # PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libatomic -j$JOBS 446 # check_error $? "Error compiling libatomic." 447 # PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libstdc++-v3 -j$JOBS 448 # check_error $? "Error compiling libstdc++." 423 449 fi 424 450 … … 427 453 if $USE_HELENOS_TARGET ; then 428 454 PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libgcc "DESTDIR=${INSTALL_DIR}" 429 # PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libatomic "DESTDIR=${INSTALL_DIR}"430 # PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libstdc++-v3 "DESTDIR=${INSTALL_DIR}"455 # PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libatomic "DESTDIR=${INSTALL_DIR}" 456 # PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libstdc++-v3 "DESTDIR=${INSTALL_DIR}" 431 457 fi 432 458 check_error $? "Error installing GCC." … … 463 489 if $REAL_INSTALL ; then 464 490 echo ">>> Moving to the destination directory." 465 echo cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*466 491 cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"* 467 492 fi … … 479 504 while [ "$#" -gt 1 ] ; do 480 505 case "$1" in 506 --system-wide) 507 SYSTEM_INSTALL=true 508 shift 509 ;; 481 510 --test-version) 482 511 test_version "$2" … … 504 533 --test-version) 505 534 test_version 535 exit 506 536 ;; 507 537 amd64|arm32|arm64|ia32|ia64|mips32|mips32eb|ppc32|riscv64|sparc64)
Note:
See TracChangeset
for help on using the changeset viewer.