source: rtems/doc/started/buildc.t @ 9789eefc

4.104.114.84.95
Last change on this file since 9789eefc was 9789eefc, checked in by Joel Sherrill <joel.sherrill@…>, on 08/22/03 at 20:00:18

2003-08-22 Joel Sherrill <joel@…>

PR 469/doc

  • buildc.t: Clarifying text on patch file to account for various ways they could be compressed or not.
  • Property mode set to 100644
File size: 27.7 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2002.
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
11NOTE:  This chapter does @b{NOT} apply if you installed
12prebuilt toolset executables for BINUTILS, GCC, NEWLIB,
13and GDB.  If you installed prebuilt executables for all
14of those, proceed to @ref{Building RTEMS}.  If you require
15a GDB with a special configuration to connect to your
16target board, then proceed to @ref{Building the GNU Debugger GDB}
17for some advice.
18
19This chapter describes the steps required to acquire the
20source code for a GNU cross compiler toolset, apply
21any required RTEMS specific patches, compile that
22toolset and install it.
23
24It is recommended that when toolset binaries are available for
25your particular host, that they be used.  Prebuilt binaries
26are much easier to install.
27
28@c
29@c  Building BINUTILS GCC and NEWLIB
30@c
31@section Building BINUTILS GCC and NEWLIB
32
33NOTE: This step is NOT required if prebuilt executables for
34BINUTILS, GCC, and NEWLIB were installed.
35
36This section describes the process of building BINUTILS, GCC, and
37NEWLIB using a variety of methods.  Included is information on
38obtaining the source code and patches, applying patches, and
39building and installing the tools using multiple methods.
40
41@c
42@c  Obtain Source and Patches for BINUTILS GCC and NEWLIB
43@c
44
45@subsection Obtain Source and Patches for BINUTILS GCC and NEWLIB
46
47NOTE: This step is required for all methods of building BINUTILS,
48GCC, and NEWLIB.
49
50This section lists the components required to build BINUTILS, GCC,
51and NEWLIB from source to target RTEMS.  These files should be
52placed in your @code{archive} directory.  Included are the locations
53of each component as well as any required RTEMS specific patches.
54
55@need 1000
56@subheading @value{GCC-VERSION}
57@example
58    FTP Site:    @value{GCC-FTPSITE}
59    Directory:   @value{GCC-FTPDIR}
60    File:        @value{GCC-TAR}
61@ifset use-html
62@c    URL:         @uref{Download @value{GCC-VERSION}, ftp://@value{GCC-FTPSITE}@value{GCC-FTPDIR}}
63    URL:         ftp://@value{GCC-FTPSITE}@value{GCC-FTPDIR}
64@end ifset
65@end example
66
67@need 1000
68@subheading @value{BINUTILS-VERSION}
69@example
70    FTP Site:    @value{BINUTILS-FTPSITE}
71    Directory:   @value{BINUTILS-FTPDIR}
72    File:        @value{BINUTILS-TAR}
73@ifset use-html
74@c    URL:         @uref{ftp://@value{BINUTILS-FTPSITE}@value{BINUTILS-FTPDIR}/@value{BINUTILS-TAR},Download @value{BINUTILS-VERSION}}
75    URL:         ftp://@value{BINUTILS-FTPSITE}@value{BINUTILS-FTPDIR}/@value{BINUTILS-TAR}
76@end ifset
77@end example
78
79@need 1000
80@subheading @value{NEWLIB-VERSION}
81@example
82    FTP Site:    @value{NEWLIB-FTPSITE}
83    Directory:   @value{NEWLIB-FTPDIR}
84    File:        @value{NEWLIB-TAR}
85@ifset use-html
86@c    URL:         @uref{ftp://@value{NEWLIB-FTPSITE}@value{NEWLIB-FTPDIR}/@value{NEWLIB-TAR}, Download @value{NEWLIB-VERSION}}
87    URL:         ftp://@value{NEWLIB-FTPSITE}@value{NEWLIB-FTPDIR}/@value{NEWLIB-TAR}
88@end ifset
89@end example
90
91@need 1000
92@subheading RTEMS Specific Tool Patches and Scripts
93@example
94    FTP Site:    @value{RTEMS-FTPSITE}
95    Directory:   @value{RTEMS-FTPDIR}/c_tools/source
96@ifset BUILDTOOLS-TAR
97    File:        @value{BUILDTOOLS-TAR}
98@end ifset
99@ifset BINUTILS-RTEMSPATCH
100    File:        @value{BINUTILS-RTEMSPATCH}
101@end ifset
102@ifset NEWLIB-RTEMSPATCH
103    File:        @value{NEWLIB-RTEMSPATCH}
104@end ifset
105@ifset GCC-RTEMSPATCH
106    File:        @value{GCC-RTEMSPATCH}
107@end ifset
108@ifset use-html
109@c    URL:         @uref{ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}/c_tools/source,Download RTEMS Patches and Scripts}
110    URL:         ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}/c_tools/source
111@end ifset
112@end example
113
114@c
115@c  Unarchiving the Tools
116@c
117@subsection Unarchiving the Tools
118
119NOTE: This step is required if building BINUTILS, GCC, and NEWLIB
120using the procedure described in @ref{Using configure and make}.
121It is @b{NOT} required if using the procedure
122described in @ref{Using RPM to Build BINUTILS GCC and NEWLIB}.
123
124GNU source distributions are archived using @code{tar} and
125compressed using either @code{gzip} or @code{bzip}. 
126If compressed with @code{gzip}, the extension @code{.gz} is used.
127If compressed with @code{bzip}, the extension @code{.bz2} is used.
128
129While in the @code{tools} directory, unpack the compressed
130tar files for BINUTILS, GCC, and NEWLIB using the appropriate
131command based upon the compression program used.
132
133@example
134cd tools
135tar xzf ../archive/TOOLNAME.tar.gz  # for gzip'ed tools
136tar xIf ../archive/TOOLNAME.tar.bz2 # for bzip'ed tools
137@end example
138
139After the compressed tar files have been unpacked using
140the appropriate commands, the following
141directories will have been created under tools.
142
143@itemize @bullet
144@item @value{BINUTILS-UNTAR}
145@item @value{GCC-UNTAR}
146@item @value{NEWLIB-UNTAR}
147@end itemize
148
149The tree should look something like the following figure:
150
151@example
152@group
153/whatever/prefix/you/choose/
154        archive/
155            @value{GCC-TAR}
156            @value{BINUTILS-TAR}
157            @value{NEWLIB-TAR}
158@ifset GCC-RTEMSPATCH
159            @value{GCC-RTEMSPATCH}
160@end ifset
161@ifset BINUTILS-RTEMSPATCH
162            @value{BINUTILS-RTEMSPATCH}
163@end ifset
164@ifset NEWLIB-RTEMSPATCH
165            @value{NEWLIB-RTEMSPATCH}
166@end ifset
167        tools/
168            @value{BINUTILS-UNTAR}/
169            @value{GCC-UNTAR}/
170            @value{NEWLIB-UNTAR}/
171@end group
172@end example
173
174@c
175@c  Applying RTEMS Patches
176@c
177
178@subsection Applying RTEMS Patches
179
180NOTE: This step is required if building BINUTILS, GCC, and NEWLIB
181using the procedures described in @ref{Using configure and make}.
182It is @b{NOT} required if using the procedure
183described in @ref{Using RPM to Build BINUTILS GCC and NEWLIB}.
184
185This section describes the process of applying the RTEMS patches
186to GCC, NEWLIB, and BINUTILS.
187
188@c
189@c  GCC patches
190@c
191
192@subheading Apply RTEMS Patch to GCC
193
194@ifclear GCC-RTEMSPATCH
195No RTEMS specific patches are required for @value{GCC-VERSION} to
196support @value{RTEMS-VERSION}.
197@end ifclear
198
199@ifset GCC-RTEMSPATCH
200
201Apply the patch using the following command sequence:
202
203@example
204cd tools/@value{GCC-UNTAR}
205cat ../../archive/@value{GCC-RTEMSPATCH} | \
206    patch -p1
207@end example
208
209If the patch was compressed with the @code{gzip} program, it will
210have a suffix of @code{.gz} and you should use @code{zcat} instead
211of @code{cat} as shown above.  If the patch was compressed with
212the @code{gzip} program, it will have a suffix of @code{.bz2} and
213you should use @code{bzcat} instead of @code{cat} as shown above.
214
215Check to see if any of these patches have been rejected using the following
216sequence:
217
218@example
219cd tools/@value{GCC-UNTAR}
220find . -name "*.rej" -print
221@end example
222
223If any files are found with the .rej extension, a patch has been rejected.
224This should not happen with a good patch file which is properly applied.
225
226@end ifset
227
228@c
229@c  BINUTILS patches
230@c
231
232@subheading Apply RTEMS Patch to binutils
233
234@ifclear BINUTILS-RTEMSPATCH
235No RTEMS specific patches are required for @value{BINUTILS-VERSION} to
236support @value{RTEMS-VERSION}.
237@end ifclear
238
239@ifset BINUTILS-RTEMSPATCH
240Apply the patch using the following command sequence:
241
242@example
243cd tools/@value{BINUTILS-UNTAR}
244cat ../../archive/@value{BINUTILS-RTEMSPATCH} | \
245    patch -p1
246@end example
247
248If the patch was compressed with the @code{gzip} program, it will
249have a suffix of @code{.gz} and you should use @code{zcat} instead
250of @code{cat} as shown above.  If the patch was compressed with
251the @code{gzip} program, it will have a suffix of @code{.bz2} and
252you should use @code{bzcat} instead of @code{cat} as shown above.
253
254Check to see if any of these patches have been rejected using the following
255sequence:
256
257@example
258cd tools/@value{BINUTILS-UNTAR}
259find . -name "*.rej" -print
260@end example
261
262If any files are found with the .rej extension, a patch has been rejected.
263This should not happen with a good patch file which is properly applied.
264
265@end ifset
266
267@c
268@c  Newlib patches
269@c
270
271@subheading Apply RTEMS Patch to newlib
272
273@ifclear NEWLIB-RTEMSPATCH
274No RTEMS specific patches are required for @value{NEWLIB-VERSION} to
275support @value{RTEMS-VERSION}.
276@end ifclear
277
278@ifset NEWLIB-RTEMSPATCH
279
280Apply the patch using the following command sequence:
281
282@example
283cd tools/@value{NEWLIB-UNTAR}
284cat ../../archive/@value{NEWLIB-RTEMSPATCH} | \
285    patch -p1
286@end example
287
288If the patch was compressed with the @code{gzip} program, it will
289have a suffix of @code{.gz} and you should use @code{zcat} instead
290of @code{cat} as shown above.  If the patch was compressed with
291the @code{gzip} program, it will have a suffix of @code{.bz2} and
292you should use @code{bzcat} instead of @code{cat} as shown above.
293
294Check to see if any of these patches have been rejected using the following
295sequence:
296
297@example
298cd tools/@value{NEWLIB-UNTAR}
299find . -name "*.rej" -print
300@end example
301
302If any files are found with the .rej extension, a patch has been rejected.
303This should not happen with a good patch file which is properly applied.
304
305@end ifset
306
307
308@c
309@c  Compiling and Installing BINUTILS GCC and NEWLIB
310@c
311
312@subsection Compiling and Installing BINUTILS GCC and NEWLIB
313
314There are two supported methods to compile and install BINUTILS, GCC,
315and NEWLIB:
316
317@itemize @bullet
318@item RPM
319@item direct invocation of @code{configure} and @code{make}
320@end itemize
321
322Direct invocation of @code{configure} and @code{make} provides more control
323and easier recovery from problems when building.
324
325@c
326@c  Using RPM to Build BINUTILS GCC and NEWLIB
327@c
328
329@subsubsection Using RPM to Build BINUTILS GCC and NEWLIB
330
331NOTE:  The procedures described in the following sections must
332be completed before this step:
333
334@itemize @bullet
335@item @ref{Obtain Source and Patches for BINUTILS GCC and NEWLIB}
336@end itemize
337
338RPM automatically unarchives the source and applies any needed
339patches so you do @b{NOT} have to manually perform the procedures
340described @ref{Unarchiving the Tools} and
341@ref{Applying RTEMS Patches}.
342
343This section describes the process of building binutils, gcc, and
344newlib using RPM.  RPM is a packaging format which can be used to
345distribute binary files as well as to capture the procedure and
346source code used to produce those binary files.  Before
347attempting to build any RPM from source, it is necessary to
348ensure that all required source and patches are in the @code{SOURCES}
349directory under the RPM root (probably @code{/usr/src/redhat} or
350@code{/usr/local/src/redhat}) on your machine.  This procedure
351starts by installing the source RPMs as shown in the following
352example:
353
354@example
355rpm -i i386-rtems-binutils-collection-2.9.5.0.24-1.nosrc.rpm
356rpm -i i386-rtems-gcc-newlib-gcc2.95.2newlib1.8.2-7.nosrc.rpm
357@end example
358
359Because RTEMS tool RPMS are called "nosrc" to indicate that one or
360more source files required to produce the RPMs are not present. 
361The RTEMS source RPMs do not include the large @code{.tar.gz} or
362@code{.tgz} files for
363each component such as BINUTILS, GCC, or NEWLIB.  These are shared
364by all RTEMS RPMs regardless of target CPU and there was no reason
365to duplicate them.  You will have to get the required source
366archive files by hand and place them in the @code{SOURCES} directory
367before attempting to build.  If you forget to do this, RPM is
368smart -- it will tell you what is missing.  To determine what is
369included or referenced by a particular RPM, use a command like the
370following:
371
372@example
373$ rpm -q -l -p i386-rtems-binutils-collection-2.9.5.0.24-1.nosrc.rpm
374binutils-2.9.5.0.24-rtems-20000207.diff
375binutils-2.9.5.0.24.tar.gz
376i386-rtems-binutils-2.9.5.0.24.spec
377@end example
378
379Notice that there is a patch file (the @code{.diff} file), a source archive
380file (the @code{.tar.gz}), and a file describing the build procedure and
381files produced (the @code{.spec} file).  The @code{.spec} file is placed
382in the @code{SPECS} directory under the RPM root directory.
383
384@c
385@c  Configuring and Building BINUTILS using RPM
386@c
387
388@subheading Configuring and Building BINUTILS using RPM
389
390The following example illustrates the invocation of RPM to build a new,
391locally compiled, binutils binary RPM that matches the installed source
392RPM.  This example assumes that all of the required source is installed.
393
394@example
395cd <RPM_ROOT_DIRECTORY>/SPECS
396rpm -bb i386-rtems-binutils-2.9.5.0.24.spec
397@end example
398
399If the build completes successfully, RPMS like the following will
400be generated in a build-host architecture specific subdirectory
401of the RPMS directory under the RPM root directory.
402
403@example
404rtems-base-binutils-2.9.5.0.24-1.i386.rpm
405i386-rtems-binutils-2.9.5.0.24-1.i386.rpm
406@end example
407
408NOTE: It may be necessary to remove the build tree in the
409@code{BUILD} directory under the RPM root directory.
410
411@c
412@c  Configuring and Building GCC and NEWLIB using RPM
413@c
414
415@subheading Configuring and Building GCC and NEWLIB using RPM
416
417The following example illustrates the invocation of RPM to build a new,
418locally compiled, set of GCC and NEWLIB binary RPMs that match the
419installed source RPM.  It is also necessary to install the BINUTILS
420RPMs and place them in your PATH.  This example assumes that all of
421the required source is installed.
422
423@example
424cd <RPM_ROOT_DIRECTORY>/RPMS/i386
425rpm -i rtems-base-binutils-2.9.5.0.24-1.i386.rpm
426rpm -i i386-rtems-binutils-2.9.5.0.24-1.i386.rpm
427export PATH=/opt/rtems/bin:$PATH
428cd <RPM_ROOT_DIRECTORY>/SPECS
429rpm -bb i386-rtems-gcc-2.95.2-newlib-1.8.2.spec
430@end example
431
432If the build completes successfully, a set of RPMS like the following will
433be generated in a build-host architecture specific subdirectory
434of the RPMS directory under the RPM root directory.
435
436@example
437rtems-base-gcc-gcc2.95.2newlib1.8.2-7.i386.rpm
438rtems-base-chill-gcc2.95.2newlib1.8.2-7.i386.rpm
439rtems-base-g77-gcc2.95.2newlib1.8.2-7.i386.rpm
440rtems-base-gcj-gcc2.95.2newlib1.8.2-7.i386.rpm
441i386-rtems-gcc-gcc2.95.2newlib1.8.2-7.i386.rpm
442i386-rtems-chill-gcc2.95.2newlib1.8.2-7.i386.rpm
443i386-rtems-g77-gcc2.95.2newlib1.8.2-7.i386.rpm
444i386-rtems-gcj-gcc2.95.2newlib1.8.2-7.i386.rpm
445i386-rtems-objc-gcc2.95.2newlib1.8.2-7.i386.rpm
446@end example
447
448NOTE: Some targets do not support building all languages.
449
450NOTE: It may be necessary to remove the build tree in the
451@code{BUILD} directory under the RPM root directory.
452
453@c
454@c  Using configure and make
455@c
456
457@subsubsection Using configure and make
458
459NOTE:  The procedures described in the following sections must
460be completed before this step:
461
462@itemize @bullet
463@item @ref{Obtain Source and Patches for BINUTILS GCC and NEWLIB}
464@item @ref{Unarchiving the Tools}
465@item @ref{Applying RTEMS Patches}
466@end itemize
467
468This section describes the process of building binutils, gcc, and
469newlib manually using @code{configure} and @code{make} directly.
470
471@c
472@c  Configuring and Building BINUTILS
473@c
474
475@subheading Configuring and Building BINUTILS
476
477The following example illustrates the invocation of
478@code{configure} and @code{make}
479to build and install @value{BINUTILS-UNTAR} for the
480sparc-rtems target:
481
482@example
483mkdir b-binutils
484cd b-binutils
485../@value{BINUTILS-UNTAR}/configure --target=sparc-rtems \
486  --prefix=/opt/rtems
487make all
488make info
489make install
490@end example
491
492After @value{BINUTILS-UNTAR} is built and installed the
493build directory @code{b-binutils} may be removed.
494
495For more information on the invocation of @code{configure}, please
496refer to the documentation for @value{BINUTILS-UNTAR} or
497invoke the @value{BINUTILS-UNTAR} @code{configure} command with the
498@code{--help} option.
499
500NOTE: The shell PATH variable needs to be updated to include the path
501the binutils has been installed in. This the prefix used above with
502@file{bin} post-fixed.
503
504@example
505export PATH=$PATH:/opt/rtems/bin
506@end example
507
508Failure to have the binutils in the path will cause the GCC and NEWLIB
509build to fail with an error message similar to:
510
511@example
512sparc-rtems-ar: command not found
513@end example
514
515@c
516@c  Configuring and Building GCC and NEWLIB
517@c
518
519@subheading Configuring and Building GCC and NEWLIB
520
521Before building @value{GCC-UNTAR} and @value{NEWLIB-UNTAR},
522@value{BINUTILS-UNTAR} must be installed and the directory
523containing those executables must be in your PATH.
524
525The C Library is built as a subordinate component of
526@value{GCC-UNTAR}.  Because of this, the @value{NEWLIB-UNTAR}
527directory source must be available inside the @value{GCC-UNTAR}
528source tree.  This is normally accomplished using a symbolic
529link as shown in this example:
530
531@example
532cd @value{GCC-UNTAR}
533ln -s ../@value{NEWLIB-UNTAR}/newlib .
534@end example
535
536The following example illustrates the invocation of
537@code{configure} and @code{make}
538to build and install @value{BINUTILS-UNTAR} for the
539sparc-rtems target:
540
541@example
542mkdir b-gcc
543cd b-gcc
544../@value{GCC-UNTAR}/configure --target=sparc-rtems \
545   --with-gnu-as --with-gnu-ld --with-newlib --verbose \
546   --enable-threads --prefix=/opt/rtems
547make all
548make info
549make install
550@end example
551
552After @value{GCC-UNTAR} is built and installed the
553build directory @code{b-gcc} may be removed.
554
555For more information on the invocation of @code{configure}, please
556refer to the documentation for @value{GCC-UNTAR} or
557invoke the @value{GCC-UNTAR} @code{configure} command with the
558@code{--help} option.
559
560@c
561@c Building the GNU Debugger GDB
562@c
563
564@section Building the GNU Debugger GDB
565
566NOTE: This step is NOT required if prebuilt executables for
567the GNU Debugger GDB were installed.
568
569The GNU Debugger GDB supports many configurations but requires some
570means of communicating between the host computer and target board.
571This communication can be via a serial port, Ethernet, BDM, or ROM emulator.
572The communication protocol can be the GDB remote protocol or GDB
573can talk directly to a ROM monitor.  This setup is target board
574specific.  The following configurations have been
575successfully used with RTEMS applications:
576
577@itemize @bullet
578@item Sparc Instruction Simulator (SIS)
579@item PowerPC Instruction Simulator (PSIM)
580@item DINK32
581@item BDM with 68360 and MPC860 CPUs
582@item Motorola Mxxxbug found on M68xxx VME boards
583@item Motorola PPCbug found on PowerPC VME and CompactPCI boards
584@end itemize
585
586GDB is currently RTEMS thread/task aware only if you are using the
587remote debugging support via Ethernet.  These are configured
588using gdb targets of the form CPU-RTEMS.  Note the capital RTEMS.
589
590It is recommended that when toolset binaries are available for
591your particular host, that they be used.  Prebuilt binaries
592are much easier to install but in the case of gdb may or may
593not include support for your particular target board.
594
595@c
596@c  Obtain Source and Patches for GDB
597@c
598
599@subsection Obtain Source and Patches for GDB
600
601NOTE: This step is required for all methods of building GDB.
602
603This section lists the components required to build GDB
604from source to target RTEMS.  These files should be
605placed in your @code{archive} directory.  Included are the locations
606of each component as well as any required RTEMS specific patches.
607
608@need 1000
609@subheading @value{GDB-VERSION}
610@example
611    FTP Site:    @value{GDB-FTPSITE}
612    Directory:   @value{GDB-FTPDIR}
613    File:        @value{GDB-TAR}
614@ifset use-html
615@c    URL:         @uref{Download @value{GDB-VERSION}, ftp://@value{GDB-FTPSITE}@value{GDB-FTPDIR}}
616    URL:         ftp://@value{GDB-FTPSITE}@value{GDB-FTPDIR}
617@end ifset
618@end example
619
620@need 1000
621@subheading RTEMS Specific Tool Patches and Scripts
622@example
623    FTP Site:    @value{RTEMS-FTPSITE}
624    Directory:   @value{RTEMS-FTPDIR}/c_tools/source
625@ifset BUILDTOOLS-TAR
626    File:        @value{BUILDTOOLS-TAR}
627@end ifset
628@ifset GDB-RTEMSPATCH
629    File:        @value{GDB-RTEMSPATCH}
630@end ifset
631@ifset use-html
632@c    URL:         @uref{ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}/c_tools/source,Download RTEMS Patches and Scripts}
633    URL:         ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}/c_tools/source
634@end ifset
635@end example
636
637@c
638@c  Unarchiving the GDB Distribution
639@c
640@subsection Unarchiving the GDB Distribution
641
642Use the following commands to unarchive the GDB distribution:
643
644@example
645cd tools
646tar xzf ../archive/@value{GDB-TAR}
647@end example
648
649The directory @value{GDB-UNTAR} is created under the tools directory.
650
651@c
652@c  Applying RTEMS Patch to GDB
653@c
654
655@subsection Applying RTEMS Patch to GDB
656
657@ifclear GDB-RTEMSPATCH
658No RTEMS specific patches are required for @value{GDB-VERSION} to
659support @value{RTEMS-VERSION}.
660@end ifclear
661
662@ifset GDB-RTEMSPATCH
663
664Apply the patch using the following command sequence:
665
666@example
667cd tools/@value{GDB-UNTAR}
668cat archive/@value{GDB-RTEMSPATCH} | \
669    patch -p1
670@end example
671
672If the patch was compressed with the @code{gzip} program, it will
673have a suffix of @code{.gz} and you should use @code{zcat} instead
674of @code{cat} as shown above.  If the patch was compressed with
675the @code{gzip} program, it will have a suffix of @code{.bz2} and
676you should use @code{bzcat} instead of @code{cat} as shown above.
677
678Check to see if any of these patches have been rejected using the following
679sequence:
680
681@example
682cd tools/@value{GDB-UNTAR}
683find . -name "*.rej" -print
684@end example
685
686If any files are found with the .rej extension, a patch has been rejected.
687This should not happen with a good patch file.
688
689@end ifset
690
691@c
692@c  Compiling and Installing the GNU Debugger GDB
693@c
694
695@subsection Compiling and Installing the GNU Debugger GDB
696
697There are three methods of building the GNU Debugger:
698
699@itemize @bullet
700@item RPM
701@item direct invocation of @code{configure} and @code{make}
702@end itemize
703
704Direct invocation of @code{configure} and @code{make} provides more control
705and easier recovery from problems when building.
706
707@c
708@c  Using RPM to Build GDB
709@c
710
711@subsubsection Using RPM to Build GDB
712
713This section describes the process of building binutils, gcc, and
714newlib using RPM.  RPM is a packaging format which can be used to
715distribute binary files as well as to capture the procedure and
716source code used to produce those binary files.  Before
717attempting to build any RPM from source, it is necessary to
718ensure that all required source and patches are in the @code{SOURCES}
719directory under the RPM root (probably @code{/usr/src/redhat} or
720@code{/usr/local/src/redhat}) on your machine.  This procedure
721starts by installing the source RPMs as shown in the following
722example:
723
724@example
725rpm -i i386-rtems-gdb-collection-4.18-4.nosrc.rpm
726@end example
727
728Because RTEMS tool RPMS are called "nosrc" to indicate that one or
729more source files required to produce the RPMs are not present.
730The RTEMS source GDB RPM does not include the large @code{.tar.gz} or
731@code{.tgz} files for GDB.  This is shared by all RTEMS RPMs
732regardless of target CPU and there was no reason
733to duplicate them.  You will have to get the required source
734archive files by hand and place them in the @code{SOURCES} directory
735before attempting to build.  If you forget to do this, RPM is
736smart -- it will tell you what is missing.  To determine what is
737included or referenced by a particular RPM, use a command like the
738following:
739
740@example
741$ rpm -q -l -p i386-rtems-gdb-collection-4.18-4.nosrc.rpm
742gdb-4.18-rtems-20000524.diff
743gdb-4.18.tar.gz
744i386-rtems-gdb-4.18.spec
745@end example
746
747Notice that there is a patch file (the @code{.diff} file), a source archive
748file (the @code{.tar.gz}), and a file describing the build procedure and
749files produced (the @code{.spec} file).  The @code{.spec} file is placed
750in the @code{SPECS} directory under the RPM root directory.
751
752@c
753@c  Configuring and Building GDB using RPM
754@c
755
756@subheading Configuring and Building GDB using RPM
757
758The following example illustrates the invocation of RPM to build a new,
759locally compiled, binutils binary RPM that matches the installed source
760RPM.  This example assumes that all of the required source is installed.
761
762@example
763cd <RPM_ROOT_DIRECTORY>/SPECS
764rpm -bb i386-rtems-gdb-4.18.spec
765@end example
766
767If the build completes successfully, RPMS like the following will
768be generated in a build-host architecture specific subdirectory
769of the RPMS directory under the RPM root directory.
770
771@example
772rtems-base-gdb-4.18-4.i386.rpm
773i386-rtems-gdb-4.18-4.i386.rpm
774@end example
775
776NOTE: It may be necessary to remove the build tree in the
777@code{BUILD} directory under the RPM root directory.
778
779@c
780@c Using the GDB configure Script Directly
781@c
782
783@subsubsection Using the GDB configure Script Directly
784
785This section describes how to configure the GNU debugger for
786RTEMS targets using @code{configure} and @code{make} directly.
787The following example illustrates the invocation of @code{configure}
788and @code{make} to build and install @value{GDB-UNTAR} for the
789m68k-rtems target:
790
791@example
792mkdir b-gdb
793cd b-gdb
794../@value{GDB-UNTAR}/configure --target=m68k-rtems \
795  --prefix=/opt/rtems
796make all
797make info
798make install
799@end example
800
801For some configurations, it is necessary to specify extra options
802to @code{configure} to enable and configure option components
803such as a processor simulator.  The following is a list of
804configurations for which there are extra options:
805
806@table @b
807@item i960-rtems
808@code{--enable-sim}
809
810@item powerpc-rtems
811@code{--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware}
812
813@item sparc-rtems
814@code{--enable-sim}
815
816@end table
817
818After @value{GDB-UNTAR} is built and installed the
819build directory @code{b-gdb} may be removed.
820
821For more information on the invocation of @code{configure}, please
822refer to the documentation for @value{GDB-UNTAR} or
823invoke the @value{GDB-UNTAR} @code{configure} command with the
824@code{--help} option.
825
826@c
827@c Common Problems
828@c
829
830@section Common Problems
831
832@subsection Error Message Indicates Invalid Option to Assembler
833
834If a message like this is printed then the new cross compiler
835is most likely using the native assembler instead of the cross
836assembler or vice-versa (native compiler using new cross assembler).
837This can occur for one of the following reasons:
838
839@itemize @bullet
840
841@item Binutils Patch Improperly Applied
842@item Binutils Not Built
843@item Current Directory is in Your PATH
844
845@end itemize
846
847If you are using binutils 2.9.1 or newer with certain older versions of
848gcc, they do not agree on what the name of the newly
849generated cross assembler is.  Older binutils called it @code{as.new}
850which became @code{as.new.exe} under Windows.  This is not a valid
851file name, so @code{as.new} is now called @code{as-new}.  By using the latest
852released tool versions and RTEMS patches, this problem will be avoided.
853
854If binutils did not successfully build the cross assembler, then
855the new cross gcc (@code{xgcc}) used to build the libraries can not
856find it.  Make sure the build of the binutils succeeded.
857
858If you include the current directory in your PATH, then there
859is a chance that the native compiler will accidentally use
860the new cross assembler instead of the native one.  This usually
861indicates that "." is before the standard system directories
862in your PATH.  As a general rule, including "." in your PATH
863is a security risk and should be avoided.  Remove "." from
864your PATH.
865
866NOTE:  In some environments, it may be difficult to remove "."
867completely from your PATH.  In this case, make sure that "."
868is after the system directories containing "as" and "ld".
869
870@subsection Error Messages Indicating Configuration Problems
871
872If you see error messages like the following,
873
874@itemize @bullet
875
876@item cannot configure libiberty
877@item coff-emulation not found
878@item etc.
879
880@end itemize
881
882Then it is likely that one or more of your gnu tools is
883already configured locally in its source tree.  You can check
884for this by searching for the @code{config.status} file
885in the various tool source trees.  The following command
886does this for the binutils source:
887
888@example
889find @value{BINUTILS-UNTAR} -name config.status -print
890@end example
891
892The solution for this is to execute the command
893@code{make distclean} in each of the GNU tools
894root source directory.  This should remove all
895generated files including Makefiles.
896
897This situation usually occurs when you have previously
898built the tool source for some non-RTEMS target.  The
899generated configuration specific files are still in
900the source tree and the include path specified during
901the RTEMS build accidentally picks up the previous
902configuration.  The include path used is something like
903this:
904
905@example
906-I../../@value{BINUTILS-UNTAR}/gcc -I/@value{BINUTILS-UNTAR}/gcc/include -I.
907@end example
908
909Note that the tool source directory is searched before the
910build directory.
911
912This situation can be avoided entirely by never using
913the source tree as the build directory -- even for
914
Note: See TracBrowser for help on using the repository browser.