Subversion Repositories HelenOS

Rev

Rev 2131 | 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. BINUTILS_VERSION="2.17"
  19. GCC_VERSION="4.1.2"
  20.  
  21. INCLUDES="ia64-pc-gnu-linux_includes.tar.bz2"
  22. BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
  23. GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
  24. GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
  25. GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
  26.  
  27. INCLUDES_SOURCE="http://download.decky.cz/"
  28. BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
  29. GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
  30.  
  31. PLATFORM="ia64"
  32. WORKDIR=`pwd`
  33. TARGET="${PLATFORM}-pc-linux-gnu"
  34. PREFIX="/usr/local/${PLATFORM}"
  35. INCLUDESDIR="${WORKDIR}/include"
  36. BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
  37. GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
  38. OBJDIR="${WORKDIR}/gcc-obj"
  39.  
  40. echo ">>> Downloading tarballs"
  41.  
  42. if [ ! -f "${INCLUDES}" ]; then
  43.     wget -c "${INCLUDES_SOURCE}${INCLUDES}"
  44.     check_error $? "Error downloading includes."
  45. fi
  46. if [ ! -f "${BINUTILS}" ]; then
  47.     wget -c "${BINUTILS_SOURCE}${BINUTILS}"
  48.     check_error $? "Error downloading binutils."
  49. fi
  50. if [ ! -f "${GCC_CORE}" ]; then
  51.     wget -c "${GCC_SOURCE}${GCC_CORE}"
  52.     check_error $? "Error downloading GCC Core."
  53. fi
  54. if [ ! -f "${GCC_OBJC}" ]; then
  55.     wget -c "${GCC_SOURCE}${GCC_OBJC}"
  56.     check_error $? "Error downloading GCC Objective C."
  57. fi
  58. if [ ! -f "${GCC_CPP}" ]; then
  59.     wget -c "${GCC_SOURCE}${GCC_CPP}"
  60.     check_error $? "Error downloading GCC C++."
  61. fi
  62.  
  63. echo ">>> Creating destionation directory"
  64. if [ ! -d "${PREFIX}" ]; then
  65.     mkdir -p "${PREFIX}"
  66.     test -d "${PREFIX}"
  67.     check_error $? "Unable to create ${PREFIX}."
  68. fi
  69.  
  70. echo ">>> Creating GCC work directory"
  71. if [ ! -d "${OBJDIR}" ]; then
  72.     mkdir -p "${OBJDIR}"
  73.     test -d "${OBJDIR}"
  74.     check_error $? "Unable to create ${OBJDIR}."
  75. fi
  76.  
  77. echo ">>> Unpacking tarballs"
  78. tar -xvjf "${INCLUDES}"
  79. check_error $? "Error unpacking includes."
  80. tar -xvzf "${BINUTILS}"
  81. check_error $? "Error unpacking binutils."
  82. tar -xvjf "${GCC_CORE}"
  83. check_error $? "Error unpacking GCC Core."
  84. tar -xvjf "${GCC_OBJC}"
  85. check_error $? "Error unpacking GCC Objective C."
  86. tar -xvjf "${GCC_CPP}"
  87. check_error $? "Error unpacking GCC C++."
  88.  
  89. echo ">>> Compiling and installing binutils"
  90. cd "${BINUTILSDIR}"
  91. check_error $? "Change directory failed."
  92. ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
  93. check_error $? "Error configuring binutils."
  94. make all install
  95. check_error $? "Error compiling/installing binutils."
  96.  
  97. echo ">>> Compiling and installing GCC"
  98. cd "${OBJDIR}"
  99. check_error $? "Change directory failed."
  100. "${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 "--with-headers=${INCLUDESDIR}" --disable-shared
  101. check_error $? "Error configuring GCC."
  102. PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
  103. check_error $? "Error compiling/installing GCC."
  104.  
  105. echo
  106. echo ">>> Cross-compiler for ${TARGET} installed."
  107.