3.1. Targets and Dependencies

The make program attempts to bring a target up-to-date by bringing all the target's dependencies up-to-date. These dependencies may have further dependencies. Thus, a potentially complex dependency graph forms when processing a typical 'Makefile':

all: foo

foo: foo.o bar.o baz.o

.c.o:
        $(CC) $(CFLAGS) -c $< -o $@@

.l.c:
        $(LEX) $< && mv lex.yy.c $@@

From a simple file that looks like this one, we can draw a dependency graph such as the one in Figure 3.1.

Figure 3.1. Example Dependency Graph.

Unless the 'Makefile' contains a directive to make, all targets are assumed to be filenames, and rules must be written to ...

Get GNU Autoconf, Automake, and Libtool now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.