Here we describe the steps necessary to setup the environment for cross-compilation of Gentoo packages for the Openmoko Freerunner. Please note that version numbers used in this description might change over time. It is also a good idea to take a look at the Gentoo cross-compile documentation to better understand what you do!
Make sure portage is up-to-date
emerge --sync
Cross-compilation with portage
- Install the necessary tools for getting the latest packages and the overlay.
Make sure you have webdav-neon and ssl enabled for subversion. I
recommend to use >dev-vcs/git-1.7 and you should enable USE="doc cvs
subversion tk" at least.
emerge dev-vcs/git subversion
- Get the overlay. Please substitute /path/to/location in the following commands with the directory you want to put the overlay in!
- manually
mkdir -p /path/to/location cd /path/to/location git clone git://git.overlays.gentoo.org/proj/embedded-cross.git openmoko-overlay export location=/path/to/location/openmoko-overlay
- with layman (test with git)
emerge --ask layman dev-python/pyxml # in case it is not installed yet layman --sync-all layman -a openmoko export location=`grep ^storage /etc/layman/layman.cfg|sed "s/.*:.//"`/openmoko/trunk
- manually
- The above command creates /path/to/location/openmoko-overlay, containing fixes for the build host and the target (Freerunner). Thus we need to add the overlay to the host.
echo '# Add the Openmoko overlay' >> /etc/make.conf echo PORTDIR_OVERLAY=\"$location/openmoko-target/ '$PORTDIR_OVERLAY'\" >> /etc/make.conf
- We also recommend to use the suggested overlay keywords and useflags of the overlay to avoid problems. This step is completely optional.
cd /etc/portage mkdir package.keywords ln -s $location/portage-flags-host/keywords package.keywords/openmoko-keywords
- Remerge python and libtool to get the cross-compile fixes. Ensure with eselect that the python version from openmoko-overlay is really used!
emerge -1 python libtool eselect python show
- Finally the version of python on your host and the version in the cross-root must be the same. For example its currently necessary to mask >dev-lang/python-2.6.4 in your host masks and in the cross-root masks until its ported to the overlay
- Emerge the cross development tool and the toolchain. Because newer versions of binutils are currently broken for our work, please use 2.18-r4. After issuing the second command you can get yourself a cup of coffee as this may take a while...
If you want to build a stable system you have to specify the -S flag so that the same crosscompiler will be installed, as you are going to install on the target system. Check your installed crosscompiler version with gcc-config:emerge crossdev crossdev --binutils 2.18-r4 --target armv4tl-softfloat-linux-gnueabi gcc-config -l [1] armv4tl-softfloat-linux-gnueabi-4.3.2 * [2] i686-pc-linux-gnu-4.3.2 *
- Emerge and setup the cross development helpers. After running the second command as root you should have the command emerge-armv4tl-softfloat-linux-gnueabi.
emerge crossdev-wrappers emerge-wrapper --init
- Furthermore, we need some autotool cache values stored in the overlay.
cd /usr/share/crossdev/include/site ln -s $location/portage-flags-host/arm-linux-gnueabi arm-linux-gnueabi
- Configure your /usr/armv4tl-softfloat-linux-gnueabi/etc/make.conf. Remember to substitute $location with the location of the overlay! If you are all new to Gentoo please do not add ~arm to your ACCEPT_KEYWORDS as this will also install unstable versions of packages. IMPORTANT: Please make sure to remove LDFLAGS lines and -I switches from CFLAGS if you had them in before. Tears and feathers will be prepared by the compile-gods for those who don't! Check the following lines:
CHOST=armv4tl-softfloat-linux-gnueabi ARCH=arm E_MACHINE=EM_ARM ACCEPT_KEYWORDS="arm" # Add ~arm here if you know what you do. MARCH_TUNE="-march=armv4t -mtune=arm920t" ROOT=/usr/${CHOST}/ PKG_CONFIG_PATH="${ROOT}/usr/lib/pkgconfig/" PORTDIR_OVERLAY="$location/openmoko-target ${ROOT}/usr/local/portage" VIDEO_CARDS="fbdev glamo dummy" INPUT_DEVICES="evdev keyboard mouse tslib" LINGUAS="en" - It's mandatory to set your profile. We suggest to use the openmoko profile here.
cd /usr/armv4tl-softfloat-linux-gnueabi/etc rm make.profile ln -s $location/openmoko-target/profiles/openmoko make.profile
- You might also want to and use the overlay keywords and useflags. This part is optional, but gets you package versions that are known to work if you are not using the ~arm keyword.
cd /usr/armv4tl-softfloat-linux-gnueabi/etc/portage mkdir package.keywords mkdir profile mkdir package.unmask mkdir package.use ln -s $location/portage-flags-target/keywords package.keywords/openmoko-keywords ln -s $location/portage-flags-target/provided/package.provided profile/package.provided ln -s $location/portage-flags-target/unmask package.unmask/openmoko-unmask ln -s $location/portage-flags-target/use package.use/openmoko-use
- Emerge the packages you want. Probably you want to start emerging system now... (You can also speed things along by untaring the stage3 tarball into /usr/armv4tl-softfloat-linux-gnueabi) (if you emerge system you may have to look after x-protos, see http://gentoo.mindzoo.de/index.cgi/wiki/X)
emerge-armv4tl-softfloat-linux-gnueabi <package>
Cross-compilation with paludis
Todo
Geek's env
Use this if you want more bugs. It is about more correct cross compilation way without hacks, or making hacks very local.
- make.conf
MARCH_TUNE="-march=armv4t -mtune=arm920t" CFLAGS="-Os -pipe ${MARCH_TUNE}" CXXFLAGS="${CFLAGS}" PKG_CONFIG_PATH="${ROOT}usr/lib/pkgconfig/" PKG_CONFIG_SYSROOT_DIR="${ROOT}" # No any LDFLAGS - Disable cross-fix-root in etc/portage/bashrc
#if [[ $EBUILD_PHASE == "postinst" ]]; then # [[ $EMERGE_FROM != binary ]] && cross-fix-root ${CHOST} #fi - Good Luck!, notify max_posedon about problems
What next
Have fun! Install it. And check others wiki pages for fixing specific problems
