Changeset ad7a6c9 in mainline for tools/toolchain.sh


Ignore:
Timestamp:
2011-03-30T13:10:24Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4ae90f9
Parents:
6e50466 (diff), d6b81941 (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:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/toolchain.sh

    r6e50466 rad7a6c9  
    2828# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929#
     30
     31GMP_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
     38#if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,2)
     39        choke me
     40#endif
     41EOF
     42
     43MPFR_MAIN=<<EOF
     44#if MPFR_VERSION < MPFR_VERSION_NUM(2, 4, 2)
     45choke me
     46        #endif
     47EOF
     48
     49MPC_MAIN=<<EOF
     50#if MPC_VERSION < MPC_VERSION_NUM(0, 8, 1)
     51        choke me
     52#endif
     53EOF
     54
     55BINUTILS_VERSION="2.21"
     56GCC_VERSION="4.6.0"
     57
     58BASEDIR="`pwd`"
     59BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2"
     60GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
     61GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
     62GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
     63
     64#
     65# Check if the library described in the argument
     66# exists and has acceptable version.
     67#
     68check_dependency() {
     69        DEPENDENCY="$1"
     70        HEADER="$2"
     71        BODY="$3"
     72       
     73        FNAME="/tmp/conftest-$$"
     74       
     75        echo "#include ${HEADER}" > "${FNAME}.c"
     76        echo >> "${FNAME}.c"
     77        echo "int main()" >> "${FNAME}.c"
     78        echo "{" >> "${FNAME}.c"
     79        echo "${BODY}" >> "${FNAME}.c"
     80        echo "  return 0;" >> "${FNAME}.c"
     81        echo "}" >> "${FNAME}.c"
     82       
     83        cc -c -o "${FNAME}.o" "${FNAME}.c" 2> "${FNAME}.log"
     84        RC="$?"
     85       
     86        if [ "$RC" -ne "0" ] ; then
     87                echo " ${DEPENDENCY} not found, too old or compiler error."
     88                echo " Please recheck manually the source file \"${FNAME}.c\"."
     89                echo " The compilation of the toolchain is probably going to fail,"
     90                echo " you have been warned."
     91                echo
     92                echo " ===== Compiler output ====="
     93                cat "${FNAME}.log"
     94                echo " ==========================="
     95                echo
     96        else
     97                echo " ${DEPENDENCY} found"
     98                rm -f "${FNAME}.log" "${FNAME}.o" "${FNAME}.c"
     99        fi
     100}
     101
     102check_dependecies() {
     103        echo ">>> Basic dependency check"
     104        check_dependency "GMP" "<gmp.h>" "${GMP_MAIN}"
     105        check_dependency "MPFR" "<mpfr.h>" "${MPFR_MAIN}"
     106        check_dependency "MPC" "<mpc.h>" "${MPC_MAIN}"
     107        echo
     108}
    30109
    31110check_error() {
     
    69148        echo " sparc64    SPARC V9"
    70149        echo " all        build all targets"
     150        echo " parallel   same as 'all', but in parallel"
     151        echo
     152        echo "The toolchain will be installed to the directory specified by"
     153        echo "the CROSS_PREFIX environment variable. If the variable is not"
     154        echo "defined, /usr/local/cross will be used by default."
    71155        echo
    72156       
     
    118202        echo " - native C library with headers"
    119203        echo
    120        
    121         show_countdown 10
    122 }
    123 
    124 download_check() {
     204}
     205
     206download_fetch() {
    125207        SOURCE="$1"
    126208        FILE="$2"
     
    136218}
    137219
     220source_check() {
     221        FILE="$1"
     222       
     223        if [ ! -f "${FILE}" ]; then
     224                echo
     225                echo "File ${FILE} not found."
     226               
     227                exit 4
     228        fi
     229}
     230
    138231cleanup_dir() {
    139232        DIR="$1"
     
    169262}
    170263
    171 patch_binutils() {
    172         PLATFORM="$1"
    173        
    174         if [ "${PLATFORM}" == "arm32" ] ; then
    175                 patch -p1 <<EOF
    176 diff -Naur binutils-2.20.orig/gas/config/tc-arm.c binutils-2.20/gas/config/tc-arm.c
    177 --- binutils-2.20.orig/gas/config/tc-arm.c      2009-08-30 00:10:59.000000000 +0200
    178 +++ binutils-2.20/gas/config/tc-arm.c   2009-11-02 14:25:11.000000000 +0100
    179 @@ -2485,8 +2485,9 @@
    180        know (frag->tc_frag_data.first_map == NULL);
    181        frag->tc_frag_data.first_map = symbolP;
    182      }
    183 -  if (frag->tc_frag_data.last_map != NULL)
    184 +  if (frag->tc_frag_data.last_map != NULL) {
    185      know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));
    186 +  }
    187    frag->tc_frag_data.last_map = symbolP;
    188  }
    189 EOF
    190                 check_error $? "Error patching binutils"
    191         fi
     264prepare() {
     265        show_dependencies
     266        check_dependecies
     267        show_countdown 10
     268       
     269        BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
     270        GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
     271       
     272        download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "c84c5acc9d266f1a7044b51c85a823f5"
     273        download_fetch "${GCC_SOURCE}" "${GCC_CORE}" "b1957f3209080b2f55bc3756d3a62b7c"
     274        download_fetch "${GCC_SOURCE}" "${GCC_OBJC}" "120d4675366ee82ea52f9ed65b57da04"
     275        download_fetch "${GCC_SOURCE}" "${GCC_CPP}" "a30090fa655d0db4c970740d353c81f1"
    192276}
    193277
     
    196280        TARGET="$2"
    197281       
    198         BINUTILS_VERSION="2.20"
    199         GCC_VERSION="4.5.1"
    200        
    201         BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2"
    202         GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
    203         GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
    204         GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
    205        
    206         BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
    207         GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
    208        
    209         WORKDIR="`pwd`"
     282        WORKDIR="${BASEDIR}/${PLATFORM}"
    210283        BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
    211284        GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
     
    213286       
    214287        if [ -z "${CROSS_PREFIX}" ] ; then
    215                 CROSS_PREFIX="/usr/local"
     288                CROSS_PREFIX="/usr/local/cross"
    216289        fi
    217290       
     
    219292       
    220293        echo ">>> Downloading tarballs"
    221         download_check "${BINUTILS_SOURCE}" "${BINUTILS}" "ee2d3e996e9a2d669808713360fa96f8"
    222         download_check "${GCC_SOURCE}" "${GCC_CORE}" "dc8959e31b01a65ce10d269614815054"
    223         download_check "${GCC_SOURCE}" "${GCC_OBJC}" "3c11b7037896e967eddf8178af2ddd98"
    224         download_check "${GCC_SOURCE}" "${GCC_CPP}" "b294953ff0bb2f20c7acb2bf005d832a"
     294        source_check "${BASEDIR}/${BINUTILS}"
     295        source_check "${BASEDIR}/${GCC_CORE}"
     296        source_check "${BASEDIR}/${GCC_OBJC}"
     297        source_check "${BASEDIR}/${GCC_CPP}"
    225298       
    226299        echo ">>> Removing previous content"
    227300        cleanup_dir "${PREFIX}"
    228         cleanup_dir "${OBJDIR}"
    229         cleanup_dir "${BINUTILSDIR}"
    230         cleanup_dir "${GCCDIR}"
     301        cleanup_dir "${WORKDIR}"
    231302       
    232303        create_dir "${PREFIX}" "destination directory"
     
    234305       
    235306        echo ">>> Unpacking tarballs"
    236         unpack_tarball "${BINUTILS}" "binutils"
    237         unpack_tarball "${GCC_CORE}" "GCC Core"
    238         unpack_tarball "${GCC_OBJC}" "Objective C"
    239         unpack_tarball "${GCC_CPP}" "C++"
     307        cd "${WORKDIR}"
     308        check_error $? "Change directory failed."
     309       
     310        unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
     311        unpack_tarball "${BASEDIR}/${GCC_CORE}" "GCC Core"
     312        unpack_tarball "${BASEDIR}/${GCC_OBJC}" "Objective C"
     313        unpack_tarball "${BASEDIR}/${GCC_CPP}" "C++"
    240314       
    241315        echo ">>> Processing binutils (${PLATFORM})"
    242316        cd "${BINUTILSDIR}"
    243317        check_error $? "Change directory failed."
    244         patch_binutils "${PLATFORM}"
    245318       
    246319        change_title "binutils: configure (${PLATFORM})"
     
    264337        check_error $? "Error compiling/installing GCC."
    265338       
    266         cd "${WORKDIR}"
     339        cd "${BASEDIR}"
    267340        check_error $? "Change directory failed."
    268341       
    269342        echo ">>> Cleaning up"
    270         cleanup_dir "${OBJDIR}"
    271         cleanup_dir "${BINUTILSDIR}"
    272         cleanup_dir "${GCCDIR}"
     343        cleanup_dir "${WORKDIR}"
    273344       
    274345        echo
     
    280351fi
    281352
    282 show_dependencies
    283 
    284353case "$1" in
    285354        "amd64")
     355                prepare
    286356                build_target "amd64" "amd64-linux-gnu"
    287357                ;;
    288358        "arm32")
     359                prepare
    289360                build_target "arm32" "arm-linux-gnu"
    290361                ;;
    291362        "ia32")
     363                prepare
    292364                build_target "ia32" "i686-pc-linux-gnu"
    293365                ;;
    294366        "ia64")
     367                prepare
    295368                build_target "ia64" "ia64-pc-linux-gnu"
    296369                ;;
    297         "ia64")
    298                 build_target "ia64" "ia64-pc-linux-gnu"
    299                 ;;
    300370        "mips32")
     371                prepare
    301372                build_target "mips32" "mipsel-linux-gnu"
    302373                ;;
    303374        "mips32eb")
     375                prepare
    304376                build_target "mips32eb" "mips-linux-gnu"
    305377                ;;
    306378        "mips64")
     379                prepare
    307380                build_target "mips64" "mips64el-linux-gnu"
    308381                ;;
    309382        "ppc32")
     383                prepare
    310384                build_target "ppc32" "ppc-linux-gnu"
    311385                ;;
    312386        "ppc64")
     387                prepare
    313388                build_target "ppc64" "ppc64-linux-gnu"
    314389                ;;
    315390        "sparc64")
     391                prepare
    316392                build_target "sparc64" "sparc64-linux-gnu"
    317393                ;;
    318394        "all")
     395                prepare
    319396                build_target "amd64" "amd64-linux-gnu"
    320397                build_target "arm32" "arm-linux-gnu"
    321398                build_target "ia32" "i686-pc-linux-gnu"
    322                 build_target "ia64" "ia64-pc-linux-gnu"
    323399                build_target "ia64" "ia64-pc-linux-gnu"
    324400                build_target "mips32" "mipsel-linux-gnu"
     
    329405                build_target "sparc64" "sparc64-linux-gnu"
    330406                ;;
     407        "parallel")
     408                prepare
     409                build_target "amd64" "amd64-linux-gnu" &
     410                build_target "arm32" "arm-linux-gnu" &
     411                build_target "ia32" "i686-pc-linux-gnu" &
     412                build_target "ia64" "ia64-pc-linux-gnu" &
     413                build_target "mips32" "mipsel-linux-gnu" &
     414                build_target "mips32eb" "mips-linux-gnu" &
     415                build_target "mips64" "mips64el-linux-gnu" &
     416                build_target "ppc32" "ppc-linux-gnu" &
     417                build_target "ppc64" "ppc64-linux-gnu" &
     418                build_target "sparc64" "sparc64-linux-gnu" &
     419                wait
     420                ;;
    331421        *)
    332422                show_usage
Note: See TracChangeset for help on using the changeset viewer.