bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cross-compiling guide


From: Alfred M. Szmidt
Subject: Cross-compiling guide
Date: Sun, 05 Sep 2004 02:47:36 +0200

I needed to do a full bootstrap, and since the instructions in
INSTALL-cross are outdated I made my own notes.  Recall that these are
notes, not some nicely polished document on how to build a
cross-compiler for GNU/Hurd.  Even if they are just notes, any
suggestions, improvments, etc are welcome; maybe if it gets polished
enough it can replace INSTALL-cross.

You can also find said document at:
http://www.update.uu.se/~ams/doc/

===File ~/public_html/doc/cross-compiler====================
* Building a cross-compiler for GNU/Hurd         -*- Outline -*-

Time-stamp: <2004-09-05 02:41:59 ams>

The following steps if followed closely but not blindly, will produce
a working cross-compiler for GNU/Hurd.

* The cross-compiler

** Initial steps

First we set a couple of variables to make our life easier.

T=/path/to/cross/compiler/

BINUTILS=$T/src/binutils-2.15
GCC=$T/src/gcc-3.4.1

GNUMACH=$T/src/gnumach--gnumach-1-branch
HURD=$T/src/hurd
MIG=$T/src/mig
LIBC=$T/src/libc

GNU_ROOT=$T/gnu

We then create a inital staging area for our GNU system that will be
built.  And create all the object directories that will be used during
building.

cd $T
mkdir gnu gnu/lib gnu/include i386-unknown-gnu0.3 \
      $GNUMACH.obj $HURD.obj $BINUTILS.obj $GCC.obj $MIG.obj $LIBC.obj
cd i386-unknown-gnu0.3
ln -s ../gnu/lib lib
ln -s ../gnu/include

** GNU Mach headers

cd $GNUMACH.obj
$GNUMACH/configure --host=i386-unknown-gnu0.3 --prefix=
make install-headers no_deps=t prefix=$GNU_ROOT/stow/`basename $GNUMACH`

(cd $GNU_ROOT/stow; stow --preserve-dirs *)

** Hurd headers

cd $HURD.obj
$HURD/configure --build=i686-pc-linux-gnu --host=i386-unknown-gnu0.3 
--disable-profile --prefix=
make version.h
make install-headers no_deps=t prefix=$GNU_ROOT/stow/`basename $HURD`

(cd $GNU_ROOT/stow; stow --preserve-dirs *)

** Cross-Binutils

cd $BINUTILS.obj
export PATH=$T/bin:$PATH
$BINUTILS/configure --target=i386-unknown-gnu0.3 --prefix=$T
make
make install prefix=$T/stow/`basename $BINUTILS`

(cd $T/stow; stow --preserve-dirs *)

** Cross-GCC - Stage 1

cd $GCC.obj
$GCC/configure --target=i386-unknown-gnu0.3 --enable-languages=c --prefix=$T 
make -k
make install -k prefix=$T/stow/`basename $GCC`

(cd $T/stow; stow --preserve-dirs *)

** Cross-MiG

cd $MIG.obj
$MIG/configure --prefix=$T --host=i686-pc-linux-gnu --target=i386-unknown-gnu0.3
make
make install prefix=$T/stow/`basename $MIG`

(cd $T/stow; stow --preserve-dirs *)

** The GNU C Library - Stage 1

cd $LIBC.obj
CC=i386-unknown-gnu0.3-gcc $LIBC/configure --prefix= --build=i686-pc-linux-gnu 
--host=i386-unknown-gnu0.3 --disable-profile
make -k
make -k install install_root=$GNU_ROOT/stow/`basename $LIBC`
touch $GNU_ROOT/stow/`basename $LIBC`/include/gnu/stubs.h

(cd $GNU_ROOT/stow; stow --preserve-dirs *)

** Cross-GCC - Stage 2

cd $GCC.obj
make -k
make -k install prefix=$T/stow/`basename $GCC`

Install static libgcc.a and libgcc_eh.a so that we can compile glibc.

cd gcc
_foo=`basename $GCC`
GCC_VER=`echo $_foo | sed -ne s/gcc-//pg`
cp libgcc_eh.a libgcc.a $T/stow/`basename 
$GCC`/lib/gcc/i386-unknown-gnu0.3/$GCC_VER

(cd $T/stow; stow --preserve-dirs *)

** The GNU C Library - Stage 2

cd $LIBC.obj
make 
make install install_root=$GNU_ROOT/stow/`basename $LIBC`

Edit $GNU_ROOT/lib/libc.so and remove the leading "/lib/" paths.

cat $GNU_ROOT/stow/`basename $LIBC`/lib/libc.so | sed -e "s/\/lib\///g" > 
/tmp/foo
mv /tmp/foo $GNU_ROOT/stow/`basename $LIBC`/lib./libc.so

(cd $GNU_ROOT/stow; stow --preserve-dirs *)

** Cross-GCC - Stage 3

cd $GCC.obj
make 
make install prefix=$T/stow/`basename $GCC`

(cd $T/stow; stow --preserve-dirs *)

* Rest of the world.

The cross-compiler setup is done now, building the Hurd, GNU Mach or
anyother utility can be done passing the following to configure:

--build=i686-pc-linux-gnu --host=i386-unknown-gnu0.3
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]