[FreeJ] debian tips - chroot and cross-compilers

dyne.org open discussions
Author: Luca Bigliardi
Date:  
To: freej
Subject: [FreeJ] debian tips - chroot and cross-compilers
Hi!

I'm sending you two tips I use to create chroot environments and
cross-compiler packages. They are a bit rude so if you have suggestions
you're more than welcome :)

# create chroot environment (simply use debootstrap)
debootstrap --arch i386 sid /path/of/your/chroot ftp://ftp.debian.org/debian/
# name your chroot, this is useful to avoid "where am I now?" if you have
# the following lines in your .bashrc:
# if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
# debian_chroot=$(cat /etc/debian_chroot)
# fi
#
# export PS1='\[\e[1m\]\h${debian_chroot:+($debian_chroot)}:\w\$\[\e[0m\] '
echo mychroot /path/of/your/chroot/etc/debian_chroot
# use your chroot (you can try "schroot" as well)
sudo chroot /path/of/your/chroot
mount /proc
echo "hi mum!"


## build a cross compiling environment
# build binutils
apt-get build-dep binutils
apt-get source binutils
cd binutils-2.18.1~cvs20080103
export TARGET=arm-linux-gnu
debian/rules binary-cross
cd ..
dpkg -i binutils-arm-linux_2.18.1~cvs20080103-1_i386.deb
# prepare for gcc build
apt-cross -a arm -u
apt-cross -a arm -k -i linux-libc-dev libc6 libc6-dev libdb1-compat
# build gcc
apt-get build-dep gcc-4.2
apt-get source gcc-4.2
cd gcc-4.2-4.2.3
export GCC_TARGET=arm
debian/rules control
debian/rules build
# WORKAROUND: patch with attached libstdc++-cross.patch (from #464365 + changes)
patch -p0 -i ../libstdc++-cross.patch
debian/rules binary
cd ..
dpkg -i cpp-4.2-arm-linux-gnu_4.2.3-1_i386.deb \
g++-4.2-arm-linux-gnu_4.2.3-1_i386.deb \
gcc-4.2-arm-linux-gnu_4.2.3-1_i386.deb \
gcc-4.2-arm-linux-gnu-base_4.2.3-1_i386.deb \
libstdc++6-4.2-dev-arm-cross_4.2.3-1_all.deb \
libstdc++6-4.2-pic-arm-cross_4.2.3-1_all.deb \
libstdc++6-arm-cross_4.2.3-1_all.deb
# use apt-cross to install libraries you need to compile your software and then
# properly export CC and CXX


HTH

Luca


-- 
Beware of programmers who carry screwdrivers.
                        -- Leonard Brandwein


http://shammash.homelinux.org/ - http://www.artha.org/ - http://www.yue.it/