[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 |
|
---|
[3f7efa79] | 31 | GMP_MAIN=<<EOF
|
---|
| 32 | #define GCC_GMP_VERSION_NUM(a, b, c) \
|
---|
| 33 | (((a) << 16L) | ((b) << 8) | (c))
|
---|
| 34 |
|
---|
| 35 | #define GCC_GMP_VERSION \
|
---|
| 36 | GCC_GMP_VERSION_NUM(__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL)
|
---|
| 37 |
|
---|
[d7f2cd6] | 38 | #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4, 3, 2)
|
---|
[3f7efa79] | 39 | choke me
|
---|
| 40 | #endif
|
---|
| 41 | EOF
|
---|
| 42 |
|
---|
| 43 | MPFR_MAIN=<<EOF
|
---|
| 44 | #if MPFR_VERSION < MPFR_VERSION_NUM(2, 4, 2)
|
---|
[7d248e3] | 45 | choke me
|
---|
| 46 | #endif
|
---|
[3f7efa79] | 47 | EOF
|
---|
| 48 |
|
---|
| 49 | MPC_MAIN=<<EOF
|
---|
| 50 | #if MPC_VERSION < MPC_VERSION_NUM(0, 8, 1)
|
---|
| 51 | choke me
|
---|
| 52 | #endif
|
---|
| 53 | EOF
|
---|
| 54 |
|
---|
[f6017ee] | 55 | ISL_MAIN=<<EOF
|
---|
| 56 | isl_ctx_get_max_operations (isl_ctx_alloc ());
|
---|
| 57 | EOF
|
---|
| 58 |
|
---|
[d2bd00f0] | 59 | BINUTILS_VERSION="2.28"
|
---|
[145d16f8] | 60 | BINUTILS_RELEASE=""
|
---|
[f6017ee] | 61 | ## BINUTILS_PATCHES="toolchain-binutils-2.23.1.patch"
|
---|
[d2bd00f0] | 62 | GCC_VERSION="7.1.0"
|
---|
[f6017ee] | 63 | ## GCC_PATCHES="toolchain-gcc-4.8.1-targets.patch toolchain-gcc-4.8.1-headers.patch"
|
---|
[3a75cb8] | 64 | GDB_VERSION="7.12.1"
|
---|
[f6017ee] | 65 | ## GDB_PATCHES="toolchain-gdb-7.6.1.patch"
|
---|
[603c8740] | 66 |
|
---|
| 67 | BASEDIR="`pwd`"
|
---|
[12735849] | 68 | SRCDIR="$(readlink -f $(dirname "$0"))"
|
---|
[7e9fce6] | 69 | BINUTILS="binutils-${BINUTILS_VERSION}${BINUTILS_RELEASE}.tar.bz2"
|
---|
[2385952] | 70 | GCC="gcc-${GCC_VERSION}.tar.bz2"
|
---|
[d249b9d] | 71 | GDB="gdb-${GDB_VERSION}.tar.gz"
|
---|
[603c8740] | 72 |
|
---|
[322ac35c] | 73 | REAL_INSTALL=true
|
---|
[5a65d29] | 74 | USE_HELENOS_TARGET=false
|
---|
[322ac35c] | 75 | INSTALL_DIR="${BASEDIR}/PKG"
|
---|
| 76 |
|
---|
[3f7efa79] | 77 | #
|
---|
| 78 | # Check if the library described in the argument
|
---|
| 79 | # exists and has acceptable version.
|
---|
| 80 | #
|
---|
| 81 | check_dependency() {
|
---|
| 82 | DEPENDENCY="$1"
|
---|
| 83 | HEADER="$2"
|
---|
| 84 | BODY="$3"
|
---|
| 85 |
|
---|
| 86 | FNAME="/tmp/conftest-$$"
|
---|
| 87 |
|
---|
| 88 | echo "#include ${HEADER}" > "${FNAME}.c"
|
---|
| 89 | echo >> "${FNAME}.c"
|
---|
| 90 | echo "int main()" >> "${FNAME}.c"
|
---|
| 91 | echo "{" >> "${FNAME}.c"
|
---|
| 92 | echo "${BODY}" >> "${FNAME}.c"
|
---|
| 93 | echo " return 0;" >> "${FNAME}.c"
|
---|
| 94 | echo "}" >> "${FNAME}.c"
|
---|
| 95 |
|
---|
[a4170d5] | 96 | cc $CFLAGS -c -o "${FNAME}.o" "${FNAME}.c" 2> "${FNAME}.log"
|
---|
[3f7efa79] | 97 | RC="$?"
|
---|
| 98 |
|
---|
| 99 | if [ "$RC" -ne "0" ] ; then
|
---|
| 100 | echo " ${DEPENDENCY} not found, too old or compiler error."
|
---|
| 101 | echo " Please recheck manually the source file \"${FNAME}.c\"."
|
---|
| 102 | echo " The compilation of the toolchain is probably going to fail,"
|
---|
| 103 | echo " you have been warned."
|
---|
| 104 | echo
|
---|
| 105 | echo " ===== Compiler output ====="
|
---|
| 106 | cat "${FNAME}.log"
|
---|
| 107 | echo " ==========================="
|
---|
| 108 | echo
|
---|
| 109 | else
|
---|
| 110 | echo " ${DEPENDENCY} found"
|
---|
| 111 | rm -f "${FNAME}.log" "${FNAME}.o" "${FNAME}.c"
|
---|
| 112 | fi
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | check_dependecies() {
|
---|
| 116 | echo ">>> Basic dependency check"
|
---|
| 117 | check_dependency "GMP" "<gmp.h>" "${GMP_MAIN}"
|
---|
| 118 | check_dependency "MPFR" "<mpfr.h>" "${MPFR_MAIN}"
|
---|
| 119 | check_dependency "MPC" "<mpc.h>" "${MPC_MAIN}"
|
---|
[f6017ee] | 120 | check_dependency "isl" "<isl/ctx.h>" "${ISL_MAIN}"
|
---|
[3f7efa79] | 121 | echo
|
---|
| 122 | }
|
---|
| 123 |
|
---|
[ff211d2] | 124 | check_error() {
|
---|
[75b24cd] | 125 | if [ "$1" -ne "0" ] ; then
|
---|
[ff211d2] | 126 | echo
|
---|
| 127 | echo "Script failed: $2"
|
---|
[3fe57ea7] | 128 |
|
---|
[ff211d2] | 129 | exit 1
|
---|
| 130 | fi
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | check_md5() {
|
---|
| 134 | FILE="$1"
|
---|
| 135 | SUM="$2"
|
---|
| 136 |
|
---|
| 137 | COMPUTED="`md5sum "${FILE}" | cut -d' ' -f1`"
|
---|
| 138 | if [ "${SUM}" != "${COMPUTED}" ] ; then
|
---|
| 139 | echo
|
---|
| 140 | echo "Checksum of ${FILE} does not match."
|
---|
[3fe57ea7] | 141 |
|
---|
[ff211d2] | 142 | exit 2
|
---|
| 143 | fi
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | show_usage() {
|
---|
| 147 | echo "Cross-compiler toolchain build script"
|
---|
| 148 | echo
|
---|
| 149 | echo "Syntax:"
|
---|
[5a65d29] | 150 | echo " $0 [--no-install] [--helenos-target] <platform>"
|
---|
[ff211d2] | 151 | echo
|
---|
| 152 | echo "Possible target platforms are:"
|
---|
[f2f89315] | 153 | echo " amd64 AMD64 (x86-64, x64)"
|
---|
[d2bd00f0] | 154 | echo " arm32 ARM 32b"
|
---|
[ff211d2] | 155 | echo " ia32 IA-32 (x86, i386)"
|
---|
| 156 | echo " ia64 IA-64 (Itanium)"
|
---|
[71e3289] | 157 | echo " mips32 MIPS little-endian 32b"
|
---|
| 158 | echo " mips32eb MIPS big-endian 32b"
|
---|
| 159 | echo " mips64 MIPS little-endian 64b"
|
---|
[d2bd00f0] | 160 | echo " ppc32 PowerPC 32b"
|
---|
| 161 | echo " ppc64 PowerPC 64v"
|
---|
| 162 | echo " riscv64 RISC-V 64b"
|
---|
[f2f89315] | 163 | echo " sparc64 SPARC V9"
|
---|
[ff211d2] | 164 | echo " all build all targets"
|
---|
[951f6b9e] | 165 | echo " essential build only targets currently needed for HelenOS development"
|
---|
[6abb346] | 166 | echo " parallel same as 'all', but all in parallel"
|
---|
| 167 | echo " 2-way same as 'all', but 2-way parallel"
|
---|
[ff211d2] | 168 | echo
|
---|
[322ac35c] | 169 | echo "The toolchain is installed into directory specified by the"
|
---|
| 170 | echo "CROSS_PREFIX environment variable. If the variable is not"
|
---|
| 171 | echo "defined, /usr/local/cross/ is used as default."
|
---|
[5a65d29] | 172 | echo
|
---|
[322ac35c] | 173 | echo "If --no-install is present, the toolchain still uses the"
|
---|
| 174 | echo "CROSS_PREFIX as the target directory but the installation"
|
---|
| 175 | echo "copies the files into PKG/ subdirectory without affecting"
|
---|
| 176 | echo "the actual root file system. That is only useful if you do"
|
---|
| 177 | echo "not want to run the script under the super user."
|
---|
[38eaf41] | 178 | echo
|
---|
[5a65d29] | 179 | echo "The --helenos-target will build HelenOS-specific toolchain"
|
---|
| 180 | echo "(i.e. it will use *-helenos-* triplet instead of *-linux-*)."
|
---|
| 181 | echo "This toolchain is installed into /usr/local/cross-helenos by"
|
---|
| 182 | echo "default. The settings can be changed by setting environment"
|
---|
| 183 | echo "variable CROSS_HELENOS_PREFIX."
|
---|
[f3287e5] | 184 | echo "Using the HelenOS-specific toolchain is still an experimental"
|
---|
| 185 | echo "feature that is not fully supported."
|
---|
[38eaf41] | 186 | echo
|
---|
[ff211d2] | 187 |
|
---|
| 188 | exit 3
|
---|
| 189 | }
|
---|
| 190 |
|
---|
[3fe57ea7] | 191 | change_title() {
|
---|
| 192 | echo -en "\e]0;$1\a"
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | show_countdown() {
|
---|
| 196 | TM="$1"
|
---|
| 197 |
|
---|
| 198 | if [ "${TM}" -eq 0 ] ; then
|
---|
| 199 | echo
|
---|
| 200 | return 0
|
---|
| 201 | fi
|
---|
| 202 |
|
---|
| 203 | echo -n "${TM} "
|
---|
| 204 | change_title "${TM}"
|
---|
| 205 | sleep 1
|
---|
| 206 |
|
---|
| 207 | TM="`expr "${TM}" - 1`"
|
---|
| 208 | show_countdown "${TM}"
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | show_dependencies() {
|
---|
| 212 | echo "IMPORTANT NOTICE:"
|
---|
| 213 | echo
|
---|
| 214 | echo "For a successful compilation and use of the cross-compiler"
|
---|
| 215 | echo "toolchain you need at least the following dependencies."
|
---|
| 216 | echo
|
---|
| 217 | echo "Please make sure that the dependencies are present in your"
|
---|
| 218 | echo "system. Otherwise the compilation process might fail after"
|
---|
| 219 | echo "a few seconds or minutes."
|
---|
| 220 | echo
|
---|
| 221 | echo " - SED, AWK, Flex, Bison, gzip, bzip2, Bourne Shell"
|
---|
| 222 | echo " - gettext, zlib, Texinfo, libelf, libgomp"
|
---|
[f6017ee] | 223 | echo " - GNU Make, Coreutils, Sharutils, tar"
|
---|
[3fe57ea7] | 224 | echo " - GNU Multiple Precision Library (GMP)"
|
---|
| 225 | echo " - MPFR"
|
---|
| 226 | echo " - MPC"
|
---|
[f6017ee] | 227 | echo " - integer point manipulation library (isl)"
|
---|
| 228 | echo " - native C and C++ compiler, assembler and linker"
|
---|
| 229 | echo " - native C and C++ standard library with headers"
|
---|
[3fe57ea7] | 230 | echo
|
---|
| 231 | }
|
---|
| 232 |
|
---|
[603c8740] | 233 | download_fetch() {
|
---|
[ff211d2] | 234 | SOURCE="$1"
|
---|
| 235 | FILE="$2"
|
---|
| 236 | CHECKSUM="$3"
|
---|
| 237 |
|
---|
[75b24cd] | 238 | if [ ! -f "${FILE}" ] ; then
|
---|
[3fe57ea7] | 239 | change_title "Downloading ${FILE}"
|
---|
[ff211d2] | 240 | wget -c "${SOURCE}${FILE}"
|
---|
| 241 | check_error $? "Error downloading ${FILE}."
|
---|
| 242 | fi
|
---|
| 243 |
|
---|
| 244 | check_md5 "${FILE}" "${CHECKSUM}"
|
---|
| 245 | }
|
---|
| 246 |
|
---|
[603c8740] | 247 | source_check() {
|
---|
| 248 | FILE="$1"
|
---|
| 249 |
|
---|
[75b24cd] | 250 | if [ ! -f "${FILE}" ] ; then
|
---|
[603c8740] | 251 | echo
|
---|
| 252 | echo "File ${FILE} not found."
|
---|
| 253 |
|
---|
| 254 | exit 4
|
---|
| 255 | fi
|
---|
| 256 | }
|
---|
| 257 |
|
---|
[ff211d2] | 258 | cleanup_dir() {
|
---|
| 259 | DIR="$1"
|
---|
| 260 |
|
---|
[75b24cd] | 261 | if [ -d "${DIR}" ] ; then
|
---|
[3fe57ea7] | 262 | change_title "Removing ${DIR}"
|
---|
[ff211d2] | 263 | echo " >>> Removing ${DIR}"
|
---|
| 264 | rm -fr "${DIR}"
|
---|
| 265 | fi
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | create_dir() {
|
---|
| 269 | DIR="$1"
|
---|
| 270 | DESC="$2"
|
---|
| 271 |
|
---|
[3fe57ea7] | 272 | change_title "Creating ${DESC}"
|
---|
[ff211d2] | 273 | echo ">>> Creating ${DESC}"
|
---|
| 274 |
|
---|
| 275 | mkdir -p "${DIR}"
|
---|
| 276 | test -d "${DIR}"
|
---|
| 277 | check_error $? "Unable to create ${DIR}."
|
---|
| 278 | }
|
---|
| 279 |
|
---|
[285589b] | 280 | check_dirs() {
|
---|
| 281 | OUTSIDE="$1"
|
---|
| 282 | BASE="$2"
|
---|
| 283 | ORIGINAL="`pwd`"
|
---|
| 284 |
|
---|
| 285 | cd "${OUTSIDE}"
|
---|
| 286 | check_error $? "Unable to change directory to ${OUTSIDE}."
|
---|
| 287 | ABS_OUTSIDE="`pwd`"
|
---|
| 288 |
|
---|
| 289 | cd "${BASE}"
|
---|
| 290 | check_error $? "Unable to change directory to ${BASE}."
|
---|
| 291 | ABS_BASE="`pwd`"
|
---|
| 292 |
|
---|
| 293 | cd "${ORIGINAL}"
|
---|
| 294 | check_error $? "Unable to change directory to ${ORIGINAL}."
|
---|
| 295 |
|
---|
| 296 | BASE_LEN="${#ABS_BASE}"
|
---|
| 297 | OUTSIDE_TRIM="${ABS_OUTSIDE:0:${BASE_LEN}}"
|
---|
| 298 |
|
---|
| 299 | if [ "${OUTSIDE_TRIM}" == "${ABS_BASE}" ] ; then
|
---|
| 300 | echo
|
---|
| 301 | echo "CROSS_PREFIX cannot reside within the working directory."
|
---|
| 302 |
|
---|
| 303 | exit 5
|
---|
| 304 | fi
|
---|
| 305 | }
|
---|
| 306 |
|
---|
[ff211d2] | 307 | unpack_tarball() {
|
---|
| 308 | FILE="$1"
|
---|
| 309 | DESC="$2"
|
---|
| 310 |
|
---|
[3fe57ea7] | 311 | change_title "Unpacking ${DESC}"
|
---|
| 312 | echo " >>> Unpacking ${DESC}"
|
---|
[ff211d2] | 313 |
|
---|
[11af58b] | 314 | case "${FILE}" in
|
---|
| 315 | *.gz)
|
---|
| 316 | tar -xzf "${FILE}"
|
---|
| 317 | ;;
|
---|
| 318 | *.xz)
|
---|
| 319 | tar -xJf "${FILE}"
|
---|
| 320 | ;;
|
---|
| 321 | *.bz2)
|
---|
| 322 | tar -xjf "${FILE}"
|
---|
| 323 | ;;
|
---|
| 324 | *)
|
---|
| 325 | check_error 1 "Don't know how to unpack ${DESC}."
|
---|
| 326 | ;;
|
---|
| 327 | esac
|
---|
[ff211d2] | 328 | check_error $? "Error unpacking ${DESC}."
|
---|
| 329 | }
|
---|
| 330 |
|
---|
[5a65d29] | 331 | patch_sources() {
|
---|
| 332 | PATCH_FILE="$1"
|
---|
| 333 | PATCH_STRIP="$2"
|
---|
| 334 | DESC="$3"
|
---|
| 335 |
|
---|
| 336 | change_title "Patching ${DESC}"
|
---|
| 337 | echo " >>> Patching ${DESC} with ${PATCH_FILE}"
|
---|
| 338 |
|
---|
| 339 | patch -t "-p${PATCH_STRIP}" <"$PATCH_FILE"
|
---|
| 340 | check_error $? "Error patching ${DESC}."
|
---|
| 341 | }
|
---|
| 342 |
|
---|
[603c8740] | 343 | prepare() {
|
---|
| 344 | show_dependencies
|
---|
| 345 | check_dependecies
|
---|
| 346 | show_countdown 10
|
---|
[fd8bf6a] | 347 |
|
---|
[603c8740] | 348 | BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
|
---|
| 349 | GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
|
---|
[2a922c8] | 350 | GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/"
|
---|
[603c8740] | 351 |
|
---|
[d2bd00f0] | 352 | download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "9e8340c96626b469a603c15c9d843727"
|
---|
| 353 | download_fetch "${GCC_SOURCE}" "${GCC}" "6bf56a2bca9dac9dbbf8e8d1036964a8"
|
---|
[3a75cb8] | 354 | download_fetch "${GDB_SOURCE}" "${GDB}" "06c8f40521ed65fe36ebc2be29b56942"
|
---|
[fd8bf6a] | 355 | }
|
---|
| 356 |
|
---|
[6c9f1a6] | 357 | set_target_from_platform() {
|
---|
| 358 | case "$1" in
|
---|
| 359 | "amd64")
|
---|
[5a65d29] | 360 | LINUX_TARGET="amd64-linux-gnu"
|
---|
| 361 | HELENOS_TARGET="amd64-helenos"
|
---|
[6c9f1a6] | 362 | ;;
|
---|
| 363 | "arm32")
|
---|
[5a65d29] | 364 | LINUX_TARGET="arm-linux-gnueabi"
|
---|
| 365 | HELENOS_TARGET="arm-helenos-gnueabi"
|
---|
[6c9f1a6] | 366 | ;;
|
---|
| 367 | "ia32")
|
---|
[5a65d29] | 368 | LINUX_TARGET="i686-pc-linux-gnu"
|
---|
| 369 | HELENOS_TARGET="i686-pc-helenos"
|
---|
[6c9f1a6] | 370 | ;;
|
---|
| 371 | "ia64")
|
---|
[5a65d29] | 372 | LINUX_TARGET="ia64-pc-linux-gnu"
|
---|
| 373 | HELENOS_TARGET="ia64-pc-helenos"
|
---|
[6c9f1a6] | 374 | ;;
|
---|
| 375 | "mips32")
|
---|
[5a65d29] | 376 | LINUX_TARGET="mipsel-linux-gnu"
|
---|
| 377 | HELENOS_TARGET="mipsel-helenos"
|
---|
[6c9f1a6] | 378 | ;;
|
---|
| 379 | "mips32eb")
|
---|
[5a65d29] | 380 | LINUX_TARGET="mips-linux-gnu"
|
---|
| 381 | HELENOS_TARGET="mips-helenos"
|
---|
[6c9f1a6] | 382 | ;;
|
---|
| 383 | "mips64")
|
---|
[5a65d29] | 384 | LINUX_TARGET="mips64el-linux-gnu"
|
---|
| 385 | HELENOS_TARGET="mips64el-helenos"
|
---|
[6c9f1a6] | 386 | ;;
|
---|
| 387 | "ppc32")
|
---|
[5a65d29] | 388 | LINUX_TARGET="ppc-linux-gnu"
|
---|
| 389 | HELENOS_TARGET="ppc-helenos"
|
---|
[6c9f1a6] | 390 | ;;
|
---|
| 391 | "ppc64")
|
---|
[5a65d29] | 392 | LINUX_TARGET="ppc64-linux-gnu"
|
---|
| 393 | HELENOS_TARGET="ppc64-helenos"
|
---|
[6c9f1a6] | 394 | ;;
|
---|
[d2bd00f0] | 395 | "riscv64")
|
---|
| 396 | LINUX_TARGET="riscv64-unknown-linux-gnu"
|
---|
| 397 | HELENOS_TARGET="riscv64-helenos"
|
---|
| 398 | ;;
|
---|
[6c9f1a6] | 399 | "sparc64")
|
---|
[5a65d29] | 400 | LINUX_TARGET="sparc64-linux-gnu"
|
---|
| 401 | HELENOS_TARGET="sparc64-helenos"
|
---|
[6c9f1a6] | 402 | ;;
|
---|
| 403 | *)
|
---|
| 404 | check_error 1 "No target known for $1."
|
---|
| 405 | ;;
|
---|
| 406 | esac
|
---|
[fd8bf6a] | 407 | }
|
---|
| 408 |
|
---|
[ff211d2] | 409 | build_target() {
|
---|
| 410 | PLATFORM="$1"
|
---|
[75b24cd] | 411 |
|
---|
[5a65d29] | 412 | # This sets the *_TARGET variables
|
---|
[6c9f1a6] | 413 | set_target_from_platform "$PLATFORM"
|
---|
[75b24cd] | 414 | if $USE_HELENOS_TARGET ; then
|
---|
[5a65d29] | 415 | TARGET="$HELENOS_TARGET"
|
---|
| 416 | else
|
---|
| 417 | TARGET="$LINUX_TARGET"
|
---|
| 418 | fi
|
---|
[ff211d2] | 419 |
|
---|
[603c8740] | 420 | WORKDIR="${BASEDIR}/${PLATFORM}"
|
---|
[ff211d2] | 421 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
|
---|
| 422 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
|
---|
| 423 | OBJDIR="${WORKDIR}/gcc-obj"
|
---|
[2a922c8] | 424 | GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
|
---|
[ff211d2] | 425 |
|
---|
| 426 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
[603c8740] | 427 | CROSS_PREFIX="/usr/local/cross"
|
---|
[ff211d2] | 428 | fi
|
---|
[5a65d29] | 429 | if [ -z "${CROSS_HELENOS_PREFIX}" ] ; then
|
---|
| 430 | CROSS_HELENOS_PREFIX="/usr/local/cross-helenos"
|
---|
| 431 | fi
|
---|
[ff211d2] | 432 |
|
---|
[75b24cd] | 433 | if $USE_HELENOS_TARGET ; then
|
---|
[5a65d29] | 434 | PREFIX="${CROSS_HELENOS_PREFIX}/${PLATFORM}"
|
---|
| 435 | else
|
---|
| 436 | PREFIX="${CROSS_PREFIX}/${PLATFORM}"
|
---|
| 437 | fi
|
---|
[ff211d2] | 438 |
|
---|
| 439 | echo ">>> Downloading tarballs"
|
---|
[603c8740] | 440 | source_check "${BASEDIR}/${BINUTILS}"
|
---|
[2385952] | 441 | source_check "${BASEDIR}/${GCC}"
|
---|
[2a922c8] | 442 | source_check "${BASEDIR}/${GDB}"
|
---|
[ff211d2] | 443 |
|
---|
| 444 | echo ">>> Removing previous content"
|
---|
[322ac35c] | 445 | $REAL_INSTALL && cleanup_dir "${PREFIX}"
|
---|
[603c8740] | 446 | cleanup_dir "${WORKDIR}"
|
---|
[ff211d2] | 447 |
|
---|
[322ac35c] | 448 | $REAL_INSTALL && create_dir "${PREFIX}" "destination directory"
|
---|
[ff211d2] | 449 | create_dir "${OBJDIR}" "GCC object directory"
|
---|
| 450 |
|
---|
[285589b] | 451 | check_dirs "${PREFIX}" "${WORKDIR}"
|
---|
| 452 |
|
---|
[ff211d2] | 453 | echo ">>> Unpacking tarballs"
|
---|
[603c8740] | 454 | cd "${WORKDIR}"
|
---|
| 455 | check_error $? "Change directory failed."
|
---|
| 456 |
|
---|
| 457 | unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
|
---|
[2385952] | 458 | unpack_tarball "${BASEDIR}/${GCC}" "GCC"
|
---|
[2a922c8] | 459 | unpack_tarball "${BASEDIR}/${GDB}" "GDB"
|
---|
[ff211d2] | 460 |
|
---|
[5a65d29] | 461 | echo ">>> Applying patches"
|
---|
[75b24cd] | 462 | for p in $BINUTILS_PATCHES ; do
|
---|
[12735849] | 463 | patch_sources "${SRCDIR}/${p}" 0 "binutils"
|
---|
[5a65d29] | 464 | done
|
---|
[75b24cd] | 465 | for p in $GCC_PATCHES ; do
|
---|
[12735849] | 466 | patch_sources "${SRCDIR}/${p}" 0 "GCC"
|
---|
[5a65d29] | 467 | done
|
---|
[75b24cd] | 468 | for p in $GDB_PATCHES ; do
|
---|
[12735849] | 469 | patch_sources "${SRCDIR}/${p}" 0 "GDB"
|
---|
[5a65d29] | 470 | done
|
---|
[322ac35c] | 471 |
|
---|
[3fe57ea7] | 472 | echo ">>> Processing binutils (${PLATFORM})"
|
---|
[ff211d2] | 473 | cd "${BINUTILSDIR}"
|
---|
| 474 | check_error $? "Change directory failed."
|
---|
[3fe57ea7] | 475 |
|
---|
| 476 | change_title "binutils: configure (${PLATFORM})"
|
---|
[322ac35c] | 477 | CFLAGS=-Wno-error ./configure \
|
---|
| 478 | "--target=${TARGET}" \
|
---|
| 479 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
|
---|
| 480 | --disable-nls --disable-werror
|
---|
[ff211d2] | 481 | check_error $? "Error configuring binutils."
|
---|
[3fe57ea7] | 482 |
|
---|
| 483 | change_title "binutils: make (${PLATFORM})"
|
---|
[322ac35c] | 484 | make all
|
---|
| 485 | check_error $? "Error compiling binutils."
|
---|
| 486 |
|
---|
| 487 | change_title "binutils: install (${PLATFORM})"
|
---|
[75b24cd] | 488 | if $REAL_INSTALL ; then
|
---|
[322ac35c] | 489 | make install
|
---|
| 490 | else
|
---|
| 491 | make install "DESTDIR=${INSTALL_DIR}"
|
---|
| 492 | fi
|
---|
| 493 | check_error $? "Error installing binutils."
|
---|
| 494 |
|
---|
[ff211d2] | 495 |
|
---|
[3fe57ea7] | 496 | echo ">>> Processing GCC (${PLATFORM})"
|
---|
[ff211d2] | 497 | cd "${OBJDIR}"
|
---|
| 498 | check_error $? "Change directory failed."
|
---|
[3fe57ea7] | 499 |
|
---|
| 500 | change_title "GCC: configure (${PLATFORM})"
|
---|
[322ac35c] | 501 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${GCCDIR}/configure" \
|
---|
| 502 | "--target=${TARGET}" \
|
---|
| 503 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
|
---|
| 504 | --with-gnu-as --with-gnu-ld --disable-nls --disable-threads \
|
---|
| 505 | --enable-languages=c,objc,c++,obj-c++ \
|
---|
| 506 | --disable-multilib --disable-libgcj --without-headers \
|
---|
| 507 | --disable-shared --enable-lto --disable-werror
|
---|
[ff211d2] | 508 | check_error $? "Error configuring GCC."
|
---|
[3fe57ea7] | 509 |
|
---|
| 510 | change_title "GCC: make (${PLATFORM})"
|
---|
[322ac35c] | 511 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc
|
---|
| 512 | check_error $? "Error compiling GCC."
|
---|
| 513 |
|
---|
| 514 | change_title "GCC: install (${PLATFORM})"
|
---|
[75b24cd] | 515 | if $REAL_INSTALL ; then
|
---|
[322ac35c] | 516 | PATH="${PATH}:${PREFIX}/bin" make install-gcc
|
---|
| 517 | else
|
---|
| 518 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
|
---|
| 519 | fi
|
---|
| 520 | check_error $? "Error installing GCC."
|
---|
| 521 |
|
---|
[ff211d2] | 522 |
|
---|
[d2bd00f0] | 523 | # No GDB support for RISC-V so far
|
---|
| 524 | if [ "$PLATFORM" != "riscv64" ] ; then
|
---|
| 525 | echo ">>> Processing GDB (${PLATFORM})"
|
---|
| 526 | cd "${GDBDIR}"
|
---|
| 527 | check_error $? "Change directory failed."
|
---|
| 528 |
|
---|
| 529 | change_title "GDB: configure (${PLATFORM})"
|
---|
| 530 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./configure \
|
---|
| 531 | "--target=${TARGET}" \
|
---|
| 532 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
|
---|
| 533 | --enable-werror=no
|
---|
| 534 | check_error $? "Error configuring GDB."
|
---|
| 535 |
|
---|
| 536 | change_title "GDB: make (${PLATFORM})"
|
---|
| 537 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all
|
---|
| 538 | check_error $? "Error compiling GDB."
|
---|
| 539 |
|
---|
| 540 | change_title "GDB: make (${PLATFORM})"
|
---|
| 541 | if $REAL_INSTALL ; then
|
---|
| 542 | PATH="${PATH}:${PREFIX}/bin" make install
|
---|
| 543 | else
|
---|
| 544 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install "DESTDIR=${INSTALL_DIR}"
|
---|
| 545 | fi
|
---|
| 546 | check_error $? "Error installing GDB."
|
---|
[322ac35c] | 547 | fi
|
---|
| 548 |
|
---|
[2a922c8] | 549 |
|
---|
[603c8740] | 550 | cd "${BASEDIR}"
|
---|
[ff211d2] | 551 | check_error $? "Change directory failed."
|
---|
| 552 |
|
---|
| 553 | echo ">>> Cleaning up"
|
---|
[603c8740] | 554 | cleanup_dir "${WORKDIR}"
|
---|
[ff211d2] | 555 |
|
---|
| 556 | echo
|
---|
| 557 | echo ">>> Cross-compiler for ${TARGET} installed."
|
---|
| 558 | }
|
---|
| 559 |
|
---|
[75b24cd] | 560 | while [ "$#" -gt 1 ] ; do
|
---|
[5a65d29] | 561 | case "$1" in
|
---|
| 562 | --no-install)
|
---|
| 563 | REAL_INSTALL=false
|
---|
| 564 | shift
|
---|
| 565 | ;;
|
---|
| 566 | --helenos-target)
|
---|
| 567 | USE_HELENOS_TARGET=true
|
---|
| 568 | shift
|
---|
| 569 | ;;
|
---|
| 570 | *)
|
---|
| 571 | show_usage
|
---|
| 572 | ;;
|
---|
| 573 | esac
|
---|
| 574 | done
|
---|
[322ac35c] | 575 |
|
---|
[75b24cd] | 576 | if [ "$#" -lt "1" ] ; then
|
---|
[ff211d2] | 577 | show_usage
|
---|
| 578 | fi
|
---|
| 579 |
|
---|
| 580 | case "$1" in
|
---|
[d2bd00f0] | 581 | amd64|arm32|ia32|ia64|mips32|mips32eb|mips64|ppc32|ppc64|riscv64|sparc64)
|
---|
[603c8740] | 582 | prepare
|
---|
[6c9f1a6] | 583 | build_target "$1"
|
---|
[b886b60] | 584 | ;;
|
---|
[ff211d2] | 585 | "all")
|
---|
[603c8740] | 586 | prepare
|
---|
[6c9f1a6] | 587 | build_target "amd64"
|
---|
| 588 | build_target "arm32"
|
---|
| 589 | build_target "ia32"
|
---|
| 590 | build_target "ia64"
|
---|
| 591 | build_target "mips32"
|
---|
| 592 | build_target "mips32eb"
|
---|
| 593 | build_target "mips64"
|
---|
| 594 | build_target "ppc32"
|
---|
| 595 | build_target "ppc64"
|
---|
[d2bd00f0] | 596 | build_target "riscv64"
|
---|
[6c9f1a6] | 597 | build_target "sparc64"
|
---|
[ff211d2] | 598 | ;;
|
---|
[951f6b9e] | 599 | "essential")
|
---|
| 600 | prepare
|
---|
| 601 | build_target "amd64"
|
---|
| 602 | build_target "arm32"
|
---|
| 603 | build_target "ia32"
|
---|
| 604 | build_target "ia64"
|
---|
| 605 | build_target "mips32"
|
---|
| 606 | build_target "mips32eb"
|
---|
| 607 | build_target "ppc32"
|
---|
| 608 | build_target "sparc64"
|
---|
| 609 | ;;
|
---|
[603c8740] | 610 | "parallel")
|
---|
| 611 | prepare
|
---|
[6c9f1a6] | 612 | build_target "amd64" &
|
---|
| 613 | build_target "arm32" &
|
---|
| 614 | build_target "ia32" &
|
---|
| 615 | build_target "ia64" &
|
---|
| 616 | build_target "mips32" &
|
---|
| 617 | build_target "mips32eb" &
|
---|
| 618 | build_target "mips64" &
|
---|
| 619 | build_target "ppc32" &
|
---|
| 620 | build_target "ppc64" &
|
---|
[d2bd00f0] | 621 | build_target "riscv64" &
|
---|
[6c9f1a6] | 622 | build_target "sparc64" &
|
---|
[6abb346] | 623 | wait
|
---|
| 624 | ;;
|
---|
| 625 | "2-way")
|
---|
| 626 | prepare
|
---|
[6c9f1a6] | 627 | build_target "amd64" &
|
---|
| 628 | build_target "arm32" &
|
---|
[6abb346] | 629 | wait
|
---|
| 630 |
|
---|
[6c9f1a6] | 631 | build_target "ia32" &
|
---|
| 632 | build_target "ia64" &
|
---|
[6abb346] | 633 | wait
|
---|
| 634 |
|
---|
[6c9f1a6] | 635 | build_target "mips32" &
|
---|
| 636 | build_target "mips32eb" &
|
---|
[6abb346] | 637 | wait
|
---|
| 638 |
|
---|
[6c9f1a6] | 639 | build_target "mips64" &
|
---|
| 640 | build_target "ppc32" &
|
---|
[6abb346] | 641 | wait
|
---|
| 642 |
|
---|
[d2bd00f0] | 643 | build_target "riscv64" &
|
---|
[6c9f1a6] | 644 | build_target "ppc64" &
|
---|
[d2bd00f0] | 645 | wait
|
---|
| 646 |
|
---|
[6c9f1a6] | 647 | build_target "sparc64" &
|
---|
[b886b60] | 648 | wait
|
---|
[603c8740] | 649 | ;;
|
---|
[ff211d2] | 650 | *)
|
---|
| 651 | show_usage
|
---|
| 652 | ;;
|
---|
| 653 | esac
|
---|