[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"
|
---|
[ff211d2] | 68 | echo " ia32 IA-32 (x86, i386)"
|
---|
| 69 | echo " ia64 IA-64 (Itanium)"
|
---|
[71e3289] | 70 | echo " mips32 MIPS little-endian 32b"
|
---|
| 71 | echo " mips32eb MIPS big-endian 32b"
|
---|
[d2bd00f0] | 72 | echo " ppc32 PowerPC 32b"
|
---|
| 73 | echo " riscv64 RISC-V 64b"
|
---|
[f2f89315] | 74 | echo " sparc64 SPARC V9"
|
---|
[ff211d2] | 75 | echo " all build all targets"
|
---|
[951f6b9e] | 76 | echo " essential build only targets currently needed for HelenOS development"
|
---|
[6abb346] | 77 | echo " parallel same as 'all', but all in parallel"
|
---|
| 78 | echo " 2-way same as 'all', but 2-way parallel"
|
---|
[ff211d2] | 79 | echo
|
---|
[322ac35c] | 80 | echo "The toolchain is installed into directory specified by the"
|
---|
| 81 | echo "CROSS_PREFIX environment variable. If the variable is not"
|
---|
| 82 | echo "defined, /usr/local/cross/ is used as default."
|
---|
[5a65d29] | 83 | echo
|
---|
[322ac35c] | 84 | echo "If --no-install is present, the toolchain still uses the"
|
---|
| 85 | echo "CROSS_PREFIX as the target directory but the installation"
|
---|
| 86 | echo "copies the files into PKG/ subdirectory without affecting"
|
---|
| 87 | echo "the actual root file system. That is only useful if you do"
|
---|
| 88 | echo "not want to run the script under the super user."
|
---|
[38eaf41] | 89 | echo
|
---|
[bbe5e34] | 90 | echo "The --non-helenos-target will build non-HelenOS-specific toolchain"
|
---|
| 91 | echo "(i.e. it will use *-linux-* triplet instead of *-helenos)."
|
---|
| 92 | echo "Using this toolchain for building HelenOS is not supported."
|
---|
[38eaf41] | 93 | echo
|
---|
[a35b458] | 94 |
|
---|
[ff211d2] | 95 | exit 3
|
---|
| 96 | }
|
---|
| 97 |
|
---|
[4aba581] | 98 | test_version() {
|
---|
| 99 | echo "Cross-compiler toolchain build script"
|
---|
| 100 | echo
|
---|
| 101 | echo "Start testing the version of the installed software"
|
---|
| 102 | echo
|
---|
[cb15b49c] | 103 |
|
---|
| 104 | if [ -z "$1" ] || [ "$1" == "all" ] ; then
|
---|
| 105 | PLATFORMS=("amd64" "arm32" "ia32" "ia64" "mips32" "mips32eb" "ppc32" "riscv64" "sparc64")
|
---|
| 106 | else
|
---|
| 107 | PLATFORMS=("$1")
|
---|
| 108 | fi
|
---|
| 109 |
|
---|
[4aba581] | 110 |
|
---|
| 111 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
| 112 | CROSS_PREFIX="/usr/local/cross"
|
---|
| 113 | fi
|
---|
| 114 |
|
---|
| 115 | for i in "${PLATFORMS[@]}"
|
---|
| 116 | do
|
---|
| 117 | PLATFORM="$i"
|
---|
| 118 | set_target_from_platform "$PLATFORM"
|
---|
| 119 | PREFIX="${CROSS_PREFIX}/bin/${HELENOS_TARGET}"
|
---|
| 120 |
|
---|
| 121 | echo "== $PLATFORM =="
|
---|
| 122 | test_app_version "Binutils" "ld" "GNU\ ld\ \(GNU\ Binutils\)\ ((\.|[0-9])+)" "$BINUTILS_VERSION"
|
---|
| 123 | test_app_version "GCC" "gcc" "gcc\ version\ ((\.|[0-9])+)" "$GCC_VERSION"
|
---|
| 124 | test_app_version "GDB" "gdb" "GNU\ gdb\ \(GDB\)\s+((\.|[0-9])+)" "$GDB_VERSION"
|
---|
| 125 | done
|
---|
| 126 |
|
---|
| 127 | exit
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | test_app_version() {
|
---|
| 131 | PKGNAME="$1"
|
---|
| 132 | APPNAME="$2"
|
---|
| 133 | REGEX="$3"
|
---|
| 134 | INS_VERSION="$4"
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | APP="${PREFIX}-${APPNAME}"
|
---|
| 138 | if [ ! -e $APP ]; then
|
---|
| 139 | echo "- $PKGNAME is missing"
|
---|
| 140 | else
|
---|
| 141 | {
|
---|
| 142 | OUT=$(${APP} -v 2>&1)
|
---|
| 143 | } &> /dev/null
|
---|
| 144 |
|
---|
| 145 | if [[ "$OUT" =~ $REGEX ]]; then
|
---|
| 146 | VERSION="${BASH_REMATCH[1]}"
|
---|
| 147 | if [ "$INS_VERSION" = "$VERSION" ]; then
|
---|
| 148 | echo "+ $PKGNAME is uptodate ($INS_VERSION)"
|
---|
| 149 | else
|
---|
| 150 | echo "- $PKGNAME ($VERSION) is outdated ($INS_VERSION)"
|
---|
| 151 | fi
|
---|
| 152 | else
|
---|
| 153 | echo "- $PKGNAME Unexpected output"
|
---|
| 154 | fi
|
---|
| 155 | fi
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 |
|
---|
| 159 |
|
---|
[3fe57ea7] | 160 | change_title() {
|
---|
| 161 | echo -en "\e]0;$1\a"
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | show_countdown() {
|
---|
| 165 | TM="$1"
|
---|
[a35b458] | 166 |
|
---|
[3fe57ea7] | 167 | if [ "${TM}" -eq 0 ] ; then
|
---|
| 168 | echo
|
---|
| 169 | return 0
|
---|
| 170 | fi
|
---|
[a35b458] | 171 |
|
---|
[3fe57ea7] | 172 | echo -n "${TM} "
|
---|
| 173 | change_title "${TM}"
|
---|
| 174 | sleep 1
|
---|
[a35b458] | 175 |
|
---|
[3fe57ea7] | 176 | TM="`expr "${TM}" - 1`"
|
---|
| 177 | show_countdown "${TM}"
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | show_dependencies() {
|
---|
| 181 | echo "IMPORTANT NOTICE:"
|
---|
| 182 | echo
|
---|
| 183 | echo "For a successful compilation and use of the cross-compiler"
|
---|
| 184 | echo "toolchain you need at least the following dependencies."
|
---|
| 185 | echo
|
---|
| 186 | echo "Please make sure that the dependencies are present in your"
|
---|
| 187 | echo "system. Otherwise the compilation process might fail after"
|
---|
| 188 | echo "a few seconds or minutes."
|
---|
| 189 | echo
|
---|
| 190 | echo " - SED, AWK, Flex, Bison, gzip, bzip2, Bourne Shell"
|
---|
| 191 | echo " - gettext, zlib, Texinfo, libelf, libgomp"
|
---|
[f6017ee] | 192 | echo " - GNU Make, Coreutils, Sharutils, tar"
|
---|
| 193 | echo " - native C and C++ compiler, assembler and linker"
|
---|
| 194 | echo " - native C and C++ standard library with headers"
|
---|
[3fe57ea7] | 195 | echo
|
---|
| 196 | }
|
---|
| 197 |
|
---|
[ff211d2] | 198 | cleanup_dir() {
|
---|
| 199 | DIR="$1"
|
---|
[a35b458] | 200 |
|
---|
[75b24cd] | 201 | if [ -d "${DIR}" ] ; then
|
---|
[3fe57ea7] | 202 | change_title "Removing ${DIR}"
|
---|
[ff211d2] | 203 | echo " >>> Removing ${DIR}"
|
---|
| 204 | rm -fr "${DIR}"
|
---|
| 205 | fi
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | create_dir() {
|
---|
| 209 | DIR="$1"
|
---|
| 210 | DESC="$2"
|
---|
[a35b458] | 211 |
|
---|
[3fe57ea7] | 212 | change_title "Creating ${DESC}"
|
---|
[ff211d2] | 213 | echo ">>> Creating ${DESC}"
|
---|
[a35b458] | 214 |
|
---|
[ff211d2] | 215 | mkdir -p "${DIR}"
|
---|
| 216 | test -d "${DIR}"
|
---|
| 217 | check_error $? "Unable to create ${DIR}."
|
---|
| 218 | }
|
---|
| 219 |
|
---|
[285589b] | 220 | check_dirs() {
|
---|
| 221 | OUTSIDE="$1"
|
---|
| 222 | BASE="$2"
|
---|
| 223 | ORIGINAL="`pwd`"
|
---|
[a35b458] | 224 |
|
---|
[0f28387] | 225 | mkdir -p "${OUTSIDE}"
|
---|
[a35b458] | 226 |
|
---|
[285589b] | 227 | cd "${OUTSIDE}"
|
---|
| 228 | check_error $? "Unable to change directory to ${OUTSIDE}."
|
---|
| 229 | ABS_OUTSIDE="`pwd`"
|
---|
[a35b458] | 230 |
|
---|
[285589b] | 231 | cd "${BASE}"
|
---|
| 232 | check_error $? "Unable to change directory to ${BASE}."
|
---|
| 233 | ABS_BASE="`pwd`"
|
---|
[a35b458] | 234 |
|
---|
[285589b] | 235 | cd "${ORIGINAL}"
|
---|
| 236 | check_error $? "Unable to change directory to ${ORIGINAL}."
|
---|
[a35b458] | 237 |
|
---|
[285589b] | 238 | BASE_LEN="${#ABS_BASE}"
|
---|
| 239 | OUTSIDE_TRIM="${ABS_OUTSIDE:0:${BASE_LEN}}"
|
---|
[a35b458] | 240 |
|
---|
[285589b] | 241 | if [ "${OUTSIDE_TRIM}" == "${ABS_BASE}" ] ; then
|
---|
| 242 | echo
|
---|
| 243 | echo "CROSS_PREFIX cannot reside within the working directory."
|
---|
[a35b458] | 244 |
|
---|
[285589b] | 245 | exit 5
|
---|
| 246 | fi
|
---|
| 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 | ;;
|
---|
| 278 | "ia32")
|
---|
[232ec3a1] | 279 | GNU_ARCH="i686"
|
---|
[6c9f1a6] | 280 | ;;
|
---|
| 281 | "mips32")
|
---|
[232ec3a1] | 282 | GNU_ARCH="mipsel"
|
---|
[6c9f1a6] | 283 | ;;
|
---|
| 284 | "mips32eb")
|
---|
[232ec3a1] | 285 | GNU_ARCH="mips"
|
---|
[6c9f1a6] | 286 | ;;
|
---|
| 287 | "ppc32")
|
---|
[232ec3a1] | 288 | GNU_ARCH="ppc"
|
---|
[6c9f1a6] | 289 | ;;
|
---|
[232ec3a1] | 290 | *)
|
---|
| 291 | GNU_ARCH="$1"
|
---|
[6c9f1a6] | 292 | ;;
|
---|
[232ec3a1] | 293 | esac
|
---|
| 294 |
|
---|
| 295 | HELENOS_TARGET="${GNU_ARCH}-helenos"
|
---|
| 296 |
|
---|
| 297 | case "$1" in
|
---|
| 298 | "arm32")
|
---|
| 299 | LINUX_TARGET="${GNU_ARCH}-linux-gnueabi"
|
---|
[6c9f1a6] | 300 | ;;
|
---|
| 301 | *)
|
---|
[232ec3a1] | 302 | LINUX_TARGET="${GNU_ARCH}-linux-gnu"
|
---|
[6c9f1a6] | 303 | ;;
|
---|
| 304 | esac
|
---|
[fd8bf6a] | 305 | }
|
---|
| 306 |
|
---|
[ff211d2] | 307 | build_target() {
|
---|
| 308 | PLATFORM="$1"
|
---|
[a35b458] | 309 |
|
---|
[5a65d29] | 310 | # This sets the *_TARGET variables
|
---|
[6c9f1a6] | 311 | set_target_from_platform "$PLATFORM"
|
---|
[75b24cd] | 312 | if $USE_HELENOS_TARGET ; then
|
---|
[5a65d29] | 313 | TARGET="$HELENOS_TARGET"
|
---|
| 314 | else
|
---|
| 315 | TARGET="$LINUX_TARGET"
|
---|
| 316 | fi
|
---|
[a35b458] | 317 |
|
---|
[591b989] | 318 | WORKDIR="${BASEDIR}/${TARGET}"
|
---|
[e38ff16] | 319 | INSTALL_DIR="${BASEDIR}/PKG"
|
---|
[ff211d2] | 320 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
|
---|
| 321 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
|
---|
[2a922c8] | 322 | GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
|
---|
[a35b458] | 323 |
|
---|
[ff211d2] | 324 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
[603c8740] | 325 | CROSS_PREFIX="/usr/local/cross"
|
---|
[ff211d2] | 326 | fi
|
---|
[a35b458] | 327 |
|
---|
[232ec3a1] | 328 | if [ -z "$JOBS" ] ; then
|
---|
| 329 | JOBS=`nproc`
|
---|
| 330 | fi
|
---|
| 331 |
|
---|
[bbe5e34] | 332 | PREFIX="${CROSS_PREFIX}"
|
---|
[a35b458] | 333 |
|
---|
[ff211d2] | 334 | echo ">>> Removing previous content"
|
---|
[603c8740] | 335 | cleanup_dir "${WORKDIR}"
|
---|
[530f2de] | 336 | mkdir -p "${WORKDIR}"
|
---|
[285589b] | 337 | check_dirs "${PREFIX}" "${WORKDIR}"
|
---|
[a35b458] | 338 |
|
---|
[232ec3a1] | 339 | if $USE_HELENOS_TARGET ; then
|
---|
| 340 | echo ">>> Creating build sysroot"
|
---|
| 341 | mkdir -p "${WORKDIR}/sysroot/include"
|
---|
| 342 | mkdir "${WORKDIR}/sysroot/lib"
|
---|
| 343 | cp -r -L -t "${WORKDIR}/sysroot/include" \
|
---|
| 344 | ${SRCDIR}/../abi/include/* \
|
---|
| 345 | ${SRCDIR}/../uspace/lib/c/arch/${PLATFORM}/include/* \
|
---|
| 346 | ${SRCDIR}/../uspace/lib/c/include/*
|
---|
| 347 | check_error $? "Failed to create build sysroot."
|
---|
| 348 | fi
|
---|
| 349 |
|
---|
[3fe57ea7] | 350 | echo ">>> Processing binutils (${PLATFORM})"
|
---|
[530f2de] | 351 | mkdir -p "${BINUTILSDIR}"
|
---|
[ff211d2] | 352 | cd "${BINUTILSDIR}"
|
---|
| 353 | check_error $? "Change directory failed."
|
---|
[a35b458] | 354 |
|
---|
[3fe57ea7] | 355 | change_title "binutils: configure (${PLATFORM})"
|
---|
[530f2de] | 356 | CFLAGS=-Wno-error "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \
|
---|
[322ac35c] | 357 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 358 | "--prefix=${PREFIX}" \
|
---|
| 359 | "--program-prefix=${TARGET}-" \
|
---|
| 360 | --disable-nls \
|
---|
| 361 | --disable-werror \
|
---|
| 362 | --enable-gold \
|
---|
| 363 | --enable-deterministic-archives \
|
---|
| 364 | --disable-gdb \
|
---|
| 365 | --with-sysroot
|
---|
[ff211d2] | 366 | check_error $? "Error configuring binutils."
|
---|
[a35b458] | 367 |
|
---|
[3fe57ea7] | 368 | change_title "binutils: make (${PLATFORM})"
|
---|
[232ec3a1] | 369 | make all -j$JOBS
|
---|
[322ac35c] | 370 | check_error $? "Error compiling binutils."
|
---|
[a35b458] | 371 |
|
---|
[322ac35c] | 372 | change_title "binutils: install (${PLATFORM})"
|
---|
[0f28387] | 373 | make install "DESTDIR=${INSTALL_DIR}"
|
---|
[322ac35c] | 374 | check_error $? "Error installing binutils."
|
---|
[a35b458] | 375 |
|
---|
| 376 |
|
---|
[3fe57ea7] | 377 | echo ">>> Processing GCC (${PLATFORM})"
|
---|
[530f2de] | 378 | mkdir -p "${GCCDIR}"
|
---|
| 379 | cd "${GCCDIR}"
|
---|
[ff211d2] | 380 | check_error $? "Change directory failed."
|
---|
[a35b458] | 381 |
|
---|
[232ec3a1] | 382 | if $USE_HELENOS_TARGET ; then
|
---|
| 383 | SYSROOT=--with-sysroot --with-build-sysroot="${WORKDIR}/sysroot"
|
---|
| 384 | else
|
---|
| 385 | SYSROOT=--without-headers
|
---|
| 386 | fi
|
---|
| 387 |
|
---|
[3fe57ea7] | 388 | change_title "GCC: configure (${PLATFORM})"
|
---|
[530f2de] | 389 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \
|
---|
[322ac35c] | 390 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 391 | "--prefix=${PREFIX}" \
|
---|
| 392 | "--program-prefix=${TARGET}-" \
|
---|
| 393 | --with-gnu-as \
|
---|
| 394 | --with-gnu-ld \
|
---|
| 395 | --disable-nls \
|
---|
| 396 | --enable-languages=c,c++,go \
|
---|
| 397 | --enable-lto \
|
---|
| 398 | --disable-shared \
|
---|
| 399 | --disable-werror \
|
---|
| 400 | $SYSROOT
|
---|
[ff211d2] | 401 | check_error $? "Error configuring GCC."
|
---|
[a35b458] | 402 |
|
---|
[3fe57ea7] | 403 | change_title "GCC: make (${PLATFORM})"
|
---|
[232ec3a1] | 404 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc -j$JOBS
|
---|
[322ac35c] | 405 | check_error $? "Error compiling GCC."
|
---|
[a35b458] | 406 |
|
---|
[232ec3a1] | 407 | if $USE_HELENOS_TARGET ; then
|
---|
| 408 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libgcc -j$JOBS
|
---|
| 409 | check_error $? "Error compiling libgcc."
|
---|
| 410 | # TODO: needs some extra care
|
---|
| 411 | #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libatomic -j$JOBS
|
---|
| 412 | #check_error $? "Error compiling libatomic."
|
---|
| 413 | #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libstdc++-v3 -j$JOBS
|
---|
| 414 | #check_error $? "Error compiling libstdc++."
|
---|
| 415 | fi
|
---|
| 416 |
|
---|
[322ac35c] | 417 | change_title "GCC: install (${PLATFORM})"
|
---|
[0f28387] | 418 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
|
---|
[232ec3a1] | 419 | if $USE_HELENOS_TARGET ; then
|
---|
| 420 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libgcc "DESTDIR=${INSTALL_DIR}"
|
---|
| 421 | #PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libatomic "DESTDIR=${INSTALL_DIR}"
|
---|
| 422 | #PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libstdc++-v3 "DESTDIR=${INSTALL_DIR}"
|
---|
| 423 | fi
|
---|
[322ac35c] | 424 | check_error $? "Error installing GCC."
|
---|
[a35b458] | 425 |
|
---|
| 426 |
|
---|
[105fcf0] | 427 | echo ">>> Processing GDB (${PLATFORM})"
|
---|
| 428 | mkdir -p "${GDBDIR}"
|
---|
| 429 | cd "${GDBDIR}"
|
---|
| 430 | check_error $? "Change directory failed."
|
---|
[a35b458] | 431 |
|
---|
[105fcf0] | 432 | change_title "GDB: configure (${PLATFORM})"
|
---|
| 433 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \
|
---|
| 434 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 435 | "--prefix=${PREFIX}" \
|
---|
| 436 | "--program-prefix=${TARGET}-" \
|
---|
| 437 | --enable-werror=no
|
---|
[105fcf0] | 438 | check_error $? "Error configuring GDB."
|
---|
[a35b458] | 439 |
|
---|
[105fcf0] | 440 | change_title "GDB: make (${PLATFORM})"
|
---|
[232ec3a1] | 441 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gdb -j$JOBS
|
---|
[105fcf0] | 442 | check_error $? "Error compiling GDB."
|
---|
[a35b458] | 443 |
|
---|
[105fcf0] | 444 | change_title "GDB: make (${PLATFORM})"
|
---|
[232ec3a1] | 445 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gdb "DESTDIR=${INSTALL_DIR}"
|
---|
[105fcf0] | 446 | check_error $? "Error installing GDB."
|
---|
[a35b458] | 447 |
|
---|
[0f28387] | 448 | # Symlink clang and lld to the install path.
|
---|
[8192d8a] | 449 | CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`"
|
---|
| 450 | LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`"
|
---|
[a35b458] | 451 |
|
---|
[0f28387] | 452 | ln -s $CLANG "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-clang"
|
---|
| 453 | ln -s $LLD "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-ld.lld"
|
---|
[a35b458] | 454 |
|
---|
[0f28387] | 455 | if $REAL_INSTALL ; then
|
---|
| 456 | echo ">>> Moving to the destination directory."
|
---|
[bbe5e34] | 457 | echo cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*
|
---|
| 458 | cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*
|
---|
[0f28387] | 459 | fi
|
---|
[a35b458] | 460 |
|
---|
[603c8740] | 461 | cd "${BASEDIR}"
|
---|
[ff211d2] | 462 | check_error $? "Change directory failed."
|
---|
[a35b458] | 463 |
|
---|
[ff211d2] | 464 | echo ">>> Cleaning up"
|
---|
[603c8740] | 465 | cleanup_dir "${WORKDIR}"
|
---|
[a35b458] | 466 |
|
---|
[ff211d2] | 467 | echo
|
---|
| 468 | echo ">>> Cross-compiler for ${TARGET} installed."
|
---|
| 469 | }
|
---|
| 470 |
|
---|
[75b24cd] | 471 | while [ "$#" -gt 1 ] ; do
|
---|
[5a65d29] | 472 | case "$1" in
|
---|
[cb15b49c] | 473 | --test-version)
|
---|
| 474 | test_version "$2"
|
---|
| 475 | exit
|
---|
| 476 | ;;
|
---|
[5a65d29] | 477 | --no-install)
|
---|
| 478 | REAL_INSTALL=false
|
---|
| 479 | shift
|
---|
| 480 | ;;
|
---|
[bbe5e34] | 481 | --non-helenos-target)
|
---|
| 482 | USE_HELENOS_TARGET=false
|
---|
[5a65d29] | 483 | shift
|
---|
| 484 | ;;
|
---|
| 485 | *)
|
---|
| 486 | show_usage
|
---|
| 487 | ;;
|
---|
| 488 | esac
|
---|
| 489 | done
|
---|
[322ac35c] | 490 |
|
---|
[75b24cd] | 491 | if [ "$#" -lt "1" ] ; then
|
---|
[ff211d2] | 492 | show_usage
|
---|
| 493 | fi
|
---|
| 494 |
|
---|
| 495 | case "$1" in
|
---|
[cb15b49c] | 496 | --test-version)
|
---|
[4aba581] | 497 | test_version
|
---|
| 498 | ;;
|
---|
[1b12042] | 499 | amd64|arm32|ia32|ia64|mips32|mips32eb|ppc32|riscv64|sparc64)
|
---|
[603c8740] | 500 | prepare
|
---|
[6c9f1a6] | 501 | build_target "$1"
|
---|
[b886b60] | 502 | ;;
|
---|
[ff211d2] | 503 | "all")
|
---|
[603c8740] | 504 | prepare
|
---|
[6c9f1a6] | 505 | build_target "amd64"
|
---|
| 506 | build_target "arm32"
|
---|
| 507 | build_target "ia32"
|
---|
| 508 | build_target "ia64"
|
---|
| 509 | build_target "mips32"
|
---|
| 510 | build_target "mips32eb"
|
---|
| 511 | build_target "ppc32"
|
---|
[d2bd00f0] | 512 | build_target "riscv64"
|
---|
[6c9f1a6] | 513 | build_target "sparc64"
|
---|
[ff211d2] | 514 | ;;
|
---|
[951f6b9e] | 515 | "essential")
|
---|
| 516 | prepare
|
---|
| 517 | build_target "amd64"
|
---|
| 518 | build_target "arm32"
|
---|
| 519 | build_target "ia32"
|
---|
| 520 | build_target "ia64"
|
---|
| 521 | build_target "mips32"
|
---|
| 522 | build_target "mips32eb"
|
---|
| 523 | build_target "ppc32"
|
---|
| 524 | build_target "sparc64"
|
---|
| 525 | ;;
|
---|
[603c8740] | 526 | "parallel")
|
---|
| 527 | prepare
|
---|
[6c9f1a6] | 528 | build_target "amd64" &
|
---|
| 529 | build_target "arm32" &
|
---|
| 530 | build_target "ia32" &
|
---|
| 531 | build_target "ia64" &
|
---|
| 532 | build_target "mips32" &
|
---|
| 533 | build_target "mips32eb" &
|
---|
| 534 | build_target "ppc32" &
|
---|
[d2bd00f0] | 535 | build_target "riscv64" &
|
---|
[6c9f1a6] | 536 | build_target "sparc64" &
|
---|
[6abb346] | 537 | wait
|
---|
| 538 | ;;
|
---|
| 539 | "2-way")
|
---|
| 540 | prepare
|
---|
[6c9f1a6] | 541 | build_target "amd64" &
|
---|
| 542 | build_target "arm32" &
|
---|
[6abb346] | 543 | wait
|
---|
[a35b458] | 544 |
|
---|
[6c9f1a6] | 545 | build_target "ia32" &
|
---|
| 546 | build_target "ia64" &
|
---|
[6abb346] | 547 | wait
|
---|
[a35b458] | 548 |
|
---|
[6c9f1a6] | 549 | build_target "mips32" &
|
---|
| 550 | build_target "mips32eb" &
|
---|
[6abb346] | 551 | wait
|
---|
[a35b458] | 552 |
|
---|
[6c9f1a6] | 553 | build_target "ppc32" &
|
---|
[d2bd00f0] | 554 | build_target "riscv64" &
|
---|
| 555 | wait
|
---|
[a35b458] | 556 |
|
---|
[6c9f1a6] | 557 | build_target "sparc64" &
|
---|
[b886b60] | 558 | wait
|
---|
[603c8740] | 559 | ;;
|
---|
[ff211d2] | 560 | *)
|
---|
| 561 | show_usage
|
---|
| 562 | ;;
|
---|
| 563 | esac
|
---|