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