Subversion Repositories HelenOS

Rev

Rev 3022 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #!/bin/bash
  2.  
  3. # Cross-Compiler Toolchain for ${PLATFORM}
  4. #  by Martin Decky <martin@decky.cz>
  5. #
  6. #  GPL'ed, copyleft
  7. #
  8.  
  9.  
  10. check_error() {
  11.     if [ "$1" -ne "0" ]; then
  12.     echo
  13.     echo "Script failed: $2"
  14.     exit
  15.     fi
  16. }
  17.  
  18. if [ -z "${CROSS_PREFIX}" ] ; then
  19.     CROSS_PREFIX="/usr/local"
  20. fi
  21.  
  22. BINUTILS_VERSION="2.19"
  23. GCC_VERSION="4.3.2"
  24.  
  25. BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
  26. GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
  27. GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
  28. GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
  29.  
  30. BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
  31. GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
  32.  
  33. PLATFORM="ia64"
  34. WORKDIR=`pwd`
  35. TARGET="${PLATFORM}-pc-linux-gnu"
  36. PREFIX="${CROSS_PREFIX}/${PLATFORM}"
  37. INCLUDESDIR="${WORKDIR}/include"
  38. BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
  39. GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
  40. OBJDIR="${WORKDIR}/gcc-obj"
  41.  
  42. echo ">>> Downloading tarballs"
  43.  
  44. if [ ! -f "${BINUTILS}" ]; then
  45.     wget -c "${BINUTILS_SOURCE}${BINUTILS}"
  46.     check_error $? "Error downloading binutils."
  47. fi
  48. if [ ! -f "${GCC_CORE}" ]; then
  49.     wget -c "${GCC_SOURCE}${GCC_CORE}"
  50.     check_error $? "Error downloading GCC Core."
  51. fi
  52. if [ ! -f "${GCC_OBJC}" ]; then
  53.     wget -c "${GCC_SOURCE}${GCC_OBJC}"
  54.     check_error $? "Error downloading GCC Objective C."
  55. fi
  56. if [ ! -f "${GCC_CPP}" ]; then
  57.     wget -c "${GCC_SOURCE}${GCC_CPP}"
  58.     check_error $? "Error downloading GCC C++."
  59. fi
  60.  
  61. echo ">>> Creating destionation directory"
  62. if [ ! -d "${PREFIX}" ]; then
  63.     mkdir -p "${PREFIX}"
  64.     test -d "${PREFIX}"
  65.     check_error $? "Unable to create ${PREFIX}."
  66. fi
  67.  
  68. echo ">>> Creating GCC work directory"
  69. if [ ! -d "${OBJDIR}" ]; then
  70.     mkdir -p "${OBJDIR}"
  71.     test -d "${OBJDIR}"
  72.     check_error $? "Unable to create ${OBJDIR}."
  73. fi
  74.  
  75. echo ">>> Unpacking tarballs"
  76. tar -xvzf "${BINUTILS}"
  77. check_error $? "Error unpacking binutils."
  78. tar -xvjf "${GCC_CORE}"
  79. check_error $? "Error unpacking GCC Core."
  80. tar -xvjf "${GCC_OBJC}"
  81. check_error $? "Error unpacking GCC Objective C."
  82. tar -xvjf "${GCC_CPP}"
  83. check_error $? "Error unpacking GCC C++."
  84.  
  85. echo ">>> Compiling and installing binutils"
  86. cd "${BINUTILSDIR}"
  87. check_error $? "Change directory failed."
  88. ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
  89. check_error $? "Error configuring binutils."
  90. make all install
  91. check_error $? "Error compiling/installing binutils."
  92.  
  93. echo ">>> Compiling and installing GCC"
  94. cd "${OBJDIR}"
  95. check_error $? "Change directory failed."
  96. "${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 --disable-shared
  97. check_error $? "Error configuring GCC."
  98. PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
  99. check_error $? "Error compiling/installing GCC."
  100.  
  101. echo
  102. echo ">>> Cross-compiler for ${TARGET} installed."
  103.