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