[Top] [Contents] [Index] [ ? ]

GNU make

The GNU make utility automatically determines which pieces of a large program need to be recompiled, and issues the commands to recompile them.

This edition of the GNU Make Manual, last updated 04 April 2000, documents GNU make Version 3.79.

This manual describes make and contains the following chapters:

1. Overview of make  
2. An Introduction to Makefiles  An introduction to make.
3. Writing Makefiles  Makefiles tell make what to do.
4. Writing Rules  Rules describe when a file must be remade.
5. Writing the Commands in Rules  Commands say how to remake a file.
6. How to Use Variables  You can use variables to avoid repetition.
7. Conditional Parts of Makefiles  Use or ignore parts of the makefile based on the values of variables.
8. Functions for Transforming Text  Many powerful ways to manipulate text.
9. How to Run make  How to invoke make on the command line.
10. Using Implicit Rules  Use implicit rules to treat many files alike, based on their file names.
11. Using make to Update Archive Files  How make can update library archives.
12. Features of GNU make  Features GNU make has over other makes.
13. Incompatibilities and Missing Features  What GNU make lacks from other makes.
14. Makefile Conventions  Conventions for makefiles in GNU programs.
A. Quick Reference  A quick reference for experienced users.
B. Errors Generated by Make  A list of common errors generated by make.
C. Complex Makefile Example  A real example of a straightforward, but nontrivial, makefile.
Index of Concepts  
Index of Functions, Variables, & Directives  

 -- The Detailed Node Listing ---

Overview of make

Preparing and Running Make  
1.1 How to Read This Manual  On Reading this Text
1.2 Problems and Bugs  

An Introduction to Makefiles

2.1 What a Rule Looks Like  What a rule looks like.
2.2 A Simple Makefile  
2.3 How make Processes a Makefile  How make Processes This Makefile
2.4 Variables Make Makefiles Simpler  
2.5 Letting make Deduce the Commands  
2.6 Another Style of Makefile  
2.7 Rules for Cleaning the Directory  

Writing Makefiles

3.1 What Makefiles Contain  What makefiles contain.
3.2 What Name to Give Your Makefile  How to name your makefile.
3.3 Including Other Makefiles  How one makefile can use another makefile.
3.4 The Variable MAKEFILES  The environment can specify extra makefiles.
3.5 How Makefiles Are Remade  How makefiles get remade.
3.6 Overriding Part of Another Makefile  How to override part of one makefile with another makefile.
3.7 How make Reads a Makefile  How makefiles are parsed.

Writing Rules

4.1 Rule Example  An example explained.
4.2 Rule Syntax  General syntax explained.
4.3 Using Wildcard Characters in File Names  Using wildcard characters such as `*'.
4.4 Searching Directories for Prerequisites  Searching other directories for source files.
4.5 Phony Targets  Using a target that is not a real file's name.
4.6 Rules without Commands or Prerequisites  You can use a target without commands or prerequisites to mark other targets as phony.
4.7 Empty Target Files to Record Events  When only the date matters and the files are empty.
4.8 Special Built-in Target Names  Targets with special built-in meanings.
4.9 Multiple Targets in a Rule  When to make use of several targets in a rule.
4.10 Multiple Rules for One Target  How to use several rules with the same target.
4.11 Static Pattern Rules  Static pattern rules apply to multiple targets and can vary the prerequisites according to the target name.
4.12 Double-Colon Rules  How to use a special kind of rule to allow several independent rules for one target.
4.13 Generating Prerequisites Automatically  How to automatically generate rules giving prerequisites from source files themselves.

Using Wildcard Characters in File Names

4.3.1 Wildcard Examples  Several examples
4.3.2 Pitfalls of Using Wildcards  Problems to avoid.
4.3.3 The Function wildcard  How to cause wildcard expansion where it does not normally take place.

Searching Directories for Prerequisites

4.4.1 VPATH: Search Path for All Prerequisites  Specifying a search path that applies to every prerequisite.
4.4.2 The vpath Directive  Specifying a search path for a specified class of names.
4.4.3 How Directory Searches are Performed  When and how search paths are applied.
4.4.4 Writing Shell Commands with Directory Search  How to write shell commands that work together with search paths.
4.4.5 Directory Search and Implicit Rules  How search paths affect implicit rules.
4.4.6 Directory Search for Link Libraries  Directory search for link libraries.

Static Pattern Rules

4.11.1 Syntax of Static Pattern Rules  The syntax of static pattern rules.
4.11.2 Static Pattern Rules versus Implicit Rules  When are they better than implicit rules?

Writing the Commands in Rules

5.1 Command Echoing  How to control when commands are echoed.
5.2 Command Execution  How commands are executed.
5.3 Parallel Execution  How commands can be executed in parallel.
5.4 Errors in Commands  What happens after a command execution error.
5.5 Interrupting or Killing make  What happens when a command is interrupted.
5.6 Recursive Use of make  Invoking make from makefiles.
5.7 Defining Canned Command Sequences  Defining canned sequences of commands.
5.8 Using Empty Commands  Defining useful, do-nothing commands.

Recursive Use of make

5.6.1 How the MAKE Variable Works  The special effects of using `$(MAKE)'.
5.6.2 Communicating Variables to a Sub-make  How to communicate variables to a sub-make.
5.6.3 Communicating Options to a Sub-make  How to communicate options to a sub-make.
5.6.4 The `--print-directory' Option  How the `-w' or `--print-directory' option helps debug use of recursive make commands.

