Changeset 4c14b88 in mainline for tools/toolchain.sh


Ignore:
Timestamp:
2013-12-31T07:57:14Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b973dc
Parents:
6297465 (diff), 208b5f5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/toolchain.sh

    r6297465 r4c14b88  
    3636        GCC_GMP_VERSION_NUM(__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL)
    3737
    38 #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,2)
     38#if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4, 3, 2)
    3939        choke me
    4040#endif
     
    5555BINUTILS_VERSION="2.23.1"
    5656BINUTILS_RELEASE=""
     57BINUTILS_PATCHES="toolchain-binutils-2.23.1.patch"
    5758GCC_VERSION="4.8.1"
    58 GDB_VERSION="7.6"
     59GCC_PATCHES="toolchain-gcc-4.8.1-targets.patch toolchain-gcc-4.8.1-headers.patch"
     60GDB_VERSION="7.6.1"
     61GDB_PATCHES="toolchain-gdb-7.6.1.patch"
    5962
    6063BASEDIR="`pwd`"
     64SRCDIR="$(readlink -f $(dirname "$0"))"
    6165BINUTILS="binutils-${BINUTILS_VERSION}${BINUTILS_RELEASE}.tar.bz2"
    6266GCC="gcc-${GCC_VERSION}.tar.bz2"
    6367GDB="gdb-${GDB_VERSION}.tar.bz2"
     68
     69REAL_INSTALL=true
     70USE_HELENOS_TARGET=false
     71INSTALL_DIR="${BASEDIR}/PKG"
    6472
    6573#
     
    135143        echo
    136144        echo "Syntax:"
    137         echo " $0 <platform>"
     145        echo " $0 [--no-install] [--helenos-target] <platform>"
    138146        echo
    139147        echo "Possible target platforms are:"
     
    147155        echo " ppc32      32-bit PowerPC"
    148156        echo " ppc64      64-bit PowerPC"
     157        echo " sparc32    SPARC V8"
    149158        echo " sparc64    SPARC V9"
    150159        echo " all        build all targets"
     
    152161        echo " 2-way      same as 'all', but 2-way parallel"
    153162        echo
    154         echo "The toolchain will be installed to the directory specified by"
    155         echo "the CROSS_PREFIX environment variable. If the variable is not"
    156         echo "defined, /usr/local/cross will be used by default."
     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."
     166        echo
     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."
     172        echo
     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."
     178        echo "Using the HelenOS-specific toolchain is still an experimental"
     179        echo "feature that is not fully supported."
    157180        echo
    158181       
     
    292315}
    293316
     317patch_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
    294329prepare() {
    295330        show_dependencies
     
    303338        download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "33adb18c3048d057ac58d07a3f1adb38"
    304339        download_fetch "${GCC_SOURCE}" "${GCC}" "3b2386c114cd74185aa3754b58a79304"
    305         download_fetch "${GDB_SOURCE}" "${GDB}" "fda57170e4d11cdde74259ca575412a8"
     340        download_fetch "${GDB_SOURCE}" "${GDB}" "fbc4dab4181e6e9937075b43a4ce2732"
     341}
     342
     343set_target_from_platform() {
     344        case "$1" in
     345                "amd64")
     346                        LINUX_TARGET="amd64-linux-gnu"
     347                        HELENOS_TARGET="amd64-helenos"
     348                        ;;
     349                "arm32")
     350                        LINUX_TARGET="arm-linux-gnueabi"
     351                        HELENOS_TARGET="arm-helenos-gnueabi"
     352                        ;;
     353                "ia32")
     354                        LINUX_TARGET="i686-pc-linux-gnu"
     355                        HELENOS_TARGET="i686-pc-helenos"
     356                        ;;
     357                "ia64")
     358                        LINUX_TARGET="ia64-pc-linux-gnu"
     359                        HELENOS_TARGET="ia64-pc-helenos"
     360                        ;;
     361                "mips32")
     362                        LINUX_TARGET="mipsel-linux-gnu"
     363                        HELENOS_TARGET="mipsel-helenos"
     364                        ;;
     365                "mips32eb")
     366                        LINUX_TARGET="mips-linux-gnu"
     367                        HELENOS_TARGET="mips-helenos"
     368                        ;;
     369                "mips64")
     370                        LINUX_TARGET="mips64el-linux-gnu"
     371                        HELENOS_TARGET="mips64el-helenos"
     372                        ;;
     373                "ppc32")
     374                        LINUX_TARGET="ppc-linux-gnu"
     375                        HELENOS_TARGET="ppc-helenos"
     376                        ;;
     377                "ppc64")
     378                        LINUX_TARGET="ppc64-linux-gnu"
     379                        HELENOS_TARGET="ppc64-helenos"
     380                        ;;
     381                "sparc32")
     382                        LINUX_TARGET="sparc-leon3-linux-gnu"
     383                        HELENOS_TARGET="sparc-leon3-helenos"
     384                        ;;
     385                "sparc64")
     386                        LINUX_TARGET="sparc64-linux-gnu"
     387                        HELENOS_TARGET="sparc64-helenos"
     388                        ;;
     389                *)
     390                        check_error 1 "No target known for $1."
     391                        ;;
     392        esac
    306393}
    307394
    308395build_target() {
    309396        PLATFORM="$1"
    310         TARGET="$2"
     397        # This sets the *_TARGET variables
     398        set_target_from_platform "$PLATFORM"
     399        if $USE_HELENOS_TARGET; then
     400                TARGET="$HELENOS_TARGET"
     401        else
     402                TARGET="$LINUX_TARGET"
     403        fi
    311404       
    312405        WORKDIR="${BASEDIR}/${PLATFORM}"
     
    319412                CROSS_PREFIX="/usr/local/cross"
    320413        fi
    321        
    322         PREFIX="${CROSS_PREFIX}/${PLATFORM}"
     414        if [ -z "${CROSS_HELENOS_PREFIX}" ] ; then
     415                CROSS_HELENOS_PREFIX="/usr/local/cross-helenos"
     416        fi
     417       
     418        if $USE_HELENOS_TARGET; then
     419                PREFIX="${CROSS_HELENOS_PREFIX}/${PLATFORM}"
     420        else
     421                PREFIX="${CROSS_PREFIX}/${PLATFORM}"
     422        fi
    323423       
    324424        echo ">>> Downloading tarballs"
     
    328428       
    329429        echo ">>> Removing previous content"
    330         cleanup_dir "${PREFIX}"
     430        $REAL_INSTALL && cleanup_dir "${PREFIX}"
    331431        cleanup_dir "${WORKDIR}"
    332432       
    333         create_dir "${PREFIX}" "destination directory"
     433        $REAL_INSTALL && create_dir "${PREFIX}" "destination directory"
    334434        create_dir "${OBJDIR}" "GCC object directory"
    335435       
     
    344444        unpack_tarball "${BASEDIR}/${GDB}" "GDB"
    345445       
     446        echo ">>> Applying patches"
     447        for p in $BINUTILS_PATCHES; do
     448                patch_sources "${SRCDIR}/${p}" 0 "binutils"
     449        done
     450        for p in $GCC_PATCHES; do
     451                patch_sources "${SRCDIR}/${p}" 0 "GCC"
     452        done
     453        for p in $GDB_PATCHES; do
     454                patch_sources "${SRCDIR}/${p}" 0 "GDB"
     455        done
     456       
    346457        echo ">>> Processing binutils (${PLATFORM})"
    347458        cd "${BINUTILSDIR}"
     
    349460       
    350461        change_title "binutils: configure (${PLATFORM})"
    351         CFLAGS=-Wno-error ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls --disable-werror
     462        CFLAGS=-Wno-error ./configure \
     463                "--target=${TARGET}" \
     464                "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
     465                --disable-nls --disable-werror
    352466        check_error $? "Error configuring binutils."
    353467       
    354468        change_title "binutils: make (${PLATFORM})"
    355         make all install
    356         check_error $? "Error compiling/installing binutils."
     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       
    357480       
    358481        echo ">>> Processing GCC (${PLATFORM})"
     
    361484       
    362485        change_title "GCC: configure (${PLATFORM})"
    363         "${GCCDIR}/configure" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c,objc,c++,obj-c++ --disable-multilib --disable-libgcj --without-headers --disable-shared --enable-lto --disable-werror
     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
    364493        check_error $? "Error configuring GCC."
    365494       
    366495        change_title "GCC: make (${PLATFORM})"
    367         PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
    368         check_error $? "Error compiling/installing GCC."
     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       
    369507       
    370508        echo ">>> Processing GDB (${PLATFORM})"
     
    373511       
    374512        change_title "GDB: configure (${PLATFORM})"
    375         ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-"
     513        PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./configure \
     514                "--target=${TARGET}" \
     515                "--prefix=${PREFIX}" "--program-prefix=${TARGET}-"
    376516        check_error $? "Error configuring GDB."
    377517       
    378518        change_title "GDB: make (${PLATFORM})"
    379         make all install
    380         check_error $? "Error compiling/installing GDB."
     519        PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all
     520        check_error $? "Error compiling GDB."
     521       
     522        change_title "GDB: make (${PLATFORM})"
     523        if $REAL_INSTALL; then
     524                PATH="${PATH}:${PREFIX}/bin" make install
     525        else
     526                PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install "DESTDIR=${INSTALL_DIR}"
     527        fi
     528        check_error $? "Error installing GDB."
     529       
    381530       
    382531        cd "${BASEDIR}"
     
    389538        echo ">>> Cross-compiler for ${TARGET} installed."
    390539}
     540
     541while [ "$#" -gt 1 ]; do
     542        case "$1" in
     543                --no-install)
     544                        REAL_INSTALL=false
     545                        shift
     546                        ;;
     547                --helenos-target)
     548                        USE_HELENOS_TARGET=true
     549                        shift
     550                        ;;
     551                *)
     552                        show_usage
     553                        ;;
     554        esac
     555done
    391556
    392557if [ "$#" -lt "1" ]; then
     
    395560
    396561case "$1" in
    397         "amd64")
     562        amd64|arm32|ia32|ia64|mips32|mips32eb|mips64|ppc32|ppc64|sparc32|sparc64)
    398563                prepare
    399                 build_target "amd64" "amd64-linux-gnu"
    400                 ;;
    401         "arm32")
    402                 prepare
    403                 build_target "arm32" "arm-linux-gnueabi"
    404                 ;;
    405         "ia32")
    406                 prepare
    407                 build_target "ia32" "i686-pc-linux-gnu"
    408                 ;;
    409         "ia64")
    410                 prepare
    411                 build_target "ia64" "ia64-pc-linux-gnu"
    412                 ;;
    413         "mips32")
    414                 prepare
    415                 build_target "mips32" "mipsel-linux-gnu"
    416                 ;;
    417         "mips32eb")
    418                 prepare
    419                 build_target "mips32eb" "mips-linux-gnu"
    420                 ;;
    421         "mips64")
    422                 prepare
    423                 build_target "mips64" "mips64el-linux-gnu"
    424                 ;;
    425         "ppc32")
    426                 prepare
    427                 build_target "ppc32" "ppc-linux-gnu"
    428                 ;;
    429         "ppc64")
    430                 prepare
    431                 build_target "ppc64" "ppc64-linux-gnu"
    432                 ;;
    433         "sparc64")
    434                 prepare
    435                 build_target "sparc64" "sparc64-linux-gnu"
     564                build_target "$1"
    436565                ;;
    437566        "all")
    438567                prepare
    439                 build_target "amd64" "amd64-linux-gnu"
    440                 build_target "arm32" "arm-linux-gnueabi"
    441                 build_target "ia32" "i686-pc-linux-gnu"
    442                 build_target "ia64" "ia64-pc-linux-gnu"
    443                 build_target "mips32" "mipsel-linux-gnu"
    444                 build_target "mips32eb" "mips-linux-gnu"
    445                 build_target "mips64" "mips64el-linux-gnu"
    446                 build_target "ppc32" "ppc-linux-gnu"
    447                 build_target "ppc64" "ppc64-linux-gnu"
    448                 build_target "sparc64" "sparc64-linux-gnu"
     568                build_target "amd64"
     569                build_target "arm32"
     570                build_target "ia32"
     571                build_target "ia64"
     572                build_target "mips32"
     573                build_target "mips32eb"
     574                build_target "mips64"
     575                build_target "ppc32"
     576                build_target "ppc64"
     577                build_target "sparc32"
     578                build_target "sparc64"
    449579                ;;
    450580        "parallel")
    451581                prepare
    452                 build_target "amd64" "amd64-linux-gnu" &
    453                 build_target "arm32" "arm-linux-gnueabi" &
    454                 build_target "ia32" "i686-pc-linux-gnu" &
    455                 build_target "ia64" "ia64-pc-linux-gnu" &
    456                 build_target "mips32" "mipsel-linux-gnu" &
    457                 build_target "mips32eb" "mips-linux-gnu" &
    458                 build_target "mips64" "mips64el-linux-gnu" &
    459                 build_target "ppc32" "ppc-linux-gnu" &
    460                 build_target "ppc64" "ppc64-linux-gnu" &
    461                 build_target "sparc64" "sparc64-linux-gnu" &
     582                build_target "amd64" &
     583                build_target "arm32" &
     584                build_target "ia32" &
     585                build_target "ia64" &
     586                build_target "mips32" &
     587                build_target "mips32eb" &
     588                build_target "mips64" &
     589                build_target "ppc32" &
     590                build_target "ppc64" &
     591                build_target "sparc32" &
     592                build_target "sparc64" &
    462593                wait
    463594                ;;
    464595        "2-way")
    465596                prepare
    466                 build_target "amd64" "amd64-linux-gnu" &
    467                 build_target "arm32" "arm-linux-gnueabi" &
     597                build_target "amd64" &
     598                build_target "arm32" &
    468599                wait
    469600               
    470                 build_target "ia32" "i686-pc-linux-gnu" &
    471                 build_target "ia64" "ia64-pc-linux-gnu" &
     601                build_target "ia32" &
     602                build_target "ia64" &
    472603                wait
    473604               
    474                 build_target "mips32" "mipsel-linux-gnu" &
    475                 build_target "mips32eb" "mips-linux-gnu" &
     605                build_target "mips32" &
     606                build_target "mips32eb" &
    476607                wait
    477608               
    478                 build_target "mips64" "mips64el-linux-gnu" &
    479                 build_target "ppc32" "ppc-linux-gnu" &
     609                build_target "mips64" &
     610                build_target "ppc32" &
    480611                wait
    481612               
    482                 build_target "ppc64" "ppc64-linux-gnu" &
    483                 build_target "sparc64" "sparc64-linux-gnu" &
     613                build_target "ppc64" &
     614                build_target "sparc32" &
     615                wait
     616               
     617                build_target "sparc64" &
    484618                wait
    485619                ;;
Note: See TracChangeset for help on using the changeset viewer.