[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 | |
---|
[57a736ff] | 16 | @section Get All the Pieces |
---|
| 17 | |
---|
[6113b3a] | 18 | Gather the components that will be required for the installation and place |
---|
[0df2ab87] | 19 | them in an archive directory. Call this directory @code{arc}. Be sure that there |
---|
[6113b3a] | 20 | is sufficient space to hold all necessary information. This will amount to |
---|
[0df2ab87] | 21 | approximately 20 megabytes. In addition, make a directory named @code{tools} |
---|
| 22 | to build the cross-compiler in. |
---|
| 23 | |
---|
[6113b3a] | 24 | |
---|
[bdec2709] | 25 | @subheading @value{GCC-VERSION} |
---|
[6113b3a] | 26 | @example |
---|
[bdec2709] | 27 | FTP Site: @value{GCC-FTPSITE} |
---|
| 28 | Directory: @value{GCC-FTPDIR} |
---|
| 29 | File: @value{GCC-TAR} |
---|
| 30 | @end example |
---|
[6113b3a] | 31 | |
---|
[bdec2709] | 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 |
---|
[6113b3a] | 38 | |
---|
[bdec2709] | 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 |
---|
[6113b3a] | 45 | |
---|
[bdec2709] | 46 | @subheading @value{RTEMS-VERSION} |
---|
| 47 | @example |
---|
| 48 | FTP Site: @value{RTEMS-FTPSITE} |
---|
| 49 | Directory: @value{RTEMS-FTPDIR} |
---|
| 50 | File: @value{RTEMS-TAR} |
---|
[6113b3a] | 51 | File: bit |
---|
[57a736ff] | 52 | @ifset BINUTILS-RTEMSPATCH |
---|
[bdec2709] | 53 | File: @value{BINUTILS-RTEMSPATCH} |
---|
[57a736ff] | 54 | @end ifset |
---|
| 55 | @ifset NEWLIB-RTEMSPATCH |
---|
[bdec2709] | 56 | File: @value{NEWLIB-RTEMSPATCH} |
---|
[57a736ff] | 57 | @end ifset |
---|
| 58 | @ifset GCC-RTEMSPATCH |
---|
[bdec2709] | 59 | File: @value{GCC-RTEMSPATCH} |
---|
[57a736ff] | 60 | @end ifset |
---|
[bdec2709] | 61 | File: hello_world_c.tgz |
---|
[6113b3a] | 62 | @end example |
---|
| 63 | |
---|
[57a736ff] | 64 | @section Create the tools Directory |
---|
[417fcc73] | 65 | |
---|
[6113b3a] | 66 | Create a directory called tools that will serve as a working directory to |
---|
[0df2ab87] | 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 | |
---|
[417fcc73] | 85 | |
---|
[0df2ab87] | 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 |
---|
[79bb9221] | 109 | |
---|
[6e3c36b7] | 110 | @section Unarchiving the Tools |
---|
[0df2ab87] | 111 | |
---|
| 112 | While in the @code{tools} directory, unpack the compressed |
---|
| 113 | tar files using the following command sequence: |
---|
[417fcc73] | 114 | |
---|
| 115 | @example |
---|
| 116 | cd tools |
---|
[bdec2709] | 117 | tar xzf ../arc/@value{GCC-TAR} |
---|
| 118 | tar xzf ../arc/@value{BINUTILS-TAR} |
---|
| 119 | tar xzf ../arc/@value{NEWLIB-TAR} |
---|
[417fcc73] | 120 | @end example |
---|
| 121 | |
---|
[6113b3a] | 122 | After the compressed tar files have been unpacked, the following |
---|
| 123 | directories will have been created under tools. |
---|
| 124 | |
---|
| 125 | @itemize @bullet |
---|
[bdec2709] | 126 | @item @value{BINUTILS-UNTAR} |
---|
| 127 | @item @value{GCC-UNTAR} |
---|
| 128 | @item @value{NEWLIB-UNTAR} |
---|
[6113b3a] | 129 | @end itemize |
---|
| 130 | |
---|
[6e3c36b7] | 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: |
---|
[0df2ab87] | 140 | |
---|
| 141 | @ifset use-ascii |
---|
| 142 | @example |
---|
| 143 | @group |
---|
[6e3c36b7] | 144 | tools |
---|
| 145 | | bit (script) |
---|
| 146 | + |
---|
| 147 | +---------+-------------+------------+----------------+ |
---|
| 148 | | | | | | |
---|
| 149 | src binutils-2.9 egcs-1.0.2 newlib-1.8.0 build-$@{CPU@}-tools |
---|
[0df2ab87] | 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 |
---|
[6e3c36b7] | 159 | tools |
---|
| 160 | | bit (script) |
---|
| 161 | + |
---|
| 162 | +---------+-------------+------------+----------------+ |
---|
| 163 | | | | | | |
---|
| 164 | src binutils-2.9 egcs-1.0.2 newlib-1.8.0 build-${CPU}-tools |
---|
[0df2ab87] | 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 | |
---|
[bdec2709] | 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 |
---|
[417fcc73] | 229 | |
---|
[bdec2709] | 230 | @ifset BINUTILS-RTEMSPATCH |
---|
| 231 | Apply the patch using the following command sequence: |
---|
[417fcc73] | 232 | |
---|
| 233 | @example |
---|
[bdec2709] | 234 | cd tools/@value{BINUTILS-UNTAR} |
---|
| 235 | zcat arc/@value{BINUTILS-RTEMSPATCH} | patch -p1 |
---|
[417fcc73] | 236 | @end example |
---|
| 237 | |
---|
[6113b3a] | 238 | Check to see if any of these patches have been rejected using the following |
---|
| 239 | sequence: |
---|
| 240 | |
---|
| 241 | @example |
---|
[bdec2709] | 242 | cd tools/@value{BINUTILS-UNTAR} |
---|
[6113b3a] | 243 | find . -name "*.rej" -print |
---|
| 244 | @end example |
---|
[417fcc73] | 245 | |
---|
[6113b3a] | 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: |
---|
[417fcc73] | 250 | |
---|
| 251 | @example |
---|
[bdec2709] | 252 | cd tools/@value{BINUTILS-UNTAR} |
---|
[6113b3a] | 253 | find . -name "*.orig" -print |
---|
[417fcc73] | 254 | @end example |
---|
| 255 | |
---|
[6113b3a] | 256 | The files that are found, have been modified by the patch file. |
---|
| 257 | |
---|
[bdec2709] | 258 | @end ifset |
---|
[6113b3a] | 259 | |
---|
[bdec2709] | 260 | @c |
---|
| 261 | @c Newlib patches |
---|
| 262 | @c |
---|
[6113b3a] | 263 | |
---|
[bdec2709] | 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: |
---|
[6113b3a] | 274 | |
---|
| 275 | @example |
---|
[bdec2709] | 276 | cd tools/@value{NEWLIB-UNTAR} |
---|
| 277 | zcat arc/@value{NEWLIB-RTEMSPATCH} | patch -p1 |
---|
[6113b3a] | 278 | @end example |
---|
| 279 | |
---|
| 280 | Check to see if any of these patches have been rejected using the following |
---|
| 281 | sequence: |
---|
| 282 | |
---|
| 283 | @example |
---|
[bdec2709] | 284 | cd tools/@value{NEWLIB-UNTAR} |
---|
[6113b3a] | 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: |
---|
[417fcc73] | 292 | |
---|
| 293 | @example |
---|
[bdec2709] | 294 | cd tools/@value{NEWLIB-UNTAR} |
---|
[6113b3a] | 295 | find . -name "*.orig" -print |
---|
[417fcc73] | 296 | @end example |
---|
| 297 | |
---|
[6113b3a] | 298 | The files that are found, have been modified by the patch file. |
---|
| 299 | |
---|
[bdec2709] | 300 | @end ifset |
---|
| 301 | |
---|
| 302 | @c |
---|
| 303 | @c Modify the bit script |
---|
| 304 | @c |
---|
| 305 | |
---|
[8a3fd66] | 306 | @section Modify the bit Script |
---|
[6113b3a] | 307 | |
---|
[bdec2709] | 308 | Copy the @code{bit} script from arc to the tools directory. |
---|
[6113b3a] | 309 | |
---|
[bdec2709] | 310 | Edit the @code{bit} file to alter the following environmental variables: |
---|
[6113b3a] | 311 | |
---|
| 312 | @itemize @bullet |
---|
| 313 | @item INSTALL_POINT |
---|
| 314 | @item BINUTILS |
---|
| 315 | @item NEWLIB |
---|
| 316 | @item GCC |
---|
| 317 | @item BUILD_DOCS |
---|
[bdec2709] | 318 | @item BUILD_OTHER_LANGUAGES |
---|
[6113b3a] | 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. |
---|
[bdec2709] | 336 | # BUILD_OTHER_LANGUAGES: |
---|
| 337 | # Set to "yes" if you want to build Fortran and Objective-C |
---|
[6113b3a] | 338 | # |
---|
[bdec2709] | 339 | BINUTILS=@value{BINUTILS-UNTAR} |
---|
| 340 | GCC=@value{GCC-UNTAR} |
---|
| 341 | NEWLIB=@value{NEWLIB-UNTAR} |
---|
[6113b3a] | 342 | BUILD_DOCS=yes |
---|
[bdec2709] | 343 | BUILD_OTHER_LANGUAGES=yes |
---|
[6113b3a] | 344 | INSTALL_POINT=/home/joel/$@{GCC@}/$@{target@} |
---|
| 345 | |
---|
| 346 | # USERCHANGE - uncomment this if you want to watch the commands. |
---|
| 347 | @end example |
---|
| 348 | |
---|
[bdec2709] | 349 | Where each of the variables which may be modified is described below: |
---|
[417fcc73] | 350 | |
---|
[6113b3a] | 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 |
---|
[bdec2709] | 359 | is the directory under tools that contains @value{BINUTILS-UNTAR}. |
---|
[fdd6a26] | 360 | For example: |
---|
[bdec2709] | 361 | |
---|
| 362 | @example |
---|
[fdd6a26] | 363 | BINUTILS=@value{BINUTILS-UNTAR} |
---|
[bdec2709] | 364 | @end example |
---|
[6113b3a] | 365 | |
---|
| 366 | @item GCC |
---|
[bdec2709] | 367 | is the directory under tools that contains @value{GCC-UNTAR}. |
---|
| 368 | For example, |
---|
| 369 | |
---|
| 370 | @example |
---|
[fdd6a26] | 371 | GCC=@value{GCC-UNTAR} |
---|
[bdec2709] | 372 | @end example |
---|
[417fcc73] | 373 | |
---|
[6113b3a] | 374 | @item NEWLIB |
---|
[bdec2709] | 375 | is the directory under tools that contains @value{NEWLIB-UNTAR}. |
---|
[fdd6a26] | 376 | For example: |
---|
[bdec2709] | 377 | |
---|
| 378 | @example |
---|
[fdd6a26] | 379 | NEWLIB=@value{NEWLIB-UNTAR} |
---|
[bdec2709] | 380 | @end example |
---|
[417fcc73] | 381 | |
---|
[6113b3a] | 382 | @item BUILD_DOCS |
---|
| 383 | is set to "yes" if you want to install documentation. |
---|
[fdd6a26] | 384 | For example: |
---|
[bdec2709] | 385 | |
---|
| 386 | @example |
---|
[6113b3a] | 387 | BUILD_DOCS=yes |
---|
[bdec2709] | 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. |
---|
[fdd6a26] | 393 | For example: |
---|
[bdec2709] | 394 | |
---|
| 395 | @example |
---|
| 396 | BUILD_OTHER_LANGUAGES=yes |
---|
| 397 | @end example |
---|
[6113b3a] | 398 | |
---|
| 399 | @end table |
---|
| 400 | |
---|
[8a3fd66] | 401 | @section Running the bit Script |
---|
[6113b3a] | 402 | |
---|
[bdec2709] | 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: |
---|
[6113b3a] | 406 | |
---|
| 407 | @example |
---|
| 408 | cd tools |
---|
| 409 | ./bit <target configuration> |
---|
| 410 | @end example |
---|
| 411 | |
---|
[bdec2709] | 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 |
---|
[6113b3a] | 426 | |
---|
[bdec2709] | 427 | If no errors are encountered, the @code{bit} script will conclude by |
---|
| 428 | printing messages similar to the following: |
---|
[6113b3a] | 429 | |
---|
| 430 | @example |
---|
[bdec2709] | 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 |
---|
[6113b3a] | 436 | @end example |
---|
[417fcc73] | 437 | |
---|
[bdec2709] | 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. |
---|
[417fcc73] | 443 | |
---|