This package, toolchain-source, contains the source-code of
GNU binutils, gcc and gdb. The cross-compiler packages can Build-Depend
on it to have access to this source code during build time. It can
be used to create cross compiler packages. The quick way is to use:

  tpkg-install <target>

which will download the binary libc debs from the specified
architecture and install them using dpkg-cross. Then binutils, gcc and
gdb source packags will be created using tpkg-make. These packages are
then compiled and installed. The exact steps are described below.

<target> should be one of alpha-linux, arm-linux, hppa-linux, i*86-linux, 
ia32-linux, ia64-linux, m68k-linux, mipsel-linux, mips-linux, ppc-linux, 
powerpc-linux, sparc-linux, s390-linux or similar.


This package also contains two scripts, tpkg-make and tpkg-update,
used to create and update the different cross-compiler packages. To
create the source packages for any specific target simply use:

  apt-get install toolchain-source
  tpkg-make <target>

This will create two unpacked source packages binutils-<target>-<ver>
and gcc-<target>-<ver> in the current directory. These packages are
ready to build, but you'll probably want to customize the options
passed to configure and make in there debian/rules files. You have to
build and install the binutils package before you can build the gcc
package. If you are lucky and everything works as it's supposed the
following commands will build and install the compiler (debi has to be
run as root since it install the package):

  cd binutils-<target>-<ver>
  debuild
  debi

  cd ../gcc-<target>-<ver>
  debuild
  debi

Quite a few of the targets needs bits of libc and associated
stuff. This generally has to be solved by hand. But if there is a
debian port for the target the compiled binary packages of this
distribution can be used. Before they can be installed they have to be
converted so that the the libs are placed in /usr/<target>/lib instead
of /usr/lib (otherwise that native libs will be overwritten). This can
be done with the dpkg-cross script (from the dpkg-cross package). Make
sure that crossbase in /etc/dpkg/cross-compile is set to /usr/ (and
not /usr/local/ which is default). Included in this package is a
script, called tpkg-install-libc that will download convert and
install libc6 and libc6-dev for any supported architecture: 

  apt-get install dpkg-cross
  ... edit /etc/dpkg/cross-compile ...
  tpkg-install-libc <target>

The current version of dh_shlibdeps (debhelper 3.0.8) don't like shard
libs for architectures other than the native and will fail the build
process. Here is a simple patch that will make dh_shlibdeps ignore
those files. Hopefully this will be fixed in future versions.

72,73c72,73
<               $ff=file "$file";
<               if ($ff=~m/ELF/ && $ff!~/statically linked/) {
---
>               $ff=ldd "$file";
>               if ($ff !~ /not a dynamic executable/) {


When a new version of binutils or gcc is released upstream, the
toolchain-source will be updated. This means that all cross-compiler
packages have to be updated as well. To accomplish this we run the
tpkg-update script in the binutils-<target>-<ver> and
gcc-<target>-<ver> dirs. This will update the toolchain-source
dependency and add an appropriate changelog entry. Then the package
can be rebuilt with the new source code:

  apt-get install toolchain-source

  cd binutils-<target>-<ver>
  tpkg-update
  debuild
  debi

  cd ../gcc-<target>-<ver>
  tpkg-update
  debuild
  debi

--
Hakan Ardo <hakan@debian.org>, http://master.debian.org/~hakan/
