Chapter 11. Example Makefiles
The makefiles shown throughout this book are industrial strength and quite suitable for adapting to your most advanced needs. But it’s still worthwhile looking at some makefiles from real-life projects to see what people have done with make under the stress of providing deliverables. Here, we discuss several example makefiles in detail. The first example is the makefile to build this book. The second is the makefile used to build the 2.6.7 Linux kernel.
The Book Makefile
Writing a book on programming is in itself an interesting exercise in building systems. The text of the book consists of many files, each of which needs various preprocessing steps. The examples are real programs that should be run and their output collected, post-processed, and included in the main text (so that they don’t have to be cut and pasted, with the risk of introducing errors). During composition, it is useful to be able to view the text in different formats. Finally, delivering the material requires packaging. Of course, all of this must be repeatable and relatively easy to maintain.
Sounds like a job for make! This is one of the great beauties of make. It can be applied to an amazing variety of problems. This book was written in DocBook format (i.e., XML). Applying make to TEX, LATEX, or troff is standard procedure when using those tools.
Example 11-1 shows the entire makefile for the book. It is about 440 lines long. The makefile is divided into these basic tasks:
Managing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access