Changes in tools/toolchain.sh [d7f2cd6:5a65d29] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/toolchain.sh

    rd7f2cd6 r5a65d29  
    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.1"
     59GCC_PATCHES="toolchain-gcc-4.8.1-targets.patch toolchain-gcc-4.8.1-headers.patch"
     60GDB_VERSION="7.6"
     61GDB_PATCHES="toolchain-gdb-7.6.patch"
    5962
    6063BASEDIR="`pwd`"
     
    6265GCC="gcc-${GCC_VERSION}.tar.bz2"
    6366GDB="gdb-${GDB_VERSION}.tar.bz2"
     67
     68REAL_INSTALL=true
     69USE_HELENOS_TARGET=false
     70INSTALL_DIR="${BASEDIR}/PKG"
    6471
    6572#
     
    135142        echo
    136143        echo "Syntax:"
    137         echo " $0 <platform>"
     144        echo " $0 [--no-install] [--helenos-target] <platform>"
    138145        echo
    139146        echo "Possible target platforms are:"
     
    152159        echo " 2-way      same as 'all', but 2-way parallel"
    153160        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."
     161        echo "The toolchain is installed into directory specified by the"
     162        echo "CROSS_PREFIX environment variable. If the variable is not"
     163        echo "defined, /usr/local/cross/ is used as default."
     164        echo
     165        echo "If --no-install is present, the toolchain still uses the"
     166        echo "CROSS_PREFIX as the target directory but the installation"
     167        echo "copies the files into PKG/ subdirectory without affecting"
     168        echo "the actual root file system. That is only useful if you do"
     169        echo "not want to run the script under the super user."
     170        echo
     171        echo "The --helenos-target will build HelenOS-specific toolchain"
     172        echo "(i.e. it will use *-helenos-* triplet instead of *-linux-*)."
     173        echo "This toolchain is installed into /usr/local/cross-helenos by"
     174        echo "default. The settings can be changed by setting environment"
     175        echo "variable CROSS_HELENOS_PREFIX."
    157176        echo
    158177       
     
    254273}
    255274
    256 check_dirs() {
    257         OUTSIDE="$1"
    258         BASE="$2"
    259         ORIGINAL="`pwd`"
    260        
    261         cd "${OUTSIDE}"
    262         check_error $? "Unable to change directory to ${OUTSIDE}."
    263         ABS_OUTSIDE="`pwd`"
    264        
    265         cd "${BASE}"
    266         check_error $? "Unable to change directory to ${BASE}."
    267         ABS_BASE="`pwd`"
    268        
    269         cd "${ORIGINAL}"
    270         check_error $? "Unable to change directory to ${ORIGINAL}."
    271        
    272         BASE_LEN="${#ABS_BASE}"
    273         OUTSIDE_TRIM="${ABS_OUTSIDE:0:${BASE_LEN}}"
    274        
    275         if [ "${OUTSIDE_TRIM}" == "${ABS_BASE}" ] ; then
    276                 echo
    277                 echo "CROSS_PREFIX cannot reside within the working directory."
    278                
    279                 exit 5
    280         fi
    281 }
    282 
    283275unpack_tarball() {
    284276        FILE="$1"
     
    290282        tar -xjf "${FILE}"
    291283        check_error $? "Error unpacking ${DESC}."
     284}
     285
     286patch_sources() {
     287        PATCH_FILE="$1"
     288        PATCH_STRIP="$2"
     289        DESC="$3"
     290       
     291        change_title "Patching ${DESC}"
     292        echo " >>> Patching ${DESC} with ${PATCH_FILE}"
     293       
     294        patch -t "-p${PATCH_STRIP}" <"$PATCH_FILE"
     295        check_error $? "Error patching ${DESC}."
    292296}
    293297
     
    303307        download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "33adb18c3048d057ac58d07a3f1adb38"
    304308        download_fetch "${GCC_SOURCE}" "${GCC}" "3b2386c114cd74185aa3754b58a79304"
    305         download_fetch "${GDB_SOURCE}" "${GDB}" "fbc4dab4181e6e9937075b43a4ce2732"
     309        download_fetch "${GDB_SOURCE}" "${GDB}" "fda57170e4d11cdde74259ca575412a8"
     310}
     311
     312set_target_from_platform() {
     313        case "$1" in
     314                "amd64")
     315                        LINUX_TARGET="amd64-linux-gnu"
     316                        HELENOS_TARGET="amd64-helenos"
     317                        ;;
     318                "arm32")
     319                        LINUX_TARGET="arm-linux-gnueabi"
     320                        HELENOS_TARGET="arm-helenos-gnueabi"
     321                        ;;
     322                "ia32")
     323                        LINUX_TARGET="i686-pc-linux-gnu"
     324                        HELENOS_TARGET="i686-pc-helenos"
     325                        ;;
     326                "ia64")
     327                        LINUX_TARGET="ia64-pc-linux-gnu"
     328                        HELENOS_TARGET="ia64-pc-helenos"
     329                        ;;
     330                "mips32")
     331                        LINUX_TARGET="mipsel-linux-gnu"
     332                        HELENOS_TARGET="mipsel-helenos"
     333                        ;;
     334                "mips32eb")
     335                        LINUX_TARGET="mips-linux-gnu"
     336                        HELENOS_TARGET="mips-helenos"
     337                        ;;
     338                "mips64")
     339                        LINUX_TARGET="mips64el-linux-gnu"
     340                        HELENOS_TARGET="mips64el-helenos"
     341                        ;;
     342                "ppc32")
     343                        LINUX_TARGET="ppc-linux-gnu"
     344                        HELENOS_TARGET="ppc-helenos"
     345                        ;;
     346                "ppc64")
     347                        LINUX_TARGET="ppc64-linux-gnu"
     348                        HELENOS_TARGET="ppc64-helenos"
     349                        ;;
     350                "sparc64")
     351                        LINUX_TARGET="sparc64-linux-gnu"
     352                        HELENOS_TARGET="sparc64-helenos"
     353                        ;;
     354                *)
     355                        check_error 1 "No target known for $1."
     356                        ;;
     357        esac
    306358}
    307359
    308360build_target() {
    309361        PLATFORM="$1"
    310         TARGET="$2"
     362        # This sets the *_TARGET variables
     363        set_target_from_platform "$PLATFORM"
     364        if $USE_HELENOS_TARGET; then
     365                TARGET="$HELENOS_TARGET"
     366        else
     367                TARGET="$LINUX_TARGET"
     368        fi
    311369       
    312370        WORKDIR="${BASEDIR}/${PLATFORM}"
     
    319377                CROSS_PREFIX="/usr/local/cross"
    320378        fi
    321        
    322         PREFIX="${CROSS_PREFIX}/${PLATFORM}"
     379        if [ -z "${CROSS_HELENOS_PREFIX}" ] ; then
     380                CROSS_HELENOS_PREFIX="/usr/local/cross-helenos"
     381        fi
     382       
     383        if $USE_HELENOS_TARGET; then
     384                PREFIX="${CROSS_HELENOS_PREFIX}/${PLATFORM}"
     385        else
     386                PREFIX="${CROSS_PREFIX}/${PLATFORM}"
     387        fi
    323388       
    324389        echo ">>> Downloading tarballs"
     
    328393       
    329394        echo ">>> Removing previous content"
    330         cleanup_dir "${PREFIX}"
     395        $REAL_INSTALL && cleanup_dir "${PREFIX}"
    331396        cleanup_dir "${WORKDIR}"
    332397       
    333         create_dir "${PREFIX}" "destination directory"
     398        $REAL_INSTALL && create_dir "${PREFIX}" "destination directory"
    334399        create_dir "${OBJDIR}" "GCC object directory"
    335        
    336         check_dirs "${PREFIX}" "${WORKDIR}"
    337400       
    338401        echo ">>> Unpacking tarballs"
     
    344407        unpack_tarball "${BASEDIR}/${GDB}" "GDB"
    345408       
     409        echo ">>> Applying patches"
     410        for p in $BINUTILS_PATCHES; do
     411                patch_sources "${BASEDIR}/${p}" 0 "binutils"
     412        done
     413        for p in $GCC_PATCHES; do
     414                patch_sources "${BASEDIR}/${p}" 0 "GCC"
     415        done
     416        for p in $GDB_PATCHES; do
     417                patch_sources "${BASEDIR}/${p}" 0 "GDB"
     418        done
     419       
    346420        echo ">>> Processing binutils (${PLATFORM})"
    347421        cd "${BINUTILSDIR}"
     
    349423       
    350424        change_title "binutils: configure (${PLATFORM})"
    351         CFLAGS=-Wno-error ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls --disable-werror
     425        CFLAGS=-Wno-error ./configure \
     426                "--target=${TARGET}" \
     427                "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
     428                --disable-nls --disable-werror
    352429        check_error $? "Error configuring binutils."
    353430       
    354431        change_title "binutils: make (${PLATFORM})"
    355         make all install
    356         check_error $? "Error compiling/installing binutils."
     432        make all
     433        check_error $? "Error compiling binutils."
     434       
     435        change_title "binutils: install (${PLATFORM})"
     436        if $REAL_INSTALL; then
     437                make install
     438        else
     439                make install "DESTDIR=${INSTALL_DIR}"
     440        fi
     441        check_error $? "Error installing binutils."
     442       
    357443       
    358444        echo ">>> Processing GCC (${PLATFORM})"
     
    361447       
    362448        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
     449        PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${GCCDIR}/configure" \
     450                "--target=${TARGET}" \
     451                "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
     452                --with-gnu-as --with-gnu-ld --disable-nls --disable-threads \
     453                --enable-languages=c,objc,c++,obj-c++ \
     454                --disable-multilib --disable-libgcj --without-headers \
     455                --disable-shared --enable-lto --disable-werror
    364456        check_error $? "Error configuring GCC."
    365457       
    366458        change_title "GCC: make (${PLATFORM})"
    367         PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
    368         check_error $? "Error compiling/installing GCC."
     459        PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc
     460        check_error $? "Error compiling GCC."
     461       
     462        change_title "GCC: install (${PLATFORM})"
     463        if $REAL_INSTALL; then
     464                PATH="${PATH}:${PREFIX}/bin" make install-gcc
     465        else
     466                PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
     467        fi
     468        check_error $? "Error installing GCC."
     469       
    369470       
    370471        echo ">>> Processing GDB (${PLATFORM})"
     
    373474       
    374475        change_title "GDB: configure (${PLATFORM})"
    375         ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-"
     476        PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./configure \
     477                "--target=${TARGET}" \
     478                "--prefix=${PREFIX}" "--program-prefix=${TARGET}-"
    376479        check_error $? "Error configuring GDB."
    377480       
    378481        change_title "GDB: make (${PLATFORM})"
    379         make all install
    380         check_error $? "Error compiling/installing GDB."
     482        PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all
     483        check_error $? "Error compiling GDB."
     484       
     485        change_title "GDB: make (${PLATFORM})"
     486        if $REAL_INSTALL; then
     487                PATH="${PATH}:${PREFIX}/bin" make install
     488        else
     489                PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install "DESTDIR=${INSTALL_DIR}"
     490        fi
     491        check_error $? "Error installing GDB."
     492       
    381493       
    382494        cd "${BASEDIR}"
     
    389501        echo ">>> Cross-compiler for ${TARGET} installed."
    390502}
     503
     504while [ "$#" -gt 1 ]; do
     505        case "$1" in
     506                --no-install)
     507                        REAL_INSTALL=false
     508                        shift
     509                        ;;
     510                --helenos-target)
     511                        USE_HELENOS_TARGET=true
     512                        shift
     513                        ;;
     514                *)
     515                        show_usage
     516                        ;;
     517        esac
     518done
    391519
    392520if [ "$#" -lt "1" ]; then
     
    395523
    396524case "$1" in
    397         "amd64")
     525        amd64|arm32|ia32|ia64|mips32|mips32eb|mips64|ppc32|ppc64|sparc64)
    398526                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"
     527                build_target "$1"
    436528                ;;
    437529        "all")
    438530                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"
     531                build_target "amd64"
     532                build_target "arm32"
     533                build_target "ia32"
     534                build_target "ia64"
     535                build_target "mips32"
     536                build_target "mips32eb"
     537                build_target "mips64"
     538                build_target "ppc32"
     539                build_target "ppc64"
     540                build_target "sparc64"
    449541                ;;
    450542        "parallel")
    451543                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" &
     544                build_target "amd64" &
     545                build_target "arm32" &
     546                build_target "ia32" &
     547                build_target "ia64" &
     548                build_target "mips32" &
     549                build_target "mips32eb" &
     550                build_target "mips64" &
     551                build_target "ppc32" &
     552                build_target "ppc64" &
     553                build_target "sparc64" &
    462554                wait
    463555                ;;
    464556        "2-way")
    465557                prepare
    466                 build_target "amd64" "amd64-linux-gnu" &
    467                 build_target "arm32" "arm-linux-gnueabi" &
     558                build_target "amd64" &
     559                build_target "arm32" &
    468560                wait
    469561               
    470                 build_target "ia32" "i686-pc-linux-gnu" &
    471                 build_target "ia64" "ia64-pc-linux-gnu" &
     562                build_target "ia32" &
     563                build_target "ia64" &
    472564                wait
    473565               
    474                 build_target "mips32" "mipsel-linux-gnu" &
    475                 build_target "mips32eb" "mips-linux-gnu" &
     566                build_target "mips32" &
     567                build_target "mips32eb" &
    476568                wait
    477569               
    478                 build_target "mips64" "mips64el-linux-gnu" &
    479                 build_target "ppc32" "ppc-linux-gnu" &
     570                build_target "mips64" &
     571                build_target "ppc32" &
    480572                wait
    481573               
    482                 build_target "ppc64" "ppc64-linux-gnu" &
    483                 build_target "sparc64" "sparc64-linux-gnu" &
     574                build_target "ppc64" &
     575                build_target "sparc64" &
    484576                wait
    485577                ;;
Note: See TracChangeset for help on using the changeset viewer.