Next: , Up: Fortran Support



7.11.1 Overview

Automake includes full support for Fortran. There are two Fortran interfaces within automake, one specific to Fortran 77 (the so-called `F77' interface) and one for all Fortran dialects (the `FC' interface), which should include Fortran 77. The newer FC interface is preferred, and new code should use this in preference to the older F77 interface. The description below refers to the FC interface, but makes remarks about the F77 interface where these seem relevant; for full details, see the Autoconf manual.

Probably the only time you will have to use the F77 interface is when your project uses both Fortran 77 and Fortran 9x sources and the Fortran 77 code uses features which a Fortran 9x compiler will typically not support. If you are in this situation, you might have to be clever about using both interfaces; but in this case you quite probably have a variety of portability problems anyway.

Any package including Fortran code must define the output variable FC in configure.ac; the simplest way to do this is to use the AC_PROG_FC macro (see Particular Program Checks (The Autoconf Manual)).

A few additional variables are defined when a Fortran source file is seen:

FC
The name of the Fortran compiler.
FCFLAGS
Any flags to pass to the Fortran compiler.
AM_FCFLAGS
The maintainer's variant of FCFLAGS.
RFLAGS
Any flags to pass to the Ratfor compiler.
AM_RFLAGS
The maintainer's variant of RFLAGS.
FCCOMPILE
The command used to actually compile a Fortran source file. The file name is appended to form the complete command line.
FCLINK
The command used to actually link a pure Fortran program or shared library.

Automake still provides the older Fortran 77 support, using the AC_PROG_F77 macro, and the substituted variables F77, FFLAGS, AM_FFLAGS, F77COMPILE and FLINK, instead of the analogous variables described above.

Automake can handle preprocessing Fortran and Ratfor source files in addition to compiling them1. Automake also contains some support for creating programs and shared libraries that are a mixture of Fortran and other languages (see Mixing Fortran With C and C++).

Automake has in the past associated the file extension .f with the F77 interface. Though this is preserved at present for the sake of backward compatibility, it is rather inconsistent with the intention that the FC interface is the preferred one. If you wish to change this (and we think that you should), then you can do so by defining the environment variable AUTOMAKE_F_IS_FC. If this is set equal to 1, then the extension .f is associated with the FC interface; if it is zero or undefined, the extension is associated with the F77 interface; we hope to change the default (the unset case) to FC in future.


Footnotes

[1] See also the information on rules in Catalogue of Rules (The GNU Make Manual).