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


SOURCES = mm.f \
matrix_multiply.f \

OBJECTS = mm.o \
matrix_multiply.o \

FC = f95
FFLAGS = -g -pg

LIBS = -lcxml

all: $(PROGRAM)

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

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

$(FC) $(FFLAGS) -c $<

Last modified: 2007-11-07

Direct questions to .