The Xbox 360 CPU is based on IBM's Power Architecture. Unless you have a machine with PowerPC CPU and Linux running (such as an older Mac or a PS3), you need to set up a cross compiler toolchain in order to compile code like the Linux Kernel for your Xbox 360.
A typical cross compiler toolchain for the GNU compiler collection usually consists of three major parts:
- the GNU binutils package
- the gcc compiler
- a implementation of the standard C library (can be left out if you only want to cross compile the Linux kernel)
Compiling a compiler on its own platform is already a quite complex task, compiling a compiler for a different platform adds even more caveats as not all versions of binutils, gcc and glibc work together well.
The easiest way to set up a complete cross compiler toolchain is to use Dan Kegel's crosstool as it does most of the work automatically for you using ready made shell scripts. Especially the author has already tried lots of combinations of binutils, GCC and glibc to mark the working ones. A complete documentation of crosstool can be found at the crosstool website. For a quick start, we will summarize the instructions from the crosstool-howto:
0. Preparations: Make sure you have the following basic UNIX tools installed (with the variety of Linux distributions available, you never know...):
- gcc & friends (targeting your own platform)
1. Download and unpack the crosstool scripts. E.g. in your home directory type:
tar -xzvf crosstool-0.43.tar.gz
2. Create the target directories for your cross compilation tools and make them writable for your user. We are using the default which is /opt/crosstool. You will probably need to be root for that so either su before typing these commands and replace $USER with your username or use sudo like in the example:
sudo mkdir /opt/crosstool
sudo chown $USER /opt/crosstool
3. Run the compilation script for the powerpc target.
4. Get a drink, go for a walk or use the time to remove the resistor R6T3 from the mainboard of your Xbox 360... Compilation of your cross compiler will just take a while.
5. When finished, you may want to add your cross compiler binaries to your PATH environment variable.
You're done. Feel free to configure and compile your Linux Kernel.
Using the Xenon Toolchain
An alternative method is to use the Xenon Toolchain. Its using current gcc and does not take as long as crossotool to compile.