The make Utility

  • "make" is a utility that can be used to streamline the edit-compile-test cycle.

    • Useful when code is divided up into many files.

    • Create a file called makefile (or Makefile) describing how the executable code can be compiled from the source code and libraries on which it depends.

    • Type make to automatically compile just the source code files that have changed since the last compilation.

    • Downloaded Linux/UNIX source code often comes with a Makefile or a configuration script (often called configure) to automatically generate a Makefile.

    • Note that the "action" lines in a Makefile (like the compilation line in the example below) begin with a tab, not spaces.


# Makefile example
# DSP 2007-03-07

PROGRAM = mm

SOURCES = mm.f \
matrix_multiply.f \
fill.f

OBJECTS = mm.o \
matrix_multiply.o \
fill.o

FC = f95
FFLAGS = -g -pg

LDFLAGS =
LIBS = -lcxml

all: $(PROGRAM)


$(PROGRAM): $(OBJECTS)
$(FC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@

clean:
rm -f $(PROGRAM) $(OBJECTS) *.mod

.f.o:
$(FC) $(FFLAGS) -c $<




Last modified: 2007-11-07

Direct questions to support@westgrid.ca .