#!/bin/bash # Setup PREFIX=/usr/local/arm TARGET=armv4l-unknown-linux-gnu SYSROOT=${PREFIX}/sysroot export ARCH=arm export SUBARCH=armv4l export CROSS_COMPILE=${TARGET}- export PATH=$PATH:${PREFIX}/bin mkdir -p ${PREFIX}/src # Get the sources cd ${PREFIX}/src for URL in \ http://ftp.gnu.org/gnu/binutils/binutils-2.16.tar.gz \ http://ftp.gnu.org/gnu/gcc/gcc-3.4.4/gcc-3.4.4.tar.bz2 \ "http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/flow.c.diff?cvsroot=gcc&only_with_tag=csl-arm-branch&r1=1.563.4.2&r2=1.563.4.3" \ http://frank.harvard.edu/~coldwell/toolchain/t-linux.diff \ http://ftp.gnu.org/gnu/glibc/glibc-2.3.5.tar.gz \ http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.3.5.tar.gz \ http://frank.harvard.edu/~coldwell/toolchain/ioperm.c.diff \ http://littlechips.com/downloads/customer/CD_Images/LN2410SBC/Linux/Kernel/linux-2.6.13.2-lc6.tar.gz #http://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.10.tar.gz \ #http://maxim.org.za/AT91RM9200/2.6/2.6.10-at91.patch.gz \ #http://maxim.org.za/AT91RM9200/2.6/26_at91_serial.c.gz do FILE=${URL##*/} FILE=${FILE%%\?*} [ -f ${FILE} ] || wget -O ${FILE} ${URL} done # GNU binutils cd ${PREFIX}/src tar xvfz binutils-2.16.tar.gz mkdir -p BUILD/binutils-2.16 cd BUILD/binutils-2.16 ../../binutils-2.16/configure --prefix=${PREFIX} --target=${TARGET} --with-sysroot=${SYSROOT} 2>&1 | tee configure.out make 2>&1 | tee make.out make install 2>&1 | tee -a make.out # Linux Kernel Headers cd ${PREFIX}/src tar xvfz linux-2.6.13.2-lc6.tar.gz ln -s linux-2.6.13.2-lc6 linux #zcat 2.6.10-at91.patch.gz | patch -d linux -p1 #zcat 26_at91_serial.c.gz >linux/drivers/serial/at91_serial.c cd linux #make at91rm9200dk_defconfig make include/linux/version.h mkdir -p ${SYSROOT}/usr/include cp -a ${PREFIX}/src/linux/include/linux ${SYSROOT}/usr/include/linux cp -a ${PREFIX}/src/linux/include/asm-arm ${SYSROOT}/usr/include/asm cp -a ${PREFIX}/src/linux/include/asm-generic ${SYSROOT}/usr/include/asm-generic # Glibc headers cd ${PREFIX}/src tar xvfz glibc-2.3.5.tar.gz patch -d glibc-2.3.5 -p1 &1 | tee configure.out make cross-compiling=yes install_root=${SYSROOT} install-headers 2>&1 | tee make.out touch ${SYSROOT}/usr/include/gnu/stubs.h touch ${SYSROOT}/usr/include/bits/stdio_lim.h # Step 4: stage 1 gcc cd ${PREFIX}/src bunzip2 -c gcc-3.4.4.tar.bz2 | tar xvf - patch -d gcc-3.4.4 -p1 < flow.c.diff patch -d gcc-3.4.4 -p1 < t-linux.diff mkdir -p BUILD/gcc-3.4.4-stage1 cd BUILD/gcc-3.4.4-stage1 ../../gcc-3.4.4/configure --prefix=${PREFIX} --target=${TARGET} --enable-languages=c --with-sysroot=${SYSROOT} 2>&1 | tee configure.out make 2>&1 | tee make.out make install 2>&1 | tee -a make.out # Step 5: glibc cd ${PREFIX}/src mkdir BUILD/glibc-2.3.5 cd BUILD/glibc-2.3.5 BUILD_CC=gcc CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar RANLIB=${CROSS_COMPILE}ranlib AS=${CROSS_COMPILE}as LD=${CROSS_COMPILE}ld ../../glibc-2.3.5/configure --prefix=/usr --build=i386-debian-linux --host=${TARGET} --target=${TARGET} --without-__thread --enable-add-ons=linuxthreads --with-headers=${SYSROOT}/usr/include 2>&1 | tee configure.out make 2>&1 | tee make.out make install_root=${SYSROOT} install # Step 6: stage 2 gcc cd ${PREFIX}/src mkdir BUILD/gcc-3.4.4 cd BUILD/gcc-3.4.4 ../../gcc-3.4.4/configure --prefix=${PREFIX} --target=${TARGET} --enable-languages=c --with-sysroot=${SYSROOT} 2>&1 | tee configure.out make 2>&1 | tee make.out make install 2>&1 | tee -a make.out cd ../.. # Step 7: Linux kernel cd ${PREFIX}/src/linux make zImage make modules make INSTALL_MOD_PATH=${SYSROOT} modules_install