From 590d8b3f0739303158fe902fe5bd3766adeafdb4 Mon Sep 17 00:00:00 2001 From: David Welch Date: Mon, 28 May 2012 15:19:01 -0400 Subject: [PATCH] adding gnu toolchain build script, to build your own cross compiler --- buildgcc/README | 13 +++++++++++++ buildgcc/build_gcc | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 buildgcc/README create mode 100755 buildgcc/build_gcc diff --git a/buildgcc/README b/buildgcc/README new file mode 100644 index 0000000..21829ac --- /dev/null +++ b/buildgcc/README @@ -0,0 +1,13 @@ + +A script for building your own gnu toolchain for ARM. + +Derived directly from the same script at the mpx project at opencores.org + +Keep or change the PREFIX in the script to a path where you want the +binary to end up. + +sudo ./build_gcc + +then put whatever you had in your prefix/bin in the path. The default +gnuarm would mean /gnuarm/bin goes in the PATH. + diff --git a/buildgcc/build_gcc b/buildgcc/build_gcc new file mode 100755 index 0000000..b90c012 --- /dev/null +++ b/buildgcc/build_gcc @@ -0,0 +1,39 @@ + +# Usage +# sudo ./build_gcc + +# Setup vars +export TARGET=arm-none-eabi +export PREFIX=/gnuarm +export PATH=$PATH:$PREFIX/bin + +rm -rf build-* +rm -rf gcc-* +rm -rf binutils-* + +# Get archives +wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2 +wget http://ftp.gnu.org/gnu/gcc/gcc-4.7.0/gcc-4.7.0.tar.bz2 + +# Extract archives +bzip2 -dc binutils-2.22.tar.bz2 | tar -xf - +bzip2 -dc gcc-4.7.0.tar.bz2 | tar -xf - + +# Build binutils +mkdir build-binutils +cd build-binutils +../binutils-2.22/configure --target=$TARGET --prefix=$PREFIX +make all +make install + +# Build GCC +mkdir ../build-gcc +cd ../build-gcc +../gcc-4.7.0/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --with-gnu-as --with-gnu-ld +make all-gcc +make install-gcc + +# Build libgcc.a +make all-target-libgcc CFLAGS_FOR_TARGET="-g -O2" +make install-target-libgcc +