README for GNU toolchain patches
================================

In this directory are the patches to GNU binutils and gcc to add support for
the i386-pc-speck target. Instructions on how to build a cross-compiler
follow. They assume you're running *NIX (Linux/FreeBSD/Solaris/whatever),
but I've only tested on Linux/i386. Make sure you're root before you do this.

note: don't take the paths literally; "/src/dir", for example, means a
directory on a drive with enough room for the source code, and
"/path/to/speck" means wherever you've installed the speck source tree.

binutils
--------

- first, unpack binutils:
cd /src/dir
tar zxvf /path/to/binutils-2.11.2.tar.gz

- now apply the patch
cd /src/dir/binutils-2.11.2
cat /path/to/speck/patches/binutils-2.11.2-speck.patch.gz | gunzip -cd \
  | patch -p1

- create a build dir
mkdir /build/dir

- configure
cd /build/dir
/src/dir/binutils-2.11.2/configure --prefix=/usr/local --target=i386-pc-speck

- build
make
make install

- you're done
You should now have /usr/local/i386-pc-speck/bin/{as,ld,ar,...} as well as
/usr/local/bin/i386-pc-speck-{as,ld,..} Note: sometimes as, ld, and gasp
have a "no" suffix appended to the executable - a configure script bug,
probably. Manually rename /usr/local/i386-pc/speck/bin/* and /usr/local/bin
/i386-pc-speck-* executables if this happens.

gcc
---

- unpack gcc
cd /src/dir
tar zxvf /path/to/gcc-2.95.2.tar.gz

- apply the patch
cd /src/dir/gcc-2.95.2
cat /path/to/speck/patches/gcc-2.95.2-speck.patch.gz | gunzip -cd \
  | patch -p1

- create a build dir
mkdir /build/dir

- configure
cd /build/dir
export LANGUAGES="c"
/src/dir/configure --prefix=/usr/local --target=i386-pc-speck --with-headers=/usr/include

[note: "/usr/include" is specified as the target header directory only because libgcc2.c,
which is compiled for the target, needs some Unix header files which speck does not yet
have. Your system include files are not actually used by speck, because the /usr/local/
i386-pc-speck/sys-include directory is overwritten by the speck libc headers the first
time libc is compiled.]

- build
make

[note: sometimes gcc fails to build because of a missing "fixinc.sh", which should be
copied to the build directory but isn't. Do "cp /src/dir/gcc-2.95.2/gcc/fixinc.sh
/build/dir/gcc/fixinc.sh" to fix this, then type "make" again. It should build without
errors.]

make install

- install the speck C library

NOTE: I have not actually written the speck libc yet. Disregard this section
for now.

cd /path/to/speck/libc
make

[note: you may want to "chown -R youruser.yourgroup /usr/local/bin/i386-pc-speck/
sys-include" so that you can install the speck headers after you've changed them 
without being root.]

- you're done
you should now have /usr/local/bin/i386-pc-speck-gcc, and it should work.
