[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 |
|
---|
| 33 | BINUTILS_BRANCH="binutils-2_30-helenos"
|
---|
[105fcf0] | 34 | BINUTILS_VERSION="2.30"
|
---|
[232ec3a1] | 35 |
|
---|
| 36 | GDB_BRANCH="gdb-8_1-helenos"
|
---|
[105fcf0] | 37 | GDB_VERSION="8.1"
|
---|
[603c8740] | 38 |
|
---|
[232ec3a1] | 39 | GCC_GIT="https://github.com/HelenOS/gcc.git"
|
---|
| 40 | GCC_BRANCH="7_3_0-helenos"
|
---|
| 41 | GCC_VERSION="7.3.0"
|
---|
| 42 |
|
---|
[603c8740] | 43 | BASEDIR="`pwd`"
|
---|
[12735849] | 44 | SRCDIR="$(readlink -f $(dirname "$0"))"
|
---|
[603c8740] | 45 |
|
---|
[322ac35c] | 46 | REAL_INSTALL=true
|
---|
[5a65d29] | 47 | USE_HELENOS_TARGET=false
|
---|
[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:"
|
---|
[5a65d29] | 62 | echo " $0 [--no-install] [--helenos-target] <platform>"
|
---|
[ff211d2] | 63 | echo
|
---|
| 64 | echo "Possible target platforms are:"
|
---|
[f2f89315] | 65 | echo " amd64 AMD64 (x86-64, x64)"
|
---|
[d2bd00f0] | 66 | echo " arm32 ARM 32b"
|
---|
[ff211d2] | 67 | echo " ia32 IA-32 (x86, i386)"
|
---|
| 68 | echo " ia64 IA-64 (Itanium)"
|
---|
[71e3289] | 69 | echo " mips32 MIPS little-endian 32b"
|
---|
| 70 | echo " mips32eb MIPS big-endian 32b"
|
---|
| 71 | echo " mips64 MIPS little-endian 64b"
|
---|
[d2bd00f0] | 72 | echo " ppc32 PowerPC 32b"
|
---|
| 73 | echo " ppc64 PowerPC 64v"
|
---|
| 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
|
---|
[5a65d29] | 91 | echo "The --helenos-target will build HelenOS-specific toolchain"
|
---|
[232ec3a1] | 92 | echo "(i.e. it will use *-helenos triplet instead of *-linux-*)."
|
---|
[f3287e5] | 93 | echo "Using the HelenOS-specific toolchain is still an experimental"
|
---|
| 94 | echo "feature that is not fully supported."
|
---|
[38eaf41] | 95 | echo
|
---|
[a35b458] | 96 |
|
---|
[ff211d2] | 97 | exit 3
|
---|
| 98 | }
|
---|
| 99 |
|
---|
[3fe57ea7] | 100 | change_title() {
|
---|
| 101 | echo -en "\e]0;$1\a"
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | show_countdown() {
|
---|
| 105 | TM="$1"
|
---|
[a35b458] | 106 |
|
---|
[3fe57ea7] | 107 | if [ "${TM}" -eq 0 ] ; then
|
---|
| 108 | echo
|
---|
| 109 | return 0
|
---|
| 110 | fi
|
---|
[a35b458] | 111 |
|
---|
[3fe57ea7] | 112 | echo -n "${TM} "
|
---|
| 113 | change_title "${TM}"
|
---|
| 114 | sleep 1
|
---|
[a35b458] | 115 |
|
---|
[3fe57ea7] | 116 | TM="`expr "${TM}" - 1`"
|
---|
| 117 | show_countdown "${TM}"
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | show_dependencies() {
|
---|
| 121 | echo "IMPORTANT NOTICE:"
|
---|
| 122 | echo
|
---|
| 123 | echo "For a successful compilation and use of the cross-compiler"
|
---|
| 124 | echo "toolchain you need at least the following dependencies."
|
---|
| 125 | echo
|
---|
| 126 | echo "Please make sure that the dependencies are present in your"
|
---|
| 127 | echo "system. Otherwise the compilation process might fail after"
|
---|
| 128 | echo "a few seconds or minutes."
|
---|
| 129 | echo
|
---|
| 130 | echo " - SED, AWK, Flex, Bison, gzip, bzip2, Bourne Shell"
|
---|
| 131 | echo " - gettext, zlib, Texinfo, libelf, libgomp"
|
---|
[f6017ee] | 132 | echo " - GNU Make, Coreutils, Sharutils, tar"
|
---|
| 133 | echo " - native C and C++ compiler, assembler and linker"
|
---|
| 134 | echo " - native C and C++ standard library with headers"
|
---|
[3fe57ea7] | 135 | echo
|
---|
| 136 | }
|
---|
| 137 |
|
---|
[ff211d2] | 138 | cleanup_dir() {
|
---|
| 139 | DIR="$1"
|
---|
[a35b458] | 140 |
|
---|
[75b24cd] | 141 | if [ -d "${DIR}" ] ; then
|
---|
[3fe57ea7] | 142 | change_title "Removing ${DIR}"
|
---|
[ff211d2] | 143 | echo " >>> Removing ${DIR}"
|
---|
| 144 | rm -fr "${DIR}"
|
---|
| 145 | fi
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | create_dir() {
|
---|
| 149 | DIR="$1"
|
---|
| 150 | DESC="$2"
|
---|
[a35b458] | 151 |
|
---|
[3fe57ea7] | 152 | change_title "Creating ${DESC}"
|
---|
[ff211d2] | 153 | echo ">>> Creating ${DESC}"
|
---|
[a35b458] | 154 |
|
---|
[ff211d2] | 155 | mkdir -p "${DIR}"
|
---|
| 156 | test -d "${DIR}"
|
---|
| 157 | check_error $? "Unable to create ${DIR}."
|
---|
| 158 | }
|
---|
| 159 |
|
---|
[285589b] | 160 | check_dirs() {
|
---|
| 161 | OUTSIDE="$1"
|
---|
| 162 | BASE="$2"
|
---|
| 163 | ORIGINAL="`pwd`"
|
---|
[a35b458] | 164 |
|
---|
[0f28387] | 165 | mkdir -p "${OUTSIDE}"
|
---|
[a35b458] | 166 |
|
---|
[285589b] | 167 | cd "${OUTSIDE}"
|
---|
| 168 | check_error $? "Unable to change directory to ${OUTSIDE}."
|
---|
| 169 | ABS_OUTSIDE="`pwd`"
|
---|
[a35b458] | 170 |
|
---|
[285589b] | 171 | cd "${BASE}"
|
---|
| 172 | check_error $? "Unable to change directory to ${BASE}."
|
---|
| 173 | ABS_BASE="`pwd`"
|
---|
[a35b458] | 174 |
|
---|
[285589b] | 175 | cd "${ORIGINAL}"
|
---|
| 176 | check_error $? "Unable to change directory to ${ORIGINAL}."
|
---|
[a35b458] | 177 |
|
---|
[285589b] | 178 | BASE_LEN="${#ABS_BASE}"
|
---|
| 179 | OUTSIDE_TRIM="${ABS_OUTSIDE:0:${BASE_LEN}}"
|
---|
[a35b458] | 180 |
|
---|
[285589b] | 181 | if [ "${OUTSIDE_TRIM}" == "${ABS_BASE}" ] ; then
|
---|
| 182 | echo
|
---|
| 183 | echo "CROSS_PREFIX cannot reside within the working directory."
|
---|
[a35b458] | 184 |
|
---|
[285589b] | 185 | exit 5
|
---|
| 186 | fi
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[603c8740] | 189 | prepare() {
|
---|
| 190 | show_dependencies
|
---|
| 191 | show_countdown 10
|
---|
[a35b458] | 192 |
|
---|
[530f2de] | 193 | mkdir -p "${BASEDIR}/downloads"
|
---|
| 194 | cd "${BASEDIR}/downloads"
|
---|
| 195 | check_error $? "Change directory failed."
|
---|
| 196 |
|
---|
[232ec3a1] | 197 | echo ">>> Downloading sources"
|
---|
| 198 | git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION"
|
---|
| 199 | git clone --depth 1 -b "$GDB_BRANCH" "$BINUTILS_GDB_GIT" "gdb-$GDB_VERSION"
|
---|
| 200 | git clone --depth 1 -b "$GCC_BRANCH" "$GCC_GIT" "gcc-$GCC_VERSION"
|
---|
[a35b458] | 201 |
|
---|
[232ec3a1] | 202 | # If the directory already existed, pull upstream changes.
|
---|
| 203 | git -C "binutils-$BINUTILS_VERSION" pull
|
---|
| 204 | git -C "gdb-$GDB_VERSION" pull
|
---|
| 205 | git -C "gcc-$GCC_VERSION" pull
|
---|
[530f2de] | 206 |
|
---|
| 207 | echo ">>> Downloading GCC prerequisites"
|
---|
| 208 | cd "gcc-${GCC_VERSION}"
|
---|
| 209 | ./contrib/download_prerequisites
|
---|
| 210 | cd ..
|
---|
[fd8bf6a] | 211 | }
|
---|
| 212 |
|
---|
[6c9f1a6] | 213 | set_target_from_platform() {
|
---|
| 214 | case "$1" in
|
---|
| 215 | "arm32")
|
---|
[232ec3a1] | 216 | GNU_ARCH="arm"
|
---|
[6c9f1a6] | 217 | ;;
|
---|
| 218 | "ia32")
|
---|
[232ec3a1] | 219 | GNU_ARCH="i686"
|
---|
[6c9f1a6] | 220 | ;;
|
---|
| 221 | "mips32")
|
---|
[232ec3a1] | 222 | GNU_ARCH="mipsel"
|
---|
[6c9f1a6] | 223 | ;;
|
---|
| 224 | "mips32eb")
|
---|
[232ec3a1] | 225 | GNU_ARCH="mips"
|
---|
[6c9f1a6] | 226 | ;;
|
---|
| 227 | "mips64")
|
---|
[232ec3a1] | 228 | GNU_ARCH="mips64el"
|
---|
[6c9f1a6] | 229 | ;;
|
---|
| 230 | "ppc32")
|
---|
[232ec3a1] | 231 | GNU_ARCH="ppc"
|
---|
[6c9f1a6] | 232 | ;;
|
---|
[232ec3a1] | 233 | *)
|
---|
| 234 | GNU_ARCH="$1"
|
---|
[6c9f1a6] | 235 | ;;
|
---|
[232ec3a1] | 236 | esac
|
---|
| 237 |
|
---|
| 238 | HELENOS_TARGET="${GNU_ARCH}-helenos"
|
---|
| 239 |
|
---|
[9e5cc73] | 240 | # TODO: Clean up this mess.
|
---|
[232ec3a1] | 241 | case "$1" in
|
---|
| 242 | "amd64")
|
---|
| 243 | LINUX_TARGET="${GNU_ARCH}-unknown-elf"
|
---|
[d2bd00f0] | 244 | ;;
|
---|
[9e5cc73] | 245 | "ia32" | "ia64")
|
---|
| 246 | LINUX_TARGET="${GNU_ARCH}-pc-linux-gnu"
|
---|
| 247 | ;;
|
---|
[232ec3a1] | 248 | "arm32")
|
---|
| 249 | LINUX_TARGET="${GNU_ARCH}-linux-gnueabi"
|
---|
[6c9f1a6] | 250 | ;;
|
---|
[9e5cc73] | 251 | "riscv64")
|
---|
| 252 | LINUX_TARGET="${GNU_ARCH}-unknown-linux-gnu"
|
---|
| 253 | ;;
|
---|
[6c9f1a6] | 254 | *)
|
---|
[232ec3a1] | 255 | LINUX_TARGET="${GNU_ARCH}-linux-gnu"
|
---|
[6c9f1a6] | 256 | ;;
|
---|
| 257 | esac
|
---|
[fd8bf6a] | 258 | }
|
---|
| 259 |
|
---|
[ff211d2] | 260 | build_target() {
|
---|
| 261 | PLATFORM="$1"
|
---|
[a35b458] | 262 |
|
---|
[5a65d29] | 263 | # This sets the *_TARGET variables
|
---|
[6c9f1a6] | 264 | set_target_from_platform "$PLATFORM"
|
---|
[75b24cd] | 265 | if $USE_HELENOS_TARGET ; then
|
---|
[5a65d29] | 266 | TARGET="$HELENOS_TARGET"
|
---|
| 267 | else
|
---|
| 268 | TARGET="$LINUX_TARGET"
|
---|
| 269 | fi
|
---|
[a35b458] | 270 |
|
---|
[591b989] | 271 | WORKDIR="${BASEDIR}/${TARGET}"
|
---|
| 272 | INSTALL_DIR="${WORKDIR}/PKG"
|
---|
[ff211d2] | 273 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
|
---|
| 274 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
|
---|
[2a922c8] | 275 | GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
|
---|
[a35b458] | 276 |
|
---|
[ff211d2] | 277 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
[603c8740] | 278 | CROSS_PREFIX="/usr/local/cross"
|
---|
[ff211d2] | 279 | fi
|
---|
[a35b458] | 280 |
|
---|
[232ec3a1] | 281 | if [ -z "$JOBS" ] ; then
|
---|
| 282 | JOBS=`nproc`
|
---|
| 283 | fi
|
---|
| 284 |
|
---|
[591b989] | 285 | PREFIX="${CROSS_PREFIX}/${TARGET}"
|
---|
[a35b458] | 286 |
|
---|
[ff211d2] | 287 | echo ">>> Removing previous content"
|
---|
[603c8740] | 288 | cleanup_dir "${WORKDIR}"
|
---|
[530f2de] | 289 | mkdir -p "${WORKDIR}"
|
---|
[285589b] | 290 | check_dirs "${PREFIX}" "${WORKDIR}"
|
---|
[a35b458] | 291 |
|
---|
[232ec3a1] | 292 | if $USE_HELENOS_TARGET ; then
|
---|
| 293 | echo ">>> Creating build sysroot"
|
---|
| 294 | mkdir -p "${WORKDIR}/sysroot/include"
|
---|
| 295 | mkdir "${WORKDIR}/sysroot/lib"
|
---|
| 296 | cp -r -L -t "${WORKDIR}/sysroot/include" \
|
---|
| 297 | ${SRCDIR}/../abi/include/* \
|
---|
| 298 | ${SRCDIR}/../uspace/lib/c/arch/${PLATFORM}/include/* \
|
---|
| 299 | ${SRCDIR}/../uspace/lib/c/include/*
|
---|
| 300 | check_error $? "Failed to create build sysroot."
|
---|
| 301 | fi
|
---|
| 302 |
|
---|
[3fe57ea7] | 303 | echo ">>> Processing binutils (${PLATFORM})"
|
---|
[530f2de] | 304 | mkdir -p "${BINUTILSDIR}"
|
---|
[ff211d2] | 305 | cd "${BINUTILSDIR}"
|
---|
| 306 | check_error $? "Change directory failed."
|
---|
[a35b458] | 307 |
|
---|
[3fe57ea7] | 308 | change_title "binutils: configure (${PLATFORM})"
|
---|
[530f2de] | 309 | CFLAGS=-Wno-error "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \
|
---|
[322ac35c] | 310 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 311 | "--prefix=${PREFIX}" \
|
---|
| 312 | "--program-prefix=${TARGET}-" \
|
---|
| 313 | --disable-nls \
|
---|
| 314 | --disable-werror \
|
---|
| 315 | --enable-gold \
|
---|
| 316 | --enable-deterministic-archives \
|
---|
| 317 | --disable-gdb \
|
---|
| 318 | --with-sysroot
|
---|
[ff211d2] | 319 | check_error $? "Error configuring binutils."
|
---|
[a35b458] | 320 |
|
---|
[3fe57ea7] | 321 | change_title "binutils: make (${PLATFORM})"
|
---|
[232ec3a1] | 322 | make all -j$JOBS
|
---|
[322ac35c] | 323 | check_error $? "Error compiling binutils."
|
---|
[a35b458] | 324 |
|
---|
[322ac35c] | 325 | change_title "binutils: install (${PLATFORM})"
|
---|
[0f28387] | 326 | make install "DESTDIR=${INSTALL_DIR}"
|
---|
[322ac35c] | 327 | check_error $? "Error installing binutils."
|
---|
[a35b458] | 328 |
|
---|
| 329 |
|
---|
[3fe57ea7] | 330 | echo ">>> Processing GCC (${PLATFORM})"
|
---|
[530f2de] | 331 | mkdir -p "${GCCDIR}"
|
---|
| 332 | cd "${GCCDIR}"
|
---|
[ff211d2] | 333 | check_error $? "Change directory failed."
|
---|
[a35b458] | 334 |
|
---|
[232ec3a1] | 335 | if $USE_HELENOS_TARGET ; then
|
---|
| 336 | SYSROOT=--with-sysroot --with-build-sysroot="${WORKDIR}/sysroot"
|
---|
| 337 | else
|
---|
| 338 | SYSROOT=--without-headers
|
---|
| 339 | fi
|
---|
| 340 |
|
---|
[3fe57ea7] | 341 | change_title "GCC: configure (${PLATFORM})"
|
---|
[530f2de] | 342 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \
|
---|
[322ac35c] | 343 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 344 | "--prefix=${PREFIX}" \
|
---|
| 345 | "--program-prefix=${TARGET}-" \
|
---|
| 346 | --with-gnu-as \
|
---|
| 347 | --with-gnu-ld \
|
---|
| 348 | --disable-nls \
|
---|
| 349 | --enable-languages=c,c++,go \
|
---|
| 350 | --enable-lto \
|
---|
| 351 | --disable-shared \
|
---|
| 352 | --disable-werror \
|
---|
| 353 | $SYSROOT
|
---|
[ff211d2] | 354 | check_error $? "Error configuring GCC."
|
---|
[a35b458] | 355 |
|
---|
[3fe57ea7] | 356 | change_title "GCC: make (${PLATFORM})"
|
---|
[232ec3a1] | 357 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc -j$JOBS
|
---|
[322ac35c] | 358 | check_error $? "Error compiling GCC."
|
---|
[a35b458] | 359 |
|
---|
[232ec3a1] | 360 | if $USE_HELENOS_TARGET ; then
|
---|
| 361 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libgcc -j$JOBS
|
---|
| 362 | check_error $? "Error compiling libgcc."
|
---|
| 363 | # TODO: needs some extra care
|
---|
| 364 | #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libatomic -j$JOBS
|
---|
| 365 | #check_error $? "Error compiling libatomic."
|
---|
| 366 | #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libstdc++-v3 -j$JOBS
|
---|
| 367 | #check_error $? "Error compiling libstdc++."
|
---|
| 368 | fi
|
---|
| 369 |
|
---|
[322ac35c] | 370 | change_title "GCC: install (${PLATFORM})"
|
---|
[0f28387] | 371 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
|
---|
[232ec3a1] | 372 | if $USE_HELENOS_TARGET ; then
|
---|
| 373 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libgcc "DESTDIR=${INSTALL_DIR}"
|
---|
| 374 | #PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libatomic "DESTDIR=${INSTALL_DIR}"
|
---|
| 375 | #PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libstdc++-v3 "DESTDIR=${INSTALL_DIR}"
|
---|
| 376 | fi
|
---|
[322ac35c] | 377 | check_error $? "Error installing GCC."
|
---|
[a35b458] | 378 |
|
---|
| 379 |
|
---|
[105fcf0] | 380 | echo ">>> Processing GDB (${PLATFORM})"
|
---|
| 381 | mkdir -p "${GDBDIR}"
|
---|
| 382 | cd "${GDBDIR}"
|
---|
| 383 | check_error $? "Change directory failed."
|
---|
[a35b458] | 384 |
|
---|
[105fcf0] | 385 | change_title "GDB: configure (${PLATFORM})"
|
---|
| 386 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \
|
---|
| 387 | "--target=${TARGET}" \
|
---|
[232ec3a1] | 388 | "--prefix=${PREFIX}" \
|
---|
| 389 | "--program-prefix=${TARGET}-" \
|
---|
| 390 | --enable-werror=no
|
---|
[105fcf0] | 391 | check_error $? "Error configuring GDB."
|
---|
[a35b458] | 392 |
|
---|
[105fcf0] | 393 | change_title "GDB: make (${PLATFORM})"
|
---|
[232ec3a1] | 394 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gdb -j$JOBS
|
---|
[105fcf0] | 395 | check_error $? "Error compiling GDB."
|
---|
[a35b458] | 396 |
|
---|
[105fcf0] | 397 | change_title "GDB: make (${PLATFORM})"
|
---|
[232ec3a1] | 398 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gdb "DESTDIR=${INSTALL_DIR}"
|
---|
[105fcf0] | 399 | check_error $? "Error installing GDB."
|
---|
[a35b458] | 400 |
|
---|
[0f28387] | 401 | # Symlink clang and lld to the install path.
|
---|
[8192d8a] | 402 | CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`"
|
---|
| 403 | LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`"
|
---|
[a35b458] | 404 |
|
---|
[0f28387] | 405 | ln -s $CLANG "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-clang"
|
---|
| 406 | ln -s $LLD "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-ld.lld"
|
---|
[a35b458] | 407 |
|
---|
[0f28387] | 408 | if $REAL_INSTALL ; then
|
---|
| 409 | echo ">>> Moving to the destination directory."
|
---|
| 410 | cleanup_dir "${PREFIX}"
|
---|
| 411 | echo mv "${INSTALL_DIR}/${PREFIX}" "${PREFIX}"
|
---|
| 412 | mv "${INSTALL_DIR}/${PREFIX}" "${PREFIX}"
|
---|
| 413 | fi
|
---|
[a35b458] | 414 |
|
---|
[603c8740] | 415 | cd "${BASEDIR}"
|
---|
[ff211d2] | 416 | check_error $? "Change directory failed."
|
---|
[a35b458] | 417 |
|
---|
[ff211d2] | 418 | echo ">>> Cleaning up"
|
---|
[603c8740] | 419 | cleanup_dir "${WORKDIR}"
|
---|
[a35b458] | 420 |
|
---|
[ff211d2] | 421 | echo
|
---|
| 422 | echo ">>> Cross-compiler for ${TARGET} installed."
|
---|
| 423 | }
|
---|
| 424 |
|
---|
[75b24cd] | 425 | while [ "$#" -gt 1 ] ; do
|
---|
[5a65d29] | 426 | case "$1" in
|
---|
| 427 | --no-install)
|
---|
| 428 | REAL_INSTALL=false
|
---|
| 429 | shift
|
---|
| 430 | ;;
|
---|
| 431 | --helenos-target)
|
---|
| 432 | USE_HELENOS_TARGET=true
|
---|
| 433 | shift
|
---|
| 434 | ;;
|
---|
| 435 | *)
|
---|
| 436 | show_usage
|
---|
| 437 | ;;
|
---|
| 438 | esac
|
---|
| 439 | done
|
---|
[322ac35c] | 440 |
|
---|
[75b24cd] | 441 | if [ "$#" -lt "1" ] ; then
|
---|
[ff211d2] | 442 | show_usage
|
---|
| 443 | fi
|
---|
| 444 |
|
---|
| 445 | case "$1" in
|
---|
[d2bd00f0] | 446 | amd64|arm32|ia32|ia64|mips32|mips32eb|mips64|ppc32|ppc64|riscv64|sparc64)
|
---|
[603c8740] | 447 | prepare
|
---|
[6c9f1a6] | 448 | build_target "$1"
|
---|
[b886b60] | 449 | ;;
|
---|
[ff211d2] | 450 | "all")
|
---|
[603c8740] | 451 | prepare
|
---|
[6c9f1a6] | 452 | build_target "amd64"
|
---|
| 453 | build_target "arm32"
|
---|
| 454 | build_target "ia32"
|
---|
| 455 | build_target "ia64"
|
---|
| 456 | build_target "mips32"
|
---|
| 457 | build_target "mips32eb"
|
---|
| 458 | build_target "mips64"
|
---|
| 459 | build_target "ppc32"
|
---|
| 460 | build_target "ppc64"
|
---|
[d2bd00f0] | 461 | build_target "riscv64"
|
---|
[6c9f1a6] | 462 | build_target "sparc64"
|
---|
[ff211d2] | 463 | ;;
|
---|
[951f6b9e] | 464 | "essential")
|
---|
| 465 | prepare
|
---|
| 466 | build_target "amd64"
|
---|
| 467 | build_target "arm32"
|
---|
| 468 | build_target "ia32"
|
---|
| 469 | build_target "ia64"
|
---|
| 470 | build_target "mips32"
|
---|
| 471 | build_target "mips32eb"
|
---|
| 472 | build_target "ppc32"
|
---|
| 473 | build_target "sparc64"
|
---|
| 474 | ;;
|
---|
[603c8740] | 475 | "parallel")
|
---|
| 476 | prepare
|
---|
[6c9f1a6] | 477 | build_target "amd64" &
|
---|
| 478 | build_target "arm32" &
|
---|
| 479 | build_target "ia32" &
|
---|
| 480 | build_target "ia64" &
|
---|
| 481 | build_target "mips32" &
|
---|
| 482 | build_target "mips32eb" &
|
---|
| 483 | build_target "mips64" &
|
---|
| 484 | build_target "ppc32" &
|
---|
| 485 | build_target "ppc64" &
|
---|
[d2bd00f0] | 486 | build_target "riscv64" &
|
---|
[6c9f1a6] | 487 | build_target "sparc64" &
|
---|
[6abb346] | 488 | wait
|
---|
| 489 | ;;
|
---|
| 490 | "2-way")
|
---|
| 491 | prepare
|
---|
[6c9f1a6] | 492 | build_target "amd64" &
|
---|
| 493 | build_target "arm32" &
|
---|
[6abb346] | 494 | wait
|
---|
[a35b458] | 495 |
|
---|
[6c9f1a6] | 496 | build_target "ia32" &
|
---|
| 497 | build_target "ia64" &
|
---|
[6abb346] | 498 | wait
|
---|
[a35b458] | 499 |
|
---|
[6c9f1a6] | 500 | build_target "mips32" &
|
---|
| 501 | build_target "mips32eb" &
|
---|
[6abb346] | 502 | wait
|
---|
[a35b458] | 503 |
|
---|
[6c9f1a6] | 504 | build_target "mips64" &
|
---|
| 505 | build_target "ppc32" &
|
---|
[6abb346] | 506 | wait
|
---|
[a35b458] | 507 |
|
---|
[d2bd00f0] | 508 | build_target "riscv64" &
|
---|
[6c9f1a6] | 509 | build_target "ppc64" &
|
---|
[d2bd00f0] | 510 | wait
|
---|
[a35b458] | 511 |
|
---|
[6c9f1a6] | 512 | build_target "sparc64" &
|
---|
[b886b60] | 513 | wait
|
---|
[603c8740] | 514 | ;;
|
---|
[ff211d2] | 515 | *)
|
---|
| 516 | show_usage
|
---|
| 517 | ;;
|
---|
| 518 | esac
|
---|