OSDN Git Service

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