#!/bin/sh GLIBC=2.2.4 TARGET=--target=strongarm-linux-elf function test_mk_cd () { if [ ! -d $1 ] ; then mkdir $1 fi cd $1 } # # build_binutils - configure, build and install the cross assembler, linker, archiver and friends # function build_binutils () { rm -rf binutils-arm test_mk_cd binutils-arm ../../binutils-2.13/configure $TARGET make make install cd ../ } # # build_gcc - configure, build and install the C cross compiler # function build_gcc () { rm -rf gcc-arm test_mk_cd gcc-arm ../../gcc-3.2/configure $TARGET --prefix=/usr/local --with-headers=/usr/local/strongarm-linux-elf/include --disable-threads --enable-languages=c --with-newlib if make ; then make install else echo "failed to build the C cross compiler" exit 1 fi cd ../ } # # build_gcc_with_clibs - configure, build and install the C cross compiler # function build_gcc_with_clibs () { rm -rf gcc-arm test_mk_cd gcc-arm ../../gcc-3.2/configure $TARGET --prefix=/usr/local --with-headers=/usr/local/strongarm-linux-elf/include --disable-threads --enable-languages=c,gm2 --with-newlib if make ; then make install else echo "failed to build C and Modula-2 cross compilers" exit 1 fi cd ../ } # # build_glibc - configure, build and install glibc for the arm # Turn off as many features as possible, it broke with some of # these features enabled. My aim was simply to get the compilers # operating, at the expense of shared libs, network stuff etc.. # function build_glibc () { rm -rf glibc-arm test_mk_cd glibc-arm export CC=strongarm-linux-elf-gcc # # notice that glibc will not accept arm-linux-elf # ../../glibc-$GLIBC/configure arm-linux --build=i586-linux --with-headers=/usr/local/strongarm-linux-elf/include --prefix=/usr/local/strongarm-linux-elf --disable-sanity-checks --disable-shared --disable-profile --enable-static-nss if make ; then export LANGUAGE=C export LC_ALL=C make install unset LC_ALL unset LANGUAGE fi unset CC cd ../ } # # build_newlib - only configure, build and install crt0.o from newlib for the arm # function build_newlib () { rm -rf newlib-arm test_mk_cd newlib-arm ../../newlib-1.10.0/newlib/libc/sys/linux/configure --target=arm-linux make "CC=strongarm-linux-elf-gcc" crt0.o cp crt0.o /usr/local/lib/gcc-lib/strongarm-linux-elf/3.2 cd ../ } # # unpack_headers - unpack arm linux headers built (copied) from linux-2.4.18 # once it was configured for the arm sa1110 processor using # menuconfig, make dep and taring up the /usr/..../linux/include/linux # directories # function unpack_headers () { gzip -dc ../strongarm-headers.tar.gz | ( cd / ; tar xf - ) } function clean_slate () { rm -rf /usr/local/lib/gcc-lib/strongarm-linux-elf } function test_and_unpack () { if [ ! -d $1 ] ; then echo -n "cannot find $1 unpacking $2 please wait " if [ "`basename $2 .gz`.gz" = "`basename $2`" ] ; then gzip -dc $2 | tar xf - elif [ "`basename $2 .bz2`.bz2" = "`basename $2`" ] ; then bzip2 -dc $2 | tar xf - else echo "do not know how to extract $2" exit 1 fi echo "done" fi } function unpack_packages () { test_and_unpack binutils-2.13 binutils-2.13.tar.bz2 if [ ! -d gcc-3.2 ] ; then ./gm2-out-of-the-box -n fi test_and_unpack glibc-$GLIBC glibc-2.2.4.tar.gz test_and_unpack newlib-1.10.0 newlib-1.10.0.tar.gz } export PATH=/usr/bin:$PATH # # please check the clean slate, if you are worried comment it out # # clean_slate # check this function as it is aggressive unpack_packages test_mk_cd build # move into the build directory build_binutils unpack_headers # unpack strongarm sys headers (from the linux kernel) build_gcc build_newlib # build crt0.o build_glibc # # now build the C compiler (gcc) again and also gm2 :-) using glibc library and C headers # build_gcc_with_clibs