The first language describes dependency graphs consisting of targets and prerequisites.
The second language is a macro language for performing textual substitution.
The only characters actually disallowed in a variable name are :, #, and =.
To get the value of a variable, enclose the variable name in$()or ${}, but single-letter variable names can omit the parentheses.
The value of a variable consists of all the words to the right of the assignment symbol with leading space trimmed. Trailing spaces are not trimmed.
3.1 What Variables Are Used For
In general it is a good idea to use variables to represent external programs. This allows users of the makefile to more easily adapt the makefile to their specific environment.
Variables can also store user-defined command sequences.
3.2 Variable Types
A simply expandedvariable (or asimple variable) is defined using the:=assignment operator:
Building and processing the dependency graph to update the requested target is what make is all about.
There are a number of different kinds of rules:
Explicit rulesindicate a specific target to be updated if it is out of date with respect to any of its prerequisites.
Implicit rulesare either pattern rules or suffix rules found in the rules database built-in to make.
Pattern rulesuse wildcards instead of explicit filenames. This allows make to apply the rule any time a target file matching the pattern needs to updated.
Static pattern rulesare like regular pattern rules except they apply only to a specific list of target files.
2.1 Explicit Rules
A rule does not have to be defined "all at once." Each time make sees a target file it adds the target and prerequisites to the dependency graph. If a target has already been seen and exists in the graph, any additional prerequisites are appended to the target file entry in make's dependency graph.
makesupports wildcards (also known as globbing).
make's wildcards are identical to the Bourne shell's:~,*,?,[...], and[^...].Wildcard expansion is performed by make when the pattern appears as a target or prerequisite, when the pattern appears in a command, the expansion is performed by the subshell.
In other contexts, wildcards can be expanded explicitly by calling a function.
In more controlled environments using wildcards to select the files in a program is considered bad practice because a rogue source file might be accidentally linked into a program.
GNU make includes a special target,.PHONY, to tell make that a target is not a real file. Any target can be declared phony by including it as a prerequisite of.PHONY:
這是讀"Managing Projects with GNU Make"的筆記,make真的是非常的有趣呀。 1.1 Targets and Prerequisites
A rule consists of three parts: the target, its prerequisites, and the command(s) to perform: One or more targets appear to the left of the colon and zero or more prerequisites can appear to the right of the colon.