Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This is a script for building gcc cross compilers.
# Building xgcc for C:
# On a mac install the latest gcc binaries via
sudo port install gcc48
port select --list gcc
sudo port select --set gcc mp-gcc48
hash -r
# Building xgcc:
# Download and extract binutils, gcc, newlib, and gdb sources:
cd $HOME/Downloads
tar zxvf binutils-2.23.2.tar.bz2
tar zxvf gcc-4.8.1.tar.bz2
tar zxvf newlib-1.20.0.tar.gz
tar zxvf gdb-7.6.tar.bz2
# Download gcc dependencies:
cd gcc-4.8.1
cd ..
# Select target
export TARGET=mips-elf
# For i386-elf:
# export TARGET=i386-elf
export PREFIX=$HOME/Dropbox/Tools/$TARGET
export PATH=$PATH:$PREFIX/bin
# Configure and build binutils:
mkdir binutils-build
cd binutils-build
../binutils-2.23.2/configure --target=$TARGET --prefix=$PREFIX
make install
cd ..
# Configure and build bootstrap xgcc:
mkdir gcc-build
cd gcc-build
../gcc-4.8.1/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c --without-headers --with-newlib --with-gnu-as --with-gnu-ld
make all-gcc
make install-gcc
cd ..
# Configure and build newlib:
mkdir newlib-build
cd newlib-build
../newlib-1.20.0/configure --target=$TARGET --prefix=$PREFIX
make install
# Configure and build xgcc:
cd gcc-build
../gcc-4.8.1/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c --with-newlib --with-gnu-as --with-gnu-ld --disable-shared --disable-libssp
make install
cd ..
# Configure and build gdb:
mkdir gdb-build
cd gdb-build
../gdb-7.6/configure --target=$TARGET --prefix=$PREFIX --disable-tui
make install
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.