How to Use Variables

6.1 Basics of Variable References  How to use the value of a variable.
6.2 The Two Flavors of Variables  Variables come in two flavors.
6.3 Advanced Features for Reference to Variables  Advanced features for referencing a variable.
6.4 How Variables Get Their Values  All the ways variables get their values.
6.5 Setting Variables  How to set a variable in the makefile.
6.6 Appending More Text to Variables  How to append more text to the old value of a variable.
6.7 The override Directive  How to set a variable in the makefile even if the user has set it with a command argument.
6.8 Defining Variables Verbatim  An alternate way to set a variable to a verbatim string.
6.9 Variables from the Environment  Variable values can come from the environment.
10.5.3 Automatic Variables  Some special variables have predefined meanings for use with implicit rules.

Advanced Features for Reference to Variables

6.3.1 Substitution References  Referencing a variable with substitutions on the value.
6.3.2 Computed Variable Names  Computing the name of the variable to refer to.

Conditional Parts of Makefiles

7.1 Example of a Conditional  Example of a conditional
7.2 Syntax of Conditionals  The syntax of conditionals.
7.3 Conditionals that Test Flags  Conditionals that test flags.

Functions for Transforming Text

8.1 Function Call Syntax  How to write a function call.
8.2 Functions for String Substitution and Analysis  General-purpose text manipulation functions.
8.3 Functions for File Names  Functions for manipulating file names.
8.4 The foreach Function  Repeat some text with controlled variation.
8.6 The call Function  Expand a user-defined function.
8.7 The origin Function  Find where a variable got its value.
8.8 The shell Function  Substitute the output of a shell command.

How to Run make

9.1 Arguments to Specify the Makefile  How to specify which makefile to use.
9.2 Arguments to Specify the Goals  How to use goal arguments to specify which parts of the makefile to use.
9.3 Instead of Executing the Commands  How to use mode flags to specify what kind of thing to do with the commands in the makefile other than simply execute them.
9.4 Avoiding Recompilation of Some Files  How to avoid recompiling certain files.
9.5 Overriding Variables  How to override a variable to specify an alternate compiler and other things.
9.6 Testing the Compilation of a Program  How to proceed past some errors, to test compilation.
9.7 Summary of Options  

Using Implicit Rules

10.1 Using Implicit Rules  How to use an existing implicit rule to get the commands for updating a file.
10.2 Catalogue of Implicit Rules  A list of built-in implicit rules.
10.3 Variables Used by Implicit Rules  How to change what predefined rules do.
10.4 Chains of Implicit Rules  How to use a chain of implicit rules.
10.5 Defining and Redefining Pattern Rules  How to define new implicit rules.
10.6 Defining Last-Resort Default Rules  How to defining commands for rules which cannot find any.
10.7 Old-Fashioned Suffix Rules  The old-fashioned style of implicit rule.
10.8 Implicit Rule Search Algorithm  The precise algorithm for applying implicit rules.

Defining and Redefining Pattern Rules

10.5.1 Introduction to Pattern Rules  An introduction to pattern rules.
10.5.2 Pattern Rule Examples  Examples of pattern rules.
10.5.3 Automatic Variables  How to use automatic variables in the commands of implicit rules.
10.5.4 How Patterns Match  How patterns match.
10.5.5 Match-Anything Pattern Rules  Precautions you should take prior to defining rules that can match any target file whatever.
10.5.6 Canceling Implicit Rules  How to override or cancel built-in rules.

Using make to Update Archive Files

11.1 Archive Members as Targets  Archive members as targets.
11.2 Implicit Rule for Archive Member Targets  The implicit rule for archive member targets.
11.3 Dangers When Using Archives  Dangers to watch out for when using archives.
11.4 Suffix Rules for Archive Files  You can write a special kind of suffix rule for updating archives.

Implicit Rule for Archive Member Targets

11.2.1 Updating Archive Symbol Directories  How to update archive symbol directories.



This document was generated by root l2-hrz on May, 9 2001 using texi2html