Changeset 89c57b6 in mainline for tools/toolchain.sh
- Timestamp:
- 2011-04-13T14:45:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 88634420
- Parents:
- cefb126 (diff), 17279ead (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/toolchain.sh
rcefb126 r89c57b6 1 #! /bin/bash1 #! /bin/bash 2 2 3 3 # … … 29 29 # 30 30 31 GMP_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 41 EOF 42 43 MPFR_MAIN=<<EOF 44 #if MPFR_VERSION < MPFR_VERSION_NUM(2, 4, 2) 45 choke me 46 #endif 47 EOF 48 49 MPC_MAIN=<<EOF 50 #if MPC_VERSION < MPC_VERSION_NUM(0, 8, 1) 51 choke me 52 #endif 53 EOF 54 55 BINUTILS_VERSION="2.21" 56 GCC_VERSION="4.6.0" 57 58 BASEDIR="`pwd`" 59 BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2" 60 GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2" 61 GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2" 62 GCC_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 # 68 check_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 102 check_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 } 109 31 110 check_error() { 32 111 if [ "$1" -ne "0" ]; then 33 112 echo 34 113 echo "Script failed: $2" 114 35 115 exit 1 36 116 fi … … 45 125 echo 46 126 echo "Checksum of ${FILE} does not match." 127 47 128 exit 2 48 129 fi … … 60 141 echo " ia32 IA-32 (x86, i386)" 61 142 echo " ia64 IA-64 (Itanium)" 62 echo " mips32 MIPS little-endian" 63 echo " mips32eb MIPS big-endian" 143 echo " mips32 MIPS little-endian 32b" 144 echo " mips32eb MIPS big-endian 32b" 145 echo " mips64 MIPS little-endian 64b" 64 146 echo " ppc32 32-bit PowerPC" 65 147 echo " ppc64 64-bit PowerPC" 66 148 echo " sparc64 SPARC V9" 67 149 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." 68 155 echo 69 156 … … 71 158 } 72 159 73 download_check() { 160 change_title() { 161 echo -en "\e]0;$1\a" 162 } 163 164 show_countdown() { 165 TM="$1" 166 167 if [ "${TM}" -eq 0 ] ; then 168 echo 169 return 0 170 fi 171 172 echo -n "${TM} " 173 change_title "${TM}" 174 sleep 1 175 176 TM="`expr "${TM}" - 1`" 177 show_countdown "${TM}" 178 } 179 180 show_dependencies() { 181 echo "IMPORTANT NOTICE:" 182 echo 183 echo "For a successful compilation and use of the cross-compiler" 184 echo "toolchain you need at least the following dependencies." 185 echo 186 echo "Please make sure that the dependencies are present in your" 187 echo "system. Otherwise the compilation process might fail after" 188 echo "a few seconds or minutes." 189 echo 190 echo " - SED, AWK, Flex, Bison, gzip, bzip2, Bourne Shell" 191 echo " - gettext, zlib, Texinfo, libelf, libgomp" 192 echo " - GNU Multiple Precision Library (GMP)" 193 echo " - GNU Make" 194 echo " - GNU tar" 195 echo " - GNU Coreutils" 196 echo " - GNU Sharutils" 197 echo " - MPFR" 198 echo " - MPC" 199 echo " - Parma Polyhedra Library (PPL)" 200 echo " - ClooG-PPL" 201 echo " - native C compiler, assembler and linker" 202 echo " - native C library with headers" 203 echo 204 } 205 206 download_fetch() { 74 207 SOURCE="$1" 75 208 FILE="$2" … … 77 210 78 211 if [ ! -f "${FILE}" ]; then 212 change_title "Downloading ${FILE}" 79 213 wget -c "${SOURCE}${FILE}" 80 214 check_error $? "Error downloading ${FILE}." … … 84 218 } 85 219 220 source_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 86 231 cleanup_dir() { 87 232 DIR="$1" 88 233 89 234 if [ -d "${DIR}" ]; then 235 change_title "Removing ${DIR}" 90 236 echo " >>> Removing ${DIR}" 91 237 rm -fr "${DIR}" … … 97 243 DESC="$2" 98 244 245 change_title "Creating ${DESC}" 99 246 echo ">>> Creating ${DESC}" 100 247 … … 108 255 DESC="$2" 109 256 110 echo " >>> ${DESC}" 257 change_title "Unpacking ${DESC}" 258 echo " >>> Unpacking ${DESC}" 111 259 112 260 tar -xjf "${FILE}" … … 114 262 } 115 263 116 patch_binutils() { 117 PLATFORM="$1" 118 119 if [ "${PLATFORM}" == "arm32" ] ; then 120 patch -p1 <<EOF 121 diff -Naur binutils-2.20.orig/gas/config/tc-arm.c binutils-2.20/gas/config/tc-arm.c 122 --- binutils-2.20.orig/gas/config/tc-arm.c 2009-08-30 00:10:59.000000000 +0200 123 +++ binutils-2.20/gas/config/tc-arm.c 2009-11-02 14:25:11.000000000 +0100 124 @@ -2485,8 +2485,9 @@ 125 know (frag->tc_frag_data.first_map == NULL); 126 frag->tc_frag_data.first_map = symbolP; 127 } 128 - if (frag->tc_frag_data.last_map != NULL) 129 + if (frag->tc_frag_data.last_map != NULL) { 130 know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP)); 131 + } 132 frag->tc_frag_data.last_map = symbolP; 133 } 134 EOF 135 check_error $? "Error patching binutils" 136 fi 264 prepare() { 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" 137 276 } 138 277 … … 141 280 TARGET="$2" 142 281 143 BINUTILS_VERSION="2.20" 144 GCC_VERSION="4.5.0" 145 146 BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2" 147 GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2" 148 GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2" 149 GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2" 150 151 BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/" 152 GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/" 153 154 WORKDIR="`pwd`" 282 WORKDIR="${BASEDIR}/${PLATFORM}" 155 283 BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}" 156 284 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" … … 158 286 159 287 if [ -z "${CROSS_PREFIX}" ] ; then 160 CROSS_PREFIX="/usr/local "288 CROSS_PREFIX="/usr/local/cross" 161 289 fi 162 290 … … 164 292 165 293 echo ">>> Downloading tarballs" 166 download_check "${BINUTILS_SOURCE}" "${BINUTILS}" "ee2d3e996e9a2d669808713360fa96f8"167 download_check "${GCC_SOURCE}" "${GCC_CORE}" "58eda33c3184303628f91c42a7ab15b5"168 download_check "${GCC_SOURCE}" "${GCC_OBJC}" "8d8c01b6631b020cc6c167860fde2398"169 download_check "${GCC_SOURCE}" "${GCC_CPP}" "5ab93605af40def4844eda09ca769c2d"294 source_check "${BASEDIR}/${BINUTILS}" 295 source_check "${BASEDIR}/${GCC_CORE}" 296 source_check "${BASEDIR}/${GCC_OBJC}" 297 source_check "${BASEDIR}/${GCC_CPP}" 170 298 171 299 echo ">>> Removing previous content" 172 300 cleanup_dir "${PREFIX}" 173 cleanup_dir "${OBJDIR}" 174 cleanup_dir "${BINUTILSDIR}" 175 cleanup_dir "${GCCDIR}" 301 cleanup_dir "${WORKDIR}" 176 302 177 303 create_dir "${PREFIX}" "destination directory" … … 179 305 180 306 echo ">>> Unpacking tarballs" 181 unpack_tarball "${BINUTILS}" "binutils" 182 unpack_tarball "${GCC_CORE}" "GCC Core" 183 unpack_tarball "${GCC_OBJC}" "Objective C" 184 unpack_tarball "${GCC_CPP}" "C++" 185 186 echo ">>> Compiling and installing binutils" 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++" 314 315 echo ">>> Processing binutils (${PLATFORM})" 187 316 cd "${BINUTILSDIR}" 188 317 check_error $? "Change directory failed." 189 patch_binutils "${PLATFORM}" 190 ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls" 318 319 change_title "binutils: configure (${PLATFORM})" 320 ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls 191 321 check_error $? "Error configuring binutils." 322 323 change_title "binutils: make (${PLATFORM})" 192 324 make all install 193 325 check_error $? "Error compiling/installing binutils." 194 326 195 echo ">>> Compiling and installing GCC"327 echo ">>> Processing GCC (${PLATFORM})" 196 328 cd "${OBJDIR}" 197 329 check_error $? "Change directory failed." 330 331 change_title "GCC: configure (${PLATFORM})" 198 332 "${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 199 333 check_error $? "Error configuring GCC." 334 335 change_title "GCC: make (${PLATFORM})" 200 336 PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc 201 337 check_error $? "Error compiling/installing GCC." 202 338 203 cd "${ WORKDIR}"339 cd "${BASEDIR}" 204 340 check_error $? "Change directory failed." 205 341 206 342 echo ">>> Cleaning up" 207 cleanup_dir "${OBJDIR}" 208 cleanup_dir "${BINUTILSDIR}" 209 cleanup_dir "${GCCDIR}" 343 cleanup_dir "${WORKDIR}" 210 344 211 345 echo … … 219 353 case "$1" in 220 354 "amd64") 355 prepare 221 356 build_target "amd64" "amd64-linux-gnu" 222 357 ;; 223 358 "arm32") 359 prepare 224 360 build_target "arm32" "arm-linux-gnu" 225 361 ;; 226 362 "ia32") 363 prepare 227 364 build_target "ia32" "i686-pc-linux-gnu" 228 365 ;; 229 366 "ia64") 367 prepare 230 368 build_target "ia64" "ia64-pc-linux-gnu" 231 369 ;; 232 "ia64")233 build_target "ia64" "ia64-pc-linux-gnu"234 ;;235 370 "mips32") 371 prepare 236 372 build_target "mips32" "mipsel-linux-gnu" 237 373 ;; 238 374 "mips32eb") 375 prepare 239 376 build_target "mips32eb" "mips-linux-gnu" 240 377 ;; 378 "mips64") 379 prepare 380 build_target "mips64" "mips64el-linux-gnu" 381 ;; 241 382 "ppc32") 383 prepare 242 384 build_target "ppc32" "ppc-linux-gnu" 243 385 ;; 244 386 "ppc64") 387 prepare 245 388 build_target "ppc64" "ppc64-linux-gnu" 246 389 ;; 247 390 "sparc64") 391 prepare 248 392 build_target "sparc64" "sparc64-linux-gnu" 249 393 ;; 250 394 "all") 395 prepare 251 396 build_target "amd64" "amd64-linux-gnu" 252 397 build_target "arm32" "arm-linux-gnu" 253 398 build_target "ia32" "i686-pc-linux-gnu" 254 399 build_target "ia64" "ia64-pc-linux-gnu" 255 build_target "ia64" "ia64-pc-linux-gnu"256 400 build_target "mips32" "mipsel-linux-gnu" 257 401 build_target "mips32eb" "mips-linux-gnu" 402 build_target "mips64" "mips64el-linux-gnu" 258 403 build_target "ppc32" "ppc-linux-gnu" 259 404 build_target "ppc64" "ppc64-linux-gnu" 260 405 build_target "sparc64" "sparc64-linux-gnu" 261 406 ;; 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 ;; 262 421 *) 263 422 show_usage
Note:
See TracChangeset
for help on using the changeset viewer.