[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 |
|
---|
[d249b9d] | 59 | BINUTILS_VERSION="2.26"
|
---|
[145d16f8] | 60 | BINUTILS_RELEASE=""
|
---|
[f6017ee] | 61 | ## BINUTILS_PATCHES="toolchain-binutils-2.23.1.patch"
|
---|
[d249b9d] | 62 | GCC_VERSION="6.1.0"
|
---|
[f6017ee] | 63 | ## GCC_PATCHES="toolchain-gcc-4.8.1-targets.patch toolchain-gcc-4.8.1-headers.patch"
|
---|
[d249b9d] | 64 | GDB_VERSION="7.11"
|
---|
[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 |
|
---|
| 96 | cc -c -o "${FNAME}.o" "${FNAME}.c" 2> "${FNAME}.log"
|
---|
| 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() {
|
---|
| 125 | if [ "$1" -ne "0" ]; then
|
---|
| 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)"
|
---|
| 154 | echo " arm32 ARM"
|
---|
[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"
|
---|
[f2f89315] | 160 | echo " ppc32 32-bit PowerPC"
|
---|
| 161 | echo " ppc64 64-bit PowerPC"
|
---|
| 162 | echo " sparc64 SPARC V9"
|
---|
[ff211d2] | 163 | echo " all build all targets"
|
---|
[6abb346] | 164 | echo " parallel same as 'all', but all in parallel"
|
---|
| 165 | echo " 2-way same as 'all', but 2-way parallel"
|
---|
[ff211d2] | 166 | echo
|
---|
[322ac35c] | 167 | echo "The toolchain is installed into directory specified by the"
|
---|
| 168 | echo "CROSS_PREFIX environment variable. If the variable is not"
|
---|
| 169 | echo "defined, /usr/local/cross/ is used as default."
|
---|
[5a65d29] | 170 | echo
|
---|
[322ac35c] | 171 | echo "If --no-install is present, the toolchain still uses the"
|
---|
| 172 | echo "CROSS_PREFIX as the target directory but the installation"
|
---|
| 173 | echo "copies the files into PKG/ subdirectory without affecting"
|
---|
| 174 | echo "the actual root file system. That is only useful if you do"
|
---|
| 175 | echo "not want to run the script under the super user."
|
---|
[38eaf41] | 176 | echo
|
---|
[5a65d29] | 177 | echo "The --helenos-target will build HelenOS-specific toolchain"
|
---|
| 178 | echo "(i.e. it will use *-helenos-* triplet instead of *-linux-*)."
|
---|
| 179 | echo "This toolchain is installed into /usr/local/cross-helenos by"
|
---|
| 180 | echo "default. The settings can be changed by setting environment"
|
---|
| 181 | echo "variable CROSS_HELENOS_PREFIX."
|
---|
[f3287e5] | 182 | echo "Using the HelenOS-specific toolchain is still an experimental"
|
---|
| 183 | echo "feature that is not fully supported."
|
---|
[38eaf41] | 184 | echo
|
---|
[ff211d2] | 185 |
|
---|
| 186 | exit 3
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[3fe57ea7] | 189 | change_title() {
|
---|
| 190 | echo -en "\e]0;$1\a"
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | show_countdown() {
|
---|
| 194 | TM="$1"
|
---|
| 195 |
|
---|
| 196 | if [ "${TM}" -eq 0 ] ; then
|
---|
| 197 | echo
|
---|
| 198 | return 0
|
---|
| 199 | fi
|
---|
| 200 |
|
---|
| 201 | echo -n "${TM} "
|
---|
| 202 | change_title "${TM}"
|
---|
| 203 | sleep 1
|
---|
| 204 |
|
---|
| 205 | TM="`expr "${TM}" - 1`"
|
---|
| 206 | show_countdown "${TM}"
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | show_dependencies() {
|
---|
| 210 | echo "IMPORTANT NOTICE:"
|
---|
| 211 | echo
|
---|
| 212 | echo "For a successful compilation and use of the cross-compiler"
|
---|
| 213 | echo "toolchain you need at least the following dependencies."
|
---|
| 214 | echo
|
---|
| 215 | echo "Please make sure that the dependencies are present in your"
|
---|
| 216 | echo "system. Otherwise the compilation process might fail after"
|
---|
| 217 | echo "a few seconds or minutes."
|
---|
| 218 | echo
|
---|
| 219 | echo " - SED, AWK, Flex, Bison, gzip, bzip2, Bourne Shell"
|
---|
| 220 | echo " - gettext, zlib, Texinfo, libelf, libgomp"
|
---|
[f6017ee] | 221 | echo " - GNU Make, Coreutils, Sharutils, tar"
|
---|
[3fe57ea7] | 222 | echo " - GNU Multiple Precision Library (GMP)"
|
---|
| 223 | echo " - MPFR"
|
---|
| 224 | echo " - MPC"
|
---|
[f6017ee] | 225 | echo " - integer point manipulation library (isl)"
|
---|
| 226 | echo " - native C and C++ compiler, assembler and linker"
|
---|
| 227 | echo " - native C and C++ standard library with headers"
|
---|
[3fe57ea7] | 228 | echo
|
---|
| 229 | }
|
---|
| 230 |
|
---|
[603c8740] | 231 | download_fetch() {
|
---|
[ff211d2] | 232 | SOURCE="$1"
|
---|
| 233 | FILE="$2"
|
---|
| 234 | CHECKSUM="$3"
|
---|
| 235 |
|
---|
| 236 | if [ ! -f "${FILE}" ]; then
|
---|
[3fe57ea7] | 237 | change_title "Downloading ${FILE}"
|
---|
[ff211d2] | 238 | wget -c "${SOURCE}${FILE}"
|
---|
| 239 | check_error $? "Error downloading ${FILE}."
|
---|
| 240 | fi
|
---|
| 241 |
|
---|
| 242 | check_md5 "${FILE}" "${CHECKSUM}"
|
---|
| 243 | }
|
---|
| 244 |
|
---|
[603c8740] | 245 | source_check() {
|
---|
| 246 | FILE="$1"
|
---|
| 247 |
|
---|
| 248 | if [ ! -f "${FILE}" ]; then
|
---|
| 249 | echo
|
---|
| 250 | echo "File ${FILE} not found."
|
---|
| 251 |
|
---|
| 252 | exit 4
|
---|
| 253 | fi
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[ff211d2] | 256 | cleanup_dir() {
|
---|
| 257 | DIR="$1"
|
---|
| 258 |
|
---|
| 259 | if [ -d "${DIR}" ]; then
|
---|
[3fe57ea7] | 260 | change_title "Removing ${DIR}"
|
---|
[ff211d2] | 261 | echo " >>> Removing ${DIR}"
|
---|
| 262 | rm -fr "${DIR}"
|
---|
| 263 | fi
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | create_dir() {
|
---|
| 267 | DIR="$1"
|
---|
| 268 | DESC="$2"
|
---|
| 269 |
|
---|
[3fe57ea7] | 270 | change_title "Creating ${DESC}"
|
---|
[ff211d2] | 271 | echo ">>> Creating ${DESC}"
|
---|
| 272 |
|
---|
| 273 | mkdir -p "${DIR}"
|
---|
| 274 | test -d "${DIR}"
|
---|
| 275 | check_error $? "Unable to create ${DIR}."
|
---|
| 276 | }
|
---|
| 277 |
|
---|
[285589b] | 278 | check_dirs() {
|
---|
| 279 | OUTSIDE="$1"
|
---|
| 280 | BASE="$2"
|
---|
| 281 | ORIGINAL="`pwd`"
|
---|
| 282 |
|
---|
| 283 | cd "${OUTSIDE}"
|
---|
| 284 | check_error $? "Unable to change directory to ${OUTSIDE}."
|
---|
| 285 | ABS_OUTSIDE="`pwd`"
|
---|
| 286 |
|
---|
| 287 | cd "${BASE}"
|
---|
| 288 | check_error $? "Unable to change directory to ${BASE}."
|
---|
| 289 | ABS_BASE="`pwd`"
|
---|
| 290 |
|
---|
| 291 | cd "${ORIGINAL}"
|
---|
| 292 | check_error $? "Unable to change directory to ${ORIGINAL}."
|
---|
| 293 |
|
---|
| 294 | BASE_LEN="${#ABS_BASE}"
|
---|
| 295 | OUTSIDE_TRIM="${ABS_OUTSIDE:0:${BASE_LEN}}"
|
---|
| 296 |
|
---|
| 297 | if [ "${OUTSIDE_TRIM}" == "${ABS_BASE}" ] ; then
|
---|
| 298 | echo
|
---|
| 299 | echo "CROSS_PREFIX cannot reside within the working directory."
|
---|
| 300 |
|
---|
| 301 | exit 5
|
---|
| 302 | fi
|
---|
| 303 | }
|
---|
| 304 |
|
---|
[ff211d2] | 305 | unpack_tarball() {
|
---|
| 306 | FILE="$1"
|
---|
| 307 | DESC="$2"
|
---|
| 308 |
|
---|
[3fe57ea7] | 309 | change_title "Unpacking ${DESC}"
|
---|
| 310 | echo " >>> Unpacking ${DESC}"
|
---|
[ff211d2] | 311 |
|
---|
[11af58b] | 312 | case "${FILE}" in
|
---|
| 313 | *.gz)
|
---|
| 314 | tar -xzf "${FILE}"
|
---|
| 315 | ;;
|
---|
| 316 | *.xz)
|
---|
| 317 | tar -xJf "${FILE}"
|
---|
| 318 | ;;
|
---|
| 319 | *.bz2)
|
---|
| 320 | tar -xjf "${FILE}"
|
---|
| 321 | ;;
|
---|
| 322 | *)
|
---|
| 323 | check_error 1 "Don't know how to unpack ${DESC}."
|
---|
| 324 | ;;
|
---|
| 325 | esac
|
---|
[ff211d2] | 326 | check_error $? "Error unpacking ${DESC}."
|
---|
| 327 | }
|
---|
| 328 |
|
---|
[5a65d29] | 329 | patch_sources() {
|
---|
| 330 | PATCH_FILE="$1"
|
---|
| 331 | PATCH_STRIP="$2"
|
---|
| 332 | DESC="$3"
|
---|
| 333 |
|
---|
| 334 | change_title "Patching ${DESC}"
|
---|
| 335 | echo " >>> Patching ${DESC} with ${PATCH_FILE}"
|
---|
| 336 |
|
---|
| 337 | patch -t "-p${PATCH_STRIP}" <"$PATCH_FILE"
|
---|
| 338 | check_error $? "Error patching ${DESC}."
|
---|
| 339 | }
|
---|
| 340 |
|
---|
[603c8740] | 341 | prepare() {
|
---|
| 342 | show_dependencies
|
---|
| 343 | check_dependecies
|
---|
| 344 | show_countdown 10
|
---|
[fd8bf6a] | 345 |
|
---|
[603c8740] | 346 | BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
|
---|
| 347 | GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
|
---|
[2a922c8] | 348 | GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/"
|
---|
[603c8740] | 349 |
|
---|
[d249b9d] | 350 | download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "64146a0faa3b411ba774f47d41de239f"
|
---|
| 351 | download_fetch "${GCC_SOURCE}" "${GCC}" "8fb6cb98b8459f5863328380fbf06bd1"
|
---|
| 352 | download_fetch "${GDB_SOURCE}" "${GDB}" "f585059252836a981ea5db9a5f8ce97f"
|
---|
[fd8bf6a] | 353 | }
|
---|
| 354 |
|
---|
[6c9f1a6] | 355 | set_target_from_platform() {
|
---|
| 356 | case "$1" in
|
---|
| 357 | "amd64")
|
---|
[5a65d29] | 358 | LINUX_TARGET="amd64-linux-gnu"
|
---|
| 359 | HELENOS_TARGET="amd64-helenos"
|
---|
[6c9f1a6] | 360 | ;;
|
---|
| 361 | "arm32")
|
---|
[5a65d29] | 362 | LINUX_TARGET="arm-linux-gnueabi"
|
---|
| 363 | HELENOS_TARGET="arm-helenos-gnueabi"
|
---|
[6c9f1a6] | 364 | ;;
|
---|
| 365 | "ia32")
|
---|
[5a65d29] | 366 | LINUX_TARGET="i686-pc-linux-gnu"
|
---|
| 367 | HELENOS_TARGET="i686-pc-helenos"
|
---|
[6c9f1a6] | 368 | ;;
|
---|
| 369 | "ia64")
|
---|
[5a65d29] | 370 | LINUX_TARGET="ia64-pc-linux-gnu"
|
---|
| 371 | HELENOS_TARGET="ia64-pc-helenos"
|
---|
[6c9f1a6] | 372 | ;;
|
---|
| 373 | "mips32")
|
---|
[5a65d29] | 374 | LINUX_TARGET="mipsel-linux-gnu"
|
---|
| 375 | HELENOS_TARGET="mipsel-helenos"
|
---|
[6c9f1a6] | 376 | ;;
|
---|
| 377 | "mips32eb")
|
---|
[5a65d29] | 378 | LINUX_TARGET="mips-linux-gnu"
|
---|
| 379 | HELENOS_TARGET="mips-helenos"
|
---|
[6c9f1a6] | 380 | ;;
|
---|
| 381 | "mips64")
|
---|
[5a65d29] | 382 | LINUX_TARGET="mips64el-linux-gnu"
|
---|
| 383 | HELENOS_TARGET="mips64el-helenos"
|
---|
[6c9f1a6] | 384 | ;;
|
---|
| 385 | "ppc32")
|
---|
[5a65d29] | 386 | LINUX_TARGET="ppc-linux-gnu"
|
---|
| 387 | HELENOS_TARGET="ppc-helenos"
|
---|
[6c9f1a6] | 388 | ;;
|
---|
| 389 | "ppc64")
|
---|
[5a65d29] | 390 | LINUX_TARGET="ppc64-linux-gnu"
|
---|
| 391 | HELENOS_TARGET="ppc64-helenos"
|
---|
[6c9f1a6] | 392 | ;;
|
---|
| 393 | "sparc64")
|
---|
[5a65d29] | 394 | LINUX_TARGET="sparc64-linux-gnu"
|
---|
| 395 | HELENOS_TARGET="sparc64-helenos"
|
---|
[6c9f1a6] | 396 | ;;
|
---|
| 397 | *)
|
---|
| 398 | check_error 1 "No target known for $1."
|
---|
| 399 | ;;
|
---|
| 400 | esac
|
---|
[fd8bf6a] | 401 | }
|
---|
| 402 |
|
---|
[ff211d2] | 403 | build_target() {
|
---|
| 404 | PLATFORM="$1"
|
---|
[5a65d29] | 405 | # This sets the *_TARGET variables
|
---|
[6c9f1a6] | 406 | set_target_from_platform "$PLATFORM"
|
---|
[5a65d29] | 407 | if $USE_HELENOS_TARGET; then
|
---|
| 408 | TARGET="$HELENOS_TARGET"
|
---|
| 409 | else
|
---|
| 410 | TARGET="$LINUX_TARGET"
|
---|
| 411 | fi
|
---|
[ff211d2] | 412 |
|
---|
[603c8740] | 413 | WORKDIR="${BASEDIR}/${PLATFORM}"
|
---|
[ff211d2] | 414 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
|
---|
| 415 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
|
---|
| 416 | OBJDIR="${WORKDIR}/gcc-obj"
|
---|
[2a922c8] | 417 | GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
|
---|
[ff211d2] | 418 |
|
---|
| 419 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
[603c8740] | 420 | CROSS_PREFIX="/usr/local/cross"
|
---|
[ff211d2] | 421 | fi
|
---|
[5a65d29] | 422 | if [ -z "${CROSS_HELENOS_PREFIX}" ] ; then
|
---|
| 423 | CROSS_HELENOS_PREFIX="/usr/local/cross-helenos"
|
---|
| 424 | fi
|
---|
[ff211d2] | 425 |
|
---|
[5a65d29] | 426 | if $USE_HELENOS_TARGET; then
|
---|
| 427 | PREFIX="${CROSS_HELENOS_PREFIX}/${PLATFORM}"
|
---|
| 428 | else
|
---|
| 429 | PREFIX="${CROSS_PREFIX}/${PLATFORM}"
|
---|
| 430 | fi
|
---|
[ff211d2] | 431 |
|
---|
| 432 | echo ">>> Downloading tarballs"
|
---|
[603c8740] | 433 | source_check "${BASEDIR}/${BINUTILS}"
|
---|
[2385952] | 434 | source_check "${BASEDIR}/${GCC}"
|
---|
[2a922c8] | 435 | source_check "${BASEDIR}/${GDB}"
|
---|
[ff211d2] | 436 |
|
---|
| 437 | echo ">>> Removing previous content"
|
---|
[322ac35c] | 438 | $REAL_INSTALL && cleanup_dir "${PREFIX}"
|
---|
[603c8740] | 439 | cleanup_dir "${WORKDIR}"
|
---|
[ff211d2] | 440 |
|
---|
[322ac35c] | 441 | $REAL_INSTALL && create_dir "${PREFIX}" "destination directory"
|
---|
[ff211d2] | 442 | create_dir "${OBJDIR}" "GCC object directory"
|
---|
| 443 |
|
---|
[285589b] | 444 | check_dirs "${PREFIX}" "${WORKDIR}"
|
---|
| 445 |
|
---|
[ff211d2] | 446 | echo ">>> Unpacking tarballs"
|
---|
[603c8740] | 447 | cd "${WORKDIR}"
|
---|
| 448 | check_error $? "Change directory failed."
|
---|
| 449 |
|
---|
| 450 | unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
|
---|
[2385952] | 451 | unpack_tarball "${BASEDIR}/${GCC}" "GCC"
|
---|
[2a922c8] | 452 | unpack_tarball "${BASEDIR}/${GDB}" "GDB"
|
---|
[ff211d2] | 453 |
|
---|
[5a65d29] | 454 | echo ">>> Applying patches"
|
---|
| 455 | for p in $BINUTILS_PATCHES; do
|
---|
[12735849] | 456 | patch_sources "${SRCDIR}/${p}" 0 "binutils"
|
---|
[5a65d29] | 457 | done
|
---|
| 458 | for p in $GCC_PATCHES; do
|
---|
[12735849] | 459 | patch_sources "${SRCDIR}/${p}" 0 "GCC"
|
---|
[5a65d29] | 460 | done
|
---|
| 461 | for p in $GDB_PATCHES; do
|
---|
[12735849] | 462 | patch_sources "${SRCDIR}/${p}" 0 "GDB"
|
---|
[5a65d29] | 463 | done
|
---|
[322ac35c] | 464 |
|
---|
[3fe57ea7] | 465 | echo ">>> Processing binutils (${PLATFORM})"
|
---|
[ff211d2] | 466 | cd "${BINUTILSDIR}"
|
---|
| 467 | check_error $? "Change directory failed."
|
---|
[3fe57ea7] | 468 |
|
---|
| 469 | change_title "binutils: configure (${PLATFORM})"
|
---|
[322ac35c] | 470 | CFLAGS=-Wno-error ./configure \
|
---|
| 471 | "--target=${TARGET}" \
|
---|
| 472 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
|
---|
| 473 | --disable-nls --disable-werror
|
---|
[ff211d2] | 474 | check_error $? "Error configuring binutils."
|
---|
[3fe57ea7] | 475 |
|
---|
| 476 | change_title "binutils: make (${PLATFORM})"
|
---|
[322ac35c] | 477 | make all
|
---|
| 478 | check_error $? "Error compiling binutils."
|
---|
| 479 |
|
---|
| 480 | change_title "binutils: install (${PLATFORM})"
|
---|
| 481 | if $REAL_INSTALL; then
|
---|
| 482 | make install
|
---|
| 483 | else
|
---|
| 484 | make install "DESTDIR=${INSTALL_DIR}"
|
---|
| 485 | fi
|
---|
| 486 | check_error $? "Error installing binutils."
|
---|
| 487 |
|
---|
[ff211d2] | 488 |
|
---|
[3fe57ea7] | 489 | echo ">>> Processing GCC (${PLATFORM})"
|
---|
[ff211d2] | 490 | cd "${OBJDIR}"
|
---|
| 491 | check_error $? "Change directory failed."
|
---|
[3fe57ea7] | 492 |
|
---|
| 493 | change_title "GCC: configure (${PLATFORM})"
|
---|
[322ac35c] | 494 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${GCCDIR}/configure" \
|
---|
| 495 | "--target=${TARGET}" \
|
---|
| 496 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
|
---|
| 497 | --with-gnu-as --with-gnu-ld --disable-nls --disable-threads \
|
---|
| 498 | --enable-languages=c,objc,c++,obj-c++ \
|
---|
| 499 | --disable-multilib --disable-libgcj --without-headers \
|
---|
| 500 | --disable-shared --enable-lto --disable-werror
|
---|
[ff211d2] | 501 | check_error $? "Error configuring GCC."
|
---|
[3fe57ea7] | 502 |
|
---|
| 503 | change_title "GCC: make (${PLATFORM})"
|
---|
[322ac35c] | 504 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc
|
---|
| 505 | check_error $? "Error compiling GCC."
|
---|
| 506 |
|
---|
| 507 | change_title "GCC: install (${PLATFORM})"
|
---|
| 508 | if $REAL_INSTALL; then
|
---|
| 509 | PATH="${PATH}:${PREFIX}/bin" make install-gcc
|
---|
| 510 | else
|
---|
| 511 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
|
---|
| 512 | fi
|
---|
| 513 | check_error $? "Error installing GCC."
|
---|
| 514 |
|
---|
[ff211d2] | 515 |
|
---|
[2a922c8] | 516 | echo ">>> Processing GDB (${PLATFORM})"
|
---|
| 517 | cd "${GDBDIR}"
|
---|
| 518 | check_error $? "Change directory failed."
|
---|
| 519 |
|
---|
| 520 | change_title "GDB: configure (${PLATFORM})"
|
---|
[322ac35c] | 521 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./configure \
|
---|
| 522 | "--target=${TARGET}" \
|
---|
[59649f3] | 523 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
|
---|
| 524 | --enable-werror=no
|
---|
[2a922c8] | 525 | check_error $? "Error configuring GDB."
|
---|
| 526 |
|
---|
| 527 | change_title "GDB: make (${PLATFORM})"
|
---|
[322ac35c] | 528 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all
|
---|
| 529 | check_error $? "Error compiling GDB."
|
---|
| 530 |
|
---|
| 531 | change_title "GDB: make (${PLATFORM})"
|
---|
| 532 | if $REAL_INSTALL; then
|
---|
| 533 | PATH="${PATH}:${PREFIX}/bin" make install
|
---|
| 534 | else
|
---|
| 535 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install "DESTDIR=${INSTALL_DIR}"
|
---|
| 536 | fi
|
---|
| 537 | check_error $? "Error installing GDB."
|
---|
| 538 |
|
---|
[2a922c8] | 539 |
|
---|
[603c8740] | 540 | cd "${BASEDIR}"
|
---|
[ff211d2] | 541 | check_error $? "Change directory failed."
|
---|
| 542 |
|
---|
| 543 | echo ">>> Cleaning up"
|
---|
[603c8740] | 544 | cleanup_dir "${WORKDIR}"
|
---|
[ff211d2] | 545 |
|
---|
| 546 | echo
|
---|
| 547 | echo ">>> Cross-compiler for ${TARGET} installed."
|
---|
| 548 | }
|
---|
| 549 |
|
---|
[5a65d29] | 550 | while [ "$#" -gt 1 ]; do
|
---|
| 551 | case "$1" in
|
---|
| 552 | --no-install)
|
---|
| 553 | REAL_INSTALL=false
|
---|
| 554 | shift
|
---|
| 555 | ;;
|
---|
| 556 | --helenos-target)
|
---|
| 557 | USE_HELENOS_TARGET=true
|
---|
| 558 | shift
|
---|
| 559 | ;;
|
---|
| 560 | *)
|
---|
| 561 | show_usage
|
---|
| 562 | ;;
|
---|
| 563 | esac
|
---|
| 564 | done
|
---|
[322ac35c] | 565 |
|
---|
[ff211d2] | 566 | if [ "$#" -lt "1" ]; then
|
---|
| 567 | show_usage
|
---|
| 568 | fi
|
---|
| 569 |
|
---|
| 570 | case "$1" in
|
---|
[d776329b] | 571 | amd64|arm32|ia32|ia64|mips32|mips32eb|mips64|ppc32|ppc64|sparc64)
|
---|
[603c8740] | 572 | prepare
|
---|
[6c9f1a6] | 573 | build_target "$1"
|
---|
[b886b60] | 574 | ;;
|
---|
[ff211d2] | 575 | "all")
|
---|
[603c8740] | 576 | prepare
|
---|
[6c9f1a6] | 577 | build_target "amd64"
|
---|
| 578 | build_target "arm32"
|
---|
| 579 | build_target "ia32"
|
---|
| 580 | build_target "ia64"
|
---|
| 581 | build_target "mips32"
|
---|
| 582 | build_target "mips32eb"
|
---|
| 583 | build_target "mips64"
|
---|
| 584 | build_target "ppc32"
|
---|
| 585 | build_target "ppc64"
|
---|
| 586 | build_target "sparc64"
|
---|
[ff211d2] | 587 | ;;
|
---|
[603c8740] | 588 | "parallel")
|
---|
| 589 | prepare
|
---|
[6c9f1a6] | 590 | build_target "amd64" &
|
---|
| 591 | build_target "arm32" &
|
---|
| 592 | build_target "ia32" &
|
---|
| 593 | build_target "ia64" &
|
---|
| 594 | build_target "mips32" &
|
---|
| 595 | build_target "mips32eb" &
|
---|
| 596 | build_target "mips64" &
|
---|
| 597 | build_target "ppc32" &
|
---|
| 598 | build_target "ppc64" &
|
---|
| 599 | build_target "sparc64" &
|
---|
[6abb346] | 600 | wait
|
---|
| 601 | ;;
|
---|
| 602 | "2-way")
|
---|
| 603 | prepare
|
---|
[6c9f1a6] | 604 | build_target "amd64" &
|
---|
| 605 | build_target "arm32" &
|
---|
[6abb346] | 606 | wait
|
---|
| 607 |
|
---|
[6c9f1a6] | 608 | build_target "ia32" &
|
---|
| 609 | build_target "ia64" &
|
---|
[6abb346] | 610 | wait
|
---|
| 611 |
|
---|
[6c9f1a6] | 612 | build_target "mips32" &
|
---|
| 613 | build_target "mips32eb" &
|
---|
[6abb346] | 614 | wait
|
---|
| 615 |
|
---|
[6c9f1a6] | 616 | build_target "mips64" &
|
---|
| 617 | build_target "ppc32" &
|
---|
[6abb346] | 618 | wait
|
---|
| 619 |
|
---|
[6c9f1a6] | 620 | build_target "ppc64" &
|
---|
| 621 | build_target "sparc64" &
|
---|
[b886b60] | 622 | wait
|
---|
[603c8740] | 623 | ;;
|
---|
[ff211d2] | 624 | *)
|
---|
| 625 | show_usage
|
---|
| 626 | ;;
|
---|
| 627 | esac
|
---|