[40c0483] | 1 | #!/bin/sh
|
---|
[ff211d2] | 2 |
|
---|
| 3 | #
|
---|
[04c3a21f] | 4 | # Copyright (c) 2009 Martin Decky
|
---|
| 5 | # All rights reserved.
|
---|
| 6 | #
|
---|
| 7 | # Redistribution and use in source and binary forms, with or without
|
---|
| 8 | # modification, are permitted provided that the following conditions
|
---|
| 9 | # are met:
|
---|
| 10 | #
|
---|
| 11 | # - Redistributions of source code must retain the above copyright
|
---|
| 12 | # notice, this list of conditions and the following disclaimer.
|
---|
| 13 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 14 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 15 | # documentation and/or other materials provided with the distribution.
|
---|
| 16 | # - The name of the author may not be used to endorse or promote products
|
---|
| 17 | # derived from this software without specific prior written permission.
|
---|
| 18 | #
|
---|
| 19 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 20 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 21 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 22 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 23 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 24 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 28 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
[ff211d2] | 29 | #
|
---|
| 30 |
|
---|
[232ec3a1] | 31 | BINUTILS_GDB_GIT="https://github.com/HelenOS/binutils-gdb.git"
|
---|
| 32 |
|
---|
[6ae5e3f] | 33 | BINUTILS_BRANCH="binutils-2_31_1-helenos"
|
---|
| 34 | BINUTILS_VERSION="2.31.1"
|
---|
[232ec3a1] | 35 |
|
---|
[6ae5e3f] | 36 | GDB_BRANCH="gdb-8_2-helenos"
|
---|
| 37 | GDB_VERSION="8.2"
|
---|
[603c8740] | 38 |
|
---|
[232ec3a1] | 39 | GCC_GIT="https://github.com/HelenOS/gcc.git"
|
---|
[c92dfed] | 40 | GCC_BRANCH="8_2_0-helenos"
|
---|
| 41 | GCC_VERSION="8.2.0"
|
---|
[232ec3a1] | 42 |
|
---|
[603c8740] | 43 | BASEDIR="`pwd`"
|
---|
[12735849] | 44 | SRCDIR="$(readlink -f $(dirname "$0"))"
|
---|
[603c8740] | 45 |
|
---|
[322ac35c] | 46 | REAL_INSTALL=true
|
---|
[bbe5e34] | 47 | USE_HELENOS_TARGET=true
|
---|
[3f7efa79] | 48 |
|
---|
[ff211d2] | 49 | check_error() {
|
---|
[75b24cd] | 50 | if [ "$1" -ne "0" ] ; then
|
---|
[ff211d2] | 51 | echo
|
---|
| 52 | echo "Script failed: $2"
|
---|
[a35b458] | 53 |
|
---|
[ff211d2] | 54 | exit 1
|
---|
| 55 | fi
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | show_usage() {
|
---|
| 59 | echo "Cross-compiler toolchain build script"
|
---|
| 60 | echo
|
---|
| 61 | echo "Syntax:"
|
---|
[bbe5e34] | 62 | echo " $0 [--no-install] [--non-helenos-target] <platform>"
|
---|
[cb15b49c] | 63 | echo " $0 --test-version [<platform>]"
|
---|
[ff211d2] | 64 | echo
|
---|
| 65 | echo "Possible target platforms are:"
|
---|
[f2f89315] | 66 | echo " amd64 AMD64 (x86-64, x64)"
|
---|
[d2bd00f0] | 67 | echo " arm32 ARM 32b"
|
---|
[c7c3508] | 68 | echo " arm64 AArch64"
|
---|
[ff211d2] | 69 | echo " ia32 IA-32 (x86, i386)"
|
---|
| 70 | echo " ia64 IA-64 (Itanium)"
|
---|
[71e3289] | 71 | echo " mips32 MIPS little-endian 32b"
|
---|
| 72 | echo " mips32eb MIPS big-endian 32b"
|
---|
[d2bd00f0] | 73 | echo " ppc32 PowerPC 32b"
|
---|
| 74 | echo " riscv64 RISC-V 64b"
|
---|
[f2f89315] | 75 | echo " sparc64 SPARC V9"
|
---|
[ff211d2] | 76 | echo " all build all targets"
|
---|
[951f6b9e] | 77 | echo " essential build only targets currently needed for HelenOS development"
|
---|
[6abb346] | 78 | echo " parallel same as 'all', but all in parallel"
|
---|
| 79 | echo " 2-way same as 'all', but 2-way parallel"
|
---|
[ff211d2] | 80 | echo
|
---|
[322ac35c] | 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."
|
---|
[5a65d29] | 84 | echo
|
---|
[322ac35c] | 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."
|
---|
[38eaf41] | 90 | echo
|
---|
[bbe5e34] | 91 | echo "The --non-helenos-target will build non-HelenOS-specific toolchain"
|
---|
| 92 | echo "(i.e. it will use *-linux-* triplet instead of *-helenos)."
|
---|
| 93 | echo "Using this toolchain for building HelenOS is not supported."
|
---|
[38eaf41] | 94 | echo
|
---|
[a35b458] | 95 |
|
---|
[ff211d2] | 96 | exit 3
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[4aba581] | 99 | test_version() {
|
---|
| 100 | echo "Cross-compiler toolchain build script"
|
---|
| 101 | echo
|
---|
| 102 | echo "Start testing the version of the installed software"
|
---|
| 103 | echo
|
---|
[cb15b49c] | 104 |
|
---|
[40c0483] | 105 | if [ -z "$1" ] || [ "$1" = "all" ] ; then
|
---|
| 106 | PLATFORMS='amd64 arm32 arm64 ia32 ia64 mips32 mips32eb ppc32 riscv64 sparc64'
|
---|
[cb15b49c] | 107 | else
|
---|
[40c0483] | 108 | PLATFORMS="$1"
|
---|
[cb15b49c] | 109 | fi
|
---|
| 110 |
|
---|
[4aba581] | 111 |
|
---|
| 112 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
| 113 | CROSS_PREFIX="/usr/local/cross"
|
---|
| 114 | fi
|
---|
| 115 |
|
---|
[40c0483] | 116 | for i in $PLATFORMS
|
---|
[4aba581] | 117 | do
|
---|
| 118 | PLATFORM="$i"
|
---|
| 119 | set_target_from_platform "$PLATFORM"
|
---|
| 120 | PREFIX="${CROSS_PREFIX}/bin/${HELENOS_TARGET}"
|
---|
| 121 |
|
---|
| 122 | echo "== $PLATFORM =="
|
---|
[40c0483] | 123 | test_app_version "Binutils" "ld" "GNU ld (.*) \([.0-9]*\)" "$BINUTILS_VERSION"
|
---|
| 124 | test_app_version "GCC" "gcc" "gcc version \([.0-9]*\)" "$GCC_VERSION"
|
---|
| 125 | test_app_version "GDB" "gdb" "GNU gdb (.*)[[:space:]]\+\([.0-9]*\)" "$GDB_VERSION"
|
---|
[4aba581] | 126 | done
|
---|
| 127 |
|
---|
| 128 | exit
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | test_app_version() {
|
---|
| 132 | PKGNAME="$1"
|
---|
| 133 | APPNAME="$2"
|
---|
| 134 | REGEX="$3"
|
---|
| 135 | INS_VERSION="$4"
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 | APP="${PREFIX}-${APPNAME}"
|
---|
| 139 | if [ ! -e $APP ]; then
|
---|
| 140 | echo "- $PKGNAME is missing"
|
---|
| 141 | else
|
---|
[40c0483] | 142 | VERSION=`${APP} -v 2>&1 | sed -n "s:^${REGEX}.*:\1:p"`
|
---|
| 143 |
|
---|
| 144 | if [ -z "$VERSION" ]; then
|
---|
| 145 | echo "- $PKGNAME Unexpected output"
|
---|
| 146 | return 1
|
---|
| 147 | fi
|
---|
| 148 |
|
---|
| 149 | if [ "$INS_VERSION" = "$VERSION" ]; then
|
---|
| 150 | echo "+ $PKGNAME is uptodate ($INS_VERSION)"
|
---|
| 151 | else
|
---|
| 152 | echo "- $PKGNAME ($VERSION) is outdated ($INS_VERSION)"
|
---|
| 153 | fi
|
---|
[4aba581] | 154 | fi
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 |
|
---|
[3fe57ea7] | 159 | change_title() {
|
---|
[40c0483] | 160 | printf "\e]0;$1\a"
|
---|
[3fe57ea7] | 161 | }
|
---|
| 162 |
|
---|
| 163 | show_countdown() {
|
---|
| 164 | TM="$1"
|
---|
[a35b458] | 165 |
|
---|
[3fe57ea7] | 166 | if [ "${TM}" -eq 0 ] ; then
|
---|
| 167 | echo
|
---|
| 168 | return 0
|
---|
| 169 | fi
|
---|
[a35b458] | 170 |
|
---|
[40c0483] | 171 | printf "${TM} "
|
---|
[3fe57ea7] | 172 | change_title "${TM}"
|
---|
| 173 | sleep 1
|
---|
[a35b458] | 174 |
|
---|
[3fe57ea7] | 175 | TM="`expr "${TM}" - 1`"
|
---|
| 176 | show_countdown "${TM}"
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 | show_dependencies() {
|
---|
| 180 | echo "IMPORTANT NOTICE:"
|
---|
| 181 | echo
|
---|
| 182 | echo "For a successful compilation and use of the cross-compiler"
|
---|
| 183 | echo "toolchain you need at least the following dependencies."
|
---|
| 184 | echo
|
---|
| 185 | echo "Please make sure that the dependencies are present in your"
|
---|
| 186 | echo "system. Otherwise the compilation process might fail after"
|
---|
| 187 | echo "a few seconds or minutes."
|
---|
| 188 | echo
|
---|
| 189 | echo " - SED, AWK, Flex, Bison, gzip, bzip2, Bourne Shell"
|
---|
| 190 | echo " - gettext, zlib, Texinfo, libelf, libgomp"
|
---|
[f6017ee] | 191 | echo " - GNU Make, Coreutils, Sharutils, tar"
|
---|
| 192 | echo " - native C and C++ compiler, assembler and linker"
|
---|
| 193 | echo " - native C and C++ standard library with headers"
|
---|
[3fe57ea7] | 194 | echo
|
---|
| 195 | }
|
---|
| 196 |
|
---|
[ff211d2] | 197 | cleanup_dir() {
|
---|
| 198 | DIR="$1"
|
---|
[a35b458] | 199 |
|
---|
[75b24cd] | 200 | if [ -d "${DIR}" ] ; then
|
---|
[3fe57ea7] | 201 | change_title "Removing ${DIR}"
|
---|
[ff211d2] | 202 | echo " >>> Removing ${DIR}"
|
---|
| 203 | rm -fr "${DIR}"
|
---|
| 204 | fi
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | create_dir() {
|
---|
| 208 | DIR="$1"
|
---|
| 209 | DESC="$2"
|
---|
[a35b458] | 210 |
|
---|
[3fe57ea7] | 211 | change_title "Creating ${DESC}"
|
---|
[ff211d2] | 212 | echo ">>> Creating ${DESC}"
|
---|
[a35b458] | 213 |
|
---|
[ff211d2] | 214 | mkdir -p "${DIR}"
|
---|
| 215 | test -d "${DIR}"
|
---|
| 216 | check_error $? "Unable to create ${DIR}."
|
---|
| 217 | }
|
---|
| 218 |
|
---|
[285589b] | 219 | check_dirs() {
|
---|
| 220 | OUTSIDE="$1"
|
---|
| 221 | BASE="$2"
|
---|
[40c0483] | 222 | ORIGINAL="$PWD"
|
---|
[a35b458] | 223 |
|
---|
[285589b] | 224 | cd "${BASE}"
|
---|
| 225 | check_error $? "Unable to change directory to ${BASE}."
|
---|
[40c0483] | 226 | ABS_BASE="$PWD"
|
---|
[285589b] | 227 | cd "${ORIGINAL}"
|
---|
| 228 | check_error $? "Unable to change directory to ${ORIGINAL}."
|
---|
[a35b458] | 229 |
|
---|
[40c0483] | 230 | mkdir -p "${OUTSIDE}"
|
---|
| 231 | cd "${OUTSIDE}"
|
---|
| 232 | check_error $? "Unable to change directory to ${OUTSIDE}."
|
---|
| 233 |
|
---|
| 234 | while [ "${#PWD}" -gt "${#ABS_BASE}" ]; do
|
---|
| 235 | cd ..
|
---|
| 236 | done
|
---|
[a35b458] | 237 |
|
---|
[40c0483] | 238 | if [ "$PWD" = "$ABS_BASE" ]; then
|
---|
[285589b] | 239 | echo
|
---|
| 240 | echo "CROSS_PREFIX cannot reside within the working directory."
|
---|
[a35b458] | 241 |
|
---|
[285589b] | 242 | exit 5
|
---|
| 243 | fi
|
---|
[40c0483] | 244 |
|
---|
| 245 | cd "${ORIGINAL}"
|
---|
| 246 | check_error $? "Unable to change directory to ${ORIGINAL}."
|
---|
[285589b] | 247 | }
|
---|
| 248 |
|
---|
[603c8740] | 249 | prepare() {
|
---|
| 250 | show_dependencies
|
---|
| 251 | show_countdown 10
|
---|
[a35b458] | 252 |
|
---|
[530f2de] | 253 | mkdir -p "${BASEDIR}/downloads"
|
---|
| 254 | cd "${BASEDIR}/downloads"
|
---|
| 255 | check_error $? "Change directory failed."
|
---|
| 256 |
|
---|
[232ec3a1] | 257 | echo ">>> Downloading sources"
|
---|
| 258 | git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION"
|
---|
| 259 | git clone --depth 1 -b "$GDB_BRANCH" "$BINUTILS_GDB_GIT" "gdb-$GDB_VERSION"
|
---|
| 260 | git clone --depth 1 -b "$GCC_BRANCH" "$GCC_GIT" "gcc-$GCC_VERSION"
|
---|
[a35b458] | 261 |
|
---|
[232ec3a1] | 262 | # If the directory already existed, pull upstream changes.
|
---|
| 263 | git -C "binutils-$BINUTILS_VERSION" pull
|
---|
| 264 | git -C "gdb-$GDB_VERSION" pull
|
---|
| 265 | git -C "gcc-$GCC_VERSION" pull
|
---|
[530f2de] | 266 |
|
---|
| 267 | echo ">>> Downloading GCC prerequisites"
|
---|
| 268 | cd "gcc-${GCC_VERSION}"
|
---|
| 269 | ./contrib/download_prerequisites
|
---|
| 270 | cd ..
|
---|
[fd8bf6a] | 271 | }
|
---|
| 272 |
|
---|
[6c9f1a6] | 273 | set_target_from_platform() {
|
---|
| 274 | case "$1" in
|
---|
| 275 | "arm32")
|
---|
[232ec3a1] | 276 | GNU_ARCH="arm"
|
---|
[6c9f1a6] | 277 | ;;
|
---|
[c7c3508] | 278 | "arm64")
|
---|
| 279 | GNU_ARCH="aarch64"
|
---|
| 280 | ;;
|
---|
[6c9f1a6] | 281 | "ia32")
|
---|
[232ec3a1] | 282 | GNU_ARCH="i686"
|
---|
[6c9f1a6] | 283 | ;;
|
---|
| 284 | "mips32")
|
---|
[232ec3a1] | 285 | GNU_ARCH="mipsel"
|
---|
[6c9f1a6] | 286 | ;;
|
---|
| 287 | "mips32eb")
|
---|
[232ec3a1] | 288 | GNU_ARCH="mips"
|
---|
[6c9f1a6] | 289 | ;;
|
---|
| 290 | "ppc32")
|
---|
[232ec3a1] | 291 | GNU_ARCH="ppc"
|
---|
[6c9f1a6] | 292 | ;;
|
---|
[232ec3a1] | 293 | *)
|
---|
| 294 | GNU_ARCH="$1"
|
---|
[6c9f1a6] | 295 | ;;
|
---|
[232ec3a1] | 296 | esac
|
---|
| 297 |
|
---|
| 298 | HELENOS_TARGET="${GNU_ARCH}-helenos"
|
---|
| 299 |
|
---|
| 300 | case "$1" in
|
---|
| 301 | "arm32")
|
---|
| 302 | LINUX_TARGET="${GNU_ARCH}-linux-gnueabi"
|
---|
[6c9f1a6] | 303 | ;;
|
---|
| 304 | *)
|
---|
[232ec3a1] | 305 | LINUX_TARGET="${GNU_ARCH}-linux-gnu"
|
---|
[6c9f1a6] | 306 | ;;
|
---|
| 307 | esac
|
---|
[fd8bf6a] | 308 | }
|
---|
| 309 |
|
---|
[ff211d2] | 310 | build_target() {
|
---|
| 311 | PLATFORM="$1"
|
---|
[a35b458] | 312 |
|
---|
[5a65d29] | 313 | # This sets the *_TARGET variables
|
---|
[6c9f1a6] | 314 | set_target_from_platform "$PLATFORM"
|
---|
[75b24cd] | 315 | if $USE_HELENOS_TARGET ; then
|
---|
[5a65d29] | 316 | TARGET="$HELENOS_TARGET"
|
---|
| 317 | else
|
---|
| 318 | TARGET="$LINUX_TARGET"
|
---|
| 319 | fi
|
---|
[a35b458] | 320 |
|
---|
[591b989] | 321 | WORKDIR="${BASEDIR}/${TARGET}"
|
---|
[e38ff16] | 322 | INSTALL_DIR="${BASEDIR}/PKG"
|
---|
[ff211d2] | 323 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
|
---|
| 324 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
|
---|
[2a922c8] | 325 | GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
|
---|
[a35b458] | 326 |
|
---|
[ff211d2] | 327 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
[603c8740] | 328 | CROSS_PREFIX="/usr/local/cross"
|
---|
[ff211d2] | 329 | fi
|
---|
[a35b458] | 330 |
|
---|
[232ec3a1] | 331 | if [ -z "$JOBS" ] ; then
|
---|
| 332 | JOBS=`nproc`
|
---|
| 333 | fi
|
---|
| 334 |
|
---|
[bbe5e34] | 335 | PREFIX="${CROSS_PREFIX}"
|
---|
[a35b458] | 336 |
|
---|
[ff211d2] | 337 | echo ">>> Removing previous content"
|
---|
[603c8740] | 338 | cleanup_dir "${WORKDIR}"
|
---|
[530f2de] | 339 | mkdir -p "${WORKDIR}"
|
---|
[285589b] | 340 | check_dirs "${PREFIX}" "${WORKDIR}"
|
---|
[a35b458] | 341 |
|
---|
[232ec3a1] | 342 | if $USE_HELENOS_TARGET ; then
|
---|
| 343 | echo ">>> Creating build sysroot"
|
---|
| 344 | mkdir -p "${WORKDIR}/sysroot/include"
|
---|
| 345 | mkdir "${WORKDIR}/sysroot/lib"
|
---|
[a9aafa1d] | 346 | ARCH="$PLATFORM"
|
---|
| 347 | if [ "$ARCH" = "mips32eb" ]; then
|
---|
| 348 | ARCH=mips32
|
---|
| 349 | fi
|
---|
| 350 |
|
---|
[232ec3a1] | 351 | cp -r -L -t "${WORKDIR}/sysroot/include" \
|
---|
| 352 | ${SRCDIR}/../abi/include/* \
|
---|
[a9aafa1d] | 353 | ${SRCDIR}/../uspace/lib/c/arch/${ARCH}/include/* \
|
---|
[232ec3a1] | 354 | ${SRCDIR}/../uspace/lib/c/include/*
|
---|
| 355 | check_error $? "Failed to create build sysroot."
|
---|
| 356 | fi
|
---|
| 357 |
|
---|
[3fe57ea7] | 358 | echo ">>> Processing binutils (${PLATFORM})"
|
---|
[530f2de] | 359 | mkdir -p "${BINUTILSDIR}"
|
---|
[ff211d2] | 360 | cd "${BINUTILSDIR}"
|
---|
| 361 | check_error $? "Change directory failed."
|
---|
[a35b458] | 362 |
|
---|
[3fe57ea7] | 363 | change_title "binutils: configure (${PLATFORM})"
|
---|
[530f2de] | 364 | CFLAGS=-Wno-error "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \
|
---|
[322ac35c] | 365 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 366 | "--prefix=${PREFIX}" \
|
---|
| 367 | "--program-prefix=${TARGET}-" \
|
---|
| 368 | --disable-nls \
|
---|
| 369 | --disable-werror \
|
---|
| 370 | --enable-gold \
|
---|
| 371 | --enable-deterministic-archives \
|
---|
| 372 | --disable-gdb \
|
---|
| 373 | --with-sysroot
|
---|
[ff211d2] | 374 | check_error $? "Error configuring binutils."
|
---|
[a35b458] | 375 |
|
---|
[3fe57ea7] | 376 | change_title "binutils: make (${PLATFORM})"
|
---|
[232ec3a1] | 377 | make all -j$JOBS
|
---|
[322ac35c] | 378 | check_error $? "Error compiling binutils."
|
---|
[a35b458] | 379 |
|
---|
[322ac35c] | 380 | change_title "binutils: install (${PLATFORM})"
|
---|
[0f28387] | 381 | make install "DESTDIR=${INSTALL_DIR}"
|
---|
[322ac35c] | 382 | check_error $? "Error installing binutils."
|
---|
[a35b458] | 383 |
|
---|
| 384 |
|
---|
[3fe57ea7] | 385 | echo ">>> Processing GCC (${PLATFORM})"
|
---|
[530f2de] | 386 | mkdir -p "${GCCDIR}"
|
---|
| 387 | cd "${GCCDIR}"
|
---|
[ff211d2] | 388 | check_error $? "Change directory failed."
|
---|
[a35b458] | 389 |
|
---|
[232ec3a1] | 390 | if $USE_HELENOS_TARGET ; then
|
---|
| 391 | SYSROOT=--with-sysroot --with-build-sysroot="${WORKDIR}/sysroot"
|
---|
| 392 | else
|
---|
| 393 | SYSROOT=--without-headers
|
---|
| 394 | fi
|
---|
| 395 |
|
---|
[3fe57ea7] | 396 | change_title "GCC: configure (${PLATFORM})"
|
---|
[530f2de] | 397 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \
|
---|
[322ac35c] | 398 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 399 | "--prefix=${PREFIX}" \
|
---|
| 400 | "--program-prefix=${TARGET}-" \
|
---|
| 401 | --with-gnu-as \
|
---|
| 402 | --with-gnu-ld \
|
---|
| 403 | --disable-nls \
|
---|
| 404 | --enable-languages=c,c++,go \
|
---|
| 405 | --enable-lto \
|
---|
| 406 | --disable-shared \
|
---|
| 407 | --disable-werror \
|
---|
| 408 | $SYSROOT
|
---|
[ff211d2] | 409 | check_error $? "Error configuring GCC."
|
---|
[a35b458] | 410 |
|
---|
[3fe57ea7] | 411 | change_title "GCC: make (${PLATFORM})"
|
---|
[232ec3a1] | 412 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc -j$JOBS
|
---|
[322ac35c] | 413 | check_error $? "Error compiling GCC."
|
---|
[a35b458] | 414 |
|
---|
[232ec3a1] | 415 | if $USE_HELENOS_TARGET ; then
|
---|
| 416 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libgcc -j$JOBS
|
---|
| 417 | check_error $? "Error compiling libgcc."
|
---|
| 418 | # TODO: needs some extra care
|
---|
| 419 | #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libatomic -j$JOBS
|
---|
| 420 | #check_error $? "Error compiling libatomic."
|
---|
| 421 | #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libstdc++-v3 -j$JOBS
|
---|
| 422 | #check_error $? "Error compiling libstdc++."
|
---|
| 423 | fi
|
---|
| 424 |
|
---|
[322ac35c] | 425 | change_title "GCC: install (${PLATFORM})"
|
---|
[0f28387] | 426 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
|
---|
[232ec3a1] | 427 | if $USE_HELENOS_TARGET ; then
|
---|
| 428 | 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}"
|
---|
| 431 | fi
|
---|
[322ac35c] | 432 | check_error $? "Error installing GCC."
|
---|
[a35b458] | 433 |
|
---|
| 434 |
|
---|
[105fcf0] | 435 | echo ">>> Processing GDB (${PLATFORM})"
|
---|
| 436 | mkdir -p "${GDBDIR}"
|
---|
| 437 | cd "${GDBDIR}"
|
---|
| 438 | check_error $? "Change directory failed."
|
---|
[a35b458] | 439 |
|
---|
[105fcf0] | 440 | change_title "GDB: configure (${PLATFORM})"
|
---|
| 441 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \
|
---|
| 442 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 443 | "--prefix=${PREFIX}" \
|
---|
| 444 | "--program-prefix=${TARGET}-" \
|
---|
| 445 | --enable-werror=no
|
---|
[105fcf0] | 446 | check_error $? "Error configuring GDB."
|
---|
[a35b458] | 447 |
|
---|
[105fcf0] | 448 | change_title "GDB: make (${PLATFORM})"
|
---|
[232ec3a1] | 449 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gdb -j$JOBS
|
---|
[105fcf0] | 450 | check_error $? "Error compiling GDB."
|
---|
[a35b458] | 451 |
|
---|
[105fcf0] | 452 | change_title "GDB: make (${PLATFORM})"
|
---|
[232ec3a1] | 453 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gdb "DESTDIR=${INSTALL_DIR}"
|
---|
[105fcf0] | 454 | check_error $? "Error installing GDB."
|
---|
[a35b458] | 455 |
|
---|
[0f28387] | 456 | # Symlink clang and lld to the install path.
|
---|
[8192d8a] | 457 | CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`"
|
---|
| 458 | LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`"
|
---|
[a35b458] | 459 |
|
---|
[0f28387] | 460 | ln -s $CLANG "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-clang"
|
---|
| 461 | ln -s $LLD "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-ld.lld"
|
---|
[a35b458] | 462 |
|
---|
[0f28387] | 463 | if $REAL_INSTALL ; then
|
---|
| 464 | echo ">>> Moving to the destination directory."
|
---|
[bbe5e34] | 465 | echo cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*
|
---|
| 466 | cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*
|
---|
[0f28387] | 467 | fi
|
---|
[a35b458] | 468 |
|
---|
[603c8740] | 469 | cd "${BASEDIR}"
|
---|
[ff211d2] | 470 | check_error $? "Change directory failed."
|
---|
[a35b458] | 471 |
|
---|
[ff211d2] | 472 | echo ">>> Cleaning up"
|
---|
[603c8740] | 473 | cleanup_dir "${WORKDIR}"
|
---|
[a35b458] | 474 |
|
---|
[ff211d2] | 475 | echo
|
---|
| 476 | echo ">>> Cross-compiler for ${TARGET} installed."
|
---|
| 477 | }
|
---|
| 478 |
|
---|
[75b24cd] | 479 | while [ "$#" -gt 1 ] ; do
|
---|
[5a65d29] | 480 | case "$1" in
|
---|
[cb15b49c] | 481 | --test-version)
|
---|
| 482 | test_version "$2"
|
---|
| 483 | exit
|
---|
| 484 | ;;
|
---|
[5a65d29] | 485 | --no-install)
|
---|
| 486 | REAL_INSTALL=false
|
---|
| 487 | shift
|
---|
| 488 | ;;
|
---|
[bbe5e34] | 489 | --non-helenos-target)
|
---|
| 490 | USE_HELENOS_TARGET=false
|
---|
[5a65d29] | 491 | shift
|
---|
| 492 | ;;
|
---|
| 493 | *)
|
---|
| 494 | show_usage
|
---|
| 495 | ;;
|
---|
| 496 | esac
|
---|
| 497 | done
|
---|
[322ac35c] | 498 |
|
---|
[75b24cd] | 499 | if [ "$#" -lt "1" ] ; then
|
---|
[ff211d2] | 500 | show_usage
|
---|
| 501 | fi
|
---|
| 502 |
|
---|
| 503 | case "$1" in
|
---|
[cb15b49c] | 504 | --test-version)
|
---|
[4aba581] | 505 | test_version
|
---|
| 506 | ;;
|
---|
[c7c3508] | 507 | amd64|arm32|arm64|ia32|ia64|mips32|mips32eb|ppc32|riscv64|sparc64)
|
---|
[603c8740] | 508 | prepare
|
---|
[6c9f1a6] | 509 | build_target "$1"
|
---|
[b886b60] | 510 | ;;
|
---|
[ff211d2] | 511 | "all")
|
---|
[603c8740] | 512 | prepare
|
---|
[6c9f1a6] | 513 | build_target "amd64"
|
---|
| 514 | build_target "arm32"
|
---|
[c7c3508] | 515 | build_target "arm64"
|
---|
[6c9f1a6] | 516 | build_target "ia32"
|
---|
| 517 | build_target "ia64"
|
---|
| 518 | build_target "mips32"
|
---|
| 519 | build_target "mips32eb"
|
---|
| 520 | build_target "ppc32"
|
---|
[d2bd00f0] | 521 | build_target "riscv64"
|
---|
[6c9f1a6] | 522 | build_target "sparc64"
|
---|
[ff211d2] | 523 | ;;
|
---|
[951f6b9e] | 524 | "essential")
|
---|
| 525 | prepare
|
---|
| 526 | build_target "amd64"
|
---|
| 527 | build_target "arm32"
|
---|
[c7c3508] | 528 | build_target "arm64"
|
---|
[951f6b9e] | 529 | build_target "ia32"
|
---|
| 530 | build_target "ia64"
|
---|
| 531 | build_target "mips32"
|
---|
| 532 | build_target "mips32eb"
|
---|
| 533 | build_target "ppc32"
|
---|
| 534 | build_target "sparc64"
|
---|
| 535 | ;;
|
---|
[603c8740] | 536 | "parallel")
|
---|
| 537 | prepare
|
---|
[6c9f1a6] | 538 | build_target "amd64" &
|
---|
| 539 | build_target "arm32" &
|
---|
[c7c3508] | 540 | build_target "arm64" &
|
---|
[6c9f1a6] | 541 | build_target "ia32" &
|
---|
| 542 | build_target "ia64" &
|
---|
| 543 | build_target "mips32" &
|
---|
| 544 | build_target "mips32eb" &
|
---|
| 545 | build_target "ppc32" &
|
---|
[d2bd00f0] | 546 | build_target "riscv64" &
|
---|
[6c9f1a6] | 547 | build_target "sparc64" &
|
---|
[6abb346] | 548 | wait
|
---|
| 549 | ;;
|
---|
| 550 | "2-way")
|
---|
| 551 | prepare
|
---|
[6c9f1a6] | 552 | build_target "amd64" &
|
---|
| 553 | build_target "arm32" &
|
---|
[6abb346] | 554 | wait
|
---|
[a35b458] | 555 |
|
---|
[c7c3508] | 556 | build_target "arm64" &
|
---|
[6c9f1a6] | 557 | build_target "ia32" &
|
---|
[6abb346] | 558 | wait
|
---|
[a35b458] | 559 |
|
---|
[c7c3508] | 560 | build_target "ia64" &
|
---|
[6c9f1a6] | 561 | build_target "mips32" &
|
---|
[6abb346] | 562 | wait
|
---|
[a35b458] | 563 |
|
---|
[c7c3508] | 564 | build_target "mips32eb" &
|
---|
[6c9f1a6] | 565 | build_target "ppc32" &
|
---|
[d2bd00f0] | 566 | wait
|
---|
[a35b458] | 567 |
|
---|
[c7c3508] | 568 | build_target "riscv64" &
|
---|
[6c9f1a6] | 569 | build_target "sparc64" &
|
---|
[b886b60] | 570 | wait
|
---|
[603c8740] | 571 | ;;
|
---|
[ff211d2] | 572 | *)
|
---|
| 573 | show_usage
|
---|
| 574 | ;;
|
---|
| 575 | esac
|
---|