home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / g77doc.zip / install.tex < prev    next >
Text File  |  1998-03-24  |  85KB  |  2,198 lines

  1. @c Copyright (C) 1995-1997 Free Software Foundation, Inc.
  2. @c This is part of the G77 manual.
  3. @c For copying conditions, see the file g77.tex.
  4.  
  5. @c The text of this file appears in the file INSTALL
  6. @c in the G77 distribution, as well as in the G77 manual.
  7.  
  8. @c 1998-03-15
  9.  
  10. @set version-g77 0.5.22
  11. @set version-gcc 2.7.2.3
  12. @set version-gcc-patched 2.7.2.3.f.2
  13. @set version-gzip 1.2.4
  14. @set version-tar 1.12
  15. @set version-patch 2.5
  16. @set version-make 3.76.1
  17. @set version-bison 1.25
  18. @set version-makeinfo 1.68
  19. @set version-texinfo 3.11
  20. @set version-sed 2.05
  21.  
  22. @ifclear INSTALLONLY
  23. @node Installation
  24. @chapter Installing GNU Fortran
  25. @end ifclear
  26. @cindex installing GNU Fortran
  27.  
  28. The following information describes how to install @code{g77}.
  29.  
  30. The information in this file generally pertains to dealing
  31. with @emph{source} distributions of @code{g77} and @code{gcc}.
  32. It is possible that some of this information will be applicable
  33. to some @emph{binary} distributions of these products---however,
  34. since these distributions are not made by the maintainers of
  35. @code{g77}, responsibility for binary distributions rests with
  36. whoever built and first distributed them.
  37.  
  38. Nevertheless, efforts to make @code{g77} easier to both build
  39. and install from source and package up as a binary distribution
  40. are ongoing.
  41.  
  42. @menu
  43. * Prerequisites::          Make sure your system is ready for @code{g77}.
  44. * Problems Installing::    Known trouble areas.
  45. * Settings::               Changing @code{g77} internals before building.
  46. * Quick Start::            The easier procedure for non-experts.
  47. * Complete Installation::  For experts, or those who want to be: the details.
  48. * Distributing Binaries::  If you plan on distributing your @code{g77}.
  49. @end menu
  50.  
  51. @node Prerequisites
  52. @section Prerequisites
  53. @cindex prerequisites
  54.  
  55. The procedures described to unpack, configure, build, and
  56. install @code{g77} assume your system has certain programs
  57. already installed.
  58.  
  59. The following prerequisites should be met by your
  60. system before you follow the @code{g77} installation instructions:
  61.  
  62. @table @asis
  63. @item @code{gzip}
  64. To unpack the @code{gcc} and @code{g77} distributions,
  65. you'll need the @code{gunzip} utility in the @code{gzip}
  66. distribution.
  67. Most UNIX systems already have @code{gzip} installed.
  68. If yours doesn't, you can get it from the FSF.
  69.  
  70. Note that you'll need @code{tar} and other utilities
  71. as well, but all UNIX systems have these.
  72. There are GNU versions of all these available---in fact,
  73. a complete GNU UNIX system can be put together on
  74. most systems, if desired.
  75.  
  76. The version of GNU @code{gzip} used to package this release
  77. is @value{version-gzip}.
  78. (The version of GNU @code{tar} used to package this release
  79. is @value{version-tar}.)
  80.  
  81. @item @file{gcc-@value{version-gcc}.tar.gz}
  82. You need to have this, or some other applicable, version
  83. of @code{gcc} on your system.
  84. The version should be an exact copy of a distribution
  85. from the FSF.
  86. Its size is approximately 7.1MB.
  87.  
  88. If you've already unpacked @file{gcc-@value{version-gcc}.tar.gz} into a
  89. directory (named @file{gcc-@value{version-gcc}}) called the @dfn{source tree}
  90. for @code{gcc}, you can delete the distribution
  91. itself, but you'll need to remember to skip any instructions to unpack
  92. this distribution.
  93.  
  94. Without an applicable @code{gcc} source tree, you cannot
  95. build @code{g77}.
  96. You can obtain an FSF distribution of @code{gcc} from the FSF.
  97.  
  98. @item @file{g77-@value{version-g77}.tar.gz}
  99. You probably have already unpacked this package,
  100. or you are reading an advance copy of these installation instructions,
  101. which are contained in this distribution.
  102. The size of this package is approximately 1.5MB.
  103.  
  104. You can obtain an FSF distribution of @code{g77} from the FSF,
  105. the same way you obtained @code{gcc}.
  106.  
  107. @item Enough disk space
  108. The amount of disk space needed to unpack, build, install,
  109. and use @code{g77} depends on the type of system you're
  110. using, how you build @code{g77}, and how much of it you
  111. install (primarily, which languages you install).
  112.  
  113. The sizes shown below assume all languages distributed
  114. in @code{gcc-@value{version-gcc}}, plus @code{g77}, will be built
  115. and installed.
  116. These sizes are indicative of GNU/Linux systems on
  117. Intel x86 running COFF and on Digital Alpha (AXP) systems
  118. running ELF.
  119. These should be fairly representative of 32-bit and 64-bit
  120. systems, respectively.
  121.  
  122. Note that all sizes are approximate and subject to change without
  123. notice!
  124. They are based on preliminary releases of g77 made shortly
  125. before the public beta release.
  126.  
  127. @itemize ---
  128. @item
  129. @code{gcc} and @code{g77} distributions occupy 8.6MB
  130. packed, 35MB unpacked.
  131. These consist of the source code and documentation,
  132. plus some derived files (mostly documentation), for
  133. @code{gcc} and @code{g77}.
  134. Any deviations from these numbers for different
  135. kinds of systems are likely to be very minor.
  136.  
  137. @item
  138. A ``bootstrap'' build requires an additional 67.3MB
  139. for a total of 102MB on an ix86, and an additional
  140. 98MB for a total of 165MB on an Alpha.
  141.  
  142. @item
  143. Removing @file{gcc/stage1} after the build recovers
  144. 10.7MB for a total of 91MB on an ix86, and recovers
  145. ??MB for a total of ??MB on an Alpha.
  146.  
  147. After doing this, the integrity of the build can
  148. still be verified via @samp{make compare}, and the
  149. @code{gcc} compiler modified and used to build itself for
  150. testing fairly quickly, using the copy of the compiler
  151. kept in @code{gcc/stage2}.
  152.  
  153. @item
  154. Removing @file{gcc/stage2} after the build further
  155. recovers 27.3MB for a total of 64.3MB, and recovers
  156. ??MB for a total of ??MB on an Alpha.
  157.  
  158. After doing this, the compiler can still be installed,
  159. especially if GNU @code{make} is used to avoid
  160. gratuitous rebuilds (or, the installation can be done
  161. by hand).
  162.  
  163. @item
  164. Installing @code{gcc} and @code{g77} copies
  165. 14.9MB onto the @samp{--prefix} disk for a total of 79.2MB
  166. on an ix86, and copies ??MB onto the @samp{--prefix}
  167. disk for a total of ??MB on an Alpha.
  168. @end itemize
  169.  
  170. After installation, if no further modifications and
  171. builds of @code{gcc} or @code{g77} are planned, the
  172. source and build directory may be removed, leaving
  173. the total impact on a system's disk storage as
  174. that of the amount copied during installation.
  175.  
  176. Systems with the appropriate version of @code{gcc}
  177. installed don't require the complete
  178. bootstrap build.
  179. Doing a ``straight build'' requires about as much
  180. space as does a bootstrap build followed by removing
  181. both the @file{gcc/stage1} and @file{gcc/stage2}
  182. directories.
  183.  
  184. Installing @code{gcc} and @code{g77} over existing
  185. versions might require less @emph{new} disk space,
  186. but note that, unlike many products, @code{gcc}
  187. installs itself in a way that avoids overwriting other
  188. installed versions of itself, so that other versions may
  189. easily be invoked (via @samp{gcc -V @var{version}}).
  190.  
  191. So, the amount of space saved as a result of having
  192. an existing version of @code{gcc} and @code{g77}
  193. already installed is not much---typically only the
  194. command drivers (@code{gcc}, @code{g77}, @code{g++},
  195. and so on, which are small) and the documentation
  196. is overwritten by the new installation.
  197. The rest of the new installation is done without
  198. replacing existing installed versions (assuming
  199. they have different version numbers).
  200.  
  201. @item @code{patch}
  202. Although you can do everything @code{patch} does yourself,
  203. by hand, without much trouble, having @code{patch} installed
  204. makes installation of new versions of GNU utilities such as
  205. @code{g77} so much easier that it is worth getting.
  206. You can obtain @code{patch} the same way you obtained
  207. @code{gcc} and @code{g77}.
  208.  
  209. In any case, you can apply patches by hand---patch files
  210. are designed for humans to read them.
  211.  
  212. The version of GNU @code{patch} used to develop this release
  213. is @value{version-patch}.
  214.  
  215. @item @code{make}
  216. Your system must have @code{make}, and you will probably save
  217. yourself a lot of trouble if it is GNU @code{make} (sometimes
  218. referred to as @code{gmake}).
  219.  
  220. The version of GNU @code{make} used to develop this release
  221. is @value{version-make}.
  222.  
  223. @item @code{cc}
  224. Your system must have a working C compiler.
  225.  
  226. @xref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC},
  227. for more information on prerequisites for installing @code{gcc}.
  228.  
  229. @item @code{bison}
  230. If you do not have @code{bison} installed, you can usually
  231. work around any need for it, since @code{g77} itself does
  232. not use it, and @code{gcc} normally includes all files
  233. generated by running it in its distribution.
  234. You can obtain @code{bison} the same way you obtained
  235. @code{gcc} and @code{g77}.
  236.  
  237. The version of GNU @code{bison} used to develop this release
  238. is @value{version-bison}.
  239.  
  240. @xref{Missing bison?},
  241. for information on how to work around not having @code{bison}.
  242.  
  243. @item @code{makeinfo}
  244. If you are missing @code{makeinfo}, you can usually work
  245. around any need for it.
  246. You can obtain @code{makeinfo} the same way you obtained
  247. @code{gcc} and @code{g77}.
  248.  
  249. The version of GNU @code{makeinfo} used to develop this release
  250. is @value{version-makeinfo}, from
  251. GNU @code{texinfo} version @value{version-texinfo}.
  252.  
  253. @xref{Missing makeinfo?},
  254. for information on getting around the lack of @code{makeinfo}.
  255.  
  256. @item @code{sed}
  257. All UNIX systems have @code{sed}, but some have a broken
  258. version that cannot handle configuring, building, or
  259. installing @code{gcc} or @code{g77}.
  260.  
  261. The version of GNU @code{sed} used to develop this release
  262. is @value{version-sed}.
  263. (Note that GNU @code{sed} version 3.0 was withdrawn by the
  264. FSF---if you happen to have this version installed, replace
  265. it with version @value{version-sed} immediately.
  266. See a GNU distribution site for further explanation.)
  267.  
  268. @item @code{root} access or equivalent
  269. To perform the complete installation procedures on a system,
  270. you need to have @code{root} access to that system, or
  271. equivalent access to the @samp{--prefix} directory tree
  272. specified on the @code{configure} command line.
  273.  
  274. Portions of the procedure (such as configuring and building
  275. @code{g77}) can be performed by any user with enough disk
  276. space and virtual memory.
  277.  
  278. However, these instructions are oriented towards less-experienced
  279. users who want to install @code{g77} on their own personal
  280. systems.
  281.  
  282. System administrators with more experience will want to
  283. determine for themselves how they want to modify the
  284. procedures described below to suit the needs of their
  285. installation.
  286. @end table
  287.  
  288. @node Problems Installing
  289. @section Problems Installing
  290. @cindex problems installing
  291. @cindex installation problems
  292.  
  293. This is a list of problems (and some apparent problems which don't
  294. really mean anything is wrong) that show up when configuring,
  295. building, installing, or porting GNU Fortran.
  296.  
  297. @xref{Installation Problems,,,gcc,Using and Porting GNU CC},
  298. for more information on installation problems that can afflict
  299. either @code{gcc} or @code{g77}.
  300.  
  301. @menu
  302. * General Problems::         Problems afflicting most or all systems.
  303. * System-specific Problems:: Problems afflicting particular systems.
  304. * Cross-compiler Problems::  Problems afflicting cross-compilation setups.
  305. @end menu
  306.  
  307. @node General Problems
  308. @subsection General Problems
  309.  
  310. These problems can occur on most or all systems.
  311.  
  312. @menu
  313. * GNU C Required::             Why even ANSI C is not enough.
  314. * Patching GNU CC Necessary::  Why @code{gcc} must be patched first.
  315. * Building GNU CC Necessary::  Why you can't build @emph{just} Fortran.
  316. * Missing strtoul::            If linking @code{f771} fails due to an
  317.                                 unresolved reference to @code{strtoul}.
  318. * Object File Differences::    It's okay that @samp{make compare} will
  319.                                 flag @file{f/zzz.o}.
  320. * Cleanup Kills Stage Directories::  A minor nit for @code{g77} developers.
  321. * Missing gperf?::             When building requires @code{gperf}.
  322. @end menu
  323.  
  324. @node GNU C Required
  325. @subsubsection GNU C Required
  326. @cindex GNU C required
  327. @cindex requirements, GNU C
  328.  
  329. Compiling @code{g77} requires GNU C, not just ANSI C.
  330. Fixing this wouldn't
  331. be very hard (just tedious), but the code using GNU extensions to
  332. the C language is expected to be rewritten for 0.6 anyway,
  333. so there are no plans for an interim fix.
  334.  
  335. This requirement does not mean you must already have @code{gcc}
  336. installed to build @code{g77}.
  337. As long as you have a working C compiler, you can use a
  338. bootstrap build to automate the process of first building
  339. @code{gcc} using the working C compiler you have, then building
  340. @code{g77} and rebuilding @code{gcc} using that just-built @code{gcc},
  341. and so on.
  342.  
  343. @node Patching GNU CC Necessary
  344. @subsubsection Patching GNU CC Necessary
  345. @cindex patch files
  346. @cindex GBE
  347.  
  348. @code{g77} currently requires application of a patch file to the gcc compiler
  349. tree.
  350. The necessary patches should be folded in to the mainline gcc distribution.
  351.  
  352. Some combinations
  353. of versions of @code{g77} and @code{gcc} might actually @emph{require} no
  354. patches, but the patch files will be provided anyway as long as
  355. there are more changes expected in subsequent releases.
  356. These patch files might contain
  357. unnecessary, but possibly helpful, patches.
  358. As a result, it is possible this issue might never be
  359. resolved, except by eliminating the need for the person
  360. configuring @code{g77} to apply a patch by hand, by going
  361. to a more automated approach (such as configure-time patching).
  362.  
  363. @node Building GNU CC Necessary
  364. @subsubsection Building GNU CC Necessary
  365. @cindex gcc, building
  366. @cindex building gcc
  367.  
  368. It should be possible to build the runtime without building @code{cc1}
  369. and other non-Fortran items, but, for now, an easy way to do that
  370. is not yet established.
  371.  
  372. @node Missing strtoul
  373. @subsubsection Missing strtoul
  374. @cindex strtoul
  375. @cindex _strtoul
  376. @cindex undefined reference (_strtoul)
  377. @cindex f771, linking error for
  378. @cindex linking error for f771
  379. @cindex ld error for f771
  380. @cindex ld can't find _strtoul
  381. @cindex SunOS4
  382.  
  383. On SunOS4 systems, linking the @code{f771} program produces
  384. an error message concerning an undefined symbol named
  385. @samp{_strtoul}.
  386.  
  387. This is not a @code{g77} bug.
  388. @xref{Patching GNU Fortran}, for information on
  389. a workaround provided by @code{g77}.
  390.  
  391. The proper fix is either to upgrade your system to one that
  392. provides a complete ANSI C environment, or improve @code{gcc} so
  393. that it provides one for all the languages and configurations it supports.
  394.  
  395. @emph{Note:} In earlier versions of @code{g77}, an automated
  396. workaround for this problem was attempted.
  397. It worked for systems without @samp{_strtoul}, substituting
  398. the incomplete-yet-sufficient version supplied with @code{g77}
  399. for those systems.
  400. However, the automated workaround failed mysteriously for systems
  401. that appeared to have conforming ANSI C environments, and it
  402. was decided that, lacking resources to more fully investigate
  403. the problem, it was better to not punish users of those systems
  404. either by requiring them to work around the problem by hand or
  405. by always substituting an incomplete @code{strtoul()} implementation
  406. when their systems had a complete, working one.
  407. Unfortunately, this meant inconveniencing users of systems not
  408. having @code{strtoul()}, but they're using obsolete (and generally
  409. unsupported) systems anyway.
  410.  
  411. @node Object File Differences
  412. @subsubsection Object File Differences
  413. @cindex zzz.o
  414. @cindex zzz.c
  415. @cindex object file, differences
  416. @cindex differences between object files
  417. @cindex make compare
  418.  
  419. A comparison of object files after building Stage 3 during a
  420. bootstrap build will result in @file{gcc/f/zzz.o} being flagged
  421. as different from the Stage 2 version.
  422. That is because it
  423. contains a string with an expansion of the @code{__TIME__} macro,
  424. which expands to the current time of day.
  425. It is nothing to worry about, since
  426. @file{gcc/f/zzz.c} doesn't contain any actual code.
  427. It does allow you to override its use of @code{__DATE__} and
  428. @code{__TIME__} by defining macros for the compilation---see the
  429. source code for details.
  430.  
  431. @node Cleanup Kills Stage Directories
  432. @subsubsection Cleanup Kills Stage Directories
  433. @cindex stage directories
  434. @cindex make clean
  435.  
  436. It'd be helpful if @code{g77}'s @file{Makefile.in} or @file{Make-lang.in}
  437. would create the various @file{stage@var{n}} directories and their
  438. subdirectories, so developers and expert installers wouldn't have to
  439. reconfigure after cleaning up.
  440.  
  441. @node Missing gperf?
  442. @subsubsection Missing @code{gperf}?
  443. @cindex @code{gperf}
  444. @cindex missing @code{gperf}
  445.  
  446. If a build aborts trying to invoke @code{gperf}, that
  447. strongly suggests an improper method was used to
  448. create the @code{gcc} source directory,
  449. such as the UNIX @samp{cp -r} command instead
  450. of @samp{cp -pr}, since this problem very likely
  451. indicates that the date-time-modified information on
  452. the @code{gcc} source files is incorrect.
  453.  
  454. The proper solution is to recreate the @code{gcc} source
  455. directory from a @code{gcc} distribution known to be
  456. provided by the FSF.
  457.  
  458. It is possible you might be able to temporarily
  459. work around the problem, however, by trying these
  460. commands:
  461.  
  462. @example
  463. sh# @kbd{cd gcc}
  464. sh# @kbd{touch c-gperf.h}
  465. sh#
  466. @end example
  467.  
  468. These commands update the date-time-modified information for
  469. the file produced by the invocation of @code{gperf}
  470. in the current versions of @code{gcc}, so that @code{make} no
  471. longer believes it needs to update it.
  472. This file should already exist in a @code{gcc}
  473. distribution, but mistakes made when copying the @code{gcc}
  474. directory can leave the modification information
  475. set such that the @code{gperf} input files look more ``recent''
  476. than the corresponding output files.
  477.  
  478. If the above does not work, definitely start from scratch
  479. and avoid copying the @code{gcc} using any method that does
  480. not reliably preserve date-time-modified information, such
  481. as the UNIX @samp{cp -r} command (use @samp{cp -pr} instead).
  482.  
  483. @node System-specific Problems
  484. @subsection System-specific Problems
  485.  
  486. @cindex Digital Alpha
  487. @cindex Alpha, Digital
  488. @cindex DEC Alpha
  489. @cindex AXP
  490. If your system is based on a Digital Alpha (AXP) architecture
  491. and employs a 64-bit operating system (such as GNU/Linux),
  492. you might consider using @code{egcs} instead of versions
  493. of @code{g77} based on versions of @code{gcc} prior to 2.8.
  494. @uref{http://www.cygnus.com/egcs} for information on @code{egcs},
  495. or obtain a copy from @uref{ftp://egcs.cygnus.com/pub/egcs}.
  496.  
  497. @cindex Irix 6
  498. @cindex SGI
  499. If your system is Irix 6, to obtain a working version of @code{gcc},
  500. @uref{http://reality.sgi.com/knobi/gcc-2.7.2.x-on-irix-6.2-6.3}.
  501.  
  502. @node Cross-compiler Problems
  503. @subsection Cross-compiler Problems
  504. @cindex cross-compiler, problems
  505.  
  506. @code{g77} has been in alpha testing since September of
  507. 1992, and in public beta testing since February of 1995.
  508. Alpha testing was done by a small number of people worldwide on a fairly
  509. wide variety of machines, involving self-compilation in most or
  510. all cases.
  511. Beta testing has been done primarily via self-compilation,
  512. but in more and more cases, cross-compilation (and ``criss-cross
  513. compilation'', where a version of a compiler is built on one machine
  514. to run on a second and generate code that runs on a third) has
  515. been tried and has succeeded, to varying extents.
  516.  
  517. Generally, @code{g77} can be ported to any configuration to which
  518. @code{gcc}, @code{f2c}, and @code{libf2c} can be ported and made
  519. to work together, aside from the known problems described in this
  520. manual.
  521. If you want to port @code{g77} to a particular configuration,
  522. you should first make sure @code{gcc} and @code{libf2c} can be
  523. ported to that configuration before focusing on @code{g77}, because
  524. @code{g77} is so dependent on them.
  525.  
  526. Even for cases where @code{gcc} and @code{libf2c} work,
  527. you might run into problems with cross-compilation on certain machines,
  528. for several reasons.
  529.  
  530. @itemize @bullet
  531. @item
  532. There is one known bug
  533. (a design bug to be fixed in 0.6) that prevents configuration of
  534. @code{g77} as a cross-compiler in some cases,
  535. though there are assumptions made during
  536. configuration that probably make doing non-self-hosting builds
  537. a hassle, requiring manual intervention.
  538.  
  539. @item
  540. @code{gcc} might still have some trouble being configured
  541. for certain combinations of machines.
  542. For example, it might not know how to handle floating-point
  543. constants.
  544.  
  545. @item
  546. Improvements to the way @code{libf2c} is built could make
  547. building @code{g77} as a cross-compiler easier---for example,
  548. passing and using @samp{$(LD)} and @samp{$(AR)} in the appropriate
  549. ways.
  550.  
  551. @item
  552. There are still some challenges putting together the right
  553. run-time libraries (needed by @code{libf2c}) for a target
  554. system, depending on the systems involved in the configuration.
  555. (This is a general problem with cross-compilation, and with
  556. @code{gcc} in particular.)
  557. @end itemize
  558.  
  559. @node Settings
  560. @section Changing Settings Before Building
  561.  
  562. Here are some internal @code{g77} settings that can be changed
  563. by editing source files in @file{gcc/f/} before building.
  564.  
  565. This information, and perhaps even these settings, represent
  566. stop-gap solutions to problems people doing various ports
  567. of @code{g77} have encountered.
  568. As such, none of the following information is expected to
  569. be pertinent in future versions of @code{g77}.
  570.  
  571. @menu
  572. * Larger File Unit Numbers::     Raising @samp{MXUNIT}.
  573. * Always Flush Output::          Synchronizing write errors.
  574. * Maximum Stackable Size::       Large arrays forced off the stack.
  575. * Floating-point Bit Patterns::  Possible programs building @code{g77}
  576.                                    as a cross-compiler.
  577. * Large Initialization::         Large arrays with @code{DATA}
  578.                                    initialization.
  579. * Alpha Problems Fixed::         Problems with 64-bit systems like
  580.                                    Alphas now fixed?
  581. @end menu
  582.  
  583. @node Larger File Unit Numbers
  584. @subsection Larger File Unit Numbers
  585. @cindex MXUNIT
  586. @cindex unit numbers
  587. @cindex maximum unit number
  588. @cindex illegal unit number
  589. @cindex increasing maximum unit number
  590.  
  591. As distributed, whether as part of @code{f2c} or @code{g77},
  592. @code{libf2c} accepts file unit numbers only in the range
  593. 0 through 99.
  594. For example, a statement such as @samp{WRITE (UNIT=100)} causes
  595. a run-time crash in @code{libf2c}, because the unit number,
  596. 100, is out of range.
  597.  
  598. If you know that Fortran programs at your installation require
  599. the use of unit numbers higher than 99, you can change the
  600. value of the @samp{MXUNIT} macro, which represents the maximum unit
  601. number, to an appropriately higher value.
  602.  
  603. To do this, edit the file @file{f/runtime/libI77/fio.h} in your
  604. @code{g77} source tree, changing the following line:
  605.  
  606. @example
  607. #define MXUNIT 100
  608. @end example
  609.  
  610. Change the line so that the value of @samp{MXUNIT} is defined to be
  611. at least one @emph{greater} than the maximum unit number used by
  612. the Fortran programs on your system.
  613.  
  614. (For example, a program that does @samp{WRITE (UNIT=255)} would require
  615. @samp{MXUNIT} set to at least 256 to avoid crashing.)
  616.  
  617. Then build or rebuild @code{g77} as appropriate.
  618.  
  619. @emph{Note:} Changing this macro has @emph{no} effect on other limits
  620. your system might place on the number of files open at the same time.
  621. That is, the macro might allow a program to do @samp{WRITE (UNIT=100)},
  622. but the library and operating system underlying @code{libf2c} might
  623. disallow it if many other files have already been opened (via @code{OPEN} or
  624. implicitly via @code{READ}, @code{WRITE}, and so on).
  625. Information on how to increase these other limits should be found
  626. in your system's documentation.
  627.  
  628. @node Always Flush Output
  629. @subsection Always Flush Output
  630. @cindex ALWAYS_FLUSH
  631. @cindex synchronous write errors
  632. @cindex disk full
  633. @cindex flushing output
  634. @cindex fflush()
  635. @cindex I/O, flushing
  636. @cindex output, flushing
  637. @cindex writes, flushing
  638. @cindex NFS
  639. @cindex network file system
  640.  
  641. Some Fortran programs require output
  642. (writes) to be flushed to the operating system (under UNIX,
  643. via the @code{fflush()} library call) so that errors,
  644. such as disk full, are immediately flagged via the relevant
  645. @code{ERR=} and @code{IOSTAT=} mechanism, instead of such
  646. errors being flagged later as subsequent writes occur, forcing
  647. the previously written data to disk, or when the file is
  648. closed.
  649.  
  650. Essentially, the difference can be viewed as synchronous error
  651. reporting (immediate flagging of errors during writes) versus
  652. asynchronous, or, more precisely, buffered error reporting
  653. (detection of errors might be delayed).
  654.  
  655. @code{libf2c} supports flagging write errors immediately when
  656. it is built with the @samp{ALWAYS_FLUSH} macro defined.
  657. This results in a @code{libf2c} that runs slower, sometimes
  658. quite a bit slower, under certain circumstances---for example,
  659. accessing files via the networked file system NFS---but the
  660. effect can be more reliable, robust file I/O.
  661.  
  662. If you know that Fortran programs requiring this level of precision
  663. of error reporting are to be compiled using the
  664. version of @code{g77} you are building, you might wish to
  665. modify the @code{g77} source tree so that the version of
  666. @code{libf2c} is built with the @samp{ALWAYS_FLUSH} macro
  667. defined, enabling this behavior.
  668.  
  669. To do this, find this line in @file{f/runtime/configure.in} in
  670. your @code{g77} source tree:
  671.  
  672. @example
  673. dnl AC_DEFINE(ALWAYS_FLUSH)
  674. @end example
  675.  
  676. Remove the leading @samp{dnl@w{ }}, so the line begins with
  677. @samp{AC_DEFINE(}, and run @code{autoconf} in that file's directory.
  678. (Or, if you don't have @code{autoconf}, you can modify @file{f2c.h.in}
  679. in the same directory to include the line @samp{#define ALWAYS_FLUSH}
  680. after @samp{#define F2C_INCLUDE}.)
  681.  
  682. Then build or rebuild @code{g77} as appropriate.
  683.  
  684. @node Maximum Stackable Size
  685. @subsection Maximum Stackable Size
  686. @vindex FFECOM_sizeMAXSTACKITEM
  687. @cindex code, stack variables
  688. @cindex maximum stackable size
  689. @cindex stack allocation
  690. @cindex segmentation violation
  691. @code{g77}, on most machines, puts many variables and arrays on the stack
  692. where possible, and can be configured (by changing
  693. @samp{FFECOM_sizeMAXSTACKITEM} in @file{gcc/f/com.c}) to force
  694. smaller-sized entities into static storage (saving
  695. on stack space) or permit larger-sized entities to be put on the
  696. stack (which can improve run-time performance, as it presents
  697. more opportunities for the GBE to optimize the generated code).
  698.  
  699. @emph{Note:} Putting more variables and arrays on the stack
  700. might cause problems due to system-dependent limits on stack size.
  701. Also, the value of @samp{FFECOM_sizeMAXSTACKITEM} has no
  702. effect on automatic variables and arrays.
  703. @xref{But-bugs}, for more information.
  704.  
  705. @node Floating-point Bit Patterns
  706. @subsection Floating-point Bit Patterns
  707.  
  708. @cindex cross-compiler, building
  709. @cindex floating-point bit patterns
  710. @cindex bit patterns
  711. The @code{g77} build will crash if an attempt is made to build
  712. it as a cross-compiler
  713. for a target when @code{g77} cannot reliably determine the bit pattern of
  714. floating-point constants for the target.
  715. Planned improvements for version 0.6 of @code{g77}
  716. will give it the capabilities it needs to not have to crash the build
  717. but rather generate correct code for the target.
  718. (Currently, @code{g77}
  719. would generate bad code under such circumstances if it didn't crash
  720. during the build, e.g. when compiling a source file that does
  721. something like @samp{EQUIVALENCE (I,R)} and @samp{DATA R/9.43578/}.)
  722.  
  723. @node Large Initialization
  724. @subsection Initialization of Large Aggregate Areas
  725.  
  726. @cindex speed, compiler
  727. @cindex slow compiler
  728. @cindex memory utilization
  729. @cindex large initialization
  730. @cindex aggregate initialization
  731. A warning message is issued when @code{g77} sees code that provides
  732. initial values (e.g. via @code{DATA}) to an aggregate area (@code{COMMON}
  733. or @code{EQUIVALENCE}, or even a large enough array or @code{CHARACTER}
  734. variable)
  735. that is large enough to increase @code{g77}'s compile time by roughly
  736. a factor of 10.
  737.  
  738. This size currently is quite small, since @code{g77}
  739. currently has a known bug requiring too much memory
  740. and time to handle such cases.
  741. In @file{gcc/f/data.c}, the macro
  742. @samp{FFEDATA_sizeTOO_BIG_INIT_} is defined
  743. to the minimum size for the warning to appear.
  744. The size is specified in storage units,
  745. which can be bytes, words, or whatever, on a case-by-case basis.
  746.  
  747. After changing this macro definition, you must
  748. (of course) rebuild and reinstall @code{g77} for
  749. the change to take effect.
  750.  
  751. Note that, as of version 0.5.18, improvements have
  752. reduced the scope of the problem for @emph{sparse}
  753. initialization of large arrays, especially those
  754. with large, contiguous uninitialized areas.
  755. However, the warning is issued at a point prior to
  756. when @code{g77} knows whether the initialization is sparse,
  757. and delaying the warning could mean it is produced
  758. too late to be helpful.
  759.  
  760. Therefore, the macro definition should not be adjusted to
  761. reflect sparse cases.
  762. Instead, adjust it to generate the warning when densely
  763. initialized arrays begin to cause responses noticeably slower
  764. than linear performance would suggest.
  765.  
  766. @node Alpha Problems Fixed
  767. @subsection Alpha Problems Fixed
  768.  
  769. @cindex Alpha, support
  770. @cindex 64-bit systems
  771. @code{g77} used to warn when it was used to compile Fortran code
  772. for a target configuration that is not basically a 32-bit
  773. machine (such as an Alpha, which is a 64-bit machine, especially
  774. if it has a 64-bit operating system running on it).
  775. That was because @code{g77} was known to not work
  776. properly on such configurations.
  777.  
  778. As of version 0.5.20, @code{g77} is believed to work well
  779. enough on such systems.
  780. So, the warning is no longer needed or provided.
  781.  
  782. However, support for 64-bit systems, especially in
  783. areas such as cross-compilation and handling of
  784. intrinsics, is still incomplete.
  785. The symptoms
  786. are believed to be compile-time diagnostics rather
  787. than the generation of bad code.
  788. It is hoped that version 0.6 will completely support 64-bit
  789. systems.
  790.  
  791. @node Quick Start
  792. @section Quick Start
  793. @cindex quick start
  794.  
  795. This procedure configures, builds, and installs @code{g77}
  796. ``out of the box'' and works on most UNIX systems.
  797. Each command is identified by a unique number,
  798. used in the explanatory text that follows.
  799. For the most part, the output of each command is not shown,
  800. though indications of the types of responses are given in a
  801. few cases.
  802.  
  803. To perform this procedure, the installer must be logged
  804. in as user @code{root}.
  805. Much of it can be done while not logged in as @code{root},
  806. and users experienced with UNIX administration should be
  807. able to modify the procedure properly to do so.
  808.  
  809. Following traditional UNIX conventions, it is assumed that
  810. the source trees for @code{g77} and @code{gcc} will be
  811. placed in @file{/usr/src}.
  812. It also is assumed that the source distributions themselves
  813. already reside in @file{/usr/FSF}, a naming convention
  814. used by the author of @code{g77} on his own system:
  815.  
  816. @example
  817. /usr/FSF/gcc-@value{version-gcc}.tar.gz
  818. /usr/FSF/g77-@value{version-g77}.tar.gz
  819. @end example
  820.  
  821. @c (You can use @file{gcc-2.7.2.1.tar.gz} instead, or
  822. @c the equivalent of it obtained by applying the
  823. @c patch distributed as @file{gcc-2.7.2-2.7.2.1.diff.gz}
  824. @c to version 2.7.2 of @code{gcc},
  825. @c if you remember to make the appropriate adjustments in the
  826. @c instructions below.)
  827.  
  828. @cindex SunOS4
  829. Users of the following systems should not blindly follow
  830. these quick-start instructions, because of problems their
  831. systems have coping with straightforward installation of
  832. @code{g77}:
  833.  
  834. @itemize @bullet
  835. @item
  836. SunOS4
  837. @end itemize
  838.  
  839. Instead, see @ref{Complete Installation}, for detailed information
  840. on how to configure, build, and install @code{g77} for your
  841. particular system.
  842. Also, see @ref{Trouble,,Known Causes of Trouble with GNU Fortran},
  843. for information on bugs and other problems known to afflict the
  844. installation process, and how to report newly discovered ones.
  845.  
  846. If your system is @emph{not} on the above list, and @emph{is}
  847. a UNIX system or one of its variants, you should be able to
  848. follow the instructions below.
  849. If you vary @emph{any} of the steps below, you might run into
  850. trouble, including possibly breaking existing programs for
  851. other users of your system.
  852. Before doing so, it is wise to review the explanations of some
  853. of the steps.
  854. These explanations follow this list of steps.
  855.  
  856. @example
  857. sh[ 1]# @kbd{cd /usr/src}
  858. @set source-dir 1
  859. sh[ 2]# @kbd{gunzip -c < /usr/FSF/gcc-@value{version-gcc}.tar.gz | tar xf -}
  860. [Might say "Broken pipe"...that is normal on some systems.]
  861. @set unpack-gcc 2
  862. sh[ 3]# @kbd{gunzip -c < /usr/FSF/g77-@value{version-g77}.tar.gz | tar xf -}
  863. ["Broken pipe" again possible.]
  864. @set unpack-g77 3
  865. sh[ 4]# @kbd{ln -s gcc-@value{version-gcc} gcc}
  866. @set link-gcc 4
  867. sh[ 5]# @kbd{ln -s g77-@value{version-g77} g77}
  868. @set link-g77 5
  869. sh[ 6]# @kbd{mv -i g77/* gcc}
  870. [No questions should be asked by mv here; or, you made a mistake.]
  871. @set merge-g77 6
  872. sh[ 7]# @kbd{patch -p1 -E -V t -d gcc < gcc/f/gbe/@value{version-gcc}.diff}
  873. [Unless patch complains about rejected patches, this step worked.]
  874. @set apply-patch 7
  875. sh[ 8]# @kbd{cd gcc}
  876. sh[ 9]# @kbd{touch f77-install-ok}
  877. [Do not do the above if your system already has an f77
  878. command, unless you've checked that overwriting it
  879. is okay.]
  880. @set f77-install-ok 9
  881. sh[10]# @kbd{touch f2c-install-ok}
  882. [Do not do the above if your system already has an f2c
  883. command, unless you've checked that overwriting it
  884. is okay.  Else, @kbd{touch f2c-exists-ok}.]
  885. @set f2c-install-ok 10
  886. sh[11]# @kbd{./configure --prefix=/usr}
  887. [Do not do the above if gcc is not installed in /usr/bin.
  888. You might need a different @kbd{--prefix=@dots{}}, as
  889. described below.]
  890. @set configure-gcc 11
  891. sh[12]# @kbd{make bootstrap}
  892. [This takes a long time, and is where most problems occur.]
  893. @set build-gcc 12
  894. sh[13]# @kbd{make compare}
  895. [This verifies that the compiler is `sane'.  Only
  896. the file `f/zzz.o' (aka `tmp-foo1' and `tmp-foo2')
  897. should be in the list of object files this command
  898. prints as having different contents.  If other files
  899. are printed, you have likely found a g77 bug.]
  900. @set compare-gcc 13
  901. sh[14]# @kbd{rm -fr stage1}
  902. @set rm-stage1 14
  903. sh[15]# @kbd{make -k install}
  904. [The actual installation.]
  905. @set install-g77 15
  906. sh[16]# @kbd{g77 -v}
  907. [Verify that g77 is installed, obtain version info.]
  908. @set show-version 16
  909. sh[17]#
  910. @set end-procedure 17
  911. @end example
  912.  
  913. @xref{Updating Documentation,,Updating Your Info Directory}, for
  914. information on how to update your system's top-level @code{info}
  915. directory to contain a reference to this manual, so that
  916. users of @code{g77} can easily find documentation instead
  917. of having to ask you for it.
  918.  
  919. Elaborations of many of the above steps follows:
  920.  
  921. @table @asis
  922. @item Step @value{source-dir}: @kbd{cd /usr/src}
  923. You can build @code{g77} pretty much anyplace.
  924. By convention, this manual assumes @file{/usr/src}.
  925. It might be helpful if other users on your system
  926. knew where to look for the source code for the
  927. installed version of @code{g77} and @code{gcc} in any case.
  928.  
  929. @c @item Step @value{unpack-gcc}: @kbd{gunzip -d @dots{}}
  930. @c Here, you might wish to use @file{gcc-2.7.2.1.tar.gz}
  931. @c instead, or apply @file{gcc-2.7.2-2.7.2.1.diff.gz} to achieve
  932. @c similar results.
  933.  
  934. @item Step @value{unpack-g77}: @kbd{gunzip -d < /usr/FSF/g77-@value{version-g77}.tar.gz | tar xf -}
  935. It is not always necessary to obtain the latest version of
  936. @code{g77} as a complete @file{.tar.gz} file if you have
  937. a complete, earlier distribution of @code{g77}.
  938. If appropriate, you can unpack that earlier
  939. version of @code{g77}, and then apply the appropriate patches
  940. to achieve the same result---a source tree containing version
  941. @value{version-g77} of @code{g77}.
  942.  
  943. @item Step @value{link-gcc}: @kbd{ln -s gcc-@value{version-gcc} gcc}
  944. @item Step @value{link-g77}: @kbd{ln -s g77-@value{version-g77} g77}
  945. These commands mainly help reduce typing,
  946. and help reduce visual clutter in examples
  947. in this manual showing what to type to install @code{g77}.
  948.  
  949. @c Of course, if appropriate, @kbd{ln -s gcc-2.7.2.1 gcc} or
  950. @c similar.
  951.  
  952. @xref{Unpacking}, for information on
  953. using distributions of @code{g77} made by organizations
  954. other than the FSF.
  955.  
  956. @item Step @value{merge-g77}: @kbd{mv -i g77/* gcc}
  957. After doing this, you can, if you like, type
  958. @samp{rm g77} and @samp{rmdir g77-@value{version-g77}} to remove
  959. the empty directory and the symbol link to it.
  960. But, it might be helpful to leave them around as
  961. quick reminders of which version(s) of @code{g77} are
  962. installed on your system.
  963.  
  964. @xref{Unpacking}, for information
  965. on the contents of the @file{g77} directory (as merged
  966. into the @file{gcc} directory).
  967.  
  968. @item Step @value{apply-patch}: @kbd{patch -p1 @dots{}}
  969. @c (Or `@kbd{@dots{} < gcc/f/gbe/2.7.2.1.diff}', if appropriate.)
  970. @c
  971. If you are using
  972. GNU @code{patch} version @value{version-patch} or later,
  973. this should produce a list of files patched.
  974. (Other versions of @code{patch} might not work
  975. properly.)
  976.  
  977. If messages about ``fuzz'', ``offset'', or
  978. especially ``reject files'' are printed, it might
  979. mean you applied the wrong patch file.
  980. If you believe this is the case, it is best to restart
  981. the sequence after deleting (or at least renaming to unused
  982. names) the top-level directories for @code{g77} and @code{gcc}
  983. and their symbolic links.
  984.  
  985. After this command finishes, the @code{gcc} directory might
  986. have old versions of several files as saved by @code{patch}.
  987. To remove these, after @kbd{cd gcc}, type @kbd{rm -i *.~*~}.
  988.  
  989. @xref{Merging Distributions}, for more information.
  990.  
  991. @emph{Note:} @code{gcc} versions circa 2.7.2.2 and 2.7.2.3
  992. are known to have slightly differing versions of the
  993. @code{gcc/ChangeLog} file,
  994. depending on how they are obtained.
  995. You can safely ignore diagnostics @code{patch} reports
  996. when patching this particular file,
  997. since it is purely a documentation file for implementors.
  998. See @file{gcc/f/gbe/2.7.2.3.diff} for more information.
  999.  
  1000. @item Step @value{f77-install-ok}: @kbd{touch f77-install-ok}
  1001. Don't do this if you don't want to overwrite an existing
  1002. version of @code{f77} (such as a native compiler, or a
  1003. script that invokes @code{f2c}).
  1004. Otherwise, installation will overwrite the @code{f77} command
  1005. and the @code{f77} man pages with copies of the corresponding
  1006. @code{g77} material.
  1007.  
  1008. @xref{Installing f77,,Installing @code{f77}}, for more
  1009. information.
  1010.  
  1011. @item Step @value{f2c-install-ok}: @kbd{touch f2c-install-ok}
  1012. Don't do this if you don't want to overwrite an existing
  1013. installation of @code{libf2c} (though, chances are, you do).
  1014. Instead, @kbd{touch f2c-exists-ok} to allow the installation
  1015. to continue without any error messages about @file{/usr/lib/libf2c.a}
  1016. already existing.
  1017.  
  1018. @xref{Installing f2c,,Installing @code{f2c}}, for more
  1019. information.
  1020.  
  1021. @item Step @value{configure-gcc}: @kbd{./configure --prefix=/usr}
  1022. This is where you specify that the @file{g77} executable is to be
  1023. installed in @file{/usr/bin/}, the @file{libf2c.a} library is
  1024. to be installed in @file{/usr/lib/}, and so on.
  1025.  
  1026. You should ensure that any existing installation of the @file{gcc}
  1027. executable is in @file{/usr/bin/}.
  1028. Otherwise, installing @code{g77} so that it does not fully
  1029. replace the existing installation of @code{gcc} is likely
  1030. to result in the inability to compile Fortran programs.
  1031.  
  1032. @xref{Where to Install,,Where in the World Does Fortran (and GNU CC) Go?},
  1033. for more information on determining where to install @code{g77}.
  1034. @xref{Configuring gcc}, for more information on the
  1035. configuration process triggered by invoking the @file{./configure}
  1036. script.
  1037.  
  1038. @item Step @value{build-gcc}: @kbd{make bootstrap}
  1039. @xref{Installation,,Installing GNU CC,
  1040. gcc,Using and Porting GNU CC}, for information
  1041. on the kinds of diagnostics you should expect during
  1042. this procedure.
  1043.  
  1044. @xref{Building gcc}, for complete @code{g77}-specific
  1045. information on this step.
  1046.  
  1047. @item Step @value{compare-gcc}: @kbd{make compare}
  1048. @xref{Bug Lists,,Where to Port Bugs}, for information
  1049. on where to report that you observed more than
  1050. @file{f/zzz.o} having different contents during this
  1051. phase.
  1052.  
  1053. @xref{Bug Reporting,,How to Report Bugs}, for
  1054. information on @emph{how} to report bugs like this.
  1055.  
  1056. @item Step @value{rm-stage1}: @kbd{rm -fr stage1}
  1057. You don't need to do this, but it frees up disk space.
  1058.  
  1059. @item Step @value{install-g77}: @kbd{make -k install}
  1060. If this doesn't seem to work, try:
  1061.  
  1062. @example
  1063. make -k install install-libf77 install-f2c-all
  1064. @end example
  1065.  
  1066. @xref{Installation of Binaries}, for more information.
  1067.  
  1068. @xref{Updating Documentation,,Updating Your Info Directory},
  1069. for information on entering this manual into your
  1070. system's list of texinfo manuals.
  1071.  
  1072. @item Step @value{show-version}: @kbd{g77 -v}
  1073. If this command prints approximately 25 lines of output,
  1074. including the GNU Fortran Front End version number (which
  1075. should be the same as the version number for the version
  1076. of @code{g77} you just built and installed) and the
  1077. version numbers for the three parts of the @code{libf2c}
  1078. library (@code{libF77}, @code{libI77}, @code{libU77}), and
  1079. those version numbers are all in agreement, then there is
  1080. a high likelihood that the installation has been successfully
  1081. completed.
  1082.  
  1083. You might consider doing further testing.
  1084. For example, log in as a non-privileged user, then create
  1085. a small Fortran program, such as:
  1086.  
  1087. @example
  1088.       PROGRAM SMTEST
  1089.       DO 10 I=1, 10
  1090.          PRINT *, 'Hello World #', I
  1091. 10    CONTINUE
  1092.       END
  1093. @end example
  1094.  
  1095. Compile, link, and run the above program, and, assuming you named
  1096. the source file @file{smtest.f}, the session should look like this:
  1097.  
  1098. @example
  1099. sh# @kbd{g77 -o smtest smtest.f}
  1100. sh# @kbd{./smtest}
  1101.  Hello World # 1
  1102.  Hello World # 2
  1103.  Hello World # 3
  1104.  Hello World # 4
  1105.  Hello World # 5
  1106.  Hello World # 6
  1107.  Hello World # 7
  1108.  Hello World # 8
  1109.  Hello World # 9
  1110.  Hello World # 10
  1111. sh#
  1112. @end example
  1113.  
  1114. After proper installation, you don't
  1115. need to keep your gcc and g77 source and build directories
  1116. around anymore.
  1117. Removing them can free up a lot of disk space.
  1118. @end table
  1119.  
  1120. @node Complete Installation
  1121. @section Complete Installation
  1122.  
  1123. Here is the complete @code{g77}-specific information on how
  1124. to configure, build, and install @code{g77}.
  1125.  
  1126. @menu
  1127. * Unpacking::
  1128. * Merging Distributions::
  1129. * f77: Installing f77.
  1130. * f2c: Installing f2c.
  1131. * Patching GNU Fortran::
  1132. * Where to Install::
  1133. * Configuring gcc::
  1134. * Building gcc::
  1135. * Pre-installation Checks::
  1136. * Installation of Binaries::
  1137. * Updating Documentation::
  1138. * bison: Missing bison?.
  1139. * makeinfo: Missing makeinfo?.
  1140. @end menu
  1141.  
  1142. @node Unpacking
  1143. @subsection Unpacking
  1144. @cindex unpacking distributions
  1145. @cindex distributions, unpacking
  1146. @cindex code, source
  1147. @cindex source code
  1148. @cindex source tree
  1149. @cindex packages
  1150.  
  1151. The @code{gcc} source distribution is a stand-alone distribution.
  1152. It is designed to be unpacked (producing the @code{gcc}
  1153. source tree) and built as is, assuming certain
  1154. prerequisites are met (including the availability of compatible
  1155. UNIX programs such as @code{make}, @code{cc}, and so on).
  1156.  
  1157. However, before building @code{gcc}, you will want to unpack
  1158. and merge the @code{g77} distribution in with it, so that you
  1159. build a Fortran-capable version of @code{gcc}, which includes
  1160. the @code{g77} command, the necessary run-time libraries,
  1161. and this manual.
  1162.  
  1163. Unlike @code{gcc}, the @code{g77} source distribution
  1164. is @emph{not} a stand-alone distribution.
  1165. It is designed to be unpacked and, afterwards, immediately merged
  1166. into an applicable @code{gcc} source tree.
  1167. That is, the @code{g77} distribution @emph{augments} a
  1168. @code{gcc} distribution---without @code{gcc}, generally
  1169. only the documentation is immediately usable.
  1170.  
  1171. A sequence of commands typically used to unpack @code{gcc}
  1172. and @code{g77} is:
  1173.  
  1174. @example
  1175. sh# @kbd{cd /usr/src}
  1176. sh# @kbd{gunzip -c /usr/FSF/gcc-@value{version-gcc}.tar.gz | tar xf -}
  1177. sh# @kbd{gunzip -c /usr/FSF/g77-@value{version-g77}.tar.gz | tar xf -}
  1178. sh# @kbd{ln -s gcc-@value{version-gcc} gcc}
  1179. sh# @kbd{ln -s g77-@value{version-g77} g77}
  1180. sh# @kbd{mv -i g77/* gcc}
  1181. @end example
  1182.  
  1183. @emph{Notes:} The commands beginning with @samp{gunzip@dots{}} might
  1184. print @samp{Broken pipe@dots{}} as they complete.
  1185. That is nothing to worry about, unless you actually
  1186. @emph{hear} a pipe breaking.
  1187. The @code{ln} commands are helpful in reducing typing
  1188. and clutter in installation examples in this manual.
  1189. Hereafter, the top level of @code{gcc} source tree is referred to
  1190. as @file{gcc}, and the top level of just the @code{g77}
  1191. source tree (prior to issuing the @code{mv} command, above)
  1192. is referred to as @file{g77}.
  1193.  
  1194. There are three top-level names in a @code{g77} distribution:
  1195.  
  1196. @example
  1197. g77/COPYING.g77
  1198. g77/README.g77
  1199. g77/f
  1200. @end example
  1201.  
  1202. All three entries should be moved (or copied) into a @code{gcc}
  1203. source tree (typically named after its version number and
  1204. as it appears in the FSF distributions---e.g. @file{gcc-@value{version-gcc}}).
  1205.  
  1206. @file{g77/f} is the subdirectory containing all of the
  1207. code, documentation, and other information that is specific
  1208. to @code{g77}.
  1209. The other two files exist to provide information on @code{g77}
  1210. to someone encountering a @code{gcc} source tree with @code{g77}
  1211. already present, who has not yet read these installation
  1212. instructions and thus needs help understanding that the
  1213. source tree they are looking at does not come from a single
  1214. FSF distribution.
  1215. They also help people encountering an unmerged @code{g77} source
  1216. tree for the first time.
  1217.  
  1218. @cindex modifying @code{g77}
  1219. @cindex code, modifying
  1220. @cindex Pentium optimizations
  1221. @cindex optimizations, Pentium
  1222. @emph{Note:} Please use @strong{only} @code{gcc} and @code{g77}
  1223. source trees as distributed by the FSF.
  1224. Use of modified versions, such as the Pentium-specific-optimization
  1225. port of @code{gcc}, is likely to result in problems that appear to be
  1226. in the @code{g77} code but, in fact, are not.
  1227. Do not use such modified versions
  1228. unless you understand all the differences between them and the versions
  1229. the FSF distributes---in which case you should be able to modify the
  1230. @code{g77} (or @code{gcc}) source trees appropriately so @code{g77}
  1231. and @code{gcc} can coexist as they do in the stock FSF distributions.
  1232.  
  1233. @node Merging Distributions
  1234. @subsection Merging Distributions
  1235. @cindex merging distributions
  1236. @cindex @code{gcc} versions supported by @code{g77}
  1237. @cindex versions of @code{gcc}
  1238. @cindex support for @code{gcc} versions
  1239.  
  1240. After merging the @code{g77} source tree into the @code{gcc}
  1241. source tree, the final merge step is done by applying the
  1242. pertinent patches the @code{g77} distribution provides for
  1243. the @code{gcc} source tree.
  1244.  
  1245. Read the file @file{gcc/f/gbe/README}, and apply the appropriate
  1246. patch file for the version of the GNU CC compiler you have, if
  1247. that exists.
  1248. If the directory exists but the appropriate file
  1249. does not exist, you are using either an old, unsupported version,
  1250. or a release one that is newer than the newest @code{gcc} version
  1251. supported by the version of @code{g77} you have.
  1252.  
  1253. @cindex gcc version numbering
  1254. @cindex version numbering
  1255. @cindex g77 version number
  1256. @cindex GNU version numbering
  1257. As of version 0.5.18, @code{g77} modifies the version number
  1258. of @code{gcc} via the pertinent patches.
  1259. This is done because the resulting version of @code{gcc} is
  1260. deemed sufficiently different from the vanilla distribution
  1261. to make it worthwhile to present, to the user, information
  1262. signaling the fact that there are some differences.
  1263.  
  1264. GNU version numbers make it easy to figure out whether a
  1265. particular version of a distribution is newer or older than
  1266. some other version of that distribution.
  1267. The format is,
  1268. generally, @var{major}.@var{minor}.@var{patch}, with
  1269. each field being a decimal number.
  1270. (You can safely ignore
  1271. leading zeros; for example, 1.5.3 is the same as 1.5.03.)@ 
  1272. The @var{major} field only increases with time.
  1273. The other two fields are reset to 0 when the field to
  1274. their left is incremented; otherwise, they, too, only
  1275. increase with time.
  1276. So, version 2.6.2 is newer than version 2.5.8, and
  1277. version 3.0 is newer than both.
  1278. (Trailing @samp{.0} fields often are omitted in
  1279. announcements and in names for distributions and
  1280. the directories they create.)
  1281.  
  1282. If your version of @code{gcc} is older than the oldest version
  1283. supported by @code{g77} (as casually determined by listing
  1284. the contents of @file{gcc/f/gbe/}), you should obtain a newer,
  1285. supported version of @code{gcc}.
  1286. (You could instead obtain an older version of @code{g77},
  1287. or try and get your @code{g77} to work with the old
  1288. @code{gcc}, but neither approach is recommended, and
  1289. you shouldn't bother reporting any bugs you find if you
  1290. take either approach, because they're probably already
  1291. fixed in the newer versions you're not using.)
  1292.  
  1293. If your version of @code{gcc} is newer than the newest version
  1294. supported by @code{g77}, it is possible that your @code{g77}
  1295. will work with it anyway.
  1296. If the version number for @code{gcc} differs only in the
  1297. @var{patch} field, you might as well try applying the @code{g77} patch
  1298. that is for the newest version of @code{gcc} having the same
  1299. @var{major} and @var{minor} fields, as this is likely to work.
  1300.  
  1301. So, for example, if a particular version of @code{g77} has support for
  1302. @code{gcc} versions 2.7.0 and 2.7.1,
  1303. it is likely that @file{gcc-2.7.2} would work well with @code{g77}
  1304. by using the @file{2.7.1.diff} patch file provided
  1305. with @code{g77} (aside from some offsets reported by @code{patch},
  1306. which usually are harmless).
  1307.  
  1308. However, @file{gcc-2.8.0} would almost certainly
  1309. not work with that version of @code{g77} no matter which patch file was
  1310. used, so a new version of @code{g77} would be needed (and you should
  1311. wait for it rather than bothering the maintainers---@pxref{Changes,,
  1312. User-Visible Changes}).
  1313.  
  1314. @cindex distributions, why separate
  1315. @cindex separate distributions
  1316. @cindex why separate distributions
  1317. This complexity is the result of @code{gcc} and @code{g77} being
  1318. separate distributions.
  1319. By keeping them separate, each product is able to be independently
  1320. improved and distributed to its user base more frequently.
  1321.  
  1322. However, @code{g77} often requires changes to contemporary
  1323. versions of @code{gcc}.
  1324. Also, the GBE interface defined by @code{gcc} typically
  1325. undergoes some incompatible changes at least every time the
  1326. @var{minor} field of the version number is incremented,
  1327. and such changes require corresponding changes to
  1328. the @code{g77} front end (FFE).
  1329.  
  1330. It is hoped that the GBE interface, and the @code{gcc} and
  1331. @code{g77} products in general, will stabilize sufficiently
  1332. for the need for hand-patching to disappear.
  1333.  
  1334. If you are using
  1335. GNU @code{patch} version @value{version-patch} or later,
  1336. this should produce a list of files patched.
  1337. (Other versions of @code{patch} might not work
  1338. properly.)
  1339.  
  1340. If messages about ``fuzz'', ``offset'', or
  1341. especially ``reject files'' are printed, it might
  1342. mean you applied the wrong patch file.
  1343. If you believe this is the case, it is best to restart
  1344. the sequence after deleting (or at least renaming to unused
  1345. names) the top-level directories for @code{g77} and @code{gcc}
  1346. and their symbolic links.
  1347. That is because @code{patch} might have partially patched
  1348. some @code{gcc} source files, so reapplying the correct
  1349. patch file might result in the correct patches being
  1350. applied incorrectly (due to the way @code{patch} necessarily
  1351. works).
  1352.  
  1353. After @code{patch} finishes, the @code{gcc} directory might
  1354. have old versions of several files as saved by @code{patch}.
  1355. To remove these, after @kbd{cd gcc}, type @kbd{rm -i *.~*~}.
  1356.  
  1357. @emph{Note:} @code{gcc} versions circa 2.7.2.2 and 2.7.2.3
  1358. are known to have slightly differing versions of the
  1359. @code{gcc/ChangeLog} file,
  1360. depending on how they are obtained.
  1361. You can safely ignore diagnostics @code{patch} reports
  1362. when patching this particular file,
  1363. since it is purely a documentation file for implementors.
  1364. See @file{gcc/f/gbe/2.7.2.3.diff} for more information.
  1365.  
  1366. @pindex config-lang.in
  1367. @emph{Note:} @code{g77}'s configuration file @file{gcc/f/config-lang.in}
  1368. ensures that the source code for the version of @code{gcc}
  1369. being configured has at least one indication of being patched
  1370. as required specifically by @code{g77}.
  1371. This configuration-time
  1372. checking should catch failure to apply the correct patch and,
  1373. if so caught, should abort the configuration with an explanation.
  1374. @emph{Please} do not try to disable the check,
  1375. otherwise @code{g77} might well appear to build
  1376. and install correctly, and even appear to compile correctly,
  1377. but could easily produce broken code.
  1378.  
  1379. @cindex creating patch files
  1380. @cindex patch files, creating
  1381. @pindex gcc/f/gbe/
  1382. @samp{LC_ALL=C TZ=UTC0 diff -rcp2N} is used to create the patch files
  1383. in @file{gcc/f/gbe/}.
  1384.  
  1385. @node Installing f77
  1386. @subsection Installing @code{f77}
  1387. @cindex f77 command
  1388. @cindex commands, f77
  1389. @cindex native compiler
  1390.  
  1391. You should decide whether you want installation of @code{g77}
  1392. to also install an @code{f77} command.
  1393. On systems with a native @code{f77}, this is not
  1394. normally desired, so @code{g77} does not do this by
  1395. default.
  1396.  
  1397. @pindex f77-install-ok
  1398. @vindex F77_INSTALL_FLAG
  1399. If you want @code{f77} installed, create the file @file{f77-install-ok}
  1400. (e.g. via the UNIX command @samp{touch f77-install-ok}) in the
  1401. source or build top-level directory (the same directory in
  1402. which the @code{g77} @file{f} directory resides, not the @file{f} directory
  1403. itself), or edit @file{gcc/f/Make-lang.in} and change the definition
  1404. of the @samp{F77_INSTALL_FLAG} macro appropriately.
  1405.  
  1406. Usually, this means that, after typing @samp{cd gcc}, you
  1407. would type @samp{touch f77-install-ok}.
  1408.  
  1409. When you enable installation of @code{f77}, either a link to or a
  1410. direct copy of the @code{g77} command is made.
  1411. Similarly, @file{f77.1} is installed as a man page.
  1412.  
  1413. (The @code{uninstall} target in the @file{gcc/Makefile} also tests
  1414. this macro and file, when invoked, to determine whether to delete the
  1415. installed copies of @code{f77} and @file{f77.1}.)
  1416.  
  1417. @emph{Note:} No attempt is yet made
  1418. to install a program (like a shell script) that provides
  1419. compatibility with any other @code{f77} programs.
  1420. Only the most rudimentary invocations of @code{f77} will
  1421. work the same way with @code{g77}.
  1422.  
  1423. @node Installing f2c
  1424. @subsection Installing @code{f2c}
  1425.  
  1426. Currently, @code{g77} does not include @code{f2c} itself in its
  1427. distribution.
  1428. However, it does include a modified version of the @code{libf2c}.
  1429. This version is normally compatible with @code{f2c}, but has been
  1430. modified to meet the needs of @code{g77} in ways that might possibly
  1431. be incompatible with some versions or configurations of @code{f2c}.
  1432.  
  1433. Decide how installation of @code{g77} should affect any existing installation
  1434. of @code{f2c} on your system.
  1435.  
  1436. @pindex f2c
  1437. @pindex f2c.h
  1438. @pindex libf2c.a
  1439. @pindex libF77.a
  1440. @pindex libI77.a
  1441. If you do not have @code{f2c} on your system (e.g. no @file{/usr/bin/f2c},
  1442. no @file{/usr/include/f2c.h}, and no @file{/usr/lib/libf2c.a},
  1443. @file{/usr/lib/libF77.a}, or @file{/usr/lib/libI77.a}), you don't need to
  1444. be concerned with this item.
  1445.  
  1446. If you do have @code{f2c} on your system, you need to decide how users
  1447. of @code{f2c} will be affected by your installing @code{g77}.
  1448. Since @code{g77} is
  1449. currently designed to be object-code-compatible with @code{f2c} (with
  1450. very few, clear exceptions), users of @code{f2c} might want to combine
  1451. @code{f2c}-compiled object files with @code{g77}-compiled object files in a
  1452. single executable.
  1453.  
  1454. To do this, users of @code{f2c} should use the same copies of @file{f2c.h} and
  1455. @file{libf2c.a} that @code{g77} uses (and that get built as part of
  1456. @code{g77}).
  1457.  
  1458. If you do nothing here, the @code{g77} installation process will not
  1459. overwrite the @file{include/f2c.h} and @file{lib/libf2c.a} files with its
  1460. own versions, and in fact will not even install @file{libf2c.a} for use
  1461. with the newly installed versions of @code{gcc} and @code{g77} if it sees
  1462. that @file{lib/libf2c.a} exists---instead, it will print an explanatory
  1463. message and skip this part of the installation.
  1464.  
  1465. @pindex f2c-install-ok
  1466. @vindex F2C_INSTALL_FLAG
  1467. To install @code{g77}'s versions of @file{f2c.h} and @file{libf2c.a}
  1468. in the appropriate
  1469. places, create the file @file{f2c-install-ok} (e.g. via the UNIX
  1470. command @samp{touch f2c-install-ok}) in the source or build top-level
  1471. directory (the same directory in which the @code{g77} @file{f} directory
  1472. resides, not the @file{f} directory itself), or edit @file{gcc/f/Make-lang.in}
  1473. and change the definition of the @samp{F2C_INSTALL_FLAG} macro appropriately.
  1474.  
  1475. Usually, this means that, after typing @samp{cd gcc}, you
  1476. would type @samp{touch f2c-install-ok}.
  1477.  
  1478. Make sure that when you enable the overwriting of @file{f2c.h}
  1479. and @file{libf2c.a}
  1480. as used by @code{f2c}, you have a recent and properly configured version of
  1481. @file{bin/f2c} so that it generates code that is compatible with @code{g77}.
  1482.  
  1483. @pindex f2c-exists-ok
  1484. @vindex F2CLIBOK
  1485. If you don't want installation of @code{g77} to overwrite @code{f2c}'s existing
  1486. installation, but you do want @code{g77} installation to proceed with
  1487. installation of its own versions of @file{f2c.h} and @file{libf2c.a} in places
  1488. where @code{g77} will pick them up (even when linking @code{f2c}-compiled
  1489. object files---which might lead to incompatibilities), create
  1490. the file @file{f2c-exists-ok} (e.g. via the UNIX command
  1491. @samp{touch f2c-exists-ok}) in the source or build top-level directory,
  1492. or edit @file{gcc/f/Make-lang.in} and change the definition of the
  1493. @samp{F2CLIBOK} macro appropriately.
  1494.  
  1495. @node Patching GNU Fortran
  1496. @subsection Patching GNU Fortran
  1497.  
  1498. If you're using a SunOS4 system, you'll need to make the following
  1499. change to @file{gcc/f/proj.h}: edit the line reading
  1500.  
  1501. @example
  1502. #define FFEPROJ_STRTOUL 1  @dots{}
  1503. @end example
  1504.  
  1505. @noindent
  1506. by replacing the @samp{1} with @samp{0}.
  1507. Or, you can avoid editing the source by adding
  1508. @example
  1509. CFLAGS='-DFFEPROJ_STRTOUL=0 -g -O'
  1510. @end example
  1511. to the command line for @code{make} when you invoke it.
  1512. (@samp{-g} is the default for @samp{CFLAGS}.)
  1513.  
  1514. This causes a minimal version of @code{strtoul()} provided
  1515. as part of the @code{g77} distribution to be compiled and
  1516. linked into whatever @code{g77} programs need it, since
  1517. some systems (like SunOS4 with only the bundled compiler and its
  1518. runtime) do not provide this function in their system libraries.
  1519.  
  1520. Similarly, a minimal version of @code{bsearch()} is available
  1521. and can be enabled by editing a line similar to the one
  1522. for @code{strtoul()} above in @file{gcc/f/proj.h}, if
  1523. your system libraries lack @code{bsearch()}.
  1524. The method of overriding @samp{X_CFLAGS} may also be used.
  1525.  
  1526. These are not problems with @code{g77}, which requires an
  1527. ANSI C environment.
  1528. You should upgrade your system to one that provides
  1529. a full ANSI C environment, or encourage the maintainers
  1530. of @code{gcc} to provide one to all @code{gcc}-based
  1531. compilers in future @code{gcc} distributions.
  1532.  
  1533. @xref{Problems Installing}, for more information on
  1534. why @code{strtoul()} comes up missing and on approaches
  1535. to dealing with this problem that have already been tried.
  1536.  
  1537. @node Where to Install
  1538. @subsection Where in the World Does Fortran (and GNU CC) Go?
  1539. @cindex language f77 not recognized
  1540. @cindex gcc will not compile Fortran programs
  1541.  
  1542. Before configuring, you should make sure you know
  1543. where you want the @code{g77} and @code{gcc}
  1544. binaries to be installed after they're built,
  1545. because this information is given to the configuration
  1546. tool and used during the build itself.
  1547.  
  1548. A @code{g77} installation necessarily requires installation of
  1549. a @code{g77}-aware version of @code{gcc}, so that the @code{gcc}
  1550. command recognizes Fortran source files and knows how to compile
  1551. them.
  1552.  
  1553. For this to work, the version of @code{gcc} that you will be building
  1554. as part of @code{g77} @strong{must} be installed as the ``active''
  1555. version of @code{gcc} on the system.
  1556.  
  1557. Sometimes people make the mistake of installing @code{gcc} as
  1558. @file{/usr/local/bin/gcc},
  1559. leaving an older, non-Fortran-aware version in @file{/usr/bin/gcc}.
  1560. (Or, the opposite happens.)@ 
  1561. This can result in @code{g77} being unable to compile Fortran
  1562. source files, because when it calls on @code{gcc} to do the
  1563. actual compilation, @code{gcc} complains that it does not
  1564. recognize the language, or the file name suffix.
  1565.  
  1566. So, determine whether @code{gcc} already is installed on your system,
  1567. and, if so, @emph{where} it is installed, and prepare to configure the
  1568. new version of @code{gcc} you'll be building so that it installs
  1569. over the existing version of @code{gcc}.
  1570.  
  1571. You might want to back up your existing copy of @file{bin/gcc}, and
  1572. the entire @file{lib/} directory, before
  1573. you perform the actual installation (as described in this manual).
  1574.  
  1575. Existing @code{gcc} installations typically are
  1576. found in @file{/usr} or @file{/usr/local}.
  1577. If you aren't certain where the currently
  1578. installed version of @code{gcc} and its
  1579. related programs reside, look at the output
  1580. of this command:
  1581.  
  1582. @example
  1583. gcc -v -o /tmp/delete-me -xc /dev/null -xnone
  1584. @end example
  1585.  
  1586. All sorts of interesting information on the locations of various
  1587. @code{gcc}-related programs and data files should be visible
  1588. in the output of the above command.
  1589. (The output also is likely to include a diagnostic from
  1590. the linker, since there's no @samp{main_()} function.)
  1591. However, you do have to sift through it yourself; @code{gcc}
  1592. currently provides no easy way to ask it where it is installed
  1593. and where it looks for the various programs and data files it
  1594. calls on to do its work.
  1595.  
  1596. Just @emph{building} @code{g77} should not overwrite any installed
  1597. programs---but, usually, after you build @code{g77}, you will want
  1598. to install it, so backing up anything it might overwrite is
  1599. a good idea.
  1600. (This is true for any package, not just @code{g77},
  1601. though in this case it is intentional that @code{g77} overwrites
  1602. @code{gcc} if it is already installed---it is unusual that
  1603. the installation process for one distribution intentionally
  1604. overwrites a program or file installed by another distribution.)
  1605.  
  1606. Another reason to back up the existing version first,
  1607. or make sure you can restore it easily, is that it might be
  1608. an older version on which other users have come to depend
  1609. for certain behaviors.
  1610. However, even the new version of @code{gcc} you install
  1611. will offer users the ability to specify an older version of
  1612. the actual compilation programs if desired, and these
  1613. older versions need not include any @code{g77} components.
  1614. @xref{Target Options,,Specifying Target Machine and Compiler Version,
  1615. gcc,Using and Porting GNU CC}, for information on the @samp{-V}
  1616. option of @code{gcc}.
  1617.  
  1618. @node Configuring gcc
  1619. @subsection Configuring GNU CC
  1620.  
  1621. @code{g77} is configured automatically when you configure
  1622. @code{gcc}.
  1623. There are two parts of @code{g77} that are configured in two
  1624. different ways---@code{g77}, which ``camps on'' to the
  1625. @code{gcc} configuration mechanism, and @code{libf2c}, which
  1626. uses a variation of the GNU @code{autoconf} configuration
  1627. system.
  1628.  
  1629. Generally, you shouldn't have to be concerned with
  1630. either @code{g77} or @code{libf2c} configuration, unless
  1631. you're configuring @code{g77} as a cross-compiler.
  1632. In this case, the @code{libf2c} configuration, and possibly the
  1633. @code{g77} and @code{gcc} configurations as well,
  1634. might need special attention.
  1635. (This also might be the case if you're porting @code{gcc} to
  1636. a whole new system---even if it is just a new operating system
  1637. on an existing, supported CPU.)
  1638.  
  1639. To configure the system, see
  1640. @ref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC},
  1641. following the instructions for running @file{./configure}.
  1642. Pay special attention to the @samp{--prefix=} option, which
  1643. you almost certainly will need to specify.
  1644.  
  1645. (Note that @code{gcc} installation information is provided
  1646. as a straight text file in @file{gcc/INSTALL}.)
  1647.  
  1648. The information printed by the invocation of @file{./configure}
  1649. should show that the @file{f} directory (the Fortran language)
  1650. has been configured.
  1651. If it does not, there is a problem.
  1652.  
  1653. @emph{Note:} Configuring with the @samp{--srcdir} argument is known
  1654. to work with GNU @code{make}, but it is not known to work with
  1655. other variants of @code{make}.
  1656. Irix5.2 and SunOS4.1 versions of @code{make} definitely
  1657. won't work outside the source directory at present.
  1658. @code{g77}'s
  1659. portion of the @file{configure} script issues a warning message
  1660. about this when you configure for building binaries outside
  1661. the source directory.
  1662.  
  1663. @node Building gcc
  1664. @subsection Building GNU CC
  1665. @cindex building @code{gcc}
  1666. @cindex building @code{g77}
  1667.  
  1668. @vindex LANGUAGES
  1669. Building @code{g77} requires building enough of @code{gcc} that
  1670. these instructions assume you're going to build all of
  1671. @code{gcc}, including @code{g++}, @code{protoize}, and so on.
  1672. You can save a little time and disk space by changes the
  1673. @samp{LANGUAGES} macro definition in @code{gcc/Makefile.in}
  1674. or @code{gcc/Makefile}, but if you do that, you're on your own.
  1675. One change is almost @emph{certainly} going to cause failures:
  1676. removing @samp{c} or @samp{f77} from the definition of the
  1677. @samp{LANGUAGES} macro.
  1678.  
  1679. After configuring @code{gcc}, which configures @code{g77} and
  1680. @code{libf2c} automatically, you're ready to start the actual
  1681. build by invoking @code{make}.
  1682.  
  1683. @pindex configure
  1684. @emph{Note:} You @strong{must} have run @file{./configure}
  1685. before you run @code{make}, even if you're
  1686. using an already existing @code{gcc} development directory, because
  1687. @file{./configure} does the work to recognize that you've added
  1688. @code{g77} to the configuration.
  1689.  
  1690. There are two general approaches to building GNU CC from
  1691. scratch:
  1692.  
  1693. @table @dfn
  1694. @item bootstrap
  1695. This method uses minimal native system facilities to
  1696. build a barebones, unoptimized @code{gcc}, that is then
  1697. used to compile (``bootstrap'') the entire system.
  1698.  
  1699. @item straight
  1700. This method assumes a more complete native system
  1701. exists, and uses that just once to build the entire
  1702. system.
  1703. @end table
  1704.  
  1705. On all systems without a recent version of @code{gcc}
  1706. already installed, the @i{bootstrap} method must be
  1707. used.
  1708. In particular, @code{g77} uses extensions to the C
  1709. language offered, apparently, only by @code{gcc}.
  1710.  
  1711. On most systems with a recent version of @code{gcc}
  1712. already installed, the @i{straight} method can be
  1713. used.
  1714. This is an advantage, because it takes less CPU time
  1715. and disk space for the build.
  1716. However, it does require that the system have fairly
  1717. recent versions of many GNU programs and other
  1718. programs, which are not enumerated here.
  1719.  
  1720. @menu
  1721. * Bootstrap Build::  For all systems.
  1722. * Straight Build::   For systems with a recent version of @code{gcc}.
  1723. @end menu
  1724.  
  1725. @node Bootstrap Build
  1726. @subsubsection Bootstrap Build
  1727. @cindex bootstrap build
  1728. @cindex build, bootstrap
  1729.  
  1730. A complete bootstrap build is done by issuing a command
  1731. beginning with @samp{make bootstrap @dots{}}, as
  1732. described in @ref{Installation,,Installing GNU CC,
  1733. gcc,Using and Porting GNU CC}.
  1734. This is the most reliable form of build, but it does require
  1735. the most disk space and CPU time, since the complete system
  1736. is built twice (in Stages 2 and 3), after an initial build
  1737. (during Stage 1) of a minimal @code{gcc} compiler using
  1738. the native compiler and libraries.
  1739.  
  1740. You might have to, or want to, control the way a bootstrap
  1741. build is done by entering the @code{make} commands to build
  1742. each stage one at a time, as described in the @code{gcc}
  1743. manual.
  1744. For example, to save time or disk space, you might want
  1745. to not bother doing the Stage 3 build, in which case you
  1746. are assuming that the @code{gcc} compiler you have built
  1747. is basically sound (because you are giving up the opportunity
  1748. to compare a large number of object files to ensure they're
  1749. identical).
  1750.  
  1751. To save some disk space during installation, after Stage 2
  1752. is built, you can type @samp{rm -fr stage1} to remove the
  1753. binaries built during Stage 1.
  1754.  
  1755. @emph{Note:} @xref{Object File Differences}, for information on
  1756. expected differences in object files produced during Stage 2 and
  1757. Stage 3 of a bootstrap build.
  1758. These differences will be encountered as a result of using
  1759. the @samp{make compare} or similar command sequence recommended
  1760. by the GNU CC installation documentation.
  1761.  
  1762. Also, @xref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC},
  1763. for important information on building @code{gcc} that is
  1764. not described in this @code{g77} manual.
  1765. For example, explanations of diagnostic messages
  1766. and whether they're expected, or indicate trouble,
  1767. are found there.
  1768.  
  1769. @node Straight Build
  1770. @subsubsection Straight Build
  1771. @cindex straight build
  1772. @cindex build, straight
  1773.  
  1774. If you have a recent version of @code{gcc}
  1775. already installed on your system, and if you're
  1776. reasonably certain it produces code that is
  1777. object-compatible with the version of @code{gcc}
  1778. you want to build as part of building @code{g77},
  1779. you can save time and disk space by doing a straight
  1780. build.
  1781.  
  1782. To build just the C and Fortran compilers and the
  1783. necessary run-time libraries, issue the following
  1784. command:
  1785.  
  1786. @example
  1787. make -k CC=gcc LANGUAGES=f77 all g77
  1788. @end example
  1789.  
  1790. (The @samp{g77} target is necessary because the @code{gcc}
  1791. build procedures apparently do not automatically build
  1792. command drivers for languages in subdirectories.
  1793. It's the @samp{all} target that triggers building
  1794. everything except, apparently, the @code{g77} command
  1795. itself.)
  1796.  
  1797. If you run into problems using this method, you have
  1798. two options:
  1799.  
  1800. @itemize @bullet
  1801. @item
  1802. Abandon this approach and do a bootstrap build.
  1803.  
  1804. @item
  1805. Try to make this approach work by diagnosing the
  1806. problems you're running into and retrying.
  1807. @end itemize
  1808.  
  1809. Especially if you do the latter, you might consider
  1810. submitting any solutions as bug/fix reports.
  1811. @xref{Trouble,,Known Causes of Trouble with GNU Fortran}.
  1812.  
  1813. However, understand that many problems preventing a
  1814. straight build from working are not @code{g77} problems,
  1815. and, in such cases, are not likely to be addressed in
  1816. future versions of @code{g77}.
  1817.  
  1818. @node Pre-installation Checks
  1819. @subsection Pre-installation Checks
  1820. @cindex pre-installation checks
  1821. @cindex installing, checking before
  1822.  
  1823. Before installing the system, which includes installing
  1824. @code{gcc}, you might want to do some minimum checking
  1825. to ensure that some basic things work.
  1826.  
  1827. Here are some commands you can try, and output typically
  1828. printed by them when they work:
  1829.  
  1830. @example
  1831. sh# @kbd{cd /usr/src/gcc}
  1832. sh# @kbd{./g77 --driver=./xgcc -B./ -v}
  1833. g77 version @value{version-g77}
  1834.  ./xgcc -B./ -v -fnull-version -o /tmp/gfa18047 @dots{}
  1835. Reading specs from ./specs
  1836. gcc version @value{version-gcc-patched}
  1837.  ./cpp -lang-c -v -isystem ./include -undef @dots{}
  1838. GNU CPP version @value{version-gcc-patched} (Linux/Alpha)
  1839. #include "..." search starts here:
  1840. #include <...> search starts here:
  1841.  ./include
  1842.  /usr/local/include
  1843.  /usr/alpha-unknown-linux/include
  1844.  /usr/lib/gcc-lib/alpha-unknown-linux/@value{version-gcc-patched}/include
  1845.  /usr/include
  1846. End of search list.
  1847.  ./f771 /tmp/cca18048.i -fset-g77-defaults -quiet -dumpbase @dots{}
  1848. GNU F77 version @value{version-gcc-patched} (Linux/Alpha) compiled @dots{}
  1849. GNU Fortran Front End version @value{version-g77} compiled: @dots{}
  1850.  as -nocpp -o /tmp/cca180481.o /tmp/cca18048.s
  1851.  ld -G 8 -O1 -o /tmp/gfa18047 /usr/lib/crt0.o -L. @dots{}
  1852. __G77_LIBF77_VERSION__: @value{version-g77}
  1853. @@(#)LIBF77 VERSION 19970404
  1854. __G77_LIBI77_VERSION__: @value{version-g77}
  1855. @@(#) LIBI77 VERSION pjw,dmg-mods 19970816
  1856. __G77_LIBU77_VERSION__: @value{version-g77}
  1857. @@(#) LIBU77 VERSION 19970609
  1858. sh# @kbd{./xgcc -B./ -v -o /tmp/delete-me -xc /dev/null -xnone}
  1859. Reading specs from ./specs
  1860. gcc version @value{version-gcc-patched}
  1861.  ./cpp -lang-c -v -isystem ./include -undef @dots{}
  1862. GNU CPP version @value{version-gcc-patched} (Linux/Alpha)
  1863. #include "..." search starts here:
  1864. #include <...> search starts here:
  1865.  ./include
  1866.  /usr/local/include
  1867.  /usr/alpha-unknown-linux/include
  1868.  /usr/lib/gcc-lib/alpha-unknown-linux/@value{version-gcc-patched}/include
  1869.  /usr/include
  1870. End of search list.
  1871.  ./cc1 /tmp/cca18063.i -quiet -dumpbase null.c -version @dots{}
  1872. GNU C version @value{version-gcc-patched} (Linux/Alpha) compiled @dots{}
  1873.  as -nocpp -o /tmp/cca180631.o /tmp/cca18063.s
  1874.  ld -G 8 -O1 -o /tmp/delete-me /usr/lib/crt0.o -L. @dots{}
  1875. /usr/lib/crt0.o: In function `__start':
  1876. crt0.S:110: undefined reference to `main'
  1877. /usr/lib/crt0.o(.lita+0x28): undefined reference to `main'
  1878. sh#
  1879. @end example
  1880.  
  1881. (Note that long lines have been truncated, and @samp{@dots{}}
  1882. used to indicate such truncations.)
  1883.  
  1884. The above two commands test whether @code{g77} and @code{gcc},
  1885. respectively, are able to compile empty (null) source files,
  1886. whether invocation of the C preprocessor works, whether libraries
  1887. can be linked, and so on.
  1888.  
  1889. If the output you get from either of the above two commands
  1890. is noticeably different, especially if it is shorter or longer
  1891. in ways that do not look consistent with the above sample
  1892. output, you probably should not install @code{gcc} and @code{g77}
  1893. until you have investigated further.
  1894.  
  1895. For example, you could try compiling actual applications and
  1896. seeing how that works.
  1897. (You might want to do that anyway, even if the above tests
  1898. work.)
  1899.  
  1900. To compile using the not-yet-installed versions of @code{gcc}
  1901. and @code{g77}, use the following commands to invoke them.
  1902.  
  1903. To invoke @code{g77}, type:
  1904.  
  1905. @example
  1906. /usr/src/gcc/g77 --driver=/usr/src/gcc/xgcc -B/usr/src/gcc/ @dots{}
  1907. @end example
  1908.  
  1909. To invoke @code{gcc}, type:
  1910.  
  1911. @example
  1912. /usr/src/gcc/xgcc -B/usr/src/gcc/ @dots{}
  1913. @end example
  1914.  
  1915. @node Installation of Binaries
  1916. @subsection Installation of Binaries
  1917. @cindex installation of binaries
  1918. @cindex @code{g77}, installation of
  1919. @cindex @code{gcc}, installation of
  1920.  
  1921. After configuring, building, and testing @code{g77} and @code{gcc},
  1922. when you are ready to install them on your system, type:
  1923.  
  1924. @example
  1925. make -k CC=gcc LANGUAGES=f77 install
  1926. @end example
  1927.  
  1928. As described in @ref{Installation,,Installing GNU CC,
  1929. gcc,Using and Porting GNU CC}, the values for
  1930. the @samp{CC} and @samp{LANGUAGES} macros should
  1931. be the same as those you supplied for the build
  1932. itself.
  1933.  
  1934. So, the details of the above command might vary
  1935. if you used a bootstrap build (where you might be
  1936. able to omit both definitions, or might have to
  1937. supply the same definitions you used when building
  1938. the final stage) or if you deviated from the
  1939. instructions for a straight build.
  1940.  
  1941. If the above command does not install @file{libf2c.a}
  1942. as expected, try this:
  1943.  
  1944. @example
  1945. make -k @dots{} install install-libf77 install-f2c-all
  1946. @end example
  1947.  
  1948. We don't know why some non-GNU versions of @code{make} sometimes
  1949. require this alternate command, but they do.
  1950. (Remember to supply the appropriate definitions for @samp{CC} and
  1951. @samp{LANGUAGES} where you see @samp{@dots{}} in the above command.)
  1952.  
  1953. Note that using the @samp{-k} option tells @code{make} to
  1954. continue after some installation problems, like not having
  1955. @code{makeinfo} installed on your system.
  1956. It might not be necessary for your system.
  1957.  
  1958. @node Updating Documentation
  1959. @subsection Updating Your Info Directory
  1960. @cindex updating info directory
  1961. @cindex info, updating directory
  1962. @cindex directory, updating info
  1963. @pindex /usr/info/dir
  1964. @pindex g77.info
  1965. @cindex texinfo
  1966. @cindex documentation
  1967.  
  1968. As part of installing @code{g77}, you should make sure users
  1969. of @code{info} can easily access this manual on-line.
  1970. Do this by making sure a line such as the following exists
  1971. in @file{/usr/info/dir}, or in whatever file is the top-level
  1972. file in the @code{info} directory on your system (perhaps
  1973. @file{/usr/local/info/dir}:
  1974.  
  1975. @example
  1976. * g77: (g77).           The GNU Fortran programming language.
  1977. @end example
  1978.  
  1979. If the menu in @file{dir} is organized into sections, @code{g77}
  1980. probably belongs in a section with a name such as one of
  1981. the following:
  1982.  
  1983. @itemize @bullet
  1984. @item
  1985. Fortran Programming
  1986.  
  1987. @item
  1988. Writing Programs
  1989.  
  1990. @item
  1991. Programming Languages
  1992.  
  1993. @item
  1994. Languages Other Than C
  1995.  
  1996. @item
  1997. Scientific/Engineering Tools
  1998.  
  1999. @item
  2000. GNU Compilers
  2001. @end itemize
  2002.  
  2003. @node Missing bison?
  2004. @subsection Missing @code{bison}?
  2005. @cindex @code{bison}
  2006. @cindex missing @code{bison}
  2007.  
  2008. If you cannot install @code{bison}, make sure you have started
  2009. with a @emph{fresh} distribution of @code{gcc}, do @emph{not}
  2010. do @samp{make maintainer-clean} (in other versions of @code{gcc},
  2011. this was called @samp{make realclean}), and, to ensure that
  2012. @code{bison} is not invoked by @code{make} during the build,
  2013. type these commands:
  2014.  
  2015. @example
  2016. sh# @kbd{cd gcc}
  2017. sh# @kbd{touch bi-parser.c bi-parser.h c-parse.c c-parse.h cexp.c}
  2018. sh# @kbd{touch cp/parse.c cp/parse.h objc-parse.c}
  2019. sh#
  2020. @end example
  2021.  
  2022. These commands update the date-time-modified information for
  2023. all the files produced by the various invocations of @code{bison}
  2024. in the current versions of @code{gcc}, so that @code{make} no
  2025. longer believes it needs to update them.
  2026. All of these files should already exist in a @code{gcc}
  2027. distribution, but the application of patches to upgrade
  2028. to a newer version can leave the modification information
  2029. set such that the @code{bison} input files look more ``recent''
  2030. than the corresponding output files.
  2031.  
  2032. @emph{Note:} New versions of @code{gcc} might change the set of
  2033. files it generates by invoking @code{bison}---if you cannot figure
  2034. out for yourself how to handle such a situation, try an
  2035. older version of @code{gcc} until you find someone who can
  2036. (or until you obtain and install @code{bison}).
  2037.  
  2038. @node Missing makeinfo?
  2039. @subsection Missing @code{makeinfo}?
  2040. @cindex @code{makeinfo}
  2041. @cindex missing @code{makeinfo}
  2042.  
  2043. If you cannot install @code{makeinfo}, either use the @code{-k} option when
  2044. invoking make to specify any of the @samp{install} or related targets,
  2045. or specify @samp{MAKEINFO=echo} on the @code{make} command line.
  2046.  
  2047. If you fail to do one of these things, some files, like @file{libf2c.a},
  2048. might not be installed, because the failed attempt by @code{make} to
  2049. invoke @code{makeinfo} causes it to cancel any further processing.
  2050.  
  2051. @node Distributing Binaries
  2052. @section Distributing Binaries
  2053. @cindex binaries, distributing
  2054. @cindex code, distributing
  2055.  
  2056. If you are building @code{g77} for distribution to others in binary form,
  2057. first make sure you are aware of your legal responsibilities (read
  2058. the file @file{gcc/COPYING} thoroughly).
  2059.  
  2060. Then, consider your target audience and decide where @code{g77} should
  2061. be installed.
  2062.  
  2063. For systems like GNU/Linux that have no native Fortran compiler (or
  2064. where @code{g77} could be considered the native compiler for Fortran and
  2065. @code{gcc} for C, etc.), you should definitely configure
  2066. @code{g77} for installation
  2067. in @file{/usr/bin} instead of @file{/usr/local/bin}.
  2068. Specify the
  2069. @samp{--prefix=/usr} option when running @file{./configure}.
  2070. You might
  2071. also want to set up the distribution so the @code{f77} command is a
  2072. link to @code{g77}---just make an empty file named @file{f77-install-ok} in
  2073. the source or build directory (the one in which the @file{f} directory
  2074. resides, not the @file{f} directory itself) when you specify one of the
  2075. @file{install} or @file{uninstall} targets in a @code{make} command.
  2076.  
  2077. For a system that might already have @code{f2c} installed, you definitely
  2078. will want to make another empty file (in the same directory) named
  2079. either @file{f2c-exists-ok} or @file{f2c-install-ok}.
  2080. Use the former if you
  2081. don't want your distribution to overwrite @code{f2c}-related files in existing
  2082. systems; use the latter if you want to improve the likelihood that
  2083. users will be able to use both @code{f2c} and @code{g77} to compile code for a
  2084. single program without encountering link-time or run-time
  2085. incompatibilities.
  2086.  
  2087. (Make sure you clearly document, in the ``advertising'' for
  2088. your distribution, how installation of your distribution will
  2089. affect existing installations of @code{gcc}, @code{f2c},
  2090. @code{f77}, @file{libf2c.a}, and so on.
  2091. Similarly, you should clearly document any requirements
  2092. you assume are met by users of your distribution.)
  2093.  
  2094. For other systems with native @code{f77} (and @code{cc}) compilers,
  2095. configure @code{g77} as you (or most of your audience) would
  2096. configure @code{gcc} for their installations.
  2097. Typically this is for installation in
  2098. @file{/usr/local}, and would not include a copy of
  2099. @code{g77} named @code{f77}, so
  2100. users could still use the native @code{f77}.
  2101.  
  2102. In any case, for @code{g77} to work properly, you @strong{must} ensure
  2103. that the binaries you distribute include:
  2104.  
  2105. @table @file
  2106. @item bin/g77
  2107. This is the command most users use to compile Fortran.
  2108.  
  2109. @item bin/gcc
  2110. This is the command all users use to compile Fortran, either
  2111. directly or indirectly via the @code{g77} command.
  2112. The @file{bin/gcc} executable file must have been built
  2113. from a @code{gcc} source tree into which a @code{g77} source
  2114. tree was merged and configured, or it will not know how
  2115. to compile Fortran programs.
  2116.  
  2117. @item bin/f77
  2118. In installations with no non-GNU native Fortran
  2119. compiler, this is the same as @file{bin/g77}.
  2120. Otherwise, it should be omitted from the distribution,
  2121. so the one on already on a particular system does
  2122. not get overwritten.
  2123.  
  2124. @item info/g77.info*
  2125. This is the documentation for @code{g77}.
  2126. If it is not included, users will have trouble understanding
  2127. diagnostics messages and other such things, and will send
  2128. you a lot of email asking questions.
  2129.  
  2130. Please edit this documentation (by editing @file{gcc/f/*.tex}
  2131. and doing @samp{make doc} from the @file{/usr/src/gcc} directory)
  2132. to reflect any changes you've made to @code{g77}, or at
  2133. least to encourage users of your binary distribution to
  2134. report bugs to you first.
  2135.  
  2136. Also, whether you distribute binaries or install @code{g77}
  2137. on your own system, it might be helpful for everyone to
  2138. add a line listing this manual by name and topic to the
  2139. top-level @code{info} node in @file{/usr/info/dir}.
  2140. That way, users can find @code{g77} documentation more
  2141. easily.
  2142. @xref{Updating Documentation,,Updating Your Info Directory}.
  2143.  
  2144. @item man/man1/g77.1
  2145. This is the short man page for @code{g77}.
  2146. It is out of date, but you might as well include it
  2147. for people who really like man pages.
  2148.  
  2149. @item man/man1/f77.1
  2150. In installations where @code{f77} is the same as @code{g77},
  2151. this is the same as @file{man/man1/g77.1}.
  2152. Otherwise, it should be omitted from the distribution,
  2153. so the one already on a particular system does not
  2154. get overwritten.
  2155.  
  2156. @item lib/gcc-lib/@dots{}/f771
  2157. This is the actual Fortran compiler.
  2158.  
  2159. @item lib/gcc-lib/@dots{}/libf2c.a
  2160. This is the run-time library for @code{g77}-compiled programs.
  2161. @end table
  2162.  
  2163. Whether you want to include the slightly updated (and possibly
  2164. improved) versions of @code{cc1}, @code{cc1plus}, and whatever other
  2165. binaries get rebuilt with the changes the GNU Fortran distribution
  2166. makes to the GNU back end, is up to you.
  2167. These changes are
  2168. highly unlikely to break any compilers, and it is possible
  2169. they'll fix back-end bugs that can be demonstrated using front
  2170. ends other than GNU Fortran's.
  2171.  
  2172. Please assure users that unless
  2173. they have a specific need for their existing,
  2174. older versions of @code{gcc} command,
  2175. they are unlikely to experience any problems by overwriting
  2176. it with your version---though they could certainly protect
  2177. themselves by making backup copies first!
  2178. Otherwise, users might try and install your binaries
  2179. in a ``safe'' place, find they cannot compile Fortran
  2180. programs with your distribution (because, perhaps, they're
  2181. picking up their old version of the @code{gcc} command,
  2182. which does not recognize Fortran programs), and assume
  2183. that your binaries (or, more generally, GNU Fortran
  2184. distributions in general) are broken, at least for their
  2185. system.
  2186.  
  2187. Finally, @strong{please} ask for bug reports to go to you first, at least
  2188. until you're sure your distribution is widely used and has been
  2189. well tested.
  2190. This especially goes for those of you making any
  2191. changes to the @code{g77} sources to port @code{g77}, e.g. to OS/2.
  2192. @email{fortran@@gnu.org} has received a fair number of bug
  2193. reports that turned out to be problems with other peoples' ports
  2194. and distributions, about which nothing could be done for the
  2195. user.
  2196. Once you are quite certain a bug report does not involve
  2197. your efforts, you can forward it to us.
  2198.