Project:Android/build

It is posible to build Gentoo RAP on your Android device from scratch. Actually, the precompiled tarball is itself made like this.

The target prefix directory EPREFIX is assumed to be /data/gentoo. The target architecture CTARGET is assumed to be armv7a-hardfloat-linux-gnueabi.

Compiler
If, as usually the case, no compiler is available on the device, you'll need to cross compile one. It is often useful to get the compiler into the EPREFIX as well, which is a process of cross triplet-prefix.

Cross triplet refers to the normal cross compiling as covered by the Embedded Handbook. While cross prefix in Gentoo Prefix is to build a package from an existing Gentoo instance into a different prefix. Cross triplet-prefix is doing the two things at once.

Prepare Cross Toolchain
Follow the corresponding session of Embedded Handbook.

Cross Build
Follow the cross triplet counterpart, make sure to use an appropriate RAP profile, and preferrably, turn off the nls and acl USE flags. In addition the new EPREFIX should be exported.

Make sure to export EPREFIX again upon opening a new shell.

Tune cross toolchain
ELFs needs to point to the dynamic linker in EPREFIX. Cross toolchain should be tuned, which is done by tweaking specs file. An helper script rt-sysroot eases the tweaking.

The helper essentially let the cross compiler search into ${ROOT}${EPREFIX} and point the interpreter field of ELFs to the dynamic linker inside EPREFIX.

Run the script:

binutils and gcc
Build everything else:

Now you have a functioning native toolchain inside EPREFIX for the target device, copy the ROOT directory over the target device and test out.

Bootstrap
The remaining process is essentially bootstraping a Gentoo RAP into EPREFIX.

On the target device with a compiler in PATH, get the bootstrap script and execute it:

Follow the prompts, give the correct EPREFIX, and wait till it finishes.