2002-03-27 09:25:09 +00:00
|
|
|
#define _PAGE_ Building the SH1 cross compiler
|
|
|
|
#include "head.t"
|
|
|
|
|
|
|
|
<p>
|
|
|
|
In this example I will assume that you are running Linux with the bash shell.
|
|
|
|
We will only build the C compiler along with the assembler, linker and stuff.
|
2002-04-25 09:15:42 +00:00
|
|
|
Note that the procedure is exactly the same if you are running cygwin on Windows.
|
2002-06-17 13:47:20 +00:00
|
|
|
|
2002-03-27 09:25:09 +00:00
|
|
|
<h2>Download the source code</h2>
|
|
|
|
<p>
|
|
|
|
You will need the following archives:
|
|
|
|
<ul>
|
|
|
|
<li>binutils-2.11.tar.gz (find it at your closest GNU FTP site)
|
2002-06-19 15:57:33 +00:00
|
|
|
<li>gcc-3.0.4.tar.gz (find it at your closest GNU FTP site)
|
2002-03-27 09:25:09 +00:00
|
|
|
<li>(optional) gdb-5.1.1.tar.gz (find it at your closest GNU FTP site)
|
|
|
|
</ul>
|
2002-06-17 13:47:20 +00:00
|
|
|
|
2002-03-27 09:25:09 +00:00
|
|
|
<h2>Unpack the archives</h2>
|
|
|
|
<p>
|
|
|
|
<pre>
|
|
|
|
/home/linus> tar zxf binutils-2.11.tar.gz
|
2002-06-19 15:59:26 +00:00
|
|
|
/home/linus> tar zxf gcc-3.0.4.tar.gz
|
2002-03-27 09:25:09 +00:00
|
|
|
/home/linus> tar zxf gdb-5.1.1.tar.gz
|
|
|
|
</pre>
|
2002-06-17 13:47:20 +00:00
|
|
|
|
2002-03-27 09:25:09 +00:00
|
|
|
<h2>Create the directory tree</h2>
|
|
|
|
<p>
|
|
|
|
<pre>
|
|
|
|
/home/linus> mkdir build
|
|
|
|
/home/linus> cd build
|
|
|
|
/home/linus/build> mkdir binutils
|
|
|
|
/home/linus/build> mkdir gcc
|
|
|
|
/home/linus/build> mkdir gdb
|
|
|
|
</pre>
|
2002-06-17 13:47:20 +00:00
|
|
|
|
2002-03-28 13:54:38 +00:00
|
|
|
<h2>Choose location</h2>
|
2002-03-27 09:25:09 +00:00
|
|
|
<p>
|
|
|
|
Now is the time to decide where you want the tools to be installed. This is
|
|
|
|
the directory where all binaries, libraries, man pages and stuff end up when
|
|
|
|
you do "make install".
|
|
|
|
<p>
|
|
|
|
In this example I have chosen "/home/linus/sh1" as my installation directory, or <i>prefix</i> as it is called. Feel free to use any prefix, like
|
|
|
|
/usr/local/sh1 for example.
|
2002-06-17 13:47:20 +00:00
|
|
|
|
2002-03-27 09:25:09 +00:00
|
|
|
<h2>Build binutils</h2>
|
|
|
|
<p>
|
|
|
|
We will start with building the binutils (the assembler, linker and stuff).
|
|
|
|
This is pretty straightforward. We will be installing the whole tool chain
|
|
|
|
in the /home/linus/sh1 directory.
|
|
|
|
<pre>
|
|
|
|
/home/linus> cd build/binutils
|
|
|
|
/home/linus/build/binutils> ../../binutils-2.11/configure --target=sh-elf --prefix=/home/linus/sh1
|
|
|
|
/home/linus/build/binutils> make
|
|
|
|
/home/linus/build/binutils> make install
|
|
|
|
</pre>
|
2002-06-17 13:47:20 +00:00
|
|
|
|
2002-03-27 09:25:09 +00:00
|
|
|
<h2>Build GCC</h2>
|
|
|
|
<p>
|
|
|
|
Now you are ready to build GCC. To do this, you must have the newly built
|
|
|
|
binutils in the PATH.
|
|
|
|
<pre>
|
|
|
|
/home/linus> export PATH=/home/linus/sh1/bin:$PATH
|
|
|
|
/home/linus> cd build/gcc
|
2002-06-19 15:59:26 +00:00
|
|
|
/home/linus/gcc> ../../gcc-3.0.4/configure --target=sh-elf --prefix=/home/linus/sh1 --enable-languages=c
|
2002-04-24 12:53:25 +00:00
|
|
|
/home/linus/build/gcc> make
|
|
|
|
/home/linus/build/gcc> make install
|
2002-03-27 09:25:09 +00:00
|
|
|
</pre>
|
2002-06-17 13:47:20 +00:00
|
|
|
|
2002-03-27 09:25:09 +00:00
|
|
|
<h2>Build GDB</h2>
|
|
|
|
<p>
|
|
|
|
If you are planning to debug your code with GDB, you have to build it as well.
|
|
|
|
<pre>
|
|
|
|
/home/linus> export PATH=/home/linus/sh1/bin:$PATH
|
|
|
|
/home/linus> cd build/gdb
|
|
|
|
/home/linus/gdb> ../../gdb-5.1.1/configure --target=sh-elf --prefix=/home/linus/sh1
|
2002-04-24 12:53:25 +00:00
|
|
|
/home/linus/build/gdb> make
|
|
|
|
/home/linus/build/gdb> make install
|
2002-03-27 09:25:09 +00:00
|
|
|
</pre>
|
2002-06-17 13:47:20 +00:00
|
|
|
|
2002-03-27 09:25:09 +00:00
|
|
|
<h2>Done</h2>
|
|
|
|
<p>
|
|
|
|
If someone up there likes you, you now have a working tool chain for SH1.
|
|
|
|
To compile a file with gcc:
|
|
|
|
<pre>
|
|
|
|
/home/linus> sh-elf-gcc -c main.o main.c
|
|
|
|
</pre>
|
|
|
|
Good luck!
|
|
|
|
<p>
|
|
|
|
<i>Linus</i>
|
|
|
|
|
|
|
|
#include "foot.t"
|