Subversion Repositories HelenOS

Rev

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