o screen.o keyboard.o. It builds the executable from the three object files:
editor.o, screen.o, and keyboard.o.
The next three rules tell make how to build the individual object files. Each rule consists of
one object file target (editor.o, screen.o, keyboard.o); one source code file dependency
(editor.c, screen.c, keyboard.c); and a rule that defines how to build that target.
CAUTION
787
Programming Tools and Utilities 29
The fifth rule defines a target named clean with no dependencies. When a target has no dependencies,
its commands are executed whenever the target is invoked. In this case, clean deletes the
constituent object files (*.o), plus any core files (core) as well as any emacs backup files (*~)
from previous builds.
The sixth rule defines a target named realclean. It uses the fifth rule as one of its dependencies.
This causes make to build the clean target and then to remove the editor binary.
Here is where make??™s value becomes evident. Ordinarily, if you tried to build editor using the
command from the second line, gcc would complain loudly and ceremoniously quit if the dependencies
did not exist. make, on the other hand, after determining that editor requires these files,
first verifies that they exist and, if they don??™t, executes the commands to create them.
Pages:
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425