This package, toolchain-source, is used as a base package for all gcc
cross-compiler packages in debian. It contains the source-code of
GNU binutils and gcc. The cross-compiler packages Build-Depends on it
to have access to this source code during build time, and their source
packages only need a rules file that knows how to compile this code
for their specific target and a few other control files. In order to
make certain that the exact source code used to compile a specific
binary package is available in any debian distribution (as the policy
and GPL dictates) the Build-Depends has to be on an specific version
of toolchain-source and thus be updated and recompiled every time
toolchain-source is updated (see below).

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-corss 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-corss
  ... 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/
