HOWTO BUILD A CROSS COMPILER WITH EMERGE ! ------------------------------------------------------------ Before you read any further, you should try using 'crossdev' in portage. You're less likely to screw something up that way. Simply do `emerge '>=crossdev-0.9'` and then execute `crossdev --help`. The insturctions below are for those who wish to learn more about the details of how crossdev works wrt portage. You could probably give two shits, so just use crossdev ! ------------------------------------------------------------ ------------- PACKAGE NOTES ------------- - binutils Only binutils versions that 'inherit toolchain-binutils' will work. The host system should also being using one of these versions or you'll probably break your system. - linux-headers Any version that has 'inherit kernel-2' should work. - gcc Only gcc versions that 'inherit toolchain' will work. Supported versions: 3.3.6+ 3.4.6+ 4.0.3+ 4.1.1+ Anything else you're on your own. - glibc Supported versions: 2.3.6-r4+ 2.4-r3+ Anything else you're on your own. ------------- GENERAL NOTES ------------- - ARCH / USE sometimes you may have to pass ARCH / USE to the emerge process for things to work properly. For example, glibc will only apply hppa patches if 'hppa' is in ARCH / USE. This is a bug and I am working on fixing it :). - CFLAGS All packages should be built with your HOST's CFLAGS except for glibc. When building glibc, change your CFLAGS to something for the target host. ------------- ON TO THE FUN ------------- (1) Pick your target. Any valid 'CHOST' will do. I will be using 'hppa2.0-unknown-linux-gnu'. (2) Setup 'categories'. $ mkdir -p /etc/portage $ echo cross-hppa2.0-unknown-linux-gnu >> /etc/portage/categories (3) Setup PORTDIR_OVERLAY. For more info, see make.conf(5) manpage. My overlay is /usr/local/portage. $ mkdir -p /usr/local/portage/cross-hppa2.0-unknown-linux-gnu $ cd /usr/local/portage/cross-hppa2.0-unknown-linux-gnu $ ln -s /usr/portage/sys-devel/binutils binutils $ ln -s /usr/portage/sys-devel/gcc gcc $ ln -s /usr/portage/sys-kernel/linux-headers linux-headers $ ln -s /usr/portage/sys-libs/glibc glibc (4) Emerge binutils. $ emerge cross-hppa2.0-unknown-linux-gnu/binutils (5) Emerge gcc [C compiler only]. $ USE=nocxx emerge cross-hppa2.0-unknown-linux-gnu/gcc < run gcc-config for the new compiler > (6) Emerge linux headers. $ emerge cross-hppa2.0-unknown-linux-gnu/linux-headers (7) Emerge glibc. $ USE=hppa emerge cross-hppa2.0-unknown-linux-gnu/glibc (8) Emerge gcc [C and C++ compiler]. $ emerge cross-hppa2.0-unknown-linux-gnu/gcc (9) Build stuff ! When you go to emerge packages, you should just need to do: ROOT=/blah/ CHOST=hppa2.0-unknown-linux-gnu emerge cpio - you should also set CBUILD to your building machine for completeness sake ... most of the time you won't need it, but sometimes you will :) - CTARGET is no longer needed so don't set it ! If you want to cross compile a kernel, do this: make ARCH=hppa CROSS_COMPILE=hppa2.0-unknown-linux-gnu-