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.
f77
Invokes the compiler
-c
Tells the compiler to generate .o file and stop
(without it, the compiler would call the linker and attempt to make an
executable)
$<
is an automatic variable set equal to the .f file being compiled.
main: $(OBJ)
main:
the target (what make
executes when
make main is typed) make
executes the command.
If they don't exist or have been modified, make
looks for
a rule to create or update them. (In this case, it goes to the
.f.o
line.)
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.
-o main
The name of the executable (a.out by default)
$(OBJ)
Reference to OBJ, which is the list of file names above.
main.o file1.o: param.hThis 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
.