Section 19.2. The Makefile


19.2. The Makefile

The make program has a special syntax for its rules. Furthermore, the rules for all the operations that you want make to manage in your project generally need to be collected in a file for make to read. The command-line option -f filename tells make which file contains the rules you want it to apply. Usually, though, this option is omitted and make looks for a file with the default name makefile, or failing that, Makefile.[*]

[*] Before makefile or Makefile, GNU make without the -f option first looks for a file named GNUmakefile.

When you read makefiles , remember that they are not simply scripts to be executed in sequential order. Rather, make first analyzes an entire makefile to build a dependency tree of possible targets and their prerequisites, then iterates through that dependency tree to build the desired targets.

In addition to rules, makefiles also contain comments, variable assignments, macro definitions, include directives, and conditional directives. These will be discussed in later sections of this chapter, after we have taken a closer look at the meat of the makefile: the rules.



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net