Toolchain From Scratch?

Dan Kegel dank@kegel.com
Thu Nov 11 07:52:00 GMT 2004


Wu Mingqiao wrote:
> As you know, the term "from scratch" refers to the fact that
> absolutely no arm cross-development tools, no pre-compiled arm system
> libraries, and no native arm development environment, of any kind, are
> assumed already available. Apart from the host-native tools,
> everything else will be built from sources. This is a very common case
> if the cross-toolchain is to be used for embedded-systems development.
> 
> Now I have a question in building arm-linux toolchain on xscale with
> linux-2.4.21 kernel header files. Before building bootstrap gcc, I
> need to collect kernel header files. It was done such like the
> following:
> patch linux-2.4.21 with linux-2.4.21-rmk1.patch and
> linux-2.4.21-rmk1-xxx-board.patch (this patch will specify
> CROSS_COMPILE=arm-linux-)
> make xxx-board_config 
> make ARCH=arm oldconfig 
> make dep (this step will use arm-linux- tools)
> make ARCH=arm symlinks include/linux/version.h
> 
> The question is: 
>    Since the step 'make dep' is mandatory for linux-2.4.21, how the
> Toolchain From Scratch can be achieved?

A good question, and one which has been much on my mind :-)
Crosstool does it by not actually running make dep.
If you're using 2.4, it's easy; just do 'make symlinks include/linux/version.h',
and copy a couple crucial include directories.  If you're using 2.6, it's
harder.   Here's the interesting bit from
http://kegel.com/crosstool/crosstool-0.28-rc37/crosstool.sh
(it might not be completely right, but it seems to work):

echo Prepare kernel headers

cd $LINUX_DIR

if test -f "$KERNELCONFIG" ; then
     cp $KERNELCONFIG .config
fi
if test -f .config; then
     yes "" | make ARCH=$ARCH oldconfig
fi

# autodetect kernel version from contents of Makefile
KERNEL_VERSION=`awk '/^VERSION =/ { print $3 }' $LINUX_DIR/Makefile`
KERNEL_PATCHLEVEL=`awk '/^PATCHLEVEL =/ { print $3 }' $LINUX_DIR/Makefile`

case "$KERNEL_VERSION.$KERNEL_PATCHLEVEL.x" in
2.2.x|2.4.x) make ARCH=$ARCH symlinks    include/linux/version.h
              ;;
2.6.x)       case $ARCH in
              sh*)        # sh does secret stuff in 'make prepare' that can't be triggered separately,
                          # but happily, it doesn't use target gcc, so we can use it.
                          make ARCH=$ARCH prepare include/linux/version.h
                          ;;
              arm*|cris*) make ARCH=$ARCH include/asm include/linux/version.h include/asm-$ARCH/.arch
                          ;;
              mips*)      # for linux-2.6, 'make prepare' for mips doesn't
                          # actually create any symlinks.  Hope generic is ok.
                          # Note that glibc ignores all -I flags passed in CFLAGS,
                          # so you have to use -isystem.
                          make ARCH=$ARCH include/asm include/linux/version.h
                          TARGET_CFLAGS="$TARGET_CFLAGS -isystem $LINUX_DIR/include/asm-mips/mach-generic"
                          ;;
              *)          make ARCH=$ARCH include/asm include/linux/version.h
                          ;;
              esac
              ;;
*)           abort "Unsupported kernel version $KERNEL_VERSION.$KERNEL_PATCHLEVEL"
esac

mkdir -p $HEADERDIR
cp -r include/linux $HEADERDIR
cp -r include/asm-${ARCH} $HEADERDIR/asm
cp -r include/asm-generic $HEADERDIR/asm-generic


-- 
Trying to get a job as a c++ developer?  See http://kegel.com/academy/getting-hired.html

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com



More information about the crossgcc mailing list