Using Sun WorkShop

FORTRAN 77 Example

Suppose you have a program of four source files and the makefile:

makefile

commonblock

computepts.f

pattern.f

startupcore.f

Assume both pattern.f and computepts.f have an INCLUDE of commonblock, and you wish to compile each .f file and link the three relocatable files, along with a series of libraries, into a program called pattern.

The makefile looks like this:


pattern: pattern.o computepts.o startupcore.o
   f77 pattern.o computepts.o startupcore.o -lcore77 \
   -lcore -lsunwindow -lpixrect -o pattern
pattern.o: pattern.f commonblock
   f77 -c -u pattern.f
computepts.o: computepts.f commonblock
   f77 -c -u computepts.f 
startupcore.o: startupcore.f
   f77 -c -u startupcore.f 

The first line of this makefile indicates that making pattern depends on pattern.o, computepts.o, and startupcore.o. The next line and its continuations give the command for making pattern from the relocatable.o files and libraries.