1 1 GNU 'make' 1 ********** 1 1 This file documents the GNU 'make' utility, which determines 1 automatically which pieces of a large program need to be recompiled, and 1 issues the commands to recompile them. 1 1 This is Edition 0.74, last updated 21 May 2016, of 'The GNU Make 1 Manual', for GNU 'make' version 4.2.1. 1 1 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 1 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc. 1 1 Permission is granted to copy, distribute and/or modify this 1 document under the terms of the GNU Free Documentation License, 1 Version 1.3 or any later version published by the Free Software 1 Foundation; with no Invariant Sections, with the Front-Cover Texts 1 being "A GNU Manual," and with the Back-Cover Texts as in (a) 1 below. A copy of the license is included in the section entitled 1 "GNU Free Documentation License." 1 1 (a) The FSF's Back-Cover Text is: "You have the freedom to copy and 1 modify this GNU manual. Buying copies from the FSF supports it in 1 developing GNU and promoting software freedom." 1
1 · Overview Overview of 'make'. · Introduction An introduction to 'make'. · Makefiles Makefiles tell 'make' what to do. · Rules Rules describe when a file must be remade. · Recipes Recipes say how to remake a file. · Using Variables You can use variables to avoid repetition. · Conditionals Use or ignore parts of the makefile based 1 on the values of variables. · Functions Many powerful ways to manipulate text. · Invoking make Running. How to invoke 'make' on the command line. · Implicit Rules Use implicit rules to treat many files alike, 1 based on their file names. · Archives How 'make' can update library archives. · Extending make Using extensions to 'make'. · Integrating make Integrating 'make' with other tools. · Features Features GNU 'make' has over other 'make's. · Missing What GNU 'make' lacks from other 'make's. · Makefile Conventions Conventions for writing makefiles for 1 GNU programs. · Quick Reference A quick reference for experienced users. · Error Messages A list of common errors generated by 'make'. · Complex Makefile A real example of a straightforward, 1 but nontrivial, makefile. 1 · GNU Free Documentation License License for copying this manual. · Concept Index Index of Concepts. · Name Index Index of Functions, Variables, & Directives. 1 1 -- The Detailed Node Listing -- 1 1 Overview of 'make' 1 · Preparing Preparing and running 'make'. · Reading On reading this text. · Bugs Problems and bugs. 1 1 An Introduction to Makefiles 1 · Rule Introduction What a rule looks like. · Simple Makefile A simple makefile. · How Make Works How 'make' processes this makefile. · Variables Simplify Variables make makefiles simpler. · make Deduces Letting 'make' deduce the recipes. · Combine By Prerequisite Another style of makefile. · Cleanup Rules for cleaning the directory. 1 1 Writing Makefiles 1 · Makefile Contents What makefiles contain. · Makefile Names How to name your makefile. · Include How one makefile can use another makefile. · MAKEFILES Variable The environment can specify extra makefiles. · Remaking Makefiles How makefiles get remade. · Overriding Makefiles How to override part of one makefile 1 with another makefile. · Reading Makefiles How makefiles are parsed. · Secondary Expansion How and when secondary expansion is performed. 1 1 What Makefiles Contain 1 · Splitting Lines Splitting long lines in makefiles 1 1 Writing Rules 1 · Rule Example An example explained. · Rule Syntax General syntax explained. · Prerequisite Types There are two types of prerequisites. · Wildcards Using wildcard characters such as '*'. · Directory Search Searching other directories for source files. · Phony Targets Using a target that is not a real file's name. · Force Targets You can use a target without a recipe 1 or prerequisites to mark other targets 1 as phony. · Empty Targets When only the date matters and the 1 files are empty. · Special Targets Targets with special built-in meanings. · Multiple Targets When to make use of several targets in a rule. · Multiple Rules How to use several rules with the same target. · Static Pattern Static pattern rules apply to multiple targets 1 and can vary the prerequisites according to 1 the target name. · Double-Colon How to use a special kind of rule to allow 1 several independent rules for one target. · Automatic Prerequisites How to automatically generate rules giving 1 prerequisites from source files themselves. 1 1 Using Wildcard Characters in File Names 1 · Wildcard Examples Several examples. · Wildcard Pitfall Problems to avoid. · Wildcard Function How to cause wildcard expansion where 1 it does not normally take place. 1 1 Searching Directories for Prerequisites 1 · General Search Specifying a search path that applies 1 to every prerequisite. · Selective Search Specifying a search path 1 for a specified class of names. · Search Algorithm When and how search paths are applied. · Recipes/Search How to write recipes that work together 1 with search paths. · Implicit/Search How search paths affect implicit rules. · Libraries/Search Directory search for link libraries. 1 1 Static Pattern Rules 1 · Static Usage The syntax of static pattern rules. · Static versus Implicit When are they better than implicit rules? 1 1 Writing Recipes in Rules 1 · Recipe Syntax Recipe syntax features and pitfalls. · Echoing How to control when recipes are echoed. · Execution How recipes are executed. · Parallel How recipes can be executed in parallel. · Errors What happens after a recipe execution error. · Interrupts What happens when a recipe is interrupted. · Recursion Invoking 'make' from makefiles. · Canned Recipes Defining canned recipes. · Empty Recipes Defining useful, do-nothing recipes. 1 1 Recipe Syntax 1 · Splitting Recipe Lines Breaking long recipe lines for readability. · Variables in Recipes Using 'make' variables in recipes. 1 1 Recipe Execution 1 · One Shell One shell for all lines in a recipe. · Choosing the Shell How 'make' chooses the shell used 1 to run recipes. 1 1 Parallel Execution 1 · Parallel Output Handling output during parallel execution · Parallel Input Handling input during parallel execution 1 1 Recursive Use of 'make' 1 · MAKE Variable The special effects of using '$(MAKE)'. · Variables/Recursion How to communicate variables to a sub-'make'. · Options/Recursion How to communicate options to a sub-'make'. · -w Option How the '-w' or '--print-directory' option 1 helps debug use of recursive 'make' commands. 1 1 How to Use Variables 1 · Reference How to use the value of a variable. · Flavors Variables come in two flavors. · Advanced Advanced features for referencing a variable. · Values All the ways variables get their values. · Setting How to set a variable in the makefile. · Appending How to append more text to the old value 1 of a variable. · Override Directive How to set a variable in the makefile even if 1 the user has set it with a command argument. · Multi-Line An alternate way to set a variable 1 to a multi-line string. · Undefine Directive How to undefine a variable so that it appears 1 as if it was never set. · Environment Variable values can come from the environment. · Target-specific Variable values can be defined on a per-target 1 basis. · Pattern-specific Target-specific variable values can be applied 1 to a group of targets that match a pattern. · Suppressing Inheritance Suppress inheritance of variables. · Special Variables Variables with special meaning or behavior. 1 1 Advanced Features for Reference to Variables 1 · Substitution Refs Referencing a variable with 1 substitutions on the value. · Computed Names Computing the name of the variable to refer to. 1 1 Conditional Parts of Makefiles 1 · Conditional Example Example of a conditional · Conditional Syntax The syntax of conditionals. · Testing Flags Conditionals that test flags. 1 1 Functions for Transforming Text 1 · Syntax of Functions How to write a function call. · Text Functions General-purpose text manipulation functions. · File Name Functions Functions for manipulating file names. · Conditional Functions Functions that implement conditions. · Foreach Function Repeat some text with controlled variation. · File Function Write text to a file. · Call Function Expand a user-defined function. · Value Function Return the un-expanded value of a variable. · Eval Function Evaluate the arguments as makefile syntax. · Origin Function Find where a variable got its value. · Flavor Function Find out the flavor of a variable. · Make Control Functions Functions that control how make runs. · Shell Function Substitute the output of a shell command. · Guile Function Use GNU Guile embedded scripting language. 1 1 How to Run 'make' 1 · Makefile Arguments How to specify which makefile to use. · Goals How to use goal arguments to specify which 1 parts of the makefile to use. · Instead of Execution How to use mode flags to specify what 1 kind of thing to do with the recipes 1 in the makefile other than simply 1 execute them. · Avoiding Compilation How to avoid recompiling certain files. · Overriding How to override a variable to specify 1 an alternate compiler and other things. · Testing How to proceed past some errors, to 1 test compilation. · Options Summary Summary of Options 1 1 Using Implicit Rules 1 · Using Implicit How to use an existing implicit rule 1 to get the recipes for updating a file. · Catalogue of Rules A list of built-in rules. · Implicit Variables How to change what predefined rules do. · Chained Rules How to use a chain of implicit rules. · Pattern Rules How to define new implicit rules. · Last Resort How to define a recipe for rules which 1 cannot find any. · Suffix Rules The old-fashioned style of implicit rule. · Implicit Rule Search The precise algorithm for applying 1 implicit rules. 1 1 Defining and Redefining Pattern Rules 1 · Pattern Intro An introduction to pattern rules. · Pattern Examples Examples of pattern rules. · Automatic Variables How to use automatic variables in the 1 recipe of implicit rules. · Pattern Match How patterns match. · Match-Anything Rules Precautions you should take prior to 1 defining rules that can match any 1 target file whatever. · Canceling Rules How to override or cancel built-in rules. 1 1 Using 'make' to Update Archive Files 1 · Archive Members Archive members as targets. · Archive Update The implicit rule for archive member targets. · Archive Pitfalls Dangers to watch out for when using archives. · Archive Suffix Rules You can write a special kind of suffix rule 1 for updating archives. 1 1 Implicit Rule for Archive Member Targets 1 · Archive Symbols How to update archive symbol directories. 1 1 Extending GNU 'make' 1 · Guile Integration Using Guile as an embedded scripting language. · Loading Objects Loading dynamic objects as extensions. 1 1 GNU Guile Integration 1 · Guile Types Converting Guile types to 'make' strings. · Guile Interface Invoking 'make' functions from Guile. · Guile Example Example using Guile in 'make'. 1 1 Loading Dynamic Objects 1 · load Directive Loading dynamic objects as extensions. · Remaking Loaded Objects How loaded objects get remade. · Loaded Object API Programmatic interface for loaded objects. · Loaded Object Example Example of a loaded object 1 1 Integrating GNU 'make' 1 · Job Slots Share job slots with GNU 'make'. · Terminal Output Control output to terminals. 1 1 Sharing Job Slots with GNU 'make' 1 · POSIX Jobserver Using the jobserver on POSIX systems. · Windows Jobserver Using the jobserver on Windows systems. 1 1