The following is steps to build cross compilers. So far, I tried only for PowerPC and MIPS.
Basically, all you have to do is to follow the following 9 steps.
First, you have to obtain the following source codes
First, choose your taget such as powerpc-eabi, powerpc-elf, mips-elf, and so on
For bash simply type
% export TARGET=powerpc-eabi % export PREFIX=/usr/local/$TARGET % export PATH=$PATH:$PREFIX/bin
% tar xjfv binutils-2.17.tar.bz2 % mkdir build-binutils % cd build-binutils % ../binutils-2.17/configure --target=$TARGET --prefix=$PREFIX % make all % make install
% tar xjfv gcc-4.1.1.tar.bz2 % mkdir build-gcc % cd build-gcc % ../gcc-4.1.1/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --with-gnu-as --with-gnu-ld % make all-gcc % make install-gcc
--with-gnu-as --with-gnu-ld prevents native assembler on certain architectures. (for others, these do not have any effects)
Newlib provides standard C library for embedded systems
% tar xzfv newlib-1.14.0.tar.gz % mkdir build-newlib % cd build-newlib % ../newlib-1.14.0/configure --target=$TARGET --prefix=$PREFIX % make all % make install
% cd build-gcc % ../gcc-4.1.1/configure --target=$TARGET --prefix=$PREFIX --with-newlib --with-gnu-as --with-gnu-ld --disable-shared --disable-libssp % make all % make install
% tar xjfv gdb-6.3.tar.bz2 % mkdir build-gdb % cd build-gdb % ../gdb-6.3/configure --target=$TARGET --prefix=$PREFIX --enable-sim-powerpc --enable-sim-stdio % make all % make install
Congratulations! You build your tool chain
Now, it's time to compile your code.
% powerpc-eabi-gcc -mcpu=405 hello.c -o hello -msim % mips-elf-gcc -Tidt.ld -mips4 hello.c -o hello
-T option specifies libraries that include start code.
To Compile with specific Memory map
% powerpc-eabi-gcc -Wl,-Ttext,0x4000,-Tdata,0xf000 hello.c -msim (-Wl,-Ttext,0x4000,-Tdata,0x10000)
% powerpc-eabi-run hello % mips-elf-run hello
Copyright © 2007 Munehiro Nakazato. All rights reserved.