[9d5bb4e] | 1 | #! /bin/bash
|
---|
[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 |
|
---|
| 105 | if [ -z "$1" ] || [ "$1" == "all" ] ; then
|
---|
[c7c3508] | 106 | PLATFORMS=("amd64" "arm32" "arm64" "ia32" "ia64" "mips32" "mips32eb" "ppc32" "riscv64" "sparc64")
|
---|
[cb15b49c] | 107 | else
|
---|
| 108 | PLATFORMS=("$1")
|
---|
| 109 | fi
|
---|
| 110 |
|
---|
[4aba581] | 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"
|
---|
| 119 | set_target_from_platform "$PLATFORM"
|
---|
| 120 | PREFIX="${CROSS_PREFIX}/bin/${HELENOS_TARGET}"
|
---|
| 121 |
|
---|
| 122 | echo "== $PLATFORM =="
|
---|
| 123 | test_app_version "Binutils" "ld" "GNU\ ld\ \(GNU\ Binutils\)\ ((\.|[0-9])+)" "$BINUTILS_VERSION"
|
---|
| 124 | test_app_version "GCC" "gcc" "gcc\ version\ ((\.|[0-9])+)" "$GCC_VERSION"
|
---|
| 125 | test_app_version "GDB" "gdb" "GNU\ gdb\ \(GDB\)\s+((\.|[0-9])+)" "$GDB_VERSION"
|
---|
| 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
|
---|
| 142 | {
|
---|
| 143 | OUT=$(${APP} -v 2>&1)
|
---|
| 144 | } &> /dev/null
|
---|
| 145 |
|
---|
| 146 | if [[ "$OUT" =~ $REGEX ]]; then
|
---|
| 147 | VERSION="${BASH_REMATCH[1]}"
|
---|
| 148 | if [ "$INS_VERSION" = "$VERSION" ]; then
|
---|
| 149 | echo "+ $PKGNAME is uptodate ($INS_VERSION)"
|
---|
| 150 | else
|
---|
| 151 | echo "- $PKGNAME ($VERSION) is outdated ($INS_VERSION)"
|
---|
| 152 | fi
|
---|
| 153 | else
|
---|
| 154 | echo "- $PKGNAME Unexpected output"
|
---|
| 155 | fi
|
---|
| 156 | fi
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 |
|
---|
[3fe57ea7] | 161 | change_title() {
|
---|
| 162 | echo -en "\e]0;$1\a"
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | show_countdown() {
|
---|
| 166 | TM="$1"
|
---|
[a35b458] | 167 |
|
---|
[3fe57ea7] | 168 | if [ "${TM}" -eq 0 ] ; then
|
---|
| 169 | echo
|
---|
| 170 | return 0
|
---|
| 171 | fi
|
---|
[a35b458] | 172 |
|
---|
[3fe57ea7] | 173 | echo -n "${TM} "
|
---|
| 174 | change_title "${TM}"
|
---|
| 175 | sleep 1
|
---|
[a35b458] | 176 |
|
---|
[3fe57ea7] | 177 | TM="`expr "${TM}" - 1`"
|
---|
| 178 | show_countdown "${TM}"
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | show_dependencies() {
|
---|
| 182 | echo "IMPORTANT NOTICE:"
|
---|
| 183 | echo
|
---|
| 184 | echo "For a successful compilation and use of the cross-compiler"
|
---|
| 185 | echo "toolchain you need at least the following dependencies."
|
---|
| 186 | echo
|
---|
| 187 | echo "Please make sure that the dependencies are present in your"
|
---|
| 188 | echo "system. Otherwise the compilation process might fail after"
|
---|
| 189 | echo "a few seconds or minutes."
|
---|
| 190 | echo
|
---|
| 191 | echo " - SED, AWK, Flex, Bison, gzip, bzip2, Bourne Shell"
|
---|
| 192 | echo " - gettext, zlib, Texinfo, libelf, libgomp"
|
---|
[f6017ee] | 193 | echo " - GNU Make, Coreutils, Sharutils, tar"
|
---|
| 194 | echo " - native C and C++ compiler, assembler and linker"
|
---|
| 195 | echo " - native C and C++ standard library with headers"
|
---|
[3fe57ea7] | 196 | echo
|
---|
| 197 | }
|
---|
| 198 |
|
---|
[ff211d2] | 199 | cleanup_dir() {
|
---|
| 200 | DIR="$1"
|
---|
[a35b458] | 201 |
|
---|
[75b24cd] | 202 | if [ -d "${DIR}" ] ; then
|
---|
[3fe57ea7] | 203 | change_title "Removing ${DIR}"
|
---|
[ff211d2] | 204 | echo " >>> Removing ${DIR}"
|
---|
| 205 | rm -fr "${DIR}"
|
---|
| 206 | fi
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | create_dir() {
|
---|
| 210 | DIR="$1"
|
---|
| 211 | DESC="$2"
|
---|
[a35b458] | 212 |
|
---|
[3fe57ea7] | 213 | change_title "Creating ${DESC}"
|
---|
[ff211d2] | 214 | echo ">>> Creating ${DESC}"
|
---|
[a35b458] | 215 |
|
---|
[ff211d2] | 216 | mkdir -p "${DIR}"
|
---|
| 217 | test -d "${DIR}"
|
---|
| 218 | check_error $? "Unable to create ${DIR}."
|
---|
| 219 | }
|
---|
| 220 |
|
---|
[285589b] | 221 | check_dirs() {
|
---|
| 222 | OUTSIDE="$1"
|
---|
| 223 | BASE="$2"
|
---|
| 224 | ORIGINAL="`pwd`"
|
---|
[a35b458] | 225 |
|
---|
[0f28387] | 226 | mkdir -p "${OUTSIDE}"
|
---|
[a35b458] | 227 |
|
---|
[285589b] | 228 | cd "${OUTSIDE}"
|
---|
| 229 | check_error $? "Unable to change directory to ${OUTSIDE}."
|
---|
| 230 | ABS_OUTSIDE="`pwd`"
|
---|
[a35b458] | 231 |
|
---|
[285589b] | 232 | cd "${BASE}"
|
---|
| 233 | check_error $? "Unable to change directory to ${BASE}."
|
---|
| 234 | ABS_BASE="`pwd`"
|
---|
[a35b458] | 235 |
|
---|
[285589b] | 236 | cd "${ORIGINAL}"
|
---|
| 237 | check_error $? "Unable to change directory to ${ORIGINAL}."
|
---|
[a35b458] | 238 |
|
---|
[285589b] | 239 | BASE_LEN="${#ABS_BASE}"
|
---|
| 240 | OUTSIDE_TRIM="${ABS_OUTSIDE:0:${BASE_LEN}}"
|
---|
[a35b458] | 241 |
|
---|
[285589b] | 242 | if [ "${OUTSIDE_TRIM}" == "${ABS_BASE}" ] ; then
|
---|
| 243 | echo
|
---|
| 244 | echo "CROSS_PREFIX cannot reside within the working directory."
|
---|
[a35b458] | 245 |
|
---|
[285589b] | 246 | exit 5
|
---|
| 247 | fi
|
---|
| 248 | }
|
---|
| 249 |
|
---|
[603c8740] | 250 | prepare() {
|
---|
| 251 | show_dependencies
|
---|
| 252 | show_countdown 10
|
---|
[a35b458] | 253 |
|
---|
[530f2de] | 254 | mkdir -p "${BASEDIR}/downloads"
|
---|
| 255 | cd "${BASEDIR}/downloads"
|
---|
| 256 | check_error $? "Change directory failed."
|
---|
| 257 |
|
---|
[232ec3a1] | 258 | echo ">>> Downloading sources"
|
---|
| 259 | git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION"
|
---|
| 260 | git clone --depth 1 -b "$GDB_BRANCH" "$BINUTILS_GDB_GIT" "gdb-$GDB_VERSION"
|
---|
| 261 | git clone --depth 1 -b "$GCC_BRANCH" "$GCC_GIT" "gcc-$GCC_VERSION"
|
---|
[a35b458] | 262 |
|
---|
[232ec3a1] | 263 | # If the directory already existed, pull upstream changes.
|
---|
| 264 | git -C "binutils-$BINUTILS_VERSION" pull
|
---|
| 265 | git -C "gdb-$GDB_VERSION" pull
|
---|
| 266 | git -C "gcc-$GCC_VERSION" pull
|
---|
[530f2de] | 267 |
|
---|
| 268 | echo ">>> Downloading GCC prerequisites"
|
---|
| 269 | cd "gcc-${GCC_VERSION}"
|
---|
| 270 | ./contrib/download_prerequisites
|
---|
| 271 | cd ..
|
---|
[fd8bf6a] | 272 | }
|
---|
| 273 |
|
---|
[6c9f1a6] | 274 | set_target_from_platform() {
|
---|
| 275 | case "$1" in
|
---|
| 276 | "arm32")
|
---|
[232ec3a1] | 277 | GNU_ARCH="arm"
|
---|
[6c9f1a6] | 278 | ;;
|
---|
[c7c3508] | 279 | "arm64")
|
---|
| 280 | GNU_ARCH="aarch64"
|
---|
| 281 | ;;
|
---|
[6c9f1a6] | 282 | "ia32")
|
---|
[232ec3a1] | 283 | GNU_ARCH="i686"
|
---|
[6c9f1a6] | 284 | ;;
|
---|
| 285 | "mips32")
|
---|
[232ec3a1] | 286 | GNU_ARCH="mipsel"
|
---|
[6c9f1a6] | 287 | ;;
|
---|
| 288 | "mips32eb")
|
---|
[232ec3a1] | 289 | GNU_ARCH="mips"
|
---|
[6c9f1a6] | 290 | ;;
|
---|
| 291 | "ppc32")
|
---|
[232ec3a1] | 292 | GNU_ARCH="ppc"
|
---|
[6c9f1a6] | 293 | ;;
|
---|
[232ec3a1] | 294 | *)
|
---|
| 295 | GNU_ARCH="$1"
|
---|
[6c9f1a6] | 296 | ;;
|
---|
[232ec3a1] | 297 | esac
|
---|
| 298 |
|
---|
| 299 | HELENOS_TARGET="${GNU_ARCH}-helenos"
|
---|
| 300 |
|
---|
| 301 | case "$1" in
|
---|
| 302 | "arm32")
|
---|
| 303 | LINUX_TARGET="${GNU_ARCH}-linux-gnueabi"
|
---|
[6c9f1a6] | 304 | ;;
|
---|
| 305 | *)
|
---|
[232ec3a1] | 306 | LINUX_TARGET="${GNU_ARCH}-linux-gnu"
|
---|
[6c9f1a6] | 307 | ;;
|
---|
| 308 | esac
|
---|
[fd8bf6a] | 309 | }
|
---|
| 310 |
|
---|
[ff211d2] | 311 | build_target() {
|
---|
| 312 | PLATFORM="$1"
|
---|
[a35b458] | 313 |
|
---|
[5a65d29] | 314 | # This sets the *_TARGET variables
|
---|
[6c9f1a6] | 315 | set_target_from_platform "$PLATFORM"
|
---|
[75b24cd] | 316 | if $USE_HELENOS_TARGET ; then
|
---|
[5a65d29] | 317 | TARGET="$HELENOS_TARGET"
|
---|
| 318 | else
|
---|
| 319 | TARGET="$LINUX_TARGET"
|
---|
| 320 | fi
|
---|
[a35b458] | 321 |
|
---|
[591b989] | 322 | WORKDIR="${BASEDIR}/${TARGET}"
|
---|
[e38ff16] | 323 | INSTALL_DIR="${BASEDIR}/PKG"
|
---|
[ff211d2] | 324 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
|
---|
| 325 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
|
---|
[2a922c8] | 326 | GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
|
---|
[a35b458] | 327 |
|
---|
[ff211d2] | 328 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
[603c8740] | 329 | CROSS_PREFIX="/usr/local/cross"
|
---|
[ff211d2] | 330 | fi
|
---|
[a35b458] | 331 |
|
---|
[232ec3a1] | 332 | if [ -z "$JOBS" ] ; then
|
---|
| 333 | JOBS=`nproc`
|
---|
| 334 | fi
|
---|
| 335 |
|
---|
[bbe5e34] | 336 | PREFIX="${CROSS_PREFIX}"
|
---|
[a35b458] | 337 |
|
---|
[ff211d2] | 338 | echo ">>> Removing previous content"
|
---|
[603c8740] | 339 | cleanup_dir "${WORKDIR}"
|
---|
[530f2de] | 340 | mkdir -p "${WORKDIR}"
|
---|
[285589b] | 341 | check_dirs "${PREFIX}" "${WORKDIR}"
|
---|
[a35b458] | 342 |
|
---|
[232ec3a1] | 343 | if $USE_HELENOS_TARGET ; then
|
---|
| 344 | echo ">>> Creating build sysroot"
|
---|
| 345 | mkdir -p "${WORKDIR}/sysroot/include"
|
---|
| 346 | mkdir "${WORKDIR}/sysroot/lib"
|
---|
| 347 | cp -r -L -t "${WORKDIR}/sysroot/include" \
|
---|
| 348 | ${SRCDIR}/../abi/include/* \
|
---|
| 349 | ${SRCDIR}/../uspace/lib/c/arch/${PLATFORM}/include/* \
|
---|
| 350 | ${SRCDIR}/../uspace/lib/c/include/*
|
---|
| 351 | check_error $? "Failed to create build sysroot."
|
---|
| 352 | fi
|
---|
| 353 |
|
---|
[3fe57ea7] | 354 | echo ">>> Processing binutils (${PLATFORM})"
|
---|
[530f2de] | 355 | mkdir -p "${BINUTILSDIR}"
|
---|
[ff211d2] | 356 | cd "${BINUTILSDIR}"
|
---|
| 357 | check_error $? "Change directory failed."
|
---|
[a35b458] | 358 |
|
---|
[3fe57ea7] | 359 | change_title "binutils: configure (${PLATFORM})"
|
---|
[530f2de] | 360 | CFLAGS=-Wno-error "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \
|
---|
[322ac35c] | 361 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 362 | "--prefix=${PREFIX}" \
|
---|
| 363 | "--program-prefix=${TARGET}-" \
|
---|
| 364 | --disable-nls \
|
---|
| 365 | --disable-werror \
|
---|
| 366 | --enable-gold \
|
---|
| 367 | --enable-deterministic-archives \
|
---|
| 368 | --disable-gdb \
|
---|
| 369 | --with-sysroot
|
---|
[ff211d2] | 370 | check_error $? "Error configuring binutils."
|
---|
[a35b458] | 371 |
|
---|
[3fe57ea7] | 372 | change_title "binutils: make (${PLATFORM})"
|
---|
[232ec3a1] | 373 | make all -j$JOBS
|
---|
[322ac35c] | 374 | check_error $? "Error compiling binutils."
|
---|
[a35b458] | 375 |
|
---|
[322ac35c] | 376 | change_title "binutils: install (${PLATFORM})"
|
---|
[0f28387] | 377 | make install "DESTDIR=${INSTALL_DIR}"
|
---|
[322ac35c] | 378 | check_error $? "Error installing binutils."
|
---|
[a35b458] | 379 |
|
---|
| 380 |
|
---|
[3fe57ea7] | 381 | echo ">>> Processing GCC (${PLATFORM})"
|
---|
[530f2de] | 382 | mkdir -p "${GCCDIR}"
|
---|
| 383 | cd "${GCCDIR}"
|
---|
[ff211d2] | 384 | check_error $? "Change directory failed."
|
---|
[a35b458] | 385 |
|
---|
[232ec3a1] | 386 | if $USE_HELENOS_TARGET ; then
|
---|
| 387 | SYSROOT=--with-sysroot --with-build-sysroot="${WORKDIR}/sysroot"
|
---|
| 388 | else
|
---|
| 389 | SYSROOT=--without-headers
|
---|
| 390 | fi
|
---|
| 391 |
|
---|
[3fe57ea7] | 392 | change_title "GCC: configure (${PLATFORM})"
|
---|
[530f2de] | 393 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \
|
---|
[322ac35c] | 394 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 395 | "--prefix=${PREFIX}" \
|
---|
| 396 | "--program-prefix=${TARGET}-" \
|
---|
| 397 | --with-gnu-as \
|
---|
| 398 | --with-gnu-ld \
|
---|
| 399 | --disable-nls \
|
---|
| 400 | --enable-languages=c,c++,go \
|
---|
| 401 | --enable-lto \
|
---|
| 402 | --disable-shared \
|
---|
| 403 | --disable-werror \
|
---|
| 404 | $SYSROOT
|
---|
[ff211d2] | 405 | check_error $? "Error configuring GCC."
|
---|
[a35b458] | 406 |
|
---|
[3fe57ea7] | 407 | change_title "GCC: make (${PLATFORM})"
|
---|
[232ec3a1] | 408 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc -j$JOBS
|
---|
[322ac35c] | 409 | check_error $? "Error compiling GCC."
|
---|
[a35b458] | 410 |
|
---|
[232ec3a1] | 411 | if $USE_HELENOS_TARGET ; then
|
---|
| 412 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libgcc -j$JOBS
|
---|
| 413 | check_error $? "Error compiling libgcc."
|
---|
| 414 | # TODO: needs some extra care
|
---|
| 415 | #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libatomic -j$JOBS
|
---|
| 416 | #check_error $? "Error compiling libatomic."
|
---|
| 417 | #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libstdc++-v3 -j$JOBS
|
---|
| 418 | #check_error $? "Error compiling libstdc++."
|
---|
| 419 | fi
|
---|
| 420 |
|
---|
[322ac35c] | 421 | change_title "GCC: install (${PLATFORM})"
|
---|
[0f28387] | 422 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
|
---|
[232ec3a1] | 423 | if $USE_HELENOS_TARGET ; then
|
---|
| 424 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libgcc "DESTDIR=${INSTALL_DIR}"
|
---|
| 425 | #PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libatomic "DESTDIR=${INSTALL_DIR}"
|
---|
| 426 | #PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libstdc++-v3 "DESTDIR=${INSTALL_DIR}"
|
---|
| 427 | fi
|
---|
[322ac35c] | 428 | check_error $? "Error installing GCC."
|
---|
[a35b458] | 429 |
|
---|
| 430 |
|
---|
[105fcf0] | 431 | echo ">>> Processing GDB (${PLATFORM})"
|
---|
| 432 | mkdir -p "${GDBDIR}"
|
---|
| 433 | cd "${GDBDIR}"
|
---|
| 434 | check_error $? "Change directory failed."
|
---|
[a35b458] | 435 |
|
---|
[105fcf0] | 436 | change_title "GDB: configure (${PLATFORM})"
|
---|
| 437 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \
|
---|
| 438 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 439 | "--prefix=${PREFIX}" \
|
---|
| 440 | "--program-prefix=${TARGET}-" \
|
---|
| 441 | --enable-werror=no
|
---|
[105fcf0] | 442 | check_error $? "Error configuring GDB."
|
---|
[a35b458] | 443 |
|
---|
[105fcf0] | 444 | change_title "GDB: make (${PLATFORM})"
|
---|
[232ec3a1] | 445 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gdb -j$JOBS
|
---|
[105fcf0] | 446 | check_error $? "Error compiling GDB."
|
---|
[a35b458] | 447 |
|
---|
[105fcf0] | 448 | change_title "GDB: make (${PLATFORM})"
|
---|
[232ec3a1] | 449 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gdb "DESTDIR=${INSTALL_DIR}"
|
---|
[105fcf0] | 450 | check_error $? "Error installing GDB."
|
---|
[a35b458] | 451 |
|
---|
[0f28387] | 452 | # Symlink clang and lld to the install path.
|
---|
[8192d8a] | 453 | CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`"
|
---|
| 454 | LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`"
|
---|
[a35b458] | 455 |
|
---|
[0f28387] | 456 | ln -s $CLANG "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-clang"
|
---|
| 457 | ln -s $LLD "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-ld.lld"
|
---|
[a35b458] | 458 |
|
---|
[0f28387] | 459 | if $REAL_INSTALL ; then
|
---|
| 460 | echo ">>> Moving to the destination directory."
|
---|
[bbe5e34] | 461 | echo cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*
|
---|
| 462 | cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*
|
---|
[0f28387] | 463 | fi
|
---|
[a35b458] | 464 |
|
---|
[603c8740] | 465 | cd "${BASEDIR}"
|
---|
[ff211d2] | 466 | check_error $? "Change directory failed."
|
---|
[a35b458] | 467 |
|
---|
[ff211d2] | 468 | echo ">>> Cleaning up"
|
---|
[603c8740] | 469 | cleanup_dir "${WORKDIR}"
|
---|
[a35b458] | 470 |
|
---|
[ff211d2] | 471 | echo
|
---|
| 472 | echo ">>> Cross-compiler for ${TARGET} installed."
|
---|
| 473 | }
|
---|
| 474 |
|
---|
[75b24cd] | 475 | while [ "$#" -gt 1 ] ; do
|
---|
[5a65d29] | 476 | case "$1" in
|
---|
[cb15b49c] | 477 | --test-version)
|
---|
| 478 | test_version "$2"
|
---|
| 479 | exit
|
---|
| 480 | ;;
|
---|
[5a65d29] | 481 | --no-install)
|
---|
| 482 | REAL_INSTALL=false
|
---|
| 483 | shift
|
---|
| 484 | ;;
|
---|
[bbe5e34] | 485 | --non-helenos-target)
|
---|
| 486 | USE_HELENOS_TARGET=false
|
---|
[5a65d29] | 487 | shift
|
---|
| 488 | ;;
|
---|
| 489 | *)
|
---|
| 490 | show_usage
|
---|
| 491 | ;;
|
---|
| 492 | esac
|
---|
| 493 | done
|
---|
[322ac35c] | 494 |
|
---|
[75b24cd] | 495 | if [ "$#" -lt "1" ] ; then
|
---|
[ff211d2] | 496 | show_usage
|
---|
| 497 | fi
|
---|
| 498 |
|
---|
| 499 | case "$1" in
|
---|
[cb15b49c] | 500 | --test-version)
|
---|
[4aba581] | 501 | test_version
|
---|
| 502 | ;;
|
---|
[c7c3508] | 503 | amd64|arm32|arm64|ia32|ia64|mips32|mips32eb|ppc32|riscv64|sparc64)
|
---|
[603c8740] | 504 | prepare
|
---|
[6c9f1a6] | 505 | build_target "$1"
|
---|
[b886b60] | 506 | ;;
|
---|
[ff211d2] | 507 | "all")
|
---|
[603c8740] | 508 | prepare
|
---|
[6c9f1a6] | 509 | build_target "amd64"
|
---|
| 510 | build_target "arm32"
|
---|
[c7c3508] | 511 | build_target "arm64"
|
---|
[6c9f1a6] | 512 | build_target "ia32"
|
---|
| 513 | build_target "ia64"
|
---|
| 514 | build_target "mips32"
|
---|
| 515 | build_target "mips32eb"
|
---|
| 516 | build_target "ppc32"
|
---|
[d2bd00f0] | 517 | build_target "riscv64"
|
---|
[6c9f1a6] | 518 | build_target "sparc64"
|
---|
[ff211d2] | 519 | ;;
|
---|
[951f6b9e] | 520 | "essential")
|
---|
| 521 | prepare
|
---|
| 522 | build_target "amd64"
|
---|
| 523 | build_target "arm32"
|
---|
[c7c3508] | 524 | build_target "arm64"
|
---|
[951f6b9e] | 525 | build_target "ia32"
|
---|
| 526 | build_target "ia64"
|
---|
| 527 | build_target "mips32"
|
---|
| 528 | build_target "mips32eb"
|
---|
| 529 | build_target "ppc32"
|
---|
| 530 | build_target "sparc64"
|
---|
| 531 | ;;
|
---|
[603c8740] | 532 | "parallel")
|
---|
| 533 | prepare
|
---|
[6c9f1a6] | 534 | build_target "amd64" &
|
---|
| 535 | build_target "arm32" &
|
---|
[c7c3508] | 536 | build_target "arm64" &
|
---|
[6c9f1a6] | 537 | build_target "ia32" &
|
---|
| 538 | build_target "ia64" &
|
---|
| 539 | build_target "mips32" &
|
---|
| 540 | build_target "mips32eb" &
|
---|
| 541 | build_target "ppc32" &
|
---|
[d2bd00f0] | 542 | build_target "riscv64" &
|
---|
[6c9f1a6] | 543 | build_target "sparc64" &
|
---|
[6abb346] | 544 | wait
|
---|
| 545 | ;;
|
---|
| 546 | "2-way")
|
---|
| 547 | prepare
|
---|
[6c9f1a6] | 548 | build_target "amd64" &
|
---|
| 549 | build_target "arm32" &
|
---|
[6abb346] | 550 | wait
|
---|
[a35b458] | 551 |
|
---|
[c7c3508] | 552 | build_target "arm64" &
|
---|
[6c9f1a6] | 553 | build_target "ia32" &
|
---|
[6abb346] | 554 | wait
|
---|
[a35b458] | 555 |
|
---|
[c7c3508] | 556 | build_target "ia64" &
|
---|
[6c9f1a6] | 557 | build_target "mips32" &
|
---|
[6abb346] | 558 | wait
|
---|
[a35b458] | 559 |
|
---|
[c7c3508] | 560 | build_target "mips32eb" &
|
---|
[6c9f1a6] | 561 | build_target "ppc32" &
|
---|
[d2bd00f0] | 562 | wait
|
---|
[a35b458] | 563 |
|
---|
[c7c3508] | 564 | build_target "riscv64" &
|
---|
[6c9f1a6] | 565 | build_target "sparc64" &
|
---|
[b886b60] | 566 | wait
|
---|
[603c8740] | 567 | ;;
|
---|
[ff211d2] | 568 | *)
|
---|
| 569 | show_usage
|
---|
| 570 | ;;
|
---|
| 571 | esac
|
---|