diff options
Diffstat (limited to 'www/cross-gcc.t')
-rw-r--r-- | www/cross-gcc.t | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/www/cross-gcc.t b/www/cross-gcc.t new file mode 100644 index 0000000000..8e6b72a66c --- /dev/null +++ b/www/cross-gcc.t | |||
@@ -0,0 +1,92 @@ | |||
1 | #define _PAGE_ Building the SH1 cross compiler | ||
2 | #include "head.t" | ||
3 | |||
4 | <p> | ||
5 | In this example I will assume that you are running Linux with the bash shell. | ||
6 | We will only build the C compiler along with the assembler, linker and stuff. | ||
7 | <h2>Download the source code</h2> | ||
8 | <p> | ||
9 | You will need the following archives: | ||
10 | <ul> | ||
11 | <li>binutils-2.11.tar.gz (find it at your closest GNU FTP site) | ||
12 | <li>gcc-3.0.3.tar.gz (find it at your closest GNU FTP site) | ||
13 | <li>newlib-1.10.0.tar.gz (go to <a href="http://sources.redhat.com/newlib/">the newlib home page</a> for information) | ||
14 | <li>(optional) gdb-5.1.1.tar.gz (find it at your closest GNU FTP site) | ||
15 | </ul> | ||
16 | <h2>Unpack the archives</h2> | ||
17 | <p> | ||
18 | <pre> | ||
19 | /home/linus> tar zxf binutils-2.11.tar.gz | ||
20 | /home/linus> tar zxf gcc-3.0.3.tar.gz | ||
21 | /home/linus> tar zxf newlib-1.10.0.tar.gz | ||
22 | /home/linus> tar zxf gdb-5.1.1.tar.gz | ||
23 | </pre> | ||
24 | <h2>Create the directory tree</h2> | ||
25 | <p> | ||
26 | <pre> | ||
27 | /home/linus> mkdir build | ||
28 | /home/linus> cd build | ||
29 | /home/linus/build> mkdir binutils | ||
30 | /home/linus/build> mkdir gcc | ||
31 | /home/linus/build> mkdir gdb | ||
32 | </pre> | ||
33 | <h2>Create the newlib and libgloss links</h2> | ||
34 | <p> | ||
35 | The GCC configuration script finds the newlib and libgloss files if they are in the GCC tree. Let's create two soft links. | ||
36 | <pre> | ||
37 | /home/linus> cd gcc-3.0.3 | ||
38 | /home/linus/gcc-3.0.3> ln -s ../newlib-1.10.0/newlib . | ||
39 | /home/linus/gcc-3.0.3> ln -s ../newlib-1.10.0/libgloss . | ||
40 | </pre> | ||
41 | <h2>Make up your mind</h2> | ||
42 | <p> | ||
43 | Now is the time to decide where you want the tools to be installed. This is | ||
44 | the directory where all binaries, libraries, man pages and stuff end up when | ||
45 | you do "make install". | ||
46 | <p> | ||
47 | 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 | ||
48 | /usr/local/sh1 for example. | ||
49 | <h2>Build binutils</h2> | ||
50 | <p> | ||
51 | We will start with building the binutils (the assembler, linker and stuff). | ||
52 | This is pretty straightforward. We will be installing the whole tool chain | ||
53 | in the /home/linus/sh1 directory. | ||
54 | <pre> | ||
55 | /home/linus> cd build/binutils | ||
56 | /home/linus/build/binutils> ../../binutils-2.11/configure --target=sh-elf --prefix=/home/linus/sh1 | ||
57 | /home/linus/build/binutils> make | ||
58 | /home/linus/build/binutils> make install | ||
59 | </pre> | ||
60 | <h2>Build GCC</h2> | ||
61 | <p> | ||
62 | Now you are ready to build GCC. To do this, you must have the newly built | ||
63 | binutils in the PATH. | ||
64 | <pre> | ||
65 | /home/linus> export PATH=/home/linus/sh1/bin:$PATH | ||
66 | /home/linus> cd build/gcc | ||
67 | /home/linus/gcc> ../../gcc-3.0.3/configure --target=sh-elf --prefix=/home/linus/sh1 --with-newlib --enable-languages=c | ||
68 | /home/linus/build/binutils> make | ||
69 | /home/linus/build/binutils> make install | ||
70 | </pre> | ||
71 | <h2>Build GDB</h2> | ||
72 | <p> | ||
73 | If you are planning to debug your code with GDB, you have to build it as well. | ||
74 | <pre> | ||
75 | /home/linus> export PATH=/home/linus/sh1/bin:$PATH | ||
76 | /home/linus> cd build/gdb | ||
77 | /home/linus/gdb> ../../gdb-5.1.1/configure --target=sh-elf --prefix=/home/linus/sh1 | ||
78 | /home/linus/build/binutils> make | ||
79 | /home/linus/build/binutils> make install | ||
80 | </pre> | ||
81 | <h2>Done</h2> | ||
82 | <p> | ||
83 | If someone up there likes you, you now have a working tool chain for SH1. | ||
84 | To compile a file with gcc: | ||
85 | <pre> | ||
86 | /home/linus> sh-elf-gcc -c main.o main.c | ||
87 | </pre> | ||
88 | Good luck! | ||
89 | <p> | ||
90 | <i>Linus</i> | ||
91 | |||
92 | #include "foot.t" | ||