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