Fortran Programming Guide

Suffix Rules in make

To make writing a makefile easier, make will use its own default rules depending on the suffix of a target file. Recognizing the .f suffix, make uses the f77 compiler, passing as arguments any flags specified by the FFLAGS macro, the -c flag, and the name of the source file to be compiled.

The example below demonstrates this rule twice:


OBJ = pattern.o computepts.o startupcore.o 
FFLAGS=-u 
pattern: $(OBJ) 
      f77 $(OBJ) -lcore77 -lcore -lsunwindow \ 
      -lpixrect -o pattern 
pattern.o: pattern.f commonblock 
      f77 $(FFLAGS) -c pattern.f 
computepts.o: computepts.f commonblock 
startupcore.o: startupcore.f

make uses default rules to compile computepts.f and startupcore.f.

Similarly, suffix rules for .f90 files will also invoke the f90 compiler.