Emdebian Cross Development Environment
Emdebian toolchain building Howto
Below is documented the build process for building cross-toolchains the 'Debian Way'. You only need to do this if the pre-built binary toolchains do not satisfy your needs for some reason.
A more up to date document can be found at Debian wiki.
We use the buildcross script to build the toolchains, it is also provided as a Debian package in the experimental suite. (buildcross replaces the old compbuildscript and emchain.)
Notation and exactly what things are called is important otherwise there can be much confusion, so we will clarify:
When building toolchains:
build == host
Build machine installing the cross compiler build Host machine running the cross compiler host Target machine for which the compiler builds code target
When building packages:
build != host
build machine running the cross compiler build host machine running the built package handheld device there is no particular meaning for 'target'.
Building your own toolchain is not a trivial matter, although this method is actually quite strightforward.
- gcc-4.0 or later
First get all the necessary build dependencies:
$ apt-get install dpkg-cross apt-cross fakeroot dpatch gawk flex realpath automake1.7 debhelper cdbs
This is not a complete list, of course you need gcc, but these are the most often forgotten ones.
Get the necessary sources :
$ apt-get source gcc-4.4 binutils
$ cd binutils-2.x
$ TARGET=$linux-architecture fakeroot debian/rules binary-cross (replace arch by arm, alpha,...)Note that binutils versions above 2.20.51, have changed syntax to support TARGET=$linux-architecture dpkg-buildpackage -b -uc -us
Once the build is finished you have to install the package that was created with dpkg -i
For the next step you can use the existing Debian packages for your target architecture, after converting them with dpkg-cross, for the kernel-headers, and the related architectures
Download, convert and install the packages for libc6, libc6-dev and linux-libc-dev for your target architecture.
$ dpkg-cross -a $architecture -b $package
You can also try a other tools trying to do smarter things as xapt package which replaces apt-cross and it is not available from squeeze, so get it from squeeze backports or wheezy.
$ xapt -a arch package
When this process was succesful, we start with the last steps. We have to build the actual compiler.
$ export GCC_TARGET=arch (replace arch through arm, alpha,...)
$ cd gcc-4.4-x
$ fakeroot debian/rules control
$ dpkg-buildpackage -b -rfakeroot
After a succesful build, install the newly created gcc packages with dpkg -i package-name. These are (for arm):
- libstdc++6-armel-cross_4.4.x_all.deb
- libstdc++6-dev-armel-cross_4.4.x_all.deb
- g++-4.4-arm-linux-gnueabi_4.4.x_i386.deb
- gcc-4.4-arm-linux-gnueabi_4.4.x_i386.deb
- cpp-4.4-arm-linux-gnueabi_4.4.x_i386.deb
- libgcc1-arm-cross_4.4.x_all.deb
- gcc-4.4-arm-linux-gnueabi-base_4.4.x_i386.deb
Now you should have a brand new cross-compiler at your disposal.
Back to the Emdebian Project homepage.