Chapter 19. Using make to Build C Programs
As you saw in Chapter 18, the commands involved in compiling and linking C programs can be numerous and complex. The make utility automates and manages the process of compiling programs of any size and complexity, so that a single make command replaces hundreds of compiler and linker commands. Moreover, make compares the timestamps of related files to avoid having to repeat any previous work. And most importantly, make manages the individual rules that define how to build various targets, and automatically analyzes the dependency relationships between all the files involved.
There are a number of different versions of make, and their features and usage differ to varying degrees. They feature different sets of built-in variables and targets with special meanings. In this brief chapter, rather than trying to cover different varieties, we concentrate on GNU make, which is widely available. (On systems that use a different default make, GNU make is often available under the executable name gmake.) Furthermore, even as far as GNU make is concerned, this chapter sticks more or less to the basics: in this book, we want to use make only as a tool for building programs from C source code. If you want to go on to exploit the full capabilities of make, an inevitable step is to read the program's documentation itself. For a well-structured course in using make's advanced capabilities, see also Managing Projects with GNU make by Robert Mecklenburg (O'Reilly).