Example Details


OBJ = main.o file1.o file2.o

OBJ is a variable. It is referenced by $(OBJ). In the lines below, $(OBJ) is equivalent to this list of file names.


.f.o:
This tells make that it is about to learn how to generate .o files from .f files.
	f77 -c $<
This line is the command actually executed. Note that command lines start with a TAB character.

main: $(OBJ)
	f77 -o main $(OBJ)
This is the command to combine all the .o files into an executable main. Note that command lines start with a TAB character.
main.o file1.o: param.h
This tells make that main.f and file1.o depend on param.h. So if param.h is modified, make with recompile main.f and file1.f.
Return to the Makefile page.