1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-1998. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Building the GNU C/C++ Cross Compiler Toolset |
---|
10 | |
---|
11 | This chapter describes the steps required to acquire the |
---|
12 | source code for a GNU cross compiler toolset, apply |
---|
13 | any required RTEMS specific patches, compile that |
---|
14 | toolset and install it. |
---|
15 | |
---|
16 | @section Create the Archive and Build Directories |
---|
17 | |
---|
18 | Start by making the @code{archive} directory to contain the downloaded |
---|
19 | source code and the @code{tools} directory to be used as a build |
---|
20 | directory. The command sequence to do this is shown |
---|
21 | below: |
---|
22 | |
---|
23 | @example |
---|
24 | mkdir archive |
---|
25 | mkdir tools |
---|
26 | @end example |
---|
27 | |
---|
28 | This will result in an initial directory structure similar to the |
---|
29 | one shown in the following figure: |
---|
30 | |
---|
31 | @example |
---|
32 | @group |
---|
33 | /whatever/prefix/you/choose/ |
---|
34 | archive/ |
---|
35 | tools/ |
---|
36 | |
---|
37 | @end group |
---|
38 | @end example |
---|
39 | |
---|
40 | @c @ifset use-html |
---|
41 | @c @html |
---|
42 | @c <IMG SRC="sfile12c.jpg" WIDTH=417 HEIGHT=178 |
---|
43 | @c ALT="Starting Directory Organization"> |
---|
44 | @c @end html |
---|
45 | @c @end ifset |
---|
46 | |
---|
47 | @section Get All the Pieces |
---|
48 | |
---|
49 | This section lists the components of an RTEMS cross development system. |
---|
50 | Included are the locations of each component as well as any required RTEMS |
---|
51 | specific patches. |
---|
52 | |
---|
53 | @subheading @value{GCC-VERSION} |
---|
54 | @example |
---|
55 | FTP Site: @value{GCC-FTPSITE} |
---|
56 | Directory: @value{GCC-FTPDIR} |
---|
57 | File: @value{GCC-TAR} |
---|
58 | @ifset use-html |
---|
59 | URL: @href{Download @value{GCC-VERSION},,,ftp://@value{GCC-FTPSITE}@value{GCC-FTPDIR}/@value{GCC-TAR}} |
---|
60 | @end ifset |
---|
61 | @end example |
---|
62 | |
---|
63 | @subheading @value{BINUTILS-VERSION} |
---|
64 | @example |
---|
65 | FTP Site: @value{BINUTILS-FTPSITE} |
---|
66 | Directory: @value{BINUTILS-FTPDIR} |
---|
67 | File: @value{BINUTILS-TAR} |
---|
68 | @ifset use-html |
---|
69 | URL: @href{Download @value{BINUTILS-VERSION},,,ftp://@value{BINUTILS-FTPSITE}@value{BINUTILS-FTPDIR}/@value{BINUTILS-TAR}} |
---|
70 | @end ifset |
---|
71 | @end example |
---|
72 | |
---|
73 | @subheading @value{NEWLIB-VERSION} |
---|
74 | @example |
---|
75 | FTP Site: @value{NEWLIB-FTPSITE} |
---|
76 | Directory: @value{NEWLIB-FTPDIR} |
---|
77 | File: @value{NEWLIB-TAR} |
---|
78 | @ifset use-html |
---|
79 | URL: @href{Download @value{NEWLIB-VERSION},,,ftp://@value{NEWLIB-FTPSITE}@value{NEWLIB-FTPDIR}/@value{NEWLIB-TAR}} |
---|
80 | @end ifset |
---|
81 | @end example |
---|
82 | |
---|
83 | @subheading @value{RTEMS-VERSION} |
---|
84 | @example |
---|
85 | FTP Site: @value{RTEMS-FTPSITE} |
---|
86 | Directory: @value{RTEMS-FTPDIR} |
---|
87 | File: @value{RTEMS-TAR} |
---|
88 | @ifset use-html |
---|
89 | URL: @href{Download RTEMS components,,,ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}} |
---|
90 | @end ifset |
---|
91 | @end example |
---|
92 | |
---|
93 | @subheading RTEMS Hello World |
---|
94 | @example |
---|
95 | FTP Site: @value{RTEMS-FTPSITE} |
---|
96 | Directory: @value{RTEMS-FTPDIR} |
---|
97 | File: hello_world_c.tgz |
---|
98 | @ifset use-html |
---|
99 | URL: @href{Download RTEMS Hello World,,,ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}/hello_world_c.tgz} |
---|
100 | @end ifset |
---|
101 | @end example |
---|
102 | |
---|
103 | @subheading RTEMS Specific Tool Patches and Scripts |
---|
104 | @example |
---|
105 | FTP Site: @value{RTEMS-FTPSITE} |
---|
106 | Directory: @value{RTEMS-FTPDIR}/c_tools |
---|
107 | File: bit |
---|
108 | @ifset BINUTILS-RTEMSPATCH |
---|
109 | File: @value{BINUTILS-RTEMSPATCH} |
---|
110 | @end ifset |
---|
111 | @ifset NEWLIB-RTEMSPATCH |
---|
112 | File: @value{NEWLIB-RTEMSPATCH} |
---|
113 | @end ifset |
---|
114 | @ifset GCC-RTEMSPATCH |
---|
115 | File: @value{GCC-RTEMSPATCH} |
---|
116 | @end ifset |
---|
117 | @ifset use-html |
---|
118 | URL: @href{Download RTEMS Patches and Scripts,,,ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}/c_tools} |
---|
119 | @end ifset |
---|
120 | @end example |
---|
121 | |
---|
122 | @section Unarchiving the Tools |
---|
123 | |
---|
124 | While in the @code{tools} directory, unpack the compressed |
---|
125 | tar files using the following command sequence: |
---|
126 | |
---|
127 | @example |
---|
128 | cd tools |
---|
129 | tar xzf ../archive/@value{GCC-TAR} |
---|
130 | tar xzf ../archive/@value{BINUTILS-TAR} |
---|
131 | tar xzf ../archive/@value{NEWLIB-TAR} |
---|
132 | @end example |
---|
133 | |
---|
134 | After the compressed tar files have been unpacked, the following |
---|
135 | directories will have been created under tools. |
---|
136 | |
---|
137 | @itemize @bullet |
---|
138 | @item @value{BINUTILS-UNTAR} |
---|
139 | @item @value{GCC-UNTAR} |
---|
140 | @item @value{NEWLIB-UNTAR} |
---|
141 | @end itemize |
---|
142 | |
---|
143 | Copy the @code{bit} script from the @code{archive} directory |
---|
144 | to the @code{tools} directory as shown below: |
---|
145 | |
---|
146 | @example |
---|
147 | cp ../archive/bit . |
---|
148 | @end example |
---|
149 | |
---|
150 | When the @code{bit} script is executed later in this process, |
---|
151 | it will automatically create two other subdirectories: |
---|
152 | |
---|
153 | @itemize @bullet |
---|
154 | @item src |
---|
155 | @item build-$@{CPU@}-tools |
---|
156 | @end itemize |
---|
157 | |
---|
158 | @itemize @bullet |
---|
159 | @item src |
---|
160 | @item build-$@{CPU@}-tools |
---|
161 | @end itemize |
---|
162 | |
---|
163 | The tree should look something like the following figure: |
---|
164 | |
---|
165 | @example |
---|
166 | @group |
---|
167 | /whatever/prefix/you/choose/ |
---|
168 | bit |
---|
169 | archive/ |
---|
170 | @value{GCC-TAR} |
---|
171 | @value{BINUTILS-TAR} |
---|
172 | @value{NEWLIB-TAR} |
---|
173 | @value{RTEMS-TAR} |
---|
174 | @ifset GCC-RTEMSPATCH |
---|
175 | @value{GCC-RTEMSPATCH} |
---|
176 | @end ifset |
---|
177 | @ifset BINUTILS-RTEMSPATCH |
---|
178 | @value{BINUTILS-RTEMSPATCH} |
---|
179 | @end ifset |
---|
180 | @ifset NEWLIB-RTEMSPATCH |
---|
181 | @value{NEWLIB-RTEMSPATCH} |
---|
182 | @end ifset |
---|
183 | hello_world_c.tgz |
---|
184 | bit |
---|
185 | tools/ |
---|
186 | @value{BINUTILS-UNTAR}/ |
---|
187 | @value{GCC-UNTAR}/ |
---|
188 | @value{NEWLIB-UNTAR}/ |
---|
189 | @value{RTEMS-UNTAR}/ |
---|
190 | bit |
---|
191 | |
---|
192 | @end group |
---|
193 | @end example |
---|
194 | |
---|
195 | |
---|
196 | @c @ifset use-html |
---|
197 | @c @html |
---|
198 | @c <IMG SRC="bit_c.jpg" WIDTH=816 HEIGHT=267 ALT="Directory Organization"> |
---|
199 | @c @end html |
---|
200 | @c @end ifset |
---|
201 | |
---|
202 | @c |
---|
203 | @c Reading the Documentation |
---|
204 | @c |
---|
205 | |
---|
206 | @section Reading the Tools Documentation |
---|
207 | |
---|
208 | Each of the tools in the GNU development suite comes with documentation. |
---|
209 | It is in the reader's and tool maintainers' interest that one read the |
---|
210 | documentation before posting a problem to a mailing list or news group. |
---|
211 | |
---|
212 | @c |
---|
213 | @c EGCS patches |
---|
214 | @c |
---|
215 | |
---|
216 | @section Apply RTEMS Patch to EGCS |
---|
217 | |
---|
218 | @ifclear GCC-RTEMSPATCH |
---|
219 | No RTEMS specific patches are required for @value{GCC-VERSION} to |
---|
220 | support @value{RTEMS-VERSION}. |
---|
221 | @end ifclear |
---|
222 | |
---|
223 | @ifset GCC-RTEMSPATCH |
---|
224 | |
---|
225 | Apply the patch using the following command sequence: |
---|
226 | |
---|
227 | @example |
---|
228 | cd tools/@value{GCC-UNTAR} |
---|
229 | zcat archive/@value{GCC-RTEMSPATCH} | patch -p1 |
---|
230 | @end example |
---|
231 | |
---|
232 | Check to see if any of these patches have been rejected using the following |
---|
233 | sequence: |
---|
234 | |
---|
235 | @example |
---|
236 | cd tools/@value{GCC-UNTAR} |
---|
237 | find . -name "*.rej" -print |
---|
238 | @end example |
---|
239 | |
---|
240 | If any files are found with the .rej extension, a patch has been rejected. |
---|
241 | This should not happen with a good patch file. |
---|
242 | |
---|
243 | @end ifset |
---|
244 | |
---|
245 | @c |
---|
246 | @c BINUTILS patches |
---|
247 | @c |
---|
248 | |
---|
249 | @section Apply RTEMS Patch to binutils |
---|
250 | |
---|
251 | @ifclear BINUTILS-RTEMSPATCH |
---|
252 | No RTEMS specific patches are required for @value{BINUTILS-VERSION} to |
---|
253 | support @value{RTEMS-VERSION}. |
---|
254 | @end ifclear |
---|
255 | |
---|
256 | @ifset BINUTILS-RTEMSPATCH |
---|
257 | Apply the patch using the following command sequence: |
---|
258 | |
---|
259 | @example |
---|
260 | cd tools/@value{BINUTILS-UNTAR} |
---|
261 | zcat archive/@value{BINUTILS-RTEMSPATCH} | patch -p1 |
---|
262 | @end example |
---|
263 | |
---|
264 | Check to see if any of these patches have been rejected using the following |
---|
265 | sequence: |
---|
266 | |
---|
267 | @example |
---|
268 | cd tools/@value{BINUTILS-UNTAR} |
---|
269 | find . -name "*.rej" -print |
---|
270 | @end example |
---|
271 | |
---|
272 | If any files are found with the .rej extension, a patch has been rejected. |
---|
273 | This should not happen with a good patch file. |
---|
274 | |
---|
275 | @end ifset |
---|
276 | |
---|
277 | @c |
---|
278 | @c Newlib patches |
---|
279 | @c |
---|
280 | |
---|
281 | @section Apply RTEMS Patch to newlib |
---|
282 | |
---|
283 | @ifclear NEWLIB-RTEMSPATCH |
---|
284 | No RTEMS specific patches are required for @value{NEWLIB-VERSION} to |
---|
285 | support @value{RTEMS-VERSION}. |
---|
286 | @end ifclear |
---|
287 | |
---|
288 | @ifset NEWLIB-RTEMSPATCH |
---|
289 | |
---|
290 | Apply the patch using the following command sequence: |
---|
291 | |
---|
292 | @example |
---|
293 | cd tools/@value{NEWLIB-UNTAR} |
---|
294 | zcat archive/@value{NEWLIB-RTEMSPATCH} | patch -p1 |
---|
295 | @end example |
---|
296 | |
---|
297 | Check to see if any of these patches have been rejected using the following |
---|
298 | sequence: |
---|
299 | |
---|
300 | @example |
---|
301 | cd tools/@value{NEWLIB-UNTAR} |
---|
302 | find . -name "*.rej" -print |
---|
303 | @end example |
---|
304 | |
---|
305 | If any files are found with the .rej extension, a patch has been rejected. |
---|
306 | This should not happen with a good patch file. |
---|
307 | |
---|
308 | @end ifset |
---|
309 | |
---|
310 | @c |
---|
311 | @c Modify the bit script |
---|
312 | @c |
---|
313 | |
---|
314 | @section Modify the bit Script |
---|
315 | |
---|
316 | Copy the @code{bit} script from @code{archive} to the tools directory. |
---|
317 | |
---|
318 | Edit the @code{bit} file to alter the following environmental variables: |
---|
319 | |
---|
320 | @itemize @bullet |
---|
321 | @item INSTALL_POINT |
---|
322 | @item BINUTILS |
---|
323 | @item NEWLIB |
---|
324 | @item GCC |
---|
325 | @item BUILD_DOCS |
---|
326 | @item BUILD_OTHER_LANGUAGES |
---|
327 | @end itemize |
---|
328 | |
---|
329 | These variables are located in the script section that resembles the |
---|
330 | extract below: |
---|
331 | |
---|
332 | |
---|
333 | @example |
---|
334 | # USERCHANGE -- localize these. |
---|
335 | # |
---|
336 | # INSTALL_POINT: Directory tools are installed into. |
---|
337 | # Recommended installation point for various OS's: |
---|
338 | # Linux: /usr/local/rtems |
---|
339 | # Solaris: /opt/gnu/rtems |
---|
340 | # BINUTILS: Binutils source directory |
---|
341 | # NEWLIB: Newlib source directory |
---|
342 | # GCC: Newlib source directory |
---|
343 | # BUILD_DOCS: Set to "yes" if you want to install documentation. |
---|
344 | # BUILD_OTHER_LANGUAGES: |
---|
345 | # Set to "yes" if you want to build Fortran and Objective-C |
---|
346 | # |
---|
347 | BINUTILS=@value{BINUTILS-UNTAR} |
---|
348 | GCC=@value{GCC-UNTAR} |
---|
349 | NEWLIB=@value{NEWLIB-UNTAR} |
---|
350 | BUILD_DOCS=yes |
---|
351 | BUILD_OTHER_LANGUAGES=yes |
---|
352 | INSTALL_POINT=/home/joel/$@{GCC@}/$@{target@} |
---|
353 | |
---|
354 | # USERCHANGE - uncomment this if you want to watch the commands. |
---|
355 | @end example |
---|
356 | |
---|
357 | Where each of the variables which may be modified is described below: |
---|
358 | |
---|
359 | @table @code |
---|
360 | @item INSTALL_POINT |
---|
361 | is the location where you wish the GNU C/C++ cross compilation tools for |
---|
362 | RTEMS to be built. It is recommended that the directory chosen to receive |
---|
363 | these tools be named so that it is clear from which egcs distribution it |
---|
364 | was generated and for which target system the tools are to produce code for. |
---|
365 | |
---|
366 | @item BINUTILS |
---|
367 | is the directory under tools that contains @value{BINUTILS-UNTAR}. |
---|
368 | For example: |
---|
369 | |
---|
370 | @example |
---|
371 | BINUTILS=@value{BINUTILS-UNTAR} |
---|
372 | @end example |
---|
373 | |
---|
374 | @item GCC |
---|
375 | is the directory under tools that contains @value{GCC-UNTAR}. |
---|
376 | For example, |
---|
377 | |
---|
378 | @example |
---|
379 | GCC=@value{GCC-UNTAR} |
---|
380 | @end example |
---|
381 | |
---|
382 | @item NEWLIB |
---|
383 | is the directory under tools that contains @value{NEWLIB-UNTAR}. |
---|
384 | For example: |
---|
385 | |
---|
386 | @example |
---|
387 | NEWLIB=@value{NEWLIB-UNTAR} |
---|
388 | @end example |
---|
389 | |
---|
390 | @item BUILD_DOCS |
---|
391 | is set to "yes" if you want to install documentation. |
---|
392 | For example: |
---|
393 | |
---|
394 | @example |
---|
395 | BUILD_DOCS=yes |
---|
396 | @end example |
---|
397 | |
---|
398 | @item BUILD_OTHER_LANGUAGES |
---|
399 | is set to "yes" if you want to build languages other than C and C++. At |
---|
400 | the current time, this enables Fortan and Objective-C. |
---|
401 | For example: |
---|
402 | |
---|
403 | @example |
---|
404 | BUILD_OTHER_LANGUAGES=yes |
---|
405 | @end example |
---|
406 | |
---|
407 | @end table |
---|
408 | |
---|
409 | @section Running the bit Script |
---|
410 | |
---|
411 | After the @code{bit} script has been modified to reflect the |
---|
412 | local installation, the modified @code{bit} script is run |
---|
413 | using the following sequence: |
---|
414 | |
---|
415 | @example |
---|
416 | cd tools |
---|
417 | ./bit <target configuration> |
---|
418 | @end example |
---|
419 | |
---|
420 | Where <target configuration> is one of the following: |
---|
421 | |
---|
422 | @itemize @bullet |
---|
423 | @item hppa1.1 |
---|
424 | @item i386 |
---|
425 | @item i386-elf |
---|
426 | @item i386-go32 |
---|
427 | @item i960 |
---|
428 | @item m68k |
---|
429 | @item mips64orion |
---|
430 | @item powerpc |
---|
431 | @item sh |
---|
432 | @item sparc |
---|
433 | @end itemize |
---|
434 | |
---|
435 | If no errors are encountered, the @code{bit} script will conclude by |
---|
436 | printing messages similar to the following: |
---|
437 | |
---|
438 | @example |
---|
439 | |
---|
440 | The src and build-i386-tools subdirectory may now be removed. |
---|
441 | |
---|
442 | Started: Fri Apr 10 10:14:07 CDT 1998 |
---|
443 | Finished: Fri Apr 10 12:01:33 CDT 1998 |
---|
444 | @end example |
---|
445 | |
---|
446 | If the @code{bit} script successfully completes, then the |
---|
447 | GNU C/C++ cross compilation tools are installed. |
---|
448 | |
---|
449 | If the @code{bit} script does not successfully complete, then investigation |
---|
450 | will be required to determine the source of the error. |
---|
451 | |
---|