[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 08 July 2002, documents GNU make Version 3.80.

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 writing makefiles for 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.

D. GNU Free Documentation License  License for copying this manual
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 The Variable MAKEFILE_LIST  Discover which makefiles have been read.
3.6 Other Special Variables  Other special variables.
3.7 How Makefiles Are Remade  How makefiles get remade.
3.8 Overriding Part of Another Makefile  How to override part of one makefile with another makefile.
3.9 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 Types of Prerequisites  There are two types of prerequisites.
4.4 Using Wildcard Characters in File Names  Using wildcard characters such as `*'.
4.5 Searching Directories for Prerequisites  Searching other directories for source files.
4.6 Phony Targets  Using a target that is not a real file's name.
4.7 Rules without Commands or Prerequisites  You can use a target without commands or prerequisites to mark other targets as phony.
4.8 Empty Target Files to Record Events  When only the date matters and the files are empty.
4.9 Special Built-in Target Names  Targets with special built-in meanings.
4.10 Multiple Targets in a Rule  When to make use of several targets in a rule.
4.11 Multiple Rules for One Target  How to use several rules with the same target.
4.12 Static Pattern Rules  Static pattern rules apply to multiple targets and can vary the prerequisites according to the target name.
4.13 Double-Colon Rules  How to use a special kind of rule to allow several independent rules for one target.
4.14 Generating Prerequisites Automatically  How to automatically generate rules giving prerequisites from source files themselves.

Using Wildcard Characters in File Names

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

Searching Directories for Prerequisites

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

Static Pattern Rules

4.12.1 Syntax of Static Pattern Rules  The syntax of static pattern rules.
4.12.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.
6.10 Target-specific Variable Values  Variable values can be defined on a per-target basis.
6.11 Pattern-specific Variable Values  Target-specific variable values can be applied to a group of targets that match a pattern.

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.5 The if Function  Conditionally expand a value.
8.6 The call Function  Expand a user-defined function.
8.7 The value Function  Return the un-expanded value of a variable.
8.8 The eval Function  Evaluate the arguments as makefile syntax.
8.9 The origin Function  Find where a variable got its value.
8.10 The shell Function  Substitute the output of a shell command.
8.11 Functions That Control Make  Functions that control how make runs.

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.

Makefile Conventions

14.1 General Conventions for Makefiles  
14.2 Utilities in Makefiles  
14.3 Variables for Specifying Commands  
14.4 Variables for Installation Directories  
14.5 Standard Targets for Users  
14.6 Install Command Categories  Three categories of commands in the `install'

Copying This Manual



This document was generated by Jeff Bailey on December, 25 2002 using texi2html