Using Sun WorkShop

Suffix Rules in the make Utility

To make writing a makefile easier, the make utility has default rules that it uses 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, the suffix rules for .f90 files invoke the f90 compiler.