mirror of
https://gitee.com/yanmu_ym/cpp.git
synced 2026-02-03 01:23:14 +08:00
18394 lines
1.1 MiB
18394 lines
1.1 MiB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- This file documents the GNU make utility, which determines
|
|
automatically which pieces of a large program need to be recompiled,
|
|
and issues the commands to recompile them.
|
|
|
|
This is Edition 0.76, last updated 31 October 2022,
|
|
of The GNU Make Manual, for GNU make version 4.4.
|
|
|
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
|
|
1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007,
|
|
2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
|
|
2020, 2021, 2022 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with no
|
|
Invariant Sections, with the Front-Cover Texts being "A GNU Manual,"
|
|
and with the Back-Cover Texts as in (a) below. A copy of the
|
|
license is included in the section entitled "GNU Free Documentation
|
|
License."
|
|
|
|
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
|
modify this GNU manual. Buying copies from the FSF supports it in
|
|
developing GNU and promoting software freedom." -->
|
|
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<title>GNU make</title>
|
|
|
|
<meta name="description" content="GNU make">
|
|
<meta name="keywords" content="GNU make">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<link href="#Top" rel="start" title="Top">
|
|
<link href="#Concept-Index" rel="index" title="Concept Index">
|
|
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="dir.html#Top" rel="up" title="(dir)">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
kbd {font-style: oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
span.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
/*
|
|
Software License Agreement (BSD License)
|
|
|
|
Copyright (c) 2006, Yahoo! Inc.
|
|
All rights reserved.
|
|
|
|
Redistribution and use of this software in source and
|
|
binary forms, with or without modification, arepermitted
|
|
provided that the following conditions are met:
|
|
|
|
* Redistributions of source code must retain the above
|
|
copyright notice, this list of conditions and the
|
|
following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
copyright notice, this list of conditions and the
|
|
following disclaimer in the documentation and/or other
|
|
materials provided with the distribution.
|
|
|
|
* Neither the name of Yahoo! Inc. nor the names of its
|
|
contributors may be used to endorse or promote products
|
|
derived from this software without specific prior
|
|
written permission of Yahoo! Inc.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
SUCH DAMAGE.
|
|
*/
|
|
|
|
html {
|
|
color: #000;
|
|
background: #FFF;
|
|
}
|
|
|
|
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4,
|
|
h5, h6, pre, code, form, fieldset, legend, input,
|
|
button, textarea, p, blockquote, th, td {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
table {
|
|
border-collapse: collapse;
|
|
border-spacing: 0;
|
|
}
|
|
|
|
fieldset, img {
|
|
border: 0;
|
|
}
|
|
|
|
address, caption, cite, code, dfn, em, strong,
|
|
th, var, optgroup {
|
|
font-style: inherit;
|
|
font-weight: inherit;
|
|
}
|
|
|
|
del, ins {
|
|
text-decoration: none;
|
|
}
|
|
|
|
li {
|
|
list-style:none;
|
|
}
|
|
|
|
caption, th {
|
|
text-align: left;
|
|
}
|
|
|
|
h1, h2, h3, h4, h5, h6 {
|
|
font-size: 100%;
|
|
font-weight: normal;
|
|
}
|
|
|
|
q:before, q:after {
|
|
content:'';
|
|
}
|
|
|
|
abbr, acronym {
|
|
border: 0;
|
|
font-variant: normal;
|
|
}
|
|
|
|
sup {
|
|
vertical-align: baseline;
|
|
}
|
|
sub {
|
|
vertical-align: baseline;
|
|
}
|
|
|
|
legend {
|
|
color: #000;
|
|
}
|
|
|
|
input, button, textarea, select, optgroup, option {
|
|
font-family: inherit;
|
|
font-size: inherit;
|
|
font-style: inherit;
|
|
font-weight: inherit;
|
|
}
|
|
|
|
input, button, textarea, select {
|
|
*font-size: 100%;
|
|
}
|
|
|
|
/* This stylesheet is used by manuals and a few older resources. */
|
|
|
|
@import url('/reset.css');
|
|
|
|
|
|
/*** PAGE LAYOUT ***/
|
|
|
|
html, body {
|
|
font-size: 1em;
|
|
text-align: left;
|
|
text-decoration: none;
|
|
}
|
|
html { background-color: #e7e7e7; }
|
|
|
|
body {
|
|
max-width: 74.92em;
|
|
margin: 0 auto;
|
|
padding: .5em 1em 1em 1em;
|
|
background-color: white;
|
|
border: .1em solid #c0c0c0;
|
|
}
|
|
|
|
/*** BASIC ELEMENTS ***/
|
|
|
|
/* Size and positioning */
|
|
|
|
p, pre, li, dt, dd, table, code, address { line-height: 1.3em; }
|
|
|
|
h1 { font-size: 2em; margin: 1em 0 }
|
|
h2 { font-size: 1.50em; margin: 1.0em 0 0.87em 0; }
|
|
h3 { font-size: 1.30em; margin: 1.0em 0 0.87em 0; }
|
|
h4 { font-size: 1.13em; margin: 1.0em 0 0.88em 0; }
|
|
h5 { font-size: 1.00em; margin: 1.0em 0 1.00em 0; }
|
|
|
|
p, pre { margin: 1em 0; }
|
|
pre { overflow: auto; padding-bottom: .3em; }
|
|
|
|
ul, ol, blockquote { margin-left: 1.5%; margin-right: 1.5%; }
|
|
hr { margin: 1em 0; }
|
|
/* Lists of underlined links are difficult to read. The top margin
|
|
gives a little more spacing between entries. */
|
|
ul li { margin: .5em 1em; }
|
|
ol li { margin: 1em; }
|
|
ol ul li { margin: .5em 1em; }
|
|
ul li p, ul ul li { margin-top: .3em; margin-bottom: .3em; }
|
|
ul ul, ol ul { margin-top: 0; margin-bottom: 0; }
|
|
|
|
/* Separate description lists from preceding text */
|
|
dl { margin: 1em 0 0 0; }
|
|
/* separate the "term" from subsequent "description" */
|
|
dt { margin: .5em 0; }
|
|
/* separate the "description" from subsequent list item
|
|
when the final <dd> child is an anonymous box */
|
|
dd { margin: .5em 3% 1em 3%; }
|
|
/* separate anonymous box (used to be the first element in <dd>)
|
|
from subsequent <p> */
|
|
dd p { margin: .5em 0; }
|
|
|
|
table {
|
|
display: block; overflow: auto;
|
|
margin-top: 1.5em; margin-bottom: 1.5em;
|
|
}
|
|
th { padding: .3em .5em; text-align: center; }
|
|
td { padding: .2em .5em; }
|
|
|
|
address { margin-bottom: 1em; }
|
|
caption { margin-bottom: .5em; text-align: center; }
|
|
sup { vertical-align: super; }
|
|
sub { vertical-align: sub; }
|
|
|
|
/* Style */
|
|
|
|
h1, h2, h3, h4, h5, h6, strong, dt, th { font-weight: bold; }
|
|
|
|
/* The default color (black) is too dark for large text in
|
|
bold font. */
|
|
h1, h2, h3, h4 { color: #333; }
|
|
h5, h6, dt { color: #222; }
|
|
|
|
a[href] { color: #005090; }
|
|
a[href]:visited { color: #100070; }
|
|
a[href]:active, a[href]:hover {
|
|
color: #100070;
|
|
text-decoration: none;
|
|
}
|
|
|
|
h1 a[href]:visited, h2 a[href]:visited, h3 a[href]:visited,
|
|
h4 a[href]:visited { color: #005090; }
|
|
h1 a[href]:hover, h2 a[href]:hover, h3 a[href]:hover,
|
|
h4 a[href]:hover { color: #100070; }
|
|
|
|
ol { list-style: decimal outside;}
|
|
ul { list-style: square outside; }
|
|
ul ul, ol ul { list-style: circle; }
|
|
li { list-style: inherit; }
|
|
|
|
hr { background-color: #ede6d5; }
|
|
table { border: 0; }
|
|
|
|
abbr,acronym {
|
|
border-bottom:1px dotted #000;
|
|
text-decoration: none;
|
|
cursor:help;
|
|
}
|
|
del { text-decoration: line-through; }
|
|
em { font-style: italic; }
|
|
small { font-size: .9em; }
|
|
|
|
img { max-width: 100%}
|
|
|
|
|
|
/*** SIMPLE CLASSES ***/
|
|
|
|
.center, .c { text-align: center; }
|
|
.nocenter{ text-align: left; }
|
|
|
|
.underline { text-decoration: underline; }
|
|
.nounderline { text-decoration: none; }
|
|
|
|
.no-bullet { list-style: none; }
|
|
.inline-list li { display: inline }
|
|
|
|
.netscape4, .no-display { display: none; }
|
|
|
|
|
|
/*** MANUAL PAGES ***/
|
|
|
|
/* This makes the very long tables of contents in Gnulib and other
|
|
manuals easier to read. */
|
|
.contents ul, .shortcontents ul { font-weight: bold; }
|
|
.contents ul ul, .shortcontents ul ul { font-weight: normal; }
|
|
.contents ul { list-style: none; }
|
|
|
|
/* For colored navigation bars (Emacs manual): make the bar extend
|
|
across the whole width of the page and give it a decent height. */
|
|
.header, .node { margin: 0 -1em; padding: 0 1em; }
|
|
.header p, .node p { line-height: 2em; }
|
|
|
|
/* For navigation links. We can't use inline-block display to avoid wrapping
|
|
because this makes the links appear much smaller than normal text on
|
|
phones with Chromium (RT #1872370). */
|
|
.node a, .header a { /*display: inline-block;*/ line-height: 2em; }
|
|
.node a:hover, .header a:hover { background: #f2efe4; }
|
|
|
|
/* Inserts */
|
|
table.cartouche td { padding: 1.5em; }
|
|
|
|
div.display, div.lisp, div.smalldisplay,
|
|
div.smallexample, div.smalllisp { margin-left: 3%; }
|
|
|
|
div.example { padding: .8em 1.2em .4em; }
|
|
pre.example { padding: .8em 1.2em; }
|
|
div.example, pre.example {
|
|
margin: 1em 0 1em 3% ;
|
|
-webkit-border-radius: .3em;
|
|
-moz-border-radius: .3em;
|
|
border-radius: .3em;
|
|
border: 1px solid #d4cbb6;
|
|
background-color: #f2efe4;
|
|
}
|
|
div.example > pre.example {
|
|
padding: 0 0 .4em;
|
|
margin: 0;
|
|
border: none;
|
|
}
|
|
|
|
pre.menu-comment { padding-top: 1.3em; margin: 0; }
|
|
|
|
|
|
/*** FOR WIDE SCREENS ***/
|
|
|
|
@media (min-width: 40em) {
|
|
body { padding: .5em 3em 1em 3em; }
|
|
div.header, div.node { margin: 0 -3em; padding: 0 3em; }
|
|
}
|
|
/* Style-sheet to use for manuals (copied from Emacs) */
|
|
|
|
@import url('/style.css');
|
|
|
|
/* makeinfo 6.5 converts @quotation to <blockquote>. Highlight them. */
|
|
blockquote {
|
|
font-style: normal;
|
|
border-left: solid 10px red;
|
|
padding-left: 2.5%;
|
|
margin-left: 0px;
|
|
}
|
|
|
|
/* Increase inter-line spacing to improve readability. */
|
|
p, pre, li, dt, dd, table, code, address { line-height: 1.5em; }
|
|
|
|
var { font-style: italic; }
|
|
|
|
/* Lay out @lisp just like @example. Copied from what /style.css
|
|
does for the 'example' class. */
|
|
div.lisp { padding: .8em 1.2em .4em; }
|
|
pre.lisp { padding: .8em 1.2em; }
|
|
div.lisp, pre.lisp {
|
|
margin: 1em 0 1em 3% ;
|
|
-webkit-border-radius: .3em;
|
|
-moz-border-radius: .3em;
|
|
border-radius: .3em;
|
|
border: 1px solid #d4cbb6;
|
|
background-color: #f2efe4;
|
|
}
|
|
div.lisp > pre.lisp {
|
|
padding: 0 0 .4em;
|
|
margin: 0;
|
|
border: none;
|
|
}
|
|
|
|
/* makeinfo 6.7 uses <div class="header"> for navigation links above node
|
|
titles. Make those links less prominent. */
|
|
.header {
|
|
line-height: 2em;
|
|
font-size: 87.5%;
|
|
color: #433;
|
|
}
|
|
|
|
/* In title and node titles, use Fira Sans if available as it is more
|
|
pleasant and more compact than Helvetica. */
|
|
.settitle, .top, .chapter, .section, .subsection, .subsubsection {
|
|
font-family: Fira Sans, sans;
|
|
}
|
|
|
|
/* ----- coreutils specific styling ----- */
|
|
|
|
/* layout.css indents "body p" when it should probably only indent "body > p"?
|
|
In any case, disable indenting of p in these sub elements. */
|
|
dd p,li p {
|
|
margin-left: 0;
|
|
margin-right: 0;
|
|
}
|
|
|
|
/* underlined links are distracting, especially within outlined tables. */
|
|
a { /*add :link for external links*/
|
|
text-decoration: none; /* don't underline links by default */
|
|
outline-style: none; /* don't put dotted box around clicked links */
|
|
}
|
|
a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
body {
|
|
/* Make sure the body doesn't become to wide: long lines are hard to
|
|
read. */
|
|
max-width: 45em;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<h1 class="settitle" align="center">GNU <code>make</code></h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span id="SEC_Overview"></span>
|
|
<h2 class="shortcontents-heading">Short Table of Contents</h2>
|
|
|
|
<div class="shortcontents">
|
|
<ul class="no-bullet">
|
|
<li><a id="stoc-Overview-of-make" href="#toc-Overview-of-make">1 Overview of <code>make</code></a></li>
|
|
<li><a id="stoc-An-Introduction-to-Makefiles" href="#toc-An-Introduction-to-Makefiles">2 An Introduction to Makefiles</a></li>
|
|
<li><a id="stoc-Writing-Makefiles" href="#toc-Writing-Makefiles">3 Writing Makefiles</a></li>
|
|
<li><a id="stoc-Writing-Rules" href="#toc-Writing-Rules">4 Writing Rules</a></li>
|
|
<li><a id="stoc-Writing-Recipes-in-Rules" href="#toc-Writing-Recipes-in-Rules">5 Writing Recipes in Rules</a></li>
|
|
<li><a id="stoc-How-to-Use-Variables" href="#toc-How-to-Use-Variables">6 How to Use Variables</a></li>
|
|
<li><a id="stoc-Conditional-Parts-of-Makefiles" href="#toc-Conditional-Parts-of-Makefiles">7 Conditional Parts of Makefiles</a></li>
|
|
<li><a id="stoc-Functions-for-Transforming-Text" href="#toc-Functions-for-Transforming-Text">8 Functions for Transforming Text</a></li>
|
|
<li><a id="stoc-How-to-Run-make" href="#toc-How-to-Run-make">9 How to Run <code>make</code></a></li>
|
|
<li><a id="stoc-Using-Implicit-Rules" href="#toc-Using-Implicit-Rules">10 Using Implicit Rules</a></li>
|
|
<li><a id="stoc-Using-make-to-Update-Archive-Files" href="#toc-Using-make-to-Update-Archive-Files">11 Using <code>make</code> to Update Archive Files</a></li>
|
|
<li><a id="stoc-Extending-GNU-make" href="#toc-Extending-GNU-make">12 Extending GNU <code>make</code></a></li>
|
|
<li><a id="stoc-Integrating-GNU-make" href="#toc-Integrating-GNU-make">13 Integrating GNU <code>make</code></a></li>
|
|
<li><a id="stoc-Features-of-GNU-make" href="#toc-Features-of-GNU-make">14 Features of GNU <code>make</code></a></li>
|
|
<li><a id="stoc-Incompatibilities-and-Missing-Features" href="#toc-Incompatibilities-and-Missing-Features">15 Incompatibilities and Missing Features</a></li>
|
|
<li><a id="stoc-Makefile-Conventions-1" href="#toc-Makefile-Conventions-1">16 Makefile Conventions</a></li>
|
|
<li><a id="stoc-Quick-Reference-1" href="#toc-Quick-Reference-1">Appendix A Quick Reference</a></li>
|
|
<li><a id="stoc-Errors-Generated-by-Make" href="#toc-Errors-Generated-by-Make">Appendix B Errors Generated by Make</a></li>
|
|
<li><a id="stoc-Complex-Makefile-Example" href="#toc-Complex-Makefile-Example">Appendix C Complex Makefile Example</a></li>
|
|
<li><a id="stoc-GNU-Free-Documentation-License-1" href="#toc-GNU-Free-Documentation-License-1">Appendix D GNU Free Documentation License</a></li>
|
|
<li><a id="stoc-Index-of-Concepts" href="#toc-Index-of-Concepts" rel="index">Index of Concepts</a></li>
|
|
<li><a id="stoc-Index-of-Functions_002c-Variables_002c-_0026-Directives" href="#toc-Index-of-Functions_002c-Variables_002c-_0026-Directives" rel="index">Index of Functions, Variables, & Directives</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<span id="SEC_Contents"></span>
|
|
<h2 class="contents-heading">Table of Contents</h2>
|
|
|
|
<div class="contents">
|
|
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Overview-of-make" href="#Overview">1 Overview of <code>make</code></a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-How-to-Read-This-Manual" href="#Reading">1.1 How to Read This Manual</a></li>
|
|
<li><a id="toc-Problems-and-Bugs" href="#Bugs">1.2 Problems and Bugs</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-An-Introduction-to-Makefiles" href="#Introduction">2 An Introduction to Makefiles</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-What-a-Rule-Looks-Like" href="#Rule-Introduction">2.1 What a Rule Looks Like</a></li>
|
|
<li><a id="toc-A-Simple-Makefile" href="#Simple-Makefile">2.2 A Simple Makefile</a></li>
|
|
<li><a id="toc-How-make-Processes-a-Makefile" href="#How-Make-Works">2.3 How <code>make</code> Processes a Makefile</a></li>
|
|
<li><a id="toc-Variables-Make-Makefiles-Simpler" href="#Variables-Simplify">2.4 Variables Make Makefiles Simpler</a></li>
|
|
<li><a id="toc-Letting-make-Deduce-the-Recipes" href="#make-Deduces">2.5 Letting <code>make</code> Deduce the Recipes</a></li>
|
|
<li><a id="toc-Another-Style-of-Makefile" href="#Combine-By-Prerequisite">2.6 Another Style of Makefile</a></li>
|
|
<li><a id="toc-Rules-for-Cleaning-the-Directory" href="#Cleanup">2.7 Rules for Cleaning the Directory</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Writing-Makefiles" href="#Makefiles">3 Writing Makefiles</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-What-Makefiles-Contain" href="#Makefile-Contents">3.1 What Makefiles Contain</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Splitting-Long-Lines" href="#Splitting-Lines">3.1.1 Splitting Long Lines</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-What-Name-to-Give-Your-Makefile" href="#Makefile-Names">3.2 What Name to Give Your Makefile</a></li>
|
|
<li><a id="toc-Including-Other-Makefiles" href="#Include">3.3 Including Other Makefiles</a></li>
|
|
<li><a id="toc-The-Variable-MAKEFILES" href="#MAKEFILES-Variable">3.4 The Variable <code>MAKEFILES</code></a></li>
|
|
<li><a id="toc-How-Makefiles-Are-Remade" href="#Remaking-Makefiles">3.5 How Makefiles Are Remade</a></li>
|
|
<li><a id="toc-Overriding-Part-of-Another-Makefile" href="#Overriding-Makefiles">3.6 Overriding Part of Another Makefile</a></li>
|
|
<li><a id="toc-How-make-Reads-a-Makefile" href="#Reading-Makefiles">3.7 How <code>make</code> Reads a Makefile</a></li>
|
|
<li><a id="toc-How-Makefiles-Are-Parsed" href="#Parsing-Makefiles">3.8 How Makefiles Are Parsed</a></li>
|
|
<li><a id="toc-Secondary-Expansion-1" href="#Secondary-Expansion">3.9 Secondary Expansion</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Writing-Rules" href="#Rules">4 Writing Rules</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Rule-Example-1" href="#Rule-Example">4.1 Rule Example</a></li>
|
|
<li><a id="toc-Rule-Syntax-1" href="#Rule-Syntax">4.2 Rule Syntax</a></li>
|
|
<li><a id="toc-Types-of-Prerequisites" href="#Prerequisite-Types">4.3 Types of Prerequisites</a></li>
|
|
<li><a id="toc-Using-Wildcard-Characters-in-File-Names" href="#Wildcards">4.4 Using Wildcard Characters in File Names</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Wildcard-Examples-1" href="#Wildcard-Examples">4.4.1 Wildcard Examples</a></li>
|
|
<li><a id="toc-Pitfalls-of-Using-Wildcards" href="#Wildcard-Pitfall">4.4.2 Pitfalls of Using Wildcards</a></li>
|
|
<li><a id="toc-The-Function-wildcard" href="#Wildcard-Function">4.4.3 The Function <code>wildcard</code></a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Searching-Directories-for-Prerequisites" href="#Directory-Search">4.5 Searching Directories for Prerequisites</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-VPATH_003a-Search-Path-for-All-Prerequisites" href="#General-Search">4.5.1 <code>VPATH</code>: Search Path for All Prerequisites</a></li>
|
|
<li><a id="toc-The-vpath-Directive" href="#Selective-Search">4.5.2 The <code>vpath</code> Directive</a></li>
|
|
<li><a id="toc-How-Directory-Searches-are-Performed" href="#Search-Algorithm">4.5.3 How Directory Searches are Performed</a></li>
|
|
<li><a id="toc-Writing-Recipes-with-Directory-Search" href="#Recipes_002fSearch">4.5.4 Writing Recipes with Directory Search</a></li>
|
|
<li><a id="toc-Directory-Search-and-Implicit-Rules" href="#Implicit_002fSearch">4.5.5 Directory Search and Implicit Rules</a></li>
|
|
<li><a id="toc-Directory-Search-for-Link-Libraries" href="#Libraries_002fSearch">4.5.6 Directory Search for Link Libraries</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Phony-Targets-1" href="#Phony-Targets">4.6 Phony Targets</a></li>
|
|
<li><a id="toc-Rules-without-Recipes-or-Prerequisites" href="#Force-Targets">4.7 Rules without Recipes or Prerequisites</a></li>
|
|
<li><a id="toc-Empty-Target-Files-to-Record-Events" href="#Empty-Targets">4.8 Empty Target Files to Record Events</a></li>
|
|
<li><a id="toc-Special-Built_002din-Target-Names" href="#Special-Targets">4.9 Special Built-in Target Names</a></li>
|
|
<li><a id="toc-Multiple-Targets-in-a-Rule" href="#Multiple-Targets">4.10 Multiple Targets in a Rule</a></li>
|
|
<li><a id="toc-Multiple-Rules-for-One-Target" href="#Multiple-Rules">4.11 Multiple Rules for One Target</a></li>
|
|
<li><a id="toc-Static-Pattern-Rules" href="#Static-Pattern">4.12 Static Pattern Rules</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Syntax-of-Static-Pattern-Rules" href="#Static-Usage">4.12.1 Syntax of Static Pattern Rules</a></li>
|
|
<li><a id="toc-Static-Pattern-Rules-versus-Implicit-Rules" href="#Static-versus-Implicit">4.12.2 Static Pattern Rules versus Implicit Rules</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Double_002dColon-Rules" href="#Double_002dColon">4.13 Double-Colon Rules</a></li>
|
|
<li><a id="toc-Generating-Prerequisites-Automatically" href="#Automatic-Prerequisites">4.14 Generating Prerequisites Automatically</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Writing-Recipes-in-Rules" href="#Recipes">5 Writing Recipes in Rules</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Recipe-Syntax-1" href="#Recipe-Syntax">5.1 Recipe Syntax</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Splitting-Recipe-Lines-1" href="#Splitting-Recipe-Lines">5.1.1 Splitting Recipe Lines</a></li>
|
|
<li><a id="toc-Using-Variables-in-Recipes" href="#Variables-in-Recipes">5.1.2 Using Variables in Recipes</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Recipe-Echoing" href="#Echoing">5.2 Recipe Echoing</a></li>
|
|
<li><a id="toc-Recipe-Execution" href="#Execution">5.3 Recipe Execution</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Using-One-Shell" href="#One-Shell">5.3.1 Using One Shell</a></li>
|
|
<li><a id="toc-Choosing-the-Shell-1" href="#Choosing-the-Shell">5.3.2 Choosing the Shell</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Parallel-Execution" href="#Parallel">5.4 Parallel Execution</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Disabling-Parallel-Execution" href="#Parallel-Disable">5.4.1 Disabling Parallel Execution</a></li>
|
|
<li><a id="toc-Output-During-Parallel-Execution" href="#Parallel-Output">5.4.2 Output During Parallel Execution</a></li>
|
|
<li><a id="toc-Input-During-Parallel-Execution" href="#Parallel-Input">5.4.3 Input During Parallel Execution</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Errors-in-Recipes" href="#Errors">5.5 Errors in Recipes</a></li>
|
|
<li><a id="toc-Interrupting-or-Killing-make" href="#Interrupts">5.6 Interrupting or Killing <code>make</code></a></li>
|
|
<li><a id="toc-Recursive-Use-of-make" href="#Recursion">5.7 Recursive Use of <code>make</code></a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-How-the-MAKE-Variable-Works" href="#MAKE-Variable">5.7.1 How the <code>MAKE</code> Variable Works</a></li>
|
|
<li><a id="toc-Communicating-Variables-to-a-Sub_002dmake" href="#Variables_002fRecursion">5.7.2 Communicating Variables to a Sub-<code>make</code></a></li>
|
|
<li><a id="toc-Communicating-Options-to-a-Sub_002dmake" href="#Options_002fRecursion">5.7.3 Communicating Options to a Sub-<code>make</code></a></li>
|
|
<li><a id="toc-The-_002d_002dprint_002ddirectory-Option" href="#g_t_002dw-Option">5.7.4 The ‘<samp>--print-directory</samp>’ Option</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Defining-Canned-Recipes" href="#Canned-Recipes">5.8 Defining Canned Recipes</a></li>
|
|
<li><a id="toc-Using-Empty-Recipes" href="#Empty-Recipes">5.9 Using Empty Recipes</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-How-to-Use-Variables" href="#Using-Variables">6 How to Use Variables</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Basics-of-Variable-References" href="#Reference">6.1 Basics of Variable References</a></li>
|
|
<li><a id="toc-The-Two-Flavors-of-Variables" href="#Flavors">6.2 The Two Flavors of Variables</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Recursively-Expanded-Variable-Assignment" href="#Recursive-Assignment">6.2.1 Recursively Expanded Variable Assignment</a></li>
|
|
<li><a id="toc-Simply-Expanded-Variable-Assignment" href="#Simple-Assignment">6.2.2 Simply Expanded Variable Assignment</a></li>
|
|
<li><a id="toc-Immediately-Expanded-Variable-Assignment" href="#Immediate-Assignment">6.2.3 Immediately Expanded Variable Assignment</a></li>
|
|
<li><a id="toc-Conditional-Variable-Assignment" href="#Conditional-Assignment">6.2.4 Conditional Variable Assignment</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Advanced-Features-for-Reference-to-Variables" href="#Advanced">6.3 Advanced Features for Reference to Variables</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Substitution-References" href="#Substitution-Refs">6.3.1 Substitution References</a></li>
|
|
<li><a id="toc-Computed-Variable-Names" href="#Computed-Names">6.3.2 Computed Variable Names</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-How-Variables-Get-Their-Values" href="#Values">6.4 How Variables Get Their Values</a></li>
|
|
<li><a id="toc-Setting-Variables" href="#Setting">6.5 Setting Variables</a></li>
|
|
<li><a id="toc-Appending-More-Text-to-Variables" href="#Appending">6.6 Appending More Text to Variables</a></li>
|
|
<li><a id="toc-The-override-Directive" href="#Override-Directive">6.7 The <code>override</code> Directive</a></li>
|
|
<li><a id="toc-Defining-Multi_002dLine-Variables" href="#Multi_002dLine">6.8 Defining Multi-Line Variables</a></li>
|
|
<li><a id="toc-Undefining-Variables" href="#Undefine-Directive">6.9 Undefining Variables</a></li>
|
|
<li><a id="toc-Variables-from-the-Environment" href="#Environment">6.10 Variables from the Environment</a></li>
|
|
<li><a id="toc-Target_002dspecific-Variable-Values" href="#Target_002dspecific">6.11 Target-specific Variable Values</a></li>
|
|
<li><a id="toc-Pattern_002dspecific-Variable-Values" href="#Pattern_002dspecific">6.12 Pattern-specific Variable Values</a></li>
|
|
<li><a id="toc-Suppressing-Inheritance-1" href="#Suppressing-Inheritance">6.13 Suppressing Inheritance</a></li>
|
|
<li><a id="toc-Other-Special-Variables" href="#Special-Variables">6.14 Other Special Variables</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Conditional-Parts-of-Makefiles" href="#Conditionals">7 Conditional Parts of Makefiles</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Example-of-a-Conditional" href="#Conditional-Example">7.1 Example of a Conditional</a></li>
|
|
<li><a id="toc-Syntax-of-Conditionals" href="#Conditional-Syntax">7.2 Syntax of Conditionals</a></li>
|
|
<li><a id="toc-Conditionals-that-Test-Flags" href="#Testing-Flags">7.3 Conditionals that Test Flags</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Functions-for-Transforming-Text" href="#Functions">8 Functions for Transforming Text</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Function-Call-Syntax" href="#Syntax-of-Functions">8.1 Function Call Syntax</a></li>
|
|
<li><a id="toc-Functions-for-String-Substitution-and-Analysis" href="#Text-Functions">8.2 Functions for String Substitution and Analysis</a></li>
|
|
<li><a id="toc-Functions-for-File-Names" href="#File-Name-Functions">8.3 Functions for File Names</a></li>
|
|
<li><a id="toc-Functions-for-Conditionals" href="#Conditional-Functions">8.4 Functions for Conditionals</a></li>
|
|
<li><a id="toc-The-let-Function" href="#Let-Function">8.5 The <code>let</code> Function</a></li>
|
|
<li><a id="toc-The-foreach-Function" href="#Foreach-Function">8.6 The <code>foreach</code> Function</a></li>
|
|
<li><a id="toc-The-file-Function" href="#File-Function">8.7 The <code>file</code> Function</a></li>
|
|
<li><a id="toc-The-call-Function" href="#Call-Function">8.8 The <code>call</code> Function</a></li>
|
|
<li><a id="toc-The-value-Function" href="#Value-Function">8.9 The <code>value</code> Function</a></li>
|
|
<li><a id="toc-The-eval-Function" href="#Eval-Function">8.10 The <code>eval</code> Function</a></li>
|
|
<li><a id="toc-The-origin-Function" href="#Origin-Function">8.11 The <code>origin</code> Function</a></li>
|
|
<li><a id="toc-The-flavor-Function" href="#Flavor-Function">8.12 The <code>flavor</code> Function</a></li>
|
|
<li><a id="toc-Functions-That-Control-Make" href="#Make-Control-Functions">8.13 Functions That Control Make</a></li>
|
|
<li><a id="toc-The-shell-Function" href="#Shell-Function">8.14 The <code>shell</code> Function</a></li>
|
|
<li><a id="toc-The-guile-Function" href="#Guile-Function">8.15 The <code>guile</code> Function</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-How-to-Run-make" href="#Running">9 How to Run <code>make</code></a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Arguments-to-Specify-the-Makefile" href="#Makefile-Arguments">9.1 Arguments to Specify the Makefile</a></li>
|
|
<li><a id="toc-Arguments-to-Specify-the-Goals" href="#Goals">9.2 Arguments to Specify the Goals</a></li>
|
|
<li><a id="toc-Instead-of-Executing-Recipes" href="#Instead-of-Execution">9.3 Instead of Executing Recipes</a></li>
|
|
<li><a id="toc-Avoiding-Recompilation-of-Some-Files" href="#Avoiding-Compilation">9.4 Avoiding Recompilation of Some Files</a></li>
|
|
<li><a id="toc-Overriding-Variables" href="#Overriding">9.5 Overriding Variables</a></li>
|
|
<li><a id="toc-Testing-the-Compilation-of-a-Program" href="#Testing">9.6 Testing the Compilation of a Program</a></li>
|
|
<li><a id="toc-Temporary-Files-1" href="#Temporary-Files">9.7 Temporary Files</a></li>
|
|
<li><a id="toc-Summary-of-Options" href="#Options-Summary">9.8 Summary of Options</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Using-Implicit-Rules" href="#Implicit-Rules">10 Using Implicit Rules</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Using-Implicit-Rules-1" href="#Using-Implicit">10.1 Using Implicit Rules</a></li>
|
|
<li><a id="toc-Catalogue-of-Built_002dIn-Rules" href="#Catalogue-of-Rules">10.2 Catalogue of Built-In Rules</a></li>
|
|
<li><a id="toc-Variables-Used-by-Implicit-Rules" href="#Implicit-Variables">10.3 Variables Used by Implicit Rules</a></li>
|
|
<li><a id="toc-Chains-of-Implicit-Rules" href="#Chained-Rules">10.4 Chains of Implicit Rules</a></li>
|
|
<li><a id="toc-Defining-and-Redefining-Pattern-Rules" href="#Pattern-Rules">10.5 Defining and Redefining Pattern Rules</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Introduction-to-Pattern-Rules" href="#Pattern-Intro">10.5.1 Introduction to Pattern Rules</a></li>
|
|
<li><a id="toc-Pattern-Rule-Examples" href="#Pattern-Examples">10.5.2 Pattern Rule Examples</a></li>
|
|
<li><a id="toc-Automatic-Variables-1" href="#Automatic-Variables">10.5.3 Automatic Variables</a></li>
|
|
<li><a id="toc-How-Patterns-Match" href="#Pattern-Match">10.5.4 How Patterns Match</a></li>
|
|
<li><a id="toc-Match_002dAnything-Pattern-Rules" href="#Match_002dAnything-Rules">10.5.5 Match-Anything Pattern Rules</a></li>
|
|
<li><a id="toc-Canceling-Implicit-Rules" href="#Canceling-Rules">10.5.6 Canceling Implicit Rules</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Defining-Last_002dResort-Default-Rules" href="#Last-Resort">10.6 Defining Last-Resort Default Rules</a></li>
|
|
<li><a id="toc-Old_002dFashioned-Suffix-Rules" href="#Suffix-Rules">10.7 Old-Fashioned Suffix Rules</a></li>
|
|
<li><a id="toc-Implicit-Rule-Search-Algorithm" href="#Implicit-Rule-Search">10.8 Implicit Rule Search Algorithm</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Using-make-to-Update-Archive-Files" href="#Archives">11 Using <code>make</code> to Update Archive Files</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Archive-Members-as-Targets" href="#Archive-Members">11.1 Archive Members as Targets</a></li>
|
|
<li><a id="toc-Implicit-Rule-for-Archive-Member-Targets" href="#Archive-Update">11.2 Implicit Rule for Archive Member Targets</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Updating-Archive-Symbol-Directories" href="#Archive-Symbols">11.2.1 Updating Archive Symbol Directories</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Dangers-When-Using-Archives" href="#Archive-Pitfalls">11.3 Dangers When Using Archives</a></li>
|
|
<li><a id="toc-Suffix-Rules-for-Archive-Files" href="#Archive-Suffix-Rules">11.4 Suffix Rules for Archive Files</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Extending-GNU-make" href="#Extending-make">12 Extending GNU <code>make</code></a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-GNU-Guile-Integration" href="#Guile-Integration">12.1 GNU Guile Integration</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Conversion-of-Guile-Types" href="#Guile-Types">12.1.1 Conversion of Guile Types</a></li>
|
|
<li><a id="toc-Interfaces-from-Guile-to-make" href="#Guile-Interface">12.1.2 Interfaces from Guile to <code>make</code></a></li>
|
|
<li><a id="toc-Example-Using-Guile-in-make" href="#Guile-Example">12.1.3 Example Using Guile in <code>make</code></a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Loading-Dynamic-Objects" href="#Loading-Objects">12.2 Loading Dynamic Objects</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-The-load-Directive" href="#load-Directive">12.2.1 The <code>load</code> Directive</a></li>
|
|
<li><a id="toc-How-Loaded-Objects-Are-Remade" href="#Remaking-Loaded-Objects">12.2.2 How Loaded Objects Are Remade</a></li>
|
|
<li><a id="toc-Loaded-Object-Interface" href="#Loaded-Object-API">12.2.3 Loaded Object Interface</a></li>
|
|
<li><a id="toc-Example-Loaded-Object" href="#Loaded-Object-Example">12.2.4 Example Loaded Object</a></li>
|
|
</ul></li>
|
|
</ul></li>
|
|
<li><a id="toc-Integrating-GNU-make" href="#Integrating-make">13 Integrating GNU <code>make</code></a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-Sharing-Job-Slots-with-GNU-make" href="#Job-Slots">13.1 Sharing Job Slots with GNU <code>make</code></a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-POSIX-Jobserver-Interaction" href="#POSIX-Jobserver">13.1.1 POSIX Jobserver Interaction</a></li>
|
|
<li><a id="toc-Windows-Jobserver-Interaction" href="#Windows-Jobserver">13.1.2 Windows Jobserver Interaction</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Synchronized-Terminal-Output" href="#Terminal-Output">13.2 Synchronized Terminal Output</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Features-of-GNU-make" href="#Features">14 Features of GNU <code>make</code></a></li>
|
|
<li><a id="toc-Incompatibilities-and-Missing-Features" href="#Missing">15 Incompatibilities and Missing Features</a></li>
|
|
<li><a id="toc-Makefile-Conventions-1" href="#Makefile-Conventions">16 Makefile Conventions</a>
|
|
<ul class="no-bullet">
|
|
<li><a id="toc-General-Conventions-for-Makefiles" href="#Makefile-Basics">16.1 General Conventions for Makefiles</a></li>
|
|
<li><a id="toc-Utilities-in-Makefiles-1" href="#Utilities-in-Makefiles">16.2 Utilities in Makefiles</a></li>
|
|
<li><a id="toc-Variables-for-Specifying-Commands" href="#Command-Variables">16.3 Variables for Specifying Commands</a></li>
|
|
<li><a id="toc-DESTDIR_003a-Support-for-Staged-Installs" href="#DESTDIR">16.4 <code>DESTDIR</code>: Support for Staged Installs</a></li>
|
|
<li><a id="toc-Variables-for-Installation-Directories" href="#Directory-Variables">16.5 Variables for Installation Directories</a></li>
|
|
<li><a id="toc-Standard-Targets-for-Users" href="#Standard-Targets">16.6 Standard Targets for Users</a></li>
|
|
<li><a id="toc-Install-Command-Categories-1" href="#Install-Command-Categories">16.7 Install Command Categories</a></li>
|
|
</ul></li>
|
|
<li><a id="toc-Quick-Reference-1" href="#Quick-Reference">Appendix A Quick Reference</a></li>
|
|
<li><a id="toc-Errors-Generated-by-Make" href="#Error-Messages">Appendix B Errors Generated by Make</a></li>
|
|
<li><a id="toc-Complex-Makefile-Example" href="#Complex-Makefile">Appendix C Complex Makefile Example</a></li>
|
|
<li><a id="toc-GNU-Free-Documentation-License-1" href="#GNU-Free-Documentation-License">Appendix D GNU Free Documentation License</a></li>
|
|
<li><a id="toc-Index-of-Concepts" href="#Concept-Index" rel="index">Index of Concepts</a></li>
|
|
<li><a id="toc-Index-of-Functions_002c-Variables_002c-_0026-Directives" href="#Name-Index" rel="index">Index of Functions, Variables, & Directives</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
<span id="Top"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Overview" accesskey="n" rel="next">Overview</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="GNU-make"></span><h1 class="top">GNU <code>make</code></h1>
|
|
|
|
<p>This file documents the GNU <code>make</code> utility, which determines
|
|
automatically which pieces of a large program need to be recompiled,
|
|
and issues the commands to recompile them.
|
|
</p>
|
|
<p>This is Edition 0.76, last updated 31 October 2022,
|
|
of <cite>The GNU Make Manual</cite>, for GNU <code>make</code> version 4.4.
|
|
</p>
|
|
<p>Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
|
|
1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007,
|
|
2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
|
|
2020, 2021, 2022 Free Software Foundation, Inc.
|
|
</p>
|
|
<blockquote>
|
|
<p>Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with no
|
|
Invariant Sections, with the Front-Cover Texts being “A GNU Manual,”
|
|
and with the Back-Cover Texts as in (a) below. A copy of the
|
|
license is included in the section entitled “GNU Free Documentation
|
|
License.”
|
|
</p>
|
|
<p>(a) The FSF’s Back-Cover Text is: “You have the freedom to copy and
|
|
modify this GNU manual. Buying copies from the FSF supports it in
|
|
developing GNU and promoting software freedom.”
|
|
</p></blockquote>
|
|
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Overview" accesskey="1">Overview</a></td><td> </td><td align="left" valign="top">Overview of <code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Introduction" accesskey="2">Introduction</a></td><td> </td><td align="left" valign="top">An introduction to <code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Makefiles" accesskey="3">Makefiles</a></td><td> </td><td align="left" valign="top">Makefiles tell <code>make</code> what to do.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Rules" accesskey="4">Rules</a></td><td> </td><td align="left" valign="top">Rules describe when a file must be remade.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Recipes" accesskey="5">Recipes</a></td><td> </td><td align="left" valign="top">Recipes say how to remake a file.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Using-Variables" accesskey="6">Using Variables</a></td><td> </td><td align="left" valign="top">You can use variables to avoid repetition.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Conditionals" accesskey="7">Conditionals</a></td><td> </td><td align="left" valign="top">Use or ignore parts of the makefile based
|
|
on the values of variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Functions" accesskey="8">Functions</a></td><td> </td><td align="left" valign="top">Many powerful ways to manipulate text.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Running" accesskey="9">Invoking make</a></td><td> </td><td align="left" valign="top">How to invoke <code>make</code> on the command line.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Implicit-Rules">Implicit Rules</a></td><td> </td><td align="left" valign="top">Use implicit rules to treat many files alike,
|
|
based on their file names.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Archives">Archives</a></td><td> </td><td align="left" valign="top">How <code>make</code> can update library archives.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Extending-make">Extending make</a></td><td> </td><td align="left" valign="top">Using extensions to <code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Integrating-make">Integrating make</a></td><td> </td><td align="left" valign="top">Integrating <code>make</code> with other tools.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Features">Features</a></td><td> </td><td align="left" valign="top">Features GNU <code>make</code> has over other <code>make</code>s.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Missing">Missing</a></td><td> </td><td align="left" valign="top">What GNU <code>make</code> lacks from other <code>make</code>s.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Makefile-Conventions">Makefile Conventions</a></td><td> </td><td align="left" valign="top">Conventions for writing makefiles for
|
|
GNU programs.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Quick-Reference">Quick Reference</a></td><td> </td><td align="left" valign="top">A quick reference for experienced users.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Error-Messages">Error Messages</a></td><td> </td><td align="left" valign="top">A list of common errors generated by <code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Complex-Makefile">Complex Makefile</a></td><td> </td><td align="left" valign="top">A real example of a straightforward,
|
|
but nontrivial, makefile.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a></td><td> </td><td align="left" valign="top">License for copying this manual.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Concept-Index" rel="index">Concept Index</a></td><td> </td><td align="left" valign="top">Index of Concepts.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Name-Index" rel="index">Name Index</a></td><td> </td><td align="left" valign="top">Index of Functions, Variables, & Directives.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
</pre></th></tr><tr><th colspan="3" align="left" valign="top"><pre class="menu-comment"> — The Detailed Node Listing —
|
|
|
|
Overview of <code>make</code>
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Preparing">Preparing</a></td><td> </td><td align="left" valign="top">Preparing and running <code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Reading">Reading</a></td><td> </td><td align="left" valign="top">On reading this text.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Bugs">Bugs</a></td><td> </td><td align="left" valign="top">Problems and bugs.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
An Introduction to Makefiles
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Rule-Introduction">Rule Introduction</a></td><td> </td><td align="left" valign="top">What a rule looks like.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Simple-Makefile">Simple Makefile</a></td><td> </td><td align="left" valign="top">A simple makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#How-Make-Works">How Make Works</a></td><td> </td><td align="left" valign="top">How <code>make</code> processes this makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Variables-Simplify">Variables Simplify</a></td><td> </td><td align="left" valign="top">Variables make makefiles simpler.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#make-Deduces">make Deduces</a></td><td> </td><td align="left" valign="top">Letting <code>make</code> deduce the recipes.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Combine-By-Prerequisite">Combine By Prerequisite</a></td><td> </td><td align="left" valign="top">Another style of makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Cleanup">Cleanup</a></td><td> </td><td align="left" valign="top">Rules for cleaning the directory.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Writing Makefiles
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Makefile-Contents">Makefile Contents</a></td><td> </td><td align="left" valign="top">What makefiles contain.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Makefile-Names">Makefile Names</a></td><td> </td><td align="left" valign="top">How to name your makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Include">Include</a></td><td> </td><td align="left" valign="top">How one makefile can use another makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#MAKEFILES-Variable">MAKEFILES Variable</a></td><td> </td><td align="left" valign="top">The environment can specify extra makefiles.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Remaking-Makefiles">Remaking Makefiles</a></td><td> </td><td align="left" valign="top">How makefiles get remade.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Overriding-Makefiles">Overriding Makefiles</a></td><td> </td><td align="left" valign="top">How to override part of one makefile
|
|
with another makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Reading-Makefiles">Reading Makefiles</a></td><td> </td><td align="left" valign="top">How makefiles are read in.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Parsing-Makefiles">Parsing Makefiles</a></td><td> </td><td align="left" valign="top">How makefiles are parsed.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Secondary-Expansion">Secondary Expansion</a></td><td> </td><td align="left" valign="top">How and when secondary expansion is performed.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
What Makefiles Contain
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Splitting-Lines">Splitting Lines</a></td><td> </td><td align="left" valign="top">Splitting long lines in makefiles
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Writing Rules
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Rule-Example">Rule Example</a></td><td> </td><td align="left" valign="top">An example explained.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Rule-Syntax">Rule Syntax</a></td><td> </td><td align="left" valign="top">General syntax explained.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Prerequisite-Types">Prerequisite Types</a></td><td> </td><td align="left" valign="top">There are two types of prerequisites.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Wildcards">Wildcards</a></td><td> </td><td align="left" valign="top">Using wildcard characters such as ‘*’.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Directory-Search">Directory Search</a></td><td> </td><td align="left" valign="top">Searching other directories for source files.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Phony-Targets">Phony Targets</a></td><td> </td><td align="left" valign="top">Using a target that is not a real file’s name.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Force-Targets">Force Targets</a></td><td> </td><td align="left" valign="top">You can use a target without a recipe
|
|
or prerequisites to mark other targets
|
|
as phony.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Empty-Targets">Empty Targets</a></td><td> </td><td align="left" valign="top">When only the date matters and the
|
|
files are empty.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Special-Targets">Special Targets</a></td><td> </td><td align="left" valign="top">Targets with special built-in meanings.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Multiple-Targets">Multiple Targets</a></td><td> </td><td align="left" valign="top">When to make use of several targets in a rule.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Multiple-Rules">Multiple Rules</a></td><td> </td><td align="left" valign="top">How to use several rules with the same target.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Static-Pattern">Static Pattern</a></td><td> </td><td align="left" valign="top">Static pattern rules apply to multiple targets
|
|
and can vary the prerequisites according to
|
|
the target name.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Double_002dColon">Double-Colon</a></td><td> </td><td align="left" valign="top">How to use a special kind of rule to allow
|
|
several independent rules for one target.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td><td> </td><td align="left" valign="top">How to automatically generate rules giving
|
|
prerequisites from source files themselves.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Using Wildcard Characters in File Names
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Wildcard-Examples">Wildcard Examples</a></td><td> </td><td align="left" valign="top">Several examples.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Wildcard-Pitfall">Wildcard Pitfall</a></td><td> </td><td align="left" valign="top">Problems to avoid.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Wildcard-Function">Wildcard Function</a></td><td> </td><td align="left" valign="top">How to cause wildcard expansion where
|
|
it does not normally take place.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Searching Directories for Prerequisites
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#General-Search">General Search</a></td><td> </td><td align="left" valign="top">Specifying a search path that applies
|
|
to every prerequisite.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Selective-Search">Selective Search</a></td><td> </td><td align="left" valign="top">Specifying a search path
|
|
for a specified class of names.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Search-Algorithm">Search Algorithm</a></td><td> </td><td align="left" valign="top">When and how search paths are applied.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Recipes_002fSearch">Recipes/Search</a></td><td> </td><td align="left" valign="top">How to write recipes that work together
|
|
with search paths.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Implicit_002fSearch">Implicit/Search</a></td><td> </td><td align="left" valign="top">How search paths affect implicit rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Libraries_002fSearch">Libraries/Search</a></td><td> </td><td align="left" valign="top">Directory search for link libraries.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Static Pattern Rules
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Static-Usage">Static Usage</a></td><td> </td><td align="left" valign="top">The syntax of static pattern rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Static-versus-Implicit">Static versus Implicit</a></td><td> </td><td align="left" valign="top">When are they better than implicit rules?
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Writing Recipes in Rules
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Recipe-Syntax">Recipe Syntax</a></td><td> </td><td align="left" valign="top">Recipe syntax features and pitfalls.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Echoing">Echoing</a></td><td> </td><td align="left" valign="top">How to control when recipes are echoed.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Execution">Execution</a></td><td> </td><td align="left" valign="top">How recipes are executed.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Parallel">Parallel</a></td><td> </td><td align="left" valign="top">How recipes can be executed in parallel.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Errors">Errors</a></td><td> </td><td align="left" valign="top">What happens after a recipe execution error.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Interrupts">Interrupts</a></td><td> </td><td align="left" valign="top">What happens when a recipe is interrupted.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Recursion">Recursion</a></td><td> </td><td align="left" valign="top">Invoking <code>make</code> from makefiles.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Canned-Recipes">Canned Recipes</a></td><td> </td><td align="left" valign="top">Defining canned recipes.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Empty-Recipes">Empty Recipes</a></td><td> </td><td align="left" valign="top">Defining useful, do-nothing recipes.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Recipe Syntax
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td><td> </td><td align="left" valign="top">Breaking long recipe lines for readability.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Variables-in-Recipes">Variables in Recipes</a></td><td> </td><td align="left" valign="top">Using <code>make</code> variables in recipes.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Recipe Execution
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#One-Shell">One Shell</a></td><td> </td><td align="left" valign="top">One shell for all lines in a recipe.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Choosing-the-Shell">Choosing the Shell</a></td><td> </td><td align="left" valign="top">How <code>make</code> chooses the shell used
|
|
to run recipes.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Parallel Execution
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Parallel-Disable">Parallel Disable</a></td><td> </td><td align="left" valign="top">Disabling parallel execution
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Parallel-Output">Parallel Output</a></td><td> </td><td align="left" valign="top">Handling output during parallel execution
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Parallel-Input">Parallel Input</a></td><td> </td><td align="left" valign="top">Handling input during parallel execution
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Recursive Use of <code>make</code>
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#MAKE-Variable">MAKE Variable</a></td><td> </td><td align="left" valign="top">The special effects of using ‘<samp>$(MAKE)</samp>’.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Variables_002fRecursion">Variables/Recursion</a></td><td> </td><td align="left" valign="top">How to communicate variables to a sub-<code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Options_002fRecursion">Options/Recursion</a></td><td> </td><td align="left" valign="top">How to communicate options to a sub-<code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#g_t_002dw-Option">-w Option</a></td><td> </td><td align="left" valign="top">How the ‘<samp>-w</samp>’ or ‘<samp>--print-directory</samp>’ option
|
|
helps debug use of recursive <code>make</code> commands.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
How to Use Variables
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Reference">Reference</a></td><td> </td><td align="left" valign="top">How to use the value of a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Flavors">Flavors</a></td><td> </td><td align="left" valign="top">Variables come in two flavors.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Advanced">Advanced</a></td><td> </td><td align="left" valign="top">Advanced features for referencing a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Values">Values</a></td><td> </td><td align="left" valign="top">All the ways variables get their values.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Setting">Setting</a></td><td> </td><td align="left" valign="top">How to set a variable in the makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Appending">Appending</a></td><td> </td><td align="left" valign="top">How to append more text to the old value
|
|
of a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Override-Directive">Override Directive</a></td><td> </td><td align="left" valign="top">How to set a variable in the makefile even if
|
|
the user has set it with a command argument.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Multi_002dLine">Multi-Line</a></td><td> </td><td align="left" valign="top">An alternate way to set a variable
|
|
to a multi-line string.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Undefine-Directive">Undefine Directive</a></td><td> </td><td align="left" valign="top">How to undefine a variable so that it appears
|
|
as if it was never set.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Environment">Environment</a></td><td> </td><td align="left" valign="top">Variable values can come from the environment.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Target_002dspecific">Target-specific</a></td><td> </td><td align="left" valign="top">Variable values can be defined on a per-target
|
|
basis.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Pattern_002dspecific">Pattern-specific</a></td><td> </td><td align="left" valign="top">Target-specific variable values can be applied
|
|
to a group of targets that match a pattern.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Suppressing-Inheritance">Suppressing Inheritance</a></td><td> </td><td align="left" valign="top">Suppress inheritance of variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Special-Variables">Special Variables</a></td><td> </td><td align="left" valign="top">Variables with special meaning or behavior.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
The Two Flavors of Variables
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Recursive-Assignment">Recursive Assignment</a></td><td> </td><td align="left" valign="top">Setting recursively expanded variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Simple-Assignment">Simple Assignment</a></td><td> </td><td align="left" valign="top">Setting simply expanded variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Immediate-Assignment">Immediate Assignment</a></td><td> </td><td align="left" valign="top">Setting immediately expanded variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Conditional-Assignment">Conditional Assignment</a></td><td> </td><td align="left" valign="top">Assigning variable values conditionally.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Advanced Features for Reference to Variables
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Substitution-Refs">Substitution Refs</a></td><td> </td><td align="left" valign="top">Referencing a variable with
|
|
substitutions on the value.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Computed-Names">Computed Names</a></td><td> </td><td align="left" valign="top">Computing the name of the variable to refer to.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Conditional Parts of Makefiles
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Conditional-Example">Conditional Example</a></td><td> </td><td align="left" valign="top">Example of a conditional
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Conditional-Syntax">Conditional Syntax</a></td><td> </td><td align="left" valign="top">The syntax of conditionals.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Testing-Flags">Testing Flags</a></td><td> </td><td align="left" valign="top">Conditionals that test flags.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Functions for Transforming Text
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Syntax-of-Functions">Syntax of Functions</a></td><td> </td><td align="left" valign="top">How to write a function call.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Text-Functions">Text Functions</a></td><td> </td><td align="left" valign="top">General-purpose text manipulation functions.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#File-Name-Functions">File Name Functions</a></td><td> </td><td align="left" valign="top">Functions for manipulating file names.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Conditional-Functions">Conditional Functions</a></td><td> </td><td align="left" valign="top">Functions that implement conditions.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Let-Function">Let Function</a></td><td> </td><td align="left" valign="top">Local variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Foreach-Function">Foreach Function</a></td><td> </td><td align="left" valign="top">Repeat some text with controlled variation.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#File-Function">File Function</a></td><td> </td><td align="left" valign="top">Write text to a file.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Call-Function">Call Function</a></td><td> </td><td align="left" valign="top">Expand a user-defined function.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Value-Function">Value Function</a></td><td> </td><td align="left" valign="top">Return the un-expanded value of a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Eval-Function">Eval Function</a></td><td> </td><td align="left" valign="top">Evaluate the arguments as makefile syntax.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Origin-Function">Origin Function</a></td><td> </td><td align="left" valign="top">Find where a variable got its value.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Flavor-Function">Flavor Function</a></td><td> </td><td align="left" valign="top">Find out the flavor of a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Make-Control-Functions">Make Control Functions</a></td><td> </td><td align="left" valign="top">Functions that control how make runs.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Shell-Function">Shell Function</a></td><td> </td><td align="left" valign="top">Substitute the output of a shell command.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Guile-Function">Guile Function</a></td><td> </td><td align="left" valign="top">Use GNU Guile embedded scripting language.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
How to Run <code>make</code>
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Makefile-Arguments">Makefile Arguments</a></td><td> </td><td align="left" valign="top">How to specify which makefile to use.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Goals">Goals</a></td><td> </td><td align="left" valign="top">How to use goal arguments to specify which
|
|
parts of the makefile to use.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Instead-of-Execution">Instead of Execution</a></td><td> </td><td align="left" valign="top">How to use mode flags to specify what
|
|
kind of thing to do with the recipes
|
|
in the makefile other than simply
|
|
execute them.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Avoiding-Compilation">Avoiding Compilation</a></td><td> </td><td align="left" valign="top">How to avoid recompiling certain files.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Overriding">Overriding</a></td><td> </td><td align="left" valign="top">How to override a variable to specify
|
|
an alternate compiler and other things.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Testing">Testing</a></td><td> </td><td align="left" valign="top">How to proceed past some errors, to
|
|
test compilation.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Temporary-Files">Temporary Files</a></td><td> </td><td align="left" valign="top">Where <code>make</code> keeps its temporary files.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Options-Summary">Options Summary</a></td><td> </td><td align="left" valign="top">Summary of Options
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Using Implicit Rules
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Using-Implicit">Using Implicit</a></td><td> </td><td align="left" valign="top">How to use an existing implicit rule
|
|
to get the recipes for updating a file.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Catalogue-of-Rules">Catalogue of Rules</a></td><td> </td><td align="left" valign="top">A list of built-in rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Implicit-Variables">Implicit Variables</a></td><td> </td><td align="left" valign="top">How to change what predefined rules do.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Chained-Rules">Chained Rules</a></td><td> </td><td align="left" valign="top">How to use a chain of implicit rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Pattern-Rules">Pattern Rules</a></td><td> </td><td align="left" valign="top">How to define new implicit rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Last-Resort">Last Resort</a></td><td> </td><td align="left" valign="top">How to define a recipe for rules which
|
|
cannot find any.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Suffix-Rules">Suffix Rules</a></td><td> </td><td align="left" valign="top">The old-fashioned style of implicit rule.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Implicit-Rule-Search">Implicit Rule Search</a></td><td> </td><td align="left" valign="top">The precise algorithm for applying
|
|
implicit rules.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Defining and Redefining Pattern Rules
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Pattern-Intro">Pattern Intro</a></td><td> </td><td align="left" valign="top">An introduction to pattern rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Pattern-Examples">Pattern Examples</a></td><td> </td><td align="left" valign="top">Examples of pattern rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Automatic-Variables">Automatic Variables</a></td><td> </td><td align="left" valign="top">How to use automatic variables in the
|
|
recipe of implicit rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Pattern-Match">Pattern Match</a></td><td> </td><td align="left" valign="top">How patterns match.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Match_002dAnything-Rules">Match-Anything Rules</a></td><td> </td><td align="left" valign="top">Precautions you should take prior to
|
|
defining rules that can match any
|
|
target file whatever.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Canceling-Rules">Canceling Rules</a></td><td> </td><td align="left" valign="top">How to override or cancel built-in rules.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Using <code>make</code> to Update Archive Files
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Archive-Members">Archive Members</a></td><td> </td><td align="left" valign="top">Archive members as targets.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Archive-Update">Archive Update</a></td><td> </td><td align="left" valign="top">The implicit rule for archive member targets.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Archive-Pitfalls">Archive Pitfalls</a></td><td> </td><td align="left" valign="top">Dangers to watch out for when using archives.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Archive-Suffix-Rules">Archive Suffix Rules</a></td><td> </td><td align="left" valign="top">You can write a special kind of suffix rule
|
|
for updating archives.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Implicit Rule for Archive Member Targets
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Archive-Symbols">Archive Symbols</a></td><td> </td><td align="left" valign="top">How to update archive symbol directories.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Extending GNU <code>make</code>
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Guile-Integration">Guile Integration</a></td><td> </td><td align="left" valign="top">Using Guile as an embedded scripting language.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Loading-Objects">Loading Objects</a></td><td> </td><td align="left" valign="top">Loading dynamic objects as extensions.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
GNU Guile Integration
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Guile-Types">Guile Types</a></td><td> </td><td align="left" valign="top">Converting Guile types to <code>make</code> strings.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Guile-Interface">Guile Interface</a></td><td> </td><td align="left" valign="top">Invoking <code>make</code> functions from Guile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Guile-Example">Guile Example</a></td><td> </td><td align="left" valign="top">Example using Guile in <code>make</code>.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Loading Dynamic Objects
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#load-Directive">load Directive</a></td><td> </td><td align="left" valign="top">Loading dynamic objects as extensions.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Remaking-Loaded-Objects">Remaking Loaded Objects</a></td><td> </td><td align="left" valign="top">How loaded objects get remade.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Loaded-Object-API">Loaded Object API</a></td><td> </td><td align="left" valign="top">Programmatic interface for loaded objects.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Loaded-Object-Example">Loaded Object Example</a></td><td> </td><td align="left" valign="top">Example of a loaded object
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Integrating GNU <code>make</code>
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#Job-Slots">Job Slots</a></td><td> </td><td align="left" valign="top">Share job slots with GNU <code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Terminal-Output">Terminal Output</a></td><td> </td><td align="left" valign="top">Control output to terminals.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
Sharing Job Slots with GNU <code>make</code>
|
|
|
|
</pre></th></tr><tr><td align="left" valign="top">• <a href="#POSIX-Jobserver">POSIX Jobserver</a></td><td> </td><td align="left" valign="top">Using the jobserver on POSIX systems.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Windows-Jobserver">Windows Jobserver</a></td><td> </td><td align="left" valign="top">Using the jobserver on Windows systems.
|
|
</td></tr>
|
|
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
|
|
|
|
</pre></th></tr></table>
|
|
|
|
<hr>
|
|
<span id="Overview"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previous: <a href="#Top" accesskey="p" rel="prev">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Overview-of-make"></span><h2 class="chapter">1 Overview of <code>make</code></h2>
|
|
|
|
<p>The <code>make</code> utility automatically determines which pieces of a large
|
|
program need to be recompiled, and issues commands to recompile them.
|
|
This manual describes GNU <code>make</code>, which was implemented by Richard
|
|
Stallman and Roland McGrath. Development since Version 3.76 has been
|
|
handled by Paul D. Smith.
|
|
</p>
|
|
<p>GNU <code>make</code> conforms to section 6.2 of <cite>IEEE Standard
|
|
1003.2-1992</cite> (POSIX.2).
|
|
<span id="index-POSIX"></span>
|
|
<span id="index-IEEE-Standard-1003_002e2"></span>
|
|
<span id="index-standards-conformance"></span>
|
|
</p>
|
|
<p>Our examples show C programs, since they are most common, but you can use
|
|
<code>make</code> with any programming language whose compiler can be run with a
|
|
shell command. Indeed, <code>make</code> is not limited to programs. You can
|
|
use it to describe any task where some files must be updated automatically
|
|
from others whenever the others change.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Preparing" accesskey="1">Preparing</a></td><td> </td><td align="left" valign="top">Preparing and running <code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Reading" accesskey="2">Reading</a></td><td> </td><td align="left" valign="top">On reading this text.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Bugs" accesskey="3">Bugs</a></td><td> </td><td align="left" valign="top">Problems and bugs.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Preparing"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Reading" accesskey="n" rel="next">Reading</a>, Previous: <a href="#Overview" accesskey="p" rel="prev">Overview</a>, Up: <a href="#Overview" accesskey="u" rel="up">Overview</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<h4 class="node-heading">Preparing</h4>
|
|
<span id="Preparing-and-Running-Make"></span><h3 class="heading">Preparing and Running Make</h3>
|
|
|
|
<p>To prepare to use <code>make</code>, you must write a file called
|
|
the <em>makefile</em> that describes the relationships among files
|
|
in your program and provides commands for updating each file.
|
|
In a program, typically, the executable file is updated from object
|
|
files, which are in turn made by compiling source files.
|
|
</p>
|
|
<p>Once a suitable makefile exists, each time you change some source files,
|
|
this simple shell command:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">make
|
|
</pre></div>
|
|
|
|
<p>suffices to perform all necessary recompilations. The <code>make</code> program
|
|
uses the makefile data base and the last-modification times of the files to
|
|
decide which of the files need to be updated. For each of those files, it
|
|
issues the recipes recorded in the data base.
|
|
</p>
|
|
<p>You can provide command line arguments to <code>make</code> to control which
|
|
files should be recompiled, or how. See <a href="#Running">How to Run
|
|
<code>make</code></a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Reading"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Bugs" accesskey="n" rel="next">Bugs</a>, Previous: <a href="#Preparing" accesskey="p" rel="prev">Preparing</a>, Up: <a href="#Overview" accesskey="u" rel="up">Overview</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-to-Read-This-Manual"></span><h3 class="section">1.1 How to Read This Manual</h3>
|
|
|
|
<p>If you are new to <code>make</code>, or are looking for a general
|
|
introduction, read the first few sections of each chapter, skipping the
|
|
later sections. In each chapter, the first few sections contain
|
|
introductory or general information and the later sections contain
|
|
specialized or technical information.
|
|
The exception is the second chapter, <a href="#Introduction">An
|
|
Introduction to Makefiles</a>, all of which is introductory.
|
|
</p>
|
|
<p>If you are familiar with other <code>make</code> programs, see <a href="#Features">Features of GNU <code>make</code></a>, which lists the enhancements GNU
|
|
<code>make</code> has, and <a href="#Missing">Incompatibilities and Missing
|
|
Features</a>, which explains the few things GNU <code>make</code> lacks that
|
|
others have.
|
|
</p>
|
|
<p>For a quick summary, see <a href="#Options-Summary">Options Summary</a>, <a href="#Quick-Reference">Quick Reference</a>,
|
|
and <a href="#Special-Targets">Special Targets</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Bugs"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Reading" accesskey="p" rel="prev">Reading</a>, Up: <a href="#Overview" accesskey="u" rel="up">Overview</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Problems-and-Bugs"></span><h3 class="section">1.2 Problems and Bugs</h3>
|
|
<span id="index-reporting-bugs"></span>
|
|
<span id="index-bugs_002c-reporting"></span>
|
|
<span id="index-problems-and-bugs_002c-reporting"></span>
|
|
|
|
<p>If you have problems with GNU <code>make</code> or think you’ve found a bug,
|
|
please report it to the developers; we cannot promise to do anything but
|
|
we might well want to fix it.
|
|
</p>
|
|
<p>Before reporting a bug, make sure you’ve actually found a real bug.
|
|
Carefully reread the documentation and see if it really says you can do
|
|
what you’re trying to do. If it’s not clear whether you should be able
|
|
to do something or not, report that too; it’s a bug in the
|
|
documentation!
|
|
</p>
|
|
<p>Before reporting a bug or trying to fix it yourself, try to isolate it
|
|
to the smallest possible makefile that reproduces the problem. Then
|
|
send us the makefile and the exact results <code>make</code> gave you,
|
|
including any error or warning messages. Please don’t paraphrase
|
|
these messages: it’s best to cut and paste them into your report.
|
|
When generating this small makefile, be sure to not use any non-free
|
|
or unusual tools in your recipes: you can almost always emulate what
|
|
such a tool would do with simple shell commands. Finally, be sure to
|
|
explain what you expected to occur; this will help us decide whether
|
|
the problem was really in the documentation.
|
|
</p>
|
|
<p>Once you have a precise problem you can report it in one of two ways.
|
|
Either send electronic mail to:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"> bug-make@gnu.org
|
|
</pre></div>
|
|
|
|
<p>or use our Web-based project management tool, at:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"> https://savannah.gnu.org/projects/make/
|
|
</pre></div>
|
|
|
|
<p>In addition to the information above, please be careful to include the
|
|
version number of <code>make</code> you are using. You can get this
|
|
information with the command ‘<samp>make --version</samp>’. Be sure also to
|
|
include the type of machine and operating system you are using. One
|
|
way to obtain this information is by looking at the final lines of
|
|
output from the command ‘<samp>make --help</samp>’.
|
|
</p>
|
|
<p>If you have a code change you’d like to submit, see the <samp>README</samp> file
|
|
section “Submitting Patches” for information.
|
|
</p>
|
|
<hr>
|
|
<span id="Introduction"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Makefiles" accesskey="n" rel="next">Makefiles</a>, Previous: <a href="#Overview" accesskey="p" rel="prev">Overview</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="An-Introduction-to-Makefiles"></span><h2 class="chapter">2 An Introduction to Makefiles</h2>
|
|
|
|
<p>You need a file called a <em>makefile</em> to tell <code>make</code> what to do.
|
|
Most often, the makefile tells <code>make</code> how to compile and link a
|
|
program.
|
|
<span id="index-makefile"></span>
|
|
</p>
|
|
<p>In this chapter, we will discuss a simple makefile that describes how to
|
|
compile and link a text editor which consists of eight C source files
|
|
and three header files. The makefile can also tell <code>make</code> how to
|
|
run miscellaneous commands when explicitly asked (for example, to remove
|
|
certain files as a clean-up operation). To see a more complex example
|
|
of a makefile, see <a href="#Complex-Makefile">Complex Makefile</a>.
|
|
</p>
|
|
<p>When <code>make</code> recompiles the editor, each changed C source file
|
|
must be recompiled. If a header file has changed, each C source file
|
|
that includes the header file must be recompiled to be safe. Each
|
|
compilation produces an object file corresponding to the source file.
|
|
Finally, if any source file has been recompiled, all the object files,
|
|
whether newly made or saved from previous compilations, must be linked
|
|
together to produce the new executable editor.
|
|
<span id="index-recompilation"></span>
|
|
<span id="index-editor"></span>
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Rule-Introduction" accesskey="1">Rule Introduction</a></td><td> </td><td align="left" valign="top">What a rule looks like.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Simple-Makefile" accesskey="2">Simple Makefile</a></td><td> </td><td align="left" valign="top">A simple makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#How-Make-Works" accesskey="3">How Make Works</a></td><td> </td><td align="left" valign="top">How <code>make</code> processes this makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Variables-Simplify" accesskey="4">Variables Simplify</a></td><td> </td><td align="left" valign="top">Variables make makefiles simpler.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#make-Deduces" accesskey="5">make Deduces</a></td><td> </td><td align="left" valign="top">Letting <code>make</code> deduce the recipes.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Combine-By-Prerequisite" accesskey="6">Combine By Prerequisite</a></td><td> </td><td align="left" valign="top">Another style of makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Cleanup" accesskey="7">Cleanup</a></td><td> </td><td align="left" valign="top">Rules for cleaning the directory.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Rule-Introduction"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Simple-Makefile" accesskey="n" rel="next">Simple Makefile</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="What-a-Rule-Looks-Like"></span><h3 class="section">2.1 What a Rule Looks Like</h3>
|
|
<span id="index-rule_002c-introduction-to"></span>
|
|
<span id="index-makefile-rule-parts"></span>
|
|
<span id="index-parts-of-makefile-rule"></span>
|
|
|
|
<p>A simple makefile consists of “rules” with the following shape:
|
|
</p>
|
|
<span id="index-targets_002c-introduction-to"></span>
|
|
<span id="index-prerequisites_002c-introduction-to"></span>
|
|
<span id="index-recipes_002c-introduction-to"></span>
|
|
<div class="example">
|
|
<pre class="example"><var>target</var> … : <var>prerequisites</var> …
|
|
<var>recipe</var>
|
|
…
|
|
…
|
|
</pre></div>
|
|
|
|
<p>A <em>target</em> is usually the name of a file that is generated by a
|
|
program; examples of targets are executable or object files. A target
|
|
can also be the name of an action to carry out, such as ‘<samp>clean</samp>’
|
|
(see <a href="#Phony-Targets">Phony Targets</a>).
|
|
</p>
|
|
<p>A <em>prerequisite</em> is a file that is used as input to create the
|
|
target. A target often depends on several files.
|
|
</p>
|
|
<span id="index-tabs-in-rules"></span>
|
|
<p>A <em>recipe</em> is an action that <code>make</code> carries out. A recipe
|
|
may have more than one command, either on the same line or each on its
|
|
own line. <strong>Please note:</strong> you need to put a tab character at
|
|
the beginning of every recipe line! This is an obscurity that catches
|
|
the unwary. If you prefer to prefix your recipes with a character
|
|
other than tab, you can set the <code>.RECIPEPREFIX</code> variable to an
|
|
alternate character (see <a href="#Special-Variables">Special Variables</a>).
|
|
</p>
|
|
<p>Usually a recipe is in a rule with prerequisites and serves to create a
|
|
target file if any of the prerequisites change. However, the rule that
|
|
specifies a recipe for the target need not have prerequisites. For
|
|
example, the rule containing the delete command associated with the
|
|
target ‘<samp>clean</samp>’ does not have prerequisites.
|
|
</p>
|
|
<p>A <em>rule</em>, then, explains how and when to remake certain files
|
|
which are the targets of the particular rule. <code>make</code> carries out
|
|
the recipe on the prerequisites to create or update the target. A
|
|
rule can also explain how and when to carry out an action.
|
|
See <a href="#Rules">Writing Rules</a>.
|
|
</p>
|
|
<p>A makefile may contain other text besides rules, but a simple makefile
|
|
need only contain rules. Rules may look somewhat more complicated
|
|
than shown in this template, but all fit the pattern more or less.
|
|
</p>
|
|
<hr>
|
|
<span id="Simple-Makefile"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#How-Make-Works" accesskey="n" rel="next">How Make Works</a>, Previous: <a href="#Rule-Introduction" accesskey="p" rel="prev">Rule Introduction</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="A-Simple-Makefile"></span><h3 class="section">2.2 A Simple Makefile</h3>
|
|
<span id="index-simple-makefile"></span>
|
|
<span id="index-makefile_002c-simple"></span>
|
|
|
|
<p>Here is a straightforward makefile that describes the way an
|
|
executable file called <code>edit</code> depends on eight object files
|
|
which, in turn, depend on eight C source and three header files.
|
|
</p>
|
|
<p>In this example, all the C files include <samp>defs.h</samp>, but only those
|
|
defining editing commands include <samp>command.h</samp>, and only low
|
|
level files that change the editor buffer include <samp>buffer.h</samp>.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">edit : main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
cc -o edit main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
|
|
main.o : main.c defs.h
|
|
cc -c main.c
|
|
kbd.o : kbd.c defs.h command.h
|
|
cc -c kbd.c
|
|
command.o : command.c defs.h command.h
|
|
cc -c command.c
|
|
display.o : display.c defs.h buffer.h
|
|
cc -c display.c
|
|
insert.o : insert.c defs.h buffer.h
|
|
cc -c insert.c
|
|
search.o : search.c defs.h buffer.h
|
|
cc -c search.c
|
|
files.o : files.c defs.h buffer.h command.h
|
|
cc -c files.c
|
|
utils.o : utils.c defs.h
|
|
cc -c utils.c
|
|
clean :
|
|
rm edit main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
</pre></div>
|
|
|
|
<p>We split each long line into two lines using backslash/newline; this is
|
|
like using one long line, but is easier to read. See <a href="#Splitting-Lines">Splitting Long Lines</a>.
|
|
<span id="index-continuation-lines"></span>
|
|
<span id="index-_005c-_0028backslash_0029_002c-for-continuation-lines"></span>
|
|
<span id="index-backslash-_0028_005c_0029_002c-for-continuation-lines"></span>
|
|
<span id="index-quoting-newline_002c-in-makefile"></span>
|
|
<span id="index-newline_002c-quoting_002c-in-makefile"></span>
|
|
</p>
|
|
<p>To use this makefile to create the executable file called <samp>edit</samp>,
|
|
type:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">make
|
|
</pre></div>
|
|
|
|
<p>To use this makefile to delete the executable file and all the object
|
|
files from the directory, type:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">make clean
|
|
</pre></div>
|
|
|
|
<p>In the example makefile, the targets include the executable file
|
|
‘<samp>edit</samp>’, and the object files ‘<samp>main.o</samp>’ and ‘<samp>kbd.o</samp>’. The
|
|
prerequisites are files such as ‘<samp>main.c</samp>’ and ‘<samp>defs.h</samp>’.
|
|
In fact, each ‘<samp>.o</samp>’ file is both a target and a prerequisite.
|
|
Recipes include ‘<samp>cc <span class="nolinebreak">-c</span> main.c</samp>’<!-- /@w --> and ‘<samp>cc <span class="nolinebreak">-c</span> kbd.c</samp>’<!-- /@w -->.
|
|
</p>
|
|
<p>When a target is a file, it needs to be recompiled or relinked if any
|
|
of its prerequisites change. In addition, any prerequisites that are
|
|
themselves automatically generated should be updated first. In this
|
|
example, <samp>edit</samp> depends on each of the eight object files; the
|
|
object file <samp>main.o</samp> depends on the source file <samp>main.c</samp> and
|
|
on the header file <samp>defs.h</samp>.
|
|
</p>
|
|
<p>A recipe may follow each line that contains a target and
|
|
prerequisites. These recipes say how to update the target file. A
|
|
tab character (or whatever character is specified by the
|
|
<code>.RECIPEPREFIX</code> variable; see <a href="#Special-Variables">Special Variables</a>) must come at
|
|
the beginning of every line in the recipe to distinguish recipes from
|
|
other lines in the makefile. (Bear in mind that <code>make</code> does not
|
|
know anything about how the recipes work. It is up to you to supply
|
|
recipes that will update the target file properly. All <code>make</code>
|
|
does is execute the recipe you have specified when the target file
|
|
needs to be updated.)
|
|
<span id="index-recipe"></span>
|
|
</p>
|
|
<p>The target ‘<samp>clean</samp>’ is not a file, but merely the name of an
|
|
action. Since you normally do not want to carry out the actions in
|
|
this rule, ‘<samp>clean</samp>’ is not a prerequisite of any other rule.
|
|
Consequently, <code>make</code> never does anything with it unless you tell
|
|
it specifically. Note that this rule not only is not a prerequisite,
|
|
it also does not have any prerequisites, so the only purpose of the
|
|
rule is to run the specified recipe. Targets that do not refer to
|
|
files but are just actions are called <em>phony targets</em>.
|
|
See <a href="#Phony-Targets">Phony Targets</a>, for information about this kind of target.
|
|
See <a href="#Errors">Errors in Recipes</a>, to see how to cause <code>make</code>
|
|
to ignore errors from <code>rm</code> or any other command.
|
|
<span id="index-clean-target"></span>
|
|
<span id="index-rm-_0028shell-command_0029"></span>
|
|
</p>
|
|
<hr>
|
|
<span id="How-Make-Works"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Variables-Simplify" accesskey="n" rel="next">Variables Simplify</a>, Previous: <a href="#Simple-Makefile" accesskey="p" rel="prev">Simple Makefile</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-make-Processes-a-Makefile"></span><h3 class="section">2.3 How <code>make</code> Processes a Makefile</h3>
|
|
<span id="index-processing-a-makefile"></span>
|
|
<span id="index-makefile_002c-how-make-processes"></span>
|
|
|
|
<p>By default, <code>make</code> starts with the first target (not targets whose names
|
|
start with ‘<samp>.</samp>’ unless they also contain one or more ‘<samp>/</samp>’). This is
|
|
called the <em>default goal</em>. (<em>Goals</em> are the targets that <code>make</code>
|
|
strives ultimately to update. You can override this behavior using the
|
|
command line (see <a href="#Goals">Arguments to Specify the Goals</a>) or with the
|
|
<code>.DEFAULT_GOAL</code> special variable (see <a href="#Special-Variables">Other
|
|
Special Variables</a>).
|
|
<span id="index-default-goal"></span>
|
|
<span id="index-goal_002c-default"></span>
|
|
<span id="index-goal"></span>
|
|
</p>
|
|
<p>In the simple example of the previous section, the default goal is to
|
|
update the executable program <samp>edit</samp>; therefore, we put that rule
|
|
first.
|
|
</p>
|
|
<p>Thus, when you give the command:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">make
|
|
</pre></div>
|
|
|
|
<p><code>make</code> reads the makefile in the current directory and begins by
|
|
processing the first rule. In the example, this rule is for relinking
|
|
<samp>edit</samp>; but before <code>make</code> can fully process this rule, it
|
|
must process the rules for the files that <samp>edit</samp> depends on,
|
|
which in this case are the object files. Each of these files is
|
|
processed according to its own rule. These rules say to update each
|
|
‘<samp>.o</samp>’ file by compiling its source file. The recompilation must
|
|
be done if the source file, or any of the header files named as
|
|
prerequisites, is more recent than the object file, or if the object
|
|
file does not exist.
|
|
</p>
|
|
<p>The other rules are processed because their targets appear as
|
|
prerequisites of the goal. If some other rule is not depended on by the
|
|
goal (or anything it depends on, etc.), that rule is not processed,
|
|
unless you tell <code>make</code> to do so (with a command such as
|
|
<code>make clean</code><!-- /@w -->).
|
|
</p>
|
|
<p>Before recompiling an object file, <code>make</code> considers updating its
|
|
prerequisites, the source file and header files. This makefile does not
|
|
specify anything to be done for them—the ‘<samp>.c</samp>’ and ‘<samp>.h</samp>’ files
|
|
are not the targets of any rules—so <code>make</code> does nothing for these
|
|
files. But <code>make</code> would update automatically generated C programs,
|
|
such as those made by Bison or Yacc, by their own rules at this time.
|
|
</p>
|
|
<p>After recompiling whichever object files need it, <code>make</code> decides
|
|
whether to relink <samp>edit</samp>. This must be done if the file
|
|
<samp>edit</samp> does not exist, or if any of the object files are newer than
|
|
it. If an object file was just recompiled, it is now newer than
|
|
<samp>edit</samp>, so <samp>edit</samp> is relinked.
|
|
<span id="index-relinking"></span>
|
|
</p>
|
|
<p>Thus, if we change the file <samp>insert.c</samp> and run <code>make</code>,
|
|
<code>make</code> will compile that file to update <samp>insert.o</samp>, and then
|
|
link <samp>edit</samp>. If we change the file <samp>command.h</samp> and run
|
|
<code>make</code>, <code>make</code> will recompile the object files <samp>kbd.o</samp>,
|
|
<samp>command.o</samp> and <samp>files.o</samp> and then link the file <samp>edit</samp>.
|
|
</p>
|
|
<hr>
|
|
<span id="Variables-Simplify"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#make-Deduces" accesskey="n" rel="next">make Deduces</a>, Previous: <a href="#How-Make-Works" accesskey="p" rel="prev">How Make Works</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Variables-Make-Makefiles-Simpler"></span><h3 class="section">2.4 Variables Make Makefiles Simpler</h3>
|
|
<span id="index-variables"></span>
|
|
<span id="index-simplifying-with-variables"></span>
|
|
|
|
<p>In our example, we had to list all the object files twice in the rule for
|
|
<samp>edit</samp> (repeated here):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">edit : main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
cc -o edit main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
</pre></div>
|
|
|
|
<span id="index-objects"></span>
|
|
<p>Such duplication is error-prone; if a new object file is added to the
|
|
system, we might add it to one list and forget the other. We can eliminate
|
|
the risk and simplify the makefile by using a variable. <em>Variables</em>
|
|
allow a text string to be defined once and substituted in multiple places
|
|
later (see <a href="#Using-Variables">How to Use Variables</a>).
|
|
</p>
|
|
<span id="index-OBJECTS"></span>
|
|
<span id="index-objs"></span>
|
|
<span id="index-OBJS"></span>
|
|
<span id="index-obj"></span>
|
|
<span id="index-OBJ"></span>
|
|
<p>It is standard practice for every makefile to have a variable named
|
|
<code>objects</code>, <code>OBJECTS</code>, <code>objs</code>, <code>OBJS</code>, <code>obj</code>,
|
|
or <code>OBJ</code> which is a list of all object file names. We would
|
|
define such a variable <code>objects</code> with a line like this in the
|
|
makefile:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
</pre></div>
|
|
|
|
<p>Then, each place we want to put a list of the object file names, we can
|
|
substitute the variable’s value by writing ‘<samp>$(objects)</samp>’
|
|
(see <a href="#Using-Variables">How to Use Variables</a>).
|
|
</p>
|
|
<p>Here is how the complete simple makefile looks when you use a variable
|
|
for the object files:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
|
|
edit : $(objects)
|
|
cc -o edit $(objects)
|
|
main.o : main.c defs.h
|
|
cc -c main.c
|
|
kbd.o : kbd.c defs.h command.h
|
|
cc -c kbd.c
|
|
command.o : command.c defs.h command.h
|
|
cc -c command.c
|
|
display.o : display.c defs.h buffer.h
|
|
cc -c display.c
|
|
insert.o : insert.c defs.h buffer.h
|
|
cc -c insert.c
|
|
search.o : search.c defs.h buffer.h
|
|
cc -c search.c
|
|
files.o : files.c defs.h buffer.h command.h
|
|
cc -c files.c
|
|
utils.o : utils.c defs.h
|
|
cc -c utils.c
|
|
clean :
|
|
rm edit $(objects)
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="make-Deduces"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Combine-By-Prerequisite" accesskey="n" rel="next">Combine By Prerequisite</a>, Previous: <a href="#Variables-Simplify" accesskey="p" rel="prev">Variables Simplify</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Letting-make-Deduce-the-Recipes"></span><h3 class="section">2.5 Letting <code>make</code> Deduce the Recipes</h3>
|
|
<span id="index-deducing-recipes-_0028implicit-rules_0029"></span>
|
|
<span id="index-implicit-rule_002c-introduction-to"></span>
|
|
<span id="index-rule_002c-implicit_002c-introduction-to"></span>
|
|
|
|
<p>It is not necessary to spell out the recipes for compiling the individual
|
|
C source files, because <code>make</code> can figure them out: it has an
|
|
<em>implicit rule</em> for updating a ‘<samp>.o</samp>’ file from a correspondingly
|
|
named ‘<samp>.c</samp>’ file using a ‘<samp>cc -c</samp>’ command. For example, it will
|
|
use the recipe ‘<samp>cc -c main.c -o main.o</samp>’ to compile <samp>main.c</samp> into
|
|
<samp>main.o</samp>. We can therefore omit the recipes from the rules for the
|
|
object files. See <a href="#Implicit-Rules">Using Implicit Rules</a>.
|
|
</p>
|
|
<p>When a ‘<samp>.c</samp>’ file is used automatically in this way, it is also
|
|
automatically added to the list of prerequisites. We can therefore omit
|
|
the ‘<samp>.c</samp>’ files from the prerequisites, provided we omit the recipe.
|
|
</p>
|
|
<p>Here is the entire example, with both of these changes, and a variable
|
|
<code>objects</code> as suggested above:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
|
|
edit : $(objects)
|
|
cc -o edit $(objects)
|
|
|
|
main.o : defs.h
|
|
kbd.o : defs.h command.h
|
|
command.o : defs.h command.h
|
|
display.o : defs.h buffer.h
|
|
insert.o : defs.h buffer.h
|
|
search.o : defs.h buffer.h
|
|
files.o : defs.h buffer.h command.h
|
|
utils.o : defs.h
|
|
|
|
.PHONY : clean
|
|
clean :
|
|
rm edit $(objects)
|
|
</pre></div>
|
|
|
|
<p>This is how we would write the makefile in actual practice. (The
|
|
complications associated with ‘<samp>clean</samp>’ are described elsewhere.
|
|
See <a href="#Phony-Targets">Phony Targets</a>, and <a href="#Errors">Errors in Recipes</a>.)
|
|
</p>
|
|
<p>Because implicit rules are so convenient, they are important. You
|
|
will see them used frequently.
|
|
</p>
|
|
<hr>
|
|
<span id="Combine-By-Prerequisite"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Cleanup" accesskey="n" rel="next">Cleanup</a>, Previous: <a href="#make-Deduces" accesskey="p" rel="prev">make Deduces</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Another-Style-of-Makefile"></span><h3 class="section">2.6 Another Style of Makefile</h3>
|
|
<span id="index-combining-rules-by-prerequisite"></span>
|
|
|
|
<p>When the objects of a makefile are created only by implicit rules, an
|
|
alternative style of makefile is possible. In this style of makefile,
|
|
you group entries by their prerequisites instead of by their targets.
|
|
Here is what one looks like:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = main.o kbd.o command.o display.o \
|
|
insert.o search.o files.o utils.o
|
|
|
|
edit : $(objects)
|
|
cc -o edit $(objects)
|
|
|
|
$(objects) : defs.h
|
|
kbd.o command.o files.o : command.h
|
|
display.o insert.o search.o files.o : buffer.h
|
|
</pre></div>
|
|
|
|
<p>Here <samp>defs.h</samp> is given as a prerequisite of all the object files;
|
|
<samp>command.h</samp> and <samp>buffer.h</samp> are prerequisites of the specific
|
|
object files listed for them.
|
|
</p>
|
|
<p>Whether this is better is a matter of taste: it is more compact, but some
|
|
people dislike it because they find it clearer to put all the information
|
|
about each target in one place.
|
|
</p>
|
|
<hr>
|
|
<span id="Cleanup"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Combine-By-Prerequisite" accesskey="p" rel="prev">Combine By Prerequisite</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Rules-for-Cleaning-the-Directory"></span><h3 class="section">2.7 Rules for Cleaning the Directory</h3>
|
|
<span id="index-cleaning-up"></span>
|
|
<span id="index-removing_002c-to-clean-up"></span>
|
|
|
|
<p>Compiling a program is not the only thing you might want to write rules
|
|
for. Makefiles commonly tell how to do a few other things besides
|
|
compiling a program: for example, how to delete all the object files
|
|
and executables so that the directory is ‘<samp>clean</samp>’.
|
|
</p>
|
|
<span id="index-clean-target-1"></span>
|
|
<p>Here is how we
|
|
could write a <code>make</code> rule for cleaning our example editor:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">clean:
|
|
rm edit $(objects)
|
|
</pre></div>
|
|
|
|
<p>In practice, we might want to write the rule in a somewhat more
|
|
complicated manner to handle unanticipated situations. We would do this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.PHONY : clean
|
|
clean :
|
|
-rm edit $(objects)
|
|
</pre></div>
|
|
|
|
<p>This prevents <code>make</code> from getting confused by an actual file
|
|
called <samp>clean</samp> and causes it to continue in spite of errors from
|
|
<code>rm</code>. (See <a href="#Phony-Targets">Phony Targets</a>, and <a href="#Errors">Errors in
|
|
Recipes</a>.)
|
|
</p>
|
|
<p>A rule such as this should not be placed at the beginning of the
|
|
makefile, because we do not want it to run by default! Thus, in the
|
|
example makefile, we want the rule for <code>edit</code>, which recompiles
|
|
the editor, to remain the default goal.
|
|
</p>
|
|
<p>Since <code>clean</code> is not a prerequisite of <code>edit</code>, this rule will not
|
|
run at all if we give the command ‘<samp>make</samp>’ with no arguments. In
|
|
order to make the rule run, we have to type ‘<samp>make clean</samp>’.
|
|
See <a href="#Running">How to Run <code>make</code></a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Makefiles"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Rules" accesskey="n" rel="next">Rules</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Writing-Makefiles"></span><h2 class="chapter">3 Writing Makefiles</h2>
|
|
|
|
<span id="index-makefile_002c-how-to-write"></span>
|
|
<p>The information that tells <code>make</code> how to recompile a system comes from
|
|
reading a data base called the <em>makefile</em>.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Makefile-Contents" accesskey="1">Makefile Contents</a></td><td> </td><td align="left" valign="top">What makefiles contain.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Makefile-Names" accesskey="2">Makefile Names</a></td><td> </td><td align="left" valign="top">How to name your makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Include" accesskey="3">Include</a></td><td> </td><td align="left" valign="top">How one makefile can use another makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#MAKEFILES-Variable" accesskey="4">MAKEFILES Variable</a></td><td> </td><td align="left" valign="top">The environment can specify extra makefiles.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Remaking-Makefiles" accesskey="5">Remaking Makefiles</a></td><td> </td><td align="left" valign="top">How makefiles get remade.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Overriding-Makefiles" accesskey="6">Overriding Makefiles</a></td><td> </td><td align="left" valign="top">How to override part of one makefile
|
|
with another makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Reading-Makefiles" accesskey="7">Reading Makefiles</a></td><td> </td><td align="left" valign="top">How makefiles are read in.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Parsing-Makefiles" accesskey="8">Parsing Makefiles</a></td><td> </td><td align="left" valign="top">How makefiles are parsed.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Secondary-Expansion" accesskey="9">Secondary Expansion</a></td><td> </td><td align="left" valign="top">How and when secondary expansion is performed.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Makefile-Contents"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Makefile-Names" accesskey="n" rel="next">Makefile Names</a>, Previous: <a href="#Makefiles" accesskey="p" rel="prev">Makefiles</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="What-Makefiles-Contain"></span><h3 class="section">3.1 What Makefiles Contain</h3>
|
|
|
|
<p>Makefiles contain five kinds of things: <em>explicit rules</em>,
|
|
<em>implicit rules</em>, <em>variable definitions</em>, <em>directives</em>,
|
|
and <em>comments</em>. Rules, variables, and directives are described at
|
|
length in later chapters.
|
|
</p>
|
|
<ul>
|
|
<li> <span id="index-rule_002c-explicit_002c-definition-of"></span>
|
|
<span id="index-explicit-rule_002c-definition-of"></span>
|
|
An <em>explicit rule</em> says when and how to remake one or more files,
|
|
called the rule’s <em>targets</em>. It lists the other files that the
|
|
targets depend on, called the <em>prerequisites</em> of the target, and
|
|
may also give a recipe to use to create or update the targets.
|
|
See <a href="#Rules">Writing Rules</a>.
|
|
|
|
</li><li> <span id="index-rule_002c-implicit_002c-definition-of"></span>
|
|
<span id="index-implicit-rule_002c-definition-of"></span>
|
|
An <em>implicit rule</em> says when and how to remake a class of files
|
|
based on their names. It describes how a target may depend on a file
|
|
with a name similar to the target and gives a recipe to create or
|
|
update such a target. See <a href="#Implicit-Rules">Using Implicit Rules</a>.
|
|
|
|
</li><li> <span id="index-variable-definition"></span>
|
|
A <em>variable definition</em> is a line that specifies a text string
|
|
value for a variable that can be substituted into the text later. The
|
|
simple makefile example shows a variable definition for <code>objects</code>
|
|
as a list of all object files (see <a href="#Variables-Simplify">Variables
|
|
Make Makefiles Simpler</a>).
|
|
|
|
</li><li> <span id="index-directive"></span>
|
|
A <em>directive</em> is an instruction for <code>make</code> to do something
|
|
special while reading the makefile. These include:
|
|
|
|
<ul>
|
|
<li> Reading another makefile (see <a href="#Include">Including Other Makefiles</a>).
|
|
|
|
</li><li> Deciding (based on the values of variables) whether to use or
|
|
ignore a part of the makefile (see <a href="#Conditionals">Conditional Parts of Makefiles</a>).
|
|
|
|
</li><li> Defining a variable from a verbatim string containing multiple lines
|
|
(see <a href="#Multi_002dLine">Defining Multi-Line Variables</a>).
|
|
</li></ul>
|
|
|
|
</li><li> <span id="index-comments_002c-in-makefile"></span>
|
|
<span id="index-_0023-_0028comments_0029_002c-in-makefile"></span>
|
|
‘<samp>#</samp>’ in a line of a makefile starts a <em>comment</em>. It and the
|
|
rest of the line are ignored, except that a trailing backslash not
|
|
escaped by another backslash will continue the comment across multiple
|
|
lines. A line containing just a comment (with perhaps spaces before
|
|
it) is effectively blank, and is ignored. If you want a literal
|
|
<code>#</code>, escape it with a backslash (e.g., <code>\#</code>). Comments may
|
|
appear on any line in the makefile, although they are treated
|
|
specially in certain situations.
|
|
|
|
<p>You cannot use comments within variable references or function calls:
|
|
any instance of <code>#</code> will be treated literally (rather than as the
|
|
start of a comment) inside a variable reference or function call.
|
|
</p>
|
|
<p>Comments within a recipe are passed to the shell, just as with any
|
|
other recipe text. The shell decides how to interpret it: whether or
|
|
not this is a comment is up to the shell.
|
|
</p>
|
|
<p>Within a <code>define</code> directive, comments are not ignored during the
|
|
definition of the variable, but rather kept intact in the value of the
|
|
variable. When the variable is expanded they will either be treated
|
|
as <code>make</code> comments or as recipe text, depending on the context in
|
|
which the variable is evaluated.
|
|
</p></li></ul>
|
|
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Splitting-Lines" accesskey="1">Splitting Lines</a></td><td> </td><td align="left" valign="top">Splitting long lines in makefiles
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Splitting-Lines"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Makefile-Contents" accesskey="p" rel="prev">Makefile Contents</a>, Up: <a href="#Makefile-Contents" accesskey="u" rel="up">Makefile Contents</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Splitting-Long-Lines"></span><h4 class="subsection">3.1.1 Splitting Long Lines</h4>
|
|
<span id="index-splitting-long-lines"></span>
|
|
<span id="index-long-lines_002c-splitting"></span>
|
|
<span id="index-backslash-_0028_005c_0029_002c-to-quote-newlines"></span>
|
|
|
|
<p>Makefiles use a “line-based” syntax in which the newline character
|
|
is special and marks the end of a statement. GNU <code>make</code> has no
|
|
limit on the length of a statement line, up to the amount of memory in
|
|
your computer.
|
|
</p>
|
|
<p>However, it is difficult to read lines which are too long to display
|
|
without wrapping or scrolling. So, you can format your makefiles for
|
|
readability by adding newlines into the middle of a statement: you do
|
|
this by escaping the internal newlines with a backslash (<code>\</code>)
|
|
character. Where we need to make a distinction we will refer to
|
|
“physical lines” as a single line ending with a newline (regardless
|
|
of whether it is escaped) and a “logical line” being a complete
|
|
statement including all escaped newlines up to the first non-escaped
|
|
newline.
|
|
</p>
|
|
<p>The way in which backslash/newline combinations are handled depends on
|
|
whether the statement is a recipe line or a non-recipe line. Handling
|
|
of backslash/newline in a recipe line is discussed later
|
|
(see <a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a>).
|
|
</p>
|
|
<p>Outside of recipe lines, backslash/newlines are converted into a
|
|
single space character. Once that is done, all whitespace around the
|
|
backslash/newline is condensed into a single space: this includes all
|
|
whitespace preceding the backslash, all whitespace at the beginning of
|
|
the line after the backslash/newline, and any consecutive
|
|
backslash/newline combinations.
|
|
</p>
|
|
<p>If the <code>.POSIX</code> special target is defined then backslash/newline
|
|
handling is modified slightly to conform to POSIX.2: first, whitespace
|
|
preceding a backslash is not removed and second, consecutive
|
|
backslash/newlines are not condensed.
|
|
</p>
|
|
<span id="Splitting-Without-Adding-Whitespace"></span><h4 class="subsubheading">Splitting Without Adding Whitespace</h4>
|
|
<span id="index-whitespace_002c-avoiding-on-line-split"></span>
|
|
<span id="index-removing-whitespace-from-split-lines"></span>
|
|
|
|
<p>If you need to split a line but do <em>not</em> want any whitespace
|
|
added, you can utilize a subtle trick: replace your backslash/newline
|
|
pairs with the three characters dollar sign, backslash, and newline:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">var := one$\
|
|
word
|
|
</pre></div>
|
|
|
|
<p>After <code>make</code> removes the backslash/newline and condenses the
|
|
following line into a single space, this is equivalent to:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">var := one$ word
|
|
</pre></div>
|
|
|
|
<p>Then <code>make</code> will perform variable expansion. The variable
|
|
reference ‘<samp>$ </samp>’ refers to a variable with the one-character name
|
|
“ ” (space) which does not exist, and so expands to the empty
|
|
string, giving a final assignment which is the equivalent of:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">var := oneword
|
|
</pre></div>
|
|
|
|
|
|
<hr>
|
|
<span id="Makefile-Names"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Include" accesskey="n" rel="next">Include</a>, Previous: <a href="#Makefile-Contents" accesskey="p" rel="prev">Makefile Contents</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="What-Name-to-Give-Your-Makefile"></span><h3 class="section">3.2 What Name to Give Your Makefile</h3>
|
|
<span id="index-makefile-name"></span>
|
|
<span id="index-name-of-makefile"></span>
|
|
<span id="index-default-makefile-name"></span>
|
|
<span id="index-file-name-of-makefile"></span>
|
|
|
|
<p>By default, when <code>make</code> looks for the makefile, it tries the
|
|
following names, in order: <samp>GNUmakefile</samp>, <samp>makefile</samp>
|
|
and <samp>Makefile</samp>.
|
|
<span id="index-Makefile"></span>
|
|
<span id="index-GNUmakefile"></span>
|
|
<span id="index-makefile-1"></span>
|
|
</p>
|
|
<span id="index-README"></span>
|
|
<p>Normally you should call your makefile either <samp>makefile</samp> or
|
|
<samp>Makefile</samp>. (We recommend <samp>Makefile</samp> because it appears
|
|
prominently near the beginning of a directory listing, right near other
|
|
important files such as <samp>README</samp>.) The first name checked,
|
|
<samp>GNUmakefile</samp>, is not recommended for most makefiles. You should
|
|
use this name if you have a makefile that is specific to GNU
|
|
<code>make</code>, and will not be understood by other versions of
|
|
<code>make</code>. Other <code>make</code> programs look for <samp>makefile</samp> and
|
|
<samp>Makefile</samp>, but not <samp>GNUmakefile</samp>.
|
|
</p>
|
|
<p>If <code>make</code> finds none of these names, it does not use any makefile.
|
|
Then you must specify a goal with a command argument, and <code>make</code>
|
|
will attempt to figure out how to remake it using only its built-in
|
|
implicit rules. See <a href="#Implicit-Rules">Using Implicit Rules</a>.
|
|
</p>
|
|
<span id="index-_002df"></span>
|
|
<span id="index-_002d_002dfile"></span>
|
|
<span id="index-_002d_002dmakefile"></span>
|
|
<p>If you want to use a nonstandard name for your makefile, you can specify
|
|
the makefile name with the ‘<samp>-f</samp>’ or ‘<samp>--file</samp>’ option. The
|
|
arguments ‘<samp><span class="nolinebreak">-f</span> <var>name</var></samp>’<!-- /@w --> or ‘<samp><span class="nolinebreak">--file=</span><var>name</var></samp>’<!-- /@w --> tell
|
|
<code>make</code> to read the file <var>name</var> as the makefile. If you use
|
|
more than one ‘<samp>-f</samp>’ or ‘<samp>--file</samp>’ option, you can specify several
|
|
makefiles. All the makefiles are effectively concatenated in the order
|
|
specified. The default makefile names <samp>GNUmakefile</samp>,
|
|
<samp>makefile</samp> and <samp>Makefile</samp> are not checked automatically if you
|
|
specify ‘<samp>-f</samp>’ or ‘<samp>--file</samp>’.
|
|
<span id="index-specifying-makefile-name"></span>
|
|
<span id="index-makefile-name_002c-how-to-specify"></span>
|
|
<span id="index-name-of-makefile_002c-how-to-specify"></span>
|
|
<span id="index-file-name-of-makefile_002c-how-to-specify"></span>
|
|
</p>
|
|
<hr>
|
|
<span id="Include"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#MAKEFILES-Variable" accesskey="n" rel="next">MAKEFILES Variable</a>, Previous: <a href="#Makefile-Names" accesskey="p" rel="prev">Makefile Names</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Including-Other-Makefiles"></span><h3 class="section">3.3 Including Other Makefiles</h3>
|
|
<span id="index-including-other-makefiles"></span>
|
|
<span id="index-makefile_002c-including"></span>
|
|
|
|
<span id="index-include"></span>
|
|
<p>The <code>include</code> directive tells <code>make</code> to suspend reading the
|
|
current makefile and read one or more other makefiles before continuing.
|
|
The directive is a line in the makefile that looks like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">include <var>filenames</var>…
|
|
</pre></div>
|
|
|
|
<p><var>filenames</var> can contain shell file name patterns. If
|
|
<var>filenames</var> is empty, nothing is included and no error is printed.
|
|
<span id="index-shell-file-name-pattern-_0028in-include_0029"></span>
|
|
<span id="index-shell-wildcards-_0028in-include_0029"></span>
|
|
<span id="index-wildcard_002c-in-include"></span>
|
|
</p>
|
|
<p>Extra spaces are allowed and ignored at the beginning of the line, but
|
|
the first character must not be a tab (or the value of
|
|
<code>.RECIPEPREFIX</code>)—if the line begins with a tab, it will be
|
|
considered a recipe line. Whitespace is required between
|
|
<code>include</code> and the file names, and between file names; extra
|
|
whitespace is ignored there and at the end of the directive. A
|
|
comment starting with ‘<samp>#</samp>’ is allowed at the end of the line. If
|
|
the file names contain any variable or function references, they are
|
|
expanded. See <a href="#Using-Variables">How to Use Variables</a>.
|
|
</p>
|
|
<p>For example, if you have three <samp>.mk</samp> files, <samp>a.mk</samp>,
|
|
<samp>b.mk</samp>, and <samp>c.mk</samp>, and <code>$(bar)</code> expands to
|
|
<code>bish bash</code>, then the following expression
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">include foo *.mk $(bar)
|
|
</pre></div>
|
|
|
|
<p>is equivalent to
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">include foo a.mk b.mk c.mk bish bash
|
|
</pre></div>
|
|
|
|
<p>When <code>make</code> processes an <code>include</code> directive, it suspends
|
|
reading of the containing makefile and reads from each listed file in
|
|
turn. When that is finished, <code>make</code> resumes reading the
|
|
makefile in which the directive appears.
|
|
</p>
|
|
<p>One occasion for using <code>include</code> directives is when several programs,
|
|
handled by individual makefiles in various directories, need to use a
|
|
common set of variable definitions
|
|
(see <a href="#Setting">Setting Variables</a>) or pattern rules
|
|
(see <a href="#Pattern-Rules">Defining and Redefining Pattern Rules</a>).
|
|
</p>
|
|
<p>Another such occasion is when you want to generate prerequisites from
|
|
source files automatically; the prerequisites can be put in a file that
|
|
is included by the main makefile. This practice is generally cleaner
|
|
than that of somehow appending the prerequisites to the end of the main
|
|
makefile as has been traditionally done with other versions of
|
|
<code>make</code>. See <a href="#Automatic-Prerequisites">Automatic Prerequisites</a>.
|
|
<span id="index-prerequisites_002c-automatic-generation"></span>
|
|
<span id="index-automatic-generation-of-prerequisites"></span>
|
|
<span id="index-generating-prerequisites-automatically"></span>
|
|
</p>
|
|
<span id="index-_002dI"></span>
|
|
<span id="index-_002d_002dinclude_002ddir"></span>
|
|
<span id="index-included-makefiles_002c-default-directories"></span>
|
|
<span id="index-default-directories-for-included-makefiles"></span>
|
|
<span id="index-_002fusr_002fgnu_002finclude"></span>
|
|
<span id="index-_002fusr_002flocal_002finclude"></span>
|
|
<span id="index-_002fusr_002finclude"></span>
|
|
<p>If the specified name does not start with a slash, and the file is not
|
|
found in the current directory, several other directories are searched.
|
|
First, any directories you have specified with the ‘<samp>-I</samp>’ or
|
|
‘<samp>--include-dir</samp>’ options are searched
|
|
(see <a href="#Options-Summary">Summary of Options</a>).
|
|
Then the following directories (if they exist)
|
|
are searched, in this order:
|
|
<samp><var>prefix</var>/include</samp> (normally <samp>/usr/local/include</samp>
|
|
<a id="DOCF1" href="#FOOT1"><sup>1</sup></a>)
|
|
<samp>/usr/gnu/include</samp>,
|
|
<samp>/usr/local/include</samp>, <samp>/usr/include</samp>.
|
|
</p>
|
|
<p>The <code>.INCLUDE_DIRS</code> variable will contain the current list of
|
|
directories that make will search for included files. See <a href="#Special-Variables">Other Special Variables</a>.
|
|
</p>
|
|
<p>You can avoid searching in these default directories by adding the
|
|
command line option <code>-I</code> with the special value <code>-</code> (e.g.,
|
|
<code>-I-</code>) to the command line. This will cause <code>make</code> to
|
|
forget any already-set include directories, including the default
|
|
directories.
|
|
</p>
|
|
<p>If an included makefile cannot be found in any of these directories it is not
|
|
an immediately fatal error; processing of the makefile containing the
|
|
<code>include</code> continues. Once it has finished reading makefiles, <code>make</code>
|
|
will try to remake any that are out of date or don’t exist. See <a href="#Remaking-Makefiles">How Makefiles Are Remade</a>. Only after it has failed to find a
|
|
rule to remake the makefile, or it found a rule but the recipe failed, will
|
|
<code>make</code> diagnose the missing makefile as a fatal error.
|
|
</p>
|
|
<p>If you want <code>make</code> to simply ignore a makefile which does not exist
|
|
or cannot be remade, with no error message, use the <code><span class="nolinebreak">-include</span></code><!-- /@w -->
|
|
directive instead of <code>include</code>, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">-include <var>filenames</var>…
|
|
</pre></div>
|
|
|
|
<p>This acts like <code>include</code> in every way except that there is no
|
|
error (not even a warning) if any of the <var>filenames</var> (or any
|
|
prerequisites of any of the <var>filenames</var>) do not exist or cannot be
|
|
remade.
|
|
</p>
|
|
<p>For compatibility with some other <code>make</code> implementations,
|
|
<code>sinclude</code> is another name for <code><span class="nolinebreak">-include</span></code><!-- /@w -->.
|
|
</p>
|
|
<hr>
|
|
<span id="MAKEFILES-Variable"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Remaking-Makefiles" accesskey="n" rel="next">Remaking Makefiles</a>, Previous: <a href="#Include" accesskey="p" rel="prev">Include</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-Variable-MAKEFILES"></span><h3 class="section">3.4 The Variable <code>MAKEFILES</code></h3>
|
|
<span id="index-makefile_002c-and-MAKEFILES-variable"></span>
|
|
<span id="index-including-_0028MAKEFILES-variable_0029"></span>
|
|
|
|
<span id="index-MAKEFILES"></span>
|
|
<p>If the environment variable <code>MAKEFILES</code> is defined, <code>make</code>
|
|
considers its value as a list of names (separated by whitespace) of
|
|
additional makefiles to be read before the others. This works much
|
|
like the <code>include</code> directive: various directories are searched
|
|
for those files (see <a href="#Include">Including Other Makefiles</a>). In
|
|
addition, the default goal is never taken from one of these makefiles
|
|
(or any makefile included by them) and it is not an error if the files
|
|
listed in <code>MAKEFILES</code> are not found.
|
|
</p>
|
|
<span id="index-recursion_002c-and-MAKEFILES-variable"></span>
|
|
<p>The main use of <code>MAKEFILES</code> is in communication between recursive
|
|
invocations of <code>make</code> (see <a href="#Recursion">Recursive Use of
|
|
<code>make</code></a>). It usually is not desirable to set the environment
|
|
variable before a top-level invocation of <code>make</code>, because it is
|
|
usually better not to mess with a makefile from outside. However, if
|
|
you are running <code>make</code> without a specific makefile, a makefile in
|
|
<code>MAKEFILES</code> can do useful things to help the built-in implicit
|
|
rules work better, such as defining search paths (see <a href="#Directory-Search">Directory Search</a>).
|
|
</p>
|
|
<p>Some users are tempted to set <code>MAKEFILES</code> in the environment
|
|
automatically on login, and program makefiles to expect this to be done.
|
|
This is a very bad idea, because such makefiles will fail to work if run by
|
|
anyone else. It is much better to write explicit <code>include</code> directives
|
|
in the makefiles. See <a href="#Include">Including Other Makefiles</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Remaking-Makefiles"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Overriding-Makefiles" accesskey="n" rel="next">Overriding Makefiles</a>, Previous: <a href="#MAKEFILES-Variable" accesskey="p" rel="prev">MAKEFILES Variable</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-Makefiles-Are-Remade"></span><h3 class="section">3.5 How Makefiles Are Remade</h3>
|
|
<span id="index-updating-makefiles"></span>
|
|
<span id="index-remaking-makefiles"></span>
|
|
<span id="index-makefile_002c-remaking-of"></span>
|
|
<p>Sometimes makefiles can be remade from other files, such as RCS or SCCS
|
|
files. If a makefile can be remade from other files, you probably want
|
|
<code>make</code> to get an up-to-date version of the makefile to read in.
|
|
</p>
|
|
<p>To this end, after reading in all makefiles <code>make</code> will consider
|
|
each as a goal target, in the order in which they were processed, and
|
|
attempt to update it. If parallel builds (see <a href="#Parallel">Parallel
|
|
Execution</a>) are enabled then makefiles will be rebuilt in parallel as
|
|
well.
|
|
</p>
|
|
<p>If a makefile has a rule which says how to update it (found either in
|
|
that very makefile or in another one) or if an implicit rule applies
|
|
to it (see <a href="#Implicit-Rules">Using Implicit Rules</a>), it will be
|
|
updated if necessary. After all makefiles have been checked, if any
|
|
have actually been changed, <code>make</code> starts with a clean slate and
|
|
reads all the makefiles over again. (It will also attempt to update
|
|
each of them over again, but normally this will not change them again,
|
|
since they are already up to date.) Each restart will cause the
|
|
special variable <code>MAKE_RESTARTS</code> to be updated (see <a href="#Special-Variables">Special Variables</a>).
|
|
</p>
|
|
<p>If you know that one or more of your makefiles cannot be remade and
|
|
you want to keep <code>make</code> from performing an implicit rule search
|
|
on them, perhaps for efficiency reasons, you can use any normal method
|
|
of preventing implicit rule look-up to do so. For example, you can
|
|
write an explicit rule with the makefile as the target, and an empty
|
|
recipe (see <a href="#Empty-Recipes">Using Empty Recipes</a>).
|
|
</p>
|
|
<p>If the makefiles specify a double-colon rule to remake a file with a recipe
|
|
but no prerequisites, that file will always be remade (see <a href="#Double_002dColon">Double-Colon</a>).
|
|
In the case of makefiles, a makefile that has a double-colon rule with a
|
|
recipe but no prerequisites will be remade every time <code>make</code> is run, and
|
|
then again after <code>make</code> starts over and reads the makefiles in again.
|
|
This would cause an infinite loop: <code>make</code> would constantly remake the
|
|
makefile and restart, and never do anything else. So, to avoid this,
|
|
<code>make</code> will <strong>not</strong> attempt to remake makefiles which are specified
|
|
as targets of a double-colon rule with a recipe but no prerequisites.
|
|
</p>
|
|
<p>Phony targets (see <a href="#Phony-Targets">Phony Targets</a>) have the same effect: they are never
|
|
considered up-to-date and so an included file marked as phony would cause
|
|
<code>make</code> to restart continuously. To avoid this <code>make</code> will not
|
|
attempt to remake makefiles which are marked phony.
|
|
</p>
|
|
<p>You can take advantage of this to optimize startup time: if you know you don’t
|
|
need your <samp>Makefile</samp> to be remade you can prevent make from trying to
|
|
remake it by adding either:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.PHONY: Makefile
|
|
</pre></div>
|
|
|
|
<p>or:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">Makefile:: ;
|
|
</pre></div>
|
|
|
|
<p>If you do not specify any makefiles to be read with ‘<samp>-f</samp>’ or
|
|
‘<samp>--file</samp>’ options, <code>make</code> will try the default makefile names;
|
|
see <a href="#Makefile-Names">What Name to Give Your Makefile</a>. Unlike
|
|
makefiles explicitly requested with ‘<samp>-f</samp>’ or ‘<samp>--file</samp>’ options,
|
|
<code>make</code> is not certain that these makefiles should exist. However,
|
|
if a default makefile does not exist but can be created by running
|
|
<code>make</code> rules, you probably want the rules to be run so that the
|
|
makefile can be used.
|
|
</p>
|
|
<p>Therefore, if none of the default makefiles exists, <code>make</code> will
|
|
try to make each of them until it succeeds in making one, or it runs
|
|
out of names to try. Note that it is not an error if <code>make</code>
|
|
cannot find or make any makefile; a makefile is not always
|
|
necessary.
|
|
</p>
|
|
<p>When you use the ‘<samp>-t</samp>’ or ‘<samp>--touch</samp>’ option
|
|
(see <a href="#Instead-of-Execution">Instead of Executing Recipes</a>),
|
|
you would not want to use an out-of-date makefile to decide which
|
|
targets to touch. So the ‘<samp>-t</samp>’ option has no effect on updating
|
|
makefiles; they are really updated even if ‘<samp>-t</samp>’ is specified.
|
|
Likewise, ‘<samp>-q</samp>’ (or ‘<samp>--question</samp>’) and ‘<samp>-n</samp>’ (or
|
|
‘<samp>--just-print</samp>’) do not prevent updating of makefiles, because an
|
|
out-of-date makefile would result in the wrong output for other targets.
|
|
Thus, ‘<samp>make -f mfile -n foo</samp>’ will update <samp>mfile</samp>, read it in,
|
|
and then print the recipe to update <samp>foo</samp> and its prerequisites
|
|
without running it. The recipe printed for <samp>foo</samp> will be the one
|
|
specified in the updated contents of <samp>mfile</samp>.
|
|
</p>
|
|
<p>However, on occasion you might actually wish to prevent updating of even
|
|
the makefiles. You can do this by specifying the makefiles as goals in
|
|
the command line as well as specifying them as makefiles. When the
|
|
makefile name is specified explicitly as a goal, the options ‘<samp>-t</samp>’
|
|
and so on do apply to them.
|
|
</p>
|
|
<p>Thus, ‘<samp>make -f mfile -n mfile foo</samp>’ would read the makefile
|
|
<samp>mfile</samp>, print the recipe needed to update it without actually
|
|
running it, and then print the recipe needed to update <samp>foo</samp>
|
|
without running that. The recipe for <samp>foo</samp> will be the one
|
|
specified by the existing contents of <samp>mfile</samp>.
|
|
</p>
|
|
<hr>
|
|
<span id="Overriding-Makefiles"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Reading-Makefiles" accesskey="n" rel="next">Reading Makefiles</a>, Previous: <a href="#Remaking-Makefiles" accesskey="p" rel="prev">Remaking Makefiles</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Overriding-Part-of-Another-Makefile"></span><h3 class="section">3.6 Overriding Part of Another Makefile</h3>
|
|
|
|
<span id="index-overriding-makefiles"></span>
|
|
<span id="index-makefile_002c-overriding"></span>
|
|
<p>Sometimes it is useful to have a makefile that is mostly just like
|
|
another makefile. You can often use the ‘<samp>include</samp>’ directive to
|
|
include one in the other, and add more targets or variable definitions.
|
|
However, it is invalid for two makefiles to give different recipes for
|
|
the same target. But there is another way.
|
|
</p>
|
|
<span id="index-match_002danything-rule_002c-used-to-override"></span>
|
|
<p>In the containing makefile (the one that wants to include the other),
|
|
you can use a match-anything pattern rule to say that to remake any
|
|
target that cannot be made from the information in the containing
|
|
makefile, <code>make</code> should look in another makefile.
|
|
See <a href="#Pattern-Rules">Pattern Rules</a>, for more information on pattern rules.
|
|
</p>
|
|
<p>For example, if you have a makefile called <samp>Makefile</samp> that says how
|
|
to make the target ‘<samp>foo</samp>’ (and other targets), you can write a
|
|
makefile called <samp>GNUmakefile</samp> that contains:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo:
|
|
frobnicate > foo
|
|
|
|
%: force
|
|
@$(MAKE) -f Makefile $@
|
|
force: ;
|
|
</pre></div>
|
|
|
|
<p>If you say ‘<samp>make foo</samp>’, <code>make</code> will find <samp>GNUmakefile</samp>,
|
|
read it, and see that to make <samp>foo</samp>, it needs to run the recipe
|
|
‘<samp>frobnicate > foo</samp>’. If you say ‘<samp>make bar</samp>’, <code>make</code> will
|
|
find no way to make <samp>bar</samp> in <samp>GNUmakefile</samp>, so it will use the
|
|
recipe from the pattern rule: ‘<samp>make -f Makefile bar</samp>’. If
|
|
<samp>Makefile</samp> provides a rule for updating <samp>bar</samp>, <code>make</code>
|
|
will apply the rule. And likewise for any other target that
|
|
<samp>GNUmakefile</samp> does not say how to make.
|
|
</p>
|
|
<p>The way this works is that the pattern rule has a pattern of just
|
|
‘<samp>%</samp>’, so it matches any target whatever. The rule specifies a
|
|
prerequisite <samp>force</samp>, to guarantee that the recipe will be run even
|
|
if the target file already exists. We give the <samp>force</samp> target an
|
|
empty recipe to prevent <code>make</code> from searching for an implicit rule to
|
|
build it—otherwise it would apply the same match-anything rule to
|
|
<samp>force</samp> itself and create a prerequisite loop!
|
|
</p>
|
|
<hr>
|
|
<span id="Reading-Makefiles"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Parsing-Makefiles" accesskey="n" rel="next">Parsing Makefiles</a>, Previous: <a href="#Overriding-Makefiles" accesskey="p" rel="prev">Overriding Makefiles</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-make-Reads-a-Makefile"></span><h3 class="section">3.7 How <code>make</code> Reads a Makefile</h3>
|
|
<span id="index-reading-makefiles"></span>
|
|
<span id="index-makefile_002c-reading"></span>
|
|
|
|
<p>GNU <code>make</code> does its work in two distinct phases. During the
|
|
first phase it reads all the makefiles, included makefiles, etc. and
|
|
internalizes all the variables and their values and implicit and
|
|
explicit rules, and builds a dependency graph of all the targets and
|
|
their prerequisites. During the second phase, <code>make</code> uses this
|
|
internalized data to determine which targets need to be updated and
|
|
run the recipes necessary to update them.
|
|
</p>
|
|
<p>It’s important to understand this two-phase approach because it has a
|
|
direct impact on how variable and function expansion happens; this is
|
|
often a source of some confusion when writing makefiles. Below is a
|
|
summary of the different constructs that can be found in a makefile,
|
|
and the phase in which expansion happens for each part of the
|
|
construct.
|
|
</p>
|
|
<p>We say that expansion is <em>immediate</em> if it happens during the
|
|
first phase: <code>make</code> will expand that part of the construct as the
|
|
makefile is parsed. We say that expansion is <em>deferred</em> if it is
|
|
not immediate. Expansion of a deferred construct part is delayed
|
|
until the expansion is used: either when it is referenced in an
|
|
immediate context, or when it is needed during the second phase.
|
|
</p>
|
|
<p>You may not be familiar with some of these constructs yet. You can
|
|
reference this section as you become familiar with them, in later
|
|
chapters.
|
|
</p>
|
|
<span id="Variable-Assignment"></span><h4 class="subheading">Variable Assignment</h4>
|
|
<span id="index-_002b_003d_002c-expansion"></span>
|
|
<span id="index-_003d_002c-expansion"></span>
|
|
<span id="index-_003f_003d_002c-expansion"></span>
|
|
<span id="index-_002b_003d_002c-expansion-1"></span>
|
|
<span id="index-_0021_003d_002c-expansion"></span>
|
|
<span id="index-define_002c-expansion"></span>
|
|
|
|
<p>Variable definitions are parsed as follows:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>immediate</var> = <var>deferred</var>
|
|
<var>immediate</var> ?= <var>deferred</var>
|
|
<var>immediate</var> := <var>immediate</var>
|
|
<var>immediate</var> ::= <var>immediate</var>
|
|
<var>immediate</var> :::= <var>immediate-with-escape</var>
|
|
<var>immediate</var> += <var>deferred</var> or <var>immediate</var>
|
|
<var>immediate</var> != <var>immediate</var>
|
|
|
|
define <var>immediate</var>
|
|
<var>deferred</var>
|
|
endef
|
|
|
|
define <var>immediate</var> =
|
|
<var>deferred</var>
|
|
endef
|
|
|
|
define <var>immediate</var> ?=
|
|
<var>deferred</var>
|
|
endef
|
|
|
|
define <var>immediate</var> :=
|
|
<var>immediate</var>
|
|
endef
|
|
|
|
define <var>immediate</var> ::=
|
|
<var>immediate</var>
|
|
endef
|
|
|
|
define <var>immediate</var> :::=
|
|
<var>immediate-with-escape</var>
|
|
endef
|
|
|
|
define <var>immediate</var> +=
|
|
<var>deferred</var> or <var>immediate</var>
|
|
endef
|
|
|
|
define <var>immediate</var> !=
|
|
<var>immediate</var>
|
|
endef
|
|
</pre></div>
|
|
|
|
<p>For the append operator ‘<samp>+=</samp>’, the right-hand side is considered
|
|
immediate if the variable was previously set as a simple variable
|
|
(‘<samp>:=</samp>’ or ‘<samp>::=</samp>’), and deferred otherwise.
|
|
</p>
|
|
<p>For the <var>immediate-with-escape</var> operator ‘<samp>:::=</samp>’, the value on
|
|
the right-hand side is immediately expanded but then escaped (that is,
|
|
all instances of <code>$</code> in the result of the expansion are replaced
|
|
with <code>$$</code>).
|
|
</p>
|
|
<p>For the shell assignment operator ‘<samp>!=</samp>’, the right-hand side is
|
|
evaluated immediately and handed to the shell. The result is stored
|
|
in the variable named on the left, and that variable is considered a
|
|
recursively expanded variable (and will thus be re-evaluated on each
|
|
reference).
|
|
</p>
|
|
<span id="Conditional-Directives"></span><h4 class="subheading">Conditional Directives</h4>
|
|
<span id="index-ifdef_002c-expansion"></span>
|
|
<span id="index-ifeq_002c-expansion"></span>
|
|
<span id="index-ifndef_002c-expansion"></span>
|
|
<span id="index-ifneq_002c-expansion"></span>
|
|
|
|
<p>Conditional directives are parsed immediately. This means, for
|
|
example, that automatic variables cannot be used in conditional
|
|
directives, as automatic variables are not set until the recipe for
|
|
that rule is invoked. If you need to use automatic variables in a
|
|
conditional directive you <em>must</em> move the condition into the
|
|
recipe and use shell conditional syntax instead.
|
|
</p>
|
|
<span id="Rule-Definition"></span><h4 class="subheading">Rule Definition</h4>
|
|
<span id="index-target_002c-expansion"></span>
|
|
<span id="index-prerequisite_002c-expansion"></span>
|
|
<span id="index-implicit-rule_002c-expansion"></span>
|
|
<span id="index-pattern-rule_002c-expansion"></span>
|
|
<span id="index-explicit-rule_002c-expansion"></span>
|
|
|
|
<p>A rule is always expanded the same way, regardless of the form:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>immediate</var> : <var>immediate</var> ; <var>deferred</var>
|
|
<var>deferred</var>
|
|
</pre></div>
|
|
|
|
<p>That is, the target and prerequisite sections are expanded
|
|
immediately, and the recipe used to build the target is always
|
|
deferred. This is true for explicit rules, pattern rules, suffix
|
|
rules, static pattern rules, and simple prerequisite definitions.
|
|
</p>
|
|
<hr>
|
|
<span id="Parsing-Makefiles"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Secondary-Expansion" accesskey="n" rel="next">Secondary Expansion</a>, Previous: <a href="#Reading-Makefiles" accesskey="p" rel="prev">Reading Makefiles</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-Makefiles-Are-Parsed"></span><h3 class="section">3.8 How Makefiles Are Parsed</h3>
|
|
<span id="index-parsing-makefiles"></span>
|
|
<span id="index-makefiles_002c-parsing"></span>
|
|
|
|
<p>GNU <code>make</code> parses makefiles line-by-line. Parsing proceeds using
|
|
the following steps:
|
|
</p>
|
|
<ol>
|
|
<li> Read in a full logical line, including backslash-escaped lines
|
|
(see <a href="#Splitting-Lines">Splitting Long Lines</a>).
|
|
|
|
</li><li> Remove comments (see <a href="#Makefile-Contents">What Makefiles Contain</a>).
|
|
|
|
</li><li> If the line begins with the recipe prefix character and we are in a
|
|
rule context, add the line to the current recipe and read the next
|
|
line (see <a href="#Recipe-Syntax">Recipe Syntax</a>).
|
|
|
|
</li><li> Expand elements of the line which appear in an <em>immediate</em>
|
|
expansion context (see <a href="#Reading-Makefiles">How <code>make</code> Reads a
|
|
Makefile</a>).
|
|
|
|
</li><li> Scan the line for a separator character, such as ‘<samp>:</samp>’ or ‘<samp>=</samp>’,
|
|
to determine whether the line is a macro assignment or a rule
|
|
(see <a href="#Recipe-Syntax">Recipe Syntax</a>).
|
|
|
|
</li><li> Internalize the resulting operation and read the next line.
|
|
</li></ol>
|
|
|
|
<p>An important consequence of this is that a macro can expand to an
|
|
entire rule, <em>if it is one line long</em>. This will work:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">myrule = target : ; echo built
|
|
|
|
$(myrule)
|
|
</pre></div>
|
|
|
|
<p>However, this will not work because <code>make</code> does not re-split lines
|
|
after it has expanded them:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">define myrule
|
|
target:
|
|
echo built
|
|
endef
|
|
|
|
$(myrule)
|
|
</pre></div>
|
|
|
|
<p>The above makefile results in the definition of a target ‘<samp>target</samp>’
|
|
with prerequisites ‘<samp>echo</samp>’ and ‘<samp>built</samp>’, as if the makefile
|
|
contained <code>target: echo built</code>, rather than a rule with a recipe.
|
|
Newlines still present in a line after expansion is complete are
|
|
ignored as normal whitespace.
|
|
</p>
|
|
<p>In order to properly expand a multi-line macro you must use the
|
|
<code>eval</code> function: this causes the <code>make</code> parser to be run on
|
|
the results of the expanded macro (see <a href="#Eval-Function">Eval Function</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Secondary-Expansion"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Parsing-Makefiles" accesskey="p" rel="prev">Parsing Makefiles</a>, Up: <a href="#Makefiles" accesskey="u" rel="up">Makefiles</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Secondary-Expansion-1"></span><h3 class="section">3.9 Secondary Expansion</h3>
|
|
<span id="index-secondary-expansion"></span>
|
|
<span id="index-expansion_002c-secondary"></span>
|
|
|
|
<span id="index-_002eSECONDEXPANSION"></span>
|
|
<p>Previously we learned that GNU <code>make</code> works in two distinct
|
|
phases: a read-in phase and a target-update phase (see <a href="#Reading-Makefiles">How <code>make</code> Reads a Makefile</a>). GNU make also has
|
|
the ability to enable a <em>second expansion</em> of the prerequisites
|
|
(only) for some or all targets defined in the makefile. In order for
|
|
this second expansion to occur, the special target
|
|
<code>.SECONDEXPANSION</code> must be defined before the first prerequisite
|
|
list that makes use of this feature.
|
|
</p>
|
|
<p>If <code>.SECONDEXPANSION</code> is defined then when GNU <code>make</code> needs to check
|
|
the prerequisites of a target, the prerequisites are expanded a <em>second
|
|
time</em>. In most circumstances this secondary expansion will have no effect,
|
|
since all variable and function references will have been expanded during the
|
|
initial parsing of the makefiles. In order to take advantage of the secondary
|
|
expansion phase of the parser, then, it’s necessary to <em>escape</em> the
|
|
variable or function reference in the makefile. In this case the first
|
|
expansion merely un-escapes the reference but doesn’t expand it, and expansion
|
|
is left to the secondary expansion phase. For example, consider this
|
|
makefile:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SECONDEXPANSION:
|
|
ONEVAR = onefile
|
|
TWOVAR = twofile
|
|
myfile: $(ONEVAR) $$(TWOVAR)
|
|
</pre></div>
|
|
|
|
<p>After the first expansion phase the prerequisites list of the
|
|
<samp>myfile</samp> target will be <code>onefile</code> and <code>$(TWOVAR)</code>; the
|
|
first (unescaped) variable reference to <var>ONEVAR</var> is expanded,
|
|
while the second (escaped) variable reference is simply unescaped,
|
|
without being recognized as a variable reference. Now during the
|
|
secondary expansion the first word is expanded again but since it
|
|
contains no variable or function references it remains the value
|
|
<samp>onefile</samp>, while the second word is now a normal reference to the
|
|
variable <var>TWOVAR</var>, which is expanded to the value <samp>twofile</samp>.
|
|
The final result is that there are two prerequisites, <samp>onefile</samp>
|
|
and <samp>twofile</samp>.
|
|
</p>
|
|
<p>Obviously, this is not a very interesting case since the same result
|
|
could more easily have been achieved simply by having both variables
|
|
appear, unescaped, in the prerequisites list. One difference becomes
|
|
apparent if the variables are reset; consider this example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SECONDEXPANSION:
|
|
AVAR = top
|
|
onefile: $(AVAR)
|
|
twofile: $$(AVAR)
|
|
AVAR = bottom
|
|
</pre></div>
|
|
|
|
<p>Here the prerequisite of <samp>onefile</samp> will be expanded immediately,
|
|
and resolve to the value <samp>top</samp>, while the prerequisite of
|
|
<samp>twofile</samp> will not be full expanded until the secondary expansion
|
|
and yield a value of <samp>bottom</samp>.
|
|
</p>
|
|
<p>This is marginally more exciting, but the true power of this feature
|
|
only becomes apparent when you discover that secondary expansions
|
|
always take place within the scope of the automatic variables for that
|
|
target. This means that you can use variables such as <code>$@</code>,
|
|
<code>$*</code>, etc. during the second expansion and they will have their
|
|
expected values, just as in the recipe. All you have to do is defer
|
|
the expansion by escaping the <code>$</code>. Also, secondary expansion
|
|
occurs for both explicit and implicit (pattern) rules. Knowing this,
|
|
the possible uses for this feature increase dramatically. For
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SECONDEXPANSION:
|
|
main_OBJS := main.o try.o test.o
|
|
lib_OBJS := lib.o api.o
|
|
|
|
main lib: $$($$@_OBJS)
|
|
</pre></div>
|
|
|
|
<p>Here, after the initial expansion the prerequisites of both the
|
|
<samp>main</samp> and <samp>lib</samp> targets will be <code>$($@_OBJS)</code>. During
|
|
the secondary expansion, the <code>$@</code> variable is set to the name of
|
|
the target and so the expansion for the <samp>main</samp> target will yield
|
|
<code>$(main_OBJS)</code>, or <code>main.o try.o test.o</code>, while the
|
|
secondary expansion for the <samp>lib</samp> target will yield
|
|
<code>$(lib_OBJS)</code>, or <code>lib.o api.o</code>.
|
|
</p>
|
|
<p>You can also mix in functions here, as long as they are properly escaped:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">main_SRCS := main.c try.c test.c
|
|
lib_SRCS := lib.c api.c
|
|
|
|
.SECONDEXPANSION:
|
|
main lib: $$(patsubst %.c,%.o,$$($$@_SRCS))
|
|
</pre></div>
|
|
|
|
<p>This version allows users to specify source files rather than object
|
|
files, but gives the same resulting prerequisites list as the previous
|
|
example.
|
|
</p>
|
|
<p>Evaluation of automatic variables during the secondary expansion
|
|
phase, especially of the target name variable <code>$$@</code>, behaves
|
|
similarly to evaluation within recipes. However, there are some
|
|
subtle differences and “corner cases” which come into play for the
|
|
different types of rule definitions that <code>make</code> understands. The
|
|
subtleties of using the different automatic variables are described
|
|
below.
|
|
</p>
|
|
<span id="Secondary-Expansion-of-Explicit-Rules"></span><h4 class="subheading">Secondary Expansion of Explicit Rules</h4>
|
|
<span id="index-secondary-expansion-and-explicit-rules"></span>
|
|
<span id="index-explicit-rules_002c-secondary-expansion-of"></span>
|
|
|
|
<p>During the secondary expansion of explicit rules, <code>$$@</code> and
|
|
<code>$$%</code> evaluate, respectively, to the file name of the target and,
|
|
when the target is an archive member, the target member name. The
|
|
<code>$$<</code> variable evaluates to the first prerequisite in the first
|
|
rule for this target. <code>$$^</code> and <code>$$+</code> evaluate to the list
|
|
of all prerequisites of rules <em>that have already appeared</em> for
|
|
the same target (<code>$$+</code> with repetitions and <code>$$^</code>
|
|
without). The following example will help illustrate these behaviors:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SECONDEXPANSION:
|
|
|
|
foo: foo.1 bar.1 $$< $$^ $$+ # line #1
|
|
|
|
foo: foo.2 bar.2 $$< $$^ $$+ # line #2
|
|
|
|
foo: foo.3 bar.3 $$< $$^ $$+ # line #3
|
|
</pre></div>
|
|
|
|
<p>In the first prerequisite list, all three variables (<code>$$<</code>,
|
|
<code>$$^</code>, and <code>$$+</code>) expand to the empty string. In the
|
|
second, they will have values <code>foo.1</code>, <code>foo.1 bar.1</code>, and
|
|
<code>foo.1 bar.1</code> respectively. In the third they will have values
|
|
<code>foo.1</code>, <code>foo.1 bar.1 foo.2 bar.2</code>, and <code>foo.1 bar.1
|
|
foo.2 bar.2 foo.1 foo.1 bar.1 foo.1 bar.1</code> respectively.
|
|
</p>
|
|
<p>Rules undergo secondary expansion in makefile order, except that
|
|
the rule with the recipe is always evaluated last.
|
|
</p>
|
|
<p>The variables <code>$$?</code> and <code>$$*</code> are not available and expand
|
|
to the empty string.
|
|
</p>
|
|
<span id="Secondary-Expansion-of-Static-Pattern-Rules"></span><h4 class="subheading">Secondary Expansion of Static Pattern Rules</h4>
|
|
<span id="index-secondary-expansion-and-static-pattern-rules"></span>
|
|
<span id="index-static-pattern-rules_002c-secondary-expansion-of"></span>
|
|
|
|
<p>Rules for secondary expansion of static pattern rules are identical to
|
|
those for explicit rules, above, with one exception: for static
|
|
pattern rules the <code>$$*</code> variable is set to the pattern stem. As
|
|
with explicit rules, <code>$$?</code> is not available and expands to the
|
|
empty string.
|
|
</p>
|
|
<span id="Secondary-Expansion-of-Implicit-Rules"></span><h4 class="subheading">Secondary Expansion of Implicit Rules</h4>
|
|
<span id="index-secondary-expansion-and-implicit-rules"></span>
|
|
<span id="index-implicit-rules_002c-secondary-expansion-of"></span>
|
|
|
|
<p>As <code>make</code> searches for an implicit rule, it substitutes the stem
|
|
and then performs secondary expansion for every rule with a matching
|
|
target pattern. The value of the automatic variables is derived in
|
|
the same fashion as for static pattern rules. As an example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SECONDEXPANSION:
|
|
|
|
foo: bar
|
|
|
|
foo foz: fo%: bo%
|
|
|
|
%oo: $$< $$^ $$+ $$*
|
|
</pre></div>
|
|
|
|
<p>When the implicit rule is tried for target <samp>foo</samp>, <code>$$<</code>
|
|
expands to <samp>bar</samp>, <code>$$^</code> expands to <samp>bar boo</samp>,
|
|
<code>$$+</code> also expands to <samp>bar boo</samp>, and <code>$$*</code> expands to
|
|
<samp>f</samp>.
|
|
</p>
|
|
<p>Note that the directory prefix (D), as described in <a href="#Implicit-Rule-Search">Implicit Rule Search Algorithm</a>, is appended (after
|
|
expansion) to all the patterns in the prerequisites list. As an
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SECONDEXPANSION:
|
|
|
|
/tmp/foo.o:
|
|
|
|
%.o: $$(addsuffix /%.c,foo bar) foo.h
|
|
@echo $^
|
|
</pre></div>
|
|
|
|
<p>The prerequisite list printed, after the secondary expansion and
|
|
directory prefix reconstruction, will be <samp>/tmp/foo/foo.c
|
|
/tmp/bar/foo.c foo.h</samp>. If you are not interested in this
|
|
reconstruction, you can use <code>$$*</code> instead of <code>%</code> in the
|
|
prerequisites list.
|
|
</p>
|
|
<hr>
|
|
<span id="Rules"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Recipes" accesskey="n" rel="next">Recipes</a>, Previous: <a href="#Makefiles" accesskey="p" rel="prev">Makefiles</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Writing-Rules"></span><h2 class="chapter">4 Writing Rules</h2>
|
|
<span id="index-writing-rules"></span>
|
|
<span id="index-rule_002c-how-to-write"></span>
|
|
<span id="index-target"></span>
|
|
<span id="index-prerequisite"></span>
|
|
|
|
<p>A <em>rule</em> appears in the makefile and says when and how to remake
|
|
certain files, called the rule’s <em>targets</em> (most often only one per rule).
|
|
It lists the other files that are the <em>prerequisites</em> of the target, and
|
|
the <em>recipe</em> to use to create or update the target.
|
|
</p>
|
|
<span id="index-default-goal-1"></span>
|
|
<span id="index-goal_002c-default-1"></span>
|
|
<p>The order of rules is not significant, except for determining the <em>default
|
|
goal</em>: the target for <code>make</code> to consider, if you do not otherwise specify
|
|
one. The default goal is the first target of the first rule in the first
|
|
makefile. There are two exceptions: a target starting with a period is not a
|
|
default unless it also contains one or more slashes, ‘<samp>/</samp>’; and, a target
|
|
that defines a pattern rule has no effect on the default goal. (See <a href="#Pattern-Rules">Defining and Redefining Pattern Rules</a>.)
|
|
</p>
|
|
<p>Therefore, we usually write the makefile so that the first rule is the
|
|
one for compiling the entire program or all the programs described by
|
|
the makefile (often with a target called ‘<samp>all</samp>’).
|
|
See <a href="#Goals">Arguments to Specify the Goals</a>.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Rule-Example" accesskey="1">Rule Example</a></td><td> </td><td align="left" valign="top">An example explained.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Rule-Syntax" accesskey="2">Rule Syntax</a></td><td> </td><td align="left" valign="top">General syntax explained.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Prerequisite-Types" accesskey="3">Prerequisite Types</a></td><td> </td><td align="left" valign="top">There are two types of prerequisites.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Wildcards" accesskey="4">Wildcards</a></td><td> </td><td align="left" valign="top">Using wildcard characters such as ‘*’.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Directory-Search" accesskey="5">Directory Search</a></td><td> </td><td align="left" valign="top">Searching other directories for source files.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Phony-Targets" accesskey="6">Phony Targets</a></td><td> </td><td align="left" valign="top">Using a target that is not a real file’s name.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Force-Targets" accesskey="7">Force Targets</a></td><td> </td><td align="left" valign="top">You can use a target without a recipe
|
|
or prerequisites to mark other targets
|
|
as phony.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Empty-Targets" accesskey="8">Empty Targets</a></td><td> </td><td align="left" valign="top">When only the date matters and the
|
|
files are empty.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Special-Targets" accesskey="9">Special Targets</a></td><td> </td><td align="left" valign="top">Targets with special built-in meanings.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Multiple-Targets">Multiple Targets</a></td><td> </td><td align="left" valign="top">When to make use of several targets in a rule.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Multiple-Rules">Multiple Rules</a></td><td> </td><td align="left" valign="top">How to use several rules with the same target.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Static-Pattern">Static Pattern</a></td><td> </td><td align="left" valign="top">Static pattern rules apply to multiple targets
|
|
and can vary the prerequisites according to
|
|
the target name.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Double_002dColon">Double-Colon</a></td><td> </td><td align="left" valign="top">How to use a special kind of rule to allow
|
|
several independent rules for one target.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td><td> </td><td align="left" valign="top">How to automatically generate rules giving
|
|
prerequisites from source files themselves.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Rule-Example"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Rule-Syntax" accesskey="n" rel="next">Rule Syntax</a>, Previous: <a href="#Rules" accesskey="p" rel="prev">Rules</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Rule-Example-1"></span><h3 class="section">4.1 Rule Example</h3>
|
|
|
|
<p>Here is an example of a rule:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.o : foo.c defs.h # module for twiddling the frobs
|
|
cc -c -g foo.c
|
|
</pre></div>
|
|
|
|
<p>Its target is <samp>foo.o</samp> and its prerequisites are <samp>foo.c</samp> and
|
|
<samp>defs.h</samp>. It has one command in the recipe: ‘<samp>cc -c -g foo.c</samp>’.
|
|
The recipe starts with a tab to identify it as a recipe.
|
|
</p>
|
|
<p>This rule says two things:
|
|
</p>
|
|
<ul>
|
|
<li> How to decide whether <samp>foo.o</samp> is out of date: it is out of date
|
|
if it does not exist, or if either <samp>foo.c</samp> or <samp>defs.h</samp> is
|
|
more recent than it.
|
|
|
|
</li><li> How to update the file <samp>foo.o</samp>: by running <code>cc</code> as stated.
|
|
The recipe does not explicitly mention <samp>defs.h</samp>, but we presume
|
|
that <samp>foo.c</samp> includes it, and that is why <samp>defs.h</samp> was added
|
|
to the prerequisites.
|
|
</li></ul>
|
|
|
|
<hr>
|
|
<span id="Rule-Syntax"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Prerequisite-Types" accesskey="n" rel="next">Prerequisite Types</a>, Previous: <a href="#Rule-Example" accesskey="p" rel="prev">Rule Example</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Rule-Syntax-1"></span><h3 class="section">4.2 Rule Syntax</h3>
|
|
|
|
<span id="index-rule-syntax"></span>
|
|
<span id="index-syntax-of-rules"></span>
|
|
<p>In general, a rule looks like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>targets</var> : <var>prerequisites</var>
|
|
<var>recipe</var>
|
|
…
|
|
</pre></div>
|
|
|
|
<p>or like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>targets</var> : <var>prerequisites</var> ; <var>recipe</var>
|
|
<var>recipe</var>
|
|
…
|
|
</pre></div>
|
|
|
|
<span id="index-targets"></span>
|
|
<span id="index-rule-targets"></span>
|
|
<p>The <var>targets</var> are file names, separated by spaces. Wildcard
|
|
characters may be used (see <a href="#Wildcards">Using Wildcard Characters
|
|
in File Names</a>) and a name of the form <samp><var>a</var>(<var>m</var>)</samp>
|
|
represents member <var>m</var> in archive file <var>a</var>
|
|
(see <a href="#Archive-Members">Archive Members as Targets</a>).
|
|
Usually there is only one
|
|
target per rule, but occasionally there is a reason to have more
|
|
(see <a href="#Multiple-Targets">Multiple Targets in a Rule</a>).
|
|
</p>
|
|
<span id="index-recipes"></span>
|
|
<span id="index-tab-character-_0028in-commands_0029"></span>
|
|
<p>The <var>recipe</var> lines start with a tab character (or the first
|
|
character in the value of the <code>.RECIPEPREFIX</code> variable;
|
|
see <a href="#Special-Variables">Special Variables</a>). The first recipe line may appear on the line
|
|
after the prerequisites, with a tab character, or may appear on the
|
|
same line, with a semicolon. Either way, the effect is the same.
|
|
There are other differences in the syntax of recipes.
|
|
See <a href="#Recipes">Writing Recipes in Rules</a>.
|
|
</p>
|
|
<span id="index-dollar-sign-_0028_0024_0029_002c-in-rules"></span>
|
|
<span id="index-_0024_002c-in-rules"></span>
|
|
<span id="index-rules_002c-and-_0024"></span>
|
|
<p>Because dollar signs are used to start <code>make</code> variable
|
|
references, if you really want a dollar sign in a target or
|
|
prerequisite you must write two of them, ‘<samp>$$</samp>’ (see <a href="#Using-Variables">How to Use Variables</a>). If you have enabled secondary
|
|
expansion (see <a href="#Secondary-Expansion">Secondary Expansion</a>) and you want a literal dollar
|
|
sign in the prerequisites list, you must actually write <em>four</em>
|
|
dollar signs (‘<samp>$$$$</samp>’).
|
|
</p>
|
|
<p>You may split a long line by inserting a backslash followed by a
|
|
newline, but this is not required, as <code>make</code> places no limit on
|
|
the length of a line in a makefile.
|
|
</p>
|
|
<p>A rule tells <code>make</code> two things: when the targets are out of date,
|
|
and how to update them when necessary.
|
|
</p>
|
|
<span id="index-prerequisites"></span>
|
|
<span id="index-rule-prerequisites"></span>
|
|
<p>The criterion for being out of date is specified in terms of the
|
|
<var>prerequisites</var>, which consist of file names separated by spaces.
|
|
(Wildcards and archive members (see <a href="#Archives">Archives</a>) are allowed here too.)
|
|
A target is out of date if it does not exist or if it is older than any
|
|
of the prerequisites (by comparison of last-modification times). The
|
|
idea is that the contents of the target file are computed based on
|
|
information in the prerequisites, so if any of the prerequisites changes,
|
|
the contents of the existing target file are no longer necessarily
|
|
valid.
|
|
</p>
|
|
<p>How to update is specified by a <var>recipe</var>. This is one or more
|
|
lines to be executed by the shell (normally ‘<samp>sh</samp>’), but with some
|
|
extra features (see <a href="#Recipes">Writing Recipes in Rules</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Prerequisite-Types"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Wildcards" accesskey="n" rel="next">Wildcards</a>, Previous: <a href="#Rule-Syntax" accesskey="p" rel="prev">Rule Syntax</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Types-of-Prerequisites"></span><h3 class="section">4.3 Types of Prerequisites</h3>
|
|
<span id="index-prerequisite-types"></span>
|
|
<span id="index-types-of-prerequisites"></span>
|
|
|
|
<span id="index-prerequisites_002c-normal"></span>
|
|
<span id="index-normal-prerequisites"></span>
|
|
<span id="index-prerequisites_002c-order_002donly"></span>
|
|
<span id="index-order_002donly-prerequisites"></span>
|
|
<p>There are two different types of prerequisites understood by GNU <code>make</code>:
|
|
normal prerequisites, described in the previous section, and <em>order-only</em>
|
|
prerequisites. A normal prerequisite makes two statements: first, it imposes
|
|
an order in which recipes will be invoked: the recipes for all prerequisites
|
|
of a target will be completed before the recipe for the target is started.
|
|
Second, it imposes a dependency relationship: if any prerequisite is newer
|
|
than the target, then the target is considered out-of-date and must be
|
|
rebuilt.
|
|
</p>
|
|
<p>Normally, this is exactly what you want: if a target’s prerequisite is
|
|
updated, then the target should also be updated.
|
|
</p>
|
|
<p>Occasionally you may want to ensure that a prerequisite is built before a
|
|
target, but <em>without</em> forcing the target to be updated if the
|
|
prerequisite is updated. <em>Order-only</em> prerequisites are used to create
|
|
this type of relationship. Order-only prerequisites can be specified by
|
|
placing a pipe symbol (<code>|</code>) in the prerequisites list: any prerequisites
|
|
to the left of the pipe symbol are normal; any prerequisites to the right are
|
|
order-only:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>targets</var> : <var>normal-prerequisites</var> | <var>order-only-prerequisites</var>
|
|
</pre></div>
|
|
|
|
<p>The normal prerequisites section may of course be empty. Also, you
|
|
may still declare multiple lines of prerequisites for the same target:
|
|
they are appended appropriately (normal prerequisites are appended to
|
|
the list of normal prerequisites; order-only prerequisites are
|
|
appended to the list of order-only prerequisites). Note that if you
|
|
declare the same file to be both a normal and an order-only
|
|
prerequisite, the normal prerequisite takes precedence (since they
|
|
have a strict superset of the behavior of an order-only prerequisite).
|
|
</p>
|
|
<p>Order-only prerequisites are never checked when determining if the
|
|
target is out of date; even order-only prerequisites marked as phony
|
|
(see <a href="#Phony-Targets">Phony Targets</a>) will not cause the target to be rebuilt.
|
|
</p>
|
|
<p>Consider an example where your targets are to be placed in a separate
|
|
directory, and that directory might not exist before <code>make</code> is
|
|
run. In this situation, you want the directory to be created before
|
|
any targets are placed into it but, because the timestamps on
|
|
directories change whenever a file is added, removed, or renamed, we
|
|
certainly don’t want to rebuild all the targets whenever the
|
|
directory’s timestamp changes. One way to manage this is with
|
|
order-only prerequisites: make the directory an order-only
|
|
prerequisite on all the targets:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">OBJDIR := objdir
|
|
OBJS := $(addprefix $(OBJDIR)/,foo.o bar.o baz.o)
|
|
|
|
$(OBJDIR)/%.o : %.c
|
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
|
|
|
all: $(OBJS)
|
|
|
|
$(OBJS): | $(OBJDIR)
|
|
|
|
$(OBJDIR):
|
|
mkdir $(OBJDIR)
|
|
</pre></div>
|
|
|
|
<p>Now the rule to create the <samp>objdir</samp> directory will be run, if
|
|
needed, before any ‘<samp>.o</samp>’ is built, but no ‘<samp>.o</samp>’ will be built
|
|
because the <samp>objdir</samp> directory timestamp changed.
|
|
</p>
|
|
<hr>
|
|
<span id="Wildcards"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Directory-Search" accesskey="n" rel="next">Directory Search</a>, Previous: <a href="#Prerequisite-Types" accesskey="p" rel="prev">Prerequisite Types</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Using-Wildcard-Characters-in-File-Names"></span><h3 class="section">4.4 Using Wildcard Characters in File Names</h3>
|
|
<span id="index-wildcard"></span>
|
|
<span id="index-file-name-with-wildcards"></span>
|
|
<span id="index-globbing-_0028wildcards_0029"></span>
|
|
|
|
<span id="index-_002a-_0028wildcard-character_0029"></span>
|
|
<span id="index-_003f-_0028wildcard-character_0029"></span>
|
|
<span id="index-_005b_2026_005d-_0028wildcard-characters_0029"></span>
|
|
<p>A single file name can specify many files using <em>wildcard characters</em>.
|
|
The wildcard characters in <code>make</code> are ‘<samp>*</samp>’, ‘<samp>?</samp>’ and
|
|
‘<samp>[…]</samp>’, the same as in the Bourne shell. For example, <samp>*.c</samp>
|
|
specifies a list of all the files (in the working directory) whose names
|
|
end in ‘<samp>.c</samp>’.
|
|
</p>
|
|
<p>If an expression matches multiple files than the results will be
|
|
sorted.<a id="DOCF2" href="#FOOT2"><sup>2</sup></a> However multiple expressions will not be
|
|
globally sorted. For example, <samp>*.c *.h</samp> will list all the files whose
|
|
names end in ‘<samp>.c</samp>’, sorted, followed by all the files whose names end in
|
|
‘<samp>.h</samp>’, sorted.
|
|
</p>
|
|
<span id="index-_007e-_0028tilde_0029"></span>
|
|
<span id="index-tilde-_0028_007e_0029"></span>
|
|
<span id="index-home-directory"></span>
|
|
<p>The character ‘<samp>~</samp>’ at the beginning of a file name also has special
|
|
significance. If alone, or followed by a slash, it represents your home
|
|
directory. For example <samp>~/bin</samp> expands to <samp>/home/you/bin</samp>.
|
|
If the ‘<samp>~</samp>’ is followed by a word, the string represents the home
|
|
directory of the user named by that word. For example <samp>~john/bin</samp>
|
|
expands to <samp>/home/john/bin</samp>. On systems which don’t have a home
|
|
directory for each user (such as MS-DOS or MS-Windows), this
|
|
functionality can be simulated by setting the environment variable
|
|
<var>HOME</var>.
|
|
</p>
|
|
<p>Wildcard expansion is performed by <code>make</code> automatically in
|
|
targets and in prerequisites. In recipes, the shell is responsible
|
|
for wildcard expansion. In other contexts, wildcard expansion happens
|
|
only if you request it explicitly with the <code>wildcard</code> function.
|
|
</p>
|
|
<p>The special significance of a wildcard character can be turned off by
|
|
preceding it with a backslash. Thus, <samp>foo\*bar</samp> would refer to a
|
|
specific file whose name consists of ‘<samp>foo</samp>’, an asterisk, and
|
|
‘<samp>bar</samp>’.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Wildcard-Examples" accesskey="1">Wildcard Examples</a></td><td> </td><td align="left" valign="top">Several examples.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Wildcard-Pitfall" accesskey="2">Wildcard Pitfall</a></td><td> </td><td align="left" valign="top">Problems to avoid.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Wildcard-Function" accesskey="3">Wildcard Function</a></td><td> </td><td align="left" valign="top">How to cause wildcard expansion where
|
|
it does not normally take place.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Wildcard-Examples"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Wildcard-Pitfall" accesskey="n" rel="next">Wildcard Pitfall</a>, Previous: <a href="#Wildcards" accesskey="p" rel="prev">Wildcards</a>, Up: <a href="#Wildcards" accesskey="u" rel="up">Wildcards</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Wildcard-Examples-1"></span><h4 class="subsection">4.4.1 Wildcard Examples</h4>
|
|
|
|
<p>Wildcards can be used in the recipe of a rule, where they are expanded
|
|
by the shell. For example, here is a rule to delete all the object files:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">clean:
|
|
rm -f *.o
|
|
</pre></div>
|
|
<span id="index-rm-_0028shell-command_0029-1"></span>
|
|
|
|
<p>Wildcards are also useful in the prerequisites of a rule. With the
|
|
following rule in the makefile, ‘<samp>make print</samp>’ will print all the
|
|
‘<samp>.c</samp>’ files that have changed since the last time you printed them:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">print: *.c
|
|
lpr -p $?
|
|
touch print
|
|
</pre></div>
|
|
|
|
<span id="index-print-target"></span>
|
|
<span id="index-lpr-_0028shell-command_0029"></span>
|
|
<span id="index-touch-_0028shell-command_0029"></span>
|
|
<p>This rule uses <samp>print</samp> as an empty target file; see <a href="#Empty-Targets">Empty Target Files to Record Events</a>. (The automatic variable
|
|
‘<samp>$?</samp>’ is used to print only those files that have changed; see
|
|
<a href="#Automatic-Variables">Automatic Variables</a>.)
|
|
</p>
|
|
<p>Wildcard expansion does not happen when you define a variable. Thus, if
|
|
you write this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = *.o
|
|
</pre></div>
|
|
|
|
<p>then the value of the variable <code>objects</code> is the actual string
|
|
‘<samp>*.o</samp>’. However, if you use the value of <code>objects</code> in a
|
|
target or prerequisite, wildcard expansion will take place there. If
|
|
you use the value of <code>objects</code> in a recipe, the shell may perform
|
|
wildcard expansion when the recipe runs. To set <code>objects</code> to the
|
|
expansion, instead use:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects := $(wildcard *.o)
|
|
</pre></div>
|
|
|
|
<p>See <a href="#Wildcard-Function">Wildcard Function</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Wildcard-Pitfall"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Wildcard-Function" accesskey="n" rel="next">Wildcard Function</a>, Previous: <a href="#Wildcard-Examples" accesskey="p" rel="prev">Wildcard Examples</a>, Up: <a href="#Wildcards" accesskey="u" rel="up">Wildcards</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Pitfalls-of-Using-Wildcards"></span><h4 class="subsection">4.4.2 Pitfalls of Using Wildcards</h4>
|
|
<span id="index-wildcard-pitfalls"></span>
|
|
<span id="index-pitfalls-of-wildcards"></span>
|
|
<span id="index-mistakes-with-wildcards"></span>
|
|
<span id="index-errors-with-wildcards"></span>
|
|
<span id="index-problems-with-wildcards"></span>
|
|
|
|
<p>Now here is an example of a naive way of using wildcard expansion, that
|
|
does not do what you would intend. Suppose you would like to say that the
|
|
executable file <samp>foo</samp> is made from all the object files in the
|
|
directory, and you write this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = *.o
|
|
|
|
foo : $(objects)
|
|
cc -o foo $(CFLAGS) $(objects)
|
|
</pre></div>
|
|
|
|
<p>The value of <code>objects</code> is the actual string ‘<samp>*.o</samp>’. Wildcard
|
|
expansion happens in the rule for <samp>foo</samp>, so that each <em>existing</em>
|
|
‘<samp>.o</samp>’ file becomes a prerequisite of <samp>foo</samp> and will be recompiled if
|
|
necessary.
|
|
</p>
|
|
<p>But what if you delete all the ‘<samp>.o</samp>’ files? When a wildcard matches
|
|
no files, it is left as it is, so then <samp>foo</samp> will depend on the
|
|
oddly-named file <samp>*.o</samp>. Since no such file is likely to exist,
|
|
<code>make</code> will give you an error saying it cannot figure out how to
|
|
make <samp>*.o</samp>. This is not what you want!
|
|
</p>
|
|
<p>Actually it is possible to obtain the desired result with wildcard
|
|
expansion, but you need more sophisticated techniques, including the
|
|
<code>wildcard</code> function and string substitution.
|
|
See <a href="#Wildcard-Function">The Function <code>wildcard</code></a>.
|
|
</p>
|
|
<span id="index-wildcards-and-MS_002dDOS_002fMS_002dWindows-backslashes"></span>
|
|
<span id="index-backslashes-in-pathnames-and-wildcard-expansion"></span>
|
|
|
|
<p>Microsoft operating systems (MS-DOS and MS-Windows) use backslashes to
|
|
separate directories in pathnames, like so:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"> c:\foo\bar\baz.c
|
|
</pre></div>
|
|
|
|
<p>This is equivalent to the Unix-style <samp>c:/foo/bar/baz.c</samp> (the
|
|
<samp>c:</samp> part is the so-called drive letter). When <code>make</code> runs on
|
|
these systems, it supports backslashes as well as the Unix-style forward
|
|
slashes in pathnames. However, this support does <em>not</em> include the
|
|
wildcard expansion, where backslash is a quote character. Therefore,
|
|
you <em>must</em> use Unix-style slashes in these cases.
|
|
</p>
|
|
|
|
<hr>
|
|
<span id="Wildcard-Function"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Wildcard-Pitfall" accesskey="p" rel="prev">Wildcard Pitfall</a>, Up: <a href="#Wildcards" accesskey="u" rel="up">Wildcards</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-Function-wildcard"></span><h4 class="subsection">4.4.3 The Function <code>wildcard</code></h4>
|
|
<span id="index-wildcard-1"></span>
|
|
|
|
<p>Wildcard expansion happens automatically in rules. But wildcard expansion
|
|
does not normally take place when a variable is set, or inside the
|
|
arguments of a function. If you want to do wildcard expansion in such
|
|
places, you need to use the <code>wildcard</code> function, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(wildcard <var>pattern</var>…)
|
|
</pre></div>
|
|
|
|
<p>This string, used anywhere in a makefile, is replaced by a
|
|
space-separated list of names of existing files that match one of the
|
|
given file name patterns. If no existing file name matches a pattern,
|
|
then that pattern is omitted from the output of the <code>wildcard</code>
|
|
function. Note that this is different from how unmatched wildcards
|
|
behave in rules, where they are used verbatim rather than ignored
|
|
(see <a href="#Wildcard-Pitfall">Wildcard Pitfall</a>).
|
|
</p>
|
|
<p>As with wildcard expansion in rules, the results of the <code>wildcard</code>
|
|
function are sorted. But again, each individual expression is sorted
|
|
separately, so ‘<samp>$(wildcard *.c *.h)</samp>’ will expand to all files matching
|
|
‘<samp>.c</samp>’, sorted, followed by all files matching ‘<samp>.h</samp>’, sorted.
|
|
</p>
|
|
<p>One use of the <code>wildcard</code> function is to get a list of all the C source
|
|
files in a directory, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(wildcard *.c)
|
|
</pre></div>
|
|
|
|
<p>We can change the list of C source files into a list of object files by
|
|
replacing the ‘<samp>.c</samp>’ suffix with ‘<samp>.o</samp>’ in the result, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(patsubst %.c,%.o,$(wildcard *.c))
|
|
</pre></div>
|
|
|
|
<p>(Here we have used another function, <code>patsubst</code>.
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.)
|
|
</p>
|
|
<p>Thus, a makefile to compile all C source files in the directory and then
|
|
link them together could be written as follows:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects := $(patsubst %.c,%.o,$(wildcard *.c))
|
|
|
|
foo : $(objects)
|
|
cc -o foo $(objects)
|
|
</pre></div>
|
|
|
|
<p>(This takes advantage of the implicit rule for compiling C programs, so
|
|
there is no need to write explicit rules for compiling the files.
|
|
See <a href="#Flavors">The Two Flavors of Variables</a>, for an explanation of
|
|
‘<samp>:=</samp>’, which is a variant of ‘<samp>=</samp>’.)
|
|
</p>
|
|
<hr>
|
|
<span id="Directory-Search"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Phony-Targets" accesskey="n" rel="next">Phony Targets</a>, Previous: <a href="#Wildcards" accesskey="p" rel="prev">Wildcards</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Searching-Directories-for-Prerequisites"></span><h3 class="section">4.5 Searching Directories for Prerequisites</h3>
|
|
<span id="index-VPATH"></span>
|
|
<span id="index-vpath-1"></span>
|
|
<span id="index-vpath"></span>
|
|
<span id="index-search-path-for-prerequisites-_0028VPATH_0029"></span>
|
|
<span id="index-directory-search-_0028VPATH_0029"></span>
|
|
|
|
<p>For large systems, it is often desirable to put sources in a separate
|
|
directory from the binaries. The <em>directory search</em> features of
|
|
<code>make</code> facilitate this by searching several directories
|
|
automatically to find a prerequisite. When you redistribute the files
|
|
among directories, you do not need to change the individual rules,
|
|
just the search paths.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#General-Search" accesskey="1">General Search</a></td><td> </td><td align="left" valign="top">Specifying a search path that applies
|
|
to every prerequisite.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Selective-Search" accesskey="2">Selective Search</a></td><td> </td><td align="left" valign="top">Specifying a search path
|
|
for a specified class of names.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Search-Algorithm" accesskey="3">Search Algorithm</a></td><td> </td><td align="left" valign="top">When and how search paths are applied.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Recipes_002fSearch" accesskey="4">Recipes/Search</a></td><td> </td><td align="left" valign="top">How to write recipes that work together
|
|
with search paths.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Implicit_002fSearch" accesskey="5">Implicit/Search</a></td><td> </td><td align="left" valign="top">How search paths affect implicit rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Libraries_002fSearch" accesskey="6">Libraries/Search</a></td><td> </td><td align="left" valign="top">Directory search for link libraries.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="General-Search"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Selective-Search" accesskey="n" rel="next">Selective Search</a>, Previous: <a href="#Directory-Search" accesskey="p" rel="prev">Directory Search</a>, Up: <a href="#Directory-Search" accesskey="u" rel="up">Directory Search</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="VPATH_003a-Search-Path-for-All-Prerequisites"></span><h4 class="subsection">4.5.1 <code>VPATH</code>: Search Path for All Prerequisites</h4>
|
|
<span id="index-VPATH-1"></span>
|
|
|
|
<p>The value of the <code>make</code> variable <code>VPATH</code> specifies a list of
|
|
directories that <code>make</code> should search. Most often, the
|
|
directories are expected to contain prerequisite files that are not in the
|
|
current directory; however, <code>make</code> uses <code>VPATH</code> as a search
|
|
list for both prerequisites and targets of rules.
|
|
</p>
|
|
<p>Thus, if a file that is listed as a target or prerequisite does not exist
|
|
in the current directory, <code>make</code> searches the directories listed in
|
|
<code>VPATH</code> for a file with that name. If a file is found in one of
|
|
them, that file may become the prerequisite (see below). Rules may then
|
|
specify the names of files in the prerequisite list as if they all
|
|
existed in the current directory. See <a href="#Recipes_002fSearch">Writing Recipes with Directory Search</a>.
|
|
</p>
|
|
<p>In the <code>VPATH</code> variable, directory names are separated by colons or
|
|
blanks. The order in which directories are listed is the order followed
|
|
by <code>make</code> in its search. (On MS-DOS and MS-Windows, semi-colons
|
|
are used as separators of directory names in <code>VPATH</code>, since the
|
|
colon can be used in the pathname itself, after the drive letter.)
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">VPATH = src:../headers
|
|
</pre></div>
|
|
|
|
<p>specifies a path containing two directories, <samp>src</samp> and
|
|
<samp>../headers</samp>, which <code>make</code> searches in that order.
|
|
</p>
|
|
<p>With this value of <code>VPATH</code>, the following rule,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.o : foo.c
|
|
</pre></div>
|
|
|
|
<p>is interpreted as if it were written like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.o : src/foo.c
|
|
</pre></div>
|
|
|
|
<p>assuming the file <samp>foo.c</samp> does not exist in the current directory but
|
|
is found in the directory <samp>src</samp>.
|
|
</p>
|
|
<hr>
|
|
<span id="Selective-Search"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Search-Algorithm" accesskey="n" rel="next">Search Algorithm</a>, Previous: <a href="#General-Search" accesskey="p" rel="prev">General Search</a>, Up: <a href="#Directory-Search" accesskey="u" rel="up">Directory Search</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-vpath-Directive"></span><h4 class="subsection">4.5.2 The <code>vpath</code> Directive</h4>
|
|
<span id="index-vpath-2"></span>
|
|
|
|
<p>Similar to the <code>VPATH</code> variable, but more selective, is the
|
|
<code>vpath</code> directive (note lower case), which allows you to specify a
|
|
search path for a particular class of file names: those that match a
|
|
particular pattern. Thus you can supply certain search directories for
|
|
one class of file names and other directories (or none) for other file
|
|
names.
|
|
</p>
|
|
<p>There are three forms of the <code>vpath</code> directive:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>vpath <var>pattern</var> <var>directories</var></code></dt>
|
|
<dd><p>Specify the search path <var>directories</var> for file names that match
|
|
<var>pattern</var>.
|
|
</p>
|
|
<p>The search path, <var>directories</var>, is a list of directories to be
|
|
searched, separated by colons (semi-colons on MS-DOS and MS-Windows) or
|
|
blanks, just like the search path used in the <code>VPATH</code> variable.
|
|
</p>
|
|
</dd>
|
|
<dt><code>vpath <var>pattern</var></code></dt>
|
|
<dd><p>Clear out the search path associated with <var>pattern</var>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>vpath</code></dt>
|
|
<dd>
|
|
<p>Clear all search paths previously specified with <code>vpath</code> directives.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>A <code>vpath</code> pattern is a string containing a ‘<samp>%</samp>’ character. The
|
|
string must match the file name of a prerequisite that is being searched
|
|
for, the ‘<samp>%</samp>’ character matching any sequence of zero or more
|
|
characters (as in pattern rules; see <a href="#Pattern-Rules">Defining and
|
|
Redefining Pattern Rules</a>). For example, <code>%.h</code> matches files that
|
|
end in <code>.h</code>. (If there is no ‘<samp>%</samp>’, the pattern must match the
|
|
prerequisite exactly, which is not useful very often.)
|
|
</p>
|
|
<span id="index-_0025_002c-quoting-in-vpath"></span>
|
|
<span id="index-_0025_002c-quoting-with-_005c-_0028backslash_0029"></span>
|
|
<span id="index-_005c-_0028backslash_0029_002c-to-quote-_0025"></span>
|
|
<span id="index-backslash-_0028_005c_0029_002c-to-quote-_0025"></span>
|
|
<span id="index-quoting-_0025_002c-in-vpath"></span>
|
|
<p>‘<samp>%</samp>’ characters in a <code>vpath</code> directive’s pattern can be quoted
|
|
with preceding backslashes (‘<samp>\</samp>’). Backslashes that would otherwise
|
|
quote ‘<samp>%</samp>’ characters can be quoted with more backslashes.
|
|
Backslashes that quote ‘<samp>%</samp>’ characters or other backslashes are
|
|
removed from the pattern before it is compared to file names. Backslashes
|
|
that are not in danger of quoting ‘<samp>%</samp>’ characters go unmolested.
|
|
</p>
|
|
<p>When a prerequisite fails to exist in the current directory, if the
|
|
<var>pattern</var> in a <code>vpath</code> directive matches the name of the
|
|
prerequisite file, then the <var>directories</var> in that directive are searched
|
|
just like (and before) the directories in the <code>VPATH</code> variable.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">vpath %.h ../headers
|
|
</pre></div>
|
|
|
|
<p>tells <code>make</code> to look for any prerequisite whose name ends in <samp>.h</samp>
|
|
in the directory <samp>../headers</samp> if the file is not found in the current
|
|
directory.
|
|
</p>
|
|
<p>If several <code>vpath</code> patterns match the prerequisite file’s name, then
|
|
<code>make</code> processes each matching <code>vpath</code> directive one by one,
|
|
searching all the directories mentioned in each directive. <code>make</code>
|
|
handles multiple <code>vpath</code> directives in the order in which they
|
|
appear in the makefile; multiple directives with the same pattern are
|
|
independent of each other.
|
|
</p>
|
|
<p>Thus,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">vpath %.c foo
|
|
vpath % blish
|
|
vpath %.c bar
|
|
</pre></div>
|
|
|
|
<p>will look for a file ending in ‘<samp>.c</samp>’ in <samp>foo</samp>, then
|
|
<samp>blish</samp>, then <samp>bar</samp>, while
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">vpath %.c foo:bar
|
|
vpath % blish
|
|
</pre></div>
|
|
|
|
<p>will look for a file ending in ‘<samp>.c</samp>’ in <samp>foo</samp>, then
|
|
<samp>bar</samp>, then <samp>blish</samp>.
|
|
</p>
|
|
<hr>
|
|
<span id="Search-Algorithm"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Recipes_002fSearch" accesskey="n" rel="next">Recipes/Search</a>, Previous: <a href="#Selective-Search" accesskey="p" rel="prev">Selective Search</a>, Up: <a href="#Directory-Search" accesskey="u" rel="up">Directory Search</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-Directory-Searches-are-Performed"></span><h4 class="subsection">4.5.3 How Directory Searches are Performed</h4>
|
|
<span id="index-algorithm-for-directory-search"></span>
|
|
<span id="index-directory-search-algorithm"></span>
|
|
|
|
<p>When a prerequisite is found through directory search, regardless of type
|
|
(general or selective), the pathname located may not be the one that
|
|
<code>make</code> actually provides you in the prerequisite list. Sometimes
|
|
the path discovered through directory search is thrown away.
|
|
</p>
|
|
<p>The algorithm <code>make</code> uses to decide whether to keep or abandon a
|
|
path found via directory search is as follows:
|
|
</p>
|
|
<ol>
|
|
<li> If a target file does not exist at the path specified in the makefile,
|
|
directory search is performed.
|
|
|
|
</li><li> If the directory search is successful, that path is kept and this file
|
|
is tentatively stored as the target.
|
|
|
|
</li><li> All prerequisites of this target are examined using this same method.
|
|
|
|
</li><li> After processing the prerequisites, the target may or may not need to be
|
|
rebuilt:
|
|
|
|
<ol type="a" start="1">
|
|
<li> If the target does <em>not</em> need to be rebuilt, the path to the file
|
|
found during directory search is used for any prerequisite lists which
|
|
contain this target. In short, if <code>make</code> doesn’t need to rebuild
|
|
the target then you use the path found via directory search.
|
|
|
|
</li><li> If the target <em>does</em> need to be rebuilt (is out-of-date), the
|
|
pathname found during directory search is <em>thrown away</em>, and the
|
|
target is rebuilt using the file name specified in the makefile. In
|
|
short, if <code>make</code> must rebuild, then the target is rebuilt locally,
|
|
not in the directory found via directory search.
|
|
</li></ol>
|
|
</li></ol>
|
|
|
|
<p>This algorithm may seem complex, but in practice it is quite often
|
|
exactly what you want.
|
|
</p>
|
|
<span id="index-traditional-directory-search-_0028GPATH_0029"></span>
|
|
<span id="index-directory-search_002c-traditional-_0028GPATH_0029"></span>
|
|
<p>Other versions of <code>make</code> use a simpler algorithm: if the file does
|
|
not exist, and it is found via directory search, then that pathname is
|
|
always used whether or not the target needs to be built. Thus, if the
|
|
target is rebuilt it is created at the pathname discovered during
|
|
directory search.
|
|
</p>
|
|
<span id="index-GPATH"></span>
|
|
<p>If, in fact, this is the behavior you want for some or all of your
|
|
directories, you can use the <code>GPATH</code> variable to indicate this to
|
|
<code>make</code>.
|
|
</p>
|
|
<p><code>GPATH</code> has the same syntax and format as <code>VPATH</code> (that is, a
|
|
space- or colon-delimited list of pathnames). If an out-of-date target
|
|
is found by directory search in a directory that also appears in
|
|
<code>GPATH</code>, then that pathname is not thrown away. The target is
|
|
rebuilt using the expanded path.
|
|
</p>
|
|
<hr>
|
|
<span id="Recipes_002fSearch"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Implicit_002fSearch" accesskey="n" rel="next">Implicit/Search</a>, Previous: <a href="#Search-Algorithm" accesskey="p" rel="prev">Search Algorithm</a>, Up: <a href="#Directory-Search" accesskey="u" rel="up">Directory Search</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Writing-Recipes-with-Directory-Search"></span><h4 class="subsection">4.5.4 Writing Recipes with Directory Search</h4>
|
|
<span id="index-recipes_002c-and-directory-search"></span>
|
|
<span id="index-directory-search-_0028VPATH_0029_002c-and-recipes"></span>
|
|
|
|
<p>When a prerequisite is found in another directory through directory search,
|
|
this cannot change the recipe of the rule; they will execute as written.
|
|
Therefore, you must write the recipe with care so that it will look for
|
|
the prerequisite in the directory where <code>make</code> finds it.
|
|
</p>
|
|
<p>This is done with the <em>automatic variables</em> such as ‘<samp>$^</samp>’
|
|
(see <a href="#Automatic-Variables">Automatic Variables</a>).
|
|
For instance, the value of ‘<samp>$^</samp>’ is a
|
|
list of all the prerequisites of the rule, including the names of
|
|
the directories in which they were found, and the value of
|
|
‘<samp>$@</samp>’ is the target. Thus:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.o : foo.c
|
|
cc -c $(CFLAGS) $^ -o $@
|
|
</pre></div>
|
|
|
|
<p>(The variable <code>CFLAGS</code> exists so you can specify flags for C
|
|
compilation by implicit rules; we use it here for consistency so it will
|
|
affect all C compilations uniformly;
|
|
see <a href="#Implicit-Variables">Variables Used by Implicit Rules</a>.)
|
|
</p>
|
|
<p>Often the prerequisites include header files as well, which you do not
|
|
want to mention in the recipe. The automatic variable ‘<samp>$<</samp>’ is
|
|
just the first prerequisite:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">VPATH = src:../headers
|
|
foo.o : foo.c defs.h hack.h
|
|
cc -c $(CFLAGS) $< -o $@
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Implicit_002fSearch"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Libraries_002fSearch" accesskey="n" rel="next">Libraries/Search</a>, Previous: <a href="#Recipes_002fSearch" accesskey="p" rel="prev">Recipes/Search</a>, Up: <a href="#Directory-Search" accesskey="u" rel="up">Directory Search</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Directory-Search-and-Implicit-Rules"></span><h4 class="subsection">4.5.5 Directory Search and Implicit Rules</h4>
|
|
<span id="index-VPATH_002c-and-implicit-rules"></span>
|
|
<span id="index-directory-search-_0028VPATH_0029_002c-and-implicit-rules"></span>
|
|
<span id="index-search-path-for-prerequisites-_0028VPATH_0029_002c-and-implicit-rules"></span>
|
|
<span id="index-implicit-rule_002c-and-directory-search"></span>
|
|
<span id="index-implicit-rule_002c-and-VPATH"></span>
|
|
<span id="index-rule_002c-implicit_002c-and-directory-search"></span>
|
|
<span id="index-rule_002c-implicit_002c-and-VPATH"></span>
|
|
|
|
<p>The search through the directories specified in <code>VPATH</code> or with
|
|
<code>vpath</code> also happens during consideration of implicit rules
|
|
(see <a href="#Implicit-Rules">Using Implicit Rules</a>).
|
|
</p>
|
|
<p>For example, when a file <samp>foo.o</samp> has no explicit rule, <code>make</code>
|
|
considers implicit rules, such as the built-in rule to compile
|
|
<samp>foo.c</samp> if that file exists. If such a file is lacking in the
|
|
current directory, the appropriate directories are searched for it. If
|
|
<samp>foo.c</samp> exists (or is mentioned in the makefile) in any of the
|
|
directories, the implicit rule for C compilation is applied.
|
|
</p>
|
|
<p>The recipes of implicit rules normally use automatic variables as a
|
|
matter of necessity; consequently they will use the file names found by
|
|
directory search with no extra effort.
|
|
</p>
|
|
<hr>
|
|
<span id="Libraries_002fSearch"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Implicit_002fSearch" accesskey="p" rel="prev">Implicit/Search</a>, Up: <a href="#Directory-Search" accesskey="u" rel="up">Directory Search</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Directory-Search-for-Link-Libraries"></span><h4 class="subsection">4.5.6 Directory Search for Link Libraries</h4>
|
|
<span id="index-link-libraries_002c-and-directory-search"></span>
|
|
<span id="index-libraries-for-linking_002c-directory-search"></span>
|
|
<span id="index-directory-search-_0028VPATH_0029_002c-and-link-libraries"></span>
|
|
<span id="index-VPATH_002c-and-link-libraries"></span>
|
|
<span id="index-search-path-for-prerequisites-_0028VPATH_0029_002c-and-link-libraries"></span>
|
|
<span id="index-_002dl-_0028library-search_0029"></span>
|
|
<span id="index-link-libraries_002c-patterns-matching"></span>
|
|
<span id="index-_002eLIBPATTERNS_002c-and-link-libraries"></span>
|
|
<span id="index-_002eLIBPATTERNS"></span>
|
|
|
|
<p>Directory search applies in a special way to libraries used with the
|
|
linker. This special feature comes into play when you write a prerequisite
|
|
whose name is of the form ‘<samp>-l<var>name</var></samp>’. (You can tell something
|
|
strange is going on here because the prerequisite is normally the name of a
|
|
file, and the <em>file name</em> of a library generally looks like
|
|
<samp>lib<var>name</var>.a</samp>, not like ‘<samp>-l<var>name</var></samp>’.)
|
|
</p>
|
|
<p>When a prerequisite’s name has the form ‘<samp>-l<var>name</var></samp>’, <code>make</code>
|
|
handles it specially by searching for the file <samp>lib<var>name</var>.so</samp>,
|
|
and, if it is not found, for the file <samp>lib<var>name</var>.a</samp> in the current
|
|
directory, in directories specified by matching <code>vpath</code>
|
|
search paths and the <code>VPATH</code> search path, and then in the
|
|
directories <samp>/lib</samp>, <samp>/usr/lib</samp>, and <samp><var>prefix</var>/lib</samp>
|
|
(normally <samp>/usr/local/lib</samp>, but MS-DOS/MS-Windows versions of
|
|
<code>make</code> behave as if <var>prefix</var> is defined to be the root of the
|
|
DJGPP installation tree).
|
|
</p>
|
|
<p>For example, if there is a <samp>/usr/lib/libcurses.a</samp> library on your
|
|
system (and no <samp>/usr/lib/libcurses.so</samp> file), then
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo : foo.c -lcurses
|
|
cc $^ -o $@
|
|
</pre></div>
|
|
|
|
<p>would cause the command ‘<samp>cc foo.c /usr/lib/libcurses.a -o foo</samp>’ to
|
|
be executed when <samp>foo</samp> is older than <samp>foo.c</samp> or than
|
|
<samp>/usr/lib/libcurses.a</samp>.
|
|
</p>
|
|
<p>Although the default set of files to be searched for is
|
|
<samp>lib<var>name</var>.so</samp> and <samp>lib<var>name</var>.a</samp>, this is customizable
|
|
via the <code>.LIBPATTERNS</code> variable. Each word in the value of this
|
|
variable is a pattern string. When a prerequisite like
|
|
‘<samp>-l<var>name</var></samp>’ is seen, <code>make</code> will replace the percent in
|
|
each pattern in the list with <var>name</var> and perform the above directory
|
|
searches using each library file name.
|
|
</p>
|
|
<p>The default value for <code>.LIBPATTERNS</code> is ‘<samp>lib%.so lib%.a</samp>’,
|
|
which provides the default behavior described above.
|
|
</p>
|
|
<p>You can turn off link library expansion completely by setting this
|
|
variable to an empty value.
|
|
</p>
|
|
<hr>
|
|
<span id="Phony-Targets"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Force-Targets" accesskey="n" rel="next">Force Targets</a>, Previous: <a href="#Directory-Search" accesskey="p" rel="prev">Directory Search</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Phony-Targets-1"></span><h3 class="section">4.6 Phony Targets</h3>
|
|
<span id="index-phony-targets"></span>
|
|
<span id="index-targets_002c-phony"></span>
|
|
<span id="index-targets-without-a-file"></span>
|
|
|
|
<p>A phony target is one that is not really the name of a file; rather it
|
|
is just a name for a recipe to be executed when you make an explicit
|
|
request. There are two reasons to use a phony target: to avoid a
|
|
conflict with a file of the same name, and to improve performance.
|
|
</p>
|
|
<p>If you write a rule whose recipe will not create the target file, the
|
|
recipe will be executed every time the target comes up for remaking.
|
|
Here is an example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">clean:
|
|
rm *.o temp
|
|
</pre></div>
|
|
|
|
<p>Because the <code>rm</code> command does not create a file named <samp>clean</samp>,
|
|
probably no such file will ever exist. Therefore, the <code>rm</code> command
|
|
will be executed every time you say ‘<samp>make clean</samp>’.
|
|
<span id="index-rm-_0028shell-command_0029-2"></span>
|
|
</p>
|
|
<span id="index-_002ePHONY"></span>
|
|
<p>In this example, the <samp>clean</samp> target will not work properly if a
|
|
file named <samp>clean</samp> is ever created in this directory. Since it
|
|
has no prerequisites, <samp>clean</samp> would always be considered up to
|
|
date and its recipe would not be executed. To avoid this problem you
|
|
can explicitly declare the target to be phony by making it a
|
|
prerequisite of the special target <code>.PHONY</code>
|
|
(see <a href="#Special-Targets">Special Built-in Target Names</a>) as follows:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.PHONY: clean
|
|
clean:
|
|
rm *.o temp
|
|
</pre></div>
|
|
|
|
<p>Once this is done, ‘<samp>make clean</samp>’ will run the recipe regardless of
|
|
whether there is a file named <samp>clean</samp>.
|
|
</p>
|
|
<p>Prerequisites of <code>.PHONY</code> are always interpreted as literal
|
|
target names, never as patterns (even if they contain ‘<samp>%</samp>’
|
|
characters). To always rebuild a pattern rule consider using a
|
|
“force target” (see <a href="#Force-Targets">Rules without Recipes or
|
|
Prerequisites</a>).
|
|
</p>
|
|
<p>Phony targets are also useful in conjunction with recursive
|
|
invocations of <code>make</code> (see <a href="#Recursion">Recursive Use of <code>make</code></a>).
|
|
In this situation the makefile will often contain a variable which
|
|
lists a number of sub-directories to be built. A simplistic way to
|
|
handle this is to define one rule with a recipe that loops over the
|
|
sub-directories, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">SUBDIRS = foo bar baz
|
|
|
|
subdirs:
|
|
for dir in $(SUBDIRS); do \
|
|
$(MAKE) -C $$dir; \
|
|
done
|
|
</pre></div>
|
|
|
|
<p>There are problems with this method, however. First, any error detected in a
|
|
sub-make is ignored by this rule, so it will continue to build the rest of the
|
|
directories even when one fails. This can be overcome by adding shell
|
|
commands to note the error and exit, but then it will do so even if
|
|
<code>make</code> is invoked with the <code>-k</code> option, which is unfortunate.
|
|
Second, and perhaps more importantly, you cannot take full advantage of
|
|
<code>make</code>’s ability to build targets in parallel (see <a href="#Parallel">Parallel
|
|
Execution</a>), since there is only one rule. Each individual makefile’s targets
|
|
will be built in parallel, but only one sub-directory will be built at a time.
|
|
</p>
|
|
<p>By declaring the sub-directories as <code>.PHONY</code> targets (you must do
|
|
this as the sub-directory obviously always exists; otherwise it won’t
|
|
be built) you can remove these problems:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">SUBDIRS = foo bar baz
|
|
|
|
.PHONY: subdirs $(SUBDIRS)
|
|
|
|
subdirs: $(SUBDIRS)
|
|
|
|
$(SUBDIRS):
|
|
$(MAKE) -C $@
|
|
|
|
foo: baz
|
|
</pre></div>
|
|
|
|
<p>Here we’ve also declared that the <samp>foo</samp> sub-directory cannot be
|
|
built until after the <samp>baz</samp> sub-directory is complete; this kind of
|
|
relationship declaration is particularly important when attempting
|
|
parallel builds.
|
|
</p>
|
|
<p>The implicit rule search (see <a href="#Implicit-Rules">Implicit Rules</a>) is skipped for
|
|
<code>.PHONY</code> targets. This is why declaring a target as
|
|
<code>.PHONY</code> is good for performance, even if you are not worried
|
|
about the actual file existing.
|
|
</p>
|
|
<p>A phony target should not be a prerequisite of a real target file; if it is,
|
|
its recipe will be run every time <code>make</code> considers that file. As long as
|
|
a phony target is never a prerequisite of a real target, the phony target
|
|
recipe will be executed only when the phony target is a specified goal
|
|
(see <a href="#Goals">Arguments to Specify the Goals</a>).
|
|
</p>
|
|
<p>You should not declare an included makefile as phony. Phony targets are not
|
|
intended to represent real files, and because the target is always considered
|
|
out of date make will always rebuild it then re-execute itself
|
|
(see <a href="#Remaking-Makefiles">How Makefiles Are Remade</a>). To avoid this,
|
|
<code>make</code> will not re-execute itself if an included file marked as phony is
|
|
re-built.
|
|
</p>
|
|
<p>Phony targets can have prerequisites. When one directory contains multiple
|
|
programs, it is most convenient to describe all of the programs in one
|
|
makefile <samp>./Makefile</samp>. Since the target remade by default will be the
|
|
first one in the makefile, it is common to make this a phony target named
|
|
‘<samp>all</samp>’ and give it, as prerequisites, all the individual programs. For
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">all : prog1 prog2 prog3
|
|
.PHONY : all
|
|
|
|
prog1 : prog1.o utils.o
|
|
cc -o prog1 prog1.o utils.o
|
|
|
|
prog2 : prog2.o
|
|
cc -o prog2 prog2.o
|
|
|
|
prog3 : prog3.o sort.o utils.o
|
|
cc -o prog3 prog3.o sort.o utils.o
|
|
</pre></div>
|
|
|
|
<p>Now you can say just ‘<samp>make</samp>’ to remake all three programs, or
|
|
specify as arguments the ones to remake (as in ‘<samp>make prog1
|
|
prog3</samp>’). Phoniness is not inherited: the prerequisites of a phony
|
|
target are not themselves phony, unless explicitly declared to be so.
|
|
</p>
|
|
<p>When one phony target is a prerequisite of another, it serves as a subroutine
|
|
of the other. For example, here ‘<samp>make cleanall</samp>’ will delete the
|
|
object files, the difference files, and the file <samp>program</samp>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.PHONY: cleanall cleanobj cleandiff
|
|
|
|
cleanall : cleanobj cleandiff
|
|
rm program
|
|
|
|
cleanobj :
|
|
rm *.o
|
|
|
|
cleandiff :
|
|
rm *.diff
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Force-Targets"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Empty-Targets" accesskey="n" rel="next">Empty Targets</a>, Previous: <a href="#Phony-Targets" accesskey="p" rel="prev">Phony Targets</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Rules-without-Recipes-or-Prerequisites"></span><h3 class="section">4.7 Rules without Recipes or Prerequisites</h3>
|
|
<span id="index-force-targets"></span>
|
|
<span id="index-targets_002c-force"></span>
|
|
<span id="index-FORCE"></span>
|
|
<span id="index-rule_002c-no-recipe-or-prerequisites"></span>
|
|
|
|
<p>If a rule has no prerequisites or recipe, and the target of the rule
|
|
is a nonexistent file, then <code>make</code> imagines this target to have
|
|
been updated whenever its rule is run. This implies that all targets
|
|
depending on this one will always have their recipe run.
|
|
</p>
|
|
<p>An example will illustrate this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">clean: FORCE
|
|
rm $(objects)
|
|
FORCE:
|
|
</pre></div>
|
|
|
|
<p>Here the target ‘<samp>FORCE</samp>’ satisfies the special conditions, so the
|
|
target <samp>clean</samp> that depends on it is forced to run its recipe.
|
|
There is nothing special about the name ‘<samp>FORCE</samp>’, but that is one
|
|
name commonly used this way.
|
|
</p>
|
|
<p>As you can see, using ‘<samp>FORCE</samp>’ this way has the same results as using
|
|
‘<samp>.PHONY: clean</samp>’.
|
|
</p>
|
|
<p>Using ‘<samp>.PHONY</samp>’ is more explicit and more efficient. However,
|
|
other versions of <code>make</code> do not support ‘<samp>.PHONY</samp>’; thus
|
|
‘<samp>FORCE</samp>’ appears in many makefiles. See <a href="#Phony-Targets">Phony Targets</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Empty-Targets"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Special-Targets" accesskey="n" rel="next">Special Targets</a>, Previous: <a href="#Force-Targets" accesskey="p" rel="prev">Force Targets</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Empty-Target-Files-to-Record-Events"></span><h3 class="section">4.8 Empty Target Files to Record Events</h3>
|
|
<span id="index-empty-targets"></span>
|
|
<span id="index-targets_002c-empty"></span>
|
|
<span id="index-recording-events-with-empty-targets"></span>
|
|
|
|
<p>The <em>empty target</em> is a variant of the phony target; it is used to hold
|
|
recipes for an action that you request explicitly from time to time.
|
|
Unlike a phony target, this target file can really exist; but the file’s
|
|
contents do not matter, and usually are empty.
|
|
</p>
|
|
<p>The purpose of the empty target file is to record, with its
|
|
last-modification time, when the rule’s recipe was last executed. It
|
|
does so because one of the commands in the recipe is a <code>touch</code>
|
|
command to update the target file.
|
|
</p>
|
|
<p>The empty target file should have some prerequisites (otherwise it
|
|
doesn’t make sense). When you ask to remake the empty target, the
|
|
recipe is executed if any prerequisite is more recent than the target;
|
|
in other words, if a prerequisite has changed since the last time you
|
|
remade the target. Here is an example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">print: foo.c bar.c
|
|
lpr -p $?
|
|
touch print
|
|
</pre></div>
|
|
<span id="index-print-target-1"></span>
|
|
<span id="index-lpr-_0028shell-command_0029-1"></span>
|
|
<span id="index-touch-_0028shell-command_0029-1"></span>
|
|
|
|
<p>With this rule, ‘<samp>make print</samp>’ will execute the <code>lpr</code> command if
|
|
either source file has changed since the last ‘<samp>make print</samp>’. The
|
|
automatic variable ‘<samp>$?</samp>’ is used to print only those files that have
|
|
changed (see <a href="#Automatic-Variables">Automatic Variables</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Special-Targets"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Multiple-Targets" accesskey="n" rel="next">Multiple Targets</a>, Previous: <a href="#Empty-Targets" accesskey="p" rel="prev">Empty Targets</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Special-Built_002din-Target-Names"></span><h3 class="section">4.9 Special Built-in Target Names</h3>
|
|
<span id="index-special-targets"></span>
|
|
<span id="index-built_002din-special-targets"></span>
|
|
<span id="index-targets_002c-built_002din-special"></span>
|
|
|
|
<p>Certain names have special meanings if they appear as targets.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dd><span id="index-_002ePHONY-1"></span>
|
|
</dd>
|
|
<dt><code>.PHONY</code></dt>
|
|
<dd>
|
|
<p>The prerequisites of the special target <code>.PHONY</code> are considered to
|
|
be phony targets. When it is time to consider such a target,
|
|
<code>make</code> will run its recipe unconditionally, regardless of
|
|
whether a file with that name exists or what its last-modification
|
|
time is. See <a href="#Phony-Targets">Phony Targets</a>.
|
|
</p>
|
|
<span id="index-_002eSUFFIXES"></span>
|
|
</dd>
|
|
<dt><code>.SUFFIXES</code></dt>
|
|
<dd>
|
|
<p>The prerequisites of the special target <code>.SUFFIXES</code> are the list
|
|
of suffixes to be used in checking for suffix rules.
|
|
See <a href="#Suffix-Rules">Old-Fashioned Suffix Rules</a>.
|
|
</p>
|
|
<span id="index-_002eDEFAULT"></span>
|
|
</dd>
|
|
<dt><code>.DEFAULT</code></dt>
|
|
<dd>
|
|
<p>The recipe specified for <code>.DEFAULT</code> is used for any target for
|
|
which no rules are found (either explicit rules or implicit rules).
|
|
See <a href="#Last-Resort">Last Resort</a>. If a <code>.DEFAULT</code> recipe is specified, every
|
|
file mentioned as a prerequisite, but not as a target in a rule, will have
|
|
that recipe executed on its behalf. See <a href="#Implicit-Rule-Search">Implicit Rule Search Algorithm</a>.
|
|
</p>
|
|
<span id="index-_002ePRECIOUS"></span>
|
|
</dd>
|
|
<dt><code>.PRECIOUS</code></dt>
|
|
<dd><span id="index-precious-targets"></span>
|
|
<span id="index-preserving-with-_002ePRECIOUS"></span>
|
|
|
|
<p>The targets which <code>.PRECIOUS</code> depends on are given the following
|
|
special treatment: if <code>make</code> is killed or interrupted during the
|
|
execution of their recipes, the target is not deleted.
|
|
See <a href="#Interrupts">Interrupting or Killing <code>make</code></a>. Also, if the
|
|
target is an intermediate file, it will not be deleted after it is no
|
|
longer needed, as is normally done. See <a href="#Chained-Rules">Chains of
|
|
Implicit Rules</a>. In this latter respect it overlaps with the
|
|
<code>.SECONDARY</code> special target.
|
|
</p>
|
|
<p>You can also list the target pattern of an implicit rule (such as
|
|
‘<samp>%.o</samp>’) as a prerequisite file of the special target <code>.PRECIOUS</code>
|
|
to preserve intermediate files created by rules whose target patterns
|
|
match that file’s name.
|
|
</p>
|
|
<span id="index-_002eINTERMEDIATE"></span>
|
|
</dd>
|
|
<dt><code>.INTERMEDIATE</code></dt>
|
|
<dd><span id="index-intermediate-targets_002c-explicit"></span>
|
|
|
|
<p>The targets which <code>.INTERMEDIATE</code> depends on are treated as
|
|
intermediate files. See <a href="#Chained-Rules">Chains of Implicit Rules</a>.
|
|
<code>.INTERMEDIATE</code> with no prerequisites has no effect.
|
|
</p>
|
|
<span id="index-_002eNOTINTERMEDIATE"></span>
|
|
</dd>
|
|
<dt><code>.NOTINTERMEDIATE</code></dt>
|
|
<dd><span id="index-not-intermediate-targets_002c-explicit"></span>
|
|
|
|
<p>Prerequisites of the special target <code>.NOTINTERMEDIATE</code> are never
|
|
considered intermediate files. See <a href="#Chained-Rules">Chains of Implicit Rules</a>.
|
|
<code>.NOTINTERMEDIATE</code> with no prerequisites causes all targets to be treated
|
|
as not intermediate.
|
|
</p>
|
|
<p>If the prerequisite is a target pattern then targets that are built using that
|
|
pattern rule are not considered intermediate.
|
|
</p>
|
|
<span id="index-_002eSECONDARY"></span>
|
|
</dd>
|
|
<dt><code>.SECONDARY</code></dt>
|
|
<dd><span id="index-secondary-targets"></span>
|
|
<span id="index-preserving-with-_002eSECONDARY"></span>
|
|
|
|
<p>The targets which <code>.SECONDARY</code> depends on are treated as
|
|
intermediate files, except that they are never automatically deleted.
|
|
See <a href="#Chained-Rules">Chains of Implicit Rules</a>.
|
|
</p>
|
|
<p><code>.SECONDARY</code> can be used to avoid redundant rebuilds in some unusual
|
|
situations. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">hello.bin: hello.o bye.o
|
|
$(CC) -o $@ $^
|
|
|
|
%.o: %.c
|
|
$(CC) -c -o $@ $<
|
|
|
|
.SECONDARY: hello.o bye.o
|
|
</pre></div>
|
|
|
|
<p>Suppose <samp>hello.bin</samp> is up to date in regards to the source files,
|
|
<em>but</em> the object file <samp>hello.o</samp> is missing. Without
|
|
<code>.SECONDARY</code> make would rebuild <samp>hello.o</samp> then rebuild
|
|
<samp>hello.bin</samp> even though the source files had not changed. By declaring
|
|
<samp>hello.o</samp> as <code>.SECONDARY</code> <code>make</code> will not need to rebuild it
|
|
and won’t need to rebuild <samp>hello.bin</samp> either. Of course, of one of the
|
|
source files <em>were</em> updated then all object files would be rebuilt so
|
|
that the creation of <samp>hello.bin</samp> could succeed.
|
|
</p>
|
|
<p><code>.SECONDARY</code> with no prerequisites causes all targets to be treated
|
|
as secondary (i.e., no target is removed because it is considered
|
|
intermediate).
|
|
</p>
|
|
<span id="index-_002eSECONDEXPANSION-1"></span>
|
|
</dd>
|
|
<dt><code>.SECONDEXPANSION</code></dt>
|
|
<dd>
|
|
<p>If <code>.SECONDEXPANSION</code> is mentioned as a target anywhere in the
|
|
makefile, then all prerequisite lists defined <em>after</em> it appears
|
|
will be expanded a second time after all makefiles have been read in.
|
|
See <a href="#Secondary-Expansion">Secondary Expansion</a>.
|
|
</p>
|
|
<span id="index-_002eDELETE_005fON_005fERROR"></span>
|
|
</dd>
|
|
<dt><code>.DELETE_ON_ERROR</code></dt>
|
|
<dd><span id="index-removing-targets-on-failure"></span>
|
|
|
|
<p>If <code>.DELETE_ON_ERROR</code> is mentioned as a target anywhere in the
|
|
makefile, then <code>make</code> will delete the target of a rule if it has
|
|
changed and its recipe exits with a nonzero exit status, just as it
|
|
does when it receives a signal. See <a href="#Errors">Errors in Recipes</a>.
|
|
</p>
|
|
<span id="index-_002eIGNORE"></span>
|
|
</dd>
|
|
<dt><code>.IGNORE</code></dt>
|
|
<dd>
|
|
<p>If you specify prerequisites for <code>.IGNORE</code>, then <code>make</code> will
|
|
ignore errors in execution of the recipe for those particular files.
|
|
The recipe for <code>.IGNORE</code> (if any) is ignored.
|
|
</p>
|
|
<p>If mentioned as a target with no prerequisites, <code>.IGNORE</code> says to
|
|
ignore errors in execution of recipes for all files. This usage of
|
|
‘<samp>.IGNORE</samp>’ is supported only for historical compatibility. Since
|
|
this affects every recipe in the makefile, it is not very useful; we
|
|
recommend you use the more selective ways to ignore errors in specific
|
|
recipes. See <a href="#Errors">Errors in Recipes</a>.
|
|
</p>
|
|
<span id="index-_002eLOW_005fRESOLUTION_005fTIME"></span>
|
|
</dd>
|
|
<dt><code>.LOW_RESOLUTION_TIME</code></dt>
|
|
<dd>
|
|
<p>If you specify prerequisites for <code>.LOW_RESOLUTION_TIME</code>,
|
|
<code>make</code> assumes that these files are created by commands that
|
|
generate low resolution time stamps. The recipe for the
|
|
<code>.LOW_RESOLUTION_TIME</code> target are ignored.
|
|
</p>
|
|
<p>The high resolution file time stamps of many modern file systems
|
|
lessen the chance of <code>make</code> incorrectly concluding that a file
|
|
is up to date. Unfortunately, some hosts do not provide a way to set a
|
|
high resolution file time stamp, so commands like ‘<samp>cp -p</samp>’ that
|
|
explicitly set a file’s time stamp must discard its sub-second part.
|
|
If a file is created by such a command, you should list it as a
|
|
prerequisite of <code>.LOW_RESOLUTION_TIME</code> so that <code>make</code>
|
|
does not mistakenly conclude that the file is out of date. For
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.LOW_RESOLUTION_TIME: dst
|
|
dst: src
|
|
cp -p src dst
|
|
</pre></div>
|
|
|
|
<p>Since ‘<samp>cp -p</samp>’ discards the sub-second part of <samp>src</samp>’s time
|
|
stamp, <samp>dst</samp> is typically slightly older than <samp>src</samp> even when
|
|
it is up to date. The <code>.LOW_RESOLUTION_TIME</code> line causes
|
|
<code>make</code> to consider <samp>dst</samp> to be up to date if its time stamp
|
|
is at the start of the same second that <samp>src</samp>’s time stamp is in.
|
|
</p>
|
|
<p>Due to a limitation of the archive format, archive member time stamps
|
|
are always low resolution. You need not list archive members as
|
|
prerequisites of <code>.LOW_RESOLUTION_TIME</code>, as <code>make</code> does this
|
|
automatically.
|
|
</p>
|
|
<span id="index-_002eSILENT"></span>
|
|
</dd>
|
|
<dt><code>.SILENT</code></dt>
|
|
<dd>
|
|
<p>If you specify prerequisites for <code>.SILENT</code>, then <code>make</code> will
|
|
not print the recipe used to remake those particular files before
|
|
executing them. The recipe for <code>.SILENT</code> is ignored.
|
|
</p>
|
|
<p>If mentioned as a target with no prerequisites, <code>.SILENT</code> says
|
|
not to print any recipes before executing them. You may also use more
|
|
selective ways to silence specific recipe command lines.
|
|
See <a href="#Echoing">Recipe Echoing</a>. If you want to silence all recipes
|
|
for a particular run of <code>make</code>, use the ‘<samp>-s</samp>’ or
|
|
‘<samp><span class="nolinebreak">--silent</span></samp>’<!-- /@w --> option (see <a href="#Options-Summary">Options Summary</a>).
|
|
</p>
|
|
<span id="index-_002eEXPORT_005fALL_005fVARIABLES"></span>
|
|
</dd>
|
|
<dt><code>.EXPORT_ALL_VARIABLES</code></dt>
|
|
<dd>
|
|
<p>Simply by being mentioned as a target, this tells <code>make</code> to export all
|
|
variables to child processes by default. This is an alternative to using
|
|
<code>export</code> with no arguments. See <a href="#Variables_002fRecursion">Communicating
|
|
Variables to a Sub-<code>make</code></a>.
|
|
</p>
|
|
<span id="index-_002eNOTPARALLEL"></span>
|
|
</dd>
|
|
<dt><code>.NOTPARALLEL</code></dt>
|
|
<dd><span id="index-parallel-execution_002c-overriding"></span>
|
|
|
|
<p>If <code>.NOTPARALLEL</code> is mentioned as a target with no prerequisites, all
|
|
targets in this invocation of <code>make</code> will be run serially, even if the
|
|
‘<samp>-j</samp>’ option is given. Any recursively invoked <code>make</code> command will
|
|
still run recipes in parallel (unless its makefile also contains this target).
|
|
</p>
|
|
<p>If <code>.NOTPARALLEL</code> has targets as prerequisites, then all the
|
|
prerequisites of those targets will be run serially. This implicitly adds a
|
|
<code>.WAIT</code> between each prerequisite of the listed targets. See <a href="#Parallel-Disable">Disabling Parallel Execution</a>.
|
|
</p>
|
|
<span id="index-_002eONESHELL"></span>
|
|
</dd>
|
|
<dt><code>.ONESHELL</code></dt>
|
|
<dd><span id="index-recipe-execution_002c-single-invocation"></span>
|
|
|
|
<p>If <code>.ONESHELL</code> is mentioned as a target, then when a target is
|
|
built all lines of the recipe will be given to a single invocation of
|
|
the shell rather than each line being invoked separately.
|
|
See <a href="#Execution">Recipe Execution</a>.
|
|
</p>
|
|
<span id="index-_002ePOSIX"></span>
|
|
</dd>
|
|
<dt><code>.POSIX</code></dt>
|
|
<dd><span id="index-POSIX_002dconforming-mode_002c-setting"></span>
|
|
|
|
<p>If <code>.POSIX</code> is mentioned as a target, then the makefile will be
|
|
parsed and run in POSIX-conforming mode. This does <em>not</em> mean
|
|
that only POSIX-conforming makefiles will be accepted: all advanced
|
|
GNU <code>make</code> features are still available. Rather, this target
|
|
causes <code>make</code> to behave as required by POSIX in those areas
|
|
where <code>make</code>’s default behavior differs.
|
|
</p>
|
|
<p>In particular, if this target is mentioned then recipes will be
|
|
invoked as if the shell had been passed the <code>-e</code> flag: the first
|
|
failing command in a recipe will cause the recipe to fail immediately.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Any defined implicit rule suffix also counts as a special target if it
|
|
appears as a target, and so does the concatenation of two suffixes, such
|
|
as ‘<samp>.c.o</samp>’. These targets are suffix rules, an obsolete way of
|
|
defining implicit rules (but a way still widely used). In principle, any
|
|
target name could be special in this way if you break it in two and add
|
|
both pieces to the suffix list. In practice, suffixes normally begin with
|
|
‘<samp>.</samp>’, so these special target names also begin with ‘<samp>.</samp>’.
|
|
See <a href="#Suffix-Rules">Old-Fashioned Suffix Rules</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Multiple-Targets"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Multiple-Rules" accesskey="n" rel="next">Multiple Rules</a>, Previous: <a href="#Special-Targets" accesskey="p" rel="prev">Special Targets</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Multiple-Targets-in-a-Rule"></span><h3 class="section">4.10 Multiple Targets in a Rule</h3>
|
|
<span id="index-multiple-targets"></span>
|
|
<span id="index-several-targets-in-a-rule"></span>
|
|
<span id="index-targets_002c-multiple"></span>
|
|
<span id="index-rule_002c-with-multiple-targets"></span>
|
|
|
|
<p>When an explicit rule has multiple targets they can be treated in one
|
|
of two possible ways: as independent targets or as grouped targets.
|
|
The manner in which they are treated is determined by the separator that
|
|
appears after the list of targets.
|
|
</p>
|
|
<span id="Rules-with-Independent-Targets"></span><h4 class="subsubheading">Rules with Independent Targets</h4>
|
|
<span id="index-independent-targets"></span>
|
|
<span id="index-targets_002c-independent"></span>
|
|
|
|
<p>Rules that use the standard target separator, <code>:</code>, define
|
|
independent targets. This is equivalent to writing the same rule once
|
|
for each target, with duplicated prerequisites and recipes. Typically,
|
|
the recipe would use automatic variables such as ‘<samp>$@</samp>’ to specify
|
|
which target is being built.
|
|
</p>
|
|
<p>Rules with independent targets are useful in two cases:
|
|
</p>
|
|
<ul>
|
|
<li> You want just prerequisites, no recipe. For example:
|
|
|
|
<div class="example">
|
|
<pre class="example">kbd.o command.o files.o: command.h
|
|
</pre></div>
|
|
|
|
<p>gives an additional prerequisite to each of the three object files
|
|
mentioned. It is equivalent to writing:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">kbd.o: command.h
|
|
command.o: command.h
|
|
files.o: command.h
|
|
</pre></div>
|
|
|
|
</li><li> Similar recipes work for all the targets. The automatic variable
|
|
‘<samp>$@</samp>’ can be used to substitute the particular target to be
|
|
remade into the commands (see <a href="#Automatic-Variables">Automatic Variables</a>). For example:
|
|
|
|
<div class="example">
|
|
<pre class="example">bigoutput littleoutput : text.g
|
|
generate text.g -$(subst output,,$@) > $@
|
|
</pre></div>
|
|
<span id="index-subst"></span>
|
|
|
|
<p>is equivalent to
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">bigoutput : text.g
|
|
generate text.g -big > bigoutput
|
|
littleoutput : text.g
|
|
generate text.g -little > littleoutput
|
|
</pre></div>
|
|
|
|
<p>Here we assume the hypothetical program <code>generate</code> makes two
|
|
types of output, one if given ‘<samp>-big</samp>’ and one if given
|
|
‘<samp>-little</samp>’.
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>,
|
|
for an explanation of the <code>subst</code> function.
|
|
</p></li></ul>
|
|
|
|
<p>Suppose you would like to vary the prerequisites according to the
|
|
target, much as the variable ‘<samp>$@</samp>’ allows you to vary the recipe.
|
|
You cannot do this with multiple targets in an ordinary rule, but you
|
|
can do it with a <em>static pattern rule</em>. See <a href="#Static-Pattern">Static Pattern Rules</a>.
|
|
</p>
|
|
<span id="Rules-with-Grouped-Targets"></span><h4 class="subsubheading">Rules with Grouped Targets</h4>
|
|
<span id="index-grouped-targets"></span>
|
|
<span id="index-targets_002c-grouped"></span>
|
|
|
|
<p>If instead of independent targets you have a recipe that generates multiple
|
|
files from a single invocation, you can express that relationship by declaring
|
|
your rule to use <em>grouped targets</em>. A grouped target rule uses the
|
|
separator <code>&:</code> (the ‘<samp>&</samp>’ here is used to imply “all”).
|
|
</p>
|
|
<p>When <code>make</code> builds any one of the grouped targets, it understands that
|
|
all the other targets in the group are also updated as a result of the
|
|
invocation of the recipe. Furthermore, if only some of the grouped targets
|
|
are out of date or missing <code>make</code> will realize that running the recipe
|
|
will update all of the targets. Finally, if any of the grouped targets are
|
|
out of date, all the grouped targets are considered out of date.
|
|
</p>
|
|
<p>As an example, this rule defines a grouped target:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo bar biz &: baz boz
|
|
echo $^ > foo
|
|
echo $^ > bar
|
|
echo $^ > biz
|
|
</pre></div>
|
|
|
|
<p>During the execution of a grouped target’s recipe, the automatic
|
|
variable ‘<samp>$@</samp>’ is set to the name of the particular target in the
|
|
group which triggered the rule. Caution must be used if relying on
|
|
this variable in the recipe of a grouped target rule.
|
|
</p>
|
|
<p>Unlike independent targets, a grouped target rule <em>must</em> include
|
|
a recipe. However, targets that are members of a grouped target may
|
|
also appear in independent target rule definitions that do not have
|
|
recipes.
|
|
</p>
|
|
<p>Each target may have only one recipe associated with it. If a grouped
|
|
target appears in either an independent target rule or in another
|
|
grouped target rule with a recipe, you will get a warning and the
|
|
latter recipe will replace the former recipe. Additionally the target
|
|
will be removed from the previous group and appear only in the new
|
|
group.
|
|
</p>
|
|
<p>If you would like a target to appear in multiple groups, then you must
|
|
use the double-colon grouped target separator, <code>&::</code> when
|
|
declaring all of the groups containing that target. Grouped
|
|
double-colon targets are each considered independently, and each
|
|
grouped double-colon rule’s recipe is executed at most once, if at
|
|
least one of its multiple targets requires updating.
|
|
</p>
|
|
<hr>
|
|
<span id="Multiple-Rules"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Static-Pattern" accesskey="n" rel="next">Static Pattern</a>, Previous: <a href="#Multiple-Targets" accesskey="p" rel="prev">Multiple Targets</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Multiple-Rules-for-One-Target"></span><h3 class="section">4.11 Multiple Rules for One Target</h3>
|
|
<span id="index-multiple-rules-for-one-target"></span>
|
|
<span id="index-several-rules-for-one-target"></span>
|
|
<span id="index-rule_002c-multiple-for-one-target"></span>
|
|
<span id="index-target_002c-multiple-rules-for-one"></span>
|
|
|
|
<p>One file can be the target of several rules. All the prerequisites
|
|
mentioned in all the rules are merged into one list of prerequisites for
|
|
the target. If the target is older than any prerequisite from any rule,
|
|
the recipe is executed.
|
|
</p>
|
|
<p>There can only be one recipe to be executed for a file. If more than
|
|
one rule gives a recipe for the same file, <code>make</code> uses the last
|
|
one given and prints an error message. (As a special case, if the
|
|
file’s name begins with a dot, no error message is printed. This odd
|
|
behavior is only for compatibility with other implementations of
|
|
<code>make</code>… you should avoid using it). Occasionally it is
|
|
useful to have the same target invoke multiple recipes which are
|
|
defined in different parts of your makefile; you can use
|
|
<em>double-colon rules</em> (see <a href="#Double_002dColon">Double-Colon</a>) for this.
|
|
</p>
|
|
<p>An extra rule with just prerequisites can be used to give a few extra
|
|
prerequisites to many files at once. For example, makefiles often
|
|
have a variable, such as <code>objects</code>, containing a list of all the
|
|
compiler output files in the system being made. An easy way to say
|
|
that all of them must be recompiled if <samp>config.h</samp> changes is to
|
|
write the following:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = foo.o bar.o
|
|
foo.o : defs.h
|
|
bar.o : defs.h test.h
|
|
$(objects) : config.h
|
|
</pre></div>
|
|
|
|
<p>This could be inserted or taken out without changing the rules that really
|
|
specify how to make the object files, making it a convenient form to use if
|
|
you wish to add the additional prerequisite intermittently.
|
|
</p>
|
|
<p>Another wrinkle is that the additional prerequisites could be
|
|
specified with a variable that you set with a command line argument to
|
|
<code>make</code> (see <a href="#Overriding">Overriding Variables</a>). For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">extradeps=
|
|
$(objects) : $(extradeps)
|
|
</pre></div>
|
|
|
|
<p>means that the command ‘<samp>make extradeps=foo.h</samp>’ will consider
|
|
<samp>foo.h</samp> as a prerequisite of each object file, but plain ‘<samp>make</samp>’
|
|
will not.
|
|
</p>
|
|
<p>If none of the explicit rules for a target has a recipe, then <code>make</code>
|
|
searches for an applicable implicit rule to find one
|
|
see <a href="#Implicit-Rules">Using Implicit Rules</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Static-Pattern"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Double_002dColon" accesskey="n" rel="next">Double-Colon</a>, Previous: <a href="#Multiple-Rules" accesskey="p" rel="prev">Multiple Rules</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Static-Pattern-Rules"></span><h3 class="section">4.12 Static Pattern Rules</h3>
|
|
<span id="index-static-pattern-rule"></span>
|
|
<span id="index-rule_002c-static-pattern"></span>
|
|
<span id="index-pattern-rules_002c-static-_0028not-implicit_0029"></span>
|
|
<span id="index-varying-prerequisites"></span>
|
|
<span id="index-prerequisites_002c-varying-_0028static-pattern_0029"></span>
|
|
|
|
<p><em>Static pattern rules</em> are rules which specify multiple targets and
|
|
construct the prerequisite names for each target based on the target name.
|
|
They are more general than ordinary rules with multiple targets because the
|
|
targets do not have to have identical prerequisites. Their prerequisites must
|
|
be <em>analogous</em>, but not necessarily <em>identical</em>.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Static-Usage" accesskey="1">Static Usage</a></td><td> </td><td align="left" valign="top">The syntax of static pattern rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Static-versus-Implicit" accesskey="2">Static versus Implicit</a></td><td> </td><td align="left" valign="top">When are they better than implicit rules?
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Static-Usage"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Static-versus-Implicit" accesskey="n" rel="next">Static versus Implicit</a>, Previous: <a href="#Static-Pattern" accesskey="p" rel="prev">Static Pattern</a>, Up: <a href="#Static-Pattern" accesskey="u" rel="up">Static Pattern</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Syntax-of-Static-Pattern-Rules"></span><h4 class="subsection">4.12.1 Syntax of Static Pattern Rules</h4>
|
|
<span id="index-static-pattern-rule_002c-syntax-of"></span>
|
|
<span id="index-pattern-rules_002c-static_002c-syntax-of"></span>
|
|
|
|
<p>Here is the syntax of a static pattern rule:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>targets</var> …: <var>target-pattern</var>: <var>prereq-patterns</var> …
|
|
<var>recipe</var>
|
|
…
|
|
</pre></div>
|
|
|
|
<p>The <var>targets</var> list specifies the targets that the rule applies to.
|
|
The targets can contain wildcard characters, just like the targets of
|
|
ordinary rules (see <a href="#Wildcards">Using Wildcard Characters in File
|
|
Names</a>).
|
|
</p>
|
|
<span id="index-target-pattern_002c-static-_0028not-implicit_0029"></span>
|
|
<span id="index-stem"></span>
|
|
<p>The <var>target-pattern</var> and <var>prereq-patterns</var> say how to compute the
|
|
prerequisites of each target. Each target is matched against the
|
|
<var>target-pattern</var> to extract a part of the target name, called the
|
|
<em>stem</em>. This stem is substituted into each of the <var>prereq-patterns</var>
|
|
to make the prerequisite names (one from each <var>prereq-pattern</var>).
|
|
</p>
|
|
<p>Each pattern normally contains the character ‘<samp>%</samp>’ just once. When the
|
|
<var>target-pattern</var> matches a target, the ‘<samp>%</samp>’ can match any part of
|
|
the target name; this part is called the <em>stem</em>. The rest of the
|
|
pattern must match exactly. For example, the target <samp>foo.o</samp> matches
|
|
the pattern ‘<samp>%.o</samp>’, with ‘<samp>foo</samp>’ as the stem. The targets
|
|
<samp>foo.c</samp> and <samp>foo.out</samp> do not match that pattern.
|
|
</p>
|
|
<span id="index-prerequisite-pattern_002c-static-_0028not-implicit_0029"></span>
|
|
<p>The prerequisite names for each target are made by substituting the stem
|
|
for the ‘<samp>%</samp>’ in each prerequisite pattern. For example, if one
|
|
prerequisite pattern is <samp>%.c</samp>, then substitution of the stem
|
|
‘<samp>foo</samp>’ gives the prerequisite name <samp>foo.c</samp>. It is legitimate
|
|
to write a prerequisite pattern that does not contain ‘<samp>%</samp>’; then this
|
|
prerequisite is the same for all targets.
|
|
</p>
|
|
<span id="index-_0025_002c-quoting-in-static-pattern"></span>
|
|
<span id="index-_0025_002c-quoting-with-_005c-_0028backslash_0029-1"></span>
|
|
<span id="index-_005c-_0028backslash_0029_002c-to-quote-_0025-1"></span>
|
|
<span id="index-backslash-_0028_005c_0029_002c-to-quote-_0025-1"></span>
|
|
<span id="index-quoting-_0025_002c-in-static-pattern"></span>
|
|
<p>‘<samp>%</samp>’ characters in pattern rules can be quoted with preceding
|
|
backslashes (‘<samp>\</samp>’). Backslashes that would otherwise quote ‘<samp>%</samp>’
|
|
characters can be quoted with more backslashes. Backslashes that quote
|
|
‘<samp>%</samp>’ characters or other backslashes are removed from the pattern
|
|
before it is compared to file names or has a stem substituted into it.
|
|
Backslashes that are not in danger of quoting ‘<samp>%</samp>’ characters go
|
|
unmolested. For example, the pattern <samp>the\%weird\\%pattern\\</samp> has
|
|
‘<samp>the%weird\</samp>’ preceding the operative ‘<samp>%</samp>’ character, and
|
|
‘<samp>pattern\\</samp>’ following it. The final two backslashes are left alone
|
|
because they cannot affect any ‘<samp>%</samp>’ character.
|
|
</p>
|
|
<p>Here is an example, which compiles each of <samp>foo.o</samp> and <samp>bar.o</samp>
|
|
from the corresponding <samp>.c</samp> file:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = foo.o bar.o
|
|
|
|
all: $(objects)
|
|
|
|
$(objects): %.o: %.c
|
|
$(CC) -c $(CFLAGS) $< -o $@
|
|
</pre></div>
|
|
|
|
<p>Here ‘<samp>$<</samp>’ is the automatic variable that holds the name of the
|
|
prerequisite and ‘<samp>$@</samp>’ is the automatic variable that holds the name
|
|
of the target; see <a href="#Automatic-Variables">Automatic Variables</a>.
|
|
</p>
|
|
<p>Each target specified must match the target pattern; a warning is issued
|
|
for each target that does not. If you have a list of files, only some of
|
|
which will match the pattern, you can use the <code>filter</code> function to
|
|
remove non-matching file names (see <a href="#Text-Functions">Functions for String Substitution and Analysis</a>):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">files = foo.elc bar.o lose.o
|
|
|
|
$(filter %.o,$(files)): %.o: %.c
|
|
$(CC) -c $(CFLAGS) $< -o $@
|
|
$(filter %.elc,$(files)): %.elc: %.el
|
|
emacs -f batch-byte-compile $<
|
|
</pre></div>
|
|
|
|
<p>In this example the result of ‘<samp>$(filter %.o,$(files))</samp>’ is
|
|
<samp>bar.o lose.o</samp>, and the first static pattern rule causes each of
|
|
these object files to be updated by compiling the corresponding C source
|
|
file. The result of ‘<samp>$(filter %.elc,$(files))</samp>’<!-- /@w --> is
|
|
<samp>foo.elc</samp>, so that file is made from <samp>foo.el</samp>.
|
|
</p>
|
|
<p>Another example shows how to use <code>$*</code> in static pattern rules:
|
|
<span id="index-_0024_002a_002c-and-static-pattern"></span>
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">bigoutput littleoutput : %output : text.g
|
|
generate text.g -$* > $@
|
|
</pre></div>
|
|
|
|
<p>When the <code>generate</code> command is run, <code>$*</code> will expand to the
|
|
stem, either ‘<samp>big</samp>’ or ‘<samp>little</samp>’.
|
|
</p>
|
|
<hr>
|
|
<span id="Static-versus-Implicit"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Static-Usage" accesskey="p" rel="prev">Static Usage</a>, Up: <a href="#Static-Pattern" accesskey="u" rel="up">Static Pattern</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Static-Pattern-Rules-versus-Implicit-Rules"></span><h4 class="subsection">4.12.2 Static Pattern Rules versus Implicit Rules</h4>
|
|
<span id="index-rule_002c-static-pattern-versus-implicit"></span>
|
|
<span id="index-static-pattern-rule_002c-versus-implicit"></span>
|
|
|
|
<p>A static pattern rule has much in common with an implicit rule defined as a
|
|
pattern rule (see <a href="#Pattern-Rules">Defining and Redefining Pattern Rules</a>).
|
|
Both have a pattern for the target and patterns for constructing the
|
|
names of prerequisites. The difference is in how <code>make</code> decides
|
|
<em>when</em> the rule applies.
|
|
</p>
|
|
<p>An implicit rule <em>can</em> apply to any target that matches its pattern,
|
|
but it <em>does</em> apply only when the target has no recipe otherwise
|
|
specified, and only when the prerequisites can be found. If more than one
|
|
implicit rule appears applicable, only one applies; the choice depends on
|
|
the order of rules.
|
|
</p>
|
|
<p>By contrast, a static pattern rule applies to the precise list of targets
|
|
that you specify in the rule. It cannot apply to any other target and it
|
|
invariably does apply to each of the targets specified. If two conflicting
|
|
rules apply, and both have recipes, that’s an error.
|
|
</p>
|
|
<p>The static pattern rule can be better than an implicit rule for these
|
|
reasons:
|
|
</p>
|
|
<ul>
|
|
<li> You may wish to override the usual implicit rule for a few
|
|
files whose names cannot be categorized syntactically but
|
|
can be given in an explicit list.
|
|
|
|
</li><li> If you cannot be sure of the precise contents of the directories
|
|
you are using, you may not be sure which other irrelevant files
|
|
might lead <code>make</code> to use the wrong implicit rule. The choice
|
|
might depend on the order in which the implicit rule search is done.
|
|
With static pattern rules, there is no uncertainty: each rule applies
|
|
to precisely the targets specified.
|
|
</li></ul>
|
|
|
|
<hr>
|
|
<span id="Double_002dColon"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Automatic-Prerequisites" accesskey="n" rel="next">Automatic Prerequisites</a>, Previous: <a href="#Static-Pattern" accesskey="p" rel="prev">Static Pattern</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Double_002dColon-Rules"></span><h3 class="section">4.13 Double-Colon Rules</h3>
|
|
<span id="index-double_002dcolon-rules"></span>
|
|
<span id="index-rule_002c-double_002dcolon-_0028_003a_003a_0029"></span>
|
|
<span id="index-multiple-rules-for-one-target-_0028_003a_003a_0029"></span>
|
|
<span id="index-_003a_003a-rules-_0028double_002dcolon_0029"></span>
|
|
|
|
<p><em>Double-colon</em> rules are explicit rules written with ‘<samp>::</samp>’
|
|
instead of ‘<samp>:</samp>’ after the target names. They are handled
|
|
differently from ordinary rules when the same target appears in more
|
|
than one rule. Pattern rules with double-colons have an entirely
|
|
different meaning (see <a href="#Match_002dAnything-Rules">Match-Anything Rules</a>).
|
|
</p>
|
|
<p>When a target appears in multiple rules, all the rules must be the same
|
|
type: all ordinary, or all double-colon. If they are double-colon, each
|
|
of them is independent of the others. Each double-colon rule’s recipe
|
|
is executed if the target is older than any prerequisites of that rule.
|
|
If there are no prerequisites for that rule, its recipe is always
|
|
executed (even if the target already exists). This can result in
|
|
executing none, any, or all of the double-colon rules.
|
|
</p>
|
|
<p>Double-colon rules with the same target are in fact completely separate
|
|
from one another. Each double-colon rule is processed individually, just
|
|
as rules with different targets are processed.
|
|
</p>
|
|
<p>The double-colon rules for a target are executed in the order they appear
|
|
in the makefile. However, the cases where double-colon rules really make
|
|
sense are those where the order of executing the recipes would not matter.
|
|
</p>
|
|
<p>Double-colon rules are somewhat obscure and not often very useful; they
|
|
provide a mechanism for cases in which the method used to update a target
|
|
differs depending on which prerequisite files caused the update, and such
|
|
cases are rare.
|
|
</p>
|
|
<p>Each double-colon rule should specify a recipe; if it does not, an
|
|
implicit rule will be used if one applies.
|
|
See <a href="#Implicit-Rules">Using Implicit Rules</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Automatic-Prerequisites"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Double_002dColon" accesskey="p" rel="prev">Double-Colon</a>, Up: <a href="#Rules" accesskey="u" rel="up">Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Generating-Prerequisites-Automatically"></span><h3 class="section">4.14 Generating Prerequisites Automatically</h3>
|
|
<span id="index-prerequisites_002c-automatic-generation-1"></span>
|
|
<span id="index-automatic-generation-of-prerequisites-1"></span>
|
|
<span id="index-generating-prerequisites-automatically-1"></span>
|
|
|
|
<p>In the makefile for a program, many of the rules you need to write often
|
|
say only that some object file depends on some header
|
|
file. For example, if <samp>main.c</samp> uses <samp>defs.h</samp> via an
|
|
<code>#include</code>, you would write:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">main.o: defs.h
|
|
</pre></div>
|
|
|
|
<p>You need this rule so that <code>make</code> knows that it must remake
|
|
<samp>main.o</samp> whenever <samp>defs.h</samp> changes. You can see that for a
|
|
large program you would have to write dozens of such rules in your
|
|
makefile. And, you must always be very careful to update the makefile
|
|
every time you add or remove an <code>#include</code>.
|
|
<span id="index-_0023include"></span>
|
|
</p>
|
|
<span id="index-_002dM-_0028to-compiler_0029"></span>
|
|
<p>To avoid this hassle, most modern C compilers can write these rules for
|
|
you, by looking at the <code>#include</code> lines in the source files.
|
|
Usually this is done with the ‘<samp>-M</samp>’ option to the compiler.
|
|
For example, the command:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">cc -M main.c
|
|
</pre></div>
|
|
|
|
<p>generates the output:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">main.o : main.c defs.h
|
|
</pre></div>
|
|
|
|
<p>Thus you no longer have to write all those rules yourself.
|
|
The compiler will do it for you.
|
|
</p>
|
|
<p>Note that such a rule constitutes mentioning <samp>main.o</samp> in a
|
|
makefile, so it can never be considered an intermediate file by
|
|
implicit rule search. This means that <code>make</code> won’t ever remove
|
|
the file after using it; see <a href="#Chained-Rules">Chains of Implicit
|
|
Rules</a>.
|
|
</p>
|
|
<span id="index-make-depend"></span>
|
|
<p>With old <code>make</code> programs, it was traditional practice to use this
|
|
compiler feature to generate prerequisites on demand with a command like
|
|
‘<samp>make depend</samp>’. That command would create a file <samp>depend</samp>
|
|
containing all the automatically-generated prerequisites; then the
|
|
makefile could use <code>include</code> to read them in (see <a href="#Include">Include</a>).
|
|
</p>
|
|
<p>In GNU <code>make</code>, the feature of remaking makefiles makes this
|
|
practice obsolete—you need never tell <code>make</code> explicitly to
|
|
regenerate the prerequisites, because it always regenerates any makefile
|
|
that is out of date. See <a href="#Remaking-Makefiles">Remaking Makefiles</a>.
|
|
</p>
|
|
<p>The practice we recommend for automatic prerequisite generation is to have
|
|
one makefile corresponding to each source file. For each source file
|
|
<samp><var>name</var>.c</samp> there is a makefile <samp><var>name</var>.d</samp> which lists
|
|
what files the object file <samp><var>name</var>.o</samp> depends on. That way
|
|
only the source files that have changed need to be rescanned to produce
|
|
the new prerequisites.
|
|
</p>
|
|
<p>Here is the pattern rule to generate a file of prerequisites (i.e., a makefile)
|
|
called <samp><var>name</var>.d</samp> from a C source file called <samp><var>name</var>.c</samp>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.d: %.c
|
|
@set -e; rm -f $@; \
|
|
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
|
|
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
|
rm -f $@.$$$$
|
|
</pre></div>
|
|
|
|
<p>See <a href="#Pattern-Rules">Pattern Rules</a>, for information on defining pattern rules. The
|
|
‘<samp>-e</samp>’ flag to the shell causes it to exit immediately if the
|
|
<code>$(CC)</code> command (or any other command) fails (exits with a
|
|
nonzero status).
|
|
<span id="index-_002de-_0028shell-flag_0029"></span>
|
|
</p>
|
|
<span id="index-_002dMM-_0028to-GNU-compiler_0029"></span>
|
|
<p>With the GNU C compiler, you may wish to use the ‘<samp>-MM</samp>’ flag instead
|
|
of ‘<samp>-M</samp>’. This omits prerequisites on system header files.
|
|
See <a href="https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options">Options Controlling the Preprocessor</a> in <cite>Using GNU CC</cite>, for details.
|
|
</p>
|
|
<span id="index-sed-_0028shell-command_0029"></span>
|
|
<p>The purpose of the <code>sed</code> command is to translate (for example):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">main.o : main.c defs.h
|
|
</pre></div>
|
|
|
|
<p>into:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">main.o main.d : main.c defs.h
|
|
</pre></div>
|
|
|
|
<p><span id="index-_002ed"></span>
|
|
This makes each ‘<samp>.d</samp>’ file depend on all the source and header files
|
|
that the corresponding ‘<samp>.o</samp>’ file depends on. <code>make</code> then
|
|
knows it must regenerate the prerequisites whenever any of the source or
|
|
header files changes.
|
|
</p>
|
|
<p>Once you’ve defined the rule to remake the ‘<samp>.d</samp>’ files,
|
|
you then use the <code>include</code> directive to read them all in.
|
|
See <a href="#Include">Include</a>. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">sources = foo.c bar.c
|
|
|
|
include $(sources:.c=.d)
|
|
</pre></div>
|
|
|
|
<p>(This example uses a substitution variable reference to translate the
|
|
list of source files ‘<samp>foo.c bar.c</samp>’ into a list of prerequisite
|
|
makefiles, ‘<samp>foo.d bar.d</samp>’. See <a href="#Substitution-Refs">Substitution Refs</a>, for full
|
|
information on substitution references.) Since the ‘<samp>.d</samp>’ files are
|
|
makefiles like any others, <code>make</code> will remake them as necessary
|
|
with no further work from you. See <a href="#Remaking-Makefiles">Remaking Makefiles</a>.
|
|
</p>
|
|
<p>Note that the ‘<samp>.d</samp>’ files contain target definitions; you should
|
|
be sure to place the <code>include</code> directive <em>after</em> the first,
|
|
default goal in your makefiles or run the risk of having a random
|
|
object file become the default goal.
|
|
See <a href="#How-Make-Works">How Make Works</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Recipes"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Using-Variables" accesskey="n" rel="next">Using Variables</a>, Previous: <a href="#Rules" accesskey="p" rel="prev">Rules</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Writing-Recipes-in-Rules"></span><h2 class="chapter">5 Writing Recipes in Rules</h2>
|
|
<span id="index-recipes-1"></span>
|
|
<span id="index-recipes_002c-how-to-write"></span>
|
|
<span id="index-writing-recipes"></span>
|
|
|
|
<p>The recipe of a rule consists of one or more shell command lines to
|
|
be executed, one at a time, in the order they appear. Typically, the
|
|
result of executing these commands is that the target of the rule is
|
|
brought up to date.
|
|
</p>
|
|
<p>Users use many different shell programs, but recipes in makefiles are
|
|
always interpreted by <samp>/bin/sh</samp> unless the makefile specifies
|
|
otherwise. See <a href="#Execution">Recipe Execution</a>.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Recipe-Syntax" accesskey="1">Recipe Syntax</a></td><td> </td><td align="left" valign="top">Recipe syntax features and pitfalls.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Echoing" accesskey="2">Echoing</a></td><td> </td><td align="left" valign="top">How to control when recipes are echoed.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Execution" accesskey="3">Execution</a></td><td> </td><td align="left" valign="top">How recipes are executed.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Parallel" accesskey="4">Parallel</a></td><td> </td><td align="left" valign="top">How recipes can be executed in parallel.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Errors" accesskey="5">Errors</a></td><td> </td><td align="left" valign="top">What happens after a recipe execution error.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Interrupts" accesskey="6">Interrupts</a></td><td> </td><td align="left" valign="top">What happens when a recipe is interrupted.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Recursion" accesskey="7">Recursion</a></td><td> </td><td align="left" valign="top">Invoking <code>make</code> from makefiles.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Canned-Recipes" accesskey="8">Canned Recipes</a></td><td> </td><td align="left" valign="top">Defining canned recipes.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Empty-Recipes" accesskey="9">Empty Recipes</a></td><td> </td><td align="left" valign="top">Defining useful, do-nothing recipes.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Recipe-Syntax"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Echoing" accesskey="n" rel="next">Echoing</a>, Previous: <a href="#Recipes" accesskey="p" rel="prev">Recipes</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Recipe-Syntax-1"></span><h3 class="section">5.1 Recipe Syntax</h3>
|
|
<span id="index-recipe-syntax"></span>
|
|
<span id="index-syntax-of-recipe"></span>
|
|
|
|
<p>Makefiles have the unusual property that there are really two distinct
|
|
syntaxes in one file. Most of the makefile uses <code>make</code> syntax
|
|
(see <a href="#Makefiles">Writing Makefiles</a>). However, recipes are meant
|
|
to be interpreted by the shell and so they are written using shell
|
|
syntax. The <code>make</code> program does not try to understand shell
|
|
syntax: it performs only a very few specific translations on the
|
|
content of the recipe before handing it to the shell.
|
|
</p>
|
|
<p>Each line in the recipe must start with a tab (or the first character
|
|
in the value of the <code>.RECIPEPREFIX</code> variable; see <a href="#Special-Variables">Special Variables</a>), except that the first recipe line may be attached to the
|
|
target-and-prerequisites line with a semicolon in between. <em>Any</em>
|
|
line in the makefile that begins with a tab and appears in a “rule
|
|
context” (that is, after a rule has been started until another rule
|
|
or variable definition) will be considered part of a recipe for that
|
|
rule. Blank lines and lines of just comments may appear among the
|
|
recipe lines; they are ignored.
|
|
</p>
|
|
<p>Some consequences of these rules include:
|
|
</p>
|
|
<ul>
|
|
<li> A blank line that begins with a tab is not blank: it’s an empty
|
|
recipe (see <a href="#Empty-Recipes">Empty Recipes</a>).
|
|
|
|
</li><li> <span id="index-comments_002c-in-recipes"></span>
|
|
<span id="index-recipes_002c-comments-in"></span>
|
|
<span id="index-_0023-_0028comments_0029_002c-in-recipes"></span>
|
|
A comment in a recipe is not a <code>make</code> comment; it will be
|
|
passed to the shell as-is. Whether the shell treats it as a comment
|
|
or not depends on your shell.
|
|
|
|
</li><li> A variable definition in a “rule context” which is indented by a tab
|
|
as the first character on the line, will be considered part of a
|
|
recipe, not a <code>make</code> variable definition, and passed to the
|
|
shell.
|
|
|
|
</li><li> A conditional expression (<code>ifdef</code>, <code>ifeq</code>,
|
|
etc. see <a href="#Conditional-Syntax">Syntax of Conditionals</a>) in a “rule
|
|
context” which is indented by a tab as the first character on the
|
|
line, will be considered part of a recipe and be passed to the shell.
|
|
|
|
</li></ul>
|
|
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Splitting-Recipe-Lines" accesskey="1">Splitting Recipe Lines</a></td><td> </td><td align="left" valign="top">Breaking long recipe lines for readability.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Variables-in-Recipes" accesskey="2">Variables in Recipes</a></td><td> </td><td align="left" valign="top">Using <code>make</code> variables in recipes.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Splitting-Recipe-Lines"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Variables-in-Recipes" accesskey="n" rel="next">Variables in Recipes</a>, Previous: <a href="#Recipe-Syntax" accesskey="p" rel="prev">Recipe Syntax</a>, Up: <a href="#Recipe-Syntax" accesskey="u" rel="up">Recipe Syntax</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Splitting-Recipe-Lines-1"></span><h4 class="subsection">5.1.1 Splitting Recipe Lines</h4>
|
|
<span id="index-recipes_002c-splitting"></span>
|
|
<span id="index-splitting-recipes"></span>
|
|
<span id="index-recipes_002c-backslash-_0028_005c_0029-in"></span>
|
|
<span id="index-recipes_002c-quoting-newlines-in"></span>
|
|
<span id="index-backslash-_0028_005c_0029_002c-in-recipes"></span>
|
|
<span id="index-_005c-_0028backslash_0029_002c-in-recipes"></span>
|
|
<span id="index-quoting-newline_002c-in-recipes"></span>
|
|
<span id="index-newline_002c-quoting_002c-in-recipes"></span>
|
|
|
|
<p>One of the few ways in which <code>make</code> does interpret recipes is
|
|
checking for a backslash just before the newline. As in normal
|
|
makefile syntax, a single logical recipe line can be split into
|
|
multiple physical lines in the makefile by placing a backslash before
|
|
each newline. A sequence of lines like this is considered a single
|
|
recipe line, and one instance of the shell will be invoked to run it.
|
|
</p>
|
|
<p>However, in contrast to how they are treated in other places in a
|
|
makefile (see <a href="#Splitting-Lines">Splitting Long Lines</a>),
|
|
backslash/newline pairs are <em>not</em> removed from the recipe. Both
|
|
the backslash and the newline characters are preserved and passed to
|
|
the shell. How the backslash/newline is interpreted depends on your
|
|
shell. If the first character of the next line after the
|
|
backslash/newline is the recipe prefix character (a tab by default;
|
|
see <a href="#Special-Variables">Special Variables</a>), then that character (and only that
|
|
character) is removed. Whitespace is never added to the recipe.
|
|
</p>
|
|
<p>For example, the recipe for the all target in this makefile:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">all :
|
|
@echo no\
|
|
space
|
|
@echo no\
|
|
space
|
|
@echo one \
|
|
space
|
|
@echo one\
|
|
space
|
|
</pre></div>
|
|
|
|
<p>consists of four separate shell commands where the output is:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">nospace
|
|
nospace
|
|
one space
|
|
one space
|
|
</pre></div>
|
|
|
|
<p>As a more complex example, this makefile:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">all : ; @echo 'hello \
|
|
world' ; echo "hello \
|
|
world"
|
|
</pre></div>
|
|
|
|
<p>will invoke one shell with a command of:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">echo 'hello \
|
|
world' ; echo "hello \
|
|
world"
|
|
</pre></div>
|
|
|
|
<p>which, according to shell quoting rules, will yield the following output:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">hello \
|
|
world
|
|
hello world
|
|
</pre></div>
|
|
|
|
<p>Notice how the backslash/newline pair was removed inside the string
|
|
quoted with double quotes (<code>"…"</code>), but not from the string
|
|
quoted with single quotes (<code>'…'</code>). This is the way the
|
|
default shell (<samp>/bin/sh</samp>) handles backslash/newline pairs. If
|
|
you specify a different shell in your makefiles it may treat them
|
|
differently.
|
|
</p>
|
|
<p>Sometimes you want to split a long line inside of single quotes, but
|
|
you don’t want the backslash/newline to appear in the quoted content.
|
|
This is often the case when passing scripts to languages such as Perl,
|
|
where extraneous backslashes inside the script can change its meaning
|
|
or even be a syntax error. One simple way of handling this is to
|
|
place the quoted string, or even the entire command, into a
|
|
<code>make</code> variable then use the variable in the recipe. In this
|
|
situation the newline quoting rules for makefiles will be used, and
|
|
the backslash/newline will be removed. If we rewrite our example
|
|
above using this method:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">HELLO = 'hello \
|
|
world'
|
|
|
|
all : ; @echo $(HELLO)
|
|
</pre></div>
|
|
|
|
<p>we will get output like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">hello world
|
|
</pre></div>
|
|
|
|
<p>If you like, you can also use target-specific variables
|
|
(see <a href="#Target_002dspecific">Target-specific Variable Values</a>) to obtain
|
|
a tighter correspondence between the variable and the recipe that
|
|
uses it.
|
|
</p>
|
|
<hr>
|
|
<span id="Variables-in-Recipes"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Splitting-Recipe-Lines" accesskey="p" rel="prev">Splitting Recipe Lines</a>, Up: <a href="#Recipe-Syntax" accesskey="u" rel="up">Recipe Syntax</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Using-Variables-in-Recipes"></span><h4 class="subsection">5.1.2 Using Variables in Recipes</h4>
|
|
<span id="index-variable-references-in-recipes"></span>
|
|
<span id="index-recipes_002c-using-variables-in"></span>
|
|
|
|
<p>The other way in which <code>make</code> processes recipes is by expanding
|
|
any variable references in them (see <a href="#Reference">Basics of Variable
|
|
References</a>). This occurs after make has finished reading all the
|
|
makefiles and the target is determined to be out of date; so, the
|
|
recipes for targets which are not rebuilt are never expanded.
|
|
</p>
|
|
<p>Variable and function references in recipes have identical syntax and
|
|
semantics to references elsewhere in the makefile. They also have the
|
|
same quoting rules: if you want a dollar sign to appear in your
|
|
recipe, you must double it (‘<samp>$$</samp>’). For shells like the default
|
|
shell, that use dollar signs to introduce variables, it’s important to
|
|
keep clear in your mind whether the variable you want to reference is
|
|
a <code>make</code> variable (use a single dollar sign) or a shell variable
|
|
(use two dollar signs). For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">LIST = one two three
|
|
all:
|
|
for i in $(LIST); do \
|
|
echo $$i; \
|
|
done
|
|
</pre></div>
|
|
|
|
<p>results in the following command being passed to the shell:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">for i in one two three; do \
|
|
echo $i; \
|
|
done
|
|
</pre></div>
|
|
|
|
<p>which generates the expected result:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">one
|
|
two
|
|
three
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Echoing"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Execution" accesskey="n" rel="next">Execution</a>, Previous: <a href="#Recipe-Syntax" accesskey="p" rel="prev">Recipe Syntax</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Recipe-Echoing"></span><h3 class="section">5.2 Recipe Echoing</h3>
|
|
<span id="index-echoing-of-recipes"></span>
|
|
<span id="index-silent-operation"></span>
|
|
<span id="index-_0040-_0028in-recipes_0029"></span>
|
|
<span id="index-recipes_002c-echoing"></span>
|
|
<span id="index-printing-of-recipes"></span>
|
|
|
|
<p>Normally <code>make</code> prints each line of the recipe before it is
|
|
executed. We call this <em>echoing</em> because it gives the appearance
|
|
that you are typing the lines yourself.
|
|
</p>
|
|
<p>When a line starts with ‘<samp>@</samp>’, the echoing of that line is suppressed.
|
|
The ‘<samp>@</samp>’ is discarded before the line is passed to the shell.
|
|
Typically you would use this for a command whose only effect is to print
|
|
something, such as an <code>echo</code> command to indicate progress through
|
|
the makefile:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">@echo About to make distribution files
|
|
</pre></div>
|
|
|
|
<span id="index-_002dn"></span>
|
|
<span id="index-_002d_002djust_002dprint"></span>
|
|
<span id="index-_002d_002ddry_002drun"></span>
|
|
<span id="index-_002d_002drecon"></span>
|
|
<p>When <code>make</code> is given the flag ‘<samp>-n</samp>’ or ‘<samp>--just-print</samp>’ it
|
|
only echoes most recipes, without executing them. See <a href="#Options-Summary">Summary of Options</a>. In this case even the recipe lines
|
|
starting with ‘<samp>@</samp>’ are printed. This flag is useful for finding
|
|
out which recipes <code>make</code> thinks are necessary without actually
|
|
doing them.
|
|
</p>
|
|
<span id="index-_002ds"></span>
|
|
<span id="index-_002d_002dsilent"></span>
|
|
<span id="index-_002d_002dquiet"></span>
|
|
<span id="index-_002eSILENT-1"></span>
|
|
<p>The ‘<samp>-s</samp>’ or ‘<samp>--silent</samp>’
|
|
flag to <code>make</code> prevents all echoing, as if all recipes
|
|
started with ‘<samp>@</samp>’. A rule in the makefile for the special target
|
|
<code>.SILENT</code> without prerequisites has the same effect
|
|
(see <a href="#Special-Targets">Special Built-in Target Names</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Execution"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Parallel" accesskey="n" rel="next">Parallel</a>, Previous: <a href="#Echoing" accesskey="p" rel="prev">Echoing</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Recipe-Execution"></span><h3 class="section">5.3 Recipe Execution</h3>
|
|
<span id="index-recipe_002c-execution"></span>
|
|
<span id="index-execution_002c-of-recipes"></span>
|
|
<span id="index-SHELL-_0028recipe-execution_0029"></span>
|
|
|
|
<p>When it is time to execute recipes to update a target, they are
|
|
executed by invoking a new sub-shell for each line of the recipe,
|
|
unless the <code>.ONESHELL</code> special target is in effect
|
|
(see <a href="#One-Shell">Using One Shell</a>) (In practice, <code>make</code> may
|
|
take shortcuts that do not affect the results.)
|
|
</p>
|
|
<span id="index-cd-_0028shell-command_0029"></span>
|
|
<span id="index-shell-variables_002c-setting-in-recipes"></span>
|
|
<span id="index-recipes-setting-shell-variables"></span>
|
|
<p><strong>Please note:</strong> this implies that setting shell variables and
|
|
invoking shell commands such as <code>cd</code> that set a context local to
|
|
each process will not affect the following lines in the recipe.<a id="DOCF3" href="#FOOT3"><sup>3</sup></a> If you want to use <code>cd</code> to affect the next statement,
|
|
put both statements in a single recipe line. Then <code>make</code> will
|
|
invoke one shell to run the entire line, and the shell will execute
|
|
the statements in sequence. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo : bar/lose
|
|
cd $(<D) && gobble $(<F) > ../$@
|
|
</pre></div>
|
|
|
|
<p>Here we use the shell AND operator (<code>&&</code>) so that if the
|
|
<code>cd</code> command fails, the script will fail without trying to invoke
|
|
the <code>gobble</code> command in the wrong directory, which could cause
|
|
problems (in this case it would certainly cause <samp>../foo</samp> to be
|
|
truncated, at least).
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#One-Shell" accesskey="1">One Shell</a></td><td> </td><td align="left" valign="top">One shell for all lines in a recipe.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Choosing-the-Shell" accesskey="2">Choosing the Shell</a></td><td> </td><td align="left" valign="top">How <code>make</code> chooses the shell used
|
|
to run recipes.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="One-Shell"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Choosing-the-Shell" accesskey="n" rel="next">Choosing the Shell</a>, Previous: <a href="#Execution" accesskey="p" rel="prev">Execution</a>, Up: <a href="#Execution" accesskey="u" rel="up">Execution</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Using-One-Shell"></span><h4 class="subsection">5.3.1 Using One Shell</h4>
|
|
<span id="index-recipe-lines_002c-single-shell"></span>
|
|
<span id="index-_002eONESHELL_002c-use-of"></span>
|
|
<span id="index-_002eONESHELL-1"></span>
|
|
|
|
<p>Sometimes you would prefer that all the lines in the recipe be passed
|
|
to a single invocation of the shell. There are generally two
|
|
situations where this is useful: first, it can improve performance in
|
|
makefiles where recipes consist of many command lines, by avoiding
|
|
extra processes. Second, you might want newlines to be included in
|
|
your recipe command (for example perhaps you are using a very
|
|
different interpreter as your <code>SHELL</code>). If the <code>.ONESHELL</code>
|
|
special target appears anywhere in the makefile then <em>all</em>
|
|
recipe lines for each target will be provided to a single invocation
|
|
of the shell. Newlines between recipe lines will be preserved. For
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.ONESHELL:
|
|
foo : bar/lose
|
|
cd $(<D)
|
|
gobble $(<F) > ../$@
|
|
</pre></div>
|
|
|
|
<p>would now work as expected even though the commands are on different
|
|
recipe lines.
|
|
</p>
|
|
<p>If <code>.ONESHELL</code> is provided, then only the first line of the
|
|
recipe will be checked for the special prefix characters (‘<samp>@</samp>’,
|
|
‘<samp>-</samp>’, and ‘<samp>+</samp>’). Subsequent lines will include the special
|
|
characters in the recipe line when the <code>SHELL</code> is invoked. If
|
|
you want your recipe to start with one of these special characters
|
|
you’ll need to arrange for them to not be the first characters on the
|
|
first line, perhaps by adding a comment or similar. For example, this
|
|
would be a syntax error in Perl because the first ‘<samp>@</samp>’ is removed
|
|
by make:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.ONESHELL:
|
|
SHELL = /usr/bin/perl
|
|
.SHELLFLAGS = -e
|
|
show :
|
|
@f = qw(a b c);
|
|
print "@f\n";
|
|
</pre></div>
|
|
|
|
<p>However, either of these alternatives would work properly:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.ONESHELL:
|
|
SHELL = /usr/bin/perl
|
|
.SHELLFLAGS = -e
|
|
show :
|
|
# Make sure "@" is not the first character on the first line
|
|
@f = qw(a b c);
|
|
print "@f\n";
|
|
</pre></div>
|
|
|
|
<p>or
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.ONESHELL:
|
|
SHELL = /usr/bin/perl
|
|
.SHELLFLAGS = -e
|
|
show :
|
|
my @f = qw(a b c);
|
|
print "@f\n";
|
|
</pre></div>
|
|
|
|
<p>As a special feature, if <code>SHELL</code> is determined to be a
|
|
POSIX-style shell, the special prefix characters in “internal”
|
|
recipe lines will be <em>removed</em> before the recipe is processed.
|
|
This feature is intended to allow existing makefiles to add the
|
|
<code>.ONESHELL</code> special target and still run properly without
|
|
extensive modifications. Since the special prefix characters are not
|
|
legal at the beginning of a line in a POSIX shell script this is not a
|
|
loss in functionality. For example, this works as expected:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.ONESHELL:
|
|
foo : bar/lose
|
|
@cd $(@D)
|
|
@gobble $(@F) > ../$@
|
|
</pre></div>
|
|
|
|
<p>Even with this special feature, however, makefiles with
|
|
<code>.ONESHELL</code> will behave differently in ways that could be
|
|
noticeable. For example, normally if any line in the recipe fails,
|
|
that causes the rule to fail and no more recipe lines are processed.
|
|
Under <code>.ONESHELL</code> a failure of any but the final recipe line will
|
|
not be noticed by <code>make</code>. You can modify <code>.SHELLFLAGS</code> to
|
|
add the <code>-e</code> option to the shell which will cause any failure
|
|
anywhere in the command line to cause the shell to fail, but this
|
|
could itself cause your recipe to behave differently. Ultimately you
|
|
may need to harden your recipe lines to allow them to work with
|
|
<code>.ONESHELL</code>.
|
|
</p>
|
|
<hr>
|
|
<span id="Choosing-the-Shell"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#One-Shell" accesskey="p" rel="prev">One Shell</a>, Up: <a href="#Execution" accesskey="u" rel="up">Execution</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Choosing-the-Shell-1"></span><h4 class="subsection">5.3.2 Choosing the Shell</h4>
|
|
<span id="index-shell_002c-choosing-the"></span>
|
|
<span id="index-SHELL_002c-value-of"></span>
|
|
<span id="index-_002eSHELLFLAGS_002c-value-of"></span>
|
|
|
|
<span id="index-SHELL"></span>
|
|
<span id="index-_002eSHELLFLAGS"></span>
|
|
<p>The program used as the shell is taken from the variable <code>SHELL</code>.
|
|
If this variable is not set in your makefile, the program
|
|
<samp>/bin/sh</samp> is used as the shell. The argument(s) passed to the
|
|
shell are taken from the variable <code>.SHELLFLAGS</code>. The default
|
|
value of <code>.SHELLFLAGS</code> is <code>-c</code> normally, or <code>-ec</code> in
|
|
POSIX-conforming mode.
|
|
</p>
|
|
<span id="index-environment_002c-SHELL-in"></span>
|
|
<p>Unlike most variables, the variable <code>SHELL</code> is never set from the
|
|
environment. This is because the <code>SHELL</code> environment variable is
|
|
used to specify your personal choice of shell program for interactive
|
|
use. It would be very bad for personal choices like this to affect the
|
|
functioning of makefiles. See <a href="#Environment">Variables from the
|
|
Environment</a>.
|
|
</p>
|
|
<p>Furthermore, when you do set <code>SHELL</code> in your makefile that value
|
|
is <em>not</em> exported in the environment to recipe lines that
|
|
<code>make</code> invokes. Instead, the value inherited from the user’s
|
|
environment, if any, is exported. You can override this behavior by
|
|
explicitly exporting <code>SHELL</code> (see <a href="#Variables_002fRecursion">Communicating Variables to a Sub-<code>make</code></a>), forcing it to be
|
|
passed in the environment to recipe lines.
|
|
</p>
|
|
<span id="index-MAKESHELL-_0028MS_002dDOS-alternative-to-SHELL_0029"></span>
|
|
<p>However, on MS-DOS and MS-Windows the value of <code>SHELL</code> in the
|
|
environment <strong>is</strong> used, since on those systems most users do not
|
|
set this variable, and therefore it is most likely set specifically to
|
|
be used by <code>make</code>. On MS-DOS, if the setting of <code>SHELL</code> is
|
|
not suitable for <code>make</code>, you can set the variable
|
|
<code>MAKESHELL</code> to the shell that <code>make</code> should use; if set it
|
|
will be used as the shell instead of the value of <code>SHELL</code>.
|
|
</p>
|
|
<span id="Choosing-a-Shell-in-DOS-and-Windows"></span><h4 class="subsubheading">Choosing a Shell in DOS and Windows</h4>
|
|
<span id="index-shell_002c-in-DOS-and-Windows"></span>
|
|
<span id="index-DOS_002c-choosing-a-shell-in"></span>
|
|
<span id="index-Windows_002c-choosing-a-shell-in"></span>
|
|
|
|
<p>Choosing a shell in MS-DOS and MS-Windows is much more complex than on
|
|
other systems.
|
|
</p>
|
|
<span id="index-COMSPEC"></span>
|
|
<p>On MS-DOS, if <code>SHELL</code> is not set, the value of the variable
|
|
<code>COMSPEC</code> (which is always set) is used instead.
|
|
</p>
|
|
<span id="index-SHELL_002c-MS_002dDOS-specifics"></span>
|
|
<p>The processing of lines that set the variable <code>SHELL</code> in Makefiles
|
|
is different on MS-DOS. The stock shell, <samp>command.com</samp>, is
|
|
ridiculously limited in its functionality and many users of <code>make</code>
|
|
tend to install a replacement shell. Therefore, on MS-DOS, <code>make</code>
|
|
examines the value of <code>SHELL</code>, and changes its behavior based on
|
|
whether it points to a Unix-style or DOS-style shell. This allows
|
|
reasonable functionality even if <code>SHELL</code> points to
|
|
<samp>command.com</samp>.
|
|
</p>
|
|
<p>If <code>SHELL</code> points to a Unix-style shell, <code>make</code> on MS-DOS
|
|
additionally checks whether that shell can indeed be found; if not, it
|
|
ignores the line that sets <code>SHELL</code>. In MS-DOS, GNU <code>make</code>
|
|
searches for the shell in the following places:
|
|
</p>
|
|
<ol>
|
|
<li> In the precise place pointed to by the value of <code>SHELL</code>. For
|
|
example, if the makefile specifies ‘<samp>SHELL = /bin/sh</samp>’, <code>make</code>
|
|
will look in the directory <samp>/bin</samp> on the current drive.
|
|
|
|
</li><li> In the current directory.
|
|
|
|
</li><li> In each of the directories in the <code>PATH</code> variable, in order.
|
|
|
|
</li></ol>
|
|
|
|
<p>In every directory it examines, <code>make</code> will first look for the
|
|
specific file (<samp>sh</samp> in the example above). If this is not found,
|
|
it will also look in that directory for that file with one of the known
|
|
extensions which identify executable files. For example <samp>.exe</samp>,
|
|
<samp>.com</samp>, <samp>.bat</samp>, <samp>.btm</samp>, <samp>.sh</samp>, and some others.
|
|
</p>
|
|
<p>If any of these attempts is successful, the value of <code>SHELL</code> will
|
|
be set to the full pathname of the shell as found. However, if none of
|
|
these is found, the value of <code>SHELL</code> will not be changed, and thus
|
|
the line that sets it will be effectively ignored. This is so
|
|
<code>make</code> will only support features specific to a Unix-style shell if
|
|
such a shell is actually installed on the system where <code>make</code> runs.
|
|
</p>
|
|
<p>Note that this extended search for the shell is limited to the cases
|
|
where <code>SHELL</code> is set from the Makefile; if it is set in the
|
|
environment or command line, you are expected to set it to the full
|
|
pathname of the shell, exactly as things are on Unix.
|
|
</p>
|
|
<p>The effect of the above DOS-specific processing is that a Makefile that
|
|
contains ‘<samp>SHELL = /bin/sh</samp>’ (as many Unix makefiles do), will work
|
|
on MS-DOS unaltered if you have e.g. <samp>sh.exe</samp> installed in some
|
|
directory along your <code>PATH</code>.
|
|
</p>
|
|
<span id="index-SHELL-1"></span>
|
|
<span id="index-_002eSHELLFLAGS-1"></span>
|
|
|
|
<hr>
|
|
<span id="Parallel"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Errors" accesskey="n" rel="next">Errors</a>, Previous: <a href="#Execution" accesskey="p" rel="prev">Execution</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Parallel-Execution"></span><h3 class="section">5.4 Parallel Execution</h3>
|
|
<span id="index-recipes_002c-execution-in-parallel"></span>
|
|
<span id="index-parallel-execution"></span>
|
|
<span id="index-execution_002c-in-parallel"></span>
|
|
<span id="index-job-slots"></span>
|
|
<span id="index-_002dj"></span>
|
|
<span id="index-_002d_002djobs"></span>
|
|
|
|
<p>GNU <code>make</code> knows how to execute several recipes at once. Normally,
|
|
<code>make</code> will execute only one recipe at a time, waiting for it to finish
|
|
before executing the next. However, the ‘<samp>-j</samp>’ or ‘<samp>--jobs</samp>’ option
|
|
tells <code>make</code> to execute many recipes simultaneously. You can inhibit
|
|
parallelism for some or all targets from within the makefile (see <a href="#Parallel-Disable">Disabling Parallel Execution</a>).
|
|
</p>
|
|
<p>On MS-DOS, the ‘<samp>-j</samp>’ option has no effect, since that system doesn’t
|
|
support multi-processing.
|
|
</p>
|
|
<p>If the ‘<samp>-j</samp>’ option is followed by an integer, this is the number of
|
|
recipes to execute at once; this is called the number of <em>job slots</em>.
|
|
If there is nothing looking like an integer after the ‘<samp>-j</samp>’ option,
|
|
there is no limit on the number of job slots. The default number of job
|
|
slots is one, which means serial execution (one thing at a time).
|
|
</p>
|
|
<p>Handling recursive <code>make</code> invocations raises issues for parallel
|
|
execution. For more information on this, see <a href="#Options_002fRecursion">Communicating Options to a Sub-<code>make</code></a>.
|
|
</p>
|
|
<p>If a recipe fails (is killed by a signal or exits with a nonzero
|
|
status), and errors are not ignored for that recipe (see <a href="#Errors">Errors in Recipes</a>), the remaining recipe lines to remake the same
|
|
target will not be run. If a recipe fails and the ‘<samp>-k</samp>’ or
|
|
‘<samp>--keep-going</samp>’ option was not given (see <a href="#Options-Summary">Summary of Options</a>), <code>make</code> aborts execution. If make
|
|
terminates for any reason (including a signal) with child processes
|
|
running, it waits for them to finish before actually exiting.
|
|
</p>
|
|
<span id="index-load-average"></span>
|
|
<span id="index-limiting-jobs-based-on-load"></span>
|
|
<span id="index-jobs_002c-limiting-based-on-load"></span>
|
|
<span id="index-_002dl-_0028load-average_0029"></span>
|
|
<span id="index-_002d_002dmax_002dload"></span>
|
|
<span id="index-_002d_002dload_002daverage"></span>
|
|
<p>When the system is heavily loaded, you will probably want to run fewer jobs
|
|
than when it is lightly loaded. You can use the ‘<samp>-l</samp>’ option to tell
|
|
<code>make</code> to limit the number of jobs to run at once, based on the load
|
|
average. The ‘<samp>-l</samp>’ or ‘<samp>--max-load</samp>’
|
|
option is followed by a floating-point number. For
|
|
example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">-l 2.5
|
|
</pre></div>
|
|
|
|
<p>will not let <code>make</code> start more than one job if the load average is
|
|
above 2.5. The ‘<samp>-l</samp>’ option with no following number removes the
|
|
load limit, if one was given with a previous ‘<samp>-l</samp>’ option.
|
|
</p>
|
|
<p>More precisely, when <code>make</code> goes to start up a job, and it already has
|
|
at least one job running, it checks the current load average; if it is not
|
|
lower than the limit given with ‘<samp>-l</samp>’, <code>make</code> waits until the load
|
|
average goes below that limit, or until all the other jobs finish.
|
|
</p>
|
|
<p>By default, there is no load limit.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Parallel-Disable" accesskey="1">Parallel Disable</a></td><td> </td><td align="left" valign="top">Disabling parallel execution
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Parallel-Output" accesskey="2">Parallel Output</a></td><td> </td><td align="left" valign="top">Handling output during parallel execution
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Parallel-Input" accesskey="3">Parallel Input</a></td><td> </td><td align="left" valign="top">Handling input during parallel execution
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Parallel-Disable"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Parallel-Output" accesskey="n" rel="next">Parallel Output</a>, Previous: <a href="#Parallel" accesskey="p" rel="prev">Parallel</a>, Up: <a href="#Parallel" accesskey="u" rel="up">Parallel</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Disabling-Parallel-Execution"></span><h4 class="subsection">5.4.1 Disabling Parallel Execution</h4>
|
|
<span id="index-disabling-parallel-execution"></span>
|
|
<span id="index-parallel-execution_002c-disabling"></span>
|
|
|
|
<p>If a makefile completely and accurately defines the dependency relationships
|
|
between all of its targets, then <code>make</code> will correctly build the goals
|
|
regardless of whether parallel execution is enabled or not. This is the ideal
|
|
way to write makefiles.
|
|
</p>
|
|
<p>However, sometimes some or all of the targets in a makefile cannot be executed
|
|
in parallel and it’s not feasible to add the prerequisites needed to inform
|
|
<code>make</code>. In that case the makefile can use various methods to disable
|
|
parallel execution.
|
|
</p>
|
|
<span id="index-_002eNOTPARALLEL-special-target"></span>
|
|
<span id="index-_002eNOTPARALLEL-1"></span>
|
|
<p>If the <code>.NOTPARALLEL</code> special target with no prerequisites is specified
|
|
anywhere then the entire instance of <code>make</code> will be run serially,
|
|
regardless of the parallel setting. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">all: one two three
|
|
one two three: ; @sleep 1; echo $@
|
|
|
|
.NOTPARALLEL:
|
|
</pre></div>
|
|
|
|
<p>Regardless of how <code>make</code> is invoked, the targets <samp>one</samp>, <samp>two</samp>,
|
|
and <samp>three</samp> will be run serially.
|
|
</p>
|
|
<p>If the <code>.NOTPARALLEL</code> special target has prerequisites, then each of
|
|
those prerequisites will be considered a target and all prerequisites of these
|
|
targets will be run serially. Note that only when building this target will
|
|
the prerequisites be run serially: if some other target lists the same
|
|
prerequisites and is not in <code>.NOTPARALLEL</code> then these prerequisites may
|
|
be run in parallel. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">all: base notparallel
|
|
|
|
base: one two three
|
|
notparallel: one two three
|
|
|
|
one two three: ; @sleep 1; echo $@
|
|
|
|
.NOTPARALLEL: notparallel
|
|
</pre></div>
|
|
|
|
<p>Here ‘<samp>make -j base</samp>’ will run the targets <samp>one</samp>, <samp>two</samp>, and
|
|
<samp>three</samp> in parallel, while ‘<samp>make -j notparallel</samp>’ will run them
|
|
serially. If you run ‘<samp>make -j all</samp>’ then they <em>will</em> be run in
|
|
parallel since <samp>base</samp> lists them as prerequisites and is not serialized.
|
|
</p>
|
|
<p>The <code>.NOTPARALLEL</code> target should not have commands.
|
|
</p>
|
|
<span id="index-_002eWAIT-special-target"></span>
|
|
<span id="index-_002eWAIT"></span>
|
|
<p>Finally you can control the serialization of specific prerequisites in a
|
|
fine-grained way using the <code>.WAIT</code> special target. When this target
|
|
appears in a prerequisite list and parallel execution is enabled, <code>make</code>
|
|
will not build any of the prerequisites to the <em>right</em> of <code>.WAIT</code>
|
|
until all prerequisites to the <em>left</em> of <code>.WAIT</code> have completed.
|
|
For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">all: one two .WAIT three
|
|
one two three: ; @sleep 1; echo $@
|
|
</pre></div>
|
|
|
|
<p>If parallel execution is enabled, <code>make</code> will try to build <samp>one</samp> and
|
|
<samp>two</samp> in parallel but will not try to build <samp>three</samp> until both are
|
|
complete.
|
|
</p>
|
|
<p>As with targets provided to <code>.NOTPARALLEL</code>, <code>.WAIT</code> takes effect
|
|
only when building the target in whose prerequisite list it appears. If the
|
|
same prerequisites are present in other targets, without <code>.WAIT</code>, then
|
|
they may still be run in parallel. Because of this, neither
|
|
<code>.NOTPARALLEL</code> with targets nor <code>.WAIT</code> are as reliable for
|
|
controlling parallel execution as defining a prerequisite relationship.
|
|
However they are easy to use and may be sufficient in less complex situations.
|
|
</p>
|
|
<p>The <code>.WAIT</code> prerequisite will not be present in any of the automatic
|
|
variables for the rule.
|
|
</p>
|
|
<p>You can create an actual target <code>.WAIT</code> in your makefile for portability
|
|
but this is not required to use this feature. If a <code>.WAIT</code> target is
|
|
created it should not have prerequisites or commands.
|
|
</p>
|
|
<p>The <code>.WAIT</code> feature is also implemented in other versions of <code>make</code>
|
|
and it’s specified in the POSIX standard for <code>make</code>.
|
|
</p>
|
|
<hr>
|
|
<span id="Parallel-Output"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Parallel-Input" accesskey="n" rel="next">Parallel Input</a>, Previous: <a href="#Parallel-Disable" accesskey="p" rel="prev">Parallel Disable</a>, Up: <a href="#Parallel" accesskey="u" rel="up">Parallel</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Output-During-Parallel-Execution"></span><h4 class="subsection">5.4.2 Output During Parallel Execution</h4>
|
|
<span id="index-output-during-parallel-execution"></span>
|
|
<span id="index-parallel-execution_002c-output-during"></span>
|
|
|
|
<p>When running several recipes in parallel the output from each
|
|
recipe appears as soon as it is generated, with the result that
|
|
messages from different recipes may be interspersed, sometimes even
|
|
appearing on the same line. This can make reading the output very
|
|
difficult.
|
|
</p>
|
|
<span id="index-_002d_002doutput_002dsync"></span>
|
|
<span id="index-_002dO"></span>
|
|
<p>To avoid this you can use the ‘<samp>--output-sync</samp>’ (‘<samp>-O</samp>’) option.
|
|
This option instructs <code>make</code> to save the output from the commands
|
|
it invokes and print it all once the commands are completed.
|
|
Additionally, if there are multiple recursive <code>make</code> invocations
|
|
running in parallel, they will communicate so that only one of them is
|
|
generating output at a time.
|
|
</p>
|
|
<p>If working directory printing is enabled (see <a href="#g_t_002dw-Option">The
|
|
‘<samp>--print-directory</samp>’ Option</a>), the enter/leave messages are
|
|
printed around each output grouping. If you prefer not to see these
|
|
messages add the ‘<samp>--no-print-directory</samp>’ option to <code>MAKEFLAGS</code>.
|
|
</p>
|
|
<p>There are four levels of granularity when synchronizing output,
|
|
specified by giving an argument to the option (e.g., ‘<samp>-Oline</samp>’ or
|
|
‘<samp>--output-sync=recurse</samp>’).
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>none</code></dt>
|
|
<dd><p>This is the default: all output is sent directly as it is generated and
|
|
no synchronization is performed.
|
|
</p>
|
|
</dd>
|
|
<dt><code>line</code></dt>
|
|
<dd><p>Output from each individual line of the recipe is grouped and printed
|
|
as soon as that line is complete. If a recipe consists of multiple
|
|
lines, they may be interspersed with lines from other recipes.
|
|
</p>
|
|
</dd>
|
|
<dt><code>target</code></dt>
|
|
<dd><p>Output from the entire recipe for each target is grouped and printed
|
|
once the target is complete. This is the default if the
|
|
<code>--output-sync</code> or <code>-O</code> option is given with no argument.
|
|
</p>
|
|
</dd>
|
|
<dt><code>recurse</code></dt>
|
|
<dd><p>Output from each recursive invocation of <code>make</code> is grouped and
|
|
printed once the recursive invocation is complete.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Regardless of the mode chosen, the total build time will be the same.
|
|
The only difference is in how the output appears.
|
|
</p>
|
|
<p>The ‘<samp>target</samp>’ and ‘<samp>recurse</samp>’ modes both collect the output of
|
|
the entire recipe of a target and display it uninterrupted when the
|
|
recipe completes. The difference between them is in how recipes that
|
|
contain recursive invocations of <code>make</code> are treated
|
|
(see <a href="#Recursion">Recursive Use of <code>make</code></a>). For all recipes
|
|
which have no recursive lines, the ‘<samp>target</samp>’ and ‘<samp>recurse</samp>’
|
|
modes behave identically.
|
|
</p>
|
|
<p>If the ‘<samp>recurse</samp>’ mode is chosen, recipes that contain recursive
|
|
<code>make</code> invocations are treated the same as other targets: the
|
|
output from the recipe, including the output from the recursive
|
|
<code>make</code>, is saved and printed after the entire recipe is complete.
|
|
This ensures output from all the targets built by a given recursive
|
|
<code>make</code> instance are grouped together, which may make the output
|
|
easier to understand. However it also leads to long periods of time
|
|
during the build where no output is seen, followed by large bursts of
|
|
output. If you are not watching the build as it proceeds, but instead
|
|
viewing a log of the build after the fact, this may be the best option
|
|
for you.
|
|
</p>
|
|
<p>If you are watching the output, the long gaps of quiet during the
|
|
build can be frustrating. The ‘<samp>target</samp>’ output synchronization
|
|
mode detects when <code>make</code> is going to be invoked recursively,
|
|
using the standard methods, and it will not synchronize the output of
|
|
those lines. The recursive <code>make</code> will perform the
|
|
synchronization for its targets and the output from each will be
|
|
displayed immediately when it completes. Be aware that output from
|
|
recursive lines of the recipe are not synchronized (for example if
|
|
the recursive line prints a message before running <code>make</code>, that
|
|
message will not be synchronized).
|
|
</p>
|
|
<p>The ‘<samp>line</samp>’ mode can be useful for front-ends that are watching
|
|
the output of <code>make</code> to track when recipes are started and
|
|
completed.
|
|
</p>
|
|
<p>Some programs invoked by <code>make</code> may behave differently if they
|
|
determine they’re writing output to a terminal versus a file (often
|
|
described as “interactive” vs. “non-interactive” modes). For
|
|
example, many programs that can display colorized output will not do
|
|
so if they determine they are not writing to a terminal. If your
|
|
makefile invokes a program like this then using the output
|
|
synchronization options will cause the program to believe it’s running
|
|
in “non-interactive” mode even though the output will ultimately go
|
|
to the terminal.
|
|
</p>
|
|
<hr>
|
|
<span id="Parallel-Input"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Parallel-Output" accesskey="p" rel="prev">Parallel Output</a>, Up: <a href="#Parallel" accesskey="u" rel="up">Parallel</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Input-During-Parallel-Execution"></span><h4 class="subsection">5.4.3 Input During Parallel Execution</h4>
|
|
<span id="index-input-during-parallel-execution"></span>
|
|
<span id="index-parallel-execution_002c-input-during"></span>
|
|
<span id="index-standard-input"></span>
|
|
|
|
<p>Two processes cannot both take input from the same device at the same
|
|
time. To make sure that only one recipe tries to take input from the
|
|
terminal at once, <code>make</code> will invalidate the standard input
|
|
streams of all but one running recipe. If another recipe attempts to
|
|
read from standard input it will usually incur a fatal error (a
|
|
‘<samp>Broken pipe</samp>’ signal).
|
|
<span id="index-broken-pipe"></span>
|
|
</p>
|
|
<p>It is unpredictable which recipe will have a valid standard input stream
|
|
(which will come from the terminal, or wherever you redirect the standard
|
|
input of <code>make</code>). The first recipe run will always get it first, and
|
|
the first recipe started after that one finishes will get it next, and so
|
|
on.
|
|
</p>
|
|
<p>We will change how this aspect of <code>make</code> works if we find a better
|
|
alternative. In the mean time, you should not rely on any recipe using
|
|
standard input at all if you are using the parallel execution feature; but
|
|
if you are not using this feature, then standard input works normally in
|
|
all recipes.
|
|
</p>
|
|
<hr>
|
|
<span id="Errors"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Interrupts" accesskey="n" rel="next">Interrupts</a>, Previous: <a href="#Parallel" accesskey="p" rel="prev">Parallel</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Errors-in-Recipes"></span><h3 class="section">5.5 Errors in Recipes</h3>
|
|
<span id="index-errors-_0028in-recipes_0029"></span>
|
|
<span id="index-recipes_002c-errors-in"></span>
|
|
<span id="index-exit-status-_0028errors_0029"></span>
|
|
|
|
<p>After each shell invocation returns, <code>make</code> looks at its exit
|
|
status. If the shell completed successfully (the exit status is
|
|
zero), the next line in the recipe is executed in a new shell; after
|
|
the last line is finished, the rule is finished.
|
|
</p>
|
|
<p>If there is an error (the exit status is nonzero), <code>make</code> gives up on
|
|
the current rule, and perhaps on all rules.
|
|
</p>
|
|
<p>Sometimes the failure of a certain recipe line does not indicate a problem.
|
|
For example, you may use the <code>mkdir</code> command to ensure that a
|
|
directory exists. If the directory already exists, <code>mkdir</code> will
|
|
report an error, but you probably want <code>make</code> to continue regardless.
|
|
</p>
|
|
<span id="index-_002d-_0028in-recipes_0029"></span>
|
|
<p>To ignore errors in a recipe line, write a ‘<samp>-</samp>’ at the beginning
|
|
of the line’s text (after the initial tab). The ‘<samp>-</samp>’ is discarded
|
|
before the line is passed to the shell for execution.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">clean:
|
|
-rm -f *.o
|
|
</pre></div>
|
|
<span id="index-rm-_0028shell-command_0029-3"></span>
|
|
|
|
<p>This causes <code>make</code> to continue even if <code>rm</code> is unable to
|
|
remove a file.
|
|
</p>
|
|
<span id="index-_002di"></span>
|
|
<span id="index-_002d_002dignore_002derrors"></span>
|
|
<span id="index-_002eIGNORE-1"></span>
|
|
<p>When you run <code>make</code> with the ‘<samp>-i</samp>’ or ‘<samp>--ignore-errors</samp>’
|
|
flag, errors are ignored in all recipes of all rules. A rule in the
|
|
makefile for the special target <code>.IGNORE</code> has the same effect, if
|
|
there are no prerequisites. This is less flexible but sometimes useful.
|
|
</p>
|
|
<p>When errors are to be ignored, because of either a ‘<samp>-</samp>’ or the
|
|
‘<samp>-i</samp>’ flag, <code>make</code> treats an error return just like success,
|
|
except that it prints out a message that tells you the status code
|
|
the shell exited with, and says that the error has been ignored.
|
|
</p>
|
|
<p>When an error happens that <code>make</code> has not been told to ignore,
|
|
it implies that the current target cannot be correctly remade, and neither
|
|
can any other that depends on it either directly or indirectly. No further
|
|
recipes will be executed for these targets, since their preconditions
|
|
have not been achieved.
|
|
</p>
|
|
|
|
<span id="index-_002dk"></span>
|
|
<span id="index-_002d_002dkeep_002dgoing"></span>
|
|
<p>Normally <code>make</code> gives up immediately in this circumstance, returning a
|
|
nonzero status. However, if the ‘<samp>-k</samp>’ or ‘<samp>--keep-going</samp>’
|
|
flag is specified, <code>make</code>
|
|
continues to consider the other prerequisites of the pending targets,
|
|
remaking them if necessary, before it gives up and returns nonzero status.
|
|
For example, after an error in compiling one object file, ‘<samp>make -k</samp>’
|
|
will continue compiling other object files even though it already knows
|
|
that linking them will be impossible. See <a href="#Options-Summary">Summary of Options</a>.
|
|
</p>
|
|
<p>The usual behavior assumes that your purpose is to get the specified
|
|
targets up to date; once <code>make</code> learns that this is impossible, it
|
|
might as well report the failure immediately. The ‘<samp>-k</samp>’ option says
|
|
that the real purpose is to test as many of the changes made in the
|
|
program as possible, perhaps to find several independent problems so
|
|
that you can correct them all before the next attempt to compile. This
|
|
is why Emacs’ <code>compile</code> command passes the ‘<samp>-k</samp>’ flag by
|
|
default.
|
|
<span id="index-Emacs-_0028M_002dx-compile_0029"></span>
|
|
</p>
|
|
<span id="index-_002eDELETE_005fON_005fERROR-1"></span>
|
|
<span id="index-deletion-of-target-files"></span>
|
|
<span id="index-removal-of-target-files"></span>
|
|
<span id="index-target_002c-deleting-on-error"></span>
|
|
<p>Usually when a recipe line fails, if it has changed the target file at all,
|
|
the file is corrupted and cannot be used—or at least it is not
|
|
completely updated. Yet the file’s time stamp says that it is now up to
|
|
date, so the next time <code>make</code> runs, it will not try to update that
|
|
file. The situation is just the same as when the shell is killed by a
|
|
signal; see <a href="#Interrupts">Interrupts</a>. So generally the right thing to do is to
|
|
delete the target file if the recipe fails after beginning to change
|
|
the file. <code>make</code> will do this if <code>.DELETE_ON_ERROR</code> appears
|
|
as a target. This is almost always what you want <code>make</code> to do, but
|
|
it is not historical practice; so for compatibility, you must explicitly
|
|
request it.
|
|
</p>
|
|
<hr>
|
|
<span id="Interrupts"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Recursion" accesskey="n" rel="next">Recursion</a>, Previous: <a href="#Errors" accesskey="p" rel="prev">Errors</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Interrupting-or-Killing-make"></span><h3 class="section">5.6 Interrupting or Killing <code>make</code></h3>
|
|
<span id="index-interrupt"></span>
|
|
<span id="index-signal"></span>
|
|
<span id="index-deletion-of-target-files-1"></span>
|
|
<span id="index-removal-of-target-files-1"></span>
|
|
<span id="index-target_002c-deleting-on-interrupt"></span>
|
|
<span id="index-killing-_0028interruption_0029"></span>
|
|
|
|
<p>If <code>make</code> gets a fatal signal while a shell is executing, it may
|
|
delete the target file that the recipe was supposed to update. This is
|
|
done if the target file’s last-modification time has changed since
|
|
<code>make</code> first checked it.
|
|
</p>
|
|
<p>The purpose of deleting the target is to make sure that it is remade from
|
|
scratch when <code>make</code> is next run. Why is this? Suppose you type
|
|
<kbd>Ctrl-c</kbd> while a compiler is running, and it has begun to write an
|
|
object file <samp>foo.o</samp>. The <kbd>Ctrl-c</kbd> kills the compiler, resulting
|
|
in an incomplete file whose last-modification time is newer than the source
|
|
file <samp>foo.c</samp>. But <code>make</code> also receives the <kbd>Ctrl-c</kbd> signal
|
|
and deletes this incomplete file. If <code>make</code> did not do this, the next
|
|
invocation of <code>make</code> would think that <samp>foo.o</samp> did not require
|
|
updating—resulting in a strange error message from the linker when it
|
|
tries to link an object file half of which is missing.
|
|
</p>
|
|
<span id="index-_002ePRECIOUS-1"></span>
|
|
<p>You can prevent the deletion of a target file in this way by making the
|
|
special target <code>.PRECIOUS</code> depend on it. Before remaking a target,
|
|
<code>make</code> checks to see whether it appears on the prerequisites of
|
|
<code>.PRECIOUS</code>, and thereby decides whether the target should be deleted
|
|
if a signal happens. Some reasons why you might do this are that the
|
|
target is updated in some atomic fashion, or exists only to record a
|
|
modification-time (its contents do not matter), or must exist at all
|
|
times to prevent other sorts of trouble.
|
|
</p>
|
|
<p>Although <code>make</code> does its best to clean up there are certain situations
|
|
in which cleanup is impossible. For example, <code>make</code> may be killed by
|
|
an uncatchable signal. Or, one of the programs make invokes may be killed
|
|
or crash, leaving behind an up-to-date but corrupt target file: <code>make</code>
|
|
will not realize that this failure requires the target to be cleaned. Or
|
|
<code>make</code> itself may encounter a bug and crash.
|
|
</p>
|
|
<p>For these reasons it’s best to write <em>defensive recipes</em>, which won’t
|
|
leave behind corrupted targets even if they fail. Most commonly these
|
|
recipes create temporary files rather than updating the target directly,
|
|
then rename the temporary file to the final target name. Some compilers
|
|
already behave this way, so that you don’t need to write a defensive recipe.
|
|
</p>
|
|
<hr>
|
|
<span id="Recursion"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Canned-Recipes" accesskey="n" rel="next">Canned Recipes</a>, Previous: <a href="#Interrupts" accesskey="p" rel="prev">Interrupts</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Recursive-Use-of-make"></span><h3 class="section">5.7 Recursive Use of <code>make</code></h3>
|
|
<span id="index-recursion"></span>
|
|
<span id="index-subdirectories_002c-recursion-for"></span>
|
|
|
|
<p>Recursive use of <code>make</code> means using <code>make</code> as a command in a
|
|
makefile. This technique is useful when you want separate makefiles for
|
|
various subsystems that compose a larger system. For example, suppose you
|
|
have a sub-directory <samp>subdir</samp> which has its own makefile, and you would
|
|
like the containing directory’s makefile to run <code>make</code> on the
|
|
sub-directory. You can do it by writing this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">subsystem:
|
|
cd subdir && $(MAKE)
|
|
</pre></div>
|
|
|
|
<p>or, equivalently, this (see <a href="#Options-Summary">Summary of Options</a>):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">subsystem:
|
|
$(MAKE) -C subdir
|
|
</pre></div>
|
|
<span id="index-_002dC"></span>
|
|
<span id="index-_002d_002ddirectory"></span>
|
|
|
|
<p>You can write recursive <code>make</code> commands just by copying this example,
|
|
but there are many things to know about how they work and why, and about
|
|
how the sub-<code>make</code> relates to the top-level <code>make</code>. You may
|
|
also find it useful to declare targets that invoke recursive
|
|
<code>make</code> commands as ‘<samp>.PHONY</samp>’ (for more discussion on when
|
|
this is useful, see <a href="#Phony-Targets">Phony Targets</a>).
|
|
</p>
|
|
<span id="index-CURDIR"></span>
|
|
<p>For your convenience, when GNU <code>make</code> starts (after it has
|
|
processed any <code>-C</code> options) it sets the variable <code>CURDIR</code> to
|
|
the pathname of the current working directory. This value is never
|
|
touched by <code>make</code> again: in particular note that if you include
|
|
files from other directories the value of <code>CURDIR</code> does not
|
|
change. The value has the same precedence it would have if it were
|
|
set in the makefile (by default, an environment variable <code>CURDIR</code>
|
|
will not override this value). Note that setting this variable has no
|
|
impact on the operation of <code>make</code> (it does not cause <code>make</code>
|
|
to change its working directory, for example).
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#MAKE-Variable" accesskey="1">MAKE Variable</a></td><td> </td><td align="left" valign="top">The special effects of using ‘<samp>$(MAKE)</samp>’.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Variables_002fRecursion" accesskey="2">Variables/Recursion</a></td><td> </td><td align="left" valign="top">How to communicate variables to a sub-<code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Options_002fRecursion" accesskey="3">Options/Recursion</a></td><td> </td><td align="left" valign="top">How to communicate options to a sub-<code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#g_t_002dw-Option" accesskey="4">-w Option</a></td><td> </td><td align="left" valign="top">How the ‘<samp>-w</samp>’ or ‘<samp>--print-directory</samp>’ option
|
|
helps debug use of recursive <code>make</code> commands.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="MAKE-Variable"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Variables_002fRecursion" accesskey="n" rel="next">Variables/Recursion</a>, Previous: <a href="#Recursion" accesskey="p" rel="prev">Recursion</a>, Up: <a href="#Recursion" accesskey="u" rel="up">Recursion</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-the-MAKE-Variable-Works"></span><h4 class="subsection">5.7.1 How the <code>MAKE</code> Variable Works</h4>
|
|
<span id="index-MAKE"></span>
|
|
<span id="index-recursion_002c-and-MAKE-variable"></span>
|
|
|
|
<p>Recursive <code>make</code> commands should always use the variable <code>MAKE</code>,
|
|
not the explicit command name ‘<samp>make</samp>’, as shown here:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">subsystem:
|
|
cd subdir && $(MAKE)
|
|
</pre></div>
|
|
|
|
<p>The value of this variable is the file name with which <code>make</code> was
|
|
invoked. If this file name was <samp>/bin/make</samp>, then the recipe executed
|
|
is ‘<samp>cd subdir && /bin/make</samp>’. If you use a special version of
|
|
<code>make</code> to run the top-level makefile, the same special version will be
|
|
executed for recursive invocations.
|
|
<span id="index-cd-_0028shell-command_0029-1"></span>
|
|
</p>
|
|
<span id="index-_002b_002c-and-recipes"></span>
|
|
<p>As a special feature, using the variable <code>MAKE</code> in the recipe of
|
|
a rule alters the effects of the ‘<samp>-t</samp>’ (‘<samp>--touch</samp>’), ‘<samp>-n</samp>’
|
|
(‘<samp>--just-print</samp>’), or ‘<samp>-q</samp>’ (‘<samp><span class="nolinebreak">--question</span></samp>’<!-- /@w -->) option.
|
|
Using the <code>MAKE</code> variable has the same effect as using a ‘<samp>+</samp>’
|
|
character at the beginning of the recipe line. See <a href="#Instead-of-Execution">Instead of Executing the Recipes</a>. This special feature
|
|
is only enabled if the <code>MAKE</code> variable appears directly in the
|
|
recipe: it does not apply if the <code>MAKE</code> variable is referenced
|
|
through expansion of another variable. In the latter case you must
|
|
use the ‘<samp>+</samp>’ token to get these special effects.
|
|
</p>
|
|
<p>Consider the command ‘<samp>make -t</samp>’ in the above example. (The
|
|
‘<samp>-t</samp>’ option marks targets as up to date without actually running
|
|
any recipes; see <a href="#Instead-of-Execution">Instead of Execution</a>.) Following the usual
|
|
definition of ‘<samp>-t</samp>’, a ‘<samp>make -t</samp>’ command in the example would
|
|
create a file named <samp>subsystem</samp> and do nothing else. What you
|
|
really want it to do is run ‘<samp>cd subdir &&<!-- /@w --> make <span class="nolinebreak">-t</span><!-- /@w --></samp>’; but
|
|
that would require executing the recipe, and ‘<samp>-t</samp>’ says not to
|
|
execute recipes.
|
|
<span id="index-_002dt_002c-and-recursion"></span>
|
|
<span id="index-recursion_002c-and-_002dt"></span>
|
|
<span id="index-_002d_002dtouch_002c-and-recursion"></span>
|
|
</p>
|
|
<p>The special feature makes this do what you want: whenever a recipe
|
|
line of a rule contains the variable <code>MAKE</code>, the flags ‘<samp>-t</samp>’,
|
|
‘<samp>-n</samp>’ and ‘<samp>-q</samp>’ do not apply to that line. Recipe lines
|
|
containing <code>MAKE</code> are executed normally despite the presence of a
|
|
flag that causes most recipes not to be run. The usual
|
|
<code>MAKEFLAGS</code> mechanism passes the flags to the sub-<code>make</code>
|
|
(see <a href="#Options_002fRecursion">Communicating Options to a
|
|
Sub-<code>make</code></a>), so your request to touch the files, or print the
|
|
recipes, is propagated to the subsystem.
|
|
</p>
|
|
<hr>
|
|
<span id="Variables_002fRecursion"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Options_002fRecursion" accesskey="n" rel="next">Options/Recursion</a>, Previous: <a href="#MAKE-Variable" accesskey="p" rel="prev">MAKE Variable</a>, Up: <a href="#Recursion" accesskey="u" rel="up">Recursion</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Communicating-Variables-to-a-Sub_002dmake"></span><h4 class="subsection">5.7.2 Communicating Variables to a Sub-<code>make</code></h4>
|
|
<span id="index-sub_002dmake"></span>
|
|
<span id="index-environment_002c-and-recursion"></span>
|
|
<span id="index-exporting-variables"></span>
|
|
<span id="index-variables_002c-environment"></span>
|
|
<span id="index-variables_002c-exporting"></span>
|
|
<span id="index-recursion_002c-and-environment"></span>
|
|
<span id="index-recursion_002c-and-variables"></span>
|
|
|
|
<p>Variable values of the top-level <code>make</code> can be passed to the
|
|
sub-<code>make</code> through the environment by explicit request. These
|
|
variables are defined in the sub-<code>make</code> as defaults, but they do
|
|
not override variables defined in the makefile used by
|
|
the sub-<code>make</code> unless you use the ‘<samp>-e</samp>’ switch (see <a href="#Options-Summary">Summary of Options</a>).
|
|
</p>
|
|
<p>To pass down, or <em>export</em>, a variable, <code>make</code> adds the
|
|
variable and its value to the environment for running each line of the
|
|
recipe. The sub-<code>make</code>, in turn, uses the environment to
|
|
initialize its table of variable values. See <a href="#Environment">Variables from the Environment</a>.
|
|
</p>
|
|
<p>Except by explicit request, <code>make</code> exports a variable only if it
|
|
is either defined in the environment initially, or if set on the command
|
|
line and its name consists only of letters, numbers, and underscores.
|
|
</p>
|
|
<span id="index-SHELL_002c-exported-value"></span>
|
|
<p>The value of the <code>make</code> variable <code>SHELL</code> is not exported.
|
|
Instead, the value of the <code>SHELL</code> variable from the invoking
|
|
environment is passed to the sub-<code>make</code>. You can force
|
|
<code>make</code> to export its value for <code>SHELL</code> by using the
|
|
<code>export</code> directive, described below. See <a href="#Choosing-the-Shell">Choosing the Shell</a>.
|
|
</p>
|
|
<p>The special variable <code>MAKEFLAGS</code> is always exported (unless you
|
|
unexport it). <code>MAKEFILES</code> is exported if you set it to anything.
|
|
</p>
|
|
<p><code>make</code> automatically passes down variable values that were defined
|
|
on the command line, by putting them in the <code>MAKEFLAGS</code> variable.
|
|
See <a href="#Options_002fRecursion">Options/Recursion</a>.
|
|
</p>
|
|
<p>Variables are <em>not</em> normally passed down if they were created by
|
|
default by <code>make</code> (see <a href="#Implicit-Variables">Variables Used by
|
|
Implicit Rules</a>). The sub-<code>make</code> will define these for
|
|
itself.
|
|
</p>
|
|
<span id="index-export"></span>
|
|
<p>If you want to export specific variables to a sub-<code>make</code>, use the
|
|
<code>export</code> directive, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">export <var>variable</var> …
|
|
</pre></div>
|
|
|
|
<p><span id="index-unexport"></span>
|
|
If you want to <em>prevent</em> a variable from being exported, use the
|
|
<code>unexport</code> directive, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">unexport <var>variable</var> …
|
|
</pre></div>
|
|
|
|
<p>In both of these forms, the arguments to <code>export</code> and
|
|
<code>unexport</code> are expanded, and so could be variables or functions
|
|
which expand to a (list of) variable names to be (un)exported.
|
|
</p>
|
|
<p>As a convenience, you can define a variable and export it at the same
|
|
time by doing:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">export <var>variable</var> = value
|
|
</pre></div>
|
|
|
|
<p>has the same result as:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>variable</var> = value
|
|
export <var>variable</var>
|
|
</pre></div>
|
|
|
|
<p>and
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">export <var>variable</var> := value
|
|
</pre></div>
|
|
|
|
<p>has the same result as:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>variable</var> := value
|
|
export <var>variable</var>
|
|
</pre></div>
|
|
|
|
<p>Likewise,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">export <var>variable</var> += value
|
|
</pre></div>
|
|
|
|
<p>is just like:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>variable</var> += value
|
|
export <var>variable</var>
|
|
</pre></div>
|
|
|
|
<p>See <a href="#Appending">Appending More Text to Variables</a>.
|
|
</p>
|
|
<p>You may notice that the <code>export</code> and <code>unexport</code> directives
|
|
work in <code>make</code> in the same way they work in the shell, <code>sh</code>.
|
|
</p>
|
|
<p>If you want all variables to be exported by default, you can use
|
|
<code>export</code> by itself:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">export
|
|
</pre></div>
|
|
|
|
<p>This tells <code>make</code> that variables which are not explicitly mentioned in an
|
|
<code>export</code> or <code>unexport</code> directive should be exported. Any variable
|
|
given in an <code>unexport</code> directive will still <em>not</em> be exported.
|
|
</p>
|
|
<span id="index-_002eEXPORT_005fALL_005fVARIABLES-1"></span>
|
|
<span id="index-compatibility-in-exporting"></span>
|
|
<p>The behavior elicited by an <code>export</code> directive by itself was the default
|
|
in older versions of GNU <code>make</code>. If your makefiles depend on this
|
|
behavior and you want to be compatible with old versions of <code>make</code>, you
|
|
can add the special target <code>.EXPORT_ALL_VARIABLES</code> to your makefile
|
|
instead of using the <code>export</code> directive. This will be ignored by old
|
|
<code>make</code>s, while the <code>export</code> directive will cause a syntax
|
|
error.
|
|
</p>
|
|
<p>When using <code>export</code> by itself or <code>.EXPORT_ALL_VARIABLES</code> to export
|
|
variables by default, only variables whose names consist solely of
|
|
alphanumerics and underscores will be exported. To export other variables you
|
|
must specifically mention them in an <code>export</code> directive.
|
|
</p>
|
|
<p>Adding a variable’s value to the environment requires it to be expanded. If
|
|
expanding a variable has side-effects (such as the <code>info</code> or <code>eval</code>
|
|
or similar functions) then these side-effects will be seen every time a
|
|
command is invoked. You can avoid this by ensuring that such variables have
|
|
names which are not exportable by default. However, a better solution is to
|
|
<em>not</em> use this “export by default” facility at all, and instead
|
|
explicitly <code>export</code> the relevant variables by name.
|
|
</p>
|
|
<p>You can use <code>unexport</code> by itself to tell <code>make</code> <em>not</em> to export
|
|
variables by default. Since this is the default behavior, you would only need
|
|
to do this if <code>export</code> had been used by itself earlier (in an included
|
|
makefile, perhaps). You <strong>cannot</strong> use <code>export</code> and <code>unexport</code>
|
|
by themselves to have variables exported for some recipes and not for others.
|
|
The last <code>export</code> or <code>unexport</code> directive that appears by itself
|
|
determines the behavior for the entire run of <code>make</code>.
|
|
</p>
|
|
<span id="index-MAKELEVEL"></span>
|
|
<span id="index-recursion_002c-level-of"></span>
|
|
<p>As a special feature, the variable <code>MAKELEVEL</code> is changed when it
|
|
is passed down from level to level. This variable’s value is a string
|
|
which is the depth of the level as a decimal number. The value is
|
|
‘<samp>0</samp>’ for the top-level <code>make</code>; ‘<samp>1</samp>’ for a sub-<code>make</code>,
|
|
‘<samp>2</samp>’ for a sub-sub-<code>make</code>, and so on. The incrementation
|
|
happens when <code>make</code> sets up the environment for a recipe.
|
|
</p>
|
|
<p>The main use of <code>MAKELEVEL</code> is to test it in a conditional
|
|
directive (see <a href="#Conditionals">Conditional Parts of Makefiles</a>); this
|
|
way you can write a makefile that behaves one way if run recursively and
|
|
another way if run directly by you.
|
|
</p>
|
|
<span id="index-MAKEFILES-1"></span>
|
|
<p>You can use the variable <code>MAKEFILES</code> to cause all sub-<code>make</code>
|
|
commands to use additional makefiles. The value of <code>MAKEFILES</code> is
|
|
a whitespace-separated list of file names. This variable, if defined in
|
|
the outer-level makefile, is passed down through the environment; then
|
|
it serves as a list of extra makefiles for the sub-<code>make</code> to read
|
|
before the usual or specified ones. See <a href="#MAKEFILES-Variable">The
|
|
Variable <code>MAKEFILES</code></a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Options_002fRecursion"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#g_t_002dw-Option" accesskey="n" rel="next">-w Option</a>, Previous: <a href="#Variables_002fRecursion" accesskey="p" rel="prev">Variables/Recursion</a>, Up: <a href="#Recursion" accesskey="u" rel="up">Recursion</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Communicating-Options-to-a-Sub_002dmake"></span><h4 class="subsection">5.7.3 Communicating Options to a Sub-<code>make</code></h4>
|
|
<span id="index-options_002c-and-recursion"></span>
|
|
<span id="index-recursion_002c-and-options"></span>
|
|
|
|
<span id="index-MAKEFLAGS"></span>
|
|
<p>Flags such as ‘<samp>-s</samp>’ and ‘<samp>-k</samp>’ are passed automatically to the
|
|
sub-<code>make</code> through the variable <code>MAKEFLAGS</code>. This variable is
|
|
set up automatically by <code>make</code> to contain the flag letters that
|
|
<code>make</code> received. Thus, if you do ‘<samp>make <span class="nolinebreak">-ks</span></samp>’<!-- /@w --> then
|
|
<code>MAKEFLAGS</code> gets the value ‘<samp>ks</samp>’.
|
|
</p>
|
|
<p>As a consequence, every sub-<code>make</code> gets a value for <code>MAKEFLAGS</code>
|
|
in its environment. In response, it takes the flags from that value and
|
|
processes them as if they had been given as arguments.
|
|
See <a href="#Options-Summary">Summary of Options</a>.
|
|
</p>
|
|
<p>The value of <code>MAKEFLAGS</code> is a possibly empty group of characters
|
|
representing single-letter options that take no argument, followed by a space
|
|
and any options that take arguments or which have long option names. If an
|
|
option has both single-letter and long options, the single-letter option is
|
|
always preferred. If there are no single-letter options on the command line,
|
|
then the value of <code>MAKEFLAGS</code> starts with a space.
|
|
</p>
|
|
<span id="index-command-line-variable-definitions_002c-and-recursion"></span>
|
|
<span id="index-variables_002c-command-line_002c-and-recursion"></span>
|
|
<span id="index-recursion_002c-and-command-line-variable-definitions"></span>
|
|
<p>Likewise variables defined on the command line are passed to the
|
|
sub-<code>make</code> through <code>MAKEFLAGS</code>. Words in the value of
|
|
<code>MAKEFLAGS</code> that contain ‘<samp>=</samp>’, <code>make</code> treats as variable
|
|
definitions just as if they appeared on the command line.
|
|
See <a href="#Overriding">Overriding Variables</a>.
|
|
</p>
|
|
<span id="index-_002dC_002c-and-recursion"></span>
|
|
<span id="index-_002df_002c-and-recursion"></span>
|
|
<span id="index-_002do_002c-and-recursion"></span>
|
|
<span id="index-_002dW_002c-and-recursion"></span>
|
|
<span id="index-_002d_002ddirectory_002c-and-recursion"></span>
|
|
<span id="index-_002d_002dfile_002c-and-recursion"></span>
|
|
<span id="index-_002d_002dold_002dfile_002c-and-recursion"></span>
|
|
<span id="index-_002d_002dassume_002dold_002c-and-recursion"></span>
|
|
<span id="index-_002d_002dassume_002dnew_002c-and-recursion"></span>
|
|
<span id="index-_002d_002dnew_002dfile_002c-and-recursion"></span>
|
|
<span id="index-recursion_002c-and-_002dC"></span>
|
|
<span id="index-recursion_002c-and-_002df"></span>
|
|
<span id="index-recursion_002c-and-_002do"></span>
|
|
<span id="index-recursion_002c-and-_002dW"></span>
|
|
<p>The options ‘<samp>-C</samp>’, ‘<samp>-f</samp>’, ‘<samp>-o</samp>’, and ‘<samp>-W</samp>’ are not put
|
|
into <code>MAKEFLAGS</code>; these options are not passed down.
|
|
</p>
|
|
<span id="index-_002dj_002c-and-recursion"></span>
|
|
<span id="index-_002d_002djobs_002c-and-recursion"></span>
|
|
<span id="index-recursion_002c-and-_002dj"></span>
|
|
<span id="index-job-slots_002c-and-recursion"></span>
|
|
<p>The ‘<samp>-j</samp>’ option is a special case (see <a href="#Parallel">Parallel Execution</a>).
|
|
If you set it to some numeric value ‘<samp>N</samp>’ and your operating system
|
|
supports it (most any UNIX system will; others typically won’t), the
|
|
parent <code>make</code> and all the sub-<code>make</code>s will communicate to
|
|
ensure that there are only ‘<samp>N</samp>’ jobs running at the same time
|
|
between them all. Note that any job that is marked recursive
|
|
(see <a href="#Instead-of-Execution">Instead of Executing Recipes</a>)
|
|
doesn’t count against the total jobs (otherwise we could get ‘<samp>N</samp>’
|
|
sub-<code>make</code>s running and have no slots left over for any real work!)
|
|
</p>
|
|
<p>If your operating system doesn’t support the above communication, then
|
|
no ‘<samp>-j</samp>’ is added to <code>MAKEFLAGS</code>, so that sub-<code>make</code>s
|
|
run in non-parallel mode. If the ‘<samp><span class="nolinebreak">-j</span></samp>’<!-- /@w --> option were passed down
|
|
to sub-<code>make</code>s you would get many more jobs running in parallel
|
|
than you asked for. If you give ‘<samp>-j</samp>’ with no numeric argument,
|
|
meaning to run as many jobs as possible in parallel, this is passed
|
|
down, since multiple infinities are no more than one.
|
|
</p>
|
|
<p>If you do not want to pass the other flags down, you must change the
|
|
value of <code>MAKEFLAGS</code>, for example like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">subsystem:
|
|
cd subdir && $(MAKE) MAKEFLAGS=
|
|
</pre></div>
|
|
|
|
<span id="index-MAKEOVERRIDES"></span>
|
|
<p>The command line variable definitions really appear in the variable
|
|
<code>MAKEOVERRIDES</code>, and <code>MAKEFLAGS</code> contains a reference to this
|
|
variable. If you do want to pass flags down normally, but don’t want to
|
|
pass down the command line variable definitions, you can reset
|
|
<code>MAKEOVERRIDES</code> to empty, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">MAKEOVERRIDES =
|
|
</pre></div>
|
|
|
|
<p><span id="index-Arg-list-too-long"></span>
|
|
<span id="index-E2BIG"></span>
|
|
This is not usually useful to do. However, some systems have a small
|
|
fixed limit on the size of the environment, and putting so much
|
|
information into the value of <code>MAKEFLAGS</code> can exceed it. If you
|
|
see the error message ‘<samp>Arg list too long</samp>’, this may be the problem.
|
|
<span id="index-_002ePOSIX-1"></span>
|
|
<span id="index-POSIX-1"></span>
|
|
(For strict compliance with POSIX.2, changing <code>MAKEOVERRIDES</code> does
|
|
not affect <code>MAKEFLAGS</code> if the special target ‘<samp>.POSIX</samp>’ appears
|
|
in the makefile. You probably do not care about this.)
|
|
</p>
|
|
<span id="index-MFLAGS"></span>
|
|
<p>A similar variable <code>MFLAGS</code> exists also, for historical
|
|
compatibility. It has the same value as <code>MAKEFLAGS</code> except that it
|
|
does not contain the command line variable definitions, and it always
|
|
begins with a hyphen unless it is empty (<code>MAKEFLAGS</code> begins with a
|
|
hyphen only when it begins with an option that has no single-letter
|
|
version, such as ‘<samp>--warn-undefined-variables</samp>’). <code>MFLAGS</code> was
|
|
traditionally used explicitly in the recursive <code>make</code> command, like
|
|
this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">subsystem:
|
|
cd subdir && $(MAKE) $(MFLAGS)
|
|
</pre></div>
|
|
|
|
<p>but now <code>MAKEFLAGS</code> makes this usage redundant. If you want your
|
|
makefiles to be compatible with old <code>make</code> programs, use this
|
|
technique; it will work fine with more modern <code>make</code> versions too.
|
|
</p>
|
|
<span id="index-setting-options-from-environment"></span>
|
|
<span id="index-options_002c-setting-from-environment"></span>
|
|
<span id="index-setting-options-in-makefiles"></span>
|
|
<span id="index-options_002c-setting-in-makefiles"></span>
|
|
<p>The <code>MAKEFLAGS</code> variable can also be useful if you want to have
|
|
certain options, such as ‘<samp>-k</samp>’ (see <a href="#Options-Summary">Summary of
|
|
Options</a>), set each time you run <code>make</code>. You simply put a value for
|
|
<code>MAKEFLAGS</code> in your environment. You can also set <code>MAKEFLAGS</code> in
|
|
a makefile, to specify additional flags that should also be in effect for
|
|
that makefile. (Note that you cannot use <code>MFLAGS</code> this way. That
|
|
variable is set only for compatibility; <code>make</code> does not interpret a
|
|
value you set for it in any way.)
|
|
</p>
|
|
<p>When <code>make</code> interprets the value of <code>MAKEFLAGS</code> (either from the
|
|
environment or from a makefile), it first prepends a hyphen if the value
|
|
does not already begin with one. Then it chops the value into words
|
|
separated by blanks, and parses these words as if they were options given
|
|
on the command line (except that ‘<samp>-C</samp>’, ‘<samp>-f</samp>’, ‘<samp>-h</samp>’,
|
|
‘<samp>-o</samp>’, ‘<samp>-W</samp>’, and their long-named versions are ignored; and there
|
|
is no error for an invalid option).
|
|
</p>
|
|
<p>If you do put <code>MAKEFLAGS</code> in your environment, you should be sure not
|
|
to include any options that will drastically affect the actions of
|
|
<code>make</code> and undermine the purpose of makefiles and of <code>make</code>
|
|
itself. For instance, the ‘<samp>-t</samp>’, ‘<samp>-n</samp>’, and ‘<samp>-q</samp>’ options, if
|
|
put in one of these variables, could have disastrous consequences and would
|
|
certainly have at least surprising and probably annoying effects.
|
|
</p>
|
|
<p>If you’d like to run other implementations of <code>make</code> in addition
|
|
to GNU <code>make</code>, and hence do not want to add GNU
|
|
<code>make</code>-specific flags to the <code>MAKEFLAGS</code> variable, you can
|
|
add them to the <code>GNUMAKEFLAGS</code> variable instead. This variable
|
|
is parsed just before <code>MAKEFLAGS</code>, in the same way as
|
|
<code>MAKEFLAGS</code>. When <code>make</code> constructs <code>MAKEFLAGS</code> to
|
|
pass to a recursive <code>make</code> it will include all flags, even those
|
|
taken from <code>GNUMAKEFLAGS</code>. As a result, after parsing
|
|
<code>GNUMAKEFLAGS</code> GNU <code>make</code> sets this variable to the empty
|
|
string to avoid duplicating flags during recursion.
|
|
</p>
|
|
<p>It’s best to use <code>GNUMAKEFLAGS</code> only with flags which won’t
|
|
materially change the behavior of your makefiles. If your makefiles
|
|
require GNU make anyway then simply use <code>MAKEFLAGS</code>. Flags such
|
|
as ‘<samp>--no-print-directory</samp>’ or ‘<samp>--output-sync</samp>’ may be
|
|
appropriate for <code>GNUMAKEFLAGS</code>.
|
|
</p>
|
|
<hr>
|
|
<span id="g_t_002dw-Option"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Options_002fRecursion" accesskey="p" rel="prev">Options/Recursion</a>, Up: <a href="#Recursion" accesskey="u" rel="up">Recursion</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-_002d_002dprint_002ddirectory-Option"></span><h4 class="subsection">5.7.4 The ‘<samp>--print-directory</samp>’ Option</h4>
|
|
<span id="index-directories_002c-printing-them"></span>
|
|
<span id="index-printing-directories"></span>
|
|
<span id="index-recursion_002c-and-printing-directories"></span>
|
|
|
|
<p>If you use several levels of recursive <code>make</code> invocations, the
|
|
‘<samp>-w</samp>’ or ‘<samp><span class="nolinebreak">--print-directory</span></samp>’<!-- /@w --> option can make the output a
|
|
lot easier to understand by showing each directory as <code>make</code>
|
|
starts processing it and as <code>make</code> finishes processing it. For
|
|
example, if ‘<samp>make -w</samp>’ is run in the directory <samp>/u/gnu/make</samp>,
|
|
<code>make</code> will print a line of the form:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">make: Entering directory `/u/gnu/make'.
|
|
</pre></div>
|
|
|
|
<p>before doing anything else, and a line of the form:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">make: Leaving directory `/u/gnu/make'.
|
|
</pre></div>
|
|
|
|
<p>when processing is completed.
|
|
</p>
|
|
<span id="index-_002dC_002c-and-_002dw"></span>
|
|
<span id="index-_002d_002ddirectory_002c-and-_002d_002dprint_002ddirectory"></span>
|
|
<span id="index-recursion_002c-and-_002dw"></span>
|
|
<span id="index-_002dw_002c-and-_002dC"></span>
|
|
<span id="index-_002dw_002c-and-recursion"></span>
|
|
<span id="index-_002d_002dprint_002ddirectory_002c-and-_002d_002ddirectory"></span>
|
|
<span id="index-_002d_002dprint_002ddirectory_002c-and-recursion"></span>
|
|
<span id="index-_002d_002dno_002dprint_002ddirectory"></span>
|
|
<span id="index-_002d_002dprint_002ddirectory_002c-disabling"></span>
|
|
<span id="index-_002dw_002c-disabling"></span>
|
|
<p>Normally, you do not need to specify this option because ‘<samp>make</samp>’
|
|
does it for you: ‘<samp>-w</samp>’ is turned on automatically when you use the
|
|
‘<samp>-C</samp>’ option, and in sub-<code>make</code>s. <code>make</code> will not
|
|
automatically turn on ‘<samp>-w</samp>’ if you also use ‘<samp>-s</samp>’, which says to
|
|
be silent, or if you use ‘<samp>--no-print-directory</samp>’ to explicitly
|
|
disable it.
|
|
</p>
|
|
<hr>
|
|
<span id="Canned-Recipes"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Empty-Recipes" accesskey="n" rel="next">Empty Recipes</a>, Previous: <a href="#Recursion" accesskey="p" rel="prev">Recursion</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Defining-Canned-Recipes"></span><h3 class="section">5.8 Defining Canned Recipes</h3>
|
|
<span id="index-canned-recipes"></span>
|
|
<span id="index-recipes_002c-canned"></span>
|
|
<span id="index-sequences-of-commands"></span>
|
|
<span id="index-commands_002c-sequences-of"></span>
|
|
|
|
<p>When the same sequence of commands is useful in making various
|
|
targets, you can define it as a canned sequence with the <code>define</code>
|
|
directive, and refer to the canned sequence from the recipes for those
|
|
targets. The canned sequence is actually a variable, so the name must
|
|
not conflict with other variable names.
|
|
</p>
|
|
<p>Here is an example of defining a canned recipe:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">define run-yacc =
|
|
yacc $(firstword $^)
|
|
mv y.tab.c $@
|
|
endef
|
|
</pre></div>
|
|
<span id="index-yacc"></span>
|
|
|
|
<p>Here <code>run-yacc</code> is the name of the variable being defined;
|
|
<code>endef</code> marks the end of the definition; the lines in between are the
|
|
commands. The <code>define</code> directive does not expand variable references
|
|
and function calls in the canned sequence; the ‘<samp>$</samp>’ characters,
|
|
parentheses, variable names, and so on, all become part of the value of the
|
|
variable you are defining.
|
|
See <a href="#Multi_002dLine">Defining Multi-Line Variables</a>,
|
|
for a complete explanation of <code>define</code>.
|
|
</p>
|
|
<p>The first command in this example runs Yacc on the first prerequisite of
|
|
whichever rule uses the canned sequence. The output file from Yacc is
|
|
always named <samp>y.tab.c</samp>. The second command moves the output to the
|
|
rule’s target file name.
|
|
</p>
|
|
<p>To use the canned sequence, substitute the variable into the recipe of a
|
|
rule. You can substitute it like any other variable
|
|
(see <a href="#Reference">Basics of Variable References</a>).
|
|
Because variables defined by <code>define</code> are recursively expanded
|
|
variables, all the variable references you wrote inside the <code>define</code>
|
|
are expanded now. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.c : foo.y
|
|
$(run-yacc)
|
|
</pre></div>
|
|
|
|
<p>‘<samp>foo.y</samp>’ will be substituted for the variable ‘<samp>$^</samp>’ when it occurs in
|
|
<code>run-yacc</code>’s value, and ‘<samp>foo.c</samp>’ for ‘<samp>$@</samp>’.
|
|
</p>
|
|
<p>This is a realistic example, but this particular one is not needed in
|
|
practice because <code>make</code> has an implicit rule to figure out these
|
|
commands based on the file names involved
|
|
(see <a href="#Implicit-Rules">Using Implicit Rules</a>).
|
|
</p>
|
|
<span id="index-_0040_002c-and-define"></span>
|
|
<span id="index-_002d_002c-and-define"></span>
|
|
<span id="index-_002b_002c-and-define"></span>
|
|
<p>In recipe execution, each line of a canned sequence is treated just as
|
|
if the line appeared on its own in the rule, preceded by a tab. In
|
|
particular, <code>make</code> invokes a separate sub-shell for each line. You
|
|
can use the special prefix characters that affect command lines
|
|
(‘<samp>@</samp>’, ‘<samp>-</samp>’, and ‘<samp>+</samp>’) on each line of a canned sequence.
|
|
See <a href="#Recipes">Writing Recipes in Rules</a>.
|
|
For example, using this canned sequence:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">define frobnicate =
|
|
@echo "frobnicating target $@"
|
|
frob-step-1 $< -o $@-step-1
|
|
frob-step-2 $@-step-1 -o $@
|
|
endef
|
|
</pre></div>
|
|
|
|
<p><code>make</code> will not echo the first line, the <code>echo</code> command.
|
|
But it <em>will</em> echo the following two recipe lines.
|
|
</p>
|
|
<p>On the other hand, prefix characters on the recipe line that refers to
|
|
a canned sequence apply to every line in the sequence. So the rule:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">frob.out: frob.in
|
|
@$(frobnicate)
|
|
</pre></div>
|
|
|
|
<p>does not echo <em>any</em> recipe lines.
|
|
(See <a href="#Echoing">Recipe Echoing</a>, for a full explanation of ‘<samp>@</samp>’.)
|
|
</p>
|
|
<hr>
|
|
<span id="Empty-Recipes"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Canned-Recipes" accesskey="p" rel="prev">Canned Recipes</a>, Up: <a href="#Recipes" accesskey="u" rel="up">Recipes</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Using-Empty-Recipes"></span><h3 class="section">5.9 Using Empty Recipes</h3>
|
|
<span id="index-empty-recipes"></span>
|
|
<span id="index-recipes_002c-empty"></span>
|
|
|
|
<p>It is sometimes useful to define recipes which do nothing. This is done
|
|
simply by giving a recipe that consists of nothing but whitespace. For
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">target: ;
|
|
</pre></div>
|
|
|
|
<p>defines an empty recipe for <samp>target</samp>. You could also use a line
|
|
beginning with a recipe prefix character to define an empty recipe,
|
|
but this would be confusing because such a line looks empty.
|
|
</p>
|
|
<span id="index-_002eDEFAULT_002c-and-empty-recipes"></span>
|
|
<p>You may be wondering why you would want to define a recipe that does
|
|
nothing. One reason this is useful is to prevent a target from
|
|
getting implicit recipes (from implicit rules or the <code>.DEFAULT</code>
|
|
special target; see <a href="#Implicit-Rules">Implicit Rules</a> and see <a href="#Last-Resort">Defining Last-Resort Default Rules</a>).
|
|
</p>
|
|
<p>Empty recipes can also be used to avoid errors for targets that will
|
|
be created as a side-effect of another recipe: if the target does not
|
|
exist the empty recipe ensures that <code>make</code> won’t complain that it
|
|
doesn’t know how to build the target, and <code>make</code> will assume the
|
|
target is out of date.
|
|
</p>
|
|
<p>You may be inclined to define empty recipes for targets that are not
|
|
actual files, but only exist so that their prerequisites can be
|
|
remade. However, this is not the best way to do that, because the
|
|
prerequisites may not be remade properly if the target file actually
|
|
does exist. See <a href="#Phony-Targets">Phony Targets</a>, for a better way to
|
|
do this.
|
|
</p>
|
|
<hr>
|
|
<span id="Using-Variables"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Conditionals" accesskey="n" rel="next">Conditionals</a>, Previous: <a href="#Recipes" accesskey="p" rel="prev">Recipes</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-to-Use-Variables"></span><h2 class="chapter">6 How to Use Variables</h2>
|
|
<span id="index-variable"></span>
|
|
<span id="index-value"></span>
|
|
<span id="index-recursive-variable-expansion"></span>
|
|
<span id="index-simple-variable-expansion"></span>
|
|
|
|
<p>A <em>variable</em> is a name defined in a makefile to represent a string
|
|
of text, called the variable’s <em>value</em>. These values are
|
|
substituted by explicit request into targets, prerequisites, recipes,
|
|
and other parts of the makefile. (In some other versions of <code>make</code>,
|
|
variables are called <em>macros</em>.)
|
|
<span id="index-macro"></span>
|
|
</p>
|
|
<p>Variables and functions in all parts of a makefile are expanded when
|
|
read, except for in recipes, the right-hand sides of variable
|
|
definitions using ‘<samp>=</samp>’, and the bodies of variable definitions
|
|
using the <code>define</code> directive. The value a variable expands to is
|
|
that of its most recent definition at the time of expansion. In other
|
|
words, variables are dynamically scoped.
|
|
</p>
|
|
<p>Variables can represent lists of file names, options to pass to compilers,
|
|
programs to run, directories to look in for source files, directories to
|
|
write output in, or anything else you can imagine.
|
|
</p>
|
|
<p>A variable name may be any sequence of characters not containing
|
|
‘<samp>:</samp>’, ‘<samp>#</samp>’, ‘<samp>=</samp>’, or whitespace. However, variable names
|
|
containing characters other than letters, numbers, and underscores
|
|
should be considered carefully, as in some shells they cannot be
|
|
passed through the environment to a sub-<code>make</code>
|
|
(see <a href="#Variables_002fRecursion">Communicating Variables to a
|
|
Sub-<code>make</code></a>). Variable names beginning with ‘<samp>.</samp>’ and an
|
|
uppercase letter may be given special meaning in future versions of
|
|
<code>make</code>.
|
|
</p>
|
|
<p>Variable names are case-sensitive. The names ‘<samp>foo</samp>’, ‘<samp>FOO</samp>’,
|
|
and ‘<samp>Foo</samp>’ all refer to different variables.
|
|
</p>
|
|
<p>It is traditional to use upper case letters in variable names, but we
|
|
recommend using lower case letters for variable names that serve internal
|
|
purposes in the makefile, and reserving upper case for parameters that
|
|
control implicit rules or for parameters that the user should override with
|
|
command options (see <a href="#Overriding">Overriding Variables</a>).
|
|
</p>
|
|
<p>A few variables have names that are a single punctuation character or
|
|
just a few characters. These are the <em>automatic variables</em>, and
|
|
they have particular specialized uses. See <a href="#Automatic-Variables">Automatic Variables</a>.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Reference" accesskey="1">Reference</a></td><td> </td><td align="left" valign="top">How to use the value of a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Flavors" accesskey="2">Flavors</a></td><td> </td><td align="left" valign="top">Variables come in two flavors.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Advanced" accesskey="3">Advanced</a></td><td> </td><td align="left" valign="top">Advanced features for referencing a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Values" accesskey="4">Values</a></td><td> </td><td align="left" valign="top">All the ways variables get their values.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Setting" accesskey="5">Setting</a></td><td> </td><td align="left" valign="top">How to set a variable in the makefile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Appending" accesskey="6">Appending</a></td><td> </td><td align="left" valign="top">How to append more text to the old value
|
|
of a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Override-Directive" accesskey="7">Override Directive</a></td><td> </td><td align="left" valign="top">How to set a variable in the makefile even if
|
|
the user has set it with a command argument.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Multi_002dLine" accesskey="8">Multi-Line</a></td><td> </td><td align="left" valign="top">An alternate way to set a variable
|
|
to a multi-line string.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Undefine-Directive" accesskey="9">Undefine Directive</a></td><td> </td><td align="left" valign="top">How to undefine a variable so that it appears
|
|
as if it was never set.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Environment">Environment</a></td><td> </td><td align="left" valign="top">Variable values can come from the environment.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Target_002dspecific">Target-specific</a></td><td> </td><td align="left" valign="top">Variable values can be defined on a per-target
|
|
basis.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Pattern_002dspecific">Pattern-specific</a></td><td> </td><td align="left" valign="top">Target-specific variable values can be applied
|
|
to a group of targets that match a pattern.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Suppressing-Inheritance">Suppressing Inheritance</a></td><td> </td><td align="left" valign="top">Suppress inheritance of variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Special-Variables">Special Variables</a></td><td> </td><td align="left" valign="top">Variables with special meaning or behavior.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Reference"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Flavors" accesskey="n" rel="next">Flavors</a>, Previous: <a href="#Using-Variables" accesskey="p" rel="prev">Using Variables</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Basics-of-Variable-References"></span><h3 class="section">6.1 Basics of Variable References</h3>
|
|
<span id="index-variables_002c-how-to-reference"></span>
|
|
<span id="index-reference-to-variables"></span>
|
|
<span id="index-_0024_002c-in-variable-reference"></span>
|
|
<span id="index-dollar-sign-_0028_0024_0029_002c-in-variable-reference"></span>
|
|
|
|
<p>To substitute a variable’s value, write a dollar sign followed by the name
|
|
of the variable in parentheses or braces: either ‘<samp>$(foo)</samp>’ or
|
|
‘<samp>${foo}</samp>’ is a valid reference to the variable <code>foo</code>. This
|
|
special significance of ‘<samp>$</samp>’ is why you must write ‘<samp>$$</samp>’ to have
|
|
the effect of a single dollar sign in a file name or recipe.
|
|
</p>
|
|
<p>Variable references can be used in any context: targets, prerequisites,
|
|
recipes, most directives, and new variable values. Here is an
|
|
example of a common case, where a variable holds the names of all the
|
|
object files in a program:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = program.o foo.o utils.o
|
|
program : $(objects)
|
|
cc -o program $(objects)
|
|
|
|
$(objects) : defs.h
|
|
</pre></div>
|
|
|
|
<p>Variable references work by strict textual substitution. Thus, the rule
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo = c
|
|
prog.o : prog.$(foo)
|
|
$(foo)$(foo) -$(foo) prog.$(foo)
|
|
</pre></div>
|
|
|
|
<p>could be used to compile a C program <samp>prog.c</samp>. Since spaces before
|
|
the variable value are ignored in variable assignments, the value of
|
|
<code>foo</code> is precisely ‘<samp>c</samp>’. (Don’t actually write your makefiles
|
|
this way!)
|
|
</p>
|
|
<p>A dollar sign followed by a character other than a dollar sign,
|
|
open-parenthesis or open-brace treats that single character as the
|
|
variable name. Thus, you could reference the variable <code>x</code> with
|
|
‘<samp>$x</samp>’. However, this practice can lead to confusion (e.g.,
|
|
‘<samp>$foo</samp>’ refers to the variable <code>f</code> followed by the string
|
|
<code>oo</code>) so we recommend using parentheses or braces around all
|
|
variables, even single-letter variables, unless omitting them gives
|
|
significant readability improvements. One place where readability is
|
|
often improved is automatic variables (see <a href="#Automatic-Variables">Automatic Variables</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Flavors"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Advanced" accesskey="n" rel="next">Advanced</a>, Previous: <a href="#Reference" accesskey="p" rel="prev">Reference</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-Two-Flavors-of-Variables"></span><h3 class="section">6.2 The Two Flavors of Variables</h3>
|
|
<span id="index-flavors-of-variables"></span>
|
|
<span id="index-recursive-variable-expansion-1"></span>
|
|
<span id="index-variables_002c-flavors"></span>
|
|
<span id="index-recursively-expanded-variables"></span>
|
|
<span id="index-variables_002c-recursively-expanded"></span>
|
|
|
|
<p>There are different ways that a variable in GNU <code>make</code> can get a value;
|
|
we call them the <em>flavors</em> of variables. The flavors are distinguished in
|
|
how they handle the values they are assigned in the makefile, and in how those
|
|
values are managed when the variable is later used and expanded.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Recursive-Assignment" accesskey="1">Recursive Assignment</a></td><td> </td><td align="left" valign="top">Setting recursively expanded variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Simple-Assignment" accesskey="2">Simple Assignment</a></td><td> </td><td align="left" valign="top">Setting simply expanded variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Immediate-Assignment" accesskey="3">Immediate Assignment</a></td><td> </td><td align="left" valign="top">Setting immediately expanded variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Conditional-Assignment" accesskey="4">Conditional Assignment</a></td><td> </td><td align="left" valign="top">Assigning variable values conditionally.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Recursive-Assignment"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Simple-Assignment" accesskey="n" rel="next">Simple Assignment</a>, Previous: <a href="#Flavors" accesskey="p" rel="prev">Flavors</a>, Up: <a href="#Flavors" accesskey="u" rel="up">Flavors</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Recursively-Expanded-Variable-Assignment"></span><h4 class="subsection">6.2.1 Recursively Expanded Variable Assignment</h4>
|
|
<span id="index-_003d"></span>
|
|
<p>The first flavor of variable is a <em>recursively expanded</em> variable.
|
|
Variables of this sort are defined by lines using ‘<samp>=</samp>’
|
|
(see <a href="#Setting">Setting Variables</a>) or by the <code>define</code> directive
|
|
(see <a href="#Multi_002dLine">Defining Multi-Line Variables</a>). The value you specify
|
|
is installed verbatim; if it contains references to other variables,
|
|
these references are expanded whenever this variable is substituted (in
|
|
the course of expanding some other string). When this happens, it is
|
|
called <em>recursive expansion</em>.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo = $(bar)
|
|
bar = $(ugh)
|
|
ugh = Huh?
|
|
|
|
all:;echo $(foo)
|
|
</pre></div>
|
|
|
|
<p>will echo ‘<samp>Huh?</samp>’: ‘<samp>$(foo)</samp>’ expands to ‘<samp>$(bar)</samp>’ which
|
|
expands to ‘<samp>$(ugh)</samp>’ which finally expands to ‘<samp>Huh?</samp>’.
|
|
</p>
|
|
<p>This flavor of variable is the only sort supported by most other
|
|
versions of <code>make</code>. It has its advantages and its disadvantages.
|
|
An advantage (most would say) is that:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">CFLAGS = $(include_dirs) -O
|
|
include_dirs = -Ifoo -Ibar
|
|
</pre></div>
|
|
|
|
<p>will do what was intended: when ‘<samp>CFLAGS</samp>’ is expanded in a recipe,
|
|
it will expand to ‘<samp>-Ifoo -Ibar -O</samp>’. A major disadvantage is that you
|
|
cannot append something on the end of a variable, as in
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">CFLAGS = $(CFLAGS) -O
|
|
</pre></div>
|
|
|
|
<p>because it will cause an infinite loop in the variable expansion.
|
|
(Actually <code>make</code> detects the infinite loop and reports an error.)
|
|
<span id="index-loops-in-variable-expansion"></span>
|
|
<span id="index-variables_002c-loops-in-expansion"></span>
|
|
</p>
|
|
<p>Another disadvantage is that any functions
|
|
(see <a href="#Functions">Functions for Transforming Text</a>)
|
|
referenced in the definition will be executed every time the variable is
|
|
expanded. This makes <code>make</code> run slower; worse, it causes the
|
|
<code>wildcard</code> and <code>shell</code> functions to give unpredictable results
|
|
because you cannot easily control when they are called, or even how many
|
|
times.
|
|
</p>
|
|
<hr>
|
|
<span id="Simple-Assignment"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Immediate-Assignment" accesskey="n" rel="next">Immediate Assignment</a>, Previous: <a href="#Recursive-Assignment" accesskey="p" rel="prev">Recursive Assignment</a>, Up: <a href="#Flavors" accesskey="u" rel="up">Flavors</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Simply-Expanded-Variable-Assignment"></span><h4 class="subsection">6.2.2 Simply Expanded Variable Assignment</h4>
|
|
<p>To avoid the problems and inconveniences of recursively expanded
|
|
variables, there is another flavor: simply expanded variables.
|
|
</p>
|
|
<span id="index-simply-expanded-variables"></span>
|
|
<span id="index-variables_002c-simply-expanded"></span>
|
|
<span id="index-_003a_003d"></span>
|
|
<span id="index-_003a_003a_003d"></span>
|
|
<p><em>Simply expanded variables</em> are defined by lines using ‘<samp>:=</samp>’
|
|
or ‘<samp>::=</samp>’ (see <a href="#Setting">Setting Variables</a>). Both forms are
|
|
equivalent in GNU <code>make</code>; however only the ‘<samp>::=</samp>’ form is
|
|
described by the POSIX standard (support for ‘<samp>::=</samp>’ is added to
|
|
the POSIX standard for POSIX Issue 8).
|
|
</p>
|
|
<p>The value of a simply expanded variable is scanned once, expanding any
|
|
references to other variables and functions, when the variable is
|
|
defined. Once that expansion is complete the value of the variable is
|
|
never expanded again: when the variable is used the value is copied
|
|
verbatim as the expansion. If the value contained variable references
|
|
the result of the expansion will contain their values <em>as of the
|
|
time this variable was defined</em>. Therefore,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">x := foo
|
|
y := $(x) bar
|
|
x := later
|
|
</pre></div>
|
|
|
|
<p>is equivalent to
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">y := foo bar
|
|
x := later
|
|
</pre></div>
|
|
|
|
<p>Here is a somewhat more complicated example, illustrating the use of
|
|
‘<samp>:=</samp>’ in conjunction with the <code>shell</code> function.
|
|
(See <a href="#Shell-Function">The <code>shell</code> Function</a>.) This example
|
|
also shows use of the variable <code>MAKELEVEL</code>, which is changed
|
|
when it is passed down from level to level.
|
|
(See <a href="#Variables_002fRecursion">Communicating Variables to a
|
|
Sub-<code>make</code></a>, for information about <code>MAKELEVEL</code>.)
|
|
</p>
|
|
<span id="index-MAKELEVEL-1"></span>
|
|
<span id="index-MAKE-1"></span>
|
|
<div class="example">
|
|
<pre class="example">ifeq (0,${MAKELEVEL})
|
|
whoami := $(shell whoami)
|
|
host-type := $(shell arch)
|
|
MAKE := ${MAKE} host-type=${host-type} whoami=${whoami}
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>An advantage of this use of ‘<samp>:=</samp>’ is that a typical
|
|
‘descend into a directory’ recipe then looks like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">${subdirs}:
|
|
${MAKE} -C $@ all
|
|
</pre></div>
|
|
|
|
<p>Simply expanded variables generally make complicated makefile programming
|
|
more predictable because they work like variables in most programming
|
|
languages. They allow you to redefine a variable using its own value (or
|
|
its value processed in some way by one of the expansion functions) and to
|
|
use the expansion functions much more efficiently
|
|
(see <a href="#Functions">Functions for Transforming Text</a>).
|
|
</p>
|
|
<span id="index-spaces_002c-in-variable-values"></span>
|
|
<span id="index-whitespace_002c-in-variable-values"></span>
|
|
<span id="index-variables_002c-spaces-in-values"></span>
|
|
<p>You can also use them to introduce controlled leading whitespace into
|
|
variable values. Leading whitespace characters are discarded from your
|
|
input before substitution of variable references and function calls;
|
|
this means you can include leading spaces in a variable value by
|
|
protecting them with variable references, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">nullstring :=
|
|
space := $(nullstring) # end of the line
|
|
</pre></div>
|
|
|
|
<p>Here the value of the variable <code>space</code> is precisely one space. The
|
|
comment ‘<samp># end of the line</samp>’<!-- /@w --> is included here just for clarity.
|
|
Since trailing space characters are <em>not</em> stripped from variable
|
|
values, just a space at the end of the line would have the same effect
|
|
(but be rather hard to read). If you put whitespace at the end of a
|
|
variable value, it is a good idea to put a comment like that at the end
|
|
of the line to make your intent clear. Conversely, if you do <em>not</em>
|
|
want any whitespace characters at the end of your variable value, you
|
|
must remember not to put a random comment on the end of the line after
|
|
some whitespace, such as this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">dir := /foo/bar # directory to put the frobs in
|
|
</pre></div>
|
|
|
|
<p>Here the value of the variable <code>dir</code> is ‘<samp>/foo/bar </samp>’<!-- /@w -->
|
|
(with four trailing spaces), which was probably not the intention.
|
|
(Imagine something like ‘<samp>$(dir)/file</samp>’<!-- /@w --> with this definition!)
|
|
</p>
|
|
<hr>
|
|
<span id="Immediate-Assignment"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Conditional-Assignment" accesskey="n" rel="next">Conditional Assignment</a>, Previous: <a href="#Simple-Assignment" accesskey="p" rel="prev">Simple Assignment</a>, Up: <a href="#Flavors" accesskey="u" rel="up">Flavors</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Immediately-Expanded-Variable-Assignment"></span><h4 class="subsection">6.2.3 Immediately Expanded Variable Assignment</h4>
|
|
<span id="index-immediate-variable-assignment"></span>
|
|
<span id="index-variables_002c-immediate-assignment"></span>
|
|
<span id="index-_003a_003a_003a_003d"></span>
|
|
|
|
<p>Another form of assignment allows for immediate expansion, but unlike simple
|
|
assignment the resulting variable is recursive: it will be re-expanded again
|
|
on every use. In order to avoid unexpected results, after the value is
|
|
immediately expanded it will automatically be quoted: all instances of
|
|
<code>$</code> in the value after expansion will be converted into <code>$$</code>. This
|
|
type of assignment uses the ‘<samp>:::=</samp>’ operator. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">var = first
|
|
OUT :::= $(var)
|
|
var = second
|
|
</pre></div>
|
|
|
|
<p>results in the <code>OUT</code> variable containing the text ‘<samp>first</samp>’, while here:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">var = one$$two
|
|
OUT :::= $(var)
|
|
var = three$$four
|
|
</pre></div>
|
|
|
|
<p>results in the <code>OUT</code> variable containing the text ‘<samp>one$$two</samp>’. The
|
|
value is expanded when the variable is assigned, so the result is the
|
|
expansion of the first value of <code>var</code>, ‘<samp>one$two</samp>’; then the value is
|
|
re-escaped before the assignment is complete giving the final result of
|
|
‘<samp>one$$two</samp>’.
|
|
</p>
|
|
<p>The variable <code>OUT</code> is thereafter considered a recursive variable, so it
|
|
will be re-expanded when it is used.
|
|
</p>
|
|
<p>This seems functionally equivalent to the ‘<samp>:=</samp>’ / ‘<samp>::=</samp>’ operators,
|
|
but there are a few differences:
|
|
</p>
|
|
<p>First, after assignment the variable is a normal recursive variable; when you
|
|
append to it with ‘<samp>+=</samp>’ the value on the right-hand side is not expanded
|
|
immediately. If you prefer the ‘<samp>+=</samp>’ operator to expand the right-hand
|
|
side immediately you should use the ‘<samp>:=</samp>’ / ‘<samp>::=</samp>’ assignment instead.
|
|
</p>
|
|
<p>Second, these variables are slightly less efficient than simply expanded
|
|
variables since they do need to be re-expanded when they are used, rather than
|
|
merely copied. However since all variable references are escaped this
|
|
expansion simply un-escapes the value, it won’t expand any variables or run
|
|
any functions.
|
|
</p>
|
|
<p>Here is another example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">var = one$$two
|
|
OUT :::= $(var)
|
|
OUT += $(var)
|
|
var = three$$four
|
|
</pre></div>
|
|
|
|
<p>After this, the value of <code>OUT</code> is the text ‘<samp>one$$two $(var)</samp>’. When
|
|
this variable is used it will be expanded and the result will be
|
|
‘<samp>one$two three$four</samp>’.
|
|
</p>
|
|
<p>This style of assignment is equivalent to the traditional BSD <code>make</code>
|
|
‘<samp>:=</samp>’ operator; as you can see it works slightly differently than the GNU
|
|
<code>make</code> ‘<samp>:=</samp>’ operator. The <code>:::=</code> operator is added to the
|
|
POSIX specification in Issue 8 to provide portability.
|
|
</p>
|
|
<hr>
|
|
<span id="Conditional-Assignment"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Immediate-Assignment" accesskey="p" rel="prev">Immediate Assignment</a>, Up: <a href="#Flavors" accesskey="u" rel="up">Flavors</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Conditional-Variable-Assignment"></span><h4 class="subsection">6.2.4 Conditional Variable Assignment</h4>
|
|
<span id="index-conditional-variable-assignment"></span>
|
|
<span id="index-variables_002c-conditional-assignment"></span>
|
|
<span id="index-_003f_003d"></span>
|
|
<p>There is another assignment operator for variables, ‘<samp>?=</samp>’. This
|
|
is called a conditional variable assignment operator, because it only
|
|
has an effect if the variable is not yet defined. This statement:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">FOO ?= bar
|
|
</pre></div>
|
|
|
|
<p>is exactly equivalent to this
|
|
(see <a href="#Origin-Function">The <code>origin</code> Function</a>):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ifeq ($(origin FOO), undefined)
|
|
FOO = bar
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>Note that a variable set to an empty value is still defined, so
|
|
‘<samp>?=</samp>’ will not set that variable.
|
|
</p>
|
|
<hr>
|
|
<span id="Advanced"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Values" accesskey="n" rel="next">Values</a>, Previous: <a href="#Flavors" accesskey="p" rel="prev">Flavors</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Advanced-Features-for-Reference-to-Variables"></span><h3 class="section">6.3 Advanced Features for Reference to Variables</h3>
|
|
<span id="index-reference-to-variables-1"></span>
|
|
|
|
<p>This section describes some advanced features you can use to reference
|
|
variables in more flexible ways.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Substitution-Refs" accesskey="1">Substitution Refs</a></td><td> </td><td align="left" valign="top">Referencing a variable with
|
|
substitutions on the value.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Computed-Names" accesskey="2">Computed Names</a></td><td> </td><td align="left" valign="top">Computing the name of the variable to refer to.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Substitution-Refs"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Computed-Names" accesskey="n" rel="next">Computed Names</a>, Previous: <a href="#Advanced" accesskey="p" rel="prev">Advanced</a>, Up: <a href="#Advanced" accesskey="u" rel="up">Advanced</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Substitution-References"></span><h4 class="subsection">6.3.1 Substitution References</h4>
|
|
<span id="index-modified-variable-reference"></span>
|
|
<span id="index-substitution-variable-reference"></span>
|
|
<span id="index-variables_002c-modified-reference"></span>
|
|
<span id="index-variables_002c-substitution-reference"></span>
|
|
|
|
<span id="index-variables_002c-substituting-suffix-in"></span>
|
|
<span id="index-suffix_002c-substituting-in-variables"></span>
|
|
<p>A <em>substitution reference</em> substitutes the value of a variable with
|
|
alterations that you specify. It has the form
|
|
‘<samp>$(<var>var</var>:<var>a</var>=<var>b</var>)</samp>’ (or
|
|
‘<samp>${<var>var</var>:<var>a</var>=<var>b</var>}</samp>’) and its meaning is to take the value
|
|
of the variable <var>var</var>, replace every <var>a</var> at the end of a word with
|
|
<var>b</var> in that value, and substitute the resulting string.
|
|
</p>
|
|
<p>When we say “at the end of a word”, we mean that <var>a</var> must appear
|
|
either followed by whitespace or at the end of the value in order to be
|
|
replaced; other occurrences of <var>a</var> in the value are unaltered. For
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo := a.o b.o l.a c.o
|
|
bar := $(foo:.o=.c)
|
|
</pre></div>
|
|
|
|
<p>sets ‘<samp>bar</samp>’ to ‘<samp>a.c b.c l.a c.c</samp>’. See <a href="#Setting">Setting Variables</a>.
|
|
</p>
|
|
<p>A substitution reference is shorthand for the <code>patsubst</code>
|
|
expansion function (see <a href="#Text-Functions">Functions for String Substitution and Analysis</a>):
|
|
‘<samp>$(<var>var</var>:<var>a</var>=<var>b</var>)</samp>’ is equivalent to
|
|
‘<samp>$(patsubst %<var>a</var>,%<var>b</var>,<var>var</var>)</samp>’. We provide
|
|
substitution references as well as <code>patsubst</code> for compatibility
|
|
with other implementations of <code>make</code>.
|
|
</p>
|
|
<span id="index-patsubst"></span>
|
|
<p>Another type of substitution reference lets you use the full power of
|
|
the <code>patsubst</code> function. It has the same form
|
|
‘<samp>$(<var>var</var>:<var>a</var>=<var>b</var>)</samp>’ described above, except that now
|
|
<var>a</var> must contain a single ‘<samp>%</samp>’ character. This case is
|
|
equivalent to ‘<samp>$(patsubst <var>a</var>,<var>b</var>,$(<var>var</var>))</samp>’.
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>,
|
|
for a description of the <code>patsubst</code> function. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo := a.o b.o l.a c.o
|
|
bar := $(foo:%.o=%.c)
|
|
</pre></div>
|
|
|
|
<p>sets ‘<samp>bar</samp>’ to ‘<samp>a.c b.c l.a c.c</samp>’.
|
|
</p>
|
|
<hr>
|
|
<span id="Computed-Names"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Substitution-Refs" accesskey="p" rel="prev">Substitution Refs</a>, Up: <a href="#Advanced" accesskey="u" rel="up">Advanced</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Computed-Variable-Names"></span><h4 class="subsection">6.3.2 Computed Variable Names</h4>
|
|
<span id="index-nested-variable-reference"></span>
|
|
<span id="index-computed-variable-name"></span>
|
|
<span id="index-variables_002c-computed-names"></span>
|
|
<span id="index-variables_002c-nested-references"></span>
|
|
<span id="index-variables_002c-_0024-in-name"></span>
|
|
<span id="index-_0024_002c-in-variable-name"></span>
|
|
<span id="index-dollar-sign-_0028_0024_0029_002c-in-variable-name"></span>
|
|
|
|
<p>Computed variable names are an advanced concept, very useful in more
|
|
sophisticated makefile programming. In simple situations you need not
|
|
consider them, but they can be extremely useful.
|
|
</p>
|
|
<p>Variables may be referenced inside the name of a variable. This is
|
|
called a <em>computed variable name</em> or a <em>nested variable
|
|
reference</em>. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">x = y
|
|
y = z
|
|
a := $($(x))
|
|
</pre></div>
|
|
|
|
<p>defines <code>a</code> as ‘<samp>z</samp>’: the ‘<samp>$(x)</samp>’ inside ‘<samp>$($(x))</samp>’ expands
|
|
to ‘<samp>y</samp>’, so ‘<samp>$($(x))</samp>’ expands to ‘<samp>$(y)</samp>’ which in turn expands
|
|
to ‘<samp>z</samp>’. Here the name of the variable to reference is not stated
|
|
explicitly; it is computed by expansion of ‘<samp>$(x)</samp>’. The reference
|
|
‘<samp>$(x)</samp>’ here is nested within the outer variable reference.
|
|
</p>
|
|
<p>The previous example shows two levels of nesting, but any number of levels
|
|
is possible. For example, here are three levels:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">x = y
|
|
y = z
|
|
z = u
|
|
a := $($($(x)))
|
|
</pre></div>
|
|
|
|
<p>Here the innermost ‘<samp>$(x)</samp>’ expands to ‘<samp>y</samp>’, so ‘<samp>$($(x))</samp>’
|
|
expands to ‘<samp>$(y)</samp>’ which in turn expands to ‘<samp>z</samp>’; now we have
|
|
‘<samp>$(z)</samp>’, which becomes ‘<samp>u</samp>’.
|
|
</p>
|
|
<p>References to recursively-expanded variables within a variable name are
|
|
re-expanded in the usual fashion. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">x = $(y)
|
|
y = z
|
|
z = Hello
|
|
a := $($(x))
|
|
</pre></div>
|
|
|
|
<p>defines <code>a</code> as ‘<samp>Hello</samp>’: ‘<samp>$($(x))</samp>’ becomes ‘<samp>$($(y))</samp>’
|
|
which becomes ‘<samp>$(z)</samp>’ which becomes ‘<samp>Hello</samp>’.
|
|
</p>
|
|
<p>Nested variable references can also contain modified references and function
|
|
invocations (see <a href="#Functions">Functions for Transforming Text</a>), just like
|
|
any other reference. For example, using the <code>subst</code> function
|
|
(see <a href="#Text-Functions">Functions for String Substitution and Analysis</a>):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">x = variable1
|
|
variable2 := Hello
|
|
y = $(subst 1,2,$(x))
|
|
z = y
|
|
a := $($($(z)))
|
|
</pre></div>
|
|
|
|
<p>eventually defines <code>a</code> as ‘<samp>Hello</samp>’. It is doubtful that anyone
|
|
would ever want to write a nested reference as convoluted as this one, but
|
|
it works: ‘<samp>$($($(z)))</samp>’ expands to ‘<samp>$($(y))</samp>’ which becomes
|
|
‘<samp>$($(subst 1,2,$(x)))</samp>’. This gets the value ‘<samp>variable1</samp>’ from
|
|
<code>x</code> and changes it by substitution to ‘<samp>variable2</samp>’, so that the
|
|
entire string becomes ‘<samp>$(variable2)</samp>’, a simple variable reference
|
|
whose value is ‘<samp>Hello</samp>’.
|
|
</p>
|
|
<p>A computed variable name need not consist entirely of a single variable
|
|
reference. It can contain several variable references, as well as some
|
|
invariant text. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">a_dirs := dira dirb
|
|
1_dirs := dir1 dir2
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">a_files := filea fileb
|
|
1_files := file1 file2
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">ifeq "$(use_a)" "yes"
|
|
a1 := a
|
|
else
|
|
a1 := 1
|
|
endif
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">ifeq "$(use_dirs)" "yes"
|
|
df := dirs
|
|
else
|
|
df := files
|
|
endif
|
|
|
|
dirs := $($(a1)_$(df))
|
|
</pre></div>
|
|
|
|
<p>will give <code>dirs</code> the same value as <code>a_dirs</code>, <code>1_dirs</code>,
|
|
<code>a_files</code> or <code>1_files</code> depending on the settings of <code>use_a</code>
|
|
and <code>use_dirs</code>.
|
|
</p>
|
|
<p>Computed variable names can also be used in substitution references:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">a_objects := a.o b.o c.o
|
|
1_objects := 1.o 2.o 3.o
|
|
|
|
sources := $($(a1)_objects:.o=.c)
|
|
</pre></div>
|
|
|
|
<p>defines <code>sources</code> as either ‘<samp>a.c b.c c.c</samp>’ or ‘<samp>1.c 2.c 3.c</samp>’,
|
|
depending on the value of <code>a1</code>.
|
|
</p>
|
|
<p>The only restriction on this sort of use of nested variable references
|
|
is that they cannot specify part of the name of a function to be called.
|
|
This is because the test for a recognized function name is done before
|
|
the expansion of nested references. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ifdef do_sort
|
|
func := sort
|
|
else
|
|
func := strip
|
|
endif
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">bar := a d b g q c
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">foo := $($(func) $(bar))
|
|
</pre></div>
|
|
|
|
<p>attempts to give ‘<samp>foo</samp>’ the value of the variable ‘<samp>sort a d b g
|
|
q c</samp>’ or ‘<samp>strip a d b g q c</samp>’, rather than giving ‘<samp>a d b g q c</samp>’
|
|
as the argument to either the <code>sort</code> or the <code>strip</code> function.
|
|
This restriction could be removed in the future if that change is shown
|
|
to be a good idea.
|
|
</p>
|
|
<p>You can also use computed variable names in the left-hand side of a
|
|
variable assignment, or in a <code>define</code> directive, as in:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">dir = foo
|
|
$(dir)_sources := $(wildcard $(dir)/*.c)
|
|
define $(dir)_print =
|
|
lpr $($(dir)_sources)
|
|
endef
|
|
</pre></div>
|
|
|
|
<p>This example defines the variables ‘<samp>dir</samp>’, ‘<samp>foo_sources</samp>’, and
|
|
‘<samp>foo_print</samp>’.
|
|
</p>
|
|
<p>Note that <em>nested variable references</em> are quite different from
|
|
<em>recursively expanded variables</em>
|
|
(see <a href="#Flavors">The Two Flavors of Variables</a>), though both are
|
|
used together in complex ways when doing makefile programming.
|
|
</p>
|
|
<hr>
|
|
<span id="Values"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Setting" accesskey="n" rel="next">Setting</a>, Previous: <a href="#Advanced" accesskey="p" rel="prev">Advanced</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-Variables-Get-Their-Values"></span><h3 class="section">6.4 How Variables Get Their Values</h3>
|
|
<span id="index-variables_002c-how-they-get-their-values"></span>
|
|
<span id="index-value_002c-how-a-variable-gets-it"></span>
|
|
|
|
<p>Variables can get values in several different ways:
|
|
</p>
|
|
<ul>
|
|
<li> You can specify an overriding value when you run <code>make</code>.
|
|
See <a href="#Overriding">Overriding Variables</a>.
|
|
|
|
</li><li> You can specify a value in the makefile, either
|
|
with an assignment (see <a href="#Setting">Setting Variables</a>) or with a
|
|
verbatim definition (see <a href="#Multi_002dLine">Defining Multi-Line Variables</a>).
|
|
|
|
</li><li> You can specify a short-lived value with the <code>let</code> function
|
|
(see <a href="#Let-Function">Let Function</a>) or with the <code>foreach</code> function
|
|
(see <a href="#Foreach-Function">Foreach Function</a>).
|
|
|
|
</li><li> Variables in the environment become <code>make</code> variables.
|
|
See <a href="#Environment">Variables from the Environment</a>.
|
|
|
|
</li><li> Several <em>automatic</em> variables are given new values for each rule.
|
|
Each of these has a single conventional use.
|
|
See <a href="#Automatic-Variables">Automatic Variables</a>.
|
|
|
|
</li><li> Several variables have constant initial values.
|
|
See <a href="#Implicit-Variables">Variables Used by Implicit Rules</a>.
|
|
</li></ul>
|
|
|
|
<hr>
|
|
<span id="Setting"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Appending" accesskey="n" rel="next">Appending</a>, Previous: <a href="#Values" accesskey="p" rel="prev">Values</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Setting-Variables"></span><h3 class="section">6.5 Setting Variables</h3>
|
|
<span id="index-setting-variables"></span>
|
|
<span id="index-variables_002c-setting"></span>
|
|
<span id="index-_003d-1"></span>
|
|
<span id="index-_003a_003d-1"></span>
|
|
<span id="index-_003a_003a_003d-1"></span>
|
|
<span id="index-_003a_003a_003a_003d-1"></span>
|
|
<span id="index-_003f_003d-1"></span>
|
|
<span id="index-_0021_003d"></span>
|
|
|
|
<p>To set a variable from the makefile, write a line starting with the variable
|
|
name followed by one of the assignment operators ‘<samp>=</samp>’, ‘<samp>:=</samp>’,
|
|
‘<samp>::=</samp>’, or ‘<samp>:::=</samp>’. Whatever follows the operator and any initial
|
|
whitespace on the line becomes the value. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = main.o foo.o bar.o utils.o
|
|
</pre></div>
|
|
|
|
<p>defines a variable named <code>objects</code> to contain the value ‘<samp>main.o
|
|
foo.o bar.o utils.o</samp>’. Whitespace around the variable name and immediately
|
|
after the ‘<samp>=</samp>’ is ignored.
|
|
</p>
|
|
<p>Variables defined with ‘<samp>=</samp>’ are <em>recursively expanded</em> variables.
|
|
Variables defined with ‘<samp>:=</samp>’ or ‘<samp>::=</samp>’ are <em>simply expanded</em>
|
|
variables; these definitions can contain variable references which will be
|
|
expanded before the definition is made. Variables defined with ‘<samp>:::=</samp>’
|
|
are <em>immediately expanded</em> variables. The different assignment operators
|
|
are described in See <a href="#Flavors">The Two Flavors of Variables</a>.
|
|
</p>
|
|
<p>The variable name may contain function and variable references, which
|
|
are expanded when the line is read to find the actual variable name to use.
|
|
</p>
|
|
<p>There is no limit on the length of the value of a variable except the
|
|
amount of memory on the computer. You can split the value of a
|
|
variable into multiple physical lines for readability
|
|
(see <a href="#Splitting-Lines">Splitting Long Lines</a>).
|
|
</p>
|
|
<p>Most variable names are considered to have the empty string as a value if
|
|
you have never set them. Several variables have built-in initial values
|
|
that are not empty, but you can set them in the usual ways
|
|
(see <a href="#Implicit-Variables">Variables Used by Implicit Rules</a>).
|
|
Several special variables are set
|
|
automatically to a new value for each rule; these are called the
|
|
<em>automatic</em> variables (see <a href="#Automatic-Variables">Automatic Variables</a>).
|
|
</p>
|
|
<p>If you’d like a variable to be set to a value only if it’s not already
|
|
set, then you can use the shorthand operator ‘<samp>?=</samp>’ instead of
|
|
‘<samp>=</samp>’. These two settings of the variable ‘<samp>FOO</samp>’ are identical
|
|
(see <a href="#Origin-Function">The <code>origin</code> Function</a>):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">FOO ?= bar
|
|
</pre></div>
|
|
|
|
<p>and
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ifeq ($(origin FOO), undefined)
|
|
FOO = bar
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>The shell assignment operator ‘<samp>!=</samp>’ can be used to execute a
|
|
shell script and set a variable to its output. This operator first
|
|
evaluates the right-hand side, then passes that result to the shell
|
|
for execution. If the result of the execution ends in a newline, that
|
|
one newline is removed; all other newlines are replaced by spaces.
|
|
The resulting string is then placed into the named
|
|
recursively-expanded variable. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">hash != printf '\043'
|
|
file_list != find . -name '*.c'
|
|
</pre></div>
|
|
|
|
<p>If the result of the execution could produce a <code>$</code>, and you don’t
|
|
intend what follows that to be interpreted as a make variable or
|
|
function reference, then you must replace every <code>$</code> with
|
|
<code>$$</code> as part of the execution. Alternatively, you can set a
|
|
simply expanded variable to the result of running a program using the
|
|
<code>shell</code> function call. See <a href="#Shell-Function">The <code>shell</code>
|
|
Function</a>. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">hash := $(shell printf '\043')
|
|
var := $(shell find . -name "*.c")
|
|
</pre></div>
|
|
|
|
<p>As with the <code>shell</code> function, the exit status of the just-invoked
|
|
shell script is stored in the <code>.SHELLSTATUS</code> variable.
|
|
</p>
|
|
|
|
<hr>
|
|
<span id="Appending"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Override-Directive" accesskey="n" rel="next">Override Directive</a>, Previous: <a href="#Setting" accesskey="p" rel="prev">Setting</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Appending-More-Text-to-Variables"></span><h3 class="section">6.6 Appending More Text to Variables</h3>
|
|
<span id="index-_002b_003d"></span>
|
|
<span id="index-appending-to-variables"></span>
|
|
<span id="index-variables_002c-appending-to"></span>
|
|
|
|
<p>Often it is useful to add more text to the value of a variable already defined.
|
|
You do this with a line containing ‘<samp>+=</samp>’, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects += another.o
|
|
</pre></div>
|
|
|
|
<p>This takes the value of the variable <code>objects</code>, and adds the text
|
|
‘<samp>another.o</samp>’ to it (preceded by a single space, if it has a value
|
|
already). Thus:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = main.o foo.o bar.o utils.o
|
|
objects += another.o
|
|
</pre></div>
|
|
|
|
<p>sets <code>objects</code> to ‘<samp>main.o foo.o bar.o utils.o another.o</samp>’.
|
|
</p>
|
|
<p>Using ‘<samp>+=</samp>’ is similar to:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = main.o foo.o bar.o utils.o
|
|
objects := $(objects) another.o
|
|
</pre></div>
|
|
|
|
<p>but differs in ways that become important when you use more complex values.
|
|
</p>
|
|
<p>When the variable in question has not been defined before, ‘<samp>+=</samp>’
|
|
acts just like normal ‘<samp>=</samp>’: it defines a recursively-expanded
|
|
variable. However, when there <em>is</em> a previous definition, exactly
|
|
what ‘<samp>+=</samp>’ does depends on what flavor of variable you defined
|
|
originally. See <a href="#Flavors">The Two Flavors of Variables</a>, for an
|
|
explanation of the two flavors of variables.
|
|
</p>
|
|
<p>When you add to a variable’s value with ‘<samp>+=</samp>’, <code>make</code> acts
|
|
essentially as if you had included the extra text in the initial definition of
|
|
the variable. If you defined it first with ‘<samp>:=</samp>’ or ‘<samp>::=</samp>’, making it
|
|
a simply-expanded variable, ‘<samp>+=</samp>’ adds to that simply-expanded definition,
|
|
and expands the new text before appending it to the old value just as
|
|
‘<samp>:=</samp>’ does (see <a href="#Setting">Setting Variables</a>, for a full explanation
|
|
of ‘<samp>:=</samp>’ or ‘<samp>::=</samp>’). In fact,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">variable := value
|
|
variable += more
|
|
</pre></div>
|
|
|
|
<p>is exactly equivalent to:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">variable := value
|
|
variable := $(variable) more
|
|
</pre></div>
|
|
|
|
<p>On the other hand, when you use ‘<samp>+=</samp>’ with a variable that you defined
|
|
first to be recursively-expanded using plain ‘<samp>=</samp>’ or ‘<samp>:::=</samp>’,
|
|
<code>make</code> appends the un-expanded text to the existing value, whatever it
|
|
is. This means that
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">variable = value
|
|
variable += more
|
|
</pre></div>
|
|
|
|
<p>is roughly equivalent to:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">temp = value
|
|
variable = $(temp) more
|
|
</pre></div>
|
|
|
|
<p>except that of course it never defines a variable called <code>temp</code>.
|
|
The importance of this comes when the variable’s old value contains
|
|
variable references. Take this common example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">CFLAGS = $(includes) -O
|
|
…
|
|
CFLAGS += -pg # enable profiling
|
|
</pre></div>
|
|
|
|
<p>The first line defines the <code>CFLAGS</code> variable with a reference to another
|
|
variable, <code>includes</code>. (<code>CFLAGS</code> is used by the rules for C
|
|
compilation; see <a href="#Catalogue-of-Rules">Catalogue of Built-In Rules</a>.)
|
|
Using ‘<samp>=</samp>’ for the definition makes <code>CFLAGS</code> a recursively-expanded
|
|
variable, meaning ‘<samp>$(includes) <span class="nolinebreak">-O</span></samp>’<!-- /@w --> is <em>not</em> expanded when
|
|
<code>make</code> processes the definition of <code>CFLAGS</code>. Thus, <code>includes</code>
|
|
need not be defined yet for its value to take effect. It only has to be
|
|
defined before any reference to <code>CFLAGS</code>. If we tried to append to the
|
|
value of <code>CFLAGS</code> without using ‘<samp>+=</samp>’, we might do it like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">CFLAGS := $(CFLAGS) -pg # enable profiling
|
|
</pre></div>
|
|
|
|
<p>This is pretty close, but not quite what we want. Using ‘<samp>:=</samp>’
|
|
redefines <code>CFLAGS</code> as a simply-expanded variable; this means
|
|
<code>make</code> expands the text ‘<samp>$(CFLAGS) <span class="nolinebreak">-pg</span></samp>’<!-- /@w --> before setting the
|
|
variable. If <code>includes</code> is not yet defined, we get ‘<samp> <span class="nolinebreak">-O</span> <span class="nolinebreak">-pg</span></samp>’<!-- /@w -->, and a later definition of <code>includes</code> will have no effect.
|
|
Conversely, by using ‘<samp>+=</samp>’ we set <code>CFLAGS</code> to the
|
|
<em>unexpanded</em> value ‘<samp>$(includes) <span class="nolinebreak">-O</span> <span class="nolinebreak">-pg</span></samp>’<!-- /@w -->. Thus we preserve
|
|
the reference to <code>includes</code>, so if that variable gets defined at
|
|
any later point, a reference like ‘<samp>$(CFLAGS)</samp>’ still uses its
|
|
value.
|
|
</p>
|
|
<hr>
|
|
<span id="Override-Directive"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Multi_002dLine" accesskey="n" rel="next">Multi-Line</a>, Previous: <a href="#Appending" accesskey="p" rel="prev">Appending</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-override-Directive"></span><h3 class="section">6.7 The <code>override</code> Directive</h3>
|
|
<span id="index-override"></span>
|
|
<span id="index-overriding-with-override"></span>
|
|
<span id="index-variables_002c-overriding"></span>
|
|
|
|
<p>If a variable has been set with a command argument
|
|
(see <a href="#Overriding">Overriding Variables</a>),
|
|
then ordinary assignments in the makefile are ignored. If you want to set
|
|
the variable in the makefile even though it was set with a command
|
|
argument, you can use an <code>override</code> directive, which is a line that
|
|
looks like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">override <var>variable</var> = <var>value</var>
|
|
</pre></div>
|
|
|
|
<p>or
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">override <var>variable</var> := <var>value</var>
|
|
</pre></div>
|
|
|
|
<p>To append more text to a variable defined on the command line, use:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">override <var>variable</var> += <var>more text</var>
|
|
</pre></div>
|
|
|
|
<p>See <a href="#Appending">Appending More Text to Variables</a>.
|
|
</p>
|
|
<p>Variable assignments marked with the <code>override</code> flag have a
|
|
higher priority than all other assignments, except another
|
|
<code>override</code>. Subsequent assignments or appends to this variable
|
|
which are not marked <code>override</code> will be ignored.
|
|
</p>
|
|
<p>The <code>override</code> directive was not invented for escalation in the war
|
|
between makefiles and command arguments. It was invented so you can alter
|
|
and add to values that the user specifies with command arguments.
|
|
</p>
|
|
<p>For example, suppose you always want the ‘<samp>-g</samp>’ switch when you run the
|
|
C compiler, but you would like to allow the user to specify the other
|
|
switches with a command argument just as usual. You could use this
|
|
<code>override</code> directive:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">override CFLAGS += -g
|
|
</pre></div>
|
|
|
|
<p>You can also use <code>override</code> directives with <code>define</code> directives.
|
|
This is done as you might expect:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">override define foo =
|
|
bar
|
|
endef
|
|
</pre></div>
|
|
|
|
<p>See <a href="#Multi_002dLine">Defining Multi-Line Variables</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Multi_002dLine"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Undefine-Directive" accesskey="n" rel="next">Undefine Directive</a>, Previous: <a href="#Override-Directive" accesskey="p" rel="prev">Override Directive</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Defining-Multi_002dLine-Variables"></span><h3 class="section">6.8 Defining Multi-Line Variables</h3>
|
|
<span id="index-define"></span>
|
|
<span id="index-endef"></span>
|
|
<span id="index-multi_002dline-variable-definition"></span>
|
|
<span id="index-variables_002c-multi_002dline"></span>
|
|
<span id="index-verbatim-variable-definition"></span>
|
|
<span id="index-defining-variables-verbatim"></span>
|
|
<span id="index-variables_002c-defining-verbatim"></span>
|
|
|
|
<p>Another way to set the value of a variable is to use the <code>define</code>
|
|
directive. This directive has an unusual syntax which allows newline
|
|
characters to be included in the value, which is convenient for
|
|
defining both canned sequences of commands (see <a href="#Canned-Recipes">Defining Canned Recipes</a>), and also sections of makefile syntax to
|
|
use with <code>eval</code> (see <a href="#Eval-Function">Eval Function</a>).
|
|
</p>
|
|
<p>The <code>define</code> directive is followed on the same line by the name
|
|
of the variable being defined and an (optional) assignment operator,
|
|
and nothing more. The value to give the variable appears on the
|
|
following lines. The end of the value is marked by a line containing
|
|
just the word <code>endef</code>.
|
|
</p>
|
|
<p>Aside from this difference in syntax, <code>define</code> works just like
|
|
any other variable definition. The variable name may contain function
|
|
and variable references, which are expanded when the directive is read
|
|
to find the actual variable name to use.
|
|
</p>
|
|
<p>The final newline before the <code>endef</code> is not included in the
|
|
value; if you want your value to contain a trailing newline you must
|
|
include a blank line. For example in order to define a variable that
|
|
contains a newline character you must use <em>two</em> empty lines, not one:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">define newline
|
|
|
|
|
|
endef
|
|
</pre></div>
|
|
|
|
<p>You may omit the variable assignment operator if you prefer. If
|
|
omitted, <code>make</code> assumes it to be ‘<samp>=</samp>’ and creates a
|
|
recursively-expanded variable (see <a href="#Flavors">The Two Flavors of Variables</a>).
|
|
When using a ‘<samp>+=</samp>’ operator, the value is appended to the previous
|
|
value as with any other append operation: with a single space
|
|
separating the old and new values.
|
|
</p>
|
|
<p>You may nest <code>define</code> directives: <code>make</code> will keep track of
|
|
nested directives and report an error if they are not all properly
|
|
closed with <code>endef</code>. Note that lines beginning with the recipe
|
|
prefix character are considered part of a recipe, so any <code>define</code>
|
|
or <code>endef</code> strings appearing on such a line will not be
|
|
considered <code>make</code> directives.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">define two-lines
|
|
echo foo
|
|
echo $(bar)
|
|
endef
|
|
</pre></div>
|
|
|
|
<p>When used in a recipe, the previous example is functionally equivalent
|
|
to this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">two-lines = echo foo; echo $(bar)
|
|
</pre></div>
|
|
|
|
<p>since two commands separated by semicolon behave much like two separate
|
|
shell commands. However, note that using two separate lines means
|
|
<code>make</code> will invoke the shell twice, running an independent sub-shell
|
|
for each line. See <a href="#Execution">Recipe Execution</a>.
|
|
</p>
|
|
<p>If you want variable definitions made with <code>define</code> to take
|
|
precedence over command-line variable definitions, you can use the
|
|
<code>override</code> directive together with <code>define</code>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">override define two-lines =
|
|
foo
|
|
$(bar)
|
|
endef
|
|
</pre></div>
|
|
|
|
<p>See <a href="#Override-Directive">The <code>override</code> Directive</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Undefine-Directive"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Environment" accesskey="n" rel="next">Environment</a>, Previous: <a href="#Multi_002dLine" accesskey="p" rel="prev">Multi-Line</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Undefining-Variables"></span><h3 class="section">6.9 Undefining Variables</h3>
|
|
<span id="index-undefine"></span>
|
|
<span id="index-undefining-variable"></span>
|
|
|
|
<p>If you want to clear a variable, setting its value to empty is usually
|
|
sufficient. Expanding such a variable will yield the same result (empty
|
|
string) regardless of whether it was set or not. However, if you are
|
|
using the <code>flavor</code> (see <a href="#Flavor-Function">Flavor Function</a>) and
|
|
<code>origin</code> (see <a href="#Origin-Function">Origin Function</a>) functions, there is a difference
|
|
between a variable that was never set and a variable with an empty value.
|
|
In such situations you may want to use the <code>undefine</code> directive to
|
|
make a variable appear as if it was never set. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo := foo
|
|
bar = bar
|
|
|
|
undefine foo
|
|
undefine bar
|
|
|
|
$(info $(origin foo))
|
|
$(info $(flavor bar))
|
|
</pre></div>
|
|
|
|
<p>This example will print “undefined” for both variables.
|
|
</p>
|
|
<p>If you want to undefine a command-line variable definition, you can use
|
|
the <code>override</code> directive together with <code>undefine</code>, similar to
|
|
how this is done for variable definitions:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">override undefine CFLAGS
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Environment"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Target_002dspecific" accesskey="n" rel="next">Target-specific</a>, Previous: <a href="#Undefine-Directive" accesskey="p" rel="prev">Undefine Directive</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Variables-from-the-Environment"></span><h3 class="section">6.10 Variables from the Environment</h3>
|
|
|
|
<span id="index-variables_002c-environment-1"></span>
|
|
<span id="index-environment"></span>
|
|
<p>Variables in <code>make</code> can come from the environment in which
|
|
<code>make</code> is run. Every environment variable that <code>make</code> sees
|
|
when it starts up is transformed into a <code>make</code> variable with the
|
|
same name and value. However, an explicit assignment in the makefile,
|
|
or with a command argument, overrides the environment. (If the
|
|
‘<samp>-e</samp>’ flag is specified, then values from the environment override
|
|
assignments in the makefile. See <a href="#Options-Summary">Summary of
|
|
Options</a>. But this is not recommended practice.)
|
|
</p>
|
|
<p>Thus, by setting the variable <code>CFLAGS</code> in your environment, you can
|
|
cause all C compilations in most makefiles to use the compiler switches you
|
|
prefer. This is safe for variables with standard or conventional meanings
|
|
because you know that no makefile will use them for other things. (Note
|
|
this is not totally reliable; some makefiles set <code>CFLAGS</code> explicitly
|
|
and therefore are not affected by the value in the environment.)
|
|
</p>
|
|
<p>When <code>make</code> runs a recipe, some variables defined in the makefile
|
|
are placed into the environment of each command <code>make</code> invokes.
|
|
By default, only variables that came from the <code>make</code>’s
|
|
environment or set on its command line are placed into the environment
|
|
of the commands. You can use the <code>export</code> directive to pass
|
|
other variables. See <a href="#Variables_002fRecursion">Communicating Variables
|
|
to a Sub-<code>make</code></a>, for full details.
|
|
</p>
|
|
<p>Other use of variables from the environment is not recommended. It is not
|
|
wise for makefiles to depend for their functioning on environment variables
|
|
set up outside their control, since this would cause different users to get
|
|
different results from the same makefile. This is against the whole
|
|
purpose of most makefiles.
|
|
</p>
|
|
<span id="index-SHELL_002c-import-from-environment"></span>
|
|
<p>Such problems would be especially likely with the variable
|
|
<code>SHELL</code>, which is normally present in the environment to specify
|
|
the user’s choice of interactive shell. It would be very undesirable
|
|
for this choice to affect <code>make</code>; so, <code>make</code> handles the
|
|
<code>SHELL</code> environment variable in a special way; see <a href="#Choosing-the-Shell">Choosing the Shell</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Target_002dspecific"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Pattern_002dspecific" accesskey="n" rel="next">Pattern-specific</a>, Previous: <a href="#Environment" accesskey="p" rel="prev">Environment</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Target_002dspecific-Variable-Values"></span><h3 class="section">6.11 Target-specific Variable Values</h3>
|
|
<span id="index-target_002dspecific-variables"></span>
|
|
<span id="index-variables_002c-target_002dspecific"></span>
|
|
|
|
<p>Variable values in <code>make</code> are usually global; that is, they are the
|
|
same regardless of where they are evaluated (unless they’re reset, of
|
|
course). Exceptions to that are variables defined with the <code>let</code>
|
|
function (see <a href="#Let-Function">Let Function</a>) or the <code>foreach</code> function
|
|
(see <a href="#Foreach-Function">Foreach Function</a>, and automatic variables
|
|
(see <a href="#Automatic-Variables">Automatic Variables</a>).
|
|
</p>
|
|
<p>Another exception are <em>target-specific variable values</em>. This
|
|
feature allows you to define different values for the same variable,
|
|
based on the target that <code>make</code> is currently building. As with
|
|
automatic variables, these values are only available within the context
|
|
of a target’s recipe (and in other target-specific assignments).
|
|
</p>
|
|
<p>Set a target-specific variable value like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>target</var> … : <var>variable-assignment</var>
|
|
</pre></div>
|
|
|
|
<p>Target-specific variable assignments can be prefixed with any or all of the
|
|
special keywords <code>export</code>, <code>unexport</code>, <code>override</code>, or
|
|
<code>private</code>; these apply their normal behavior to this instance of the
|
|
variable only.
|
|
</p>
|
|
<p>Multiple <var>target</var> values create a target-specific variable value for
|
|
each member of the target list individually.
|
|
</p>
|
|
<p>The <var>variable-assignment</var> can be any valid form of assignment; recursive
|
|
(‘<samp>=</samp>’), simple (‘<samp>:=</samp>’ or ‘<samp>::=</samp>’), immediate (‘<samp>::=</samp>’),
|
|
appending (‘<samp>+=</samp>’), or conditional (‘<samp>?=</samp>’). All variables that appear
|
|
within the <var>variable-assignment</var> are evaluated within the context of the
|
|
target: thus, any previously-defined target-specific variable values will be
|
|
in effect. Note that this variable is actually distinct from any “global”
|
|
value: the two variables do not have to have the same flavor (recursive vs.
|
|
simple).
|
|
</p>
|
|
<p>Target-specific variables have the same priority as any other makefile
|
|
variable. Variables provided on the command line (and in the
|
|
environment if the ‘<samp>-e</samp>’ option is in force) will take precedence.
|
|
Specifying the <code>override</code> directive will allow the target-specific
|
|
variable value to be preferred.
|
|
</p>
|
|
<p>There is one more special feature of target-specific variables: when
|
|
you define a target-specific variable that variable value is also in
|
|
effect for all prerequisites of this target, and all their
|
|
prerequisites, etc. (unless those prerequisites override that variable
|
|
with their own target-specific variable value). So, for example, a
|
|
statement like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">prog : CFLAGS = -g
|
|
prog : prog.o foo.o bar.o
|
|
</pre></div>
|
|
|
|
<p>will set <code>CFLAGS</code> to ‘<samp>-g</samp>’ in the recipe for <samp>prog</samp>, but
|
|
it will also set <code>CFLAGS</code> to ‘<samp>-g</samp>’ in the recipes that create
|
|
<samp>prog.o</samp>, <samp>foo.o</samp>, and <samp>bar.o</samp>, and any recipes which
|
|
create their prerequisites.
|
|
</p>
|
|
<p>Be aware that a given prerequisite will only be built once per
|
|
invocation of make, at most. If the same file is a prerequisite of
|
|
multiple targets, and each of those targets has a different value for
|
|
the same target-specific variable, then the first target to be built
|
|
will cause that prerequisite to be built and the prerequisite will
|
|
inherit the target-specific value from the first target. It will
|
|
ignore the target-specific values from any other targets.
|
|
</p>
|
|
<hr>
|
|
<span id="Pattern_002dspecific"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Suppressing-Inheritance" accesskey="n" rel="next">Suppressing Inheritance</a>, Previous: <a href="#Target_002dspecific" accesskey="p" rel="prev">Target-specific</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Pattern_002dspecific-Variable-Values"></span><h3 class="section">6.12 Pattern-specific Variable Values</h3>
|
|
<span id="index-pattern_002dspecific-variables"></span>
|
|
<span id="index-variables_002c-pattern_002dspecific"></span>
|
|
|
|
<p>In addition to target-specific variable values
|
|
(see <a href="#Target_002dspecific">Target-specific Variable Values</a>), GNU
|
|
<code>make</code> supports pattern-specific variable values. In this form,
|
|
the variable is defined for any target that matches the pattern
|
|
specified.
|
|
</p>
|
|
<p>Set a pattern-specific variable value like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>pattern</var> … : <var>variable-assignment</var>
|
|
</pre></div>
|
|
<p>where <var>pattern</var> is a %-pattern. As with target-specific variable
|
|
values, multiple <var>pattern</var> values create a pattern-specific variable
|
|
value for each pattern individually. The <var>variable-assignment</var> can
|
|
be any valid form of assignment. Any command line variable setting will
|
|
take precedence, unless <code>override</code> is specified.
|
|
</p>
|
|
<p>For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.o : CFLAGS = -O
|
|
</pre></div>
|
|
|
|
<p>will assign <code>CFLAGS</code> the value of ‘<samp>-O</samp>’ for all targets
|
|
matching the pattern <code>%.o</code>.
|
|
</p>
|
|
<p>If a target matches more than one pattern, the matching pattern-specific
|
|
variables with longer stems are interpreted first. This results in more
|
|
specific variables taking precedence over the more generic ones, for
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.o: %.c
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
|
|
lib/%.o: CFLAGS := -fPIC -g
|
|
%.o: CFLAGS := -g
|
|
|
|
all: foo.o lib/bar.o
|
|
</pre></div>
|
|
|
|
<p>In this example the first definition of the <code>CFLAGS</code> variable
|
|
will be used to update <samp>lib/bar.o</samp> even though the second one
|
|
also applies to this target. Pattern-specific variables which result
|
|
in the same stem length are considered in the order in which they
|
|
were defined in the makefile.
|
|
</p>
|
|
<p>Pattern-specific variables are searched after any target-specific
|
|
variables defined explicitly for that target, and before target-specific
|
|
variables defined for the parent target.
|
|
</p>
|
|
<hr>
|
|
<span id="Suppressing-Inheritance"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Special-Variables" accesskey="n" rel="next">Special Variables</a>, Previous: <a href="#Pattern_002dspecific" accesskey="p" rel="prev">Pattern-specific</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Suppressing-Inheritance-1"></span><h3 class="section">6.13 Suppressing Inheritance</h3>
|
|
<span id="index-private"></span>
|
|
<span id="index-suppressing-inheritance"></span>
|
|
<span id="index-inheritance_002c-suppressing"></span>
|
|
|
|
<p>As described in previous sections, <code>make</code> variables are inherited
|
|
by prerequisites. This capability allows you to modify the behavior
|
|
of a prerequisite based on which targets caused it to be rebuilt. For
|
|
example, you might set a target-specific variable on a <code>debug</code>
|
|
target, then running ‘<samp>make debug</samp>’ will cause that variable to be
|
|
inherited by all prerequisites of <code>debug</code>, while just running
|
|
‘<samp>make all</samp>’ (for example) would not have that assignment.
|
|
</p>
|
|
<p>Sometimes, however, you may not want a variable to be inherited. For
|
|
these situations, <code>make</code> provides the <code>private</code> modifier.
|
|
Although this modifier can be used with any variable assignment, it
|
|
makes the most sense with target- and pattern-specific variables. Any
|
|
variable marked <code>private</code> will be visible to its local target but
|
|
will not be inherited by prerequisites of that target. A global
|
|
variable marked <code>private</code> will be visible in the global scope but
|
|
will not be inherited by any target, and hence will not be visible
|
|
in any recipe.
|
|
</p>
|
|
<p>As an example, consider this makefile:
|
|
</p><div class="example">
|
|
<pre class="example">EXTRA_CFLAGS =
|
|
|
|
prog: private EXTRA_CFLAGS = -L/usr/local/lib
|
|
prog: a.o b.o
|
|
</pre></div>
|
|
|
|
<p>Due to the <code>private</code> modifier, <code>a.o</code> and <code>b.o</code> will not
|
|
inherit the <code>EXTRA_CFLAGS</code> variable assignment from the
|
|
<code>prog</code> target.
|
|
</p>
|
|
<hr>
|
|
<span id="Special-Variables"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Suppressing-Inheritance" accesskey="p" rel="prev">Suppressing Inheritance</a>, Up: <a href="#Using-Variables" accesskey="u" rel="up">Using Variables</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Other-Special-Variables"></span><h3 class="section">6.14 Other Special Variables</h3>
|
|
<span id="index-makefiles_002c-and-special-variables"></span>
|
|
<span id="index-special-variables"></span>
|
|
|
|
<p>GNU <code>make</code> supports some variables that have special properties.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dd>
|
|
<span id="index-MAKEFILE_005fLIST-_0028list-of-parsed-makefiles_0029"></span>
|
|
<span id="index-makefiles_002c-and-MAKEFILE_005fLIST-variable"></span>
|
|
<span id="index-including-_0028MAKEFILE_005fLIST-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>MAKEFILE_LIST</code></dt>
|
|
<dd><p>Contains the name of each makefile that is parsed by <code>make</code>, in
|
|
the order in which it was parsed. The name is appended just
|
|
before <code>make</code> begins to parse the makefile. Thus, if the first
|
|
thing a makefile does is examine the last word in this variable, it
|
|
will be the name of the current makefile. Once the current makefile
|
|
has used <code>include</code>, however, the last word will be the
|
|
just-included makefile.
|
|
</p>
|
|
<p>If a makefile named <code>Makefile</code> has this content:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">name1 := $(lastword $(MAKEFILE_LIST))
|
|
|
|
include inc.mk
|
|
|
|
name2 := $(lastword $(MAKEFILE_LIST))
|
|
|
|
all:
|
|
@echo name1 = $(name1)
|
|
@echo name2 = $(name2)
|
|
</pre></div>
|
|
|
|
<p>then you would expect to see this output:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">name1 = Makefile
|
|
name2 = inc.mk
|
|
</pre></div>
|
|
|
|
<span id="index-_002eDEFAULT_005fGOAL-_0028define-default-goal_0029"></span>
|
|
</dd>
|
|
<dt><code>.DEFAULT_GOAL</code></dt>
|
|
<dd><p>Sets the default goal to be used if no targets were specified on the
|
|
command line (see <a href="#Goals">Arguments to Specify the Goals</a>). The
|
|
<code>.DEFAULT_GOAL</code> variable allows you to discover the current
|
|
default goal, restart the default goal selection algorithm by clearing
|
|
its value, or to explicitly set the default goal. The following
|
|
example illustrates these cases:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"># Query the default goal.
|
|
ifeq ($(.DEFAULT_GOAL),)
|
|
$(warning no default goal is set)
|
|
endif
|
|
|
|
.PHONY: foo
|
|
foo: ; @echo $@
|
|
|
|
$(warning default goal is $(.DEFAULT_GOAL))
|
|
|
|
# Reset the default goal.
|
|
.DEFAULT_GOAL :=
|
|
|
|
.PHONY: bar
|
|
bar: ; @echo $@
|
|
|
|
$(warning default goal is $(.DEFAULT_GOAL))
|
|
|
|
# Set our own.
|
|
.DEFAULT_GOAL := foo
|
|
</pre></div>
|
|
|
|
<p>This makefile prints:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">no default goal is set
|
|
default goal is foo
|
|
default goal is bar
|
|
foo
|
|
</pre></div>
|
|
|
|
<p>Note that assigning more than one target name to <code>.DEFAULT_GOAL</code> is
|
|
invalid and will result in an error.
|
|
</p>
|
|
<span id="index-MAKE_005fRESTARTS-_0028number-of-times-make-has-restarted_0029"></span>
|
|
</dd>
|
|
<dt><code>MAKE_RESTARTS</code></dt>
|
|
<dd><p>This variable is set only if this instance of <code>make</code> has
|
|
restarted (see <a href="#Remaking-Makefiles">How Makefiles Are Remade</a>): it
|
|
will contain the number of times this instance has restarted. Note
|
|
this is not the same as recursion (counted by the <code>MAKELEVEL</code>
|
|
variable). You should not set, modify, or export this variable.
|
|
</p>
|
|
<span id="index-MAKE_005fTERMOUT-_0028whether-stdout-is-a-terminal_0029"></span>
|
|
<span id="index-MAKE_005fTERMERR-_0028whether-stderr-is-a-terminal_0029"></span>
|
|
</dd>
|
|
<dt><code>MAKE_TERMOUT</code></dt>
|
|
<dt><code>MAKE_TERMERR</code></dt>
|
|
<dd><p>When <code>make</code> starts it will check whether stdout and stderr will
|
|
show their output on a terminal. If so, it will set
|
|
<code>MAKE_TERMOUT</code> and <code>MAKE_TERMERR</code>, respectively, to the name
|
|
of the terminal device (or <code>true</code> if this cannot be determined).
|
|
If set these variables will be marked for export. These variables
|
|
will not be changed by <code>make</code> and they will not be modified if
|
|
already set.
|
|
</p>
|
|
<p>These values can be used (particularly in combination with output
|
|
synchronization (see <a href="#Parallel-Output">Output During Parallel
|
|
Execution</a>) to determine whether <code>make</code> itself is writing to a
|
|
terminal; they can be tested to decide whether to force recipe
|
|
commands to generate colorized output for example.
|
|
</p>
|
|
<p>If you invoke a sub-<code>make</code> and redirect its stdout or stderr it
|
|
is your responsibility to reset or unexport these variables as well,
|
|
if your makefiles rely on them.
|
|
</p>
|
|
<span id="index-_002eRECIPEPREFIX-_0028change-the-recipe-prefix-character_0029"></span>
|
|
</dd>
|
|
<dt><code>.RECIPEPREFIX</code></dt>
|
|
<dd><p>The first character of the value of this variable is used as the
|
|
character make assumes is introducing a recipe line. If the variable
|
|
is empty (as it is by default) that character is the standard tab
|
|
character. For example, this is a valid makefile:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.RECIPEPREFIX = >
|
|
all:
|
|
> @echo Hello, world
|
|
</pre></div>
|
|
|
|
<p>The value of <code>.RECIPEPREFIX</code> can be changed multiple times; once set
|
|
it stays in effect for all rules parsed until it is modified.
|
|
</p>
|
|
<span id="index-_002eVARIABLES-_0028list-of-variables_0029"></span>
|
|
</dd>
|
|
<dt><code>.VARIABLES</code></dt>
|
|
<dd><p>Expands to a list of the <em>names</em> of all global variables defined
|
|
so far. This includes variables which have empty values, as well as
|
|
built-in variables (see <a href="#Implicit-Variables">Variables Used by
|
|
Implicit Rules</a>), but does not include any variables which are only
|
|
defined in a target-specific context. Note that any value you assign
|
|
to this variable will be ignored; it will always return its special
|
|
value.
|
|
</p>
|
|
|
|
<span id="index-_002eFEATURES-_0028list-of-supported-features_0029"></span>
|
|
</dd>
|
|
<dt><code>.FEATURES</code></dt>
|
|
<dd><p>Expands to a list of special features supported by this version of
|
|
<code>make</code>. Possible values include, but are not limited to:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>archives</samp>’</dt>
|
|
<dd><p>Supports <code>ar</code> (archive) files using special file name syntax.
|
|
See <a href="#Archives">Using <code>make</code> to Update Archive Files</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>check-symlink</samp>’</dt>
|
|
<dd><p>Supports the <code>-L</code> (<code>--check-symlink-times</code>) flag.
|
|
See <a href="#Options-Summary">Summary of Options</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>else-if</samp>’</dt>
|
|
<dd><p>Supports “else if” non-nested conditionals. See <a href="#Conditional-Syntax">Syntax of Conditionals</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>extra-prereqs</samp>’</dt>
|
|
<dd><p>Supports the <code>.EXTRA_PREREQS</code> special target.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>grouped-target</samp>’</dt>
|
|
<dd><p>Supports grouped target syntax for explicit rules. See <a href="#Multiple-Targets">Multiple Targets in a Rule</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>guile</samp>’</dt>
|
|
<dd><p>Has GNU Guile available as an embedded extension language.
|
|
See <a href="#Guile-Integration">GNU Guile Integration</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>jobserver</samp>’</dt>
|
|
<dd><p>Supports “job server” enhanced parallel builds. See <a href="#Parallel">Parallel Execution</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>jobserver-fifo</samp>’</dt>
|
|
<dd><p>Supports “job server” enhanced parallel builds using named pipes.
|
|
See <a href="#Integrating-make">Integrating GNU <code>make</code></a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>load</samp>’</dt>
|
|
<dd><p>Supports dynamically loadable objects for creating custom extensions.
|
|
See <a href="#Loading-Objects">Loading Dynamic Objects</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>notintermediate</samp>’</dt>
|
|
<dd><p>Supports the <code>.NOTINTERMEDIATE</code> special target.
|
|
See <a href="#Integrating-make">Integrating GNU <code>make</code></a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>oneshell</samp>’</dt>
|
|
<dd><p>Supports the <code>.ONESHELL</code> special target. See <a href="#One-Shell">Using
|
|
One Shell</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>order-only</samp>’</dt>
|
|
<dd><p>Supports order-only prerequisites. See <a href="#Prerequisite-Types">Types
|
|
of Prerequisites</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>output-sync</samp>’</dt>
|
|
<dd><p>Supports the <code>--output-sync</code> command line option. See <a href="#Options-Summary">Summary of Options</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>second-expansion</samp>’</dt>
|
|
<dd><p>Supports secondary expansion of prerequisite lists.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>shell-export</samp>’</dt>
|
|
<dd><p>Supports exporting <code>make</code> variables to <code>shell</code> functions.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>shortest-stem</samp>’</dt>
|
|
<dd><p>Uses the “shortest stem” method of choosing which pattern, of
|
|
multiple applicable options, will be used. See <a href="#Pattern-Match">How
|
|
Patterns Match</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>target-specific</samp>’</dt>
|
|
<dd><p>Supports target-specific and pattern-specific variable assignments.
|
|
See <a href="#Target_002dspecific">Target-specific Variable Values</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>undefine</samp>’</dt>
|
|
<dd><p>Supports the <code>undefine</code> directive. See <a href="#Undefine-Directive">Undefine Directive</a>.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<span id="index-_002eINCLUDE_005fDIRS-_0028list-of-include-directories_0029"></span>
|
|
</dd>
|
|
<dt><code>.INCLUDE_DIRS</code></dt>
|
|
<dd><p>Expands to a list of directories that <code>make</code> searches for
|
|
included makefiles (see <a href="#Include">Including Other Makefiles</a>).
|
|
Note that modifying this variable’s value does not change the list of
|
|
directories which are searched.
|
|
</p>
|
|
<span id="index-_002eEXTRA_005fPREREQS-_0028prerequisites-not-added-to-automatic-variables_0029"></span>
|
|
</dd>
|
|
<dt><code>.EXTRA_PREREQS</code></dt>
|
|
<dd><p>Each word in this variable is a new prerequisite which is added to
|
|
targets for which it is set. These prerequisites differ from normal
|
|
prerequisites in that they do not appear in any of the automatic
|
|
variables (see <a href="#Automatic-Variables">Automatic Variables</a>). This allows prerequisites to
|
|
be defined which do not impact the recipe.
|
|
</p>
|
|
<p>Consider a rule to link a program:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">myprog: myprog.o file1.o file2.o
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
|
|
</pre></div>
|
|
|
|
<p>Now suppose you want to enhance this makefile to ensure that updates
|
|
to the compiler cause the program to be re-linked. You can add the
|
|
compiler as a prerequisite, but you must ensure that it’s not passed
|
|
as an argument to link command. You’ll need something like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">myprog: myprog.o file1.o file2.o $(CC)
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
|
|
$(filter-out $(CC),$^) $(LDLIBS)
|
|
</pre></div>
|
|
|
|
<p>Then consider having multiple extra prerequisites: they would all have
|
|
to be filtered out. Using <code>.EXTRA_PREREQS</code> and target-specific
|
|
variables provides a simpler solution:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">myprog: myprog.o file1.o file2.o
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
|
|
myprog: .EXTRA_PREREQS = $(CC)
|
|
</pre></div>
|
|
|
|
<p>This feature can also be useful if you want to add prerequisites to a
|
|
makefile you cannot easily modify: you can create a new file such as
|
|
<samp>extra.mk</samp>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">myprog: .EXTRA_PREREQS = $(CC)
|
|
</pre></div>
|
|
|
|
<p>then invoke <code>make -f extra.mk -f Makefile</code>.
|
|
</p>
|
|
<p>Setting <code>.EXTRA_PREREQS</code> globally will cause those prerequisites
|
|
to be added to all targets (which did not themselves override it with
|
|
a target-specific value). Note <code>make</code> is smart enough not to add
|
|
a prerequisite listed in <code>.EXTRA_PREREQS</code> as a prerequisite to
|
|
itself.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Conditionals"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Functions" accesskey="n" rel="next">Functions</a>, Previous: <a href="#Using-Variables" accesskey="p" rel="prev">Using Variables</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Conditional-Parts-of-Makefiles"></span><h2 class="chapter">7 Conditional Parts of Makefiles</h2>
|
|
|
|
<span id="index-conditionals"></span>
|
|
<p>A <em>conditional</em> directive causes part of a makefile to be obeyed
|
|
or ignored depending on the values of variables. Conditionals can
|
|
compare the value of one variable to another, or the value of a
|
|
variable to a constant string. Conditionals control what <code>make</code>
|
|
actually “sees” in the makefile, so they <em>cannot</em> be used to
|
|
control recipes at the time of execution.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Conditional-Example" accesskey="1">Conditional Example</a></td><td> </td><td align="left" valign="top">Example of a conditional
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Conditional-Syntax" accesskey="2">Conditional Syntax</a></td><td> </td><td align="left" valign="top">The syntax of conditionals.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Testing-Flags" accesskey="3">Testing Flags</a></td><td> </td><td align="left" valign="top">Conditionals that test flags.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Conditional-Example"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Conditional-Syntax" accesskey="n" rel="next">Conditional Syntax</a>, Previous: <a href="#Conditionals" accesskey="p" rel="prev">Conditionals</a>, Up: <a href="#Conditionals" accesskey="u" rel="up">Conditionals</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Example-of-a-Conditional"></span><h3 class="section">7.1 Example of a Conditional</h3>
|
|
|
|
<p>The following example of a conditional tells <code>make</code> to use one
|
|
set of libraries if the <code>CC</code> variable is ‘<samp>gcc</samp>’, and a
|
|
different set of libraries otherwise. It works by controlling which
|
|
of two recipe lines will be used for the rule. The result is that
|
|
‘<samp>CC=gcc</samp>’ as an argument to <code>make</code> changes not only which
|
|
compiler is used but also which libraries are linked.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">libs_for_gcc = -lgnu
|
|
normal_libs =
|
|
|
|
foo: $(objects)
|
|
ifeq ($(CC),gcc)
|
|
$(CC) -o foo $(objects) $(libs_for_gcc)
|
|
else
|
|
$(CC) -o foo $(objects) $(normal_libs)
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>This conditional uses three directives: one <code>ifeq</code>, one <code>else</code>
|
|
and one <code>endif</code>.
|
|
</p>
|
|
<p>The <code>ifeq</code> directive begins the conditional, and specifies the
|
|
condition. It contains two arguments, separated by a comma and surrounded
|
|
by parentheses. Variable substitution is performed on both arguments and
|
|
then they are compared. The lines of the makefile following the
|
|
<code>ifeq</code> are obeyed if the two arguments match; otherwise they are
|
|
ignored.
|
|
</p>
|
|
<p>The <code>else</code> directive causes the following lines to be obeyed if the
|
|
previous conditional failed. In the example above, this means that the
|
|
second alternative linking command is used whenever the first alternative
|
|
is not used. It is optional to have an <code>else</code> in a conditional.
|
|
</p>
|
|
<p>The <code>endif</code> directive ends the conditional. Every conditional must
|
|
end with an <code>endif</code>. Unconditional makefile text follows.
|
|
</p>
|
|
<p>As this example illustrates, conditionals work at the textual level:
|
|
the lines of the conditional are treated as part of the makefile, or
|
|
ignored, according to the condition. This is why the larger syntactic
|
|
units of the makefile, such as rules, may cross the beginning or the
|
|
end of the conditional.
|
|
</p>
|
|
<p>When the variable <code>CC</code> has the value ‘<samp>gcc</samp>’, the above example has
|
|
this effect:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo: $(objects)
|
|
$(CC) -o foo $(objects) $(libs_for_gcc)
|
|
</pre></div>
|
|
|
|
<p>When the variable <code>CC</code> has any other value, the effect is this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo: $(objects)
|
|
$(CC) -o foo $(objects) $(normal_libs)
|
|
</pre></div>
|
|
|
|
<p>Equivalent results can be obtained in another way by conditionalizing a
|
|
variable assignment and then using the variable unconditionally:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">libs_for_gcc = -lgnu
|
|
normal_libs =
|
|
|
|
ifeq ($(CC),gcc)
|
|
libs=$(libs_for_gcc)
|
|
else
|
|
libs=$(normal_libs)
|
|
endif
|
|
|
|
foo: $(objects)
|
|
$(CC) -o foo $(objects) $(libs)
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Conditional-Syntax"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Testing-Flags" accesskey="n" rel="next">Testing Flags</a>, Previous: <a href="#Conditional-Example" accesskey="p" rel="prev">Conditional Example</a>, Up: <a href="#Conditionals" accesskey="u" rel="up">Conditionals</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Syntax-of-Conditionals"></span><h3 class="section">7.2 Syntax of Conditionals</h3>
|
|
<span id="index-ifdef"></span>
|
|
<span id="index-ifeq"></span>
|
|
<span id="index-ifndef"></span>
|
|
<span id="index-ifneq"></span>
|
|
<span id="index-else"></span>
|
|
<span id="index-endif"></span>
|
|
|
|
<p>The syntax of a simple conditional with no <code>else</code> is as follows:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>conditional-directive</var>
|
|
<var>text-if-true</var>
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>The <var>text-if-true</var> may be any lines of text, to be considered as part
|
|
of the makefile if the condition is true. If the condition is false, no
|
|
text is used instead.
|
|
</p>
|
|
<p>The syntax of a complex conditional is as follows:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>conditional-directive</var>
|
|
<var>text-if-true</var>
|
|
else
|
|
<var>text-if-false</var>
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>or:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>conditional-directive-one</var>
|
|
<var>text-if-one-is-true</var>
|
|
else <var>conditional-directive-two</var>
|
|
<var>text-if-two-is-true</var>
|
|
else
|
|
<var>text-if-one-and-two-are-false</var>
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>There can be as many “<code>else</code> <var>conditional-directive</var>”
|
|
clauses as necessary. Once a given condition is true,
|
|
<var>text-if-true</var> is used and no other clause is used; if no
|
|
condition is true then <var>text-if-false</var> is used. The
|
|
<var>text-if-true</var> and <var>text-if-false</var> can be any number of lines
|
|
of text.
|
|
</p>
|
|
<p>The syntax of the <var>conditional-directive</var> is the same whether the
|
|
conditional is simple or complex; after an <code>else</code> or not. There
|
|
are four different directives that test different conditions. Here is
|
|
a table of them:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>ifeq (<var>arg1</var>, <var>arg2</var>)</code></dt>
|
|
<dt><code>ifeq '<var>arg1</var>' '<var>arg2</var>'</code></dt>
|
|
<dt><code>ifeq "<var>arg1</var>" "<var>arg2</var>"</code></dt>
|
|
<dt><code>ifeq "<var>arg1</var>" '<var>arg2</var>'</code></dt>
|
|
<dt><code>ifeq '<var>arg1</var>' "<var>arg2</var>"</code></dt>
|
|
<dd><p>Expand all variable references in <var>arg1</var> and <var>arg2</var> and
|
|
compare them. If they are identical, the <var>text-if-true</var> is
|
|
effective; otherwise, the <var>text-if-false</var>, if any, is effective.
|
|
</p>
|
|
<p>Often you want to test if a variable has a non-empty value. When the
|
|
value results from complex expansions of variables and functions,
|
|
expansions you would consider empty may actually contain whitespace
|
|
characters and thus are not seen as empty. However, you can use the
|
|
<code>strip</code> function (see <a href="#Text-Functions">Text Functions</a>) to avoid interpreting
|
|
whitespace as a non-empty value. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ifeq ($(strip $(foo)),)
|
|
<var>text-if-empty</var>
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>will evaluate <var>text-if-empty</var> even if the expansion of
|
|
<code>$(foo)</code> contains whitespace characters.
|
|
</p>
|
|
</dd>
|
|
<dt><code>ifneq (<var>arg1</var>, <var>arg2</var>)</code></dt>
|
|
<dt><code>ifneq '<var>arg1</var>' '<var>arg2</var>'</code></dt>
|
|
<dt><code>ifneq "<var>arg1</var>" "<var>arg2</var>"</code></dt>
|
|
<dt><code>ifneq "<var>arg1</var>" '<var>arg2</var>'</code></dt>
|
|
<dt><code>ifneq '<var>arg1</var>' "<var>arg2</var>"</code></dt>
|
|
<dd><p>Expand all variable references in <var>arg1</var> and <var>arg2</var> and
|
|
compare them. If they are different, the <var>text-if-true</var> is
|
|
effective; otherwise, the <var>text-if-false</var>, if any, is effective.
|
|
</p>
|
|
</dd>
|
|
<dt><code>ifdef <var>variable-name</var></code></dt>
|
|
<dd><p>The <code>ifdef</code> form takes the <em>name</em> of a variable as its
|
|
argument, not a reference to a variable. If the value of that
|
|
variable has a non-empty value, the <var>text-if-true</var> is effective;
|
|
otherwise, the <var>text-if-false</var>, if any, is effective. Variables
|
|
that have never been defined have an empty value. The text
|
|
<var>variable-name</var> is expanded, so it could be a variable or function
|
|
that expands to the name of a variable. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">bar = true
|
|
foo = bar
|
|
ifdef $(foo)
|
|
frobozz = yes
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>The variable reference <code>$(foo)</code> is expanded, yielding <code>bar</code>,
|
|
which is considered to be the name of a variable. The variable
|
|
<code>bar</code> is not expanded, but its value is examined to determine if
|
|
it is non-empty.
|
|
</p>
|
|
<p>Note that <code>ifdef</code> only tests whether a variable has a value. It
|
|
does not expand the variable to see if that value is nonempty.
|
|
Consequently, tests using <code>ifdef</code> return true for all definitions
|
|
except those like <code>foo =</code>. To test for an empty value, use
|
|
<code>ifeq ($(foo),)</code><!-- /@w -->. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">bar =
|
|
foo = $(bar)
|
|
ifdef foo
|
|
frobozz = yes
|
|
else
|
|
frobozz = no
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>sets ‘<samp>frobozz</samp>’ to ‘<samp>yes</samp>’, while:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo =
|
|
ifdef foo
|
|
frobozz = yes
|
|
else
|
|
frobozz = no
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>sets ‘<samp>frobozz</samp>’ to ‘<samp>no</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>ifndef <var>variable-name</var></code></dt>
|
|
<dd><p>If the variable <var>variable-name</var> has an empty value, the
|
|
<var>text-if-true</var> is effective; otherwise, the <var>text-if-false</var>,
|
|
if any, is effective. The rules for expansion and testing of
|
|
<var>variable-name</var> are identical to the <code>ifdef</code> directive.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Extra spaces are allowed and ignored at the beginning of the
|
|
conditional directive line, but a tab is not allowed. (If the line
|
|
begins with a tab, it will be considered part of a recipe for a rule.)
|
|
Aside from this, extra spaces or tabs may be inserted with no effect
|
|
anywhere except within the directive name or within an argument. A
|
|
comment starting with ‘<samp>#</samp>’ may appear at the end of the line.
|
|
</p>
|
|
<p>The other two directives that play a part in a conditional are <code>else</code>
|
|
and <code>endif</code>. Each of these directives is written as one word, with no
|
|
arguments. Extra spaces are allowed and ignored at the beginning of the
|
|
line, and spaces or tabs at the end. A comment starting with ‘<samp>#</samp>’ may
|
|
appear at the end of the line.
|
|
</p>
|
|
<p>Conditionals affect which lines of the makefile <code>make</code> uses. If
|
|
the condition is true, <code>make</code> reads the lines of the
|
|
<var>text-if-true</var> as part of the makefile; if the condition is false,
|
|
<code>make</code> ignores those lines completely. It follows that syntactic
|
|
units of the makefile, such as rules, may safely be split across the
|
|
beginning or the end of the conditional.
|
|
</p>
|
|
<p><code>make</code> evaluates conditionals when it reads a makefile.
|
|
Consequently, you cannot use automatic variables in the tests of
|
|
conditionals because they are not defined until recipes are run
|
|
(see <a href="#Automatic-Variables">Automatic Variables</a>).
|
|
</p>
|
|
<p>To prevent intolerable confusion, it is not permitted to start a
|
|
conditional in one makefile and end it in another. However, you may
|
|
write an <code>include</code> directive within a conditional, provided you do
|
|
not attempt to terminate the conditional inside the included file.
|
|
</p>
|
|
<hr>
|
|
<span id="Testing-Flags"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Conditional-Syntax" accesskey="p" rel="prev">Conditional Syntax</a>, Up: <a href="#Conditionals" accesskey="u" rel="up">Conditionals</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Conditionals-that-Test-Flags"></span><h3 class="section">7.3 Conditionals that Test Flags</h3>
|
|
|
|
<p>You can write a conditional that tests <code>make</code> command flags such as
|
|
‘<samp>-t</samp>’ by using the variable <code>MAKEFLAGS</code> together with the
|
|
<code>findstring</code> function
|
|
(see <a href="#Text-Functions">Functions for String Substitution and Analysis</a>).
|
|
This is useful when <code>touch</code> is not enough to make a file appear up
|
|
to date.
|
|
</p>
|
|
<p>Recall that <code>MAKEFLAGS</code> will put all single-letter options (such as
|
|
‘<samp>-t</samp>’) into the first word, and that word will be empty if no
|
|
single-letter options were given. To work with this, it’s helpful to add a
|
|
value at the start to ensure there’s a word: for example
|
|
‘<samp>-$(MAKEFLAGS)</samp>’.
|
|
</p>
|
|
<p>The <code>findstring</code> function determines whether one string appears as a
|
|
substring of another. If you want to test for the ‘<samp>-t</samp>’ flag, use
|
|
‘<samp>t</samp>’ as the first string and the first word of <code>MAKEFLAGS</code> as the
|
|
other.
|
|
</p>
|
|
<p>For example, here is how to arrange to use ‘<samp>ranlib -t</samp>’ to finish
|
|
marking an archive file up to date:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">archive.a: …
|
|
ifneq (,$(findstring t,$(word 1,-$(MAKEFLAGS))))
|
|
+touch archive.a
|
|
+ranlib -t archive.a
|
|
else
|
|
ranlib archive.a
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>The ‘<samp>+</samp>’ prefix marks those recipe lines as “recursive” so that
|
|
they will be executed despite use of the ‘<samp>-t</samp>’ flag.
|
|
See <a href="#Recursion">Recursive Use of <code>make</code></a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Functions"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Running" accesskey="n" rel="next">Running</a>, Previous: <a href="#Conditionals" accesskey="p" rel="prev">Conditionals</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Functions-for-Transforming-Text"></span><h2 class="chapter">8 Functions for Transforming Text</h2>
|
|
<span id="index-functions"></span>
|
|
|
|
<p><em>Functions</em> allow you to do text processing in the makefile to
|
|
compute the files to operate on or the commands to use in recipes.
|
|
You use a function in a <em>function call</em>, where you give the name
|
|
of the function and some text (the <em>arguments</em>) for the function
|
|
to operate on. The result of the function’s processing is substituted
|
|
into the makefile at the point of the call, just as a variable might
|
|
be substituted.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Syntax-of-Functions" accesskey="1">Syntax of Functions</a></td><td> </td><td align="left" valign="top">How to write a function call.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Text-Functions" accesskey="2">Text Functions</a></td><td> </td><td align="left" valign="top">General-purpose text manipulation functions.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#File-Name-Functions" accesskey="3">File Name Functions</a></td><td> </td><td align="left" valign="top">Functions for manipulating file names.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Conditional-Functions" accesskey="4">Conditional Functions</a></td><td> </td><td align="left" valign="top">Functions that implement conditions.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Let-Function" accesskey="5">Let Function</a></td><td> </td><td align="left" valign="top">Local variables.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Foreach-Function" accesskey="6">Foreach Function</a></td><td> </td><td align="left" valign="top">Repeat some text with controlled variation.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#File-Function" accesskey="7">File Function</a></td><td> </td><td align="left" valign="top">Write text to a file.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Call-Function" accesskey="8">Call Function</a></td><td> </td><td align="left" valign="top">Expand a user-defined function.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Value-Function" accesskey="9">Value Function</a></td><td> </td><td align="left" valign="top">Return the un-expanded value of a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Eval-Function">Eval Function</a></td><td> </td><td align="left" valign="top">Evaluate the arguments as makefile syntax.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Origin-Function">Origin Function</a></td><td> </td><td align="left" valign="top">Find where a variable got its value.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Flavor-Function">Flavor Function</a></td><td> </td><td align="left" valign="top">Find out the flavor of a variable.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Make-Control-Functions">Make Control Functions</a></td><td> </td><td align="left" valign="top">Functions that control how make runs.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Shell-Function">Shell Function</a></td><td> </td><td align="left" valign="top">Substitute the output of a shell command.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Guile-Function">Guile Function</a></td><td> </td><td align="left" valign="top">Use GNU Guile embedded scripting language.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Syntax-of-Functions"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Text-Functions" accesskey="n" rel="next">Text Functions</a>, Previous: <a href="#Functions" accesskey="p" rel="prev">Functions</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Function-Call-Syntax"></span><h3 class="section">8.1 Function Call Syntax</h3>
|
|
<span id="index-_0024_002c-in-function-call"></span>
|
|
<span id="index-dollar-sign-_0028_0024_0029_002c-in-function-call"></span>
|
|
<span id="index-arguments-of-functions"></span>
|
|
<span id="index-functions_002c-syntax-of"></span>
|
|
|
|
<p>A function call resembles a variable reference. It can appear
|
|
anywhere a variable reference can appear, and it is expanded using the
|
|
same rules as variable references. A function call looks like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(<var>function</var> <var>arguments</var>)
|
|
</pre></div>
|
|
|
|
<p>or like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">${<var>function</var> <var>arguments</var>}
|
|
</pre></div>
|
|
|
|
<p>Here <var>function</var> is a function name; one of a short list of names
|
|
that are part of <code>make</code>. You can also essentially create your own
|
|
functions by using the <code>call</code> built-in function.
|
|
</p>
|
|
<p>The <var>arguments</var> are the arguments of the function. They are separated
|
|
from the function name by one or more spaces or tabs, and if there is more
|
|
than one argument, then they are separated by commas. Such whitespace and
|
|
commas are not part of an argument’s value. The delimiters which you use to
|
|
surround the function call, whether parentheses or braces, can appear in an
|
|
argument only in matching pairs; the other kind of delimiters may appear
|
|
singly. If the arguments themselves contain other function calls or variable
|
|
references, it is wisest to use the same kind of delimiters for all the
|
|
references; write ‘<samp>$(subst a,b,$(x))</samp>’<!-- /@w -->, not ‘<samp>$(subst a,b,${x})</samp>’<!-- /@w -->. This is because it is clearer, and because only one type of
|
|
delimiter is matched to find the end of the reference.
|
|
</p>
|
|
<p>Each argument is expanded before the function is invoked, unless otherwise
|
|
noted below. The substitution is done in the order in which the arguments
|
|
appear.
|
|
</p>
|
|
<span id="Special-Characters"></span><h4 class="subsubheading">Special Characters</h4>
|
|
<span id="index-special-characters-in-function-arguments"></span>
|
|
<span id="index-function-arguments_002c-special-characters-in"></span>
|
|
|
|
<p>When using characters that are special to <code>make</code> as function arguments,
|
|
you may need to hide them. GNU <code>make</code> doesn’t support escaping
|
|
characters with backslashes or other escape sequences; however, because
|
|
arguments are split before they are expanded you can hide them by putting them
|
|
into variables.
|
|
</p>
|
|
<p>Characters you may need to hide include:
|
|
</p>
|
|
<ul>
|
|
<li> Commas
|
|
</li><li> Initial whitespace in the first argument
|
|
</li><li> Unmatched open parenthesis or brace
|
|
</li><li> An open parenthesis or brace if you don’t want it to start a matched pair
|
|
</li></ul>
|
|
|
|
<p>For example, you can define variables <code>comma</code> and <code>space</code> whose
|
|
values are isolated comma and space characters, then substitute these
|
|
variables where such characters are wanted, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">comma:= ,
|
|
empty:=
|
|
space:= $(empty) $(empty)
|
|
foo:= a b c
|
|
bar:= $(subst $(space),$(comma),$(foo))
|
|
# <span class="roman">bar is now ‘a,b,c’.</span>
|
|
</pre></div>
|
|
|
|
<p>Here the <code>subst</code> function replaces each space with a comma, through
|
|
the value of <code>foo</code>, and substitutes the result.
|
|
</p>
|
|
<hr>
|
|
<span id="Text-Functions"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#File-Name-Functions" accesskey="n" rel="next">File Name Functions</a>, Previous: <a href="#Syntax-of-Functions" accesskey="p" rel="prev">Syntax of Functions</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Functions-for-String-Substitution-and-Analysis"></span><h3 class="section">8.2 Functions for String Substitution and Analysis</h3>
|
|
<span id="index-functions_002c-for-text"></span>
|
|
|
|
<p>Here are some functions that operate on strings:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>$(subst <var>from</var>,<var>to</var>,<var>text</var>)</code></dt>
|
|
<dd><span id="index-subst-1"></span>
|
|
<p>Performs a textual replacement on the text <var>text</var>: each occurrence
|
|
of <var>from</var> is replaced by <var>to</var>. The result is substituted for
|
|
the function call. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(subst ee,EE,feet on the street)
|
|
</pre></div>
|
|
|
|
<p>produces the value ‘<samp>fEEt on the strEEt</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(patsubst <var>pattern</var>,<var>replacement</var>,<var>text</var>)</code></dt>
|
|
<dd><span id="index-patsubst-1"></span>
|
|
<p>Finds whitespace-separated words in <var>text</var> that match
|
|
<var>pattern</var> and replaces them with <var>replacement</var>. Here
|
|
<var>pattern</var> may contain a ‘<samp>%</samp>’ which acts as a wildcard,
|
|
matching any number of any characters within a word. If
|
|
<var>replacement</var> also contains a ‘<samp>%</samp>’, the ‘<samp>%</samp>’ is replaced
|
|
by the text that matched the ‘<samp>%</samp>’ in <var>pattern</var>. Words that do
|
|
not match the pattern are kept without change in the output. Only the
|
|
first ‘<samp>%</samp>’ in the <var>pattern</var> and <var>replacement</var> is treated
|
|
this way; any subsequent ‘<samp>%</samp>’ is unchanged.
|
|
</p>
|
|
<span id="index-_0025_002c-quoting-in-patsubst"></span>
|
|
<span id="index-_0025_002c-quoting-with-_005c-_0028backslash_0029-2"></span>
|
|
<span id="index-_005c-_0028backslash_0029_002c-to-quote-_0025-2"></span>
|
|
<span id="index-backslash-_0028_005c_0029_002c-to-quote-_0025-2"></span>
|
|
<span id="index-quoting-_0025_002c-in-patsubst"></span>
|
|
<p>‘<samp>%</samp>’ characters in <code>patsubst</code> function invocations can be
|
|
quoted with preceding backslashes (‘<samp>\</samp>’). Backslashes that would
|
|
otherwise quote ‘<samp>%</samp>’ characters can be quoted with more backslashes.
|
|
Backslashes that quote ‘<samp>%</samp>’ characters or other backslashes are
|
|
removed from the pattern before it is compared file names or has a stem
|
|
substituted into it. Backslashes that are not in danger of quoting
|
|
‘<samp>%</samp>’ characters go unmolested. For example, the pattern
|
|
<samp>the\%weird\\%pattern\\</samp> has ‘<samp>the%weird\</samp>’ preceding the
|
|
operative ‘<samp>%</samp>’ character, and ‘<samp>pattern\\</samp>’ following it. The
|
|
final two backslashes are left alone because they cannot affect any
|
|
‘<samp>%</samp>’ character.
|
|
</p>
|
|
<p>Whitespace between words is folded into single space characters;
|
|
leading and trailing whitespace is discarded.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(patsubst %.c,%.o,x.c.c bar.c)
|
|
</pre></div>
|
|
|
|
<p>produces the value ‘<samp>x.c.o bar.o</samp>’.
|
|
</p>
|
|
<p>Substitution references (see <a href="#Substitution-Refs">Substitution
|
|
References</a>) are a simpler way to get the effect of the <code>patsubst</code>
|
|
function:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(<var>var</var>:<var>pattern</var>=<var>replacement</var>)
|
|
</pre></div>
|
|
|
|
<p>is equivalent to
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(patsubst <var>pattern</var>,<var>replacement</var>,$(<var>var</var>))
|
|
</pre></div>
|
|
|
|
<p>The second shorthand simplifies one of the most common uses of
|
|
<code>patsubst</code>: replacing the suffix at the end of file names.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(<var>var</var>:<var>suffix</var>=<var>replacement</var>)
|
|
</pre></div>
|
|
|
|
<p>is equivalent to
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(patsubst %<var>suffix</var>,%<var>replacement</var>,$(<var>var</var>))
|
|
</pre></div>
|
|
|
|
<p>For example, you might have a list of object files:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects = foo.o bar.o baz.o
|
|
</pre></div>
|
|
|
|
<p>To get the list of corresponding source files, you could simply write:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(objects:.o=.c)
|
|
</pre></div>
|
|
|
|
<p>instead of using the general form:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(patsubst %.o,%.c,$(objects))
|
|
</pre></div>
|
|
|
|
</dd>
|
|
<dt><code>$(strip <var>string</var>)</code></dt>
|
|
<dd><span id="index-stripping-whitespace"></span>
|
|
<span id="index-whitespace_002c-stripping"></span>
|
|
<span id="index-spaces_002c-stripping"></span>
|
|
<span id="index-strip"></span>
|
|
<p>Removes leading and trailing whitespace from <var>string</var> and replaces
|
|
each internal sequence of one or more whitespace characters with a
|
|
single space. Thus, ‘<samp>$(strip a b c )</samp>’ results in ‘<samp>a b c</samp>’<!-- /@w -->.
|
|
</p>
|
|
<p>The function <code>strip</code> can be very useful when used in conjunction
|
|
with conditionals. When comparing something with the empty string
|
|
‘<samp></samp>’ using <code>ifeq</code> or <code>ifneq</code>, you usually want a string of
|
|
just whitespace to match the empty string (see <a href="#Conditionals">Conditionals</a>).
|
|
</p>
|
|
<p>Thus, the following may fail to have the desired results:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.PHONY: all
|
|
ifneq "$(needs_made)" ""
|
|
all: $(needs_made)
|
|
else
|
|
all:;@echo 'Nothing to make!'
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>Replacing the variable reference ‘<samp><span class="nolinebreak">$(needs_made)</span></samp>’<!-- /@w --> with the
|
|
function call ‘<samp>$(strip <span class="nolinebreak">$(needs_made))</span></samp>’<!-- /@w --> in the <code>ifneq</code>
|
|
directive would make it more robust.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(findstring <var>find</var>,<var>in</var>)</code></dt>
|
|
<dd><span id="index-findstring"></span>
|
|
<span id="index-searching-for-strings"></span>
|
|
<span id="index-finding-strings"></span>
|
|
<span id="index-strings_002c-searching-for"></span>
|
|
<p>Searches <var>in</var> for an occurrence of <var>find</var>. If it occurs, the
|
|
value is <var>find</var>; otherwise, the value is empty. You can use this
|
|
function in a conditional to test for the presence of a specific
|
|
substring in a given string. Thus, the two examples,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(findstring a,a b c)
|
|
$(findstring a,b c)
|
|
</pre></div>
|
|
|
|
<p>produce the values ‘<samp>a</samp>’ and ‘<samp></samp>’ (the empty string),
|
|
respectively. See <a href="#Testing-Flags">Testing Flags</a>, for a practical application of
|
|
<code>findstring</code>.
|
|
</p>
|
|
<span id="index-filter"></span>
|
|
<span id="index-filtering-words"></span>
|
|
<span id="index-words_002c-filtering"></span>
|
|
</dd>
|
|
<dt><code>$(filter <var>pattern</var>…,<var>text</var>)</code></dt>
|
|
<dd><p>Returns all whitespace-separated words in <var>text</var> that <em>do</em> match
|
|
any of the <var>pattern</var> words, removing any words that <em>do not</em>
|
|
match. The patterns are written using ‘<samp>%</samp>’, just like the patterns
|
|
used in the <code>patsubst</code> function above.
|
|
</p>
|
|
<p>The <code>filter</code> function can be used to separate out different types
|
|
of strings (such as file names) in a variable. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">sources := foo.c bar.c baz.s ugh.h
|
|
foo: $(sources)
|
|
cc $(filter %.c %.s,$(sources)) -o foo
|
|
</pre></div>
|
|
|
|
<p>says that <samp>foo</samp> depends of <samp>foo.c</samp>, <samp>bar.c</samp>,
|
|
<samp>baz.s</samp> and <samp>ugh.h</samp> but only <samp>foo.c</samp>, <samp>bar.c</samp> and
|
|
<samp>baz.s</samp> should be specified in the command to the
|
|
compiler.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(filter-out <var>pattern</var>…,<var>text</var>)</code></dt>
|
|
<dd><span id="index-filter_002dout"></span>
|
|
<span id="index-filtering-out-words"></span>
|
|
<span id="index-words_002c-filtering-out"></span>
|
|
<p>Returns all whitespace-separated words in <var>text</var> that <em>do not</em>
|
|
match any of the <var>pattern</var> words, removing the words that <em>do</em>
|
|
match one or more. This is the exact opposite of the <code>filter</code>
|
|
function.
|
|
</p>
|
|
<p>For example, given:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">objects=main1.o foo.o main2.o bar.o
|
|
mains=main1.o main2.o
|
|
</pre></div>
|
|
|
|
<p>the following generates a list which contains all the object files not
|
|
in ‘<samp>mains</samp>’:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(filter-out $(mains),$(objects))
|
|
</pre></div>
|
|
|
|
<span id="index-sort"></span>
|
|
<span id="index-sorting-words"></span>
|
|
</dd>
|
|
<dt><code>$(sort <var>list</var>)</code></dt>
|
|
<dd><p>Sorts the words of <var>list</var> in lexical order, removing duplicate
|
|
words. The output is a list of words separated by single spaces.
|
|
Thus,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(sort foo bar lose)
|
|
</pre></div>
|
|
|
|
<p>returns the value ‘<samp>bar foo lose</samp>’.
|
|
</p>
|
|
<span id="index-removing-duplicate-words"></span>
|
|
<span id="index-duplicate-words_002c-removing"></span>
|
|
<span id="index-words_002c-removing-duplicates"></span>
|
|
<p>Incidentally, since <code>sort</code> removes duplicate words, you can use
|
|
it for this purpose even if you don’t care about the sort order.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(word <var>n</var>,<var>text</var>)</code></dt>
|
|
<dd><span id="index-word"></span>
|
|
<span id="index-word_002c-selecting-a"></span>
|
|
<span id="index-selecting-a-word"></span>
|
|
<p>Returns the <var>n</var>th word of <var>text</var>. The legitimate values of
|
|
<var>n</var> start from 1. If <var>n</var> is bigger than the number of words
|
|
in <var>text</var>, the value is empty. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(word 2, foo bar baz)
|
|
</pre></div>
|
|
|
|
<p>returns ‘<samp>bar</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(wordlist <var>s</var>,<var>e</var>,<var>text</var>)</code></dt>
|
|
<dd><span id="index-wordlist"></span>
|
|
<span id="index-words_002c-selecting-lists-of"></span>
|
|
<span id="index-selecting-word-lists"></span>
|
|
<p>Returns the list of words in <var>text</var> starting with word <var>s</var> and
|
|
ending with word <var>e</var> (inclusive). The legitimate values of <var>s</var>
|
|
start from 1; <var>e</var> may start from 0. If <var>s</var> is bigger than the
|
|
number of words in <var>text</var>, the value is empty. If <var>e</var> is
|
|
bigger than the number of words in <var>text</var>, words up to the end of
|
|
<var>text</var> are returned. If <var>s</var> is greater than <var>e</var>, nothing
|
|
is returned. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(wordlist 2, 3, foo bar baz)
|
|
</pre></div>
|
|
|
|
<p>returns ‘<samp>bar baz</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(words <var>text</var>)</code></dt>
|
|
<dd><span id="index-words"></span>
|
|
<span id="index-words_002c-finding-number"></span>
|
|
<p>Returns the number of words in <var>text</var>. Thus, the last word of <var>text</var>
|
|
is <code>$(word $(words <var>text</var>),<var>text</var>)</code><!-- /@w -->.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(firstword <var>names</var>…)</code></dt>
|
|
<dd><span id="index-firstword"></span>
|
|
<span id="index-words_002c-extracting-first"></span>
|
|
<p>The argument <var>names</var> is regarded as a series of names, separated
|
|
by whitespace. The value is the first name in the series. The rest
|
|
of the names are ignored.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(firstword foo bar)
|
|
</pre></div>
|
|
|
|
<p>produces the result ‘<samp>foo</samp>’. Although <code>$(firstword
|
|
<var>text</var>)</code> is the same as <code>$(word 1,<var>text</var>)</code>, the
|
|
<code>firstword</code> function is retained for its simplicity.
|
|
</p>
|
|
|
|
</dd>
|
|
<dt><code>$(lastword <var>names</var>…)</code></dt>
|
|
<dd><span id="index-lastword"></span>
|
|
<span id="index-words_002c-extracting-last"></span>
|
|
<p>The argument <var>names</var> is regarded as a series of names, separated
|
|
by whitespace. The value is the last name in the series.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(lastword foo bar)
|
|
</pre></div>
|
|
|
|
<p>produces the result ‘<samp>bar</samp>’. Although <code>$(lastword
|
|
<var>text</var>)</code> is the same as <code>$(word $(words <var>text</var>),<var>text</var>)</code>,
|
|
the <code>lastword</code> function was added for its simplicity and better
|
|
performance.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
|
|
<p>Here is a realistic example of the use of <code>subst</code> and
|
|
<code>patsubst</code>. Suppose that a makefile uses the <code>VPATH</code> variable
|
|
to specify a list of directories that <code>make</code> should search for
|
|
prerequisite files
|
|
(see <a href="#General-Search"><code>VPATH</code> Search Path for All Prerequisites</a>).
|
|
This example shows how to
|
|
tell the C compiler to search for header files in the same list of
|
|
directories.
|
|
</p>
|
|
<p>The value of <code>VPATH</code> is a list of directories separated by colons,
|
|
such as ‘<samp>src:../headers</samp>’. First, the <code>subst</code> function is used to
|
|
change the colons to spaces:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(subst :, ,$(VPATH))
|
|
</pre></div>
|
|
|
|
<p>This produces ‘<samp>src ../headers</samp>’. Then <code>patsubst</code> is used to turn
|
|
each directory name into a ‘<samp>-I</samp>’ flag. These can be added to the
|
|
value of the variable <code>CFLAGS</code>, which is passed automatically to the C
|
|
compiler, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH)))
|
|
</pre></div>
|
|
|
|
<p>The effect is to append the text ‘<samp>-Isrc -I../headers</samp>’ to the
|
|
previously given value of <code>CFLAGS</code>. The <code>override</code> directive is
|
|
used so that the new value is assigned even if the previous value of
|
|
<code>CFLAGS</code> was specified with a command argument (see <a href="#Override-Directive">The <code>override</code> Directive</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="File-Name-Functions"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Conditional-Functions" accesskey="n" rel="next">Conditional Functions</a>, Previous: <a href="#Text-Functions" accesskey="p" rel="prev">Text Functions</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Functions-for-File-Names"></span><h3 class="section">8.3 Functions for File Names</h3>
|
|
<span id="index-functions_002c-for-file-names"></span>
|
|
<span id="index-file-name-functions"></span>
|
|
|
|
<p>Several of the built-in expansion functions relate specifically to
|
|
taking apart file names or lists of file names.
|
|
</p>
|
|
<p>Each of the following functions performs a specific transformation on a
|
|
file name. The argument of the function is regarded as a series of file
|
|
names, separated by whitespace. (Leading and trailing whitespace is
|
|
ignored.) Each file name in the series is transformed in the same way and
|
|
the results are concatenated with single spaces between them.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>$(dir <var>names</var>…)</code></dt>
|
|
<dd><span id="index-dir"></span>
|
|
<span id="index-directory-part"></span>
|
|
<span id="index-file-name_002c-directory-part"></span>
|
|
<p>Extracts the directory-part of each file name in <var>names</var>. The
|
|
directory-part of the file name is everything up through (and
|
|
including) the last slash in it. If the file name contains no slash,
|
|
the directory part is the string ‘<samp>./</samp>’. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(dir src/foo.c hacks)
|
|
</pre></div>
|
|
|
|
<p>produces the result ‘<samp>src/ ./</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(notdir <var>names</var>…)</code></dt>
|
|
<dd><span id="index-notdir"></span>
|
|
<span id="index-file-name_002c-nondirectory-part"></span>
|
|
<span id="index-nondirectory-part"></span>
|
|
<p>Extracts all but the directory-part of each file name in <var>names</var>.
|
|
If the file name contains no slash, it is left unchanged. Otherwise,
|
|
everything through the last slash is removed from it.
|
|
</p>
|
|
<p>A file name that ends with a slash becomes an empty string. This is
|
|
unfortunate, because it means that the result does not always have the
|
|
same number of whitespace-separated file names as the argument had;
|
|
but we do not see any other valid alternative.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(notdir src/foo.c hacks)
|
|
</pre></div>
|
|
|
|
<p>produces the result ‘<samp>foo.c hacks</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(suffix <var>names</var>…)</code></dt>
|
|
<dd><span id="index-suffix"></span>
|
|
<span id="index-suffix_002c-function-to-find"></span>
|
|
<span id="index-file-name-suffix"></span>
|
|
<p>Extracts the suffix of each file name in <var>names</var>. If the file name
|
|
contains a period, the suffix is everything starting with the last
|
|
period. Otherwise, the suffix is the empty string. This frequently
|
|
means that the result will be empty when <var>names</var> is not, and if
|
|
<var>names</var> contains multiple file names, the result may contain fewer
|
|
file names.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(suffix src/foo.c src-1.0/bar.c hacks)
|
|
</pre></div>
|
|
|
|
<p>produces the result ‘<samp>.c .c</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(basename <var>names</var>…)</code></dt>
|
|
<dd><span id="index-basename-1"></span>
|
|
<span id="index-basename"></span>
|
|
<span id="index-file-name_002c-basename-of"></span>
|
|
<p>Extracts all but the suffix of each file name in <var>names</var>. If the
|
|
file name contains a period, the basename is everything starting up to
|
|
(and not including) the last period. Periods in the directory part are
|
|
ignored. If there is no period, the basename is the entire file name.
|
|
For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(basename src/foo.c src-1.0/bar hacks)
|
|
</pre></div>
|
|
|
|
<p>produces the result ‘<samp>src/foo src-1.0/bar hacks</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(addsuffix <var>suffix</var>,<var>names</var>…)</code></dt>
|
|
<dd><span id="index-addsuffix"></span>
|
|
<span id="index-suffix_002c-adding"></span>
|
|
<span id="index-file-name-suffix_002c-adding"></span>
|
|
<p>The argument <var>names</var> is regarded as a series of names, separated
|
|
by whitespace; <var>suffix</var> is used as a unit. The value of
|
|
<var>suffix</var> is appended to the end of each individual name and the
|
|
resulting larger names are concatenated with single spaces between
|
|
them. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(addsuffix .c,foo bar)
|
|
</pre></div>
|
|
|
|
<p>produces the result ‘<samp>foo.c bar.c</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(addprefix <var>prefix</var>,<var>names</var>…)</code></dt>
|
|
<dd><span id="index-addprefix"></span>
|
|
<span id="index-prefix_002c-adding"></span>
|
|
<span id="index-file-name-prefix_002c-adding"></span>
|
|
<p>The argument <var>names</var> is regarded as a series of names, separated
|
|
by whitespace; <var>prefix</var> is used as a unit. The value of
|
|
<var>prefix</var> is prepended to the front of each individual name and the
|
|
resulting larger names are concatenated with single spaces between
|
|
them. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(addprefix src/,foo bar)
|
|
</pre></div>
|
|
|
|
<p>produces the result ‘<samp>src/foo src/bar</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(join <var>list1</var>,<var>list2</var>)</code></dt>
|
|
<dd><span id="index-join"></span>
|
|
<span id="index-joining-lists-of-words"></span>
|
|
<span id="index-words_002c-joining-lists"></span>
|
|
<p>Concatenates the two arguments word by word: the two first words (one
|
|
from each argument) concatenated form the first word of the result, the
|
|
two second words form the second word of the result, and so on. So the
|
|
<var>n</var>th word of the result comes from the <var>n</var>th word of each
|
|
argument. If one argument has more words that the other, the extra
|
|
words are copied unchanged into the result.
|
|
</p>
|
|
<p>For example, ‘<samp>$(join a b,.c .o)</samp>’ produces ‘<samp>a.c b.o</samp>’.
|
|
</p>
|
|
<p>Whitespace between the words in the lists is not preserved; it is
|
|
replaced with a single space.
|
|
</p>
|
|
<p>This function can merge the results of the <code>dir</code> and
|
|
<code>notdir</code> functions, to produce the original list of files which
|
|
was given to those two functions.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(wildcard <var>pattern</var>)</code></dt>
|
|
<dd><span id="index-wildcard-2"></span>
|
|
<span id="index-wildcard_002c-function"></span>
|
|
<p>The argument <var>pattern</var> is a file name pattern, typically containing
|
|
wildcard characters (as in shell file name patterns). The result of
|
|
<code>wildcard</code> is a space-separated list of the names of existing files
|
|
that match the pattern.
|
|
See <a href="#Wildcards">Using Wildcard Characters in File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(realpath <var>names</var>…)</code></dt>
|
|
<dd><span id="index-realpath-1"></span>
|
|
<span id="index-realpath"></span>
|
|
<span id="index-file-name_002c-realpath-of"></span>
|
|
<p>For each file name in <var>names</var> return the canonical absolute name.
|
|
A canonical name does not contain any <code>.</code> or <code>..</code> components,
|
|
nor any repeated path separators (<code>/</code>) or symlinks. In case of a
|
|
failure the empty string is returned. Consult the <code>realpath(3)</code>
|
|
documentation for a list of possible failure causes.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(abspath <var>names</var>…)</code></dt>
|
|
<dd><span id="index-abspath-1"></span>
|
|
<span id="index-abspath"></span>
|
|
<span id="index-file-name_002c-abspath-of"></span>
|
|
<p>For each file name in <var>names</var> return an absolute name that does
|
|
not contain any <code>.</code> or <code>..</code> components, nor any repeated path
|
|
separators (<code>/</code>). Note that, in contrast to <code>realpath</code>
|
|
function, <code>abspath</code> does not resolve symlinks and does not require
|
|
the file names to refer to an existing file or directory. Use the
|
|
<code>wildcard</code> function to test for existence.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Conditional-Functions"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Let-Function" accesskey="n" rel="next">Let Function</a>, Previous: <a href="#File-Name-Functions" accesskey="p" rel="prev">File Name Functions</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Functions-for-Conditionals"></span><h3 class="section">8.4 Functions for Conditionals</h3>
|
|
<span id="index-if"></span>
|
|
<span id="index-conditional-expansion"></span>
|
|
<p>There are four functions that provide conditional expansion. A key
|
|
aspect of these functions is that not all of the arguments are
|
|
expanded initially. Only those arguments which need to be expanded,
|
|
will be expanded.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>$(if <var>condition</var>,<var>then-part</var>[,<var>else-part</var>])</code></dt>
|
|
<dd><span id="index-if-1"></span>
|
|
<p>The <code>if</code> function provides support for conditional expansion in a
|
|
functional context (as opposed to the GNU <code>make</code> makefile
|
|
conditionals such as <code>ifeq</code> (see <a href="#Conditional-Syntax">Syntax of
|
|
Conditionals</a>)).
|
|
</p>
|
|
<p>The first argument, <var>condition</var>, first has all preceding and
|
|
trailing whitespace stripped, then is expanded. If it expands to any
|
|
non-empty string, then the condition is considered to be true. If it
|
|
expands to an empty string, the condition is considered to be false.
|
|
</p>
|
|
<p>If the condition is true then the second argument, <var>then-part</var>, is
|
|
evaluated and this is used as the result of the evaluation of the entire
|
|
<code>if</code> function.
|
|
</p>
|
|
<p>If the condition is false then the third argument, <var>else-part</var>, is
|
|
evaluated and this is the result of the <code>if</code> function. If there is
|
|
no third argument, the <code>if</code> function evaluates to nothing (the
|
|
empty string).
|
|
</p>
|
|
<p>Note that only one of the <var>then-part</var> or the <var>else-part</var> will be
|
|
evaluated, never both. Thus, either can contain side-effects (such as
|
|
<code>shell</code> function calls, etc.)
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(or <var>condition1</var>[,<var>condition2</var>[,<var>condition3</var>…]])</code></dt>
|
|
<dd><span id="index-or"></span>
|
|
<p>The <code>or</code> function provides a “short-circuiting” OR operation.
|
|
Each argument is expanded, in order. If an argument expands to a
|
|
non-empty string the processing stops and the result of the expansion
|
|
is that string. If, after all arguments are expanded, all of them are
|
|
false (empty), then the result of the expansion is the empty string.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(and <var>condition1</var>[,<var>condition2</var>[,<var>condition3</var>…]])</code></dt>
|
|
<dd><span id="index-and"></span>
|
|
<p>The <code>and</code> function provides a “short-circuiting” AND operation.
|
|
Each argument is expanded, in order. If an argument expands to an
|
|
empty string the processing stops and the result of the expansion is
|
|
the empty string. If all arguments expand to a non-empty string then
|
|
the result of the expansion is the expansion of the last argument.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(intcmp <var>lhs</var>,<var>rhs</var>[,<var>lt-part</var>[,<var>eq-part</var>[,<var>gt-part</var>]]])</code></dt>
|
|
<dd><span id="index-intcmp"></span>
|
|
<p>The <code>intcmp</code> function provides support for numerical comparison of
|
|
integers. This function has no counterpart among the GNU <code>make</code> makefile
|
|
conditionals.
|
|
</p>
|
|
<p>The left-hand side, <var>lhs</var>, and right-hand side, <var>rhs</var>, are expanded
|
|
and parsed as integral numbers in base 10. Expansion of the remaining
|
|
arguments is controlled by how the numerical left-hand side compares to the
|
|
numerical right-hand side.
|
|
</p>
|
|
<p>If there are no further arguments, then the function expands to empty if the
|
|
left-hand side and right-hand side do not compare equal, or to their numerical
|
|
value if they do compare equal.
|
|
</p>
|
|
<p>Else if the left-hand side is strictly less than the right-hand side, the
|
|
<code>intcmp</code> function evaluates to the expansion of the third argument,
|
|
<var>lt-part</var>. If both sides compare equal, then the <code>intcmp</code> function
|
|
evaluates to the expansion of the fourth argument, <var>eq-part</var>. If the
|
|
left-hand side is strictly greater than the right-hand side, then the
|
|
<code>intcmp</code> function evaluates to the expansion of the fifth argument,
|
|
<var>gt-part</var>.
|
|
</p>
|
|
<p>If <var>gt-part</var> is missing, it defaults to <var>eq-part</var>. If <var>eq-part</var>
|
|
is missing, it defaults to the empty string. Thus both ‘<samp>$(intcmp
|
|
9,7,hello)</samp>’ and ‘<samp>$(intcmp 9,7,hello,world,)</samp>’ evaluate to the empty
|
|
string, while ‘<samp>$(intcmp 9,7,hello,world)</samp>’ (notice the absence of a comma
|
|
after <code>world</code>) evaluates to ‘<samp>world</samp>’.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Let-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Foreach-Function" accesskey="n" rel="next">Foreach Function</a>, Previous: <a href="#Conditional-Functions" accesskey="p" rel="prev">Conditional Functions</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-let-Function"></span><h3 class="section">8.5 The <code>let</code> Function</h3>
|
|
<span id="index-let"></span>
|
|
<span id="index-variables_002c-local"></span>
|
|
|
|
<p>The <code>let</code> function provides a means to limit the scope of a
|
|
variable. The assignment of the named variables in a <code>let</code>
|
|
expression is in effect only within the text provided by the
|
|
<code>let</code> expression, and this assignment doesn’t impact that named
|
|
variable in any outer scope.
|
|
</p>
|
|
<p>Additionally, the <code>let</code> function enables list unpacking by
|
|
assigning all unassigned values to the last named variable.
|
|
</p>
|
|
<p>The syntax of the <code>let</code> function is:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(let <var>var</var> [<var>var</var> ...],[<var>list</var>],<var>text</var>)
|
|
</pre></div>
|
|
|
|
<p>The first two arguments, <var>var</var> and <var>list</var>, are expanded before
|
|
anything else is done; note that the last argument, <var>text</var>, is
|
|
<strong>not</strong> expanded at the same time. Next, each word of the
|
|
expanded value of <var>list</var> is bound to each of the variable names,
|
|
<var>var</var>, in turn, with the final variable name being bound to the
|
|
remainder of the expanded <var>list</var>. In other words, the first word
|
|
of <var>list</var> is bound to the first variable <var>var</var>, the second
|
|
word to the second variable <var>var</var>, and so on.
|
|
</p>
|
|
<p>If there are more variable names in <var>var</var> than there are words in
|
|
<var>list</var>, the remaining <var>var</var> variable names are set to the
|
|
empty string. If there are fewer <var>var</var>s than words in <var>list</var>
|
|
then the last <var>var</var> is set to all remaining words in <var>list</var>.
|
|
</p>
|
|
<p>The variables in <var>var</var> are assigned as simply-expanded variables
|
|
during the execution of <code>let</code>. See <a href="#Flavors">The Two Flavors
|
|
of Variables</a>.
|
|
</p>
|
|
<p>After all variables are thus bound, <var>text</var> is expanded to provide
|
|
the result of the <code>let</code> function.
|
|
</p>
|
|
<p>For example, this macro reverses the order of the words in the list
|
|
that it is given as its first argument:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">reverse = $(let first rest,$1,\
|
|
$(if $(rest),$(call reverse,$(rest)) )$(first))
|
|
|
|
all: ; @echo $(call reverse,d c b a)
|
|
</pre></div>
|
|
|
|
<p>will print <code>a b c d</code>. When first called, <code>let</code> will expand
|
|
<var>$1</var> to <code>d c b a</code>. It will then assign <var>first</var> to
|
|
<code>d</code> and assign <var>rest</var> to <code>c b a</code>. It will then expand
|
|
the if-statement, where <code>$(rest)</code> is not empty so we recursively
|
|
invoke the <var>reverse</var> function with the value of <var>rest</var> which
|
|
is now <code>c b a</code>. The recursive invocation of <code>let</code> assigns
|
|
<var>first</var> to <code>c</code> and <var>rest</var> to <code>b a</code>. The recursion
|
|
continues until <code>let</code> is called with just a single value,
|
|
<code>a</code>. Here <var>first</var> is <code>a</code> and <var>rest</var> is empty, so we
|
|
do not recurse but simply expand <code>$(first)</code> to <code>a</code> and
|
|
return, which adds <code> b</code>, etc.
|
|
</p>
|
|
<p>After the <var>reverse</var> call is complete, the <var>first</var> and
|
|
<var>rest</var> variables are no longer set. If variables by those names
|
|
existed beforehand, they are not affected by the expansion of the
|
|
<code>reverse</code> macro.
|
|
</p>
|
|
<hr>
|
|
<span id="Foreach-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#File-Function" accesskey="n" rel="next">File Function</a>, Previous: <a href="#Let-Function" accesskey="p" rel="prev">Let Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-foreach-Function"></span><h3 class="section">8.6 The <code>foreach</code> Function</h3>
|
|
<span id="index-foreach"></span>
|
|
<span id="index-words_002c-iterating-over"></span>
|
|
|
|
<p>The <code>foreach</code> function is similar to the <code>let</code> function, but very
|
|
different from other functions. It causes one piece of text to be used
|
|
repeatedly, each time with a different substitution performed on it. The
|
|
<code>foreach</code> function resembles the <code>for</code> command in the
|
|
shell <code>sh</code> and the <code>foreach</code> command in the C-shell <code>csh</code>.
|
|
</p>
|
|
<p>The syntax of the <code>foreach</code> function is:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(foreach <var>var</var>,<var>list</var>,<var>text</var>)
|
|
</pre></div>
|
|
|
|
<p>The first two arguments, <var>var</var> and <var>list</var>, are expanded before
|
|
anything else is done; note that the last argument, <var>text</var>, is
|
|
<strong>not</strong> expanded at the same time. Then for each word of the expanded
|
|
value of <var>list</var>, the variable named by the expanded value of <var>var</var>
|
|
is set to that word, and <var>text</var> is expanded. Presumably <var>text</var>
|
|
contains references to that variable, so its expansion will be different
|
|
each time.
|
|
</p>
|
|
<p>The result is that <var>text</var> is expanded as many times as there are
|
|
whitespace-separated words in <var>list</var>. The multiple expansions of
|
|
<var>text</var> are concatenated, with spaces between them, to make the result
|
|
of <code>foreach</code>.
|
|
</p>
|
|
<p>This simple example sets the variable ‘<samp>files</samp>’ to the list of all files
|
|
in the directories in the list ‘<samp>dirs</samp>’:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">dirs := a b c d
|
|
files := $(foreach dir,$(dirs),$(wildcard $(dir)/*))
|
|
</pre></div>
|
|
|
|
<p>Here <var>text</var> is ‘<samp>$(wildcard $(dir)/*)</samp>’. The first repetition
|
|
finds the value ‘<samp>a</samp>’ for <code>dir</code>, so it produces the same result
|
|
as ‘<samp>$(wildcard a/*)</samp>’; the second repetition produces the result
|
|
of ‘<samp>$(wildcard b/*)</samp>’; and the third, that of ‘<samp>$(wildcard c/*)</samp>’.
|
|
</p>
|
|
<p>This example has the same result (except for setting ‘<samp>dirs</samp>’) as
|
|
the following example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">files := $(wildcard a/* b/* c/* d/*)
|
|
</pre></div>
|
|
|
|
<p>When <var>text</var> is complicated, you can improve readability by giving it
|
|
a name, with an additional variable:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">find_files = $(wildcard $(dir)/*)
|
|
dirs := a b c d
|
|
files := $(foreach dir,$(dirs),$(find_files))
|
|
</pre></div>
|
|
|
|
<p>Here we use the variable <code>find_files</code> this way. We use plain ‘<samp>=</samp>’
|
|
to define a recursively-expanding variable, so that its value contains an
|
|
actual function call to be re-expanded under the control of <code>foreach</code>;
|
|
a simply-expanded variable would not do, since <code>wildcard</code> would be
|
|
called only once at the time of defining <code>find_files</code>.
|
|
</p>
|
|
<p>Like the <code>let</code> function, the <code>foreach</code> function has no permanent
|
|
effect on the variable <var>var</var>; its value and flavor after the
|
|
<code>foreach</code> function call are the same as they were beforehand. The
|
|
other values which are taken from <var>list</var> are in effect only
|
|
temporarily, during the execution of <code>foreach</code>. The variable
|
|
<var>var</var> is a simply-expanded variable during the execution of
|
|
<code>foreach</code>. If <var>var</var> was undefined before the <code>foreach</code>
|
|
function call, it is undefined after the call.
|
|
See <a href="#Flavors">The Two Flavors of Variables</a>.
|
|
</p>
|
|
<p>You must take care when using complex variable expressions that result in
|
|
variable names because many strange things are valid variable names, but
|
|
are probably not what you intended. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">files := $(foreach Esta-escrito-en-espanol!,b c ch,$(find_files))
|
|
</pre></div>
|
|
|
|
<p>might be useful if the value of <code>find_files</code> references the variable
|
|
whose name is ‘<samp>Esta-escrito-en-espanol!</samp>’ (es un nombre bastante largo,
|
|
no?), but it is more likely to be a mistake.
|
|
</p>
|
|
<hr>
|
|
<span id="File-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Call-Function" accesskey="n" rel="next">Call Function</a>, Previous: <a href="#Foreach-Function" accesskey="p" rel="prev">Foreach Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-file-Function"></span><h3 class="section">8.7 The <code>file</code> Function</h3>
|
|
<span id="index-file"></span>
|
|
<span id="index-writing-to-a-file"></span>
|
|
<span id="index-file_002c-writing-to"></span>
|
|
<span id="index-reading-from-a-file"></span>
|
|
<span id="index-file_002c-reading-from"></span>
|
|
|
|
<p>The <code>file</code> function allows the makefile to write to or read from
|
|
a file. Two modes of writing are supported: overwrite, where the text
|
|
is written to the beginning of the file and any existing content is
|
|
lost, and append, where the text is written to the end of the file,
|
|
preserving the existing content. In both cases the file is created if
|
|
it does not exist. It is a fatal error if the file cannot be opened
|
|
for writing, or if the write operation fails. The <code>file</code>
|
|
function expands to the empty string when writing to a file.
|
|
</p>
|
|
<p>When reading from a file, the <code>file</code> function expands to the
|
|
verbatim contents of the file, except that the final newline (if there
|
|
is one) will be stripped. Attempting to read from a non-existent file
|
|
expands to the empty string.
|
|
</p>
|
|
<p>The syntax of the <code>file</code> function is:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(file <var>op</var> <var>filename</var>[,<var>text</var>])
|
|
</pre></div>
|
|
|
|
<p>When the <code>file</code> function is evaluated all its arguments are
|
|
expanded first, then the file indicated by <var>filename</var> will be
|
|
opened in the mode described by <var>op</var>.
|
|
</p>
|
|
<p>The operator <var>op</var> can be <code>></code> to indicate the file will be
|
|
overwritten with new content, <code>>></code> to indicate the current
|
|
contents of the file will be appended to, or <code><</code> to indicate the
|
|
contents of the file will be read in. The <var>filename</var> specifies
|
|
the file to be written to or read from. There may optionally be
|
|
whitespace between the operator and the file name.
|
|
</p>
|
|
<p>When reading files, it is an error to provide a <var>text</var> value.
|
|
</p>
|
|
<p>When writing files, <var>text</var> will be written to the file. If
|
|
<var>text</var> does not already end in a newline a final newline will be
|
|
written (even if <var>text</var> is the empty string). If the <var>text</var>
|
|
argument is not given at all, nothing will be written.
|
|
</p>
|
|
<p>For example, the <code>file</code> function can be useful if your build
|
|
system has a limited command line size and your recipe runs a command
|
|
that can accept arguments from a file as well. Many commands use the
|
|
convention that an argument prefixed with an <code>@</code> specifies a
|
|
file containing more arguments. Then you might write your recipe in
|
|
this way:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">program: $(OBJECTS)
|
|
$(file >$@.in,$^)
|
|
$(CMD) $(CMDFLAGS) @$@.in
|
|
@rm $@.in
|
|
</pre></div>
|
|
|
|
<p>If the command required each argument to be on a separate line of the
|
|
input file, you might write your recipe like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">program: $(OBJECTS)
|
|
$(file >$@.in) $(foreach O,$^,$(file >>$@.in,$O))
|
|
$(CMD) $(CMDFLAGS) @$@.in
|
|
@rm $@.in
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Call-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Value-Function" accesskey="n" rel="next">Value Function</a>, Previous: <a href="#File-Function" accesskey="p" rel="prev">File Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-call-Function"></span><h3 class="section">8.8 The <code>call</code> Function</h3>
|
|
<span id="index-call"></span>
|
|
<span id="index-functions_002c-user-defined"></span>
|
|
<span id="index-user-defined-functions"></span>
|
|
|
|
<p>The <code>call</code> function is unique in that it can be used to create new
|
|
parameterized functions. You can write a complex expression as the
|
|
value of a variable, then use <code>call</code> to expand it with different
|
|
values.
|
|
</p>
|
|
<p>The syntax of the <code>call</code> function is:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(call <var>variable</var>,<var>param</var>,<var>param</var>,…)
|
|
</pre></div>
|
|
|
|
<p>When <code>make</code> expands this function, it assigns each <var>param</var> to
|
|
temporary variables <code>$(1)</code>, <code>$(2)</code>, etc. The variable
|
|
<code>$(0)</code> will contain <var>variable</var>. There is no maximum number of
|
|
parameter arguments. There is no minimum, either, but it doesn’t make
|
|
sense to use <code>call</code> with no parameters.
|
|
</p>
|
|
<p>Then <var>variable</var> is expanded as a <code>make</code> variable in the context
|
|
of these temporary assignments. Thus, any reference to <code>$(1)</code> in
|
|
the value of <var>variable</var> will resolve to the first <var>param</var> in the
|
|
invocation of <code>call</code>.
|
|
</p>
|
|
<p>Note that <var>variable</var> is the <em>name</em> of a variable, not a
|
|
<em>reference</em> to that variable. Therefore you would not normally use
|
|
a ‘<samp>$</samp>’ or parentheses when writing it. (You can, however, use a
|
|
variable reference in the name if you want the name not to be a
|
|
constant.)
|
|
</p>
|
|
<p>If <var>variable</var> is the name of a built-in function, the built-in function
|
|
is always invoked (even if a <code>make</code> variable by that name also
|
|
exists).
|
|
</p>
|
|
<p>The <code>call</code> function expands the <var>param</var> arguments before
|
|
assigning them to temporary variables. This means that <var>variable</var>
|
|
values containing references to built-in functions that have special
|
|
expansion rules, like <code>foreach</code> or <code>if</code>, may not work as you
|
|
expect.
|
|
</p>
|
|
<p>Some examples may make this clearer.
|
|
</p>
|
|
<p>This macro simply reverses its arguments:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">reverse = $(2) $(1)
|
|
|
|
foo = $(call reverse,a,b)
|
|
</pre></div>
|
|
|
|
<p>Here <code>foo</code> will contain ‘<samp>b a</samp>’.
|
|
</p>
|
|
<p>This one is slightly more interesting: it defines a macro to search for
|
|
the first instance of a program in <code>PATH</code>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH)))))
|
|
|
|
LS := $(call pathsearch,ls)
|
|
</pre></div>
|
|
|
|
<p>Now the variable <code>LS</code> contains <code>/bin/ls</code> or similar.
|
|
</p>
|
|
<p>The <code>call</code> function can be nested. Each recursive invocation gets
|
|
its own local values for <code>$(1)</code>, etc. that mask the values of
|
|
higher-level <code>call</code>. For example, here is an implementation of a
|
|
<em>map</em> function:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">map = $(foreach a,$(2),$(call $(1),$(a)))
|
|
</pre></div>
|
|
|
|
<p>Now you can <code>map</code> a function that normally takes only one argument,
|
|
such as <code>origin</code>, to multiple values in one step:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">o = $(call map,origin,o map MAKE)
|
|
</pre></div>
|
|
|
|
<p>and end up with <code>o</code> containing something like ‘<samp>file file default</samp>’.
|
|
</p>
|
|
<p>A final caution: be careful when adding whitespace to the arguments to
|
|
<code>call</code>. As with other functions, any whitespace contained in the
|
|
second and subsequent arguments is kept; this can cause strange
|
|
effects. It’s generally safest to remove all extraneous whitespace when
|
|
providing parameters to <code>call</code>.
|
|
</p>
|
|
<hr>
|
|
<span id="Value-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Eval-Function" accesskey="n" rel="next">Eval Function</a>, Previous: <a href="#Call-Function" accesskey="p" rel="prev">Call Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-value-Function"></span><h3 class="section">8.9 The <code>value</code> Function</h3>
|
|
<span id="index-value-1"></span>
|
|
<span id="index-variables_002c-unexpanded-value"></span>
|
|
|
|
<p>The <code>value</code> function provides a way for you to use the value of a
|
|
variable <em>without</em> having it expanded. Please note that this
|
|
does not undo expansions which have already occurred; for example if
|
|
you create a simply expanded variable its value is expanded during the
|
|
definition; in that case the <code>value</code> function will return the
|
|
same result as using the variable directly.
|
|
</p>
|
|
<p>The syntax of the <code>value</code> function is:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(value <var>variable</var>)
|
|
</pre></div>
|
|
|
|
<p>Note that <var>variable</var> is the <em>name</em> of a variable, not a
|
|
<em>reference</em> to that variable. Therefore you would not normally
|
|
use a ‘<samp>$</samp>’ or parentheses when writing it. (You can, however, use
|
|
a variable reference in the name if you want the name not to be a
|
|
constant.)
|
|
</p>
|
|
<p>The result of this function is a string containing the value of
|
|
<var>variable</var>, without any expansion occurring. For example, in this
|
|
makefile:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">FOO = $PATH
|
|
|
|
all:
|
|
@echo $(FOO)
|
|
@echo $(value FOO)
|
|
</pre></div>
|
|
|
|
<p>The first output line would be <code>ATH</code>, since the “$P” would be
|
|
expanded as a <code>make</code> variable, while the second output line would
|
|
be the current value of your <code>$PATH</code> environment variable, since
|
|
the <code>value</code> function avoided the expansion.
|
|
</p>
|
|
<p>The <code>value</code> function is most often used in conjunction with the
|
|
<code>eval</code> function (see <a href="#Eval-Function">Eval Function</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Eval-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Origin-Function" accesskey="n" rel="next">Origin Function</a>, Previous: <a href="#Value-Function" accesskey="p" rel="prev">Value Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-eval-Function"></span><h3 class="section">8.10 The <code>eval</code> Function</h3>
|
|
<span id="index-eval"></span>
|
|
<span id="index-evaluating-makefile-syntax"></span>
|
|
<span id="index-makefile-syntax_002c-evaluating"></span>
|
|
|
|
<p>The <code>eval</code> function is very special: it allows you to define new
|
|
makefile constructs that are not constant; which are the result of
|
|
evaluating other variables and functions. The argument to the
|
|
<code>eval</code> function is expanded, then the results of that expansion
|
|
are parsed as makefile syntax. The expanded results can define new
|
|
<code>make</code> variables, targets, implicit or explicit rules, etc.
|
|
</p>
|
|
<p>The result of the <code>eval</code> function is always the empty string;
|
|
thus, it can be placed virtually anywhere in a makefile without
|
|
causing syntax errors.
|
|
</p>
|
|
<p>It’s important to realize that the <code>eval</code> argument is expanded
|
|
<em>twice</em>; first by the <code>eval</code> function, then the results of
|
|
that expansion are expanded again when they are parsed as makefile
|
|
syntax. This means you may need to provide extra levels of escaping
|
|
for “$” characters when using <code>eval</code>. The <code>value</code>
|
|
function (see <a href="#Value-Function">Value Function</a>) can sometimes be useful in these
|
|
situations, to circumvent unwanted expansions.
|
|
</p>
|
|
<p>Here is an example of how <code>eval</code> can be used; this example
|
|
combines a number of concepts and other functions. Although it might
|
|
seem overly complex to use <code>eval</code> in this example, rather than
|
|
just writing out the rules, consider two things: first, the template
|
|
definition (in <code>PROGRAM_template</code>) could need to be much more
|
|
complex than it is here; and second, you might put the complex,
|
|
“generic” part of this example into another makefile, then include
|
|
it in all the individual makefiles. Now your individual makefiles are
|
|
quite straightforward.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">PROGRAMS = server client
|
|
|
|
server_OBJS = server.o server_priv.o server_access.o
|
|
server_LIBS = priv protocol
|
|
|
|
client_OBJS = client.o client_api.o client_mem.o
|
|
client_LIBS = protocol
|
|
|
|
# Everything after this is generic
|
|
|
|
.PHONY: all
|
|
all: $(PROGRAMS)
|
|
|
|
define PROGRAM_template =
|
|
$(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%)
|
|
ALL_OBJS += $$($(1)_OBJS)
|
|
endef
|
|
|
|
$(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog))))
|
|
|
|
$(PROGRAMS):
|
|
$(LINK.o) $^ $(LDLIBS) -o $@
|
|
|
|
clean:
|
|
rm -f $(ALL_OBJS) $(PROGRAMS)
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Origin-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Flavor-Function" accesskey="n" rel="next">Flavor Function</a>, Previous: <a href="#Eval-Function" accesskey="p" rel="prev">Eval Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-origin-Function"></span><h3 class="section">8.11 The <code>origin</code> Function</h3>
|
|
<span id="index-origin"></span>
|
|
<span id="index-variables_002c-origin-of"></span>
|
|
<span id="index-origin-of-variable"></span>
|
|
|
|
<p>The <code>origin</code> function is unlike most other functions in that it does
|
|
not operate on the values of variables; it tells you something <em>about</em>
|
|
a variable. Specifically, it tells you where it came from.
|
|
</p>
|
|
<p>The syntax of the <code>origin</code> function is:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(origin <var>variable</var>)
|
|
</pre></div>
|
|
|
|
<p>Note that <var>variable</var> is the <em>name</em> of a variable to inquire about,
|
|
not a <em>reference</em> to that variable. Therefore you would not normally
|
|
use a ‘<samp>$</samp>’ or parentheses when writing it. (You can, however, use a
|
|
variable reference in the name if you want the name not to be a constant.)
|
|
</p>
|
|
<p>The result of this function is a string telling you how the variable
|
|
<var>variable</var> was defined:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>undefined</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> was never defined.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>default</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> has a default definition, as is usual with <code>CC</code>
|
|
and so on. See <a href="#Implicit-Variables">Variables Used by Implicit Rules</a>.
|
|
Note that if you have redefined a default variable, the <code>origin</code>
|
|
function will return the origin of the later definition.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>environment</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> was inherited from the environment provided to
|
|
<code>make</code>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>environment override</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> was inherited from the environment provided to
|
|
<code>make</code>, and is overriding a setting for <var>variable</var> in the
|
|
makefile as a result of the ‘<samp><span class="nolinebreak">-e</span></samp>’<!-- /@w --> option (see <a href="#Options-Summary">Summary of Options</a>).
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>file</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> was defined in a makefile.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>command line</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> was defined on the command line.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>override</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> was defined with an <code>override</code> directive in a
|
|
makefile (see <a href="#Override-Directive">The <code>override</code> Directive</a>).
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>automatic</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> is an automatic variable defined for the execution
|
|
of the recipe for each rule (see <a href="#Automatic-Variables">Automatic Variables</a>).
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>This information is primarily useful (other than for your curiosity) to
|
|
determine if you want to believe the value of a variable. For example,
|
|
suppose you have a makefile <samp>foo</samp> that includes another makefile
|
|
<samp>bar</samp>. You want a variable <code>bletch</code> to be defined in <samp>bar</samp>
|
|
if you run the command ‘<samp>make <span class="nolinebreak">-f</span> bar</samp>’<!-- /@w -->, even if the environment contains
|
|
a definition of <code>bletch</code>. However, if <samp>foo</samp> defined
|
|
<code>bletch</code> before including <samp>bar</samp>, you do not want to override that
|
|
definition. This could be done by using an <code>override</code> directive in
|
|
<samp>foo</samp>, giving that definition precedence over the later definition in
|
|
<samp>bar</samp>; unfortunately, the <code>override</code> directive would also
|
|
override any command line definitions. So, <samp>bar</samp> could
|
|
include:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ifdef bletch
|
|
ifeq "$(origin bletch)" "environment"
|
|
bletch = barf, gag, etc.
|
|
endif
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>If <code>bletch</code> has been defined from the environment, this will redefine
|
|
it.
|
|
</p>
|
|
<p>If you want to override a previous definition of <code>bletch</code> if it came
|
|
from the environment, even under ‘<samp>-e</samp>’, you could instead write:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ifneq "$(findstring environment,$(origin bletch))" ""
|
|
bletch = barf, gag, etc.
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>Here the redefinition takes place if ‘<samp>$(origin bletch)</samp>’ returns either
|
|
‘<samp>environment</samp>’ or ‘<samp>environment override</samp>’.
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Flavor-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Make-Control-Functions" accesskey="n" rel="next">Make Control Functions</a>, Previous: <a href="#Origin-Function" accesskey="p" rel="prev">Origin Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-flavor-Function"></span><h3 class="section">8.12 The <code>flavor</code> Function</h3>
|
|
<span id="index-flavor"></span>
|
|
<span id="index-variables_002c-flavor-of"></span>
|
|
<span id="index-flavor-of-variable"></span>
|
|
|
|
<p>The <code>flavor</code> function, like the <code>origin</code> function, does not
|
|
operate on the values of variables but rather it tells you something
|
|
<em>about</em> a variable. Specifically, it tells you the flavor of a
|
|
variable (see <a href="#Flavors">The Two Flavors of Variables</a>).
|
|
</p>
|
|
<p>The syntax of the <code>flavor</code> function is:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(flavor <var>variable</var>)
|
|
</pre></div>
|
|
|
|
<p>Note that <var>variable</var> is the <em>name</em> of a variable to inquire about,
|
|
not a <em>reference</em> to that variable. Therefore you would not normally
|
|
use a ‘<samp>$</samp>’ or parentheses when writing it. (You can, however, use a
|
|
variable reference in the name if you want the name not to be a constant.)
|
|
</p>
|
|
<p>The result of this function is a string that identifies the flavor of the
|
|
variable <var>variable</var>:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>undefined</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> was never defined.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>recursive</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> is a recursively expanded variable.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>simple</samp>’</dt>
|
|
<dd>
|
|
<p>if <var>variable</var> is a simply expanded variable.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Make-Control-Functions"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Shell-Function" accesskey="n" rel="next">Shell Function</a>, Previous: <a href="#Flavor-Function" accesskey="p" rel="prev">Flavor Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Functions-That-Control-Make"></span><h3 class="section">8.13 Functions That Control Make</h3>
|
|
<span id="index-functions_002c-for-controlling-make"></span>
|
|
<span id="index-controlling-make"></span>
|
|
|
|
<p>These functions control the way make runs. Generally, they are used to
|
|
provide information to the user of the makefile or to cause make to stop
|
|
if some sort of environmental error is detected.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>$(error <var>text</var>…)</code></dt>
|
|
<dd><span id="index-error"></span>
|
|
<span id="index-error_002c-stopping-on"></span>
|
|
<span id="index-stopping-make"></span>
|
|
<p>Generates a fatal error where the message is <var>text</var>. Note that
|
|
the error is generated whenever this function is evaluated. So, if
|
|
you put it inside a recipe or on the right side of a recursive
|
|
variable assignment, it won’t be evaluated until later. The
|
|
<var>text</var> will be expanded before the error is generated.
|
|
</p>
|
|
<p>For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ifdef ERROR1
|
|
$(error error is $(ERROR1))
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>will generate a fatal error during the read of the makefile if the
|
|
<code>make</code> variable <code>ERROR1</code> is defined. Or,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ERR = $(error found an error!)
|
|
|
|
.PHONY: err
|
|
err: ; $(ERR)
|
|
</pre></div>
|
|
|
|
<p>will generate a fatal error while <code>make</code> is running, if the
|
|
<code>err</code> target is invoked.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(warning <var>text</var>…)</code></dt>
|
|
<dd><span id="index-warning"></span>
|
|
<span id="index-warnings_002c-printing"></span>
|
|
<span id="index-printing-user-warnings"></span>
|
|
<p>This function works similarly to the <code>error</code> function, above,
|
|
except that <code>make</code> doesn’t exit. Instead, <var>text</var> is expanded
|
|
and the resulting message is displayed, but processing of the makefile
|
|
continues.
|
|
</p>
|
|
<p>The result of the expansion of this function is the empty string.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(info <var>text</var>…)</code></dt>
|
|
<dd><span id="index-info"></span>
|
|
<span id="index-printing-messages"></span>
|
|
<p>This function does nothing more than print its (expanded) argument(s)
|
|
to standard output. No makefile name or line number is added. The
|
|
result of the expansion of this function is the empty string.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Shell-Function"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Guile-Function" accesskey="n" rel="next">Guile Function</a>, Previous: <a href="#Make-Control-Functions" accesskey="p" rel="prev">Make Control Functions</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-shell-Function"></span><h3 class="section">8.14 The <code>shell</code> Function</h3>
|
|
<span id="index-shell"></span>
|
|
<span id="index-command-expansion"></span>
|
|
<span id="index-backquotes"></span>
|
|
<span id="index-shell-command_002c-function-for"></span>
|
|
|
|
<p>The <code>shell</code> function is unlike any other function other than the
|
|
<code>wildcard</code> function
|
|
(see <a href="#Wildcard-Function">The Function <code>wildcard</code></a>) in that it
|
|
communicates with the world outside of <code>make</code>.
|
|
</p>
|
|
<p>The <code>shell</code> function provides for <code>make</code> the same facility that
|
|
backquotes (‘<samp>`</samp>’) provide in most shells: it does <em>command expansion</em>.
|
|
This means that it takes as an argument a shell command and expands to the
|
|
output of the command. The only processing <code>make</code> does on the result is
|
|
to convert each newline (or carriage-return / newline pair) to a single space.
|
|
If there is a trailing (carriage-return and) newline it will simply be
|
|
removed.
|
|
</p>
|
|
<p>The commands run by calls to the <code>shell</code> function are run when the
|
|
function calls are expanded (see <a href="#Reading-Makefiles">How <code>make</code> Reads
|
|
a Makefile</a>). Because this function involves spawning a new shell, you should
|
|
carefully consider the performance implications of using the <code>shell</code>
|
|
function within recursively expanded variables vs. simply expanded variables
|
|
(see <a href="#Flavors">The Two Flavors of Variables</a>).
|
|
</p>
|
|
<p>An alternative to the <code>shell</code> function is the ‘<samp>!=</samp>’ assignment
|
|
operator; it provides a similar behavior but has subtle differences
|
|
(see <a href="#Setting">Setting Variables</a>). The ‘<samp>!=</samp>’ assignment operator is
|
|
included in newer POSIX standards.
|
|
</p>
|
|
<span id="index-_002eSHELLSTATUS"></span>
|
|
<p>After the <code>shell</code> function or ‘<samp>!=</samp>’ assignment operator is
|
|
used, its exit status is placed in the <code>.SHELLSTATUS</code> variable.
|
|
</p>
|
|
<p>Here are some examples of the use of the <code>shell</code> function:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">contents := $(shell cat foo)
|
|
</pre></div>
|
|
|
|
<p>sets <code>contents</code> to the contents of the file <samp>foo</samp>, with a space
|
|
(rather than a newline) separating each line.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">files := $(shell echo *.c)
|
|
</pre></div>
|
|
|
|
<p>sets <code>files</code> to the expansion of ‘<samp>*.c</samp>’. Unless <code>make</code> is
|
|
using a very strange shell, this has the same result as
|
|
‘<samp>$(wildcard *.c)</samp>’<!-- /@w --> (as long as at least one ‘<samp>.c</samp>’ file
|
|
exists).
|
|
</p>
|
|
<p>All variables that are marked as <code>export</code> will also be passed to the
|
|
shell started by the <code>shell</code> function. It is possible to create a
|
|
variable expansion loop: consider this <samp>makefile</samp>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">export HI = $(shell echo hi)
|
|
all: ; @echo $$HI
|
|
</pre></div>
|
|
|
|
<p>When <code>make</code> wants to run the recipe it must add the variable <var>HI</var> to
|
|
the environment; to do so it must be expanded. The value of this variable
|
|
requires an invocation of the <code>shell</code> function, and to invoke it we must
|
|
create its environment. Since <var>HI</var> is exported, we need to expand it to
|
|
create its environment. And so on. In this obscure case <code>make</code> will use
|
|
the value of the variable from the environment provided to <code>make</code>, or
|
|
else the empty string if there was none, rather than looping or issuing an
|
|
error. This is often what you want; for example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">export PATH = $(shell echo /usr/local/bin:$$PATH)
|
|
</pre></div>
|
|
|
|
<p>However, it would be simpler and more efficient to use a simply-expanded
|
|
variable here (‘<samp>:=</samp>’) in the first place.
|
|
</p>
|
|
<hr>
|
|
<span id="Guile-Function"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Shell-Function" accesskey="p" rel="prev">Shell Function</a>, Up: <a href="#Functions" accesskey="u" rel="up">Functions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-guile-Function"></span><h3 class="section">8.15 The <code>guile</code> Function</h3>
|
|
<span id="index-guile"></span>
|
|
<span id="index-Guile"></span>
|
|
|
|
<p>If GNU <code>make</code> is built with support for GNU Guile as an embedded
|
|
extension language then the <code>guile</code> function will be available.
|
|
The <code>guile</code> function takes one argument which is first expanded
|
|
by <code>make</code> in the normal fashion, then passed to the GNU Guile
|
|
evaluator. The result of the evaluator is converted into a string and
|
|
used as the expansion of the <code>guile</code> function in the makefile.
|
|
See <a href="#Guile-Integration">GNU Guile Integration</a> for details on
|
|
writing extensions to <code>make</code> in Guile.
|
|
</p>
|
|
<p>You can determine whether GNU Guile support is available by checking
|
|
the <code>.FEATURES</code> variable for the word <var>guile</var>.
|
|
</p>
|
|
<hr>
|
|
<span id="Running"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Implicit-Rules" accesskey="n" rel="next">Implicit Rules</a>, Previous: <a href="#Functions" accesskey="p" rel="prev">Functions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-to-Run-make"></span><h2 class="chapter">9 How to Run <code>make</code></h2>
|
|
|
|
<p>A makefile that says how to recompile a program can be used in more
|
|
than one way. The simplest use is to recompile every file that is out
|
|
of date. Usually, makefiles are written so that if you run
|
|
<code>make</code> with no arguments, it does just that.
|
|
</p>
|
|
<p>But you might want to update only some of the files; you might want to use
|
|
a different compiler or different compiler options; you might want just to
|
|
find out which files are out of date without changing them.
|
|
</p>
|
|
<p>By giving arguments when you run <code>make</code>, you can do any of these
|
|
things and many others.
|
|
</p>
|
|
<span id="index-exit-status-of-make"></span>
|
|
<p>The exit status of <code>make</code> is always one of three values:
|
|
</p><dl compact="compact">
|
|
<dt><code>0</code></dt>
|
|
<dd><p>The exit status is zero if <code>make</code> is successful.
|
|
</p></dd>
|
|
<dt><code>2</code></dt>
|
|
<dd><p>The exit status is two if <code>make</code> encounters any errors.
|
|
It will print messages describing the particular errors.
|
|
</p></dd>
|
|
<dt><code>1</code></dt>
|
|
<dd><p>The exit status is one if you use the ‘<samp>-q</samp>’ flag and <code>make</code>
|
|
determines that some target is not already up to date.
|
|
See <a href="#Instead-of-Execution">Instead of Executing Recipes</a>.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Makefile-Arguments" accesskey="1">Makefile Arguments</a></td><td> </td><td align="left" valign="top">How to specify which makefile to use.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Goals" accesskey="2">Goals</a></td><td> </td><td align="left" valign="top">How to use goal arguments to specify which
|
|
parts of the makefile to use.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Instead-of-Execution" accesskey="3">Instead of Execution</a></td><td> </td><td align="left" valign="top">How to use mode flags to specify what
|
|
kind of thing to do with the recipes
|
|
in the makefile other than simply
|
|
execute them.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Avoiding-Compilation" accesskey="4">Avoiding Compilation</a></td><td> </td><td align="left" valign="top">How to avoid recompiling certain files.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Overriding" accesskey="5">Overriding</a></td><td> </td><td align="left" valign="top">How to override a variable to specify
|
|
an alternate compiler and other things.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Testing" accesskey="6">Testing</a></td><td> </td><td align="left" valign="top">How to proceed past some errors, to
|
|
test compilation.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Temporary-Files" accesskey="7">Temporary Files</a></td><td> </td><td align="left" valign="top">Where <code>make</code> keeps its temporary files.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Options-Summary" accesskey="8">Options Summary</a></td><td> </td><td align="left" valign="top">Summary of Options
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Makefile-Arguments"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Goals" accesskey="n" rel="next">Goals</a>, Previous: <a href="#Running" accesskey="p" rel="prev">Running</a>, Up: <a href="#Running" accesskey="u" rel="up">Running</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Arguments-to-Specify-the-Makefile"></span><h3 class="section">9.1 Arguments to Specify the Makefile</h3>
|
|
<span id="index-_002d_002dfile-1"></span>
|
|
<span id="index-_002d_002dmakefile-1"></span>
|
|
<span id="index-_002df-1"></span>
|
|
|
|
<p>The way to specify the name of the makefile is with the ‘<samp>-f</samp>’ or
|
|
‘<samp>--file</samp>’ option (‘<samp>--makefile</samp>’ also works). For example,
|
|
‘<samp>-f altmake</samp>’ says to use the file <samp>altmake</samp> as the makefile.
|
|
</p>
|
|
<p>If you use the ‘<samp>-f</samp>’ flag several times and follow each ‘<samp>-f</samp>’
|
|
with an argument, all the specified files are used jointly as
|
|
makefiles.
|
|
</p>
|
|
<p>If you do not use the ‘<samp>-f</samp>’ or ‘<samp>--file</samp>’ flag, the default is
|
|
to try <samp>GNUmakefile</samp>, <samp>makefile</samp>, and <samp>Makefile</samp>, in
|
|
that order, and use the first of these three which exists or can be made
|
|
(see <a href="#Makefiles">Writing Makefiles</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Goals"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Instead-of-Execution" accesskey="n" rel="next">Instead of Execution</a>, Previous: <a href="#Makefile-Arguments" accesskey="p" rel="prev">Makefile Arguments</a>, Up: <a href="#Running" accesskey="u" rel="up">Running</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Arguments-to-Specify-the-Goals"></span><h3 class="section">9.2 Arguments to Specify the Goals</h3>
|
|
<span id="index-goal_002c-how-to-specify"></span>
|
|
|
|
<p>The <em>goals</em> are the targets that <code>make</code> should strive ultimately
|
|
to update. Other targets are updated as well if they appear as
|
|
prerequisites of goals, or prerequisites of prerequisites of goals, etc.
|
|
</p>
|
|
<p>By default, the goal is the first target in the makefile (not counting
|
|
targets that start with a period). Therefore, makefiles are usually
|
|
written so that the first target is for compiling the entire program or
|
|
programs they describe. If the first rule in the makefile has several
|
|
targets, only the first target in the rule becomes the default goal, not
|
|
the whole list. You can manage the selection of the default goal from
|
|
within your makefile using the <code>.DEFAULT_GOAL</code> variable
|
|
(see <a href="#Special-Variables">Other Special Variables</a>).
|
|
</p>
|
|
<p>You can also specify a different goal or goals with command line
|
|
arguments to <code>make</code>. Use the name of the goal as an argument.
|
|
If you specify several goals, <code>make</code> processes each of them in
|
|
turn, in the order you name them.
|
|
</p>
|
|
<p>Any target in the makefile may be specified as a goal (unless it
|
|
starts with ‘<samp>-</samp>’ or contains an ‘<samp>=</samp>’, in which case it will be
|
|
parsed as a switch or variable definition, respectively). Even
|
|
targets not in the makefile may be specified, if <code>make</code> can find
|
|
implicit rules that say how to make them.
|
|
</p>
|
|
<span id="index-MAKECMDGOALS"></span>
|
|
<p><code>Make</code> will set the special variable <code>MAKECMDGOALS</code> to the
|
|
list of goals you specified on the command line. If no goals were given
|
|
on the command line, this variable is empty. Note that this variable
|
|
should be used only in special circumstances.
|
|
</p>
|
|
<p>An example of appropriate use is to avoid including <samp>.d</samp> files
|
|
during <code>clean</code> rules (see <a href="#Automatic-Prerequisites">Automatic Prerequisites</a>), so
|
|
<code>make</code> won’t create them only to immediately remove them
|
|
again:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">sources = foo.c bar.c
|
|
|
|
ifeq (,$(filter clean,$(MAKECMDGOALS))
|
|
include $(sources:.c=.d)
|
|
endif
|
|
</pre></div>
|
|
|
|
<p>One use of specifying a goal is if you want to compile only a part of
|
|
the program, or only one of several programs. Specify as a goal each
|
|
file that you wish to remake. For example, consider a directory containing
|
|
several programs, with a makefile that starts like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.PHONY: all
|
|
all: size nm ld ar as
|
|
</pre></div>
|
|
|
|
<p>If you are working on the program <code>size</code>, you might want to say
|
|
‘<samp>make size</samp>’<!-- /@w --> so that only the files of that program are recompiled.
|
|
</p>
|
|
<p>Another use of specifying a goal is to make files that are not normally
|
|
made. For example, there may be a file of debugging output, or a
|
|
version of the program that is compiled specially for testing, which has
|
|
a rule in the makefile but is not a prerequisite of the default goal.
|
|
</p>
|
|
<p>Another use of specifying a goal is to run the recipe associated with
|
|
a phony target (see <a href="#Phony-Targets">Phony Targets</a>) or empty target (see <a href="#Empty-Targets">Empty Target Files to Record Events</a>). Many makefiles contain
|
|
a phony target named <samp>clean</samp> which deletes everything except source
|
|
files. Naturally, this is done only if you request it explicitly with
|
|
‘<samp>make clean</samp>’<!-- /@w -->. Following is a list of typical phony and empty
|
|
target names. See <a href="#Standard-Targets">Standard Targets</a>, for a detailed list of all the
|
|
standard target names which GNU software packages use.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><samp>all</samp></dt>
|
|
<dd><span id="index-all-_0028standard-target_0029"></span>
|
|
<p>Make all the top-level targets the makefile knows about.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>clean</samp></dt>
|
|
<dd><span id="index-clean-_0028standard-target_0029"></span>
|
|
<p>Delete all files that are normally created by running <code>make</code>.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>mostlyclean</samp></dt>
|
|
<dd><span id="index-mostlyclean-_0028standard-target_0029"></span>
|
|
<p>Like ‘<samp>clean</samp>’, but may refrain from deleting a few files that people
|
|
normally don’t want to recompile. For example, the ‘<samp>mostlyclean</samp>’
|
|
target for GCC does not delete <samp>libgcc.a</samp>, because recompiling it
|
|
is rarely necessary and takes a lot of time.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>distclean</samp></dt>
|
|
<dd><span id="index-distclean-_0028standard-target_0029"></span>
|
|
</dd>
|
|
<dt><samp>realclean</samp></dt>
|
|
<dd><span id="index-realclean-_0028standard-target_0029"></span>
|
|
</dd>
|
|
<dt><samp>clobber</samp></dt>
|
|
<dd><span id="index-clobber-_0028standard-target_0029"></span>
|
|
<p>Any of these targets might be defined to delete <em>more</em> files than
|
|
‘<samp>clean</samp>’ does. For example, this would delete configuration files
|
|
or links that you would normally create as preparation for compilation,
|
|
even if the makefile itself cannot create these files.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>install</samp></dt>
|
|
<dd><span id="index-install-_0028standard-target_0029"></span>
|
|
<p>Copy the executable file into a directory that users typically search
|
|
for commands; copy any auxiliary files that the executable uses into
|
|
the directories where it will look for them.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>print</samp></dt>
|
|
<dd><span id="index-print-_0028standard-target_0029"></span>
|
|
<p>Print listings of the source files that have changed.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>tar</samp></dt>
|
|
<dd><span id="index-tar-_0028standard-target_0029"></span>
|
|
<p>Create a tar file of the source files.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>shar</samp></dt>
|
|
<dd><span id="index-shar-_0028standard-target_0029"></span>
|
|
<p>Create a shell archive (shar file) of the source files.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>dist</samp></dt>
|
|
<dd><span id="index-dist-_0028standard-target_0029"></span>
|
|
<p>Create a distribution file of the source files. This might
|
|
be a tar file, or a shar file, or a compressed version of one of the
|
|
above, or even more than one of the above.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>TAGS</samp></dt>
|
|
<dd><span id="index-TAGS-_0028standard-target_0029"></span>
|
|
<p>Update a tags table for this program.
|
|
</p>
|
|
</dd>
|
|
<dt><samp>check</samp></dt>
|
|
<dd><span id="index-check-_0028standard-target_0029"></span>
|
|
</dd>
|
|
<dt><samp>test</samp></dt>
|
|
<dd><span id="index-test-_0028standard-target_0029"></span>
|
|
<p>Perform self tests on the program this makefile builds.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Instead-of-Execution"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Avoiding-Compilation" accesskey="n" rel="next">Avoiding Compilation</a>, Previous: <a href="#Goals" accesskey="p" rel="prev">Goals</a>, Up: <a href="#Running" accesskey="u" rel="up">Running</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Instead-of-Executing-Recipes"></span><h3 class="section">9.3 Instead of Executing Recipes</h3>
|
|
<span id="index-execution_002c-instead-of"></span>
|
|
<span id="index-recipes_002c-instead-of-executing"></span>
|
|
|
|
<p>The makefile tells <code>make</code> how to tell whether a target is up to date,
|
|
and how to update each target. But updating the targets is not always
|
|
what you want. Certain options specify other activities for <code>make</code>.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>-n</samp>’</dt>
|
|
<dt>‘<samp>--just-print</samp>’</dt>
|
|
<dt>‘<samp>--dry-run</samp>’</dt>
|
|
<dt>‘<samp>--recon</samp>’</dt>
|
|
<dd><span id="index-_002d_002djust_002dprint-1"></span>
|
|
<span id="index-_002d_002ddry_002drun-1"></span>
|
|
<span id="index-_002d_002drecon-1"></span>
|
|
<span id="index-_002dn-1"></span>
|
|
|
|
<p>“No-op”. Causes <code>make</code> to print the recipes that are needed to
|
|
make the targets up to date, but not actually execute them. Note that
|
|
some recipes are still executed, even with this flag (see <a href="#MAKE-Variable">How the <code>MAKE</code> Variable Works</a>). Also any recipes
|
|
needed to update included makefiles are still executed
|
|
(see <a href="#Remaking-Makefiles">How Makefiles Are Remade</a>).
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-t</samp>’</dt>
|
|
<dt>‘<samp>--touch</samp>’</dt>
|
|
<dd><span id="index-_002d_002dtouch"></span>
|
|
<span id="index-touching-files"></span>
|
|
<span id="index-target_002c-touching"></span>
|
|
<span id="index-_002dt"></span>
|
|
|
|
<p>“Touch”. Marks targets as up to date without actually changing
|
|
them. In other words, <code>make</code> pretends to update the targets but
|
|
does not really change their contents; instead only their modified
|
|
times are updated.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-q</samp>’</dt>
|
|
<dt>‘<samp>--question</samp>’</dt>
|
|
<dd><span id="index-_002d_002dquestion"></span>
|
|
<span id="index-_002dq"></span>
|
|
<span id="index-question-mode"></span>
|
|
|
|
<p>“Question”. Silently check whether the targets are up to date, but
|
|
do not execute recipes; the exit code shows whether any updates are
|
|
needed.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-W <var>file</var></samp>’</dt>
|
|
<dt>‘<samp>--what-if=<var>file</var></samp>’</dt>
|
|
<dt>‘<samp>--assume-new=<var>file</var></samp>’</dt>
|
|
<dt>‘<samp>--new-file=<var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dwhat_002dif"></span>
|
|
<span id="index-_002dW"></span>
|
|
<span id="index-_002d_002dassume_002dnew"></span>
|
|
<span id="index-_002d_002dnew_002dfile"></span>
|
|
<span id="index-what-if"></span>
|
|
<span id="index-files_002c-assuming-new"></span>
|
|
|
|
<p>“What if”. Each ‘<samp>-W</samp>’ flag is followed by a file name. The given
|
|
files’ modification times are recorded by <code>make</code> as being the present
|
|
time, although the actual modification times remain the same.
|
|
You can use the ‘<samp>-W</samp>’ flag in conjunction with the ‘<samp>-n</samp>’ flag
|
|
to see what would happen if you were to modify specific files.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>With the ‘<samp>-n</samp>’ flag, <code>make</code> prints the recipe that it would
|
|
normally execute but usually does not execute it.
|
|
</p>
|
|
<p>With the ‘<samp>-t</samp>’ flag, <code>make</code> ignores the recipes in the rules
|
|
and uses (in effect) the command <code>touch</code> for each target that needs to
|
|
be remade. The <code>touch</code> command is also printed, unless ‘<samp>-s</samp>’ or
|
|
<code>.SILENT</code> is used. For speed, <code>make</code> does not actually invoke
|
|
the program <code>touch</code>. It does the work directly.
|
|
</p>
|
|
<p>With the ‘<samp>-q</samp>’ flag, <code>make</code> prints nothing and executes no
|
|
recipes, but the exit status code it returns is zero if and only if the
|
|
targets to be considered are already up to date. If the exit status is
|
|
one, then some updating needs to be done. If <code>make</code> encounters an
|
|
error, the exit status is two, so you can distinguish an error from a
|
|
target that is not up to date.
|
|
</p>
|
|
<p>It is an error to use more than one of these three flags in the same
|
|
invocation of <code>make</code>.
|
|
</p>
|
|
<span id="index-_002b_002c-and-recipe-execution"></span>
|
|
<p>The ‘<samp>-n</samp>’, ‘<samp>-t</samp>’, and ‘<samp>-q</samp>’ options do not affect recipe
|
|
lines that begin with ‘<samp>+</samp>’ characters or contain the strings
|
|
‘<samp>$(MAKE)</samp>’ or ‘<samp>${MAKE}</samp>’. Note that only the line containing
|
|
the ‘<samp>+</samp>’ character or the strings ‘<samp>$(MAKE)</samp>’ or ‘<samp>${MAKE}</samp>’
|
|
is run regardless of these options. Other lines in the same rule are
|
|
not run unless they too begin with ‘<samp>+</samp>’ or contain ‘<samp>$(MAKE)</samp>’ or
|
|
‘<samp>${MAKE}</samp>’ (See <a href="#MAKE-Variable">How the <code>MAKE</code> Variable Works</a>.)
|
|
</p>
|
|
<span id="index-phony-targets-and-recipe-execution"></span>
|
|
<p>The ‘<samp>-t</samp>’ flag prevents phony targets (see <a href="#Phony-Targets">Phony Targets</a>) from
|
|
being updated, unless there are recipe lines beginning with ‘<samp>+</samp>’
|
|
or containing ‘<samp>$(MAKE)</samp>’ or ‘<samp>${MAKE}</samp>’.
|
|
</p>
|
|
<p>The ‘<samp>-W</samp>’ flag provides two features:
|
|
</p>
|
|
<ul>
|
|
<li> If you also use the ‘<samp>-n</samp>’ or ‘<samp>-q</samp>’ flag, you can see what
|
|
<code>make</code> would do if you were to modify some files.
|
|
|
|
</li><li> Without the ‘<samp>-n</samp>’ or ‘<samp>-q</samp>’ flag, when <code>make</code> is actually
|
|
executing recipes, the ‘<samp>-W</samp>’ flag can direct <code>make</code> to act as
|
|
if some files had been modified, without actually running the recipes
|
|
for those files.
|
|
</li></ul>
|
|
|
|
<p>Note that the options ‘<samp>-p</samp>’ and ‘<samp>-v</samp>’ allow you to obtain other
|
|
information about <code>make</code> or about the makefiles in use
|
|
(see <a href="#Options-Summary">Summary of Options</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Avoiding-Compilation"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Overriding" accesskey="n" rel="next">Overriding</a>, Previous: <a href="#Instead-of-Execution" accesskey="p" rel="prev">Instead of Execution</a>, Up: <a href="#Running" accesskey="u" rel="up">Running</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Avoiding-Recompilation-of-Some-Files"></span><h3 class="section">9.4 Avoiding Recompilation of Some Files</h3>
|
|
<span id="index-_002do"></span>
|
|
<span id="index-_002d_002dold_002dfile"></span>
|
|
<span id="index-_002d_002dassume_002dold"></span>
|
|
<span id="index-files_002c-assuming-old"></span>
|
|
<span id="index-files_002c-avoiding-recompilation-of"></span>
|
|
<span id="index-recompilation_002c-avoiding"></span>
|
|
|
|
<p>Sometimes you may have changed a source file but you do not want to
|
|
recompile all the files that depend on it. For example, suppose you add
|
|
a macro or a declaration to a header file that many other files depend
|
|
on. Being conservative, <code>make</code> assumes that any change in the
|
|
header file requires recompilation of all dependent files, but you know
|
|
that they do not need to be recompiled and you would rather not waste
|
|
the time waiting for them to compile.
|
|
</p>
|
|
<p>If you anticipate the problem before changing the header file, you can
|
|
use the ‘<samp>-t</samp>’ flag. This flag tells <code>make</code> not to run the
|
|
recipes in the rules, but rather to mark the target up to date by
|
|
changing its last-modification date. You would follow this procedure:
|
|
</p>
|
|
<ol>
|
|
<li> Use the command ‘<samp>make</samp>’ to recompile the source files that really
|
|
need recompilation, ensuring that the object files are up-to-date
|
|
before you begin.
|
|
|
|
</li><li> Make the changes in the header files.
|
|
|
|
</li><li> Use the command ‘<samp>make -t</samp>’ to mark all the object files as
|
|
up to date. The next time you run <code>make</code>, the changes in the
|
|
header files will not cause any recompilation.
|
|
</li></ol>
|
|
|
|
<p>If you have already changed the header file at a time when some files
|
|
do need recompilation, it is too late to do this. Instead, you can
|
|
use the ‘<samp><span class="nolinebreak">-o</span> <var>file</var></samp>’<!-- /@w --> flag, which marks a specified file as
|
|
“old” (see <a href="#Options-Summary">Summary of Options</a>). This means
|
|
that the file itself will not be remade, and nothing else will be
|
|
remade on its account. Follow this procedure:
|
|
</p>
|
|
<ol>
|
|
<li> Recompile the source files that need compilation for reasons independent
|
|
of the particular header file, with ‘<samp>make -o <var>headerfile</var></samp>’.
|
|
If several header files are involved, use a separate ‘<samp>-o</samp>’ option
|
|
for each header file.
|
|
|
|
</li><li> Touch all the object files with ‘<samp>make -t</samp>’.
|
|
</li></ol>
|
|
|
|
<hr>
|
|
<span id="Overriding"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Testing" accesskey="n" rel="next">Testing</a>, Previous: <a href="#Avoiding-Compilation" accesskey="p" rel="prev">Avoiding Compilation</a>, Up: <a href="#Running" accesskey="u" rel="up">Running</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Overriding-Variables"></span><h3 class="section">9.5 Overriding Variables</h3>
|
|
<span id="index-overriding-variables-with-arguments"></span>
|
|
<span id="index-variables_002c-overriding-with-arguments"></span>
|
|
<span id="index-command-line-variables"></span>
|
|
<span id="index-variables_002c-command-line"></span>
|
|
|
|
<p>An argument that contains ‘<samp>=</samp>’ specifies the value of a variable:
|
|
‘<samp><var>v</var>=<var>x</var></samp>’ sets the value of the variable <var>v</var> to <var>x</var>.
|
|
If you specify a value in this way, all ordinary assignments of the same
|
|
variable in the makefile are ignored; we say they have been
|
|
<em>overridden</em> by the command line argument.
|
|
</p>
|
|
<p>The most common way to use this facility is to pass extra flags to
|
|
compilers. For example, in a properly written makefile, the variable
|
|
<code>CFLAGS</code> is included in each recipe that runs the C compiler, so a
|
|
file <samp>foo.c</samp> would be compiled something like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">cc -c $(CFLAGS) foo.c
|
|
</pre></div>
|
|
|
|
<p>Thus, whatever value you set for <code>CFLAGS</code> affects each compilation
|
|
that occurs. The makefile probably specifies the usual value for
|
|
<code>CFLAGS</code>, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">CFLAGS=-g
|
|
</pre></div>
|
|
|
|
<p>Each time you run <code>make</code>, you can override this value if you
|
|
wish. For example, if you say ‘<samp>make CFLAGS='-g -O'</samp>’, each C
|
|
compilation will be done with ‘<samp>cc -c -g -O</samp>’. (This also
|
|
illustrates how you can use quoting in the shell to enclose spaces and
|
|
other special characters in the value of a variable when you override
|
|
it.)
|
|
</p>
|
|
<p>The variable <code>CFLAGS</code> is only one of many standard variables that
|
|
exist just so that you can change them this way. See <a href="#Implicit-Variables">Variables Used by Implicit Rules</a>, for a complete list.
|
|
</p>
|
|
<p>You can also program the makefile to look at additional variables of your
|
|
own, giving the user the ability to control other aspects of how the
|
|
makefile works by changing the variables.
|
|
</p>
|
|
<p>When you override a variable with a command line argument, you can
|
|
define either a recursively-expanded variable or a simply-expanded
|
|
variable. The examples shown above make a recursively-expanded
|
|
variable; to make a simply-expanded variable, write ‘<samp>:=</samp>’ or
|
|
‘<samp>::=</samp>’ instead of ‘<samp>=</samp>’. But, unless you want to include a
|
|
variable reference or function call in the <em>value</em> that you
|
|
specify, it makes no difference which kind of variable you create.
|
|
</p>
|
|
<p>There is one way that the makefile can change a variable that you have
|
|
overridden. This is to use the <code>override</code> directive, which is a line
|
|
that looks like this: ‘<samp>override <var>variable</var> = <var>value</var></samp>’
|
|
(see <a href="#Override-Directive">The <code>override</code> Directive</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Testing"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Temporary-Files" accesskey="n" rel="next">Temporary Files</a>, Previous: <a href="#Overriding" accesskey="p" rel="prev">Overriding</a>, Up: <a href="#Running" accesskey="u" rel="up">Running</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Testing-the-Compilation-of-a-Program"></span><h3 class="section">9.6 Testing the Compilation of a Program</h3>
|
|
<span id="index-testing-compilation"></span>
|
|
<span id="index-compilation_002c-testing"></span>
|
|
|
|
<p>Normally, when an error happens in executing a shell command, <code>make</code>
|
|
gives up immediately, returning a nonzero status. No further recipes are
|
|
executed for any target. The error implies that the goal cannot be
|
|
correctly remade, and <code>make</code> reports this as soon as it knows.
|
|
</p>
|
|
<p>When you are compiling a program that you have just changed, this is not
|
|
what you want. Instead, you would rather that <code>make</code> try compiling
|
|
every file that can be tried, to show you as many compilation errors
|
|
as possible.
|
|
</p>
|
|
<span id="index-_002dk-1"></span>
|
|
<span id="index-_002d_002dkeep_002dgoing-1"></span>
|
|
<p>On these occasions, you should use the ‘<samp>-k</samp>’ or
|
|
‘<samp>--keep-going</samp>’ flag. This tells <code>make</code> to continue to
|
|
consider the other prerequisites of the pending targets, remaking them
|
|
if necessary, before it gives up and returns nonzero status. For
|
|
example, after an error in compiling one object file, ‘<samp>make -k</samp>’
|
|
will continue compiling other object files even though it already
|
|
knows that linking them will be impossible. In addition to continuing
|
|
after failed shell commands, ‘<samp>make -k</samp>’ will continue as much as
|
|
possible after discovering that it does not know how to make a target
|
|
or prerequisite file. This will always cause an error message, but
|
|
without ‘<samp>-k</samp>’, it is a fatal error (see <a href="#Options-Summary">Summary of Options</a>).
|
|
</p>
|
|
<p>The usual behavior of <code>make</code> assumes that your purpose is to get the
|
|
goals up to date; once <code>make</code> learns that this is impossible, it might
|
|
as well report the failure immediately. The ‘<samp>-k</samp>’ flag says that the
|
|
real purpose is to test as much as possible of the changes made in the
|
|
program, perhaps to find several independent problems so that you can
|
|
correct them all before the next attempt to compile. This is why Emacs’
|
|
<kbd>M-x compile</kbd> command passes the ‘<samp>-k</samp>’ flag by default.
|
|
</p>
|
|
<hr>
|
|
<span id="Temporary-Files"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Options-Summary" accesskey="n" rel="next">Options Summary</a>, Previous: <a href="#Testing" accesskey="p" rel="prev">Testing</a>, Up: <a href="#Running" accesskey="u" rel="up">Running</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Temporary-Files-1"></span><h3 class="section">9.7 Temporary Files</h3>
|
|
<span id="index-temporary-files"></span>
|
|
|
|
<p>In some situations, <code>make</code> will need to create its own temporary files.
|
|
These files must not be disturbed while <code>make</code> is running, including all
|
|
recursively-invoked instances of <code>make</code>.
|
|
</p>
|
|
<span id="index-MAKE_005fTMPDIR"></span>
|
|
<p>If the environment variable <code>MAKE_TMPDIR</code> is set then all temporary files
|
|
created by <code>make</code> will be placed there.
|
|
</p>
|
|
<span id="index-TMPDIR"></span>
|
|
<span id="index-TMP"></span>
|
|
<span id="index-TEMP"></span>
|
|
<p>If <code>MAKE_TMPDIR</code> is not set, then the standard location for temporary
|
|
files for the current operating system will be used. For POSIX systems this
|
|
will be the location set in the <code>TMPDIR</code> environment variable, or else
|
|
the system’s default location (e.g., <samp>/tmp</samp>) is used. On Windows,
|
|
first <code>TMP</code> then <code>TEMP</code> will be checked, then <code>TMPDIR</code>, and
|
|
finally the system default temporary file location will be used.
|
|
</p>
|
|
<p>Note that this directory must already exist or <code>make</code> will fail:
|
|
<code>make</code> will not attempt to create it.
|
|
</p>
|
|
<p>These variables <em>cannot</em> be set from within a makefile: GNU <code>make</code>
|
|
must have access to this location before it begins reading the makefiles.
|
|
</p>
|
|
<hr>
|
|
<span id="Options-Summary"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Temporary-Files" accesskey="p" rel="prev">Temporary Files</a>, Up: <a href="#Running" accesskey="u" rel="up">Running</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Summary-of-Options"></span><h3 class="section">9.8 Summary of Options</h3>
|
|
<span id="index-options"></span>
|
|
<span id="index-flags"></span>
|
|
<span id="index-switches"></span>
|
|
|
|
<p>Here is a table of all the options <code>make</code> understands:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>-b</samp>’</dt>
|
|
<dd><span id="index-_002db"></span>
|
|
</dd>
|
|
<dt>‘<samp>-m</samp>’</dt>
|
|
<dd><span id="index-_002dm"></span>
|
|
<p>These options are ignored for compatibility with other versions of <code>make</code>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-B</samp>’</dt>
|
|
<dd><span id="index-_002dB"></span>
|
|
</dd>
|
|
<dt>‘<samp>--always-make</samp>’</dt>
|
|
<dd><span id="index-_002d_002dalways_002dmake"></span>
|
|
<p>Consider all targets out-of-date. GNU <code>make</code> proceeds to
|
|
consider targets and their prerequisites using the normal algorithms;
|
|
however, all targets so considered are always remade regardless of the
|
|
status of their prerequisites. To avoid infinite recursion, if
|
|
<code>MAKE_RESTARTS</code> (see <a href="#Special-Variables">Other Special
|
|
Variables</a>) is set to a number greater than 0 this option is disabled
|
|
when considering whether to remake makefiles (see <a href="#Remaking-Makefiles">How Makefiles Are Remade</a>).
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-C <var>dir</var></samp>’</dt>
|
|
<dd><span id="index-_002dC-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--directory=<var>dir</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002ddirectory-1"></span>
|
|
<p>Change to directory <var>dir</var> before reading the makefiles. If multiple
|
|
‘<samp>-C</samp>’ options are specified, each is interpreted relative to the
|
|
previous one: ‘<samp>-C / -C etc</samp>’ is equivalent to ‘<samp>-C /etc</samp>’.
|
|
This is typically used with recursive invocations of <code>make</code>
|
|
(see <a href="#Recursion">Recursive Use of <code>make</code></a>).
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-d</samp>’</dt>
|
|
<dd><span id="index-_002dd"></span>
|
|
|
|
<p>Print debugging information in addition to normal processing. The
|
|
debugging information says which files are being considered for
|
|
remaking, which file-times are being compared and with what results,
|
|
which files actually need to be remade, which implicit rules are
|
|
considered and which are applied—everything interesting about how
|
|
<code>make</code> decides what to do. The <code>-d</code> option is equivalent to
|
|
‘<samp>--debug=a</samp>’ (see below).
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>--debug[=<var>options</var>]</samp>’</dt>
|
|
<dd><span id="index-_002d_002ddebug"></span>
|
|
|
|
<p>Print debugging information in addition to normal processing. Various
|
|
levels and types of output can be chosen. With no arguments, print the
|
|
“basic” level of debugging. Possible arguments are below; only the
|
|
first character is considered, and values must be comma- or
|
|
space-separated.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>a (<i>all</i>)</code></dt>
|
|
<dd><p>All types of debugging output are enabled. This is equivalent to using
|
|
‘<samp>-d</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>b (<i>basic</i>)</code></dt>
|
|
<dd><p>Basic debugging prints each target that was found to be out-of-date, and
|
|
whether the build was successful or not.
|
|
</p>
|
|
</dd>
|
|
<dt><code>v (<i>verbose</i>)</code></dt>
|
|
<dd><p>A level above ‘<samp>basic</samp>’; includes messages about which makefiles were
|
|
parsed, prerequisites that did not need to be rebuilt, etc. This option
|
|
also enables ‘<samp>basic</samp>’ messages.
|
|
</p>
|
|
</dd>
|
|
<dt><code>i (<i>implicit</i>)</code></dt>
|
|
<dd><p>Prints messages describing the implicit rule searches for each target.
|
|
This option also enables ‘<samp>basic</samp>’ messages.
|
|
</p>
|
|
</dd>
|
|
<dt><code>j (<i>jobs</i>)</code></dt>
|
|
<dd><p>Prints messages giving details on the invocation of specific sub-commands.
|
|
</p>
|
|
</dd>
|
|
<dt><code>m (<i>makefile</i>)</code></dt>
|
|
<dd><p>By default, the above messages are not enabled while trying to remake
|
|
the makefiles. This option enables messages while rebuilding makefiles,
|
|
too. Note that the ‘<samp>all</samp>’ option does enable this option. This
|
|
option also enables ‘<samp>basic</samp>’ messages.
|
|
</p>
|
|
</dd>
|
|
<dt><code>p (<i>print</i>)</code></dt>
|
|
<dd><p>Prints the recipe to be executed, even when the recipe is normally
|
|
silent (due to <code>.SILENT</code> or ‘<samp>@</samp>’). Also prints the makefile
|
|
name and line number where the recipe was defined.
|
|
</p>
|
|
</dd>
|
|
<dt><code>w (<i>why</i>)</code></dt>
|
|
<dd><p>Explains why each target must be remade by showing which prerequisites
|
|
are more up to date than the target.
|
|
</p>
|
|
</dd>
|
|
<dt><code>n (<i>none</i>)</code></dt>
|
|
<dd><p>Disable all debugging currently enabled. If additional debugging
|
|
flags are encountered after this they will still take effect.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
</dd>
|
|
<dt>‘<samp>-e</samp>’</dt>
|
|
<dd><span id="index-_002de"></span>
|
|
</dd>
|
|
<dt>‘<samp>--environment-overrides</samp>’</dt>
|
|
<dd><span id="index-_002d_002denvironment_002doverrides"></span>
|
|
<p>Give variables taken from the environment precedence
|
|
over variables from makefiles.
|
|
See <a href="#Environment">Variables from the Environment</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-E <var>string</var></samp>’</dt>
|
|
<dd><span id="index-_002dE"></span>
|
|
</dd>
|
|
<dt>‘<samp>--eval=<var>string</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002deval"></span>
|
|
|
|
<p>Evaluate <var>string</var> as makefile syntax. This is a command-line
|
|
version of the <code>eval</code> function (see <a href="#Eval-Function">Eval Function</a>). The
|
|
evaluation is performed after the default rules and variables have
|
|
been defined, but before any makefiles are read.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-f <var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002df-2"></span>
|
|
</dd>
|
|
<dt>‘<samp>--file=<var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dfile-2"></span>
|
|
</dd>
|
|
<dt>‘<samp>--makefile=<var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dmakefile-2"></span>
|
|
<p>Read the file named <var>file</var> as a makefile.
|
|
See <a href="#Makefiles">Writing Makefiles</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-h</samp>’</dt>
|
|
<dd><span id="index-_002dh"></span>
|
|
</dd>
|
|
<dt>‘<samp>--help</samp>’</dt>
|
|
<dd><span id="index-_002d_002dhelp"></span>
|
|
|
|
<p>Remind you of the options that <code>make</code> understands and then exit.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-i</samp>’</dt>
|
|
<dd><span id="index-_002di-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--ignore-errors</samp>’</dt>
|
|
<dd><span id="index-_002d_002dignore_002derrors-1"></span>
|
|
<p>Ignore all errors in recipes executed to remake files.
|
|
See <a href="#Errors">Errors in Recipes</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-I <var>dir</var></samp>’</dt>
|
|
<dd><span id="index-_002dI-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--include-dir=<var>dir</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dinclude_002ddir-1"></span>
|
|
<p>Specifies a directory <var>dir</var> to search for included makefiles.
|
|
See <a href="#Include">Including Other Makefiles</a>. If several ‘<samp>-I</samp>’
|
|
options are used to specify several directories, the directories are
|
|
searched in the order specified. If the directory <var>dir</var> is a
|
|
single dash (<code>-</code>) then any already-specified directories up to
|
|
that point (including the default directory paths) will be discarded.
|
|
You can examine the current list of directories to be searched via the
|
|
<code>.INCLUDE_DIRS</code> variable.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-j [<var>jobs</var>]</samp>’</dt>
|
|
<dd><span id="index-_002dj-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--jobs[=<var>jobs</var>]</samp>’</dt>
|
|
<dd><span id="index-_002d_002djobs-1"></span>
|
|
<p>Specifies the number of recipes (jobs) to run simultaneously. With no
|
|
argument, <code>make</code> runs as many recipes simultaneously as possible.
|
|
If there is more than one ‘<samp>-j</samp>’ option, the last one is effective.
|
|
See <a href="#Parallel">Parallel Execution</a>, for more information on how
|
|
recipes are run. Note that this option is ignored on MS-DOS.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>--jobserver-style=[<var>style</var>]</samp>’</dt>
|
|
<dd><span id="index-_002d_002djobserver_002dstyle"></span>
|
|
<p>Chooses the style of jobserver to use. This option only has effect if
|
|
parallel builds are enabled (see <a href="#Parallel">Parallel Execution</a>). On POSIX
|
|
systems <var>style</var> can be one of <code>fifo</code> (the default) or <code>pipe</code>.
|
|
On Windows the only acceptable <var>style</var> is <code>sem</code> (the default). This
|
|
option is useful if you need to use an older versions of GNU <code>make</code>, or a
|
|
different tool that requires a specific jobserver style.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-k</samp>’</dt>
|
|
<dd><span id="index-_002dk-2"></span>
|
|
</dd>
|
|
<dt>‘<samp>--keep-going</samp>’</dt>
|
|
<dd><span id="index-_002d_002dkeep_002dgoing-2"></span>
|
|
<p>Continue as much as possible after an error. While the target that
|
|
failed, and those that depend on it, cannot be remade, the other
|
|
prerequisites of these targets can be processed all the same.
|
|
See <a href="#Testing">Testing the Compilation of a Program</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-l [<var>load</var>]</samp>’</dt>
|
|
<dd><span id="index-_002dl"></span>
|
|
</dd>
|
|
<dt>‘<samp>--load-average[=<var>load</var>]</samp>’</dt>
|
|
<dd><span id="index-_002d_002dload_002daverage-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--max-load[=<var>load</var>]</samp>’</dt>
|
|
<dd><span id="index-_002d_002dmax_002dload-1"></span>
|
|
<p>Specifies that no new recipes should be started if there are other
|
|
recipes running and the load average is at least <var>load</var> (a
|
|
floating-point number). With no argument, removes a previous load
|
|
limit. See <a href="#Parallel">Parallel Execution</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-L</samp>’</dt>
|
|
<dd><span id="index-_002dL"></span>
|
|
</dd>
|
|
<dt>‘<samp>--check-symlink-times</samp>’</dt>
|
|
<dd><span id="index-_002d_002dcheck_002dsymlink_002dtimes"></span>
|
|
<p>On systems that support symbolic links, this option causes <code>make</code>
|
|
to consider the timestamps on any symbolic links in addition to the
|
|
timestamp on the file referenced by those links. When this option is
|
|
provided, the most recent timestamp among the file and the symbolic
|
|
links is taken as the modification time for this target file.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-n</samp>’</dt>
|
|
<dd><span id="index-_002dn-2"></span>
|
|
</dd>
|
|
<dt>‘<samp>--just-print</samp>’</dt>
|
|
<dd><span id="index-_002d_002djust_002dprint-2"></span>
|
|
</dd>
|
|
<dt>‘<samp>--dry-run</samp>’</dt>
|
|
<dd><span id="index-_002d_002ddry_002drun-2"></span>
|
|
</dd>
|
|
<dt>‘<samp>--recon</samp>’</dt>
|
|
<dd><span id="index-_002d_002drecon-2"></span>
|
|
|
|
<p>Print the recipe that would be executed, but do not execute it (except
|
|
in certain circumstances).
|
|
See <a href="#Instead-of-Execution">Instead of Executing Recipes</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-o <var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002do-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--old-file=<var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dold_002dfile-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--assume-old=<var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dassume_002dold-1"></span>
|
|
<p>Do not remake the file <var>file</var> even if it is older than its
|
|
prerequisites, and do not remake anything on account of changes in
|
|
<var>file</var>. Essentially the file is treated as very old and its rules
|
|
are ignored. See <a href="#Avoiding-Compilation">Avoiding Recompilation of
|
|
Some Files</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-O[<var>type</var>]</samp>’</dt>
|
|
<dd><span id="index-_002dO-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--output-sync[=<var>type</var>]</samp>’</dt>
|
|
<dd><span id="index-_002d_002doutput_002dsync-1"></span>
|
|
<span id="index-output-during-parallel-execution-1"></span>
|
|
<span id="index-parallel-execution_002c-output-during-1"></span>
|
|
<p>Ensure that the complete output from each recipe is printed in one
|
|
uninterrupted sequence. This option is only useful when using the
|
|
<code>--jobs</code> option to run multiple recipes simultaneously
|
|
(see <a href="#Parallel">Parallel Execution</a>) Without this option output
|
|
will be displayed as it is generated by the recipes.
|
|
</p>
|
|
<p>With no type or the type ‘<samp>target</samp>’, output from the entire recipe
|
|
of each target is grouped together. With the type ‘<samp>line</samp>’, output
|
|
from each line in the recipe is grouped together. With the type
|
|
‘<samp>recurse</samp>’, the output from an entire recursive make is grouped
|
|
together. With the type ‘<samp>none</samp>’, no output synchronization is
|
|
performed. See <a href="#Parallel-Output">Output During Parallel Execution</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-p</samp>’</dt>
|
|
<dd><span id="index-_002dp"></span>
|
|
</dd>
|
|
<dt>‘<samp>--print-data-base</samp>’</dt>
|
|
<dd><span id="index-_002d_002dprint_002ddata_002dbase"></span>
|
|
<span id="index-data-base-of-make-rules"></span>
|
|
<span id="index-predefined-rules-and-variables_002c-printing"></span>
|
|
<p>Print the data base (rules and variable values) that results from
|
|
reading the makefiles; then execute as usual or as otherwise
|
|
specified. This also prints the version information given by the
|
|
‘<samp>-v</samp>’ switch (see below). To print the data base without trying
|
|
to remake any files, use ‘<samp>make <span class="nolinebreak">-qp</span></samp>’<!-- /@w -->. To print the data base
|
|
of predefined rules and variables, use ‘<samp>make <span class="nolinebreak">-p</span> <span class="nolinebreak">-f</span> /dev/null</samp>’<!-- /@w -->.
|
|
The data base output contains file name and line number information for
|
|
recipe and variable definitions, so it can be a useful debugging tool
|
|
in complex environments.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-q</samp>’</dt>
|
|
<dd><span id="index-_002dq-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--question</samp>’</dt>
|
|
<dd><span id="index-_002d_002dquestion-1"></span>
|
|
<p>“Question mode”. Do not run any recipes, or print anything; just
|
|
return an exit status that is zero if the specified targets are already
|
|
up to date, one if any remaking is required, or two if an error is
|
|
encountered. See <a href="#Instead-of-Execution">Instead of Executing
|
|
Recipes</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-r</samp>’</dt>
|
|
<dd><span id="index-_002dr"></span>
|
|
</dd>
|
|
<dt>‘<samp>--no-builtin-rules</samp>’</dt>
|
|
<dd><span id="index-_002d_002dno_002dbuiltin_002drules"></span>
|
|
<p>Eliminate use of the built-in implicit rules (see <a href="#Implicit-Rules">Using Implicit Rules</a>). You can still define your own by writing
|
|
pattern rules (see <a href="#Pattern-Rules">Defining and Redefining Pattern
|
|
Rules</a>). The ‘<samp>-r</samp>’ option also clears out the default list of
|
|
suffixes for suffix rules (see <a href="#Suffix-Rules">Old-Fashioned Suffix
|
|
Rules</a>). But you can still define your own suffixes with a rule for
|
|
<code>.SUFFIXES</code>, and then define your own suffix rules. Note that only
|
|
<em>rules</em> are affected by the <code>-r</code> option; default variables
|
|
remain in effect (see <a href="#Implicit-Variables">Variables Used by Implicit
|
|
Rules</a>); see the ‘<samp>-R</samp>’ option below.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-R</samp>’</dt>
|
|
<dd><span id="index-_002dR"></span>
|
|
</dd>
|
|
<dt>‘<samp>--no-builtin-variables</samp>’</dt>
|
|
<dd><span id="index-_002d_002dno_002dbuiltin_002dvariables"></span>
|
|
<p>Eliminate use of the built-in rule-specific variables (see <a href="#Implicit-Variables">Variables Used by Implicit Rules</a>). You can still define
|
|
your own, of course. The ‘<samp>-R</samp>’ option also automatically enables
|
|
the ‘<samp>-r</samp>’ option (see above), since it doesn’t make sense to have
|
|
implicit rules without any definitions for the variables that they use.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-s</samp>’</dt>
|
|
<dd><span id="index-_002ds-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--silent</samp>’</dt>
|
|
<dd><span id="index-_002d_002dsilent-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--quiet</samp>’</dt>
|
|
<dd><span id="index-_002d_002dquiet-1"></span>
|
|
|
|
<p>Silent operation; do not print the recipes as they are executed.
|
|
See <a href="#Echoing">Recipe Echoing</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-S</samp>’</dt>
|
|
<dd><span id="index-_002dS"></span>
|
|
</dd>
|
|
<dt>‘<samp>--no-keep-going</samp>’</dt>
|
|
<dd><span id="index-_002d_002dno_002dkeep_002dgoing"></span>
|
|
</dd>
|
|
<dt>‘<samp>--stop</samp>’</dt>
|
|
<dd><span id="index-_002d_002dstop"></span>
|
|
|
|
<p>Cancel the effect of the ‘<samp>-k</samp>’ option. This is never necessary
|
|
except in a recursive <code>make</code> where ‘<samp>-k</samp>’ might be inherited
|
|
from the top-level <code>make</code> via <code>MAKEFLAGS</code>
|
|
(see <a href="#Recursion">Recursive Use of <code>make</code></a>)
|
|
or if you set ‘<samp>-k</samp>’ in <code>MAKEFLAGS</code> in your environment.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>--shuffle[=<var>mode</var>]</samp>’</dt>
|
|
<dd><span id="index-_002d_002dshuffle"></span>
|
|
|
|
<p>This option enables a form of fuzz-testing of prerequisite relationships.
|
|
When parallelism is enabled (‘<samp>-j</samp>’) the order in which targets are
|
|
built becomes less deterministic. If prerequisites are not fully declared
|
|
in the makefile this can lead to intermittent and hard-to-track-down build
|
|
failures.
|
|
</p>
|
|
<p>The ‘<samp>--shuffle</samp>’ option forces <code>make</code> to purposefully reorder goals
|
|
and prerequisites so target/prerequisite relationships still hold, but
|
|
ordering of prerequisites of a given target are reordered as described below.
|
|
</p>
|
|
<p>The order in which prerequisites are listed in automatic variables is not
|
|
changed by this option.
|
|
</p>
|
|
<p>The <code>.NOTPARALLEL</code> pseudo-target disables shuffling for that makefile.
|
|
Also any prerequisite list which contains <code>.WAIT</code> will not be shuffled.
|
|
See <a href="#Parallel-Disable">Disabling Parallel Execution</a>.
|
|
</p>
|
|
<p>The ‘<samp>--shuffle=</samp>’ option accepts these values:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>random</code></dt>
|
|
<dd><p>Choose a random seed for the shuffle. This is the default if no mode is
|
|
specified. The chosen seed is also provided to sub-<code>make</code> commands. The
|
|
seed is included in error messages so that it can be re-used in future runs to
|
|
reproduce the problem or verify that it has been resolved.
|
|
</p>
|
|
</dd>
|
|
<dt><code>reverse</code></dt>
|
|
<dd><p>Reverse the order of goals and prerequisites, rather than a random shuffle.
|
|
</p>
|
|
</dd>
|
|
<dt><code><var>seed</var></code></dt>
|
|
<dd><p>Use ‘<samp>random</samp>’ shuffle initialized with the specified seed value. The
|
|
<var>seed</var> is an integer.
|
|
</p>
|
|
</dd>
|
|
<dt><code>none</code></dt>
|
|
<dd><p>Disable shuffling. This negates any previous ‘<samp>--shuffle</samp>’ options.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
</dd>
|
|
<dt>‘<samp>-t</samp>’</dt>
|
|
<dd><span id="index-_002dt-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--touch</samp>’</dt>
|
|
<dd><span id="index-_002d_002dtouch-1"></span>
|
|
|
|
<p>Touch files (mark them up to date without really changing them)
|
|
instead of running their recipes. This is used to pretend that the
|
|
recipes were done, in order to fool future invocations of
|
|
<code>make</code>. See <a href="#Instead-of-Execution">Instead of Executing Recipes</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>--trace</samp>’</dt>
|
|
<dd><span id="index-_002d_002dtrace"></span>
|
|
<p>Show tracing information for <code>make</code> execution. Using <code>--trace</code> is
|
|
shorthand for <code>--debug=print,why</code>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-v</samp>’</dt>
|
|
<dd><span id="index-_002dv"></span>
|
|
</dd>
|
|
<dt>‘<samp>--version</samp>’</dt>
|
|
<dd><span id="index-_002d_002dversion"></span>
|
|
<p>Print the version of the <code>make</code> program plus a copyright, a list
|
|
of authors, and a notice that there is no warranty; then exit.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-w</samp>’</dt>
|
|
<dd><span id="index-_002dw"></span>
|
|
</dd>
|
|
<dt>‘<samp>--print-directory</samp>’</dt>
|
|
<dd><span id="index-_002d_002dprint_002ddirectory"></span>
|
|
<p>Print a message containing the working directory both before and after
|
|
executing the makefile. This may be useful for tracking down errors
|
|
from complicated nests of recursive <code>make</code> commands.
|
|
See <a href="#Recursion">Recursive Use of <code>make</code></a>. (In practice, you
|
|
rarely need to specify this option since ‘<samp>make</samp>’ does it for you;
|
|
see <a href="#g_t_002dw-Option">The ‘<samp>--print-directory</samp>’ Option</a>.)
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>--no-print-directory</samp>’</dt>
|
|
<dd><span id="index-_002d_002dno_002dprint_002ddirectory-1"></span>
|
|
<p>Disable printing of the working directory under <code>-w</code>.
|
|
This option is useful when <code>-w</code> is turned on automatically,
|
|
but you do not want to see the extra messages.
|
|
See <a href="#g_t_002dw-Option">The ‘<samp>--print-directory</samp>’ Option</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>-W <var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002dW-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--what-if=<var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dwhat_002dif-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--new-file=<var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dnew_002dfile-1"></span>
|
|
</dd>
|
|
<dt>‘<samp>--assume-new=<var>file</var></samp>’</dt>
|
|
<dd><span id="index-_002d_002dassume_002dnew-1"></span>
|
|
<p>Pretend that the target <var>file</var> has just been modified. When used
|
|
with the ‘<samp>-n</samp>’ flag, this shows you what would happen if you were
|
|
to modify that file. Without ‘<samp>-n</samp>’, it is almost the same as
|
|
running a <code>touch</code> command on the given file before running
|
|
<code>make</code>, except that the modification time is changed only in the
|
|
imagination of <code>make</code>.
|
|
See <a href="#Instead-of-Execution">Instead of Executing Recipes</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>--warn-undefined-variables</samp>’</dt>
|
|
<dd><span id="index-_002d_002dwarn_002dundefined_002dvariables"></span>
|
|
<span id="index-variables_002c-warning-for-undefined"></span>
|
|
<span id="index-undefined-variables_002c-warning-message"></span>
|
|
<p>Issue a warning message whenever <code>make</code> sees a reference to an
|
|
undefined variable. This can be helpful when you are trying to debug
|
|
makefiles which use variables in complex ways.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Implicit-Rules"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Archives" accesskey="n" rel="next">Archives</a>, Previous: <a href="#Running" accesskey="p" rel="prev">Running</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Using-Implicit-Rules"></span><h2 class="chapter">10 Using Implicit Rules</h2>
|
|
<span id="index-implicit-rule"></span>
|
|
<span id="index-rule_002c-implicit"></span>
|
|
|
|
<p>Certain standard ways of remaking target files are used very often. For
|
|
example, one customary way to make an object file is from a C source file
|
|
using the C compiler, <code>cc</code>.
|
|
</p>
|
|
<p><em>Implicit rules</em> tell <code>make</code> how to use customary techniques so
|
|
that you do not have to specify them in detail when you want to use
|
|
them. For example, there is an implicit rule for C compilation. File
|
|
names determine which implicit rules are run. For example, C
|
|
compilation typically takes a <samp>.c</samp> file and makes a <samp>.o</samp> file.
|
|
So <code>make</code> applies the implicit rule for C compilation when it sees
|
|
this combination of file name endings.
|
|
</p>
|
|
<p>A chain of implicit rules can apply in sequence; for example, <code>make</code>
|
|
will remake a <samp>.o</samp> file from a <samp>.y</samp> file by way of a <samp>.c</samp> file.
|
|
</p>
|
|
<p>The built-in implicit rules use several variables in their recipes so
|
|
that, by changing the values of the variables, you can change the way the
|
|
implicit rule works. For example, the variable <code>CFLAGS</code> controls the
|
|
flags given to the C compiler by the implicit rule for C compilation.
|
|
</p>
|
|
<p>You can define your own implicit rules by writing <em>pattern rules</em>.
|
|
</p>
|
|
<p><em>Suffix rules</em> are a more limited way to define implicit rules.
|
|
Pattern rules are more general and clearer, but suffix rules are
|
|
retained for compatibility.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Using-Implicit" accesskey="1">Using Implicit</a></td><td> </td><td align="left" valign="top">How to use an existing implicit rule
|
|
to get the recipes for updating a file.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Catalogue-of-Rules" accesskey="2">Catalogue of Rules</a></td><td> </td><td align="left" valign="top">A list of built-in rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Implicit-Variables" accesskey="3">Implicit Variables</a></td><td> </td><td align="left" valign="top">How to change what predefined rules do.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Chained-Rules" accesskey="4">Chained Rules</a></td><td> </td><td align="left" valign="top">How to use a chain of implicit rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Pattern-Rules" accesskey="5">Pattern Rules</a></td><td> </td><td align="left" valign="top">How to define new implicit rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Last-Resort" accesskey="6">Last Resort</a></td><td> </td><td align="left" valign="top">How to define a recipe for rules which
|
|
cannot find any.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Suffix-Rules" accesskey="7">Suffix Rules</a></td><td> </td><td align="left" valign="top">The old-fashioned style of implicit rule.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Implicit-Rule-Search" accesskey="8">Implicit Rule Search</a></td><td> </td><td align="left" valign="top">The precise algorithm for applying
|
|
implicit rules.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Using-Implicit"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Catalogue-of-Rules" accesskey="n" rel="next">Catalogue of Rules</a>, Previous: <a href="#Implicit-Rules" accesskey="p" rel="prev">Implicit Rules</a>, Up: <a href="#Implicit-Rules" accesskey="u" rel="up">Implicit Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Using-Implicit-Rules-1"></span><h3 class="section">10.1 Using Implicit Rules</h3>
|
|
<span id="index-implicit-rule_002c-how-to-use"></span>
|
|
<span id="index-rule_002c-implicit_002c-how-to-use"></span>
|
|
|
|
<p>To allow <code>make</code> to find a customary method for updating a target
|
|
file, all you have to do is refrain from specifying recipes yourself.
|
|
Either write a rule with no recipe, or don’t write a rule at all.
|
|
Then <code>make</code> will figure out which implicit rule to use based on
|
|
which kind of source file exists or can be made.
|
|
</p>
|
|
<p>For example, suppose the makefile looks like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo : foo.o bar.o
|
|
cc -o foo foo.o bar.o $(CFLAGS) $(LDFLAGS)
|
|
</pre></div>
|
|
|
|
<p>Because you mention <samp>foo.o</samp> but do not give a rule for it, <code>make</code>
|
|
will automatically look for an implicit rule that tells how to update it.
|
|
This happens whether or not the file <samp>foo.o</samp> currently exists.
|
|
</p>
|
|
<p>If an implicit rule is found, it can supply both a recipe and one or
|
|
more prerequisites (the source files). You would want to write a rule
|
|
for <samp>foo.o</samp> with no recipe if you need to specify additional
|
|
prerequisites, such as header files, that the implicit rule cannot
|
|
supply.
|
|
</p>
|
|
<p>Each implicit rule has a target pattern and prerequisite patterns. There may
|
|
be many implicit rules with the same target pattern. For example, numerous
|
|
rules make ‘<samp>.o</samp>’ files: one, from a ‘<samp>.c</samp>’ file with the C compiler;
|
|
another, from a ‘<samp>.p</samp>’ file with the Pascal compiler; and so on. The rule
|
|
that actually applies is the one whose prerequisites exist or can be made.
|
|
So, if you have a file <samp>foo.c</samp>, <code>make</code> will run the C compiler;
|
|
otherwise, if you have a file <samp>foo.p</samp>, <code>make</code> will run the Pascal
|
|
compiler; and so on.
|
|
</p>
|
|
<p>Of course, when you write the makefile, you know which implicit rule you
|
|
want <code>make</code> to use, and you know it will choose that one because you
|
|
know which possible prerequisite files are supposed to exist.
|
|
See <a href="#Catalogue-of-Rules">Catalogue of Built-In Rules</a>,
|
|
for a catalogue of all the predefined implicit rules.
|
|
</p>
|
|
<p>Above, we said an implicit rule applies if the required prerequisites “exist
|
|
or can be made”. A file “can be made” if it is mentioned explicitly in
|
|
the makefile as a target or a prerequisite, or if an implicit rule can be
|
|
recursively found for how to make it. When an implicit prerequisite is the
|
|
result of another implicit rule, we say that <em>chaining</em> is occurring.
|
|
See <a href="#Chained-Rules">Chains of Implicit Rules</a>.
|
|
</p>
|
|
<p>In general, <code>make</code> searches for an implicit rule for each target, and
|
|
for each double-colon rule, that has no recipe. A file that is mentioned
|
|
only as a prerequisite is considered a target whose rule specifies nothing,
|
|
so implicit rule search happens for it. See <a href="#Implicit-Rule-Search">Implicit Rule Search Algorithm</a>, for the
|
|
details of how the search is done.
|
|
</p>
|
|
<p>Note that explicit prerequisites do not influence implicit rule search.
|
|
For example, consider this explicit rule:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.o: foo.p
|
|
</pre></div>
|
|
|
|
<p>The prerequisite on <samp>foo.p</samp> does not necessarily mean that
|
|
<code>make</code> will remake <samp>foo.o</samp> according to the implicit rule to
|
|
make an object file, a <samp>.o</samp> file, from a Pascal source file, a
|
|
<samp>.p</samp> file. For example, if <samp>foo.c</samp> also exists, the implicit
|
|
rule to make an object file from a C source file is used instead,
|
|
because it appears before the Pascal rule in the list of predefined
|
|
implicit rules (see <a href="#Catalogue-of-Rules">Catalogue of Built-In
|
|
Rules</a>).
|
|
</p>
|
|
<p>If you do not want an implicit rule to be used for a target that has no
|
|
recipe, you can give that target an empty recipe by writing a semicolon
|
|
(see <a href="#Empty-Recipes">Defining Empty Recipes</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Catalogue-of-Rules"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Implicit-Variables" accesskey="n" rel="next">Implicit Variables</a>, Previous: <a href="#Using-Implicit" accesskey="p" rel="prev">Using Implicit</a>, Up: <a href="#Implicit-Rules" accesskey="u" rel="up">Implicit Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Catalogue-of-Built_002dIn-Rules"></span><h3 class="section">10.2 Catalogue of Built-In Rules</h3>
|
|
<span id="index-implicit-rule_002c-predefined"></span>
|
|
<span id="index-rule_002c-implicit_002c-predefined"></span>
|
|
|
|
<p>Here is a catalogue of predefined implicit rules which are always
|
|
available unless the makefile explicitly overrides or cancels them.
|
|
See <a href="#Canceling-Rules">Canceling Implicit Rules</a>, for information on
|
|
canceling or overriding an implicit rule. The ‘<samp>-r</samp>’ or
|
|
‘<samp>--no-builtin-rules</samp>’ option cancels all predefined rules.
|
|
</p>
|
|
<p>This manual only documents the default rules available on POSIX-based
|
|
operating systems. Other operating systems, such as VMS, Windows,
|
|
OS/2, etc. may have different sets of default rules. To see the full
|
|
list of default rules and variables available in your version of GNU
|
|
<code>make</code>, run ‘<samp>make -p</samp>’ in a directory with no makefile.
|
|
</p>
|
|
<p>Not all of these rules will always be defined, even when the ‘<samp>-r</samp>’
|
|
option is not given. Many of the predefined implicit rules are
|
|
implemented in <code>make</code> as suffix rules, so which ones will be
|
|
defined depends on the <em>suffix list</em> (the list of prerequisites of
|
|
the special target <code>.SUFFIXES</code>). The default suffix list is:
|
|
<code>.out</code>, <code>.a</code>, <code>.ln</code>, <code>.o</code>, <code>.c</code>, <code>.cc</code>,
|
|
<code>.C</code>, <code>.cpp</code>, <code>.p</code>, <code>.f</code>, <code>.F</code>, <code>.m</code>,
|
|
<code>.r</code>, <code>.y</code>, <code>.l</code>, <code>.ym</code>, <code>.lm</code>, <code>.s</code>,
|
|
<code>.S</code>, <code>.mod</code>, <code>.sym</code>, <code>.def</code>, <code>.h</code>,
|
|
<code>.info</code>, <code>.dvi</code>, <code>.tex</code>, <code>.texinfo</code>, <code>.texi</code>,
|
|
<code>.txinfo</code>, <code>.w</code>, <code>.ch</code> <code>.web</code>, <code>.sh</code>,
|
|
<code>.elc</code>, <code>.el</code>. All of the implicit rules described below
|
|
whose prerequisites have one of these suffixes are actually suffix
|
|
rules. If you modify the suffix list, the only predefined suffix
|
|
rules in effect will be those named by one or two of the suffixes that
|
|
are on the list you specify; rules whose suffixes fail to be on the
|
|
list are disabled. See <a href="#Suffix-Rules">Old-Fashioned Suffix Rules</a>,
|
|
for full details on suffix rules.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>Compiling C programs</dt>
|
|
<dd><span id="index-C_002c-rule-to-compile"></span>
|
|
<span id="index-cc"></span>
|
|
<span id="index-gcc"></span>
|
|
<span id="index-_002eo"></span>
|
|
<span id="index-_002ec"></span>
|
|
<p><samp><var>n</var>.o</samp> is made automatically from <samp><var>n</var>.c</samp> with
|
|
a recipe of the form ‘<samp>$(CC) $(CPPFLAGS) $(CFLAGS) <span class="nolinebreak">-c</span></samp>’<!-- /@w -->.
|
|
</p>
|
|
</dd>
|
|
<dt>Compiling C++ programs</dt>
|
|
<dd><span id="index-C_002b_002b_002c-rule-to-compile"></span>
|
|
<span id="index-g_002b_002b"></span>
|
|
<span id="index-_002ecc"></span>
|
|
<span id="index-_002ecpp"></span>
|
|
<span id="index-_002eC"></span>
|
|
<p><samp><var>n</var>.o</samp> is made automatically from <samp><var>n</var>.cc</samp>,
|
|
<samp><var>n</var>.cpp</samp>, or <samp><var>n</var>.C</samp> with a recipe of the form
|
|
‘<samp>$(CXX) $(CPPFLAGS) $(CXXFLAGS) <span class="nolinebreak">-c</span></samp>’<!-- /@w -->. We encourage you to use the
|
|
suffix ‘<samp>.cc</samp>’ or ‘<samp>.cpp</samp>’ for C++ source files instead of ‘<samp>.C</samp>’ to
|
|
better support case-insensitive file systems.
|
|
</p>
|
|
</dd>
|
|
<dt>Compiling Pascal programs</dt>
|
|
<dd><span id="index-Pascal_002c-rule-to-compile"></span>
|
|
<span id="index-pc"></span>
|
|
<span id="index-_002ep"></span>
|
|
<p><samp><var>n</var>.o</samp> is made automatically from <samp><var>n</var>.p</samp>
|
|
with the recipe ‘<samp>$(PC) $(PFLAGS) -c</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt>Compiling Fortran and Ratfor programs</dt>
|
|
<dd><span id="index-Fortran_002c-rule-to-compile"></span>
|
|
<span id="index-Ratfor_002c-rule-to-compile"></span>
|
|
<span id="index-f77"></span>
|
|
<span id="index-_002ef"></span>
|
|
<span id="index-_002er"></span>
|
|
<span id="index-_002eF"></span>
|
|
<p><samp><var>n</var>.o</samp> is made automatically from <samp><var>n</var>.r</samp>,
|
|
<samp><var>n</var>.F</samp> or <samp><var>n</var>.f</samp> by running the
|
|
Fortran compiler. The precise recipe used is as follows:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>.f</samp>’</dt>
|
|
<dd><p>‘<samp>$(FC) $(FFLAGS) -c</samp>’.
|
|
</p></dd>
|
|
<dt>‘<samp>.F</samp>’</dt>
|
|
<dd><p>‘<samp>$(FC) $(FFLAGS) $(CPPFLAGS) -c</samp>’.
|
|
</p></dd>
|
|
<dt>‘<samp>.r</samp>’</dt>
|
|
<dd><p>‘<samp>$(FC) $(FFLAGS) $(RFLAGS) -c</samp>’.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
</dd>
|
|
<dt>Preprocessing Fortran and Ratfor programs</dt>
|
|
<dd><p><samp><var>n</var>.f</samp> is made automatically from <samp><var>n</var>.r</samp> or
|
|
<samp><var>n</var>.F</samp>. This rule runs just the preprocessor to convert a
|
|
Ratfor or preprocessable Fortran program into a strict Fortran
|
|
program. The precise recipe used is as follows:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>.F</samp>’</dt>
|
|
<dd><p>‘<samp>$(FC) $(CPPFLAGS) $(FFLAGS) -F</samp>’.
|
|
</p></dd>
|
|
<dt>‘<samp>.r</samp>’</dt>
|
|
<dd><p>‘<samp>$(FC) $(FFLAGS) $(RFLAGS) -F</samp>’.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
</dd>
|
|
<dt>Compiling Modula-2 programs</dt>
|
|
<dd><span id="index-Modula_002d2_002c-rule-to-compile"></span>
|
|
<span id="index-m2c"></span>
|
|
<span id="index-_002esym"></span>
|
|
<span id="index-_002edef"></span>
|
|
<span id="index-_002emod"></span>
|
|
<p><samp><var>n</var>.sym</samp> is made from <samp><var>n</var>.def</samp> with a recipe of the form
|
|
‘<samp>$(M2C) $(M2FLAGS) $(DEFFLAGS)</samp>’<!-- /@w -->. <samp><var>n</var>.o</samp> is made from
|
|
<samp><var>n</var>.mod</samp>; the form is: ‘<samp>$(M2C) $(M2FLAGS) $(MODFLAGS)</samp>’<!-- /@w -->.
|
|
</p>
|
|
</dd>
|
|
<dt>Assembling and preprocessing assembler programs</dt>
|
|
<dd><span id="index-assembly_002c-rule-to-compile"></span>
|
|
<span id="index-as"></span>
|
|
<span id="index-_002es"></span>
|
|
<p><samp><var>n</var>.o</samp> is made automatically from <samp><var>n</var>.s</samp> by
|
|
running the assembler, <code>as</code>. The precise recipe is
|
|
‘<samp>$(AS) $(ASFLAGS)</samp>’.
|
|
</p>
|
|
<span id="index-_002eS"></span>
|
|
<p><samp><var>n</var>.s</samp> is made automatically from <samp><var>n</var>.S</samp> by
|
|
running the C preprocessor, <code>cpp</code>. The precise recipe is
|
|
‘<samp>$(CPP) $(CPPFLAGS)</samp>’<!-- /@w -->.
|
|
</p>
|
|
</dd>
|
|
<dt>Linking a single object file</dt>
|
|
<dd><span id="index-linking_002c-predefined-rule-for"></span>
|
|
<span id="index-ld"></span>
|
|
<span id="index-_002eo-1"></span>
|
|
<p><samp><var>n</var></samp> is made automatically from <samp><var>n</var>.o</samp> by running the C
|
|
compiler to link the program. The precise recipe used is ‘<samp>$(CC) $(LDFLAGS) <var>n</var>.o $(LOADLIBES) $(LDLIBS)</samp>’<!-- /@w -->.
|
|
</p>
|
|
<p>This rule does the right thing for a simple program with only one
|
|
source file. It will also do the right thing if there are multiple
|
|
object files (presumably coming from various other source files), one
|
|
of which has a name matching that of the executable file. Thus,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">x: y.o z.o
|
|
</pre></div>
|
|
|
|
<p>when <samp>x.c</samp>, <samp>y.c</samp> and <samp>z.c</samp> all exist will execute:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">cc -c x.c -o x.o
|
|
cc -c y.c -o y.o
|
|
cc -c z.c -o z.o
|
|
cc x.o y.o z.o -o x
|
|
rm -f x.o
|
|
rm -f y.o
|
|
rm -f z.o
|
|
</pre></div>
|
|
|
|
<p>In more complicated cases, such as when there is no object file whose
|
|
name derives from the executable file name, you must write an explicit
|
|
recipe for linking.
|
|
</p>
|
|
<p>Each kind of file automatically made into ‘<samp>.o</samp>’ object files will
|
|
be automatically linked by using the compiler (‘<samp>$(CC)</samp>’,
|
|
‘<samp>$(FC)</samp>’ or ‘<samp>$(PC)</samp>’; the C compiler ‘<samp>$(CC)</samp>’ is used to
|
|
assemble ‘<samp>.s</samp>’ files) without the ‘<samp>-c</samp>’ option. This could be
|
|
done by using the ‘<samp>.o</samp>’ object files as intermediates, but it is
|
|
faster to do the compiling and linking in one step, so that’s how it’s
|
|
done.
|
|
</p>
|
|
</dd>
|
|
<dt>Yacc for C programs</dt>
|
|
<dd><span id="index-yacc-1"></span>
|
|
<span id="index-Yacc_002c-rule-to-run"></span>
|
|
<span id="index-_002ey"></span>
|
|
<p><samp><var>n</var>.c</samp> is made automatically from <samp><var>n</var>.y</samp> by
|
|
running Yacc with the recipe ‘<samp>$(YACC) $(YFLAGS)</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt>Lex for C programs</dt>
|
|
<dd><span id="index-lex"></span>
|
|
<span id="index-Lex_002c-rule-to-run"></span>
|
|
<span id="index-_002el"></span>
|
|
<p><samp><var>n</var>.c</samp> is made automatically from <samp><var>n</var>.l</samp> by
|
|
running Lex. The actual recipe is ‘<samp>$(LEX) $(LFLAGS)</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt>Lex for Ratfor programs</dt>
|
|
<dd><p><samp><var>n</var>.r</samp> is made automatically from <samp><var>n</var>.l</samp> by
|
|
running Lex. The actual recipe is ‘<samp>$(LEX) $(LFLAGS)</samp>’.
|
|
</p>
|
|
<p>The convention of using the same suffix ‘<samp>.l</samp>’ for all Lex files
|
|
regardless of whether they produce C code or Ratfor code makes it
|
|
impossible for <code>make</code> to determine automatically which of the two
|
|
languages you are using in any particular case. If <code>make</code> is
|
|
called upon to remake an object file from a ‘<samp>.l</samp>’ file, it must
|
|
guess which compiler to use. It will guess the C compiler, because
|
|
that is more common. If you are using Ratfor, make sure <code>make</code>
|
|
knows this by mentioning <samp><var>n</var>.r</samp> in the makefile. Or, if you
|
|
are using Ratfor exclusively, with no C files, remove ‘<samp>.c</samp>’ from
|
|
the list of implicit rule suffixes with:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SUFFIXES:
|
|
.SUFFIXES: .o .r .f .l …
|
|
</pre></div>
|
|
|
|
</dd>
|
|
<dt>Making Lint Libraries from C, Yacc, or Lex programs</dt>
|
|
<dd><span id="index-lint"></span>
|
|
<span id="index-lint_002c-rule-to-run"></span>
|
|
<span id="index-_002eln"></span>
|
|
<p><samp><var>n</var>.ln</samp> is made from <samp><var>n</var>.c</samp> by running <code>lint</code>.
|
|
The precise recipe is ‘<samp>$(LINT) $(LINTFLAGS) $(CPPFLAGS) <span class="nolinebreak">-i</span></samp>’<!-- /@w -->.
|
|
The same recipe is used on the C code produced from
|
|
<samp><var>n</var>.y</samp> or <samp><var>n</var>.l</samp>.
|
|
</p>
|
|
</dd>
|
|
<dt>TeX and Web</dt>
|
|
<dd><span id="index-TeX_002c-rule-to-run"></span>
|
|
<span id="index-Web_002c-rule-to-run"></span>
|
|
<span id="index-tex"></span>
|
|
<span id="index-cweave"></span>
|
|
<span id="index-weave"></span>
|
|
<span id="index-tangle"></span>
|
|
<span id="index-ctangle"></span>
|
|
<span id="index-_002edvi"></span>
|
|
<span id="index-_002etex"></span>
|
|
<span id="index-_002eweb"></span>
|
|
<span id="index-_002ew"></span>
|
|
<span id="index-_002ech"></span>
|
|
<p><samp><var>n</var>.dvi</samp> is made from <samp><var>n</var>.tex</samp> with the recipe
|
|
‘<samp>$(TEX)</samp>’. <samp><var>n</var>.tex</samp> is made from <samp><var>n</var>.web</samp> with
|
|
‘<samp>$(WEAVE)</samp>’, or from <samp><var>n</var>.w</samp> (and from <samp><var>n</var>.ch</samp> if
|
|
it exists or can be made) with ‘<samp>$(CWEAVE)</samp>’. <samp><var>n</var>.p</samp> is
|
|
made from <samp><var>n</var>.web</samp> with ‘<samp>$(TANGLE)</samp>’ and <samp><var>n</var>.c</samp>
|
|
is made from <samp><var>n</var>.w</samp> (and from <samp><var>n</var>.ch</samp> if it exists
|
|
or can be made) with ‘<samp>$(CTANGLE)</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt>Texinfo and Info</dt>
|
|
<dd><span id="index-Texinfo_002c-rule-to-format"></span>
|
|
<span id="index-Info_002c-rule-to-format"></span>
|
|
<span id="index-texi2dvi"></span>
|
|
<span id="index-makeinfo"></span>
|
|
<span id="index-_002etexinfo"></span>
|
|
<span id="index-_002einfo"></span>
|
|
<span id="index-_002etexi"></span>
|
|
<span id="index-_002etxinfo"></span>
|
|
<p><samp><var>n</var>.dvi</samp> is made from <samp><var>n</var>.texinfo</samp>,
|
|
<samp><var>n</var>.texi</samp>, or <samp><var>n</var>.txinfo</samp>, with the recipe
|
|
‘<samp>$(TEXI2DVI) <span class="nolinebreak">$(TEXI2DVI_FLAGS)</span></samp>’<!-- /@w -->. <samp><var>n</var>.info</samp> is made from
|
|
<samp><var>n</var>.texinfo</samp>, <samp><var>n</var>.texi</samp>, or <samp><var>n</var>.txinfo</samp>, with
|
|
the recipe ‘<samp>$(MAKEINFO) <span class="nolinebreak">$(MAKEINFO_FLAGS)</span></samp>’<!-- /@w -->.
|
|
</p>
|
|
</dd>
|
|
<dt>RCS</dt>
|
|
<dd><span id="index-RCS_002c-rule-to-extract-from"></span>
|
|
<span id="index-co"></span>
|
|
<span id="index-_002cv-_0028RCS-file-extension_0029"></span>
|
|
<p>Any file <samp><var>n</var></samp> is extracted if necessary from an RCS file
|
|
named either <samp><var>n</var>,v</samp> or <samp>RCS/<var>n</var>,v</samp>. The precise
|
|
recipe used is ‘<samp>$(CO) $(COFLAGS)</samp>’<!-- /@w -->. <samp><var>n</var></samp> will not be
|
|
extracted from RCS if it already exists, even if the RCS file is
|
|
newer. The rules for RCS are terminal
|
|
(see <a href="#Match_002dAnything-Rules">Match-Anything Pattern Rules</a>),
|
|
so RCS files cannot be generated from another source; they must
|
|
actually exist.
|
|
</p>
|
|
</dd>
|
|
<dt>SCCS</dt>
|
|
<dd><span id="index-SCCS_002c-rule-to-extract-from"></span>
|
|
<span id="index-get"></span>
|
|
<span id="index-s_002e-_0028SCCS-file-prefix_0029"></span>
|
|
<p>Any file <samp><var>n</var></samp> is extracted if necessary from an SCCS file
|
|
named either <samp>s.<var>n</var></samp> or <samp>SCCS/s.<var>n</var></samp>. The precise
|
|
recipe used is ‘<samp>$(GET) $(GFLAGS)</samp>’<!-- /@w -->. The rules for SCCS are
|
|
terminal (see <a href="#Match_002dAnything-Rules">Match-Anything Pattern Rules</a>),
|
|
so SCCS files cannot be generated from another source; they must
|
|
actually exist.
|
|
</p>
|
|
<span id="index-_002esh"></span>
|
|
<p>For the benefit of SCCS, a file <samp><var>n</var></samp> is copied from
|
|
<samp><var>n</var>.sh</samp> and made executable (by everyone). This is for
|
|
shell scripts that are checked into SCCS. Since RCS preserves the
|
|
execution permission of a file, you do not need to use this feature
|
|
with RCS.
|
|
</p>
|
|
<p>We recommend that you avoid using of SCCS. RCS is widely held to be
|
|
superior, and is also free. By choosing free software in place of
|
|
comparable (or inferior) proprietary software, you support the free
|
|
software movement.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Usually, you want to change only the variables listed in the table
|
|
above, which are documented in the following section.
|
|
</p>
|
|
<p>However, the recipes in built-in implicit rules actually use
|
|
variables such as <code>COMPILE.c</code>, <code>LINK.p</code>, and
|
|
<code>PREPROCESS.S</code>, whose values contain the recipes listed above.
|
|
</p>
|
|
<p><code>make</code> follows the convention that the rule to compile a
|
|
<samp>.<var>x</var></samp> source file uses the variable <code>COMPILE.<var>x</var></code>.
|
|
Similarly, the rule to produce an executable from a <samp>.<var>x</var></samp>
|
|
file uses <code>LINK.<var>x</var></code>; and the rule to preprocess a
|
|
<samp>.<var>x</var></samp> file uses <code>PREPROCESS.<var>x</var></code>.
|
|
</p>
|
|
<span id="index-OUTPUT_005fOPTION"></span>
|
|
<p>Every rule that produces an object file uses the variable
|
|
<code>OUTPUT_OPTION</code>. <code>make</code> defines this variable either to
|
|
contain ‘<samp>-o $@</samp>’, or to be empty, depending on a compile-time
|
|
option. You need the ‘<samp>-o</samp>’ option to ensure that the output goes
|
|
into the right file when the source file is in a different directory,
|
|
as when using <code>VPATH</code> (see <a href="#Directory-Search">Directory Search</a>). However,
|
|
compilers on some systems do not accept a ‘<samp>-o</samp>’ switch for object
|
|
files. If you use such a system, and use <code>VPATH</code>, some
|
|
compilations will put their output in the wrong place.
|
|
A possible workaround for this problem is to give <code>OUTPUT_OPTION</code>
|
|
the value ‘<samp>; mv $*.o $@</samp>’<!-- /@w -->.
|
|
</p>
|
|
<hr>
|
|
<span id="Implicit-Variables"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Chained-Rules" accesskey="n" rel="next">Chained Rules</a>, Previous: <a href="#Catalogue-of-Rules" accesskey="p" rel="prev">Catalogue of Rules</a>, Up: <a href="#Implicit-Rules" accesskey="u" rel="up">Implicit Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Variables-Used-by-Implicit-Rules"></span><h3 class="section">10.3 Variables Used by Implicit Rules</h3>
|
|
<span id="index-flags-for-compilers"></span>
|
|
|
|
<p>The recipes in built-in implicit rules make liberal use of certain
|
|
predefined variables. You can alter the values of these variables in
|
|
the makefile, with arguments to <code>make</code>, or in the environment to
|
|
alter how the implicit rules work without redefining the rules
|
|
themselves. You can cancel all variables used by implicit rules with
|
|
the ‘<samp>-R</samp>’ or ‘<samp>--no-builtin-variables</samp>’ option.
|
|
</p>
|
|
<p>For example, the recipe used to compile a C source file actually says
|
|
‘<samp>$(CC) -c $(CFLAGS) $(CPPFLAGS)</samp>’. The default values of the variables
|
|
used are ‘<samp>cc</samp>’ and nothing, resulting in the command ‘<samp>cc -c</samp>’. By
|
|
redefining ‘<samp>CC</samp>’ to ‘<samp>ncc</samp>’, you could cause ‘<samp>ncc</samp>’ to be
|
|
used for all C compilations performed by the implicit rule. By redefining
|
|
‘<samp>CFLAGS</samp>’ to be ‘<samp>-g</samp>’, you could pass the ‘<samp>-g</samp>’ option to
|
|
each compilation. <em>All</em> implicit rules that do C compilation use
|
|
‘<samp>$(CC)</samp>’ to get the program name for the compiler and <em>all</em>
|
|
include ‘<samp>$(CFLAGS)</samp>’ among the arguments given to the compiler.
|
|
</p>
|
|
<p>The variables used in implicit rules fall into two classes: those that are
|
|
names of programs (like <code>CC</code>) and those that contain arguments for the
|
|
programs (like <code>CFLAGS</code>). (The “name of a program” may also contain
|
|
some command arguments, but it must start with an actual executable program
|
|
name.) If a variable value contains more than one argument, separate them
|
|
with spaces.
|
|
</p>
|
|
<p>The following tables describe of some of the more commonly-used predefined
|
|
variables. This list is not exhaustive, and the default values shown here may
|
|
not be what <code>make</code> selects for your environment. To see the
|
|
complete list of predefined variables for your instance of GNU <code>make</code> you
|
|
can run ‘<samp>make -p</samp>’ in a directory with no makefiles.
|
|
</p>
|
|
<p>Here is a table of some of the more common variables used as names of
|
|
programs in built-in rules:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>AR</code></dt>
|
|
<dd><span id="index-AR"></span>
|
|
<p>Archive-maintaining program; default ‘<samp>ar</samp>’.
|
|
<span id="index-ar"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>AS</code></dt>
|
|
<dd><span id="index-AS"></span>
|
|
<p>Program for compiling assembly files; default ‘<samp>as</samp>’.
|
|
<span id="index-as-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>CC</code></dt>
|
|
<dd><span id="index-CC"></span>
|
|
<p>Program for compiling C programs; default ‘<samp>cc</samp>’.
|
|
<span id="index-cc-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>CXX</code></dt>
|
|
<dd><span id="index-CXX"></span>
|
|
<p>Program for compiling C++ programs; default ‘<samp>g++</samp>’.
|
|
<span id="index-g_002b_002b-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>CPP</code></dt>
|
|
<dd><span id="index-CPP"></span>
|
|
<p>Program for running the C preprocessor, with results to standard output;
|
|
default ‘<samp>$(CC) -E</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>FC</code></dt>
|
|
<dd><span id="index-FC"></span>
|
|
<p>Program for compiling or preprocessing Fortran and Ratfor programs;
|
|
default ‘<samp>f77</samp>’.
|
|
<span id="index-f77-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>M2C</code></dt>
|
|
<dd><span id="index-M2C"></span>
|
|
<p>Program to use to compile Modula-2 source code; default ‘<samp>m2c</samp>’.
|
|
<span id="index-m2c-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>PC</code></dt>
|
|
<dd><span id="index-PC"></span>
|
|
<p>Program for compiling Pascal programs; default ‘<samp>pc</samp>’.
|
|
<span id="index-pc-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>CO</code></dt>
|
|
<dd><span id="index-CO"></span>
|
|
<p>Program for extracting a file from RCS; default ‘<samp>co</samp>’.
|
|
<span id="index-co-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>GET</code></dt>
|
|
<dd><span id="index-GET"></span>
|
|
<p>Program for extracting a file from SCCS; default ‘<samp>get</samp>’.
|
|
<span id="index-get-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>LEX</code></dt>
|
|
<dd><span id="index-LEX"></span>
|
|
<p>Program to use to turn Lex grammars into source code; default ‘<samp>lex</samp>’.
|
|
<span id="index-lex-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>YACC</code></dt>
|
|
<dd><span id="index-YACC"></span>
|
|
<p>Program to use to turn Yacc grammars into source code; default ‘<samp>yacc</samp>’.
|
|
<span id="index-yacc-2"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>LINT</code></dt>
|
|
<dd><span id="index-LINT"></span>
|
|
<p>Program to use to run lint on source code; default ‘<samp>lint</samp>’.
|
|
<span id="index-lint-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>MAKEINFO</code></dt>
|
|
<dd><span id="index-MAKEINFO"></span>
|
|
<p>Program to convert a Texinfo source file into an Info file; default
|
|
‘<samp>makeinfo</samp>’.
|
|
<span id="index-makeinfo-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>TEX</code></dt>
|
|
<dd><span id="index-TEX"></span>
|
|
<p>Program to make TeX <small>DVI</small> files from TeX source;
|
|
default ‘<samp>tex</samp>’.
|
|
<span id="index-tex-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>TEXI2DVI</code></dt>
|
|
<dd><span id="index-TEXI2DVI"></span>
|
|
<p>Program to make TeX <small>DVI</small> files from Texinfo source;
|
|
default ‘<samp>texi2dvi</samp>’.
|
|
<span id="index-texi2dvi-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>WEAVE</code></dt>
|
|
<dd><span id="index-WEAVE"></span>
|
|
<p>Program to translate Web into TeX; default ‘<samp>weave</samp>’.
|
|
<span id="index-weave-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>CWEAVE</code></dt>
|
|
<dd><span id="index-CWEAVE"></span>
|
|
<p>Program to translate C Web into TeX; default ‘<samp>cweave</samp>’.
|
|
<span id="index-cweave-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>TANGLE</code></dt>
|
|
<dd><span id="index-TANGLE"></span>
|
|
<p>Program to translate Web into Pascal; default ‘<samp>tangle</samp>’.
|
|
<span id="index-tangle-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>CTANGLE</code></dt>
|
|
<dd><span id="index-CTANGLE"></span>
|
|
<p>Program to translate C Web into C; default ‘<samp>ctangle</samp>’.
|
|
<span id="index-ctangle-1"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>RM</code></dt>
|
|
<dd><span id="index-RM"></span>
|
|
<p>Command to remove a file; default ‘<samp>rm -f</samp>’.
|
|
<span id="index-rm"></span>
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Here is a table of variables whose values are additional arguments for the
|
|
programs above. The default values for all of these is the empty
|
|
string, unless otherwise noted.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>ARFLAGS</code></dt>
|
|
<dd><span id="index-ARFLAGS"></span>
|
|
<p>Flags to give the archive-maintaining program; default ‘<samp>rv</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt><code>ASFLAGS</code></dt>
|
|
<dd><span id="index-ASFLAGS"></span>
|
|
<p>Extra flags to give to the assembler (when explicitly
|
|
invoked on a ‘<samp>.s</samp>’ or ‘<samp>.S</samp>’ file).
|
|
</p>
|
|
</dd>
|
|
<dt><code>CFLAGS</code></dt>
|
|
<dd><span id="index-CFLAGS"></span>
|
|
<p>Extra flags to give to the C compiler.
|
|
</p>
|
|
</dd>
|
|
<dt><code>CXXFLAGS</code></dt>
|
|
<dd><span id="index-CXXFLAGS"></span>
|
|
<p>Extra flags to give to the C++ compiler.
|
|
</p>
|
|
</dd>
|
|
<dt><code>COFLAGS</code></dt>
|
|
<dd><span id="index-COFLAGS"></span>
|
|
<p>Extra flags to give to the RCS <code>co</code> program.
|
|
</p>
|
|
</dd>
|
|
<dt><code>CPPFLAGS</code></dt>
|
|
<dd><span id="index-CPPFLAGS"></span>
|
|
<p>Extra flags to give to the C preprocessor and programs
|
|
that use it (the C and Fortran compilers).
|
|
</p>
|
|
</dd>
|
|
<dt><code>FFLAGS</code></dt>
|
|
<dd><span id="index-FFLAGS"></span>
|
|
<p>Extra flags to give to the Fortran compiler.
|
|
</p>
|
|
</dd>
|
|
<dt><code>GFLAGS</code></dt>
|
|
<dd><span id="index-GFLAGS"></span>
|
|
<p>Extra flags to give to the SCCS <code>get</code> program.
|
|
</p>
|
|
</dd>
|
|
<dt><code>LDFLAGS</code></dt>
|
|
<dd><span id="index-LDFLAGS"></span>
|
|
<p>Extra flags to give to compilers when they are supposed to invoke the linker,
|
|
‘<samp>ld</samp>’, such as <code>-L</code>. Libraries (<code>-lfoo</code>) should be
|
|
added to the <code>LDLIBS</code> variable instead.
|
|
</p>
|
|
</dd>
|
|
<dt><code>LDLIBS</code></dt>
|
|
<dd><span id="index-LDLIBS"></span>
|
|
<span id="index-LOADLIBES"></span>
|
|
<p>Library flags or names given to compilers when they are supposed to
|
|
invoke the linker, ‘<samp>ld</samp>’. <code>LOADLIBES</code> is a deprecated (but
|
|
still supported) alternative to <code>LDLIBS</code>. Non-library linker
|
|
flags, such as <code>-L</code>, should go in the <code>LDFLAGS</code> variable.
|
|
</p>
|
|
</dd>
|
|
<dt><code>LFLAGS</code></dt>
|
|
<dd><span id="index-LFLAGS"></span>
|
|
<p>Extra flags to give to Lex.
|
|
</p>
|
|
</dd>
|
|
<dt><code>YFLAGS</code></dt>
|
|
<dd><span id="index-YFLAGS"></span>
|
|
<p>Extra flags to give to Yacc.
|
|
</p>
|
|
</dd>
|
|
<dt><code>PFLAGS</code></dt>
|
|
<dd><span id="index-PFLAGS"></span>
|
|
<p>Extra flags to give to the Pascal compiler.
|
|
</p>
|
|
</dd>
|
|
<dt><code>RFLAGS</code></dt>
|
|
<dd><span id="index-RFLAGS"></span>
|
|
<p>Extra flags to give to the Fortran compiler for Ratfor programs.
|
|
</p>
|
|
</dd>
|
|
<dt><code>LINTFLAGS</code></dt>
|
|
<dd><span id="index-LINTFLAGS"></span>
|
|
<p>Extra flags to give to lint.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Chained-Rules"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Pattern-Rules" accesskey="n" rel="next">Pattern Rules</a>, Previous: <a href="#Implicit-Variables" accesskey="p" rel="prev">Implicit Variables</a>, Up: <a href="#Implicit-Rules" accesskey="u" rel="up">Implicit Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Chains-of-Implicit-Rules"></span><h3 class="section">10.4 Chains of Implicit Rules</h3>
|
|
|
|
<span id="index-chains-of-rules"></span>
|
|
<span id="index-rule_002c-implicit_002c-chains-of"></span>
|
|
<p>Sometimes a file can be made by a sequence of implicit rules. For example,
|
|
a file <samp><var>n</var>.o</samp> could be made from <samp><var>n</var>.y</samp> by running
|
|
first Yacc and then <code>cc</code>. Such a sequence is called a <em>chain</em>.
|
|
</p>
|
|
<p>If the file <samp><var>n</var>.c</samp> exists, or is mentioned in the makefile, no
|
|
special searching is required: <code>make</code> finds that the object file can
|
|
be made by C compilation from <samp><var>n</var>.c</samp>; later on, when considering
|
|
how to make <samp><var>n</var>.c</samp>, the rule for running Yacc is
|
|
used. Ultimately both <samp><var>n</var>.c</samp> and <samp><var>n</var>.o</samp> are
|
|
updated.
|
|
</p>
|
|
<span id="index-intermediate-files"></span>
|
|
<span id="index-files_002c-intermediate"></span>
|
|
<p>However, even if <samp><var>n</var>.c</samp> does not exist and is not mentioned,
|
|
<code>make</code> knows how to envision it as the missing link between
|
|
<samp><var>n</var>.o</samp> and <samp><var>n</var>.y</samp>! In this case, <samp><var>n</var>.c</samp> is
|
|
called an <em>intermediate file</em>. Once <code>make</code> has decided to use the
|
|
intermediate file, it is entered in the data base as if it had been
|
|
mentioned in the makefile, along with the implicit rule that says how to
|
|
create it.
|
|
</p>
|
|
<p>Intermediate files are remade using their rules just like all other
|
|
files. But intermediate files are treated differently in two ways.
|
|
</p>
|
|
<p>The first difference is what happens if the intermediate file does not
|
|
exist. If an ordinary file <var>b</var> does not exist, and <code>make</code>
|
|
considers a target that depends on <var>b</var>, it invariably creates
|
|
<var>b</var> and then updates the target from <var>b</var>. But if <var>b</var> is
|
|
an intermediate file, then <code>make</code> can leave well enough alone:
|
|
it won’t create <var>b</var> unless one of its prerequisites is out of
|
|
date. This means the target depending on <var>b</var> won’t be rebuilt
|
|
either, unless there is some other reason to update that target: for
|
|
example the target doesn’t exist or a different prerequisite is newer
|
|
than the target.
|
|
</p>
|
|
<p>The second difference is that if <code>make</code> <em>does</em> create <var>b</var> in
|
|
order to update something else, it deletes <var>b</var> later on after it is no
|
|
longer needed. Therefore, an intermediate file which did not exist before
|
|
<code>make</code> also does not exist after <code>make</code>. <code>make</code> reports the
|
|
deletion to you by printing a ‘<samp>rm</samp>’ command showing which file it is
|
|
deleting.
|
|
</p>
|
|
<p>You can explicitly mark a file as intermediate by listing it as a prerequisite
|
|
of the special target <code>.INTERMEDIATE</code>. This takes effect even if the
|
|
file is mentioned explicitly in some other way.
|
|
</p>
|
|
<p>A file cannot be intermediate if it is mentioned in the makefile as a target
|
|
or prerequisite, so one way to avoid the deletion of intermediate files is by
|
|
adding it as a prerequisite to some target. However, doing so can cause make
|
|
to do extra work when searching pattern rules (see <a href="#Implicit-Rule-Search">Implicit Rule Search Algorithm</a>).
|
|
</p>
|
|
<p>As an alternative, listing a file as a prerequisite of the special target
|
|
<code>.NOTINTERMEDIATE</code> forces it to not be considered intermediate (just as
|
|
any other mention of the file will do). Also, listing the target pattern of a
|
|
pattern rule as a prerequisite of <code>.NOTINTERMEDIATE</code> ensures that no
|
|
targets generated using that pattern rule are considered intermediate.
|
|
</p>
|
|
<p>You can disable intermediate files completely in your makefile by
|
|
providing <code>.NOTINTERMEDIATE</code> as a target with no prerequisites:
|
|
in that case it applies to every file in the makefile.
|
|
</p>
|
|
<span id="index-intermediate-files_002c-preserving"></span>
|
|
<span id="index-preserving-intermediate-files"></span>
|
|
<span id="index-secondary-files"></span>
|
|
<p>If you do not want <code>make</code> to create a file merely because it does
|
|
not already exist, but you also do not want <code>make</code> to
|
|
automatically delete the file, you can mark it as a <em>secondary</em>
|
|
file. To do this, list it as a prerequisite of the special target
|
|
<code>.SECONDARY</code>. Marking a file as secondary also marks it as
|
|
intermediate.
|
|
</p>
|
|
<p>A chain can involve more than two implicit rules. For example, it is
|
|
possible to make a file <samp>foo</samp> from <samp>RCS/foo.y,v</samp> by running RCS,
|
|
Yacc and <code>cc</code>. Then both <samp>foo.y</samp> and <samp>foo.c</samp> are
|
|
intermediate files that are deleted at the end.
|
|
</p>
|
|
<p>No single implicit rule can appear more than once in a chain. This means
|
|
that <code>make</code> will not even consider such a ridiculous thing as making
|
|
<samp>foo</samp> from <samp>foo.o.o</samp> by running the linker twice. This
|
|
constraint has the added benefit of preventing any infinite loop in the
|
|
search for an implicit rule chain.
|
|
</p>
|
|
<p>There are some special implicit rules to optimize certain cases that would
|
|
otherwise be handled by rule chains. For example, making <samp>foo</samp> from
|
|
<samp>foo.c</samp> could be handled by compiling and linking with separate
|
|
chained rules, using <samp>foo.o</samp> as an intermediate file. But what
|
|
actually happens is that a special rule for this case does the compilation
|
|
and linking with a single <code>cc</code> command. The optimized rule is used in
|
|
preference to the step-by-step chain because it comes earlier in the
|
|
ordering of rules.
|
|
</p>
|
|
<p>Finally, for performance reasons <code>make</code> will not consider non-terminal
|
|
match-anything rules (i.e., ‘<samp>%:</samp>’) when searching for a rule to
|
|
build a prerequisite of an implicit rule (see <a href="#Match_002dAnything-Rules">Match-Anything Rules</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Pattern-Rules"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Last-Resort" accesskey="n" rel="next">Last Resort</a>, Previous: <a href="#Chained-Rules" accesskey="p" rel="prev">Chained Rules</a>, Up: <a href="#Implicit-Rules" accesskey="u" rel="up">Implicit Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Defining-and-Redefining-Pattern-Rules"></span><h3 class="section">10.5 Defining and Redefining Pattern Rules</h3>
|
|
|
|
<p>You define an implicit rule by writing a <em>pattern rule</em>. A pattern
|
|
rule looks like an ordinary rule, except that its target contains the
|
|
character ‘<samp>%</samp>’ (exactly one of them). The target is considered a
|
|
pattern for matching file names; the ‘<samp>%</samp>’ can match any nonempty
|
|
substring, while other characters match only themselves. The prerequisites
|
|
likewise use ‘<samp>%</samp>’ to show how their names relate to the target name.
|
|
</p>
|
|
<p>Thus, a pattern rule ‘<samp>%.o : %.c</samp>’ says how to make any file
|
|
<samp><var>stem</var>.o</samp> from another file <samp><var>stem</var>.c</samp>.
|
|
</p>
|
|
<p>Note that expansion using ‘<samp>%</samp>’ in pattern rules occurs
|
|
<strong>after</strong> any variable or function expansions, which take place
|
|
when the makefile is read. See <a href="#Using-Variables">How to Use
|
|
Variables</a>, and <a href="#Functions">Functions for Transforming Text</a>.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Pattern-Intro" accesskey="1">Pattern Intro</a></td><td> </td><td align="left" valign="top">An introduction to pattern rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Pattern-Examples" accesskey="2">Pattern Examples</a></td><td> </td><td align="left" valign="top">Examples of pattern rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Automatic-Variables" accesskey="3">Automatic Variables</a></td><td> </td><td align="left" valign="top">How to use automatic variables in the
|
|
recipe of implicit rules.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Pattern-Match" accesskey="4">Pattern Match</a></td><td> </td><td align="left" valign="top">How patterns match.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Match_002dAnything-Rules" accesskey="5">Match-Anything Rules</a></td><td> </td><td align="left" valign="top">Precautions you should take prior to
|
|
defining rules that can match any
|
|
target file whatever.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Canceling-Rules" accesskey="6">Canceling Rules</a></td><td> </td><td align="left" valign="top">How to override or cancel built-in rules.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Pattern-Intro"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Pattern-Examples" accesskey="n" rel="next">Pattern Examples</a>, Previous: <a href="#Pattern-Rules" accesskey="p" rel="prev">Pattern Rules</a>, Up: <a href="#Pattern-Rules" accesskey="u" rel="up">Pattern Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Introduction-to-Pattern-Rules"></span><h4 class="subsection">10.5.1 Introduction to Pattern Rules</h4>
|
|
<span id="index-pattern-rule"></span>
|
|
<span id="index-rule_002c-pattern"></span>
|
|
|
|
<p>A pattern rule contains the character ‘<samp>%</samp>’ (exactly one of them)
|
|
in the target; otherwise, it looks exactly like an ordinary rule. The
|
|
target is a pattern for matching file names; the ‘<samp>%</samp>’ matches any
|
|
nonempty substring, while other characters match only themselves.
|
|
<span id="index-target-pattern_002c-implicit"></span>
|
|
<span id="index-_0025_002c-in-pattern-rules"></span>
|
|
</p>
|
|
<p>For example, ‘<samp>%.c</samp>’ as a pattern matches any file name that ends in
|
|
‘<samp>.c</samp>’. ‘<samp>s.%.c</samp>’ as a pattern matches any file name that starts
|
|
with ‘<samp>s.</samp>’, ends in ‘<samp>.c</samp>’ and is at least five characters long.
|
|
(There must be at least one character to match the ‘<samp>%</samp>’.) The substring
|
|
that the ‘<samp>%</samp>’ matches is called the <em>stem</em>.
|
|
</p>
|
|
<p>‘<samp>%</samp>’ in a prerequisite of a pattern rule stands for the same stem
|
|
that was matched by the ‘<samp>%</samp>’ in the target. In order for the
|
|
pattern rule to apply, its target pattern must match the file name
|
|
under consideration and all of its prerequisites (after pattern
|
|
substitution) must name files that exist or can be made. These files
|
|
become prerequisites of the target.
|
|
<span id="index-prerequisite-pattern_002c-implicit"></span>
|
|
</p>
|
|
<p>Thus, a rule of the form
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.o : %.c ; <var>recipe</var>…
|
|
</pre></div>
|
|
|
|
<p>specifies how to make a file <samp><var>n</var>.o</samp>, with another file
|
|
<samp><var>n</var>.c</samp> as its prerequisite, provided that <samp><var>n</var>.c</samp>
|
|
exists or can be made.
|
|
</p>
|
|
<p>There may also be prerequisites that do not use ‘<samp>%</samp>’; such a prerequisite
|
|
attaches to every file made by this pattern rule. These unvarying
|
|
prerequisites are useful occasionally.
|
|
</p>
|
|
<p>A pattern rule need not have any prerequisites that contain ‘<samp>%</samp>’, or
|
|
in fact any prerequisites at all. Such a rule is effectively a general
|
|
wildcard. It provides a way to make any file that matches the target
|
|
pattern. See <a href="#Last-Resort">Last Resort</a>.
|
|
</p>
|
|
<p>More than one pattern rule may match a target. In this case
|
|
<code>make</code> will choose the “best fit” rule. See <a href="#Pattern-Match">How Patterns Match</a>.
|
|
</p>
|
|
<span id="index-multiple-targets_002c-in-pattern-rule"></span>
|
|
<span id="index-target_002c-multiple-in-pattern-rule"></span>
|
|
<p>Pattern rules may have more than one target; however, every target must
|
|
contain a <code>%</code> character. Multiple target patterns in pattern rules are
|
|
always treated as grouped targets (see <a href="#Multiple-Targets">Multiple Targets
|
|
in a Rule</a>) regardless of whether they use the <code>:</code> or <code>&:</code>
|
|
separator.
|
|
</p>
|
|
<p>There is one exception: if a pattern target is out of date or does
|
|
not exist and the makefile does not need to build it, then it will not cause
|
|
the other targets to be considered out of date. Note that this historical
|
|
exception will be removed in future versions of GNU <code>make</code> and should not
|
|
be relied on. If this situation is detected <code>make</code> will generate a
|
|
warning <em>pattern recipe did not update peer target</em>; however, <code>make</code>
|
|
cannot detect all such situations. Please be sure that your recipe updates
|
|
<em>all</em> the target patterns when it runs.
|
|
</p>
|
|
<hr>
|
|
<span id="Pattern-Examples"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Automatic-Variables" accesskey="n" rel="next">Automatic Variables</a>, Previous: <a href="#Pattern-Intro" accesskey="p" rel="prev">Pattern Intro</a>, Up: <a href="#Pattern-Rules" accesskey="u" rel="up">Pattern Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Pattern-Rule-Examples"></span><h4 class="subsection">10.5.2 Pattern Rule Examples</h4>
|
|
|
|
<p>Here are some examples of pattern rules actually predefined in
|
|
<code>make</code>. First, the rule that compiles ‘<samp>.c</samp>’ files into ‘<samp>.o</samp>’
|
|
files:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.o : %.c
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
</pre></div>
|
|
|
|
<p>defines a rule that can make any file <samp><var>x</var>.o</samp> from
|
|
<samp><var>x</var>.c</samp>. The recipe uses the automatic variables ‘<samp>$@</samp>’ and
|
|
‘<samp>$<</samp>’ to substitute the names of the target file and the source file
|
|
in each case where the rule applies (see <a href="#Automatic-Variables">Automatic Variables</a>).
|
|
</p>
|
|
<p>Here is a second built-in rule:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">% :: RCS/%,v
|
|
$(CO) $(COFLAGS) $<
|
|
</pre></div>
|
|
|
|
<p>defines a rule that can make any file <samp><var>x</var></samp> whatsoever from a
|
|
corresponding file <samp><var>x</var>,v</samp> in the sub-directory <samp>RCS</samp>. Since
|
|
the target is ‘<samp>%</samp>’, this rule will apply to any file whatever, provided
|
|
the appropriate prerequisite file exists. The double colon makes the rule
|
|
<em>terminal</em>, which means that its prerequisite may not be an intermediate
|
|
file (see <a href="#Match_002dAnything-Rules">Match-Anything Pattern Rules</a>).
|
|
</p>
|
|
<p>This pattern rule has two targets:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.tab.c %.tab.h: %.y
|
|
bison -d $<
|
|
</pre></div>
|
|
|
|
<p>This tells <code>make</code> that the recipe ‘<samp>bison -d <var>x</var>.y</samp>’ will
|
|
make both <samp><var>x</var>.tab.c</samp> and <samp><var>x</var>.tab.h</samp>. If the file
|
|
<samp>foo</samp> depends on the files <samp>parse.tab.o</samp> and <samp>scan.o</samp>
|
|
and the file <samp>scan.o</samp> depends on the file <samp>parse.tab.h</samp>,
|
|
when <samp>parse.y</samp> is changed, the recipe ‘<samp>bison -d parse.y</samp>’
|
|
will be executed only once, and the prerequisites of both
|
|
<samp>parse.tab.o</samp> and <samp>scan.o</samp> will be satisfied. (Presumably
|
|
the file <samp>parse.tab.o</samp> will be recompiled from <samp>parse.tab.c</samp>
|
|
and the file <samp>scan.o</samp> from <samp>scan.c</samp>, while <samp>foo</samp> is
|
|
linked from <samp>parse.tab.o</samp>, <samp>scan.o</samp>, and its other
|
|
prerequisites, and it will execute happily ever after.)
|
|
</p>
|
|
<hr>
|
|
<span id="Automatic-Variables"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Pattern-Match" accesskey="n" rel="next">Pattern Match</a>, Previous: <a href="#Pattern-Examples" accesskey="p" rel="prev">Pattern Examples</a>, Up: <a href="#Pattern-Rules" accesskey="u" rel="up">Pattern Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Automatic-Variables-1"></span><h4 class="subsection">10.5.3 Automatic Variables</h4>
|
|
<span id="index-automatic-variables"></span>
|
|
<span id="index-variables_002c-automatic"></span>
|
|
<span id="index-variables_002c-and-implicit-rule"></span>
|
|
|
|
<p>Suppose you are writing a pattern rule to compile a ‘<samp>.c</samp>’ file into a
|
|
‘<samp>.o</samp>’ file: how do you write the ‘<samp>cc</samp>’ command so that it operates
|
|
on the right source file name? You cannot write the name in the recipe,
|
|
because the name is different each time the implicit rule is applied.
|
|
</p>
|
|
<p>What you do is use a special feature of <code>make</code>, the <em>automatic
|
|
variables</em>. These variables have values computed afresh for each rule that
|
|
is executed, based on the target and prerequisites of the rule. In this
|
|
example, you would use ‘<samp>$@</samp>’ for the object file name and ‘<samp>$<</samp>’
|
|
for the source file name.
|
|
</p>
|
|
<span id="index-automatic-variables-in-prerequisites"></span>
|
|
<span id="index-prerequisites_002c-and-automatic-variables"></span>
|
|
<p>It’s very important that you recognize the limited scope in which
|
|
automatic variable values are available: they only have values within
|
|
the recipe. In particular, you cannot use them anywhere
|
|
within the target list of a rule; they have no value there and will
|
|
expand to the empty string. Also, they cannot be accessed directly
|
|
within the prerequisite list of a rule. A common mistake is
|
|
attempting to use <code>$@</code> within the prerequisites list; this will
|
|
not work. However, there is a special feature of GNU <code>make</code>,
|
|
secondary expansion (see <a href="#Secondary-Expansion">Secondary Expansion</a>), which will allow
|
|
automatic variable values to be used in prerequisite lists.
|
|
</p>
|
|
<p>Here is a table of automatic variables:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dd><span id="index-_0024_0040"></span>
|
|
<span id="index-_0040-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>$@</code></dt>
|
|
<dd><p>The file name of the target of the rule. If the target is an archive
|
|
member, then ‘<samp>$@</samp>’ is the name of the archive file. In a pattern
|
|
rule that has multiple targets (see <a href="#Pattern-Intro">Introduction to
|
|
Pattern Rules</a>), ‘<samp>$@</samp>’ is the name of whichever target caused the
|
|
rule’s recipe to be run.
|
|
</p>
|
|
<span id="index-_0024_0025"></span>
|
|
<span id="index-_0025-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>$%</code></dt>
|
|
<dd><p>The target member name, when the target is an archive member.
|
|
See <a href="#Archives">Archives</a>. For example, if the target is <samp>foo.a(bar.o)</samp> then
|
|
‘<samp>$%</samp>’ is <samp>bar.o</samp> and ‘<samp>$@</samp>’ is <samp>foo.a</samp>. ‘<samp>$%</samp>’ is
|
|
empty when the target is not an archive member.
|
|
</p>
|
|
<span id="index-_0024_003c"></span>
|
|
<span id="index-_003c-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>$<</code></dt>
|
|
<dd><p>The name of the first prerequisite. If the target got its recipe from
|
|
an implicit rule, this will be the first prerequisite added by the
|
|
implicit rule (see <a href="#Implicit-Rules">Implicit Rules</a>).
|
|
</p>
|
|
<span id="index-_0024_003f"></span>
|
|
<span id="index-_003f-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>$?</code></dt>
|
|
<dd><p>The names of all the prerequisites that are newer than the target, with
|
|
spaces between them. If the target does not exist, all prerequisites
|
|
will be included. For prerequisites which are archive members, only the
|
|
named member is used (see <a href="#Archives">Archives</a>).
|
|
</p>
|
|
<p>‘<samp>$?</samp>’ is useful even in explicit rules when you wish to operate on only
|
|
the prerequisites that have changed. For example, suppose that an archive
|
|
named <samp>lib</samp> is supposed to contain copies of several object files.
|
|
This rule copies just the changed object files into the archive:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">lib: foo.o bar.o lose.o win.o
|
|
ar r lib $?
|
|
</pre></div>
|
|
<span id="index-prerequisites_002c-list-of-changed"></span>
|
|
<span id="index-list-of-changed-prerequisites"></span>
|
|
|
|
<span id="index-_0024_005e"></span>
|
|
<span id="index-_005e-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>$^</code></dt>
|
|
<dd><p>The names of all the prerequisites, with spaces between them. For
|
|
prerequisites which are archive members, only the named member is used
|
|
(see <a href="#Archives">Archives</a>). A target has only one prerequisite on each other file
|
|
it depends on, no matter how many times each file is listed as a
|
|
prerequisite. So if you list a prerequisite more than once for a target,
|
|
the value of <code>$^</code> contains just one copy of the name. This list
|
|
does <strong>not</strong> contain any of the order-only prerequisites; for those
|
|
see the ‘<samp>$|</samp>’ variable, below.
|
|
<span id="index-prerequisites_002c-list-of-all"></span>
|
|
<span id="index-list-of-all-prerequisites"></span>
|
|
</p>
|
|
<span id="index-_0024_002b"></span>
|
|
<span id="index-_002b-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>$+</code></dt>
|
|
<dd><p>This is like ‘<samp>$^</samp>’, but prerequisites listed more than once are
|
|
duplicated in the order they were listed in the makefile. This is
|
|
primarily useful for use in linking commands where it is meaningful to
|
|
repeat library file names in a particular order.
|
|
</p>
|
|
<span id="index-_0024_007c"></span>
|
|
<span id="index-_007c-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>$|</code></dt>
|
|
<dd><p>The names of all the order-only prerequisites, with spaces between
|
|
them.
|
|
</p>
|
|
<span id="index-_0024_002a"></span>
|
|
<span id="index-_002a-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt><code>$*</code></dt>
|
|
<dd><p>The stem with which an implicit rule matches (see <a href="#Pattern-Match">How
|
|
Patterns Match</a>). If the target is <samp>dir/a.foo.b</samp> and the target
|
|
pattern is <samp>a.%.b</samp> then the stem is <samp>dir/foo</samp>. The stem is
|
|
useful for constructing names of related files.
|
|
<span id="index-stem_002c-variable-for"></span>
|
|
</p>
|
|
<p>In a static pattern rule, the stem is part of the file name that matched
|
|
the ‘<samp>%</samp>’ in the target pattern.
|
|
</p>
|
|
<p>In an explicit rule, there is no stem; so ‘<samp>$*</samp>’ cannot be determined
|
|
in that way. Instead, if the target name ends with a recognized suffix
|
|
(see <a href="#Suffix-Rules">Old-Fashioned Suffix Rules</a>), ‘<samp>$*</samp>’ is set to
|
|
the target name minus the suffix. For example, if the target name is
|
|
‘<samp>foo.c</samp>’, then ‘<samp>$*</samp>’ is set to ‘<samp>foo</samp>’, since ‘<samp>.c</samp>’ is a
|
|
suffix. GNU <code>make</code> does this bizarre thing only for compatibility
|
|
with other implementations of <code>make</code>. You should generally avoid
|
|
using ‘<samp>$*</samp>’ except in implicit rules or static pattern rules.
|
|
</p>
|
|
<p>If the target name in an explicit rule does not end with a recognized
|
|
suffix, ‘<samp>$*</samp>’ is set to the empty string for that rule.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Of the variables listed above, four have values that are single file
|
|
names, and three have values that are lists of file names. These
|
|
seven have variants that get just the file’s directory name or just
|
|
the file name within the directory. The variant variables’ names are
|
|
formed by appending ‘<samp>D</samp>’ or ‘<samp>F</samp>’, respectively. The functions
|
|
<code>dir</code> and <code>notdir</code> can be used to obtain a similar effect
|
|
(see <a href="#File-Name-Functions">Functions for File Names</a>). Note,
|
|
however, that the ‘<samp>D</samp>’ variants all omit the trailing slash which
|
|
always appears in the output of the <code>dir</code> function. Here is a
|
|
table of the variants:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dd><span id="index-_0024_0028_0040D_0029"></span>
|
|
<span id="index-_0040D-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(@D)</samp>’</dt>
|
|
<dd><p>The directory part of the file name of the target, with the trailing
|
|
slash removed. If the value of ‘<samp>$@</samp>’ is <samp>dir/foo.o</samp> then
|
|
‘<samp>$(@D)</samp>’ is <samp>dir</samp>. This value is <samp>.</samp> if ‘<samp>$@</samp>’ does
|
|
not contain a slash.
|
|
</p>
|
|
<span id="index-_0024_0028_0040F_0029"></span>
|
|
<span id="index-_0040F-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(@F)</samp>’</dt>
|
|
<dd><p>The file-within-directory part of the file name of the target. If the
|
|
value of ‘<samp>$@</samp>’ is <samp>dir/foo.o</samp> then ‘<samp>$(@F)</samp>’ is
|
|
<samp>foo.o</samp>. ‘<samp>$(@F)</samp>’ is equivalent to ‘<samp>$(notdir $@)</samp>’.
|
|
</p>
|
|
<span id="index-_0024_0028_002aD_0029"></span>
|
|
<span id="index-_002aD-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(*D)</samp>’</dt>
|
|
<dd><span id="index-_0024_0028_002aF_0029"></span>
|
|
<span id="index-_002aF-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(*F)</samp>’</dt>
|
|
<dd><p>The directory part and the file-within-directory
|
|
part of the stem; <samp>dir</samp> and <samp>foo</samp> in this example.
|
|
</p>
|
|
<span id="index-_0024_0028_0025D_0029"></span>
|
|
<span id="index-_0025D-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(%D)</samp>’</dt>
|
|
<dd><span id="index-_0024_0028_0025F_0029"></span>
|
|
<span id="index-_0025F-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(%F)</samp>’</dt>
|
|
<dd><p>The directory part and the file-within-directory part of the target
|
|
archive member name. This makes sense only for archive member targets
|
|
of the form <samp><var>archive</var>(<var>member</var>)</samp> and is useful only when
|
|
<var>member</var> may contain a directory name. (See <a href="#Archive-Members">Archive Members as Targets</a>.)
|
|
</p>
|
|
<span id="index-_0024_0028_003cD_0029"></span>
|
|
<span id="index-_003cD-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(<D)</samp>’</dt>
|
|
<dd><span id="index-_0024_0028_003cF_0029"></span>
|
|
<span id="index-_003cF-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(<F)</samp>’</dt>
|
|
<dd><p>The directory part and the file-within-directory
|
|
part of the first prerequisite.
|
|
</p>
|
|
<span id="index-_0024_0028_005eD_0029"></span>
|
|
<span id="index-_005eD-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(^D)</samp>’</dt>
|
|
<dd><span id="index-_0024_0028_005eF_0029"></span>
|
|
<span id="index-_005eF-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(^F)</samp>’</dt>
|
|
<dd><p>Lists of the directory parts and the file-within-directory
|
|
parts of all prerequisites.
|
|
</p>
|
|
<span id="index-_0024_0028_002bD_0029"></span>
|
|
<span id="index-_002bD-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(+D)</samp>’</dt>
|
|
<dd><span id="index-_0024_0028_002bF_0029"></span>
|
|
<span id="index-_002bF-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(+F)</samp>’</dt>
|
|
<dd><p>Lists of the directory parts and the file-within-directory
|
|
parts of all prerequisites, including multiple instances of duplicated
|
|
prerequisites.
|
|
</p>
|
|
<span id="index-_0024_0028_003fD_0029"></span>
|
|
<span id="index-_003fD-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(?D)</samp>’</dt>
|
|
<dd><span id="index-_0024_0028_003fF_0029"></span>
|
|
<span id="index-_003fF-_0028automatic-variable_0029"></span>
|
|
</dd>
|
|
<dt>‘<samp>$(?F)</samp>’</dt>
|
|
<dd><p>Lists of the directory parts and the file-within-directory parts of
|
|
all prerequisites that are newer than the target.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Note that we use a special stylistic convention when we talk about these
|
|
automatic variables; we write “the value of ‘<samp>$<</samp>’”, rather than
|
|
“the variable <code><</code>”<!-- /@w --> as we would write for ordinary variables
|
|
such as <code>objects</code> and <code>CFLAGS</code>. We think this convention
|
|
looks more natural in this special case. Please do not assume it has a
|
|
deep significance; ‘<samp>$<</samp>’ refers to the variable named <code><</code> just
|
|
as ‘<samp>$(CFLAGS)</samp>’ refers to the variable named <code>CFLAGS</code>.
|
|
You could just as well use ‘<samp>$(<)</samp>’ in place of ‘<samp>$<</samp>’.
|
|
</p>
|
|
<hr>
|
|
<span id="Pattern-Match"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Match_002dAnything-Rules" accesskey="n" rel="next">Match-Anything Rules</a>, Previous: <a href="#Automatic-Variables" accesskey="p" rel="prev">Automatic Variables</a>, Up: <a href="#Pattern-Rules" accesskey="u" rel="up">Pattern Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-Patterns-Match"></span><h4 class="subsection">10.5.4 How Patterns Match</h4>
|
|
|
|
<span id="index-stem-1"></span>
|
|
<p>A target pattern is composed of a ‘<samp>%</samp>’ between a prefix and a suffix,
|
|
either or both of which may be empty. The pattern matches a file name only
|
|
if the file name starts with the prefix and ends with the suffix, without
|
|
overlap. The text between the prefix and the suffix is called the
|
|
<em>stem</em>. Thus, when the pattern ‘<samp>%.o</samp>’ matches the file name
|
|
<samp>test.o</samp>, the stem is ‘<samp>test</samp>’. The pattern rule prerequisites are
|
|
turned into actual file names by substituting the stem for the character
|
|
‘<samp>%</samp>’. Thus, if in the same example one of the prerequisites is written
|
|
as ‘<samp>%.c</samp>’, it expands to ‘<samp>test.c</samp>’.
|
|
</p>
|
|
<p>When the target pattern does not contain a slash (and it usually does
|
|
not), directory names in the file names are removed from the file name
|
|
before it is compared with the target prefix and suffix. After the
|
|
comparison of the file name to the target pattern, the directory
|
|
names, along with the slash that ends them, are added on to the
|
|
prerequisite file names generated from the pattern rule’s prerequisite
|
|
patterns and the file name. The directories are ignored only for the
|
|
purpose of finding an implicit rule to use, not in the application of
|
|
that rule. Thus, ‘<samp>e%t</samp>’ matches the file name <samp>src/eat</samp>,
|
|
with ‘<samp>src/a</samp>’ as the stem. When prerequisites are turned into file
|
|
names, the directories from the stem are added at the front, while the
|
|
rest of the stem is substituted for the ‘<samp>%</samp>’. The stem
|
|
‘<samp>src/a</samp>’ with a prerequisite pattern ‘<samp>c%r</samp>’ gives the file name
|
|
<samp>src/car</samp>.
|
|
</p>
|
|
<span id="index-pattern-rules_002c-order-of"></span>
|
|
<span id="index-order-of-pattern-rules"></span>
|
|
<p>A pattern rule can be used to build a given file only if there is a
|
|
target pattern that matches the file name, <em>and</em> all
|
|
prerequisites in that rule either exist or can be built. The rules
|
|
you write take precedence over those that are built in. Note however,
|
|
that a rule which can be satisfied without chaining other implicit
|
|
rules (for example, one which has no prerequisites or its
|
|
prerequisites already exist or are mentioned) always takes priority
|
|
over a rule with prerequisites that must be made by chaining other
|
|
implicit rules.
|
|
</p>
|
|
<span id="index-stem_002c-shortest"></span>
|
|
<p>It is possible that more than one pattern rule will meet these
|
|
criteria. In that case, <code>make</code> will choose the rule with the
|
|
shortest stem (that is, the pattern that matches most specifically).
|
|
If more than one pattern rule has the shortest stem, <code>make</code> will
|
|
choose the first one found in the makefile.
|
|
</p>
|
|
<p>This algorithm results in more specific rules being preferred over
|
|
more generic ones; for example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.o: %.c
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
|
|
%.o : %.f
|
|
$(COMPILE.F) $(OUTPUT_OPTION) $<
|
|
|
|
lib/%.o: lib/%.c
|
|
$(CC) -fPIC -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
</pre></div>
|
|
|
|
<p>Given these rules and asked to build <samp>bar.o</samp> where both
|
|
<samp>bar.c</samp> and <samp>bar.f</samp> exist, <code>make</code> will choose the first
|
|
rule and compile <samp>bar.c</samp> into <samp>bar.o</samp>. In the same
|
|
situation where <samp>bar.c</samp> does not exist, then <code>make</code> will
|
|
choose the second rule and compile <samp>bar.f</samp> into <samp>bar.o</samp>.
|
|
</p>
|
|
<p>If <code>make</code> is asked to build <samp>lib/bar.o</samp> and both
|
|
<samp>lib/bar.c</samp> and <samp>lib/bar.f</samp> exist, then the third rule will
|
|
be chosen since the stem for this rule (‘<samp>bar</samp>’) is shorter than
|
|
the stem for the first rule (‘<samp>lib/bar</samp>’). If <samp>lib/bar.c</samp>
|
|
does not exist then the third rule is not eligible and the second rule
|
|
will be used, even though the stem is longer.
|
|
</p>
|
|
<hr>
|
|
<span id="Match_002dAnything-Rules"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Canceling-Rules" accesskey="n" rel="next">Canceling Rules</a>, Previous: <a href="#Pattern-Match" accesskey="p" rel="prev">Pattern Match</a>, Up: <a href="#Pattern-Rules" accesskey="u" rel="up">Pattern Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Match_002dAnything-Pattern-Rules"></span><h4 class="subsection">10.5.5 Match-Anything Pattern Rules</h4>
|
|
|
|
<span id="index-match_002danything-rule"></span>
|
|
<span id="index-terminal-rule"></span>
|
|
<p>When a pattern rule’s target is just ‘<samp>%</samp>’, it matches any file name
|
|
whatever. We call these rules <em>match-anything</em> rules. They are very
|
|
useful, but it can take a lot of time for <code>make</code> to think about them,
|
|
because it must consider every such rule for each file name listed either
|
|
as a target or as a prerequisite.
|
|
</p>
|
|
<p>Suppose the makefile mentions <samp>foo.c</samp>. For this target, <code>make</code>
|
|
would have to consider making it by linking an object file <samp>foo.c.o</samp>,
|
|
or by C compilation-and-linking in one step from <samp>foo.c.c</samp>, or by
|
|
Pascal compilation-and-linking from <samp>foo.c.p</samp>, and many other
|
|
possibilities.
|
|
</p>
|
|
<p>We know these possibilities are ridiculous since <samp>foo.c</samp> is a C source
|
|
file, not an executable. If <code>make</code> did consider these possibilities,
|
|
it would ultimately reject them, because files such as <samp>foo.c.o</samp> and
|
|
<samp>foo.c.p</samp> would not exist. But these possibilities are so
|
|
numerous that <code>make</code> would run very slowly if it had to consider
|
|
them.
|
|
</p>
|
|
<p>To gain speed, we have put various constraints on the way <code>make</code>
|
|
considers match-anything rules. There are two different constraints that
|
|
can be applied, and each time you define a match-anything rule you must
|
|
choose one or the other for that rule.
|
|
</p>
|
|
<p>One choice is to mark the match-anything rule as <em>terminal</em> by defining
|
|
it with a double colon. When a rule is terminal, it does not apply unless
|
|
its prerequisites actually exist. Prerequisites that could be made with
|
|
other implicit rules are not good enough. In other words, no further
|
|
chaining is allowed beyond a terminal rule.
|
|
</p>
|
|
<p>For example, the built-in implicit rules for extracting sources from RCS
|
|
and SCCS files are terminal; as a result, if the file <samp>foo.c,v</samp> does
|
|
not exist, <code>make</code> will not even consider trying to make it as an
|
|
intermediate file from <samp>foo.c,v.o</samp> or from <samp>RCS/SCCS/s.foo.c,v</samp>.
|
|
RCS and SCCS files are generally ultimate source files, which should not be
|
|
remade from any other files; therefore, <code>make</code> can save time by not
|
|
looking for ways to remake them.
|
|
</p>
|
|
<p>If you do not mark the match-anything rule as terminal, then it is
|
|
non-terminal. A non-terminal match-anything rule cannot apply to a
|
|
prerequisite of an implicit rule, or to a file name that indicates a
|
|
specific type of data. A file name indicates a specific type of data
|
|
if some non-match-anything implicit rule target matches it.
|
|
</p>
|
|
<p>For example, the file name <samp>foo.c</samp> matches the target for the pattern
|
|
rule ‘<samp>%.c : %.y</samp>’ (the rule to run Yacc). Regardless of whether this
|
|
rule is actually applicable (which happens only if there is a file
|
|
<samp>foo.y</samp>), the fact that its target matches is enough to prevent
|
|
consideration of any non-terminal match-anything rules for the file
|
|
<samp>foo.c</samp>. Thus, <code>make</code> will not even consider trying to make
|
|
<samp>foo.c</samp> as an executable file from <samp>foo.c.o</samp>, <samp>foo.c.c</samp>,
|
|
<samp>foo.c.p</samp>, etc.
|
|
</p>
|
|
<p>The motivation for this constraint is that non-terminal match-anything
|
|
rules are used for making files containing specific types of data (such as
|
|
executable files) and a file name with a recognized suffix indicates some
|
|
other specific type of data (such as a C source file).
|
|
</p>
|
|
<p>Special built-in dummy pattern rules are provided solely to recognize
|
|
certain file names so that non-terminal match-anything rules will not be
|
|
considered. These dummy rules have no prerequisites and no recipes, and
|
|
they are ignored for all other purposes. For example, the built-in
|
|
implicit rule
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.p :
|
|
</pre></div>
|
|
|
|
<p>exists to make sure that Pascal source files such as <samp>foo.p</samp> match a
|
|
specific target pattern and thereby prevent time from being wasted looking
|
|
for <samp>foo.p.o</samp> or <samp>foo.p.c</samp>.
|
|
</p>
|
|
<p>Dummy pattern rules such as the one for ‘<samp>%.p</samp>’ are made for every
|
|
suffix listed as valid for use in suffix rules (see <a href="#Suffix-Rules">Old-Fashioned Suffix Rules</a>).
|
|
</p>
|
|
<hr>
|
|
<span id="Canceling-Rules"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Match_002dAnything-Rules" accesskey="p" rel="prev">Match-Anything Rules</a>, Up: <a href="#Pattern-Rules" accesskey="u" rel="up">Pattern Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Canceling-Implicit-Rules"></span><h4 class="subsection">10.5.6 Canceling Implicit Rules</h4>
|
|
|
|
<p>You can override a built-in implicit rule (or one you have defined
|
|
yourself) by defining a new pattern rule with the same target and
|
|
prerequisites, but a different recipe. When the new rule is defined, the
|
|
built-in one is replaced. The new rule’s position in the sequence of
|
|
implicit rules is determined by where you write the new rule.
|
|
</p>
|
|
<p>You can cancel a built-in implicit rule by defining a pattern rule with the
|
|
same target and prerequisites, but no recipe. For example, the following
|
|
would cancel the rule that runs the assembler:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.o : %.s
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Last-Resort"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Suffix-Rules" accesskey="n" rel="next">Suffix Rules</a>, Previous: <a href="#Pattern-Rules" accesskey="p" rel="prev">Pattern Rules</a>, Up: <a href="#Implicit-Rules" accesskey="u" rel="up">Implicit Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Defining-Last_002dResort-Default-Rules"></span><h3 class="section">10.6 Defining Last-Resort Default Rules</h3>
|
|
<span id="index-last_002dresort-default-rules"></span>
|
|
<span id="index-default-rules_002c-last_002dresort"></span>
|
|
|
|
<p>You can define a last-resort implicit rule by writing a terminal
|
|
match-anything pattern rule with no prerequisites (see <a href="#Match_002dAnything-Rules">Match-Anything Rules</a>). This is just like any other pattern rule; the only thing
|
|
special about it is that it will match any target. So such a rule’s
|
|
recipe is used for all targets and prerequisites that have no recipe
|
|
of their own and for which no other implicit rule applies.
|
|
</p>
|
|
<p>For example, when testing a makefile, you might not care if the source
|
|
files contain real data, only that they exist. Then you might do this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%::
|
|
touch $@
|
|
</pre></div>
|
|
|
|
<p>to cause all the source files needed (as prerequisites) to be created
|
|
automatically.
|
|
</p>
|
|
<span id="index-_002eDEFAULT-1"></span>
|
|
<p>You can instead define a recipe to be used for targets for which there
|
|
are no rules at all, even ones which don’t specify recipes. You do
|
|
this by writing a rule for the target <code>.DEFAULT</code>. Such a rule’s
|
|
recipe is used for all prerequisites which do not appear as targets in
|
|
any explicit rule, and for which no implicit rule applies. Naturally,
|
|
there is no <code>.DEFAULT</code> rule unless you write one.
|
|
</p>
|
|
<p>If you use <code>.DEFAULT</code> with no recipe or prerequisites:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.DEFAULT:
|
|
</pre></div>
|
|
|
|
<p>the recipe previously stored for <code>.DEFAULT</code> is cleared. Then
|
|
<code>make</code> acts as if you had never defined <code>.DEFAULT</code> at all.
|
|
</p>
|
|
<p>If you do not want a target to get the recipe from a match-anything
|
|
pattern rule or <code>.DEFAULT</code>, but you also do not want any recipe
|
|
to be run for the target, you can give it an empty recipe
|
|
(see <a href="#Empty-Recipes">Defining Empty Recipes</a>).
|
|
</p>
|
|
<p>You can use a last-resort rule to override part of another makefile.
|
|
See <a href="#Overriding-Makefiles">Overriding Part of Another Makefile</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Suffix-Rules"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Implicit-Rule-Search" accesskey="n" rel="next">Implicit Rule Search</a>, Previous: <a href="#Last-Resort" accesskey="p" rel="prev">Last Resort</a>, Up: <a href="#Implicit-Rules" accesskey="u" rel="up">Implicit Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Old_002dFashioned-Suffix-Rules"></span><h3 class="section">10.7 Old-Fashioned Suffix Rules</h3>
|
|
<span id="index-old_002dfashioned-suffix-rules"></span>
|
|
<span id="index-suffix-rule"></span>
|
|
|
|
<p><em>Suffix rules</em> are the old-fashioned way of defining implicit rules for
|
|
<code>make</code>. Suffix rules are obsolete because pattern rules are more
|
|
general and clearer. They are supported in GNU <code>make</code> for
|
|
compatibility with old makefiles. They come in two kinds:
|
|
<em>double-suffix</em> and <em>single-suffix</em>.
|
|
</p>
|
|
<p>A double-suffix rule is defined by a pair of suffixes: the target
|
|
suffix and the source suffix. It matches any file whose name ends
|
|
with the target suffix. The corresponding implicit prerequisite is
|
|
made by replacing the target suffix with the source suffix in the file
|
|
name. A two-suffix rule ‘<samp>.c.o</samp>’ (whose target and source suffixes
|
|
are ‘<samp>.o</samp>’ and ‘<samp>.c</samp>’) is equivalent to the pattern rule
|
|
‘<samp>%.o : %.c</samp>’.
|
|
</p>
|
|
<p>A single-suffix rule is defined by a single suffix, which is the source
|
|
suffix. It matches any file name, and the corresponding implicit
|
|
prerequisite name is made by appending the source suffix. A single-suffix
|
|
rule whose source suffix is ‘<samp>.c</samp>’ is equivalent to the pattern rule
|
|
‘<samp>% : %.c</samp>’.
|
|
</p>
|
|
<p>Suffix rule definitions are recognized by comparing each rule’s target
|
|
against a defined list of known suffixes. When <code>make</code> sees a rule
|
|
whose target is a known suffix, this rule is considered a single-suffix
|
|
rule. When <code>make</code> sees a rule whose target is two known suffixes
|
|
concatenated, this rule is taken as a double-suffix rule.
|
|
</p>
|
|
<p>For example, ‘<samp>.c</samp>’ and ‘<samp>.o</samp>’ are both on the default list of
|
|
known suffixes. Therefore, if you define a rule whose target is
|
|
‘<samp>.c.o</samp>’, <code>make</code> takes it to be a double-suffix rule with source
|
|
suffix ‘<samp>.c</samp>’ and target suffix ‘<samp>.o</samp>’. Here is the old-fashioned
|
|
way to define the rule for compiling a C source file:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.c.o:
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
|
|
</pre></div>
|
|
|
|
<p>Suffix rules cannot have any prerequisites of their own. If they have any,
|
|
they are treated as normal files with funny names, not as suffix rules.
|
|
Thus, the rule:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.c.o: foo.h
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
|
|
</pre></div>
|
|
|
|
<p>tells how to make the file <samp>.c.o</samp> from the prerequisite file
|
|
<samp>foo.h</samp>, and is not at all like the pattern rule:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">%.o: %.c foo.h
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
|
|
</pre></div>
|
|
|
|
<p>which tells how to make ‘<samp>.o</samp>’ files from ‘<samp>.c</samp>’ files, and makes all
|
|
‘<samp>.o</samp>’ files using this pattern rule also depend on <samp>foo.h</samp>.
|
|
</p>
|
|
<p>Suffix rules with no recipe are also meaningless. They do not remove
|
|
previous rules as do pattern rules with no recipe (see <a href="#Canceling-Rules">Canceling Implicit Rules</a>). They simply enter the suffix or
|
|
pair of suffixes concatenated as a target in the data base.
|
|
</p>
|
|
<span id="index-_002eSUFFIXES-1"></span>
|
|
<p>The known suffixes are simply the names of the prerequisites of the special
|
|
target <code>.SUFFIXES</code>. You can add your own suffixes by writing a rule
|
|
for <code>.SUFFIXES</code> that adds more prerequisites, as in:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SUFFIXES: .hack .win
|
|
</pre></div>
|
|
|
|
<p>which adds ‘<samp>.hack</samp>’ and ‘<samp>.win</samp>’ to the end of the list of suffixes.
|
|
</p>
|
|
<p>If you wish to eliminate the default known suffixes instead of just adding
|
|
to them, write a rule for <code>.SUFFIXES</code> with no prerequisites. By
|
|
special dispensation, this eliminates all existing prerequisites of
|
|
<code>.SUFFIXES</code>. You can then write another rule to add the suffixes you
|
|
want. For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SUFFIXES: # <span class="roman">Delete the default suffixes</span>
|
|
.SUFFIXES: .c .o .h # <span class="roman">Define our suffix list</span>
|
|
</pre></div>
|
|
|
|
<p>The ‘<samp>-r</samp>’ or ‘<samp>--no-builtin-rules</samp>’ flag causes the default
|
|
list of suffixes to be empty.
|
|
</p>
|
|
<span id="index-SUFFIXES"></span>
|
|
<p>The variable <code>SUFFIXES</code> is defined to the default list of suffixes
|
|
before <code>make</code> reads any makefiles. You can change the list of suffixes
|
|
with a rule for the special target <code>.SUFFIXES</code>, but that does not alter
|
|
this variable.
|
|
</p>
|
|
<hr>
|
|
<span id="Implicit-Rule-Search"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Suffix-Rules" accesskey="p" rel="prev">Suffix Rules</a>, Up: <a href="#Implicit-Rules" accesskey="u" rel="up">Implicit Rules</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Implicit-Rule-Search-Algorithm"></span><h3 class="section">10.8 Implicit Rule Search Algorithm</h3>
|
|
<span id="index-implicit-rule_002c-search-algorithm"></span>
|
|
<span id="index-search-algorithm_002c-implicit-rule"></span>
|
|
|
|
<p>Here is the procedure <code>make</code> uses for searching for an implicit rule
|
|
for a target <var>t</var>. This procedure is followed for each double-colon
|
|
rule with no recipe, for each target of ordinary rules none of which have
|
|
a recipe, and for each prerequisite that is not the target of any rule. It
|
|
is also followed recursively for prerequisites that come from implicit
|
|
rules, in the search for a chain of rules.
|
|
</p>
|
|
<p>Suffix rules are not mentioned in this algorithm because suffix rules are
|
|
converted to equivalent pattern rules once the makefiles have been read in.
|
|
</p>
|
|
<p>For an archive member target of the form
|
|
‘<samp><var>archive</var>(<var>member</var>)</samp>’, the following algorithm is run
|
|
twice, first using the entire target name <var>t</var>, and second using
|
|
‘<samp>(<var>member</var>)</samp>’ as the target <var>t</var> if the first run found no
|
|
rule.
|
|
</p>
|
|
<ol>
|
|
<li> Split <var>t</var> into a directory part, called <var>d</var>, and the rest,
|
|
called <var>n</var>. For example, if <var>t</var> is ‘<samp>src/foo.o</samp>’, then
|
|
<var>d</var> is ‘<samp>src/</samp>’ and <var>n</var> is ‘<samp>foo.o</samp>’.
|
|
|
|
</li><li> Make a list of all the pattern rules one of whose targets matches
|
|
<var>t</var> or <var>n</var>. If the target pattern contains a slash, it is
|
|
matched against <var>t</var>; otherwise, against <var>n</var>.
|
|
|
|
</li><li> If any rule in that list is <em>not</em> a match-anything rule, or if
|
|
<var>t</var> is a prerequisite of an implicit rule, then remove all
|
|
non-terminal match-anything rules from the list.
|
|
|
|
</li><li> Remove from the list all rules with no recipe.
|
|
|
|
</li><li> For each pattern rule in the list:
|
|
|
|
<ol type="a" start="1">
|
|
<li> Find the stem <var>s</var>, which is the nonempty part of <var>t</var> or <var>n</var>
|
|
matched by the ‘<samp>%</samp>’ in the target pattern.
|
|
|
|
</li><li> Compute the prerequisite names by substituting <var>s</var> for ‘<samp>%</samp>’; if
|
|
the target pattern does not contain a slash, append <var>d</var> to
|
|
the front of each prerequisite name.
|
|
|
|
</li><li> Test whether all the prerequisites exist or ought to exist. (If a
|
|
file name is mentioned in the makefile as a target or as an explicit
|
|
prerequisite of target T, then we say it ought to exist.)
|
|
|
|
<p>If all prerequisites exist or ought to exist, or there are no prerequisites,
|
|
then this rule applies.
|
|
</p></li></ol>
|
|
|
|
</li><li> If no pattern rule has been found so far, try harder.
|
|
For each pattern rule in the list:
|
|
|
|
<ol type="a" start="1">
|
|
<li> If the rule is terminal, ignore it and go on to the next rule.
|
|
|
|
</li><li> Compute the prerequisite names as before.
|
|
|
|
</li><li> Test whether all the prerequisites exist or ought to exist.
|
|
|
|
</li><li> For each prerequisite that does not exist, follow this algorithm
|
|
recursively to see if the prerequisite can be made by an implicit
|
|
rule.
|
|
|
|
</li><li> If all prerequisites exist, ought to exist, or can be
|
|
made by implicit rules, then this rule applies.
|
|
</li></ol>
|
|
|
|
</li><li> If no pattern rule has been found then try step 5 and step 6 again with a
|
|
modified definition of “ought to exist”: if a filename is mentioned as a
|
|
target or as an explicit prerequisite of <em>any</em> target, then it ought to
|
|
exist. This check is only present for backward-compatibility with older
|
|
versions of GNU make: we don’t recommend relying on it.
|
|
|
|
</li><li> If no implicit rule applies, the rule for <code>.DEFAULT</code>, if any,
|
|
applies. In that case, give <var>t</var> the same recipe that
|
|
<code>.DEFAULT</code> has. Otherwise, there is no recipe for <var>t</var>.
|
|
</li></ol>
|
|
|
|
<p>Once a rule that applies has been found, for each target pattern of
|
|
the rule other than the one that matched <var>t</var> or <var>n</var>, the
|
|
‘<samp>%</samp>’ in the pattern is replaced with <var>s</var> and the resultant
|
|
file name is stored until the recipe to remake the target file <var>t</var>
|
|
is executed. After the recipe is executed, each of these stored file
|
|
names are entered into the data base and marked as having been updated
|
|
and having the same update status as the file <var>t</var>.
|
|
</p>
|
|
<p>When the recipe of a pattern rule is executed for <var>t</var>, the
|
|
automatic variables are set corresponding to the target and
|
|
prerequisites. See <a href="#Automatic-Variables">Automatic Variables</a>.
|
|
</p>
|
|
<hr>
|
|
<span id="Archives"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Extending-make" accesskey="n" rel="next">Extending make</a>, Previous: <a href="#Implicit-Rules" accesskey="p" rel="prev">Implicit Rules</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Using-make-to-Update-Archive-Files"></span><h2 class="chapter">11 Using <code>make</code> to Update Archive Files</h2>
|
|
<span id="index-archive"></span>
|
|
|
|
<p><em>Archive files</em> are files containing named sub-files called
|
|
<em>members</em>; they are maintained with the program <code>ar</code> and their
|
|
main use is as subroutine libraries for linking.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Archive-Members" accesskey="1">Archive Members</a></td><td> </td><td align="left" valign="top">Archive members as targets.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Archive-Update" accesskey="2">Archive Update</a></td><td> </td><td align="left" valign="top">The implicit rule for archive member targets.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Archive-Pitfalls" accesskey="3">Archive Pitfalls</a></td><td> </td><td align="left" valign="top">Dangers to watch out for when using archives.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Archive-Suffix-Rules" accesskey="4">Archive Suffix Rules</a></td><td> </td><td align="left" valign="top">You can write a special kind of suffix rule
|
|
for updating archives.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Archive-Members"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Archive-Update" accesskey="n" rel="next">Archive Update</a>, Previous: <a href="#Archives" accesskey="p" rel="prev">Archives</a>, Up: <a href="#Archives" accesskey="u" rel="up">Archives</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Archive-Members-as-Targets"></span><h3 class="section">11.1 Archive Members as Targets</h3>
|
|
<span id="index-archive-member-targets"></span>
|
|
|
|
<p>An individual member of an archive file can be used as a target or
|
|
prerequisite in <code>make</code>. You specify the member named <var>member</var> in
|
|
archive file <var>archive</var> as follows:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"><var>archive</var>(<var>member</var>)
|
|
</pre></div>
|
|
|
|
<p>This construct is available only in targets and prerequisites, not in
|
|
recipes! Most programs that you might use in recipes do not support
|
|
this syntax and cannot act directly on archive members. Only
|
|
<code>ar</code> and other programs specifically designed to operate on
|
|
archives can do so. Therefore, valid recipes to update an archive
|
|
member target probably must use <code>ar</code>. For example, this rule
|
|
says to create a member <samp>hack.o</samp> in archive <samp>foolib</samp> by
|
|
copying the file <samp>hack.o</samp>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foolib(hack.o) : hack.o
|
|
ar cr foolib hack.o
|
|
</pre></div>
|
|
|
|
<p>In fact, nearly all archive member targets are updated in just this way
|
|
and there is an implicit rule to do it for you. <strong>Please note:</strong> The
|
|
‘<samp>c</samp>’ flag to <code>ar</code> is required if the archive file does not
|
|
already exist.
|
|
</p>
|
|
<p>To specify several members in the same archive, you can write all the
|
|
member names together between the parentheses. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foolib(hack.o kludge.o)
|
|
</pre></div>
|
|
|
|
<p>is equivalent to:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foolib(hack.o) foolib(kludge.o)
|
|
</pre></div>
|
|
|
|
<span id="index-wildcard_002c-in-archive-member"></span>
|
|
<p>You can also use shell-style wildcards in an archive member reference.
|
|
See <a href="#Wildcards">Using Wildcard Characters in File Names</a>. For
|
|
example, ‘<samp>foolib(*.o)</samp>’<!-- /@w --> expands to all existing members of the
|
|
<samp>foolib</samp> archive whose names end in ‘<samp>.o</samp>’; perhaps
|
|
‘<samp>foolib(hack.o)<!-- /@w --> foolib(kludge.o)<!-- /@w --></samp>’.
|
|
</p>
|
|
<hr>
|
|
<span id="Archive-Update"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Archive-Pitfalls" accesskey="n" rel="next">Archive Pitfalls</a>, Previous: <a href="#Archive-Members" accesskey="p" rel="prev">Archive Members</a>, Up: <a href="#Archives" accesskey="u" rel="up">Archives</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Implicit-Rule-for-Archive-Member-Targets"></span><h3 class="section">11.2 Implicit Rule for Archive Member Targets</h3>
|
|
|
|
<p>Recall that a target that looks like <samp><var>a</var>(<var>m</var>)</samp> stands for the
|
|
member named <var>m</var> in the archive file <var>a</var>.
|
|
</p>
|
|
<p>When <code>make</code> looks for an implicit rule for such a target, as a special
|
|
feature it considers implicit rules that match <samp>(<var>m</var>)</samp>, as well as
|
|
those that match the actual target <samp><var>a</var>(<var>m</var>)</samp>.
|
|
</p>
|
|
<p>This causes one special rule whose target is <samp>(%)</samp> to match. This
|
|
rule updates the target <samp><var>a</var>(<var>m</var>)</samp> by copying the file <var>m</var>
|
|
into the archive. For example, it will update the archive member target
|
|
<samp>foo.a(bar.o)</samp> by copying the <em>file</em> <samp>bar.o</samp> into the
|
|
archive <samp>foo.a</samp> as a <em>member</em> named <samp>bar.o</samp>.
|
|
</p>
|
|
<p>When this rule is chained with others, the result is very powerful.
|
|
Thus, ‘<samp>make "foo.a(bar.o)"</samp>’ (the quotes are needed to protect the
|
|
‘<samp>(</samp>’ and ‘<samp>)</samp>’ from being interpreted specially by the shell) in
|
|
the presence of a file <samp>bar.c</samp> is enough to cause the following
|
|
recipe to be run, even without a makefile:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">cc -c bar.c -o bar.o
|
|
ar r foo.a bar.o
|
|
rm -f bar.o
|
|
</pre></div>
|
|
|
|
<p>Here <code>make</code> has envisioned the file <samp>bar.o</samp> as an intermediate
|
|
file. See <a href="#Chained-Rules">Chains of Implicit Rules</a>.
|
|
</p>
|
|
<p>Implicit rules such as this one are written using the automatic variable
|
|
‘<samp>$%</samp>’. See <a href="#Automatic-Variables">Automatic Variables</a>.
|
|
</p>
|
|
<p>An archive member name in an archive cannot contain a directory name, but
|
|
it may be useful in a makefile to pretend that it does. If you write an
|
|
archive member target <samp>foo.a(dir/file.o)</samp>, <code>make</code> will perform
|
|
automatic updating with this recipe:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ar r foo.a dir/file.o
|
|
</pre></div>
|
|
|
|
<p>which has the effect of copying the file <samp>dir/file.o</samp> into a member
|
|
named <samp>file.o</samp>. In connection with such usage, the automatic variables
|
|
<code>%D</code> and <code>%F</code> may be useful.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Archive-Symbols" accesskey="1">Archive Symbols</a></td><td> </td><td align="left" valign="top">How to update archive symbol directories.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Archive-Symbols"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Archive-Update" accesskey="p" rel="prev">Archive Update</a>, Up: <a href="#Archive-Update" accesskey="u" rel="up">Archive Update</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Updating-Archive-Symbol-Directories"></span><h4 class="subsection">11.2.1 Updating Archive Symbol Directories</h4>
|
|
<span id="index-_005f_005f_002eSYMDEF"></span>
|
|
<span id="index-updating-archive-symbol-directories"></span>
|
|
<span id="index-archive-symbol-directory-updating"></span>
|
|
<span id="index-symbol-directories_002c-updating-archive"></span>
|
|
<span id="index-directories_002c-updating-archive-symbol"></span>
|
|
|
|
<p>An archive file that is used as a library usually contains a special member
|
|
named <samp>__.SYMDEF</samp> that contains a directory of the external symbol
|
|
names defined by all the other members. After you update any other
|
|
members, you need to update <samp>__.SYMDEF</samp> so that it will summarize the
|
|
other members properly. This is done by running the <code>ranlib</code> program:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ranlib <var>archivefile</var>
|
|
</pre></div>
|
|
|
|
<p>Normally you would put this command in the rule for the archive file,
|
|
and make all the members of the archive file prerequisites of that rule.
|
|
For example,
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">libfoo.a: libfoo.a(x.o) libfoo.a(y.o) …
|
|
ranlib libfoo.a
|
|
</pre></div>
|
|
|
|
<p>The effect of this is to update archive members <samp>x.o</samp>, <samp>y.o</samp>,
|
|
etc., and then update the symbol directory member <samp>__.SYMDEF</samp> by
|
|
running <code>ranlib</code>. The rules for updating the members are not shown
|
|
here; most likely you can omit them and use the implicit rule which copies
|
|
files into the archive, as described in the preceding section.
|
|
</p>
|
|
<p>This is not necessary when using the GNU <code>ar</code> program, which
|
|
updates the <samp>__.SYMDEF</samp> member automatically.
|
|
</p>
|
|
<hr>
|
|
<span id="Archive-Pitfalls"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Archive-Suffix-Rules" accesskey="n" rel="next">Archive Suffix Rules</a>, Previous: <a href="#Archive-Update" accesskey="p" rel="prev">Archive Update</a>, Up: <a href="#Archives" accesskey="u" rel="up">Archives</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Dangers-When-Using-Archives"></span><h3 class="section">11.3 Dangers When Using Archives</h3>
|
|
<span id="index-archive_002c-and-parallel-execution"></span>
|
|
<span id="index-parallel-execution_002c-and-archive-update"></span>
|
|
<span id="index-archive_002c-and-_002dj"></span>
|
|
<span id="index-_002dj_002c-and-archive-update"></span>
|
|
|
|
<p>It is important to be careful when using parallel execution (the
|
|
<code>-j</code> switch; see <a href="#Parallel">Parallel Execution</a>) and archives.
|
|
If multiple <code>ar</code> commands run at the same time on the same archive
|
|
file, they will not know about each other and can corrupt the file.
|
|
</p>
|
|
<p>Possibly a future version of <code>make</code> will provide a mechanism to
|
|
circumvent this problem by serializing all recipes that operate on the
|
|
same archive file. But for the time being, you must either write your
|
|
makefiles to avoid this problem in some other way, or not use <code>-j</code>.
|
|
</p>
|
|
<hr>
|
|
<span id="Archive-Suffix-Rules"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Archive-Pitfalls" accesskey="p" rel="prev">Archive Pitfalls</a>, Up: <a href="#Archives" accesskey="u" rel="up">Archives</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Suffix-Rules-for-Archive-Files"></span><h3 class="section">11.4 Suffix Rules for Archive Files</h3>
|
|
<span id="index-suffix-rule_002c-for-archive"></span>
|
|
<span id="index-archive_002c-suffix-rule-for"></span>
|
|
<span id="index-library-archive_002c-suffix-rule-for"></span>
|
|
<span id="index-_002ea-_0028archives_0029"></span>
|
|
|
|
<p>You can write a special kind of suffix rule for dealing with archive
|
|
files. See <a href="#Suffix-Rules">Suffix Rules</a>, for a full explanation of suffix rules.
|
|
Archive suffix rules are obsolete in GNU <code>make</code>, because pattern
|
|
rules for archives are a more general mechanism (see <a href="#Archive-Update">Archive Update</a>). But they are retained for compatibility with other
|
|
<code>make</code>s.
|
|
</p>
|
|
<p>To write a suffix rule for archives, you simply write a suffix rule
|
|
using the target suffix ‘<samp>.a</samp>’ (the usual suffix for archive files).
|
|
For example, here is the old-fashioned suffix rule to update a library
|
|
archive from C source files:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.c.a:
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
|
|
$(AR) r $@ $*.o
|
|
$(RM) $*.o
|
|
</pre></div>
|
|
|
|
<p>This works just as if you had written the pattern rule:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">(%.o): %.c
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
|
|
$(AR) r $@ $*.o
|
|
$(RM) $*.o
|
|
</pre></div>
|
|
|
|
<p>In fact, this is just what <code>make</code> does when it sees a suffix rule
|
|
with ‘<samp>.a</samp>’ as the target suffix. Any double-suffix rule
|
|
‘<samp>.<var>x</var>.a</samp>’<!-- /@w --> is converted to a pattern rule with the target
|
|
pattern ‘<samp>(%.o)</samp>’ and a prerequisite pattern of ‘<samp>%.<var>x</var></samp>’.
|
|
</p>
|
|
<p>Since you might want to use ‘<samp>.a</samp>’ as the suffix for some other kind
|
|
of file, <code>make</code> also converts archive suffix rules to pattern rules
|
|
in the normal way (see <a href="#Suffix-Rules">Suffix Rules</a>). Thus a double-suffix rule
|
|
‘<samp>.<var>x</var>.a</samp>’<!-- /@w --> produces two pattern rules: ‘<samp>(%.o):<!-- /@w -->
|
|
%.<var>x</var><!-- /@w --></samp>’ and ‘<samp>%.a<!-- /@w -->: %.<var>x</var><!-- /@w --></samp>’.
|
|
</p>
|
|
<hr>
|
|
<span id="Extending-make"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Integrating-make" accesskey="n" rel="next">Integrating make</a>, Previous: <a href="#Archives" accesskey="p" rel="prev">Archives</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Extending-GNU-make"></span><h2 class="chapter">12 Extending GNU <code>make</code></h2>
|
|
<span id="index-make-extensions"></span>
|
|
|
|
<p>GNU <code>make</code> provides many advanced capabilities, including many
|
|
useful functions. However, it does not contain a complete programming
|
|
language and so it has limitations. Sometimes these limitations can be
|
|
overcome through use of the <code>shell</code> function to invoke a separate
|
|
program, although this can be inefficient.
|
|
</p>
|
|
<p>In cases where the built-in capabilities of GNU <code>make</code> are
|
|
insufficient to your requirements there are two options for extending
|
|
<code>make</code>. On systems where it’s provided, you can utilize GNU
|
|
Guile as an embedded scripting language (see <a href="#Guile-Integration">GNU
|
|
Guile Integration</a>). On systems which support dynamically loadable
|
|
objects, you can write your own extension in any language (which can
|
|
be compiled into such an object) and load it to provide extended
|
|
capabilities (see <a href="#load-Directive">The <code>load</code> Directive</a>).
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Guile-Integration" accesskey="1">Guile Integration</a></td><td> </td><td align="left" valign="top">Using Guile as an embedded scripting language.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Loading-Objects" accesskey="2">Loading Objects</a></td><td> </td><td align="left" valign="top">Loading dynamic objects as extensions.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Guile-Integration"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Loading-Objects" accesskey="n" rel="next">Loading Objects</a>, Previous: <a href="#Extending-make" accesskey="p" rel="prev">Extending make</a>, Up: <a href="#Extending-make" accesskey="u" rel="up">Extending make</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="GNU-Guile-Integration"></span><h3 class="section">12.1 GNU Guile Integration</h3>
|
|
<span id="index-Guile-1"></span>
|
|
<span id="index-extensions_002c-Guile"></span>
|
|
|
|
<p>GNU <code>make</code> may be built with support for GNU Guile as an embedded
|
|
extension language. Guile implements the Scheme language. A review
|
|
of GNU Guile and the Scheme language and its features is beyond the
|
|
scope of this manual: see the documentation for GNU Guile and Scheme.
|
|
</p>
|
|
<p>You can determine if <code>make</code> contains support for Guile by
|
|
examining the <code>.FEATURES</code> variable; it will contain the word
|
|
<var>guile</var> if Guile support is available.
|
|
</p>
|
|
<p>The Guile integration provides one new <code>make</code> function: <code>guile</code>.
|
|
The <code>guile</code> function takes one argument which is first expanded
|
|
by <code>make</code> in the normal fashion, then passed to the GNU Guile
|
|
evaluator. The result of the evaluator is converted into a string and
|
|
used as the expansion of the <code>guile</code> function in the makefile.
|
|
</p>
|
|
<p>In addition, GNU <code>make</code> exposes Guile procedures for use in Guile
|
|
scripts.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Guile-Types" accesskey="1">Guile Types</a></td><td> </td><td align="left" valign="top">Converting Guile types to <code>make</code> strings.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Guile-Interface" accesskey="2">Guile Interface</a></td><td> </td><td align="left" valign="top">Invoking <code>make</code> functions from Guile.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Guile-Example" accesskey="3">Guile Example</a></td><td> </td><td align="left" valign="top">Example using Guile in <code>make</code>.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Guile-Types"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Guile-Interface" accesskey="n" rel="next">Guile Interface</a>, Previous: <a href="#Guile-Integration" accesskey="p" rel="prev">Guile Integration</a>, Up: <a href="#Guile-Integration" accesskey="u" rel="up">Guile Integration</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Conversion-of-Guile-Types"></span><h4 class="subsection">12.1.1 Conversion of Guile Types</h4>
|
|
<span id="index-convert-guile-types"></span>
|
|
<span id="index-guile_002c-conversion-of-types"></span>
|
|
<span id="index-types_002c-conversion-of"></span>
|
|
|
|
<p>There is only one “data type” in <code>make</code>: a string. GNU Guile,
|
|
on the other hand, provides a rich variety of different data types.
|
|
An important aspect of the interface between <code>make</code> and GNU Guile
|
|
is the conversion of Guile data types into <code>make</code> strings.
|
|
</p>
|
|
<p>This conversion is relevant in two places: when a makefile invokes the
|
|
<code>guile</code> function to evaluate a Guile expression, the result of
|
|
that evaluation must be converted into a make string so it can be
|
|
further evaluated by <code>make</code>. And secondly, when a Guile script
|
|
invokes one of the procedures exported by <code>make</code> the argument
|
|
provided to the procedure must be converted into a string.
|
|
</p>
|
|
<p>The conversion of Guile types into <code>make</code> strings is as below:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>#f</code></dt>
|
|
<dd><p>False is converted into the empty string: in <code>make</code> conditionals
|
|
the empty string is considered false.
|
|
</p>
|
|
</dd>
|
|
<dt><code>#t</code></dt>
|
|
<dd><p>True is converted to the string ‘<samp>#t</samp>’: in <code>make</code> conditionals
|
|
any non-empty string is considered true.
|
|
</p>
|
|
</dd>
|
|
<dt><code>symbol</code></dt>
|
|
<dt><code>number</code></dt>
|
|
<dd><p>A symbol or number is converted into the string representation of that
|
|
symbol or number.
|
|
</p>
|
|
</dd>
|
|
<dt><code>character</code></dt>
|
|
<dd><p>A printable character is converted to the same character.
|
|
</p>
|
|
</dd>
|
|
<dt><code>string</code></dt>
|
|
<dd><p>A string containing only printable characters is converted to the same
|
|
string.
|
|
</p>
|
|
</dd>
|
|
<dt><code>list</code></dt>
|
|
<dd><p>A list is converted recursively according to the above rules. This
|
|
implies that any structured list will be flattened (that is, a result
|
|
of ‘<samp>'(a b (c d) e)</samp>’ will be converted to the <code>make</code> string
|
|
‘<samp>a b c d e</samp>’).
|
|
</p>
|
|
</dd>
|
|
<dt><code>other</code></dt>
|
|
<dd><p>Any other Guile type results in an error. In future versions of
|
|
<code>make</code>, other Guile types may be converted.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The translation of ‘<samp>#f</samp>’ (to the empty string) and ‘<samp>#t</samp>’ (to
|
|
the non-empty string ‘<samp>#t</samp>’) is designed to allow you to use Guile
|
|
boolean results directly as <code>make</code> boolean conditions. For
|
|
example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(if $(guile (access? "myfile" R_OK)),$(info myfile exists))
|
|
</pre></div>
|
|
|
|
<p>As a consequence of these conversion rules you must consider the
|
|
result of your Guile script, as that result will be converted into a
|
|
string and parsed by <code>make</code>. If there is no natural result for
|
|
the script (that is, the script exists solely for its side-effects),
|
|
you should add ‘<samp>#f</samp>’ as the final expression in order to avoid
|
|
syntax errors in your makefile.
|
|
</p>
|
|
<hr>
|
|
<span id="Guile-Interface"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Guile-Example" accesskey="n" rel="next">Guile Example</a>, Previous: <a href="#Guile-Types" accesskey="p" rel="prev">Guile Types</a>, Up: <a href="#Guile-Integration" accesskey="u" rel="up">Guile Integration</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Interfaces-from-Guile-to-make"></span><h4 class="subsection">12.1.2 Interfaces from Guile to <code>make</code></h4>
|
|
<span id="index-make-interface-to-guile"></span>
|
|
<span id="index-make-procedures-in-guile"></span>
|
|
|
|
<p>In addition to the <code>guile</code> function available in makefiles,
|
|
<code>make</code> exposes some procedures for use in your Guile scripts. At
|
|
startup <code>make</code> creates a new Guile module, <code>gnu make</code>, and
|
|
exports these procedures as public interfaces from that module:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>gmk-expand</code></dt>
|
|
<dd><span id="index-gmk_002dexpand"></span>
|
|
<p>This procedure takes a single argument which is converted into a
|
|
string. The string is expanded by <code>make</code> using normal
|
|
<code>make</code> expansion rules. The result of the expansion is converted
|
|
into a Guile string and provided as the result of the procedure.
|
|
</p>
|
|
</dd>
|
|
<dt><code>gmk-eval</code></dt>
|
|
<dd><span id="index-gmk_002deval"></span>
|
|
<p>This procedure takes a single argument which is converted into a
|
|
string. The string is evaluated by <code>make</code> as if it were a
|
|
makefile. This is the same capability available via the <code>eval</code>
|
|
function (see <a href="#Eval-Function">Eval Function</a>). The result of the <code>gmk-eval</code>
|
|
procedure is always the empty string.
|
|
</p>
|
|
<p>Note that <code>gmk-eval</code> is not quite the same as using
|
|
<code>gmk-expand</code> with the <code>eval</code> function: in the latter case
|
|
the evaluated string will be expanded <em>twice</em>; first by
|
|
<code>gmk-expand</code>, then again by the <code>eval</code> function.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Guile-Example"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Guile-Interface" accesskey="p" rel="prev">Guile Interface</a>, Up: <a href="#Guile-Integration" accesskey="u" rel="up">Guile Integration</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Example-Using-Guile-in-make"></span><h4 class="subsection">12.1.3 Example Using Guile in <code>make</code></h4>
|
|
<span id="index-Guile-example"></span>
|
|
<span id="index-example-using-Guile"></span>
|
|
|
|
<p>Here is a very simple example using GNU Guile to manage writing to a
|
|
file. These Guile procedures simply open a file, allow writing to the
|
|
file (one string per line), and close the file. Note that because we
|
|
cannot store complex values such as Guile ports in <code>make</code>
|
|
variables, we’ll keep the port as a global variable in the Guile
|
|
interpreter.
|
|
</p>
|
|
<p>You can create Guile functions easily using <code>define</code>/<code>endef</code>
|
|
to create a Guile script, then use the <code>guile</code> function to
|
|
internalize it:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">define GUILEIO
|
|
;; A simple Guile IO library for GNU make
|
|
|
|
(define MKPORT #f)
|
|
|
|
(define (mkopen name mode)
|
|
(set! MKPORT (open-file name mode))
|
|
#f)
|
|
|
|
(define (mkwrite s)
|
|
(display s MKPORT)
|
|
(newline MKPORT)
|
|
#f)
|
|
|
|
(define (mkclose)
|
|
(close-port MKPORT)
|
|
#f)
|
|
|
|
#f
|
|
endef
|
|
|
|
# Internalize the Guile IO functions
|
|
$(guile $(GUILEIO))
|
|
</pre></div>
|
|
|
|
<p>If you have a significant amount of Guile support code, you might
|
|
consider keeping it in a different file (e.g., <samp>guileio.scm</samp>) and
|
|
then loading it in your makefile using the <code>guile</code> function:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(guile (load "guileio.scm"))
|
|
</pre></div>
|
|
|
|
<p>An advantage to this method is that when editing <samp>guileio.scm</samp>,
|
|
your editor will understand that this file contains Scheme syntax
|
|
rather than makefile syntax.
|
|
</p>
|
|
<p>Now you can use these Guile functions to create files. Suppose you
|
|
need to operate on a very large list, which cannot fit on the command
|
|
line, but the utility you’re using accepts the list as input as well:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">prog: $(PREREQS)
|
|
@$(guile (mkopen "tmp.out" "w")) \
|
|
$(foreach X,$^,$(guile (mkwrite "$(X)"))) \
|
|
$(guile (mkclose))
|
|
$(LINK) < tmp.out
|
|
</pre></div>
|
|
|
|
<p>A more comprehensive suite of file manipulation procedures is possible
|
|
of course. You could, for example, maintain multiple output files at
|
|
the same time by choosing a symbol for each one and using it as the
|
|
key to a hash table, where the value is a port, then returning the
|
|
symbol to be stored in a <code>make</code> variable.
|
|
</p>
|
|
<hr>
|
|
<span id="Loading-Objects"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Guile-Integration" accesskey="p" rel="prev">Guile Integration</a>, Up: <a href="#Extending-make" accesskey="u" rel="up">Extending make</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Loading-Dynamic-Objects"></span><h3 class="section">12.2 Loading Dynamic Objects</h3>
|
|
<span id="index-loaded-objects"></span>
|
|
<span id="index-objects_002c-loaded"></span>
|
|
<span id="index-extensions_002c-loading"></span>
|
|
|
|
<table class="cartouche" border="1"><tr><td>
|
|
<blockquote>
|
|
<p><b>Warning:</b> The <code>load</code> directive and extension capability is considered a
|
|
“technology preview” in this release of GNU make. We encourage you
|
|
to experiment with this feature and we appreciate any feedback on it.
|
|
However we cannot guarantee to maintain backward-compatibility in the
|
|
next release. Consider using GNU Guile instead for extending GNU make
|
|
(see <a href="#Guile-Function">The <code>guile</code> Function</a>).
|
|
</p></blockquote>
|
|
</td></tr></table>
|
|
|
|
<p>Many operating systems provide a facility for dynamically loading
|
|
compiled objects. If your system provides this facility, GNU
|
|
<code>make</code> can make use of it to load dynamic objects at runtime,
|
|
providing new capabilities which may then be invoked by your makefile.
|
|
</p>
|
|
<p>The <code>load</code> directive is used to load a dynamic object. Once the
|
|
object is loaded, a “setup” function will be invoked to allow the
|
|
object to initialize itself and register new facilities with GNU
|
|
<code>make</code>. A dynamic object might include new <code>make</code> functions,
|
|
for example, and the “setup” function would register them with GNU
|
|
<code>make</code>’s function handling system.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#load-Directive" accesskey="1">load Directive</a></td><td> </td><td align="left" valign="top">Loading dynamic objects as extensions.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Remaking-Loaded-Objects" accesskey="2">Remaking Loaded Objects</a></td><td> </td><td align="left" valign="top">How loaded objects get remade.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Loaded-Object-API" accesskey="3">Loaded Object API</a></td><td> </td><td align="left" valign="top">Programmatic interface for loaded objects.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Loaded-Object-Example" accesskey="4">Loaded Object Example</a></td><td> </td><td align="left" valign="top">Example of a loaded object
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="load-Directive"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Remaking-Loaded-Objects" accesskey="n" rel="next">Remaking Loaded Objects</a>, Previous: <a href="#Loading-Objects" accesskey="p" rel="prev">Loading Objects</a>, Up: <a href="#Loading-Objects" accesskey="u" rel="up">Loading Objects</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="The-load-Directive"></span><h4 class="subsection">12.2.1 The <code>load</code> Directive</h4>
|
|
<span id="index-load-directive"></span>
|
|
<span id="index-extensions_002c-load-directive"></span>
|
|
|
|
<p>Objects are loaded into GNU <code>make</code> by placing the <code>load</code>
|
|
directive into your makefile. The syntax of the <code>load</code> directive
|
|
is as follows:
|
|
</p>
|
|
<span id="index-load"></span>
|
|
<div class="example">
|
|
<pre class="example">load <var>object-file</var> …
|
|
</pre></div>
|
|
|
|
<p>or:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">load <var>object-file</var>(<var>symbol-name</var>) …
|
|
</pre></div>
|
|
|
|
<p>The file <var>object-file</var> is dynamically loaded by GNU <code>make</code>.
|
|
If <var>object-file</var> does not include a directory path then it is
|
|
first looked for in the current directory. If it is not found there,
|
|
or a directory path is included, then system-specific paths will be
|
|
searched. If the load fails for any reason, <code>make</code> will print a
|
|
message and exit.
|
|
</p>
|
|
<p>If the load succeeds <code>make</code> will invoke an initializing function.
|
|
</p>
|
|
<p>If <var>symbol-name</var> is provided, it will be used as the name of the
|
|
initializing function.
|
|
</p>
|
|
<p>If no <var>symbol-name</var> is provided, the initializing function name is
|
|
created by taking the base file name of <var>object-file</var>, up to the
|
|
first character which is not a valid symbol name character
|
|
(alphanumerics and underscores are valid symbol name characters). To
|
|
this prefix will be appended the suffix <code>_gmk_setup</code>.
|
|
</p>
|
|
<p>More than one object file may be loaded with a single <code>load</code>
|
|
directive, and both forms of <code>load</code> arguments may be used in the
|
|
same directive.
|
|
</p>
|
|
<p>The initializing function will be provided the file name and line
|
|
number of the invocation of the <code>load</code> operation. It should
|
|
return a value of type <code>int</code>, which must be <code>0</code> on failure
|
|
and non-<code>0</code> on success. If the return value is <code>-1</code>, then
|
|
GNU make will <em>not</em> attempt to rebuild the object file
|
|
(see <a href="#Remaking-Loaded-Objects">How Loaded Objects Are Remade</a>).
|
|
</p>
|
|
<p>For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">load ../mk_funcs.so
|
|
</pre></div>
|
|
|
|
<p>will load the dynamic object <samp>../mk_funcs.so</samp>. After the object
|
|
is loaded, <code>make</code> will invoke the function (assumed to be defined
|
|
by the shared object) <code>mk_funcs_gmk_setup</code>.
|
|
</p>
|
|
<p>On the other hand:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">load ../mk_funcs.so(init_mk_func)
|
|
</pre></div>
|
|
|
|
<p>will load the dynamic object <samp>../mk_funcs.so</samp>. After the object
|
|
is loaded, <code>make</code> will invoke the function <code>init_mk_func</code>.
|
|
</p>
|
|
<p>Regardless of how many times an object file appears in a <code>load</code>
|
|
directive, it will only be loaded (and its setup function will only
|
|
be invoked) once.
|
|
</p>
|
|
<span id="index-_002eLOADED"></span>
|
|
<p>After an object has been successfully loaded, its file name is
|
|
appended to the <code>.LOADED</code> variable.
|
|
</p>
|
|
<span id="index-_002dload"></span>
|
|
<p>If you would prefer that failure to load a dynamic object not be
|
|
reported as an error, you can use the <code>-load</code> directive instead
|
|
of <code>load</code>. GNU <code>make</code> will not fail and no message will be
|
|
generated if an object fails to load. The failed object is not added
|
|
to the <code>.LOADED</code> variable, which can then be consulted to
|
|
determine if the load was successful.
|
|
</p>
|
|
<hr>
|
|
<span id="Remaking-Loaded-Objects"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Loaded-Object-API" accesskey="n" rel="next">Loaded Object API</a>, Previous: <a href="#load-Directive" accesskey="p" rel="prev">load Directive</a>, Up: <a href="#Loading-Objects" accesskey="u" rel="up">Loading Objects</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="How-Loaded-Objects-Are-Remade"></span><h4 class="subsection">12.2.2 How Loaded Objects Are Remade</h4>
|
|
<span id="index-updating-loaded-objects"></span>
|
|
<span id="index-remaking-loaded-objects"></span>
|
|
<span id="index-loaded-objects_002c-remaking-of"></span>
|
|
|
|
<p>Loaded objects undergo the same re-make procedure as makefiles
|
|
(see <a href="#Remaking-Makefiles">How Makefiles Are Remade</a>). If any
|
|
loaded object is recreated, then <code>make</code> will start from scratch
|
|
and re-read all the makefiles, and reload the object files again. It
|
|
is not necessary for the loaded object to do anything special to
|
|
support this.
|
|
</p>
|
|
<p>It’s up to the makefile author to provide the rules needed for
|
|
rebuilding the loaded object.
|
|
</p>
|
|
<hr>
|
|
<span id="Loaded-Object-API"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Loaded-Object-Example" accesskey="n" rel="next">Loaded Object Example</a>, Previous: <a href="#Remaking-Loaded-Objects" accesskey="p" rel="prev">Remaking Loaded Objects</a>, Up: <a href="#Loading-Objects" accesskey="u" rel="up">Loading Objects</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Loaded-Object-Interface"></span><h4 class="subsection">12.2.3 Loaded Object Interface</h4>
|
|
<span id="index-loaded-object-API"></span>
|
|
<span id="index-interface-for-loaded-objects"></span>
|
|
|
|
<table class="cartouche" border="1"><tr><td>
|
|
<blockquote>
|
|
<p><b>Warning:</b> For this feature to be useful your extensions will need to invoke
|
|
various functions internal to GNU <code>make</code>. The programming
|
|
interfaces provided in this release should not be considered stable:
|
|
functions may be added, removed, or change calling signatures or
|
|
implementations in future versions of GNU <code>make</code>.
|
|
</p></blockquote>
|
|
</td></tr></table>
|
|
|
|
<p>To be useful, loaded objects must be able to interact with GNU
|
|
<code>make</code>. This interaction includes both interfaces the loaded
|
|
object provides to makefiles and also interfaces <code>make</code> provides
|
|
to the loaded object to manipulate <code>make</code>’s operation.
|
|
</p>
|
|
<p>The interface between loaded objects and <code>make</code> is defined by the
|
|
<samp>gnumake.h</samp> C header file. All loaded objects written in C
|
|
should include this header file. Any loaded object not written in C
|
|
will need to implement the interface defined in this header file.
|
|
</p>
|
|
<p>Typically, a loaded object will register one or more new GNU
|
|
<code>make</code> functions using the <code>gmk_add_function</code> routine from
|
|
within its setup function. The implementations of these <code>make</code>
|
|
functions may make use of the <code>gmk_expand</code> and <code>gmk_eval</code>
|
|
routines to perform their tasks, then optionally return a string as
|
|
the result of the function expansion.
|
|
</p>
|
|
<span id="Loaded-Object-Licensing"></span><h4 class="subsubheading">Loaded Object Licensing</h4>
|
|
<span id="index-loaded-object-licensing"></span>
|
|
<span id="index-plugin_005fis_005fGPL_005fcompatible"></span>
|
|
|
|
<p>Every dynamic extension should define the global symbol
|
|
<code>plugin_is_GPL_compatible</code> to assert that it has been licensed
|
|
under a GPL-compatible license. If this symbol does not exist,
|
|
<code>make</code> emits a fatal error and exits when it tries to load your
|
|
extension.
|
|
</p>
|
|
<p>The declared type of the symbol should be <code>int</code>. It does not need
|
|
to be in any allocated section, though. The code merely asserts that
|
|
the symbol exists in the global scope. Something like this is enough:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">int plugin_is_GPL_compatible;
|
|
</pre></div>
|
|
|
|
<span id="Data-Structures"></span><h4 class="subsubheading">Data Structures</h4>
|
|
|
|
<dl compact="compact">
|
|
<dt><code>gmk_floc</code></dt>
|
|
<dd><p>This structure represents a filename/location pair. It is provided
|
|
when defining items, so GNU <code>make</code> can inform the user later
|
|
where the definition occurred if necessary.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<span id="Registering-Functions"></span><h4 class="subsubheading">Registering Functions</h4>
|
|
<span id="index-gmk_005fadd_005ffunction"></span>
|
|
|
|
<p>There is currently one way for makefiles to invoke operations provided
|
|
by the loaded object: through the <code>make</code> function call
|
|
interface. A loaded object can register one or more new functions
|
|
which may then be invoked from within the makefile in the same way as
|
|
any other function.
|
|
</p>
|
|
<p>Use <code>gmk_add_function</code> to create a new <code>make</code> function. Its
|
|
arguments are as follows:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>name</code></dt>
|
|
<dd><p>The function name. This is what the makefile should use to invoke the
|
|
function. The name must be between 1 and 255 characters long and it
|
|
may only contain alphanumeric, period (‘<samp>.</samp>’), dash (‘<samp>-</samp>’), and
|
|
underscore (‘<samp>_</samp>’) characters. It may not begin with a period.
|
|
</p>
|
|
</dd>
|
|
<dt><code>func_ptr</code></dt>
|
|
<dd><p>A pointer to a function that <code>make</code> will invoke when it expands
|
|
the function in a makefile. This function must be defined by the
|
|
loaded object.
|
|
</p>
|
|
</dd>
|
|
<dt><code>min_args</code></dt>
|
|
<dd><p>The minimum number of arguments the function will accept. Must be
|
|
between 0 and 255. GNU <code>make</code> will check this and fail before
|
|
invoking <code>func_ptr</code> if the function was invoked with too few
|
|
arguments.
|
|
</p>
|
|
</dd>
|
|
<dt><code>max_args</code></dt>
|
|
<dd><p>The maximum number of arguments the function will accept. Must be
|
|
between 0 and 255. GNU <code>make</code> will check this and fail before
|
|
invoking <code>func_ptr</code> if the function was invoked with too many
|
|
arguments. If the value is 0, then any number of arguments is
|
|
accepted. If the value is greater than 0, then it must be greater
|
|
than or equal to <code>min_args</code>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>flags</code></dt>
|
|
<dd><p>Flags that specify how this function will operate; the desired flags
|
|
should be OR’d together. If the <code>GMK_FUNC_NOEXPAND</code> flag is
|
|
given then the function arguments will not be expanded before the
|
|
function is called; otherwise they will be expanded first.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<span id="Registered-Function-Interface"></span><h4 class="subsubheading">Registered Function Interface</h4>
|
|
<span id="index-gmk_005ffunc_005fptr"></span>
|
|
|
|
<p>A function registered with <code>make</code> must match the
|
|
<code>gmk_func_ptr</code> type. It will be invoked with three parameters:
|
|
<code>name</code> (the name of the function), <code>argc</code> (the number of
|
|
arguments to the function), and <code>argv</code> (an array of pointers to
|
|
arguments to the function). The last pointer (that is,
|
|
<code>argv[argc]</code>) will be null (<code>0</code>).
|
|
</p>
|
|
<p>The return value of the function is the result of expanding the
|
|
function. If the function expands to nothing the return value may be
|
|
null. Otherwise, it must be a pointer to a string created with
|
|
<code>gmk_alloc</code>. Once the function returns, <code>make</code> owns this
|
|
string and will free it when appropriate; it cannot be accessed by the
|
|
loaded object.
|
|
</p>
|
|
<span id="GNU-make-Facilities"></span><h4 class="subsubheading">GNU <code>make</code> Facilities</h4>
|
|
|
|
<p>There are some facilities exported by GNU <code>make</code> for use by
|
|
loaded objects. Typically these would be run from within the
|
|
setup function and/or the functions registered via
|
|
<code>gmk_add_function</code>, to retrieve or modify the data <code>make</code>
|
|
works with.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>gmk_expand</code></dt>
|
|
<dd><span id="index-gmk_005fexpand"></span>
|
|
<p>This function takes a string and expands it using <code>make</code>
|
|
expansion rules. The result of the expansion is returned in a
|
|
nil-terminated string buffer. The caller is responsible for calling
|
|
<code>gmk_free</code> with a pointer to the returned buffer when done.
|
|
</p>
|
|
</dd>
|
|
<dt><code>gmk_eval</code></dt>
|
|
<dd><span id="index-gmk_005feval"></span>
|
|
<p>This function takes a buffer and evaluates it as a segment of makefile
|
|
syntax. This function can be used to define new variables, new rules,
|
|
etc. It is equivalent to using the <code>eval</code> <code>make</code> function.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Note that there is a difference between <code>gmk_eval</code> and calling
|
|
<code>gmk_expand</code> with a string using the <code>eval</code> function: in
|
|
the latter case the string will be expanded <em>twice</em>; once by
|
|
<code>gmk_expand</code> and then again by the <code>eval</code> function. Using
|
|
<code>gmk_eval</code> the buffer is only expanded once, at most (as it’s
|
|
read by the <code>make</code> parser).
|
|
</p>
|
|
<span id="Memory-Management"></span><h4 class="subsubheading">Memory Management</h4>
|
|
|
|
<p>Some systems allow for different memory management schemes. Thus you
|
|
should never pass memory that you’ve allocated directly to any
|
|
<code>make</code> function, nor should you attempt to directly free any
|
|
memory returned to you by any <code>make</code> function. Instead, use the
|
|
<code>gmk_alloc</code> and <code>gmk_free</code> functions.
|
|
</p>
|
|
<p>In particular, the string returned to <code>make</code> by a function
|
|
registered using <code>gmk_add_function</code> <em>must</em> be allocated
|
|
using <code>gmk_alloc</code>, and the string returned from the <code>make</code>
|
|
<code>gmk_expand</code> function <em>must</em> be freed (when no longer
|
|
needed) using <code>gmk_free</code>.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>gmk_alloc</code></dt>
|
|
<dd><span id="index-gmk_005falloc"></span>
|
|
<p>Return a pointer to a newly-allocated buffer. This function will
|
|
always return a valid pointer; if not enough memory is available
|
|
<code>make</code> will exit. <code>gmk_alloc</code> does not initialize allocated memory.
|
|
</p>
|
|
</dd>
|
|
<dt><code>gmk_free</code></dt>
|
|
<dd><span id="index-gmk_005ffree"></span>
|
|
<p>Free a buffer returned to you by <code>make</code>. Once the
|
|
<code>gmk_free</code> function returns the string will no longer be valid.
|
|
If NULL is passed to <code>gmk_free</code>, no operation is performed.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Loaded-Object-Example"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Loaded-Object-API" accesskey="p" rel="prev">Loaded Object API</a>, Up: <a href="#Loading-Objects" accesskey="u" rel="up">Loading Objects</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Example-Loaded-Object"></span><h4 class="subsection">12.2.4 Example Loaded Object</h4>
|
|
<span id="index-loaded-object-example"></span>
|
|
<span id="index-example-of-loaded-objects"></span>
|
|
|
|
<p>Let’s suppose we wanted to write a new GNU <code>make</code> function that
|
|
would create a temporary file and return its name. We would like our
|
|
function to take a prefix as an argument. First we can write the
|
|
function in a file <samp>mk_temp.c</samp>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
|
|
#include <gnumake.h>
|
|
|
|
int plugin_is_GPL_compatible;
|
|
|
|
char *
|
|
gen_tmpfile(const char *nm, int argc, char **argv)
|
|
{
|
|
int fd;
|
|
|
|
/* Compute the size of the filename and allocate space for it. */
|
|
int len = strlen (argv[0]) + 6 + 1;
|
|
char *buf = gmk_alloc (len);
|
|
|
|
strcpy (buf, argv[0]);
|
|
strcat (buf, "XXXXXX");
|
|
|
|
fd = mkstemp(buf);
|
|
if (fd >= 0)
|
|
{
|
|
/* Don't leak the file descriptor. */
|
|
close (fd);
|
|
return buf;
|
|
}
|
|
|
|
/* Failure. */
|
|
fprintf (stderr, "mkstemp(%s) failed: %s\n", buf, strerror (errno));
|
|
gmk_free (buf);
|
|
return NULL;
|
|
}
|
|
|
|
int
|
|
mk_temp_gmk_setup (const gmk_floc *floc)
|
|
{
|
|
printf ("mk_temp plugin loaded from %s:%lu\n", floc->filenm, floc->lineno);
|
|
/* Register the function with make name "mk-temp". */
|
|
gmk_add_function ("mk-temp", gen_tmpfile, 1, 1, 1);
|
|
return 1;
|
|
}
|
|
</pre></div>
|
|
|
|
<p>Next, we will write a <samp>Makefile</samp> that can build this shared object, load
|
|
it, and use it:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">all:
|
|
@echo Temporary file: $(mk-temp tmpfile.)
|
|
|
|
load mk_temp.so
|
|
|
|
mk_temp.so: mk_temp.c
|
|
$(CC) -shared -fPIC -o $@ $<
|
|
</pre></div>
|
|
|
|
<p>On MS-Windows, due to peculiarities of how shared objects are
|
|
produced, the compiler needs to scan the <em>import library</em> produced
|
|
when building <code>make</code>, typically called
|
|
<samp>libgnumake-<var>version</var>.dll.a</samp>, where <var>version</var> is the
|
|
version of the load object API. So the recipe to produce a shared
|
|
object will look on Windows like this (assuming the API version is 1):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">mk_temp.dll: mk_temp.c
|
|
$(CC) -shared -o $@ $< -lgnumake-1
|
|
</pre></div>
|
|
|
|
<p>Now when you run <code>make</code> you’ll see something like:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$ make
|
|
mk_temp plugin loaded from Makefile:4
|
|
cc -shared -fPIC -o mk_temp.so mk_temp.c
|
|
Temporary filename: tmpfile.A7JEwd
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Integrating-make"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Features" accesskey="n" rel="next">Features</a>, Previous: <a href="#Extending-make" accesskey="p" rel="prev">Extending make</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Integrating-GNU-make"></span><h2 class="chapter">13 Integrating GNU <code>make</code></h2>
|
|
<span id="index-make-integration"></span>
|
|
|
|
<p>GNU <code>make</code> is often one component in a larger system of tools,
|
|
including integrated development environments, compiler toolchains,
|
|
and others. The role of <code>make</code> is to start commands and
|
|
determine whether they succeeded or not: no special integration is
|
|
needed to accomplish that. However, sometimes it is convenient to
|
|
bind <code>make</code> more tightly with other parts of the system, both
|
|
higher-level (tools that invoke <code>make</code>) and lower-level (tools
|
|
that <code>make</code> invokes).
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Job-Slots" accesskey="1">Job Slots</a></td><td> </td><td align="left" valign="top">Share job slots with GNU <code>make</code>.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Terminal-Output" accesskey="2">Terminal Output</a></td><td> </td><td align="left" valign="top">Control output to terminals.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Job-Slots"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Terminal-Output" accesskey="n" rel="next">Terminal Output</a>, Previous: <a href="#Integrating-make" accesskey="p" rel="prev">Integrating make</a>, Up: <a href="#Integrating-make" accesskey="u" rel="up">Integrating make</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Sharing-Job-Slots-with-GNU-make"></span><h3 class="section">13.1 Sharing Job Slots with GNU <code>make</code></h3>
|
|
<span id="index-job-slots_002c-sharing"></span>
|
|
<span id="index-tools_002c-sharing-job-slots"></span>
|
|
|
|
<p>GNU <code>make</code> has the ability to run multiple recipes in parallel
|
|
(see <a href="#Parallel">Parallel Execution</a>) and to cap the total number of
|
|
parallel jobs even across recursive invocations of <code>make</code>
|
|
(see <a href="#Options_002fRecursion">Communicating Options to a
|
|
Sub-<code>make</code></a>). Tools that <code>make</code> invokes which are also able
|
|
to run multiple operations in parallel, either using multiple threads
|
|
or multiple processes, can be enhanced to participate in GNU
|
|
<code>make</code>’s job management facility to ensure that the total number
|
|
of active threads/processes running on the system does not exceed the
|
|
maximum number of slots provided to GNU <code>make</code>.
|
|
</p>
|
|
<span id="index-jobserver"></span>
|
|
<p>GNU <code>make</code> uses a method called the “jobserver” to control the
|
|
number of active jobs across recursive invocations. The actual
|
|
implementation of the jobserver varies across different operating
|
|
systems, but some fundamental aspects are always true.
|
|
</p>
|
|
<span id="index-_002d_002djobserver_002dauth"></span>
|
|
<p>First, <code>make</code> will provide information necessary for accessing the
|
|
jobserver through the environment to its children, in the <code>MAKEFLAGS</code>
|
|
environment variable. Tools which want to participate in the jobserver
|
|
protocol will need to parse this environment variable and find the word
|
|
starting with <code>--jobserver-auth=</code>. The value of this option will
|
|
describe how to communicate with the jobserver. The interpretation of this
|
|
value is described in the sections below.
|
|
</p>
|
|
<p>Be aware that the <code>MAKEFLAGS</code> variable may contain multiple instances of
|
|
the <code>--jobserver-auth=</code> option. Only the <em>last</em> instance is
|
|
relevant.
|
|
</p>
|
|
<p>Second, every command <code>make</code> starts has one implicit job slot
|
|
reserved for it before it starts. Any tool which wants to participate
|
|
in the jobserver protocol should assume it can always run one job
|
|
without having to contact the jobserver at all.
|
|
</p>
|
|
<p>Finally, it’s critical that tools that participate in the jobserver
|
|
protocol return the exact number of slots they obtained from the
|
|
jobserver back to the jobserver before they exit, even under error
|
|
conditions. Remember that the implicit job slot should <strong>not</strong>
|
|
be returned to the jobserver! Returning too few slots means that
|
|
those slots will be lost for the rest of the build process; returning
|
|
too many slots means that extra slots will be available. The
|
|
top-level <code>make</code> command will print an error message at the end
|
|
of the build if it detects an incorrect number of slots available in
|
|
the jobserver.
|
|
</p>
|
|
<p>As an example, suppose you are implementing a linker which provides
|
|
for multithreaded operation. You would like to enhance the linker so
|
|
that if it is invoked by GNU <code>make</code> it can participate in the
|
|
jobserver protocol to control how many threads are used during link.
|
|
First you will need to modify the linker to determine if the
|
|
<code>MAKEFLAGS</code> environment variable is set. Next you will need to
|
|
parse the value of that variable to determine if the jobserver is
|
|
available, and how to access it. If it is available then you can
|
|
access it to obtain job slots controlling how much parallelism your
|
|
tool can use. Once done your tool must return those job slots back to
|
|
the jobserver.
|
|
</p>
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#POSIX-Jobserver" accesskey="1">POSIX Jobserver</a></td><td> </td><td align="left" valign="top">Using the jobserver on POSIX systems.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Windows-Jobserver" accesskey="2">Windows Jobserver</a></td><td> </td><td align="left" valign="top">Using the jobserver on Windows systems.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="POSIX-Jobserver"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Windows-Jobserver" accesskey="n" rel="next">Windows Jobserver</a>, Previous: <a href="#Job-Slots" accesskey="p" rel="prev">Job Slots</a>, Up: <a href="#Job-Slots" accesskey="u" rel="up">Job Slots</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="POSIX-Jobserver-Interaction"></span><h4 class="subsection">13.1.1 POSIX Jobserver Interaction</h4>
|
|
<span id="index-jobserver-on-POSIX"></span>
|
|
|
|
<p>On POSIX systems the jobserver is implemented in one of two ways: on systems
|
|
that support it, GNU <code>make</code> will create a named pipe and use that for the
|
|
jobserver. In this case the auth option will have the form
|
|
<code>--jobserver-auth=fifo:PATH</code> where ‘<samp>PATH</samp>’ is the pathname of the
|
|
named pipe. To access the jobserver you should open the named pipe path and
|
|
read/write to it as described below.
|
|
</p>
|
|
<span id="index-_002d_002djobserver_002dstyle-1"></span>
|
|
<p>If the system doesn’t support named pipes, or if the user provided the
|
|
<code>--jobserver-style</code> option and specified ‘<samp>pipe</samp>’, then the jobserver
|
|
will be implemented as a simple UNIX pipe. In this case the auth option will
|
|
have the form <code>--jobserver-auth=R,W</code> where ‘<samp>R</samp>’ and ‘<samp>W</samp>’ are
|
|
non-negative integers representing file descriptors: ‘<samp>R</samp>’ is the read file
|
|
descriptor and ‘<samp>W</samp>’ is the write file descriptor. If either or both of
|
|
these file descriptors are negative, it means the jobserver is disabled for
|
|
this process.
|
|
</p>
|
|
<p>When using a simple pipe, only command lines that <code>make</code> understands to
|
|
be recursive invocations of <code>make</code> (see <a href="#MAKE-Variable">How the
|
|
<code>MAKE</code> Variable Works</a>) will have access to the jobserver. When writing
|
|
makefiles you must be sure to mark the command as recursive (most commonly by
|
|
prefixing the command line with the <code>+</code> indicator (see <a href="#Recursion">Recursive Use of <code>make</code></a>). Note that the read side of the jobserver
|
|
pipe is set to “blocking” mode. This should not be changed.
|
|
</p>
|
|
<p>In both implementations of the jobserver, the pipe will be pre-loaded with one
|
|
single-character token for each available job. To obtain an extra slot you
|
|
must read a single character from the jobserver; to release a slot you must
|
|
write a single character back into the jobserver.
|
|
</p>
|
|
<p>It’s important that when you release the job slot, you write back the same
|
|
character you read. Don’t assume that all tokens are the same character;
|
|
different characters may have different meanings to GNU <code>make</code>. The
|
|
order is not important, since <code>make</code> has no idea in what order jobs will
|
|
complete anyway.
|
|
</p>
|
|
<p>There are various error conditions you must consider to ensure your
|
|
implementation is robust:
|
|
</p>
|
|
<ul>
|
|
<li> If you have a command-line argument controlling the parallel operation of your
|
|
tool, consider whether your tool should detect situations where both the
|
|
jobserver and the command-line argument are specified, and how it should
|
|
react.
|
|
|
|
</li><li> If your tool does not recognize the format of the <code>--jobserver-auth</code>
|
|
string, it should assume the jobserver is using a different style and it
|
|
cannot connect.
|
|
|
|
</li><li> If your tool determines that the <code>--jobserver-auth</code> option references a
|
|
simple pipe but that the file descriptors specified are closed, this means
|
|
that the calling <code>make</code> process did not think that your tool was a
|
|
recursive <code>make</code> invocation (e.g., the command line was not prefixed with
|
|
a <code>+</code> character). You should notify your users of this situation.
|
|
|
|
</li><li> Your tool should be sure to write back the tokens it read, even under error
|
|
conditions. This includes not only errors in your tool but also outside
|
|
influences such as interrupts (<code>SIGINT</code>), etc. You may want to install
|
|
signal handlers to manage this write-back.
|
|
|
|
</li><li> Your tool may also examine the first word of the <code>MAKEFLAGS</code> variable and
|
|
look for the character <code>n</code>. If this character is present then
|
|
<code>make</code> was invoked with the ‘<samp>-n</samp>’ option and your tool may want to
|
|
stop without performing any operations.
|
|
</li></ul>
|
|
|
|
<hr>
|
|
<span id="Windows-Jobserver"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#POSIX-Jobserver" accesskey="p" rel="prev">POSIX Jobserver</a>, Up: <a href="#Job-Slots" accesskey="u" rel="up">Job Slots</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Windows-Jobserver-Interaction"></span><h4 class="subsection">13.1.2 Windows Jobserver Interaction</h4>
|
|
<span id="index-jobserver-on-Windows"></span>
|
|
|
|
<p>On Windows systems the jobserver is implemented as a named semaphore.
|
|
The semaphore will be set with an initial count equal to the number of
|
|
available slots; to obtain a slot you must wait on the semaphore (with
|
|
or without a timeout). To release a slot, release the semaphore.
|
|
</p>
|
|
<p>To access the semaphore you must parse the <code>MAKEFLAGS</code> variable and
|
|
look for the argument string <code>--jobserver-auth=NAME</code> where
|
|
‘<samp>NAME</samp>’ is the name of the named semaphore. Use this name with
|
|
<code>OpenSemaphore</code> to create a handle to the semaphore.
|
|
</p>
|
|
<span id="index-_002d_002djobserver_002dstyle-for-Windows"></span>
|
|
<p>The only valid style for <code>--jobserver-style</code> is ‘<samp>sem</samp>’.
|
|
</p>
|
|
<p>There are various error conditions you must consider to ensure your
|
|
implementation is robust:
|
|
</p>
|
|
<ul>
|
|
<li> Usually you will have a command-line argument controlling the parallel
|
|
operation of your tool. Consider whether your tool should detect
|
|
situations where both the jobserver and the command-line argument are
|
|
specified, and how it should react.
|
|
|
|
</li><li> Your tool should be sure to release the semaphore for the tokens it
|
|
read, even under error conditions. This includes not only errors in
|
|
your tool but also outside influences such as interrupts
|
|
(<code>SIGINT</code>), etc. You may want to install signal handlers to
|
|
manage this write-back.
|
|
</li></ul>
|
|
|
|
<hr>
|
|
<span id="Terminal-Output"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Job-Slots" accesskey="p" rel="prev">Job Slots</a>, Up: <a href="#Integrating-make" accesskey="u" rel="up">Integrating make</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Synchronized-Terminal-Output"></span><h3 class="section">13.2 Synchronized Terminal Output</h3>
|
|
<span id="index-parallel-output-to-terminal"></span>
|
|
<span id="index-terminal_002c-output-to"></span>
|
|
|
|
<p>Normally GNU <code>make</code> will invoke all commands with access to the
|
|
same standard and error outputs that <code>make</code> itself was started
|
|
with. A number of tools will detect whether the output is a terminal
|
|
or not-a-terminal, and use this information to change the output
|
|
style. For example if the output goes to a terminal the tool may add
|
|
control characters that set color, or even change the location of the
|
|
cursor. If the output is not going to a terminal then these special
|
|
control characters are not emitted so that they don’t corrupt log
|
|
files, etc.
|
|
</p>
|
|
<p>The <code>--output-sync</code> (see <a href="#Parallel-Output">Output During
|
|
Parallel Execution</a>) option will defeat the terminal detection. When
|
|
output synchronization is enabled GNU <code>make</code> arranges for all
|
|
command output to be written to a file, so that its output can be
|
|
written as a block without interference from other commands. This
|
|
means that all tools invoked by <code>make</code> will believe that their
|
|
output is not going to be displayed on a terminal, even when it will
|
|
be (because <code>make</code> will display it there after the command is
|
|
completed).
|
|
</p>
|
|
<p>In order to facilitate tools which would like to determine whether or
|
|
not their output will be displayed on a terminal, GNU <code>make</code> will
|
|
set the <code>MAKE_TERMOUT</code> and <code>MAKE_TERMERR</code> environment
|
|
variables before invoking any commands. Tools which would like to
|
|
determine whether standard or error output (respectively) will be
|
|
displayed on a terminal can check these environment variables to
|
|
determine if they exist and contain a non-empty value. If so the tool
|
|
can assume that the output will (eventually) be displayed on a
|
|
terminal. If the variables are not set or have an empty value, then
|
|
the tool should fall back to its normal methods of detecting whether
|
|
output is going to a terminal or not.
|
|
</p>
|
|
<p>The content of the variables can be parsed to determine the type of
|
|
terminal which will be used to display the output.
|
|
</p>
|
|
<p>Similarly, environments which invoke <code>make</code> and would like to
|
|
capture the output and eventually display it on a terminal (or some
|
|
display which can interpret terminal control characters) can set these
|
|
variables before invoking <code>make</code>. GNU <code>make</code> will not
|
|
modify these environment variables if they already exist when it
|
|
starts.
|
|
</p>
|
|
<hr>
|
|
<span id="Features"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Missing" accesskey="n" rel="next">Missing</a>, Previous: <a href="#Integrating-make" accesskey="p" rel="prev">Integrating make</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Features-of-GNU-make"></span><h2 class="chapter">14 Features of GNU <code>make</code></h2>
|
|
<span id="index-features-of-GNU-make"></span>
|
|
<span id="index-portability"></span>
|
|
<span id="index-compatibility"></span>
|
|
|
|
<p>Here is a summary of the features of GNU <code>make</code>, for comparison
|
|
with and credit to other versions of <code>make</code>. We consider the
|
|
features of <code>make</code> in 4.2 BSD systems as a baseline. If you are
|
|
concerned with writing portable makefiles, you should not use the
|
|
features of <code>make</code> listed here, nor the ones in <a href="#Missing">Missing</a>.
|
|
</p>
|
|
<p>Many features come from the version of <code>make</code> in System V.
|
|
</p>
|
|
<ul>
|
|
<li> The <code>VPATH</code> variable and its special meaning.
|
|
See <a href="#Directory-Search">Searching Directories for Prerequisites</a>.
|
|
This feature exists in System V <code>make</code>, but is undocumented.
|
|
It is documented in 4.3 BSD <code>make</code> (which says it mimics System V’s
|
|
<code>VPATH</code> feature).
|
|
|
|
</li><li> Included makefiles. See <a href="#Include">Including Other Makefiles</a>.
|
|
Allowing multiple files to be included with a single directive is a GNU
|
|
extension.
|
|
|
|
</li><li> Variables are read from and communicated via the environment.
|
|
See <a href="#Environment">Variables from the Environment</a>.
|
|
|
|
</li><li> Options passed through the variable <code>MAKEFLAGS</code> to recursive
|
|
invocations of <code>make</code>.
|
|
See <a href="#Options_002fRecursion">Communicating Options to a Sub-<code>make</code></a>.
|
|
|
|
</li><li> The automatic variable <code>$%</code> is set to the member name
|
|
in an archive reference. See <a href="#Automatic-Variables">Automatic Variables</a>.
|
|
|
|
</li><li> The automatic variables <code>$@</code>, <code>$*</code>, <code>$<</code>, <code>$%</code>,
|
|
and <code>$?</code> have corresponding forms like <code>$(@F)</code> and
|
|
<code>$(@D)</code>. We have generalized this to <code>$^</code> as an obvious
|
|
extension. See <a href="#Automatic-Variables">Automatic Variables</a>.
|
|
|
|
</li><li> Substitution variable references.
|
|
See <a href="#Reference">Basics of Variable References</a>.
|
|
|
|
</li><li> The command line options ‘<samp>-b</samp>’ and ‘<samp>-m</samp>’, accepted and
|
|
ignored. In System V <code>make</code>, these options actually do something.
|
|
|
|
</li><li> Execution of recursive commands to run <code>make</code> via the variable
|
|
<code>MAKE</code> even if ‘<samp>-n</samp>’, ‘<samp>-q</samp>’ or ‘<samp>-t</samp>’ is specified.
|
|
See <a href="#Recursion">Recursive Use of <code>make</code></a>.
|
|
|
|
</li><li> Support for suffix ‘<samp>.a</samp>’ in suffix rules. See <a href="#Archive-Suffix-Rules">Archive Suffix Rules</a>. This feature is obsolete in GNU <code>make</code>, because the
|
|
general feature of rule chaining (see <a href="#Chained-Rules">Chains of
|
|
Implicit Rules</a>) allows one pattern rule for installing members in an
|
|
archive (see <a href="#Archive-Update">Archive Update</a>) to be sufficient.
|
|
|
|
</li><li> The arrangement of lines and backslash/newline combinations in
|
|
recipes is retained when the recipes are printed, so they appear as
|
|
they do in the makefile, except for the stripping of initial
|
|
whitespace.
|
|
</li></ul>
|
|
|
|
<p>The following features were inspired by various other versions of
|
|
<code>make</code>. In some cases it is unclear exactly which versions inspired
|
|
which others.
|
|
</p>
|
|
<ul>
|
|
<li> Pattern rules using ‘<samp>%</samp>’.
|
|
This has been implemented in several versions of <code>make</code>.
|
|
We’re not sure who invented it first, but it’s been spread around a bit.
|
|
See <a href="#Pattern-Rules">Defining and Redefining Pattern Rules</a>.
|
|
|
|
</li><li> Rule chaining and implicit intermediate files.
|
|
This was implemented by Stu Feldman in his version of <code>make</code>
|
|
for AT&T Eighth Edition Research Unix, and later by Andrew Hume of
|
|
AT&T Bell Labs in his <code>mk</code> program (where he terms it
|
|
“transitive closure”). We do not really know if
|
|
we got this from either of them or thought it up ourselves at the
|
|
same time. See <a href="#Chained-Rules">Chains of Implicit Rules</a>.
|
|
|
|
</li><li> The automatic variable <code>$^</code> containing a list of all prerequisites
|
|
of the current target. We did not invent this, but we have no idea who
|
|
did. See <a href="#Automatic-Variables">Automatic Variables</a>. The automatic variable
|
|
<code>$+</code> is a simple extension of <code>$^</code>.
|
|
|
|
</li><li> The “what if” flag (‘<samp>-W</samp>’ in GNU <code>make</code>) was (as far as we know)
|
|
invented by Andrew Hume in <code>mk</code>.
|
|
See <a href="#Instead-of-Execution">Instead of Executing Recipes</a>.
|
|
|
|
</li><li> The concept of doing several things at once (parallelism) exists in
|
|
many incarnations of <code>make</code> and similar programs, though not in the
|
|
System V or BSD implementations. See <a href="#Execution">Recipe Execution</a>.
|
|
|
|
</li><li> A number of different build tools that support parallelism also
|
|
support collecting output and displaying as a single block.
|
|
See <a href="#Parallel-Output">Output During Parallel Execution</a>.
|
|
|
|
</li><li> Modified variable references using pattern substitution come from
|
|
SunOS 4. See <a href="#Reference">Basics of Variable References</a>.
|
|
This functionality was provided in GNU <code>make</code> by the
|
|
<code>patsubst</code> function before the alternate syntax was implemented
|
|
for compatibility with SunOS 4. It is not altogether clear who
|
|
inspired whom, since GNU <code>make</code> had <code>patsubst</code> before SunOS
|
|
4 was released.
|
|
|
|
</li><li> The special significance of ‘<samp>+</samp>’ characters preceding recipe lines
|
|
(see <a href="#Instead-of-Execution">Instead of Executing Recipes</a>) is
|
|
mandated by <cite>IEEE Standard 1003.2-1992</cite> (POSIX.2).
|
|
|
|
</li><li> The ‘<samp>+=</samp>’ syntax to append to the value of a variable comes from SunOS
|
|
4 <code>make</code>. See <a href="#Appending">Appending More Text to Variables</a>.
|
|
|
|
</li><li> The syntax ‘<samp><var>archive</var>(<var>mem1</var> <var>mem2</var>…)</samp>’<!-- /@w --> to list
|
|
multiple members in a single archive file comes from SunOS 4 <code>make</code>.
|
|
See <a href="#Archive-Members">Archive Members</a>.
|
|
|
|
</li><li> The <code>-include</code> directive to include makefiles with no error for a
|
|
nonexistent file comes from SunOS 4 <code>make</code>. (But note that SunOS 4
|
|
<code>make</code> does not allow multiple makefiles to be specified in one
|
|
<code>-include</code> directive.) The same feature appears with the name
|
|
<code>sinclude</code> in SGI <code>make</code> and perhaps others.
|
|
|
|
</li><li> The <code>!=</code> shell assignment operator exists in many BSD of
|
|
<code>make</code> and is purposefully implemented here to behave identically
|
|
to those implementations.
|
|
|
|
</li><li> Various build management tools are implemented using scripting
|
|
languages such as Perl or Python and thus provide a natural embedded
|
|
scripting language, similar to GNU <code>make</code>’s integration of GNU
|
|
Guile.
|
|
</li></ul>
|
|
|
|
<p>The remaining features are inventions new in GNU <code>make</code>:
|
|
</p>
|
|
<ul>
|
|
<li> Use the ‘<samp>-v</samp>’ or ‘<samp>--version</samp>’ option to print version and
|
|
copyright information.
|
|
|
|
</li><li> Use the ‘<samp>-h</samp>’ or ‘<samp>--help</samp>’ option to summarize the options to
|
|
<code>make</code>.
|
|
|
|
</li><li> Simply-expanded variables. See <a href="#Flavors">The Two Flavors of Variables</a>.
|
|
|
|
</li><li> Pass command line variable assignments automatically through the
|
|
variable <code>MAKE</code> to recursive <code>make</code> invocations.
|
|
See <a href="#Recursion">Recursive Use of <code>make</code></a>.
|
|
|
|
</li><li> Use the ‘<samp>-C</samp>’ or ‘<samp>--directory</samp>’ command option to change
|
|
directory. See <a href="#Options-Summary">Summary of Options</a>.
|
|
|
|
</li><li> Make verbatim variable definitions with <code>define</code>.
|
|
See <a href="#Multi_002dLine">Defining Multi-Line Variables</a>.
|
|
|
|
</li><li> Declare phony targets with the special target <code>.PHONY</code>.
|
|
|
|
<p>Andrew Hume of AT&T Bell Labs implemented a similar feature with a
|
|
different syntax in his <code>mk</code> program. This seems to be a case of
|
|
parallel discovery. See <a href="#Phony-Targets">Phony Targets</a>.
|
|
</p>
|
|
</li><li> Manipulate text by calling functions.
|
|
See <a href="#Functions">Functions for Transforming Text</a>.
|
|
|
|
</li><li> Use the ‘<samp>-o</samp>’ or ‘<samp>--old-file</samp>’
|
|
option to pretend a file’s modification-time is old.
|
|
See <a href="#Avoiding-Compilation">Avoiding Recompilation of Some Files</a>.
|
|
|
|
</li><li> Conditional execution.
|
|
|
|
<p>This feature has been implemented numerous times in various versions
|
|
of <code>make</code>; it seems a natural extension derived from the features
|
|
of the C preprocessor and similar macro languages and is not a
|
|
revolutionary concept. See <a href="#Conditionals">Conditional Parts of Makefiles</a>.
|
|
</p>
|
|
</li><li> Specify a search path for included makefiles.
|
|
See <a href="#Include">Including Other Makefiles</a>.
|
|
|
|
</li><li> Specify extra makefiles to read with an environment variable.
|
|
See <a href="#MAKEFILES-Variable">The Variable <code>MAKEFILES</code></a>.
|
|
|
|
</li><li> Strip leading sequences of ‘<samp>./</samp>’ from file names, so that
|
|
<samp>./<var>file</var></samp> and <samp><var>file</var></samp> are considered to be the
|
|
same file.
|
|
|
|
</li><li> Use a special search method for library prerequisites written in the
|
|
form ‘<samp>-l<var>name</var></samp>’.
|
|
See <a href="#Libraries_002fSearch">Directory Search for Link Libraries</a>.
|
|
|
|
</li><li> Allow suffixes for suffix rules
|
|
(see <a href="#Suffix-Rules">Old-Fashioned Suffix Rules</a>) to contain any
|
|
characters. In other versions of <code>make</code>, they must begin with
|
|
‘<samp>.</samp>’ and not contain any ‘<samp>/</samp>’ characters.
|
|
|
|
</li><li> Keep track of the current level of <code>make</code> recursion using the
|
|
variable <code>MAKELEVEL</code>. See <a href="#Recursion">Recursive Use of <code>make</code></a>.
|
|
|
|
</li><li> Provide any goals given on the command line in the variable
|
|
<code>MAKECMDGOALS</code>. See <a href="#Goals">Arguments to Specify the Goals</a>.
|
|
|
|
</li><li> Specify static pattern rules. See <a href="#Static-Pattern">Static Pattern Rules</a>.
|
|
|
|
</li><li> Provide selective <code>vpath</code> search.
|
|
See <a href="#Directory-Search">Searching Directories for Prerequisites</a>.
|
|
|
|
</li><li> Provide computed variable references.
|
|
See <a href="#Reference">Basics of Variable References</a>.
|
|
|
|
</li><li> Update makefiles. See <a href="#Remaking-Makefiles">How Makefiles Are Remade</a>.
|
|
System V <code>make</code> has a very, very limited form of this
|
|
functionality in that it will check out SCCS files for makefiles.
|
|
|
|
</li><li> Various new built-in implicit rules.
|
|
See <a href="#Catalogue-of-Rules">Catalogue of Built-In Rules</a>.
|
|
|
|
</li><li> Load dynamic objects which can modify the behavior of <code>make</code>.
|
|
See <a href="#Loading-Objects">Loading Dynamic Objects</a>.
|
|
</li></ul>
|
|
|
|
<hr>
|
|
<span id="Missing"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Makefile-Conventions" accesskey="n" rel="next">Makefile Conventions</a>, Previous: <a href="#Features" accesskey="p" rel="prev">Features</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Incompatibilities-and-Missing-Features"></span><h2 class="chapter">15 Incompatibilities and Missing Features</h2>
|
|
<span id="index-incompatibilities"></span>
|
|
<span id="index-missing-features"></span>
|
|
<span id="index-features_002c-missing"></span>
|
|
|
|
<p>The <code>make</code> programs in various other systems support a few features
|
|
that are not implemented in GNU <code>make</code>. The POSIX.2 standard
|
|
(<cite>IEEE Standard 1003.2-1992</cite>) which specifies <code>make</code> does not
|
|
require any of these features.
|
|
</p>
|
|
<ul>
|
|
<li> A target of the form ‘<samp><var>file</var>((<var>entry</var>))</samp>’ stands for a member
|
|
of archive file <var>file</var>. The member is chosen, not by name, but by
|
|
being an object file which defines the linker symbol <var>entry</var>.
|
|
|
|
<p>This feature was not put into GNU <code>make</code> because of the
|
|
non-modularity of putting knowledge into <code>make</code> of the internal
|
|
format of archive file symbol tables.
|
|
See <a href="#Archive-Symbols">Updating Archive Symbol Directories</a>.
|
|
</p>
|
|
</li><li> Suffixes (used in suffix rules) that end with the character ‘<samp>~</samp>’
|
|
have a special meaning to System V <code>make</code>;
|
|
they refer to the SCCS file that corresponds
|
|
to the file one would get without the ‘<samp>~</samp>’. For example, the
|
|
suffix rule ‘<samp>.c~.o</samp>’ would make the file <samp><var>n</var>.o</samp> from
|
|
the SCCS file <samp>s.<var>n</var>.c</samp>. For complete coverage, a whole
|
|
series of such suffix rules is required.
|
|
See <a href="#Suffix-Rules">Old-Fashioned Suffix Rules</a>.
|
|
|
|
<p>In GNU <code>make</code>, this entire series of cases is handled by two
|
|
pattern rules for extraction from SCCS, in combination with the
|
|
general feature of rule chaining.
|
|
See <a href="#Chained-Rules">Chains of Implicit Rules</a>.
|
|
</p>
|
|
</li><li> In System V and 4.3 BSD <code>make</code>, files found by <code>VPATH</code>
|
|
search (see <a href="#Directory-Search">Searching Directories for
|
|
Prerequisites</a>) have their names changed inside recipes. We feel it
|
|
is much cleaner to always use automatic variables and thus make this
|
|
feature unnecessary.
|
|
|
|
</li><li> In some Unix <code>make</code>s, the automatic variable <code>$*</code> appearing in
|
|
the prerequisites of a rule has the amazingly strange “feature” of
|
|
expanding to the full name of the <em>target of that rule</em>. We cannot
|
|
imagine what went on in the minds of Unix <code>make</code> developers to do
|
|
this; it is utterly inconsistent with the normal definition of <code>$*</code>.
|
|
<span id="index-_002a-_0028automatic-variable_0029_002c-unsupported-bizarre-usage"></span>
|
|
|
|
</li><li> In some Unix <code>make</code>s, implicit rule search (see <a href="#Implicit-Rules">Using Implicit Rules</a>) is apparently done for <em>all</em>
|
|
targets, not just those without recipes. This means you can
|
|
do:
|
|
|
|
<div class="example">
|
|
<pre class="example">foo.o:
|
|
cc -c foo.c
|
|
</pre></div>
|
|
|
|
<p>and Unix <code>make</code> will intuit that <samp>foo.o</samp> depends on
|
|
<samp>foo.c</samp>.
|
|
</p>
|
|
<p>We feel that such usage is broken. The prerequisite properties of
|
|
<code>make</code> are well-defined (for GNU <code>make</code>, at least),
|
|
and doing such a thing simply does not fit the model.
|
|
</p>
|
|
</li><li> GNU <code>make</code> does not include any built-in implicit rules for
|
|
compiling or preprocessing EFL programs. If we hear of anyone who is
|
|
using EFL, we will gladly add them.
|
|
|
|
</li><li> It appears that in SVR4 <code>make</code>, a suffix rule can be specified
|
|
with no recipe, and it is treated as if it had an empty recipe
|
|
(see <a href="#Empty-Recipes">Empty Recipes</a>). For example:
|
|
|
|
<div class="example">
|
|
<pre class="example">.c.a:
|
|
</pre></div>
|
|
|
|
<p>will override the built-in <samp>.c.a</samp> suffix rule.
|
|
</p>
|
|
<p>We feel that it is cleaner for a rule without a recipe to always simply
|
|
add to the prerequisite list for the target. The above example can be
|
|
easily rewritten to get the desired behavior in GNU <code>make</code>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.c.a: ;
|
|
</pre></div>
|
|
|
|
</li><li> Some versions of <code>make</code> invoke the shell with the ‘<samp>-e</samp>’ flag,
|
|
except under ‘<samp>-k</samp>’ (see <a href="#Testing">Testing the Compilation of a
|
|
Program</a>). The ‘<samp>-e</samp>’ flag tells the shell to exit as soon as any
|
|
program it runs returns a nonzero status. We feel it is cleaner to
|
|
write each line of the recipe to stand on its own and not require this
|
|
special treatment.
|
|
</li></ul>
|
|
|
|
|
|
<hr>
|
|
<span id="Makefile-Conventions"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Quick-Reference" accesskey="n" rel="next">Quick Reference</a>, Previous: <a href="#Missing" accesskey="p" rel="prev">Missing</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Makefile-Conventions-1"></span><h2 class="chapter">16 Makefile Conventions</h2>
|
|
<span id="index-makefile_002c-conventions-for"></span>
|
|
<span id="index-conventions-for-makefiles"></span>
|
|
<span id="index-standards-for-makefiles"></span>
|
|
|
|
|
|
<p>This
|
|
describes conventions for writing the Makefiles for GNU programs.
|
|
Using Automake will help you write a Makefile that follows these
|
|
conventions. For more information on portable Makefiles, see
|
|
<small>POSIX</small> and <a href="https://www.gnu.org/software/autoconf/manual/autoconf.html#Portable-Make">Portable Make Programming</a> in <cite>Autoconf</cite>.
|
|
</p>
|
|
|
|
<table class="menu" border="0" cellspacing="0">
|
|
<tr><td align="left" valign="top">• <a href="#Makefile-Basics" accesskey="1">Makefile Basics</a></td><td> </td><td align="left" valign="top">General conventions for Makefiles.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Utilities-in-Makefiles" accesskey="2">Utilities in Makefiles</a></td><td> </td><td align="left" valign="top">Utilities to be used in Makefiles.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Command-Variables" accesskey="3">Command Variables</a></td><td> </td><td align="left" valign="top">Variables for specifying commands.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#DESTDIR" accesskey="4">DESTDIR</a></td><td> </td><td align="left" valign="top">Supporting staged installs.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Directory-Variables" accesskey="5">Directory Variables</a></td><td> </td><td align="left" valign="top">Variables for installation directories.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Standard-Targets" accesskey="6">Standard Targets</a></td><td> </td><td align="left" valign="top">Standard targets for users.
|
|
</td></tr>
|
|
<tr><td align="left" valign="top">• <a href="#Install-Command-Categories" accesskey="7">Install Command Categories</a></td><td> </td><td align="left" valign="top">Three categories of commands in the ‘<samp>install</samp>’
|
|
rule: normal, pre-install and post-install.
|
|
</td></tr>
|
|
</table>
|
|
|
|
<hr>
|
|
<span id="Makefile-Basics"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Utilities-in-Makefiles" accesskey="n" rel="next">Utilities in Makefiles</a>, Up: <a href="#Makefile-Conventions" accesskey="u" rel="up">Makefile Conventions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="General-Conventions-for-Makefiles"></span><h3 class="section">16.1 General Conventions for Makefiles</h3>
|
|
|
|
<p>Every Makefile should contain this line:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">SHELL = /bin/sh
|
|
</pre></div>
|
|
|
|
<p>to avoid trouble on systems where the <code>SHELL</code> variable might be
|
|
inherited from the environment. (This is never a problem with GNU
|
|
<code>make</code>.)
|
|
</p>
|
|
<p>Different <code>make</code> programs have incompatible suffix lists and
|
|
implicit rules, and this sometimes creates confusion or misbehavior. So
|
|
it is a good idea to set the suffix list explicitly using only the
|
|
suffixes you need in the particular Makefile, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.SUFFIXES:
|
|
.SUFFIXES: .c .o
|
|
</pre></div>
|
|
|
|
<p>The first line clears out the suffix list, the second introduces all
|
|
suffixes which may be subject to implicit rules in this Makefile.
|
|
</p>
|
|
<p>Don’t assume that <samp>.</samp> is in the path for command execution. When
|
|
you need to run programs that are a part of your package during the
|
|
make, please make sure that it uses <samp>./</samp> if the program is built as
|
|
part of the make or <samp>$(srcdir)/</samp> if the file is an unchanging part
|
|
of the source code. Without one of these prefixes, the current search
|
|
path is used.
|
|
</p>
|
|
<p>The distinction between <samp>./</samp> (the <em>build directory</em>) and
|
|
<samp>$(srcdir)/</samp> (the <em>source directory</em>) is important because
|
|
users can build in a separate directory using the ‘<samp>--srcdir</samp>’ option
|
|
to <samp>configure</samp>. A rule of the form:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.1 : foo.man sedscript
|
|
sed -f sedscript foo.man > foo.1
|
|
</pre></div>
|
|
|
|
<p>will fail when the build directory is not the source directory, because
|
|
<samp>foo.man</samp> and <samp>sedscript</samp> are in the source directory.
|
|
</p>
|
|
<p>When using GNU <code>make</code>, relying on ‘<samp>VPATH</samp>’ to find the source
|
|
file will work in the case where there is a single dependency file,
|
|
since the <code>make</code> automatic variable ‘<samp>$<</samp>’ will represent the
|
|
source file wherever it is. (Many versions of <code>make</code> set ‘<samp>$<</samp>’
|
|
only in implicit rules.) A Makefile target like
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.o : bar.c
|
|
$(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
|
|
</pre></div>
|
|
|
|
<p>should instead be written as
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.o : bar.c
|
|
$(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@
|
|
</pre></div>
|
|
|
|
<p>in order to allow ‘<samp>VPATH</samp>’ to work correctly. When the target has
|
|
multiple dependencies, using an explicit ‘<samp>$(srcdir)</samp>’ is the easiest
|
|
way to make the rule work well. For example, the target above for
|
|
<samp>foo.1</samp> is best written as:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">foo.1 : foo.man sedscript
|
|
sed -f $(srcdir)/sedscript $(srcdir)/foo.man > $@
|
|
</pre></div>
|
|
|
|
<p>GNU distributions usually contain some files which are not source
|
|
files—for example, Info files, and the output from Autoconf, Automake,
|
|
Bison or Flex. Since these files normally appear in the source
|
|
directory, they should always appear in the source directory, not in the
|
|
build directory. So Makefile rules to update them should put the
|
|
updated files in the source directory.
|
|
</p>
|
|
<p>However, if a file does not appear in the distribution, then the
|
|
Makefile should not put it in the source directory, because building a
|
|
program in ordinary circumstances should not modify the source directory
|
|
in any way.
|
|
</p>
|
|
<p>Try to make the build and installation targets, at least (and all their
|
|
subtargets) work correctly with a parallel <code>make</code>.
|
|
</p>
|
|
<hr>
|
|
<span id="Utilities-in-Makefiles"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Command-Variables" accesskey="n" rel="next">Command Variables</a>, Previous: <a href="#Makefile-Basics" accesskey="p" rel="prev">Makefile Basics</a>, Up: <a href="#Makefile-Conventions" accesskey="u" rel="up">Makefile Conventions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Utilities-in-Makefiles-1"></span><h3 class="section">16.2 Utilities in Makefiles</h3>
|
|
|
|
<p>Write the Makefile commands (and any shell scripts, such as
|
|
<code>configure</code>) to run under <code>sh</code> (both the traditional Bourne
|
|
shell and the <small>POSIX</small> shell), not <code>csh</code>. Don’t use any
|
|
special features of <code>ksh</code> or <code>bash</code>, or <small>POSIX</small> features
|
|
not widely supported in traditional Bourne <code>sh</code>.
|
|
</p>
|
|
<p>The <code>configure</code> script and the Makefile rules for building and
|
|
installation should not use any utilities directly except these:
|
|
</p>
|
|
|
|
<div class="example">
|
|
<pre class="example">awk cat cmp cp diff echo egrep expr false grep install-info ln ls
|
|
mkdir mv printf pwd rm rmdir sed sleep sort tar test touch tr true
|
|
</pre></div>
|
|
|
|
<p>Compression programs such as <code>gzip</code> can be used in the
|
|
<code>dist</code> rule.
|
|
</p>
|
|
<p>Generally, stick to the widely-supported (usually
|
|
<small>POSIX</small>-specified) options and features of these programs. For
|
|
example, don’t use ‘<samp>mkdir -p</samp>’, convenient as it may be, because a
|
|
few systems don’t support it at all and with others, it is not safe
|
|
for parallel execution. For a list of known incompatibilities, see
|
|
<a href="https://www.gnu.org/software/autoconf/manual/autoconf.html#Portable-Shell">Portable Shell Programming</a> in <cite>Autoconf</cite>.
|
|
</p>
|
|
|
|
<p>It is a good idea to avoid creating symbolic links in makefiles, since a
|
|
few file systems don’t support them.
|
|
</p>
|
|
<p>The Makefile rules for building and installation can also use compilers
|
|
and related programs, but should do so via <code>make</code> variables so that the
|
|
user can substitute alternatives. Here are some of the programs we
|
|
mean:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">ar bison cc flex install ld ldconfig lex
|
|
make makeinfo ranlib texi2dvi yacc
|
|
</pre></div>
|
|
|
|
<p>Use the following <code>make</code> variables to run those programs:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
|
|
$(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
|
|
</pre></div>
|
|
|
|
<p>When you use <code>ranlib</code> or <code>ldconfig</code>, you should make sure
|
|
nothing bad happens if the system does not have the program in question.
|
|
Arrange to ignore an error from that command, and print a message before
|
|
the command to tell the user that failure of this command does not mean
|
|
a problem. (The Autoconf ‘<samp>AC_PROG_RANLIB</samp>’ macro can help with
|
|
this.)
|
|
</p>
|
|
<p>If you use symbolic links, you should implement a fallback for systems
|
|
that don’t have symbolic links.
|
|
</p>
|
|
<p>Additional utilities that can be used via Make variables are:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">chgrp chmod chown mknod
|
|
</pre></div>
|
|
|
|
<p>It is ok to use other utilities in Makefile portions (or scripts)
|
|
intended only for particular systems where you know those utilities
|
|
exist.
|
|
</p>
|
|
<hr>
|
|
<span id="Command-Variables"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#DESTDIR" accesskey="n" rel="next">DESTDIR</a>, Previous: <a href="#Utilities-in-Makefiles" accesskey="p" rel="prev">Utilities in Makefiles</a>, Up: <a href="#Makefile-Conventions" accesskey="u" rel="up">Makefile Conventions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Variables-for-Specifying-Commands"></span><h3 class="section">16.3 Variables for Specifying Commands</h3>
|
|
|
|
<p>Makefiles should provide variables for overriding certain commands, options,
|
|
and so on.
|
|
</p>
|
|
<p>In particular, you should run most utility programs via variables.
|
|
Thus, if you use Bison, have a variable named <code>BISON</code> whose default
|
|
value is set with ‘<samp>BISON = bison</samp>’, and refer to it with
|
|
<code>$(BISON)</code> whenever you need to use Bison.
|
|
</p>
|
|
<p>File management utilities such as <code>ln</code>, <code>rm</code>, <code>mv</code>, and
|
|
so on, need not be referred to through variables in this way, since users
|
|
don’t need to replace them with other programs.
|
|
</p>
|
|
<p>Each program-name variable should come with an options variable that is
|
|
used to supply options to the program. Append ‘<samp>FLAGS</samp>’ to the
|
|
program-name variable name to get the options variable name—for
|
|
example, <code>BISONFLAGS</code>. (The names <code>CFLAGS</code> for the C
|
|
compiler, <code>YFLAGS</code> for yacc, and <code>LFLAGS</code> for lex, are
|
|
exceptions to this rule, but we keep them because they are standard.)
|
|
Use <code>CPPFLAGS</code> in any compilation command that runs the
|
|
preprocessor, and use <code>LDFLAGS</code> in any compilation command that
|
|
does linking as well as in any direct use of <code>ld</code>.
|
|
</p>
|
|
<p>If there are C compiler options that <em>must</em> be used for proper
|
|
compilation of certain files, do not include them in <code>CFLAGS</code>.
|
|
Users expect to be able to specify <code>CFLAGS</code> freely themselves.
|
|
Instead, arrange to pass the necessary options to the C compiler
|
|
independently of <code>CFLAGS</code>, by writing them explicitly in the
|
|
compilation commands or by defining an implicit rule, like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">CFLAGS = -g
|
|
ALL_CFLAGS = -I. $(CFLAGS)
|
|
.c.o:
|
|
$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
|
|
</pre></div>
|
|
|
|
<p>Do include the ‘<samp>-g</samp>’ option in <code>CFLAGS</code>, because that is not
|
|
<em>required</em> for proper compilation. You can consider it a default
|
|
that is only recommended. If the package is set up so that it is
|
|
compiled with GCC by default, then you might as well include ‘<samp>-O</samp>’
|
|
in the default value of <code>CFLAGS</code> as well.
|
|
</p>
|
|
<p>Put <code>CFLAGS</code> last in the compilation command, after other variables
|
|
containing compiler options, so the user can use <code>CFLAGS</code> to
|
|
override the others.
|
|
</p>
|
|
<p><code>CFLAGS</code> should be used in every invocation of the C compiler,
|
|
both those which do compilation and those which do linking.
|
|
</p>
|
|
<p>Every Makefile should define the variable <code>INSTALL</code>, which is the
|
|
basic command for installing a file into the system.
|
|
</p>
|
|
<p>Every Makefile should also define the variables <code>INSTALL_PROGRAM</code>
|
|
and <code>INSTALL_DATA</code>. (The default for <code>INSTALL_PROGRAM</code> should
|
|
be <code>$(INSTALL)</code>; the default for <code>INSTALL_DATA</code> should be
|
|
<code>${INSTALL} -m 644</code>.) Then it should use those variables as the
|
|
commands for actual installation, for executables and non-executables
|
|
respectively. Minimal use of these variables is as follows:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(INSTALL_PROGRAM) foo $(bindir)/foo
|
|
$(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
|
|
</pre></div>
|
|
|
|
<p>However, it is preferable to support a <code>DESTDIR</code> prefix on the
|
|
target files, as explained in the next section.
|
|
</p>
|
|
<p>It is acceptable, but not required, to install multiple files in one
|
|
command, with the final argument being a directory, as in:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(INSTALL_PROGRAM) foo bar baz $(bindir)
|
|
</pre></div>
|
|
|
|
|
|
<hr>
|
|
<span id="DESTDIR"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Directory-Variables" accesskey="n" rel="next">Directory Variables</a>, Previous: <a href="#Command-Variables" accesskey="p" rel="prev">Command Variables</a>, Up: <a href="#Makefile-Conventions" accesskey="u" rel="up">Makefile Conventions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="DESTDIR_003a-Support-for-Staged-Installs"></span><h3 class="section">16.4 <code>DESTDIR</code>: Support for Staged Installs</h3>
|
|
|
|
<span id="index-DESTDIR"></span>
|
|
<span id="index-staged-installs"></span>
|
|
<span id="index-installations_002c-staged"></span>
|
|
|
|
<p><code>DESTDIR</code> is a variable prepended to each installed target file,
|
|
like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
|
|
$(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
|
|
</pre></div>
|
|
|
|
<p>The <code>DESTDIR</code> variable is specified by the user on the <code>make</code>
|
|
command line as an absolute file name. For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">make DESTDIR=/tmp/stage install
|
|
</pre></div>
|
|
|
|
<p><code>DESTDIR</code> should be supported only in the <code>install*</code> and
|
|
<code>uninstall*</code> targets, as those are the only targets where it is
|
|
useful.
|
|
</p>
|
|
<p>If your installation step would normally install
|
|
<samp>/usr/local/bin/foo</samp> and <samp>/usr/local/lib/libfoo.a</samp>, then an
|
|
installation invoked as in the example above would install
|
|
<samp>/tmp/stage/usr/local/bin/foo</samp> and
|
|
<samp>/tmp/stage/usr/local/lib/libfoo.a</samp> instead.
|
|
</p>
|
|
<p>Prepending the variable <code>DESTDIR</code> to each target in this way
|
|
provides for <em>staged installs</em>, where the installed files are not
|
|
placed directly into their expected location but are instead copied
|
|
into a temporary location (<code>DESTDIR</code>). However, installed files
|
|
maintain their relative directory structure and any embedded file names
|
|
will not be modified.
|
|
</p>
|
|
<p>You should not set the value of <code>DESTDIR</code> in your <samp>Makefile</samp>
|
|
at all; then the files are installed into their expected locations by
|
|
default. Also, specifying <code>DESTDIR</code> should not change the
|
|
operation of the software in any way, so its value should not be
|
|
included in any file contents.
|
|
</p>
|
|
<p><code>DESTDIR</code> support is commonly used in package creation. It is
|
|
also helpful to users who want to understand what a given package will
|
|
install where, and to allow users who don’t normally have permissions
|
|
to install into protected areas to build and install before gaining
|
|
those permissions. Finally, it can be useful with tools such as
|
|
<code>stow</code>, where code is installed in one place but made to appear
|
|
to be installed somewhere else using symbolic links or special mount
|
|
operations. So, we strongly recommend GNU packages support
|
|
<code>DESTDIR</code>, though it is not an absolute requirement.
|
|
</p>
|
|
|
|
<hr>
|
|
<span id="Directory-Variables"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Standard-Targets" accesskey="n" rel="next">Standard Targets</a>, Previous: <a href="#DESTDIR" accesskey="p" rel="prev">DESTDIR</a>, Up: <a href="#Makefile-Conventions" accesskey="u" rel="up">Makefile Conventions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Variables-for-Installation-Directories"></span><h3 class="section">16.5 Variables for Installation Directories</h3>
|
|
|
|
<p>Installation directories should always be named by variables, so it is
|
|
easy to install in a nonstandard place. The standard names for these
|
|
variables and the values they should have in GNU packages are
|
|
described below. They are based on a standard file system layout;
|
|
variants of it are used in GNU/Linux and other modern operating
|
|
systems.
|
|
</p>
|
|
<p>Installers are expected to override these values when calling
|
|
<code>make</code> (e.g., <kbd>make prefix=/usr install</kbd>) or
|
|
<code>configure</code> (e.g., <kbd>configure --prefix=/usr</kbd>). GNU
|
|
packages should not try to guess which value should be appropriate for
|
|
these variables on the system they are being installed onto: use the
|
|
default settings specified here so that all GNU packages behave
|
|
identically, allowing the installer to achieve any desired layout.
|
|
</p>
|
|
<span id="index-directories_002c-creating-installation"></span>
|
|
<span id="index-installation-directories_002c-creating"></span>
|
|
<p>All installation directories, and their parent directories, should be
|
|
created (if necessary) before they are installed into.
|
|
</p>
|
|
<p>These first two variables set the root for the installation. All the
|
|
other installation directories should be subdirectories of one of
|
|
these two, and nothing should be directly installed into these two
|
|
directories.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>prefix</code></dt>
|
|
<dd><span id="index-prefix"></span>
|
|
<p>A prefix used in constructing the default values of the variables listed
|
|
below. The default value of <code>prefix</code> should be <samp>/usr/local</samp>.
|
|
When building the complete GNU system, the prefix will be empty and
|
|
<samp>/usr</samp> will be a symbolic link to <samp>/</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@prefix@</samp>’.)
|
|
</p>
|
|
<p>Running ‘<samp>make install</samp>’ with a different value of <code>prefix</code> from
|
|
the one used to build the program should <em>not</em> recompile the
|
|
program.
|
|
</p>
|
|
</dd>
|
|
<dt><code>exec_prefix</code></dt>
|
|
<dd><span id="index-exec_005fprefix"></span>
|
|
<p>A prefix used in constructing the default values of some of the
|
|
variables listed below. The default value of <code>exec_prefix</code> should
|
|
be <code>$(prefix)</code>.
|
|
(If you are using Autoconf, write it as ‘<samp>@exec_prefix@</samp>’.)
|
|
</p>
|
|
<p>Generally, <code>$(exec_prefix)</code> is used for directories that contain
|
|
machine-specific files (such as executables and subroutine libraries),
|
|
while <code>$(prefix)</code> is used directly for other directories.
|
|
</p>
|
|
<p>Running ‘<samp>make install</samp>’ with a different value of <code>exec_prefix</code>
|
|
from the one used to build the program should <em>not</em> recompile the
|
|
program.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Executable programs are installed in one of the following directories.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>bindir</code></dt>
|
|
<dd><span id="index-bindir"></span>
|
|
<p>The directory for installing executable programs that users can run.
|
|
This should normally be <samp>/usr/local/bin</samp>, but write it as
|
|
<samp>$(exec_prefix)/bin</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@bindir@</samp>’.)
|
|
</p>
|
|
</dd>
|
|
<dt><code>sbindir</code></dt>
|
|
<dd><span id="index-sbindir"></span>
|
|
<p>The directory for installing executable programs that can be run from
|
|
the shell, but are only generally useful to system administrators. This
|
|
should normally be <samp>/usr/local/sbin</samp>, but write it as
|
|
<samp>$(exec_prefix)/sbin</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@sbindir@</samp>’.)
|
|
</p>
|
|
</dd>
|
|
<dt><code>libexecdir</code></dt>
|
|
<dd><span id="index-libexecdir"></span>
|
|
<p>The directory for installing executable programs to be run by other
|
|
programs rather than by users. This directory should normally be
|
|
<samp>/usr/local/libexec</samp>, but write it as <samp>$(exec_prefix)/libexec</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@libexecdir@</samp>’.)
|
|
</p>
|
|
<p>The definition of ‘<samp>libexecdir</samp>’ is the same for all packages, so
|
|
you should install your data in a subdirectory thereof. Most packages
|
|
install their data under <samp>$(libexecdir)/<var>package-name</var>/</samp>,
|
|
possibly within additional subdirectories thereof, such as
|
|
<samp>$(libexecdir)/<var>package-name</var>/<var>machine</var>/<var>version</var></samp>.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Data files used by the program during its execution are divided into
|
|
categories in two ways.
|
|
</p>
|
|
<ul>
|
|
<li> Some files are normally modified by programs; others are never normally
|
|
modified (though users may edit some of these).
|
|
|
|
</li><li> Some files are architecture-independent and can be shared by all
|
|
machines at a site; some are architecture-dependent and can be shared
|
|
only by machines of the same kind and operating system; others may never
|
|
be shared between two machines.
|
|
</li></ul>
|
|
|
|
<p>This makes for six different possibilities. However, we want to
|
|
discourage the use of architecture-dependent files, aside from object
|
|
files and libraries. It is much cleaner to make other data files
|
|
architecture-independent, and it is generally not hard.
|
|
</p>
|
|
<p>Here are the variables Makefiles should use to specify directories
|
|
to put these various kinds of files in:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>datarootdir</samp>’</dt>
|
|
<dd><p>The root of the directory tree for read-only architecture-independent
|
|
data files. This should normally be <samp>/usr/local/share</samp>, but
|
|
write it as <samp>$(prefix)/share</samp>. (If you are using Autoconf, write
|
|
it as ‘<samp>@datarootdir@</samp>’.) ‘<samp>datadir</samp>’’s default value is
|
|
based on this variable; so are ‘<samp>infodir</samp>’, ‘<samp>mandir</samp>’, and
|
|
others.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>datadir</samp>’</dt>
|
|
<dd><p>The directory for installing idiosyncratic read-only
|
|
architecture-independent data files for this program. This is usually
|
|
the same place as ‘<samp>datarootdir</samp>’, but we use the two separate
|
|
variables so that you can move these program-specific files without
|
|
altering the location for Info files, man pages, etc.
|
|
</p>
|
|
<p>This should normally be <samp>/usr/local/share</samp>, but write it as
|
|
<samp>$(datarootdir)</samp>. (If you are using Autoconf, write it as
|
|
‘<samp>@datadir@</samp>’.)
|
|
</p>
|
|
<p>The definition of ‘<samp>datadir</samp>’ is the same for all packages, so you
|
|
should install your data in a subdirectory thereof. Most packages
|
|
install their data under <samp>$(datadir)/<var>package-name</var>/</samp>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>sysconfdir</samp>’</dt>
|
|
<dd><p>The directory for installing read-only data files that pertain to a
|
|
single machine–that is to say, files for configuring a host. Mailer
|
|
and network configuration files, <samp>/etc/passwd</samp>, and so forth belong
|
|
here. All the files in this directory should be ordinary ASCII text
|
|
files. This directory should normally be <samp>/usr/local/etc</samp>, but
|
|
write it as <samp>$(prefix)/etc</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@sysconfdir@</samp>’.)
|
|
</p>
|
|
<p>Do not install executables here in this directory (they probably belong
|
|
in <samp>$(libexecdir)</samp> or <samp>$(sbindir)</samp>). Also do not install
|
|
files that are modified in the normal course of their use (programs
|
|
whose purpose is to change the configuration of the system excluded).
|
|
Those probably belong in <samp>$(localstatedir)</samp>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>sharedstatedir</samp>’</dt>
|
|
<dd><p>The directory for installing architecture-independent data files which
|
|
the programs modify while they run. This should normally be
|
|
<samp>/usr/local/com</samp>, but write it as <samp>$(prefix)/com</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@sharedstatedir@</samp>’.)
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>localstatedir</samp>’</dt>
|
|
<dd><p>The directory for installing data files which the programs modify while
|
|
they run, and that pertain to one specific machine. Users should never
|
|
need to modify files in this directory to configure the package’s
|
|
operation; put such configuration information in separate files that go
|
|
in <samp>$(datadir)</samp> or <samp>$(sysconfdir)</samp>. <samp>$(localstatedir)</samp>
|
|
should normally be <samp>/usr/local/var</samp>, but write it as
|
|
<samp>$(prefix)/var</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@localstatedir@</samp>’.)
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>runstatedir</samp>’</dt>
|
|
<dd><p>The directory for installing data files which the programs modify
|
|
while they run, that pertain to one specific machine, and which need
|
|
not persist longer than the execution of the program—which is
|
|
generally long-lived, for example, until the next reboot. PID files
|
|
for system daemons are a typical use. In addition, this directory
|
|
should not be cleaned except perhaps at reboot, while the general
|
|
<samp>/tmp</samp> (<code>TMPDIR</code>) may be cleaned arbitrarily. This should
|
|
normally be <samp>/var/run</samp>, but write it as
|
|
<samp>$(localstatedir)/run</samp>. Having it as a separate variable allows
|
|
the use of <samp>/run</samp> if desired, for example. (If you are using
|
|
Autoconf 2.70 or later, write it as ‘<samp>@runstatedir@</samp>’.)
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>These variables specify the directory for installing certain specific
|
|
types of files, if your program has them. Every GNU package should
|
|
have Info files, so every program needs ‘<samp>infodir</samp>’, but not all
|
|
need ‘<samp>libdir</samp>’ or ‘<samp>lispdir</samp>’.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>includedir</samp>’</dt>
|
|
<dd><p>The directory for installing header files to be included by user
|
|
programs with the C ‘<samp>#include</samp>’ preprocessor directive. This
|
|
should normally be <samp>/usr/local/include</samp>, but write it as
|
|
<samp>$(prefix)/include</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@includedir@</samp>’.)
|
|
</p>
|
|
<p>Most compilers other than GCC do not look for header files in directory
|
|
<samp>/usr/local/include</samp>. So installing the header files this way is
|
|
only useful with GCC. Sometimes this is not a problem because some
|
|
libraries are only really intended to work with GCC. But some libraries
|
|
are intended to work with other compilers. They should install their
|
|
header files in two places, one specified by <code>includedir</code> and one
|
|
specified by <code>oldincludedir</code>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>oldincludedir</samp>’</dt>
|
|
<dd><p>The directory for installing ‘<samp>#include</samp>’ header files for use with
|
|
compilers other than GCC. This should normally be <samp>/usr/include</samp>.
|
|
(If you are using Autoconf, you can write it as ‘<samp>@oldincludedir@</samp>’.)
|
|
</p>
|
|
<p>The Makefile commands should check whether the value of
|
|
<code>oldincludedir</code> is empty. If it is, they should not try to use
|
|
it; they should cancel the second installation of the header files.
|
|
</p>
|
|
<p>A package should not replace an existing header in this directory unless
|
|
the header came from the same package. Thus, if your Foo package
|
|
provides a header file <samp>foo.h</samp>, then it should install the header
|
|
file in the <code>oldincludedir</code> directory if either (1) there is no
|
|
<samp>foo.h</samp> there or (2) the <samp>foo.h</samp> that exists came from the Foo
|
|
package.
|
|
</p>
|
|
<p>To tell whether <samp>foo.h</samp> came from the Foo package, put a magic
|
|
string in the file—part of a comment—and <code>grep</code> for that string.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>docdir</samp>’</dt>
|
|
<dd><p>The directory for installing documentation files (other than Info) for
|
|
this package. By default, it should be
|
|
<samp>/usr/local/share/doc/<var>yourpkg</var></samp>, but it should be written as
|
|
<samp>$(datarootdir)/doc/<var>yourpkg</var></samp>. (If you are using Autoconf,
|
|
write it as ‘<samp>@docdir@</samp>’.) The <var>yourpkg</var> subdirectory, which
|
|
may include a version number, prevents collisions among files with
|
|
common names, such as <samp>README</samp>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>infodir</samp>’</dt>
|
|
<dd><p>The directory for installing the Info files for this package. By
|
|
default, it should be <samp>/usr/local/share/info</samp>, but it should be
|
|
written as <samp>$(datarootdir)/info</samp>. (If you are using Autoconf,
|
|
write it as ‘<samp>@infodir@</samp>’.) <code>infodir</code> is separate from
|
|
<code>docdir</code> for compatibility with existing practice.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>htmldir</samp>’</dt>
|
|
<dt>‘<samp>dvidir</samp>’</dt>
|
|
<dt>‘<samp>pdfdir</samp>’</dt>
|
|
<dt>‘<samp>psdir</samp>’</dt>
|
|
<dd><p>Directories for installing documentation files in the particular
|
|
format. They should all be set to <code>$(docdir)</code> by default. (If
|
|
you are using Autoconf, write them as ‘<samp>@htmldir@</samp>’,
|
|
‘<samp>@dvidir@</samp>’, etc.) Packages which supply several translations
|
|
of their documentation should install them in
|
|
‘<samp>$(htmldir)/</samp>’<var>ll</var>, ‘<samp>$(pdfdir)/</samp>’<var>ll</var>, etc. where
|
|
<var>ll</var> is a locale abbreviation such as ‘<samp>en</samp>’ or ‘<samp>pt_BR</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>libdir</samp>’</dt>
|
|
<dd><p>The directory for object files and libraries of object code. Do not
|
|
install executables here, they probably ought to go in <samp>$(libexecdir)</samp>
|
|
instead. The value of <code>libdir</code> should normally be
|
|
<samp>/usr/local/lib</samp>, but write it as <samp>$(exec_prefix)/lib</samp>.
|
|
(If you are using Autoconf, write it as ‘<samp>@libdir@</samp>’.)
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>lispdir</samp>’</dt>
|
|
<dd><p>The directory for installing any Emacs Lisp files in this package. By
|
|
default, it should be <samp>/usr/local/share/emacs/site-lisp</samp>, but it
|
|
should be written as <samp>$(datarootdir)/emacs/site-lisp</samp>.
|
|
</p>
|
|
<p>If you are using Autoconf, write the default as ‘<samp>@lispdir@</samp>’.
|
|
In order to make ‘<samp>@lispdir@</samp>’ work, you need the following lines
|
|
in your <samp>configure.ac</samp> file:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">lispdir='${datarootdir}/emacs/site-lisp'
|
|
AC_SUBST(lispdir)
|
|
</pre></div>
|
|
|
|
</dd>
|
|
<dt>‘<samp>localedir</samp>’</dt>
|
|
<dd><p>The directory for installing locale-specific message catalogs for this
|
|
package. By default, it should be <samp>/usr/local/share/locale</samp>, but
|
|
it should be written as <samp>$(datarootdir)/locale</samp>. (If you are
|
|
using Autoconf, write it as ‘<samp>@localedir@</samp>’.) This directory
|
|
usually has a subdirectory per locale.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Unix-style man pages are installed in one of the following:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>mandir</samp>’</dt>
|
|
<dd><p>The top-level directory for installing the man pages (if any) for this
|
|
package. It will normally be <samp>/usr/local/share/man</samp>, but you
|
|
should write it as <samp>$(datarootdir)/man</samp>. (If you are using
|
|
Autoconf, write it as ‘<samp>@mandir@</samp>’.)
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>man1dir</samp>’</dt>
|
|
<dd><p>The directory for installing section 1 man pages. Write it as
|
|
<samp>$(mandir)/man1</samp>.
|
|
</p></dd>
|
|
<dt>‘<samp>man2dir</samp>’</dt>
|
|
<dd><p>The directory for installing section 2 man pages. Write it as
|
|
<samp>$(mandir)/man2</samp>
|
|
</p></dd>
|
|
<dt>‘<samp>…</samp>’</dt>
|
|
<dd>
|
|
<p><strong>Don’t make the primary documentation for any GNU software be a
|
|
man page. Write a manual in Texinfo instead. Man pages are just for
|
|
the sake of people running GNU software on Unix, which is a secondary
|
|
application only.</strong>
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>manext</samp>’</dt>
|
|
<dd><p>The file name extension for the installed man page. This should contain
|
|
a period followed by the appropriate digit; it should normally be ‘<samp>.1</samp>’.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>man1ext</samp>’</dt>
|
|
<dd><p>The file name extension for installed section 1 man pages.
|
|
</p></dd>
|
|
<dt>‘<samp>man2ext</samp>’</dt>
|
|
<dd><p>The file name extension for installed section 2 man pages.
|
|
</p></dd>
|
|
<dt>‘<samp>…</samp>’</dt>
|
|
<dd><p>Use these names instead of ‘<samp>manext</samp>’ if the package needs to install man
|
|
pages in more than one section of the manual.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>And finally, you should set the following variable:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>srcdir</samp>’</dt>
|
|
<dd><p>The directory for the sources being compiled. The value of this
|
|
variable is normally inserted by the <code>configure</code> shell script.
|
|
(If you are using Autoconf, use ‘<samp>srcdir = @srcdir@</samp>’.)
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>For example:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"># Common prefix for installation directories.
|
|
# NOTE: This directory must exist when you start the install.
|
|
prefix = /usr/local
|
|
datarootdir = $(prefix)/share
|
|
datadir = $(datarootdir)
|
|
exec_prefix = $(prefix)
|
|
# Where to put the executable for the command 'gcc'.
|
|
bindir = $(exec_prefix)/bin
|
|
# Where to put the directories used by the compiler.
|
|
libexecdir = $(exec_prefix)/libexec
|
|
# Where to put the Info files.
|
|
infodir = $(datarootdir)/info
|
|
</pre></div>
|
|
|
|
<p>If your program installs a large number of files into one of the
|
|
standard user-specified directories, it might be useful to group them
|
|
into a subdirectory particular to that program. If you do this, you
|
|
should write the <code>install</code> rule to create these subdirectories.
|
|
</p>
|
|
<p>Do not expect the user to include the subdirectory name in the value of
|
|
any of the variables listed above. The idea of having a uniform set of
|
|
variable names for installation directories is to enable the user to
|
|
specify the exact same values for several different GNU packages. In
|
|
order for this to be useful, all the packages must be designed so that
|
|
they will work sensibly when the user does so.
|
|
</p>
|
|
<p>At times, not all of these variables may be implemented in the current
|
|
release of Autoconf and/or Automake; but as of Autoconf 2.60, we
|
|
believe all of them are. When any are missing, the descriptions here
|
|
serve as specifications for what Autoconf will implement. As a
|
|
programmer, you can either use a development version of Autoconf or
|
|
avoid using these variables until a stable release is made which
|
|
supports them.
|
|
</p>
|
|
|
|
<hr>
|
|
<span id="Standard-Targets"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Install-Command-Categories" accesskey="n" rel="next">Install Command Categories</a>, Previous: <a href="#Directory-Variables" accesskey="p" rel="prev">Directory Variables</a>, Up: <a href="#Makefile-Conventions" accesskey="u" rel="up">Makefile Conventions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Standard-Targets-for-Users"></span><h3 class="section">16.6 Standard Targets for Users</h3>
|
|
|
|
<p>All GNU programs should have the following targets in their Makefiles:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>all</samp>’</dt>
|
|
<dd><p>Compile the entire program. This should be the default target. This
|
|
target need not rebuild any documentation files; Info files should
|
|
normally be included in the distribution, and DVI (and other
|
|
documentation format) files should be made only when explicitly asked
|
|
for.
|
|
</p>
|
|
<p>By default, the Make rules should compile and link with ‘<samp>-g</samp>’, so
|
|
that executable programs have debugging symbols. Otherwise, you are
|
|
essentially helpless in the face of a crash, and it is often far from
|
|
easy to reproduce with a fresh build.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>install</samp>’</dt>
|
|
<dd><p>Compile the program and copy the executables, libraries, and so on to
|
|
the file names where they should reside for actual use. If there is a
|
|
simple test to verify that a program is properly installed, this target
|
|
should run that test.
|
|
</p>
|
|
<p>Do not strip executables when installing them. This helps eventual
|
|
debugging that may be needed later, and nowadays disk space is cheap
|
|
and dynamic loaders typically ensure debug sections are not loaded during
|
|
normal execution. Users that need stripped binaries may invoke the
|
|
<code>install-strip</code> target to do that.
|
|
</p>
|
|
<p>If possible, write the <code>install</code> target rule so that it does not
|
|
modify anything in the directory where the program was built, provided
|
|
‘<samp>make all</samp>’ has just been done. This is convenient for building the
|
|
program under one user name and installing it under another.
|
|
</p>
|
|
<p>The commands should create all the directories in which files are to be
|
|
installed, if they don’t already exist. This includes the directories
|
|
specified as the values of the variables <code>prefix</code> and
|
|
<code>exec_prefix</code>, as well as all subdirectories that are needed.
|
|
One way to do this is by means of an <code>installdirs</code> target
|
|
as described below.
|
|
</p>
|
|
<p>Use ‘<samp>-</samp>’ before any command for installing a man page, so that
|
|
<code>make</code> will ignore any errors. This is in case there are systems
|
|
that don’t have the Unix man page documentation system installed.
|
|
</p>
|
|
<p>The way to install Info files is to copy them into <samp>$(infodir)</samp>
|
|
with <code>$(INSTALL_DATA)</code> (see <a href="#Command-Variables">Command Variables</a>), and then run
|
|
the <code>install-info</code> program if it is present. <code>install-info</code>
|
|
is a program that edits the Info <samp>dir</samp> file to add or update the
|
|
menu entry for the given Info file; it is part of the Texinfo package.
|
|
</p>
|
|
<p>Here is a sample rule to install an Info file that also tries to
|
|
handle some additional situations, such as <code>install-info</code> not
|
|
being present.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">do-install-info: foo.info installdirs
|
|
$(NORMAL_INSTALL)
|
|
# Prefer an info file in . to one in srcdir.
|
|
if test -f foo.info; then d=.; \
|
|
else d="$(srcdir)"; fi; \
|
|
$(INSTALL_DATA) $$d/foo.info \
|
|
"$(DESTDIR)$(infodir)/foo.info"
|
|
# Run install-info only if it exists.
|
|
# Use 'if' instead of just prepending '-' to the
|
|
# line so we notice real errors from install-info.
|
|
# Use '$(SHELL) -c' because some shells do not
|
|
# fail gracefully when there is an unknown command.
|
|
$(POST_INSTALL)
|
|
if $(SHELL) -c 'install-info --version' \
|
|
>/dev/null 2>&1; then \
|
|
install-info --dir-file="$(DESTDIR)$(infodir)/dir" \
|
|
"$(DESTDIR)$(infodir)/foo.info"; \
|
|
else true; fi
|
|
</pre></div>
|
|
|
|
<p>When writing the <code>install</code> target, you must classify all the
|
|
commands into three categories: normal ones, <em>pre-installation</em>
|
|
commands and <em>post-installation</em> commands. See <a href="#Install-Command-Categories">Install Command Categories</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>install-html</samp>’</dt>
|
|
<dt>‘<samp>install-dvi</samp>’</dt>
|
|
<dt>‘<samp>install-pdf</samp>’</dt>
|
|
<dt>‘<samp>install-ps</samp>’</dt>
|
|
<dd><p>These targets install documentation in formats other than Info;
|
|
they’re intended to be called explicitly by the person installing the
|
|
package, if that format is desired. GNU prefers Info files, so these
|
|
must be installed by the <code>install</code> target.
|
|
</p>
|
|
<p>When you have many documentation files to install, we recommend that
|
|
you avoid collisions and clutter by arranging for these targets to
|
|
install in subdirectories of the appropriate installation directory,
|
|
such as <code>htmldir</code>. As one example, if your package has multiple
|
|
manuals, and you wish to install HTML documentation with many files
|
|
(such as the “split” mode output by <code>makeinfo --html</code>), you’ll
|
|
certainly want to use subdirectories, or two nodes with the same name
|
|
in different manuals will overwrite each other.
|
|
</p>
|
|
<p>Please make these <code>install-<var>format</var></code> targets invoke the
|
|
commands for the <var>format</var> target, for example, by making
|
|
<var>format</var> a dependency.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>uninstall</samp>’</dt>
|
|
<dd><p>Delete all the installed files—the copies that the ‘<samp>install</samp>’
|
|
and ‘<samp>install-*</samp>’ targets create.
|
|
</p>
|
|
<p>This rule should not modify the directories where compilation is done,
|
|
only the directories where files are installed.
|
|
</p>
|
|
<p>The uninstallation commands are divided into three categories, just like
|
|
the installation commands. See <a href="#Install-Command-Categories">Install Command Categories</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>install-strip</samp>’</dt>
|
|
<dd><p>Like <code>install</code>, but strip the executable files while installing
|
|
them. In simple cases, this target can use the <code>install</code> target in
|
|
a simple way:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">install-strip:
|
|
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
|
|
install
|
|
</pre></div>
|
|
|
|
<p>But if the package installs scripts as well as real executables, the
|
|
<code>install-strip</code> target can’t just refer to the <code>install</code>
|
|
target; it has to strip the executables but not the scripts.
|
|
</p>
|
|
<p><code>install-strip</code> should not strip the executables in the build
|
|
directory which are being copied for installation. It should only strip
|
|
the copies that are installed.
|
|
</p>
|
|
<p>Normally we do not recommend stripping an executable unless you are sure
|
|
the program has no bugs. However, it can be reasonable to install a
|
|
stripped executable for actual execution while saving the unstripped
|
|
executable elsewhere in case there is a bug.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>clean</samp>’</dt>
|
|
<dd><p>Delete all files in the current directory that are normally created by
|
|
building the program. Also delete files in other directories if they
|
|
are created by this makefile. However, don’t delete the files that
|
|
record the configuration. Also preserve files that could be made by
|
|
building, but normally aren’t because the distribution comes with
|
|
them. There is no need to delete parent directories that were created
|
|
with ‘<samp>mkdir -p</samp>’, since they could have existed anyway.
|
|
</p>
|
|
<p>Delete <samp>.dvi</samp> files here if they are not part of the distribution.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>distclean</samp>’</dt>
|
|
<dd><p>Delete all files in the current directory (or created by this
|
|
makefile) that are created by configuring or building the program. If
|
|
you have unpacked the source and built the program without creating
|
|
any other files, ‘<samp>make distclean</samp>’ should leave only the files
|
|
that were in the distribution. However, there is no need to delete
|
|
parent directories that were created with ‘<samp>mkdir -p</samp>’, since they
|
|
could have existed anyway.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>mostlyclean</samp>’</dt>
|
|
<dd><p>Like ‘<samp>clean</samp>’, but may refrain from deleting a few files that people
|
|
normally don’t want to recompile. For example, the ‘<samp>mostlyclean</samp>’
|
|
target for GCC does not delete <samp>libgcc.a</samp>, because recompiling it
|
|
is rarely necessary and takes a lot of time.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>maintainer-clean</samp>’</dt>
|
|
<dd><p>Delete almost everything that can be reconstructed with this Makefile.
|
|
This typically includes everything deleted by <code>distclean</code>, plus
|
|
more: C source files produced by Bison, tags tables, Info files, and
|
|
so on.
|
|
</p>
|
|
<p>The reason we say “almost everything” is that running the command
|
|
‘<samp>make maintainer-clean</samp>’ should not delete <samp>configure</samp> even
|
|
if <samp>configure</samp> can be remade using a rule in the Makefile. More
|
|
generally, ‘<samp>make maintainer-clean</samp>’ should not delete anything
|
|
that needs to exist in order to run <samp>configure</samp> and then begin to
|
|
build the program. Also, there is no need to delete parent
|
|
directories that were created with ‘<samp>mkdir -p</samp>’, since they could
|
|
have existed anyway. These are the only exceptions;
|
|
<code>maintainer-clean</code> should delete everything else that can be
|
|
rebuilt.
|
|
</p>
|
|
<p>The ‘<samp>maintainer-clean</samp>’ target is intended to be used by a maintainer of
|
|
the package, not by ordinary users. You may need special tools to
|
|
reconstruct some of the files that ‘<samp>make maintainer-clean</samp>’ deletes.
|
|
Since these files are normally included in the distribution, we don’t
|
|
take care to make them easy to reconstruct. If you find you need to
|
|
unpack the full distribution again, don’t blame us.
|
|
</p>
|
|
<p>To help make users aware of this, the commands for the special
|
|
<code>maintainer-clean</code> target should start with these two:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">@echo 'This command is intended for maintainers to use; it'
|
|
@echo 'deletes files that may need special tools to rebuild.'
|
|
</pre></div>
|
|
|
|
</dd>
|
|
<dt>‘<samp>TAGS</samp>’</dt>
|
|
<dd><p>Update a tags table for this program.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>info</samp>’</dt>
|
|
<dd><p>Generate any Info files needed. The best way to write the rules is as
|
|
follows:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">info: foo.info
|
|
|
|
foo.info: foo.texi chap1.texi chap2.texi
|
|
$(MAKEINFO) $(srcdir)/foo.texi
|
|
</pre></div>
|
|
|
|
<p>You must define the variable <code>MAKEINFO</code> in the Makefile. It should
|
|
run the <code>makeinfo</code> program, which is part of the Texinfo
|
|
distribution.
|
|
</p>
|
|
<p>Normally a GNU distribution comes with Info files, and that means the
|
|
Info files are present in the source directory. Therefore, the Make
|
|
rule for an info file should update it in the source directory. When
|
|
users build the package, ordinarily Make will not update the Info files
|
|
because they will already be up to date.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>dvi</samp>’</dt>
|
|
<dt>‘<samp>html</samp>’</dt>
|
|
<dt>‘<samp>pdf</samp>’</dt>
|
|
<dt>‘<samp>ps</samp>’</dt>
|
|
<dd><p>Generate documentation files in the given format. These targets
|
|
should always exist, but any or all can be a no-op if the given output
|
|
format cannot be generated. These targets should not be dependencies
|
|
of the <code>all</code> target; the user must manually invoke them.
|
|
</p>
|
|
<p>Here’s an example rule for generating DVI files from Texinfo:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">dvi: foo.dvi
|
|
|
|
foo.dvi: foo.texi chap1.texi chap2.texi
|
|
$(TEXI2DVI) $(srcdir)/foo.texi
|
|
</pre></div>
|
|
|
|
<p>You must define the variable <code>TEXI2DVI</code> in the Makefile. It
|
|
should run the program <code>texi2dvi</code>, which is part of the Texinfo
|
|
distribution. (<code>texi2dvi</code> uses TeX to do the real work of
|
|
formatting. TeX is not distributed with Texinfo.) Alternatively,
|
|
write only the dependencies, and allow GNU <code>make</code> to provide the
|
|
command.
|
|
</p>
|
|
<p>Here’s another example, this one for generating HTML from Texinfo:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">html: foo.html
|
|
|
|
foo.html: foo.texi chap1.texi chap2.texi
|
|
$(TEXI2HTML) $(srcdir)/foo.texi
|
|
</pre></div>
|
|
|
|
<p>Again, you would define the variable <code>TEXI2HTML</code> in the Makefile;
|
|
for example, it might run <code>makeinfo --no-split --html</code>
|
|
(<code>makeinfo</code> is part of the Texinfo distribution).
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>dist</samp>’</dt>
|
|
<dd><p>Create a distribution tar file for this program. The tar file should be
|
|
set up so that the file names in the tar file start with a subdirectory
|
|
name which is the name of the package it is a distribution for. This
|
|
name can include the version number.
|
|
</p>
|
|
<p>For example, the distribution tar file of GCC version 1.40 unpacks into
|
|
a subdirectory named <samp>gcc-1.40</samp>.
|
|
</p>
|
|
<p>The easiest way to do this is to create a subdirectory appropriately
|
|
named, use <code>ln</code> or <code>cp</code> to install the proper files in it, and
|
|
then <code>tar</code> that subdirectory.
|
|
</p>
|
|
<p>Compress the tar file with <code>gzip</code>. For example, the actual
|
|
distribution file for GCC version 1.40 is called <samp>gcc-1.40.tar.gz</samp>.
|
|
It is ok to support other free compression formats as well.
|
|
</p>
|
|
<p>The <code>dist</code> target should explicitly depend on all non-source files
|
|
that are in the distribution, to make sure they are up to date in the
|
|
distribution.
|
|
See <a href="https://www.gnu.org/prep/standards/standards.html#Releases">Making Releases</a> in <cite>GNU Coding Standards</cite>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>check</samp>’</dt>
|
|
<dd><p>Perform self-tests (if any). The user must build the program before
|
|
running the tests, but need not install the program; you should write
|
|
the self-tests so that they work when the program is built but not
|
|
installed.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>The following targets are suggested as conventional names, for programs
|
|
in which they are useful.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>installcheck</code></dt>
|
|
<dd><p>Perform installation tests (if any). The user must build and install
|
|
the program before running the tests. You should not assume that
|
|
<samp>$(bindir)</samp> is in the search path.
|
|
</p>
|
|
</dd>
|
|
<dt><code>installdirs</code></dt>
|
|
<dd><p>It’s useful to add a target named ‘<samp>installdirs</samp>’ to create the
|
|
directories where files are installed, and their parent directories.
|
|
There is a script called <samp>mkinstalldirs</samp> which is convenient for
|
|
this; you can find it in the Gnulib package.
|
|
You can use a rule like this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"># Make sure all installation directories (e.g. $(bindir))
|
|
# actually exist by making them if necessary.
|
|
installdirs: mkinstalldirs
|
|
$(srcdir)/mkinstalldirs $(bindir) $(datadir) \
|
|
$(libdir) $(infodir) \
|
|
$(mandir)
|
|
</pre></div>
|
|
|
|
<p>or, if you wish to support <code>DESTDIR</code> (strongly encouraged),
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"># Make sure all installation directories (e.g. $(bindir))
|
|
# actually exist by making them if necessary.
|
|
installdirs: mkinstalldirs
|
|
$(srcdir)/mkinstalldirs \
|
|
$(DESTDIR)$(bindir) $(DESTDIR)$(datadir) \
|
|
$(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \
|
|
$(DESTDIR)$(mandir)
|
|
</pre></div>
|
|
|
|
<p>This rule should not modify the directories where compilation is done.
|
|
It should do nothing but create installation directories.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Install-Command-Categories"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Standard-Targets" accesskey="p" rel="prev">Standard Targets</a>, Up: <a href="#Makefile-Conventions" accesskey="u" rel="up">Makefile Conventions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Install-Command-Categories-1"></span><h3 class="section">16.7 Install Command Categories</h3>
|
|
|
|
<span id="index-pre_002dinstallation-commands"></span>
|
|
<span id="index-post_002dinstallation-commands"></span>
|
|
<p>When writing the <code>install</code> target, you must classify all the
|
|
commands into three categories: normal ones, <em>pre-installation</em>
|
|
commands and <em>post-installation</em> commands.
|
|
</p>
|
|
<p>Normal commands move files into their proper places, and set their
|
|
modes. They may not alter any files except the ones that come entirely
|
|
from the package they belong to.
|
|
</p>
|
|
<p>Pre-installation and post-installation commands may alter other files;
|
|
in particular, they can edit global configuration files or data bases.
|
|
</p>
|
|
<p>Pre-installation commands are typically executed before the normal
|
|
commands, and post-installation commands are typically run after the
|
|
normal commands.
|
|
</p>
|
|
<p>The most common use for a post-installation command is to run
|
|
<code>install-info</code>. This cannot be done with a normal command, since
|
|
it alters a file (the Info directory) which does not come entirely and
|
|
solely from the package being installed. It is a post-installation
|
|
command because it needs to be done after the normal command which
|
|
installs the package’s Info files.
|
|
</p>
|
|
<p>Most programs don’t need any pre-installation commands, but we have the
|
|
feature just in case it is needed.
|
|
</p>
|
|
<p>To classify the commands in the <code>install</code> rule into these three
|
|
categories, insert <em>category lines</em> among them. A category line
|
|
specifies the category for the commands that follow.
|
|
</p>
|
|
<p>A category line consists of a tab and a reference to a special Make
|
|
variable, plus an optional comment at the end. There are three
|
|
variables you can use, one for each category; the variable name
|
|
specifies the category. Category lines are no-ops in ordinary execution
|
|
because these three Make variables are normally undefined (and you
|
|
<em>should not</em> define them in the makefile).
|
|
</p>
|
|
<p>Here are the three possible category lines, each with a comment that
|
|
explains what it means:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"> $(PRE_INSTALL) # <span class="roman">Pre-install commands follow.</span>
|
|
$(POST_INSTALL) # <span class="roman">Post-install commands follow.</span>
|
|
$(NORMAL_INSTALL) # <span class="roman">Normal commands follow.</span>
|
|
</pre></div>
|
|
|
|
<p>If you don’t use a category line at the beginning of the <code>install</code>
|
|
rule, all the commands are classified as normal until the first category
|
|
line. If you don’t use any category lines, all the commands are
|
|
classified as normal.
|
|
</p>
|
|
<p>These are the category lines for <code>uninstall</code>:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"> $(PRE_UNINSTALL) # <span class="roman">Pre-uninstall commands follow.</span>
|
|
$(POST_UNINSTALL) # <span class="roman">Post-uninstall commands follow.</span>
|
|
$(NORMAL_UNINSTALL) # <span class="roman">Normal commands follow.</span>
|
|
</pre></div>
|
|
|
|
<p>Typically, a pre-uninstall command would be used for deleting entries
|
|
from the Info directory.
|
|
</p>
|
|
<p>If the <code>install</code> or <code>uninstall</code> target has any dependencies
|
|
which act as subroutines of installation, then you should start
|
|
<em>each</em> dependency’s commands with a category line, and start the
|
|
main target’s commands with a category line also. This way, you can
|
|
ensure that each command is placed in the right category regardless of
|
|
which of the dependencies actually run.
|
|
</p>
|
|
<p>Pre-installation and post-installation commands should not run any
|
|
programs except for these:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">[ basename bash cat chgrp chmod chown cmp cp dd diff echo
|
|
egrep expand expr false fgrep find getopt grep gunzip gzip
|
|
hostname install install-info kill ldconfig ln ls md5sum
|
|
mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee
|
|
test touch true uname xargs yes
|
|
</pre></div>
|
|
|
|
<span id="index-binary-packages"></span>
|
|
<p>The reason for distinguishing the commands in this way is for the sake
|
|
of making binary packages. Typically a binary package contains all the
|
|
executables and other files that need to be installed, and has its own
|
|
method of installing them—so it does not need to run the normal
|
|
installation commands. But installing the binary package does need to
|
|
execute the pre-installation and post-installation commands.
|
|
</p>
|
|
<p>Programs to build binary packages work by extracting the
|
|
pre-installation and post-installation commands. Here is one way of
|
|
extracting the pre-installation commands (the <samp>-s</samp> option to
|
|
<code>make</code> is needed to silence messages about entering
|
|
subdirectories):
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">make -s -n install -o all \
|
|
PRE_INSTALL=pre-install \
|
|
POST_INSTALL=post-install \
|
|
NORMAL_INSTALL=normal-install \
|
|
| gawk -f pre-install.awk
|
|
</pre></div>
|
|
|
|
<p>where the file <samp>pre-install.awk</samp> could contain this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">$0 ~ /^(normal-install|post-install)[ \t]*$/ {on = 0}
|
|
on {print $0}
|
|
$0 ~ /^pre-install[ \t]*$/ {on = 1}
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="Quick-Reference"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Error-Messages" accesskey="n" rel="next">Error Messages</a>, Previous: <a href="#Makefile-Conventions" accesskey="p" rel="prev">Makefile Conventions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Quick-Reference-1"></span><h2 class="appendix">Appendix A Quick Reference</h2>
|
|
|
|
<p>This appendix summarizes the directives, text manipulation functions,
|
|
and special variables which GNU <code>make</code> understands.
|
|
See <a href="#Special-Targets">Special Targets</a>, <a href="#Catalogue-of-Rules">Catalogue of Built-In Rules</a>,
|
|
and <a href="#Options-Summary">Summary of Options</a>,
|
|
for other summaries.
|
|
</p>
|
|
<p>Here is a summary of the directives GNU <code>make</code> recognizes:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>define <var>variable</var></code></dt>
|
|
<dt><code>define <var>variable</var> =</code></dt>
|
|
<dt><code>define <var>variable</var> :=</code></dt>
|
|
<dt><code>define <var>variable</var> ::=</code></dt>
|
|
<dt><code>define <var>variable</var> :::=</code></dt>
|
|
<dt><code>define <var>variable</var> +=</code></dt>
|
|
<dt><code>define <var>variable</var> ?=</code></dt>
|
|
<dt><code>endef</code></dt>
|
|
<dd><p>Define multi-line variables.<br>
|
|
See <a href="#Multi_002dLine">Multi-Line</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>undefine <var>variable</var></code></dt>
|
|
<dd><p>Undefining variables.<br>
|
|
See <a href="#Undefine-Directive">Undefine Directive</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>ifdef <var>variable</var></code></dt>
|
|
<dt><code>ifndef <var>variable</var></code></dt>
|
|
<dt><code>ifeq (<var>a</var>,<var>b</var>)</code></dt>
|
|
<dt><code>ifeq "<var>a</var>" "<var>b</var>"</code></dt>
|
|
<dt><code>ifeq '<var>a</var>' '<var>b</var>'</code></dt>
|
|
<dt><code>ifneq (<var>a</var>,<var>b</var>)</code></dt>
|
|
<dt><code>ifneq "<var>a</var>" "<var>b</var>"</code></dt>
|
|
<dt><code>ifneq '<var>a</var>' '<var>b</var>'</code></dt>
|
|
<dt><code>else</code></dt>
|
|
<dt><code>endif</code></dt>
|
|
<dd><p>Conditionally evaluate part of the makefile.<br>
|
|
See <a href="#Conditionals">Conditionals</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>include <var>file</var></code></dt>
|
|
<dt><code>-include <var>file</var></code></dt>
|
|
<dt><code>sinclude <var>file</var></code></dt>
|
|
<dd><p>Include another makefile.<br>
|
|
See <a href="#Include">Including Other Makefiles</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>override <var>variable-assignment</var></code></dt>
|
|
<dd><p>Define a variable, overriding any previous definition, even one from
|
|
the command line.<br>
|
|
See <a href="#Override-Directive">The <code>override</code> Directive</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>export</code></dt>
|
|
<dd><p>Tell <code>make</code> to export all variables to child processes by default.<br>
|
|
See <a href="#Variables_002fRecursion">Communicating Variables to a Sub-<code>make</code></a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>export <var>variable</var></code></dt>
|
|
<dt><code>export <var>variable-assignment</var></code></dt>
|
|
<dt><code>unexport <var>variable</var></code></dt>
|
|
<dd><p>Tell <code>make</code> whether or not to export a particular variable to child
|
|
processes.<br>
|
|
See <a href="#Variables_002fRecursion">Communicating Variables to a Sub-<code>make</code></a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>private <var>variable-assignment</var></code></dt>
|
|
<dd><p>Do not allow this variable assignment to be inherited by prerequisites.<br>
|
|
See <a href="#Suppressing-Inheritance">Suppressing Inheritance</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>vpath <var>pattern</var> <var>path</var></code></dt>
|
|
<dd><p>Specify a search path for files matching a ‘<samp>%</samp>’ pattern.<br>
|
|
See <a href="#Selective-Search">The <code>vpath</code> Directive</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>vpath <var>pattern</var></code></dt>
|
|
<dd><p>Remove all search paths previously specified for <var>pattern</var>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>vpath</code></dt>
|
|
<dd><p>Remove all search paths previously specified in any <code>vpath</code>
|
|
directive.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Here is a summary of the built-in functions (see <a href="#Functions">Functions</a>):
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>$(subst <var>from</var>,<var>to</var>,<var>text</var>)</code></dt>
|
|
<dd><p>Replace <var>from</var> with <var>to</var> in <var>text</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(patsubst <var>pattern</var>,<var>replacement</var>,<var>text</var>)</code></dt>
|
|
<dd><p>Replace words matching <var>pattern</var> with <var>replacement</var> in <var>text</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(strip <var>string</var>)</code></dt>
|
|
<dd><p>Remove excess whitespace characters from <var>string</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(findstring <var>find</var>,<var>text</var>)</code></dt>
|
|
<dd><p>Locate <var>find</var> in <var>text</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(filter <var>pattern</var>…,<var>text</var>)</code></dt>
|
|
<dd><p>Select words in <var>text</var> that match one of the <var>pattern</var> words.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(filter-out <var>pattern</var>…,<var>text</var>)</code></dt>
|
|
<dd><p>Select words in <var>text</var> that <em>do not</em> match any of the <var>pattern</var> words.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(sort <var>list</var>)</code></dt>
|
|
<dd><p>Sort the words in <var>list</var> lexicographically, removing duplicates.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(word <var>n</var>,<var>text</var>)</code></dt>
|
|
<dd><p>Extract the <var>n</var>th word (one-origin) of <var>text</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(words <var>text</var>)</code></dt>
|
|
<dd><p>Count the number of words in <var>text</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(wordlist <var>s</var>,<var>e</var>,<var>text</var>)</code></dt>
|
|
<dd><p>Returns the list of words in <var>text</var> from <var>s</var> to <var>e</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(firstword <var>names</var>…)</code></dt>
|
|
<dd><p>Extract the first word of <var>names</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(lastword <var>names</var>…)</code></dt>
|
|
<dd><p>Extract the last word of <var>names</var>.<br>
|
|
See <a href="#Text-Functions">Functions for String Substitution and Analysis</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(dir <var>names</var>…)</code></dt>
|
|
<dd><p>Extract the directory part of each file name.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(notdir <var>names</var>…)</code></dt>
|
|
<dd><p>Extract the non-directory part of each file name.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(suffix <var>names</var>…)</code></dt>
|
|
<dd><p>Extract the suffix (the last ‘<samp>.</samp>’ and following characters) of each file name.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(basename <var>names</var>…)</code></dt>
|
|
<dd><p>Extract the base name (name without suffix) of each file name.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(addsuffix <var>suffix</var>,<var>names</var>…)</code></dt>
|
|
<dd><p>Append <var>suffix</var> to each word in <var>names</var>.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(addprefix <var>prefix</var>,<var>names</var>…)</code></dt>
|
|
<dd><p>Prepend <var>prefix</var> to each word in <var>names</var>.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(join <var>list1</var>,<var>list2</var>)</code></dt>
|
|
<dd><p>Join two parallel lists of words.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(wildcard <var>pattern</var>…)</code></dt>
|
|
<dd><p>Find file names matching a shell file name pattern (<em>not</em> a
|
|
‘<samp>%</samp>’ pattern).<br>
|
|
See <a href="#Wildcard-Function">The Function <code>wildcard</code></a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(realpath <var>names</var>…)</code></dt>
|
|
<dd><p>For each file name in <var>names</var>, expand to an absolute name that
|
|
does not contain any <code>.</code>, <code>..</code>, nor symlinks.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(abspath <var>names</var>…)</code></dt>
|
|
<dd><p>For each file name in <var>names</var>, expand to an absolute name that
|
|
does not contain any <code>.</code> or <code>..</code> components, but preserves
|
|
symlinks.<br>
|
|
See <a href="#File-Name-Functions">Functions for File Names</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(error <var>text</var>…)</code></dt>
|
|
<dd><p>When this function is evaluated, <code>make</code> generates a fatal error
|
|
with the message <var>text</var>.<br>
|
|
See <a href="#Make-Control-Functions">Functions That Control Make</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(warning <var>text</var>…)</code></dt>
|
|
<dd><p>When this function is evaluated, <code>make</code> generates a warning with
|
|
the message <var>text</var>.<br>
|
|
See <a href="#Make-Control-Functions">Functions That Control Make</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(shell <var>command</var>)</code></dt>
|
|
<dd><p>Execute a shell command and return its output.<br>
|
|
See <a href="#Shell-Function">The <code>shell</code> Function</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(origin <var>variable</var>)</code></dt>
|
|
<dd><p>Return a string describing how the <code>make</code> variable <var>variable</var> was
|
|
defined.<br>
|
|
See <a href="#Origin-Function">The <code>origin</code> Function</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(flavor <var>variable</var>)</code></dt>
|
|
<dd><p>Return a string describing the flavor of the <code>make</code> variable
|
|
<var>variable</var>.<br>
|
|
See <a href="#Flavor-Function">The <code>flavor</code> Function</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(let <var>var</var> [<var>var</var> ...],<var>words</var>,<var>text</var>)</code></dt>
|
|
<dd><p>Evaluate <var>text</var> with the <var>var</var>s bound to the words in
|
|
<var>words</var>.<br>
|
|
See <a href="#Let-Function">The <code>let</code> Function</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(foreach <var>var</var>,<var>words</var>,<var>text</var>)</code></dt>
|
|
<dd><p>Evaluate <var>text</var> with <var>var</var> bound to each word in <var>words</var>,
|
|
and concatenate the results.<br>
|
|
See <a href="#Foreach-Function">The <code>foreach</code> Function</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(if <var>condition</var>,<var>then-part</var>[,<var>else-part</var>])</code></dt>
|
|
<dd><p>Evaluate the condition <var>condition</var>; if it’s non-empty substitute
|
|
the expansion of the <var>then-part</var> otherwise substitute the
|
|
expansion of the <var>else-part</var>.<br>
|
|
See <a href="#Conditional-Functions">Functions for Conditionals</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(or <var>condition1</var>[,<var>condition2</var>[,<var>condition3</var>…]])</code></dt>
|
|
<dd><p>Evaluate each condition <var>conditionN</var> one at a time; substitute the
|
|
first non-empty expansion. If all expansions are empty, substitute
|
|
the empty string.<br>
|
|
See <a href="#Conditional-Functions">Functions for Conditionals</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(and <var>condition1</var>[,<var>condition2</var>[,<var>condition3</var>…]])</code></dt>
|
|
<dd><p>Evaluate each condition <var>conditionN</var> one at a time; if any
|
|
expansion results in the empty string substitute the empty string. If
|
|
all expansions result in a non-empty string, substitute the expansion
|
|
of the last <var>condition</var>.<br>
|
|
See <a href="#Conditional-Functions">Functions for Conditionals</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(intcmp <var>lhs</var>,<var>rhs</var>[,<var>lt-part</var>[,<var>eq-part</var>[,<var>gt-part</var>]]])</code></dt>
|
|
<dd><p>Compare <var>lhs</var> and <var>rhs</var> numerically; substitute the expansion of
|
|
<var>lt-part</var>, <var>eq-part</var>, or <var>gt-part</var> depending on whether the
|
|
left-hand side is less-than, equal-to, or greater-than the right-hand
|
|
side, respectively.<br>
|
|
See <a href="#Conditional-Functions">Functions for Conditionals</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(call <var>var</var>,<var>param</var>,…)</code></dt>
|
|
<dd><p>Evaluate the variable <var>var</var> replacing any references to <code>$(1)</code>,
|
|
<code>$(2)</code> with the first, second, etc. <var>param</var> values.<br>
|
|
See <a href="#Call-Function">The <code>call</code> Function</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(eval <var>text</var>)</code></dt>
|
|
<dd><p>Evaluate <var>text</var> then read the results as makefile commands.
|
|
Expands to the empty string.<br>
|
|
See <a href="#Eval-Function">The <code>eval</code> Function</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(file <var>op</var> <var>filename</var>,<var>text</var>)</code></dt>
|
|
<dd><p>Expand the arguments, then open the file <var>filename</var> using mode
|
|
<var>op</var> and write <var>text</var> to that file.<br>
|
|
See <a href="#File-Function">The <code>file</code> Function</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(value <var>var</var>)</code></dt>
|
|
<dd><p>Evaluates to the contents of the variable <var>var</var>, with no expansion
|
|
performed on it.<br>
|
|
See <a href="#Value-Function">The <code>value</code> Function</a>.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>Here is a summary of the automatic variables.
|
|
See <a href="#Automatic-Variables">Automatic Variables</a>,
|
|
for full information.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>$@</code></dt>
|
|
<dd><p>The file name of the target.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$%</code></dt>
|
|
<dd><p>The target member name, when the target is an archive member.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$<</code></dt>
|
|
<dd><p>The name of the first prerequisite.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$?</code></dt>
|
|
<dd><p>The names of all the prerequisites that are
|
|
newer than the target, with spaces between them.
|
|
For prerequisites which are archive members, only
|
|
the named member is used (see <a href="#Archives">Archives</a>).
|
|
</p>
|
|
</dd>
|
|
<dt><code>$^</code></dt>
|
|
<dt><code>$+</code></dt>
|
|
<dd><p>The names of all the prerequisites, with spaces between them. For
|
|
prerequisites which are archive members, only the named member is used
|
|
(see <a href="#Archives">Archives</a>). The value of <code>$^</code> omits duplicate
|
|
prerequisites, while <code>$+</code> retains them and preserves their order.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$*</code></dt>
|
|
<dd><p>The stem with which an implicit rule matches
|
|
(see <a href="#Pattern-Match">How Patterns Match</a>).
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(@D)</code></dt>
|
|
<dt><code>$(@F)</code></dt>
|
|
<dd><p>The directory part and the file-within-directory part of <code>$@</code>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(*D)</code></dt>
|
|
<dt><code>$(*F)</code></dt>
|
|
<dd><p>The directory part and the file-within-directory part of <code>$*</code>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(%D)</code></dt>
|
|
<dt><code>$(%F)</code></dt>
|
|
<dd><p>The directory part and the file-within-directory part of <code>$%</code>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(<D)</code></dt>
|
|
<dt><code>$(<F)</code></dt>
|
|
<dd><p>The directory part and the file-within-directory part of <code>$<</code>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(^D)</code></dt>
|
|
<dt><code>$(^F)</code></dt>
|
|
<dd><p>The directory part and the file-within-directory part of <code>$^</code>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(+D)</code></dt>
|
|
<dt><code>$(+F)</code></dt>
|
|
<dd><p>The directory part and the file-within-directory part of <code>$+</code>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>$(?D)</code></dt>
|
|
<dt><code>$(?F)</code></dt>
|
|
<dd><p>The directory part and the file-within-directory part of <code>$?</code>.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<p>These variables are used specially by GNU <code>make</code>:
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>MAKEFILES</code></dt>
|
|
<dd>
|
|
<p>Makefiles to be read on every invocation of <code>make</code>.<br>
|
|
See <a href="#MAKEFILES-Variable">The Variable <code>MAKEFILES</code></a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>VPATH</code></dt>
|
|
<dd>
|
|
<p>Directory search path for files not found in the current directory.<br>
|
|
See <a href="#General-Search"><code>VPATH</code> Search Path for All Prerequisites</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>SHELL</code></dt>
|
|
<dd>
|
|
<p>The name of the system default command interpreter, usually <samp>/bin/sh</samp>.
|
|
You can set <code>SHELL</code> in the makefile to change the shell used to run
|
|
recipes. See <a href="#Execution">Recipe Execution</a>. The <code>SHELL</code>
|
|
variable is handled specially when importing from and exporting to the
|
|
environment. See <a href="#Choosing-the-Shell">Choosing the Shell</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>MAKESHELL</code></dt>
|
|
<dd>
|
|
<p>On MS-DOS only, the name of the command interpreter that is to be used
|
|
by <code>make</code>. This value takes precedence over the value of
|
|
<code>SHELL</code>. See <a href="#Execution">MAKESHELL variable</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>MAKE</code></dt>
|
|
<dd>
|
|
<p>The name with which <code>make</code> was invoked. Using this variable in
|
|
recipes has special meaning. See <a href="#MAKE-Variable">How the
|
|
<code>MAKE</code> Variable Works</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>MAKE_VERSION</code></dt>
|
|
<dd>
|
|
<p>The built-in variable ‘<samp>MAKE_VERSION</samp>’ expands to the version
|
|
number of the GNU <code>make</code> program.
|
|
<span id="index-MAKE_005fVERSION"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>MAKE_HOST</code></dt>
|
|
<dd>
|
|
<p>The built-in variable ‘<samp>MAKE_HOST</samp>’ expands to a string
|
|
representing the host that GNU <code>make</code> was built to run on.
|
|
<span id="index-MAKE_005fHOST"></span>
|
|
</p>
|
|
</dd>
|
|
<dt><code>MAKELEVEL</code></dt>
|
|
<dd>
|
|
<p>The number of levels of recursion (sub-<code>make</code>s).<br>
|
|
See <a href="#Variables_002fRecursion">Variables/Recursion</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>MAKEFLAGS</code></dt>
|
|
<dd>
|
|
<p>The flags given to <code>make</code>. You can set this in the environment or
|
|
a makefile to set flags.<br>
|
|
See <a href="#Options_002fRecursion">Communicating Options to a Sub-<code>make</code></a>.
|
|
</p>
|
|
<p>It is <em>never</em> appropriate to use <code>MAKEFLAGS</code> directly in a
|
|
recipe line: its contents may not be quoted correctly for use in the
|
|
shell. Always allow recursive <code>make</code>’s to obtain these values
|
|
through the environment from its parent.
|
|
</p>
|
|
</dd>
|
|
<dt><code>GNUMAKEFLAGS</code></dt>
|
|
<dd>
|
|
<p>Other flags parsed by <code>make</code>. You can set this in the environment or
|
|
a makefile to set <code>make</code> command-line flags. GNU <code>make</code>
|
|
never sets this variable itself. This variable is only needed if
|
|
you’d like to set GNU <code>make</code>-specific flags in a POSIX-compliant
|
|
makefile. This variable will be seen by GNU <code>make</code> and ignored
|
|
by other <code>make</code> implementations. It’s not needed if you only use
|
|
GNU <code>make</code>; just use <code>MAKEFLAGS</code> directly.
|
|
See <a href="#Options_002fRecursion">Communicating Options to a Sub-<code>make</code></a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>MAKECMDGOALS</code></dt>
|
|
<dd>
|
|
<p>The targets given to <code>make</code> on the command line. Setting this
|
|
variable has no effect on the operation of <code>make</code>.<br>
|
|
See <a href="#Goals">Arguments to Specify the Goals</a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>CURDIR</code></dt>
|
|
<dd>
|
|
<p>Set to the absolute pathname of the current working directory (after
|
|
all <code>-C</code> options are processed, if any). Setting this variable
|
|
has no effect on the operation of <code>make</code>.<br>
|
|
See <a href="#Recursion">Recursive Use of <code>make</code></a>.
|
|
</p>
|
|
</dd>
|
|
<dt><code>SUFFIXES</code></dt>
|
|
<dd>
|
|
<p>The default list of suffixes before <code>make</code> reads any makefiles.
|
|
</p>
|
|
</dd>
|
|
<dt><code>.LIBPATTERNS</code></dt>
|
|
<dd><p>Defines the naming of the libraries <code>make</code> searches for, and their
|
|
order.<br>
|
|
See <a href="#Libraries_002fSearch">Directory Search for Link Libraries</a>.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Error-Messages"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Complex-Makefile" accesskey="n" rel="next">Complex Makefile</a>, Previous: <a href="#Quick-Reference" accesskey="p" rel="prev">Quick Reference</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Errors-Generated-by-Make"></span><h2 class="appendix">Appendix B Errors Generated by Make</h2>
|
|
|
|
<p>Here is a list of the more common errors you might see generated by
|
|
<code>make</code>, and some information about what they mean and how to fix
|
|
them.
|
|
</p>
|
|
<p>Sometimes <code>make</code> errors are not fatal, especially in the presence
|
|
of a <code>-</code> prefix on a recipe line, or the <code>-k</code> command line
|
|
option. Errors that are fatal are prefixed with the string
|
|
<code>***</code>.
|
|
</p>
|
|
<p>Error messages are all either prefixed with the name of the program
|
|
(usually ‘<samp>make</samp>’), or, if the error is found in a makefile, the name
|
|
of the file and line number containing the problem.
|
|
</p>
|
|
<p>In the table below, these common prefixes are left off.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt>‘<samp>[<var>foo</var>] Error <var>NN</var></samp>’</dt>
|
|
<dt>‘<samp>[<var>foo</var>] <var>signal description</var></samp>’</dt>
|
|
<dd><p>These errors are not really <code>make</code> errors at all. They mean that a
|
|
program that <code>make</code> invoked as part of a recipe returned a
|
|
non-0 error code (‘<samp>Error <var>NN</var></samp>’), which <code>make</code> interprets
|
|
as failure, or it exited in some other abnormal fashion (with a
|
|
signal of some type). See <a href="#Errors">Errors in Recipes</a>.
|
|
</p>
|
|
<p>If no <code>***</code> is attached to the message, then the sub-process failed
|
|
but the rule in the makefile was prefixed with the <code>-</code> special
|
|
character, so <code>make</code> ignored the error.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>missing separator. Stop.</samp>’</dt>
|
|
<dt>‘<samp>missing separator (did you mean TAB instead of 8 spaces?). Stop.</samp>’</dt>
|
|
<dd><p>This means that <code>make</code> could not understand much of anything
|
|
about the makefile line it just read. GNU <code>make</code> looks for
|
|
various separators (<code>:</code>, <code>=</code>, recipe prefix characters,
|
|
etc.) to indicate what kind of line it’s parsing. This message means
|
|
it couldn’t find a valid one.
|
|
</p>
|
|
<p>One of the most common reasons for this message is that you (or
|
|
perhaps your oh-so-helpful editor, as is the case with many MS-Windows
|
|
editors) have attempted to indent your recipe lines with spaces
|
|
instead of a tab character. In this case, <code>make</code> will use the
|
|
second form of the error above. Remember that every line in the
|
|
recipe must begin with a tab character (unless you set
|
|
<code>.RECIPEPREFIX</code>; see <a href="#Special-Variables">Special Variables</a>). Eight spaces do not
|
|
count. See <a href="#Rule-Syntax">Rule Syntax</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>recipe commences before first target. Stop.</samp>’</dt>
|
|
<dt>‘<samp>missing rule before recipe. Stop.</samp>’</dt>
|
|
<dd><p>This means the first thing in the makefile seems to be part of a
|
|
recipe: it begins with a recipe prefix character and doesn’t appear to
|
|
be a legal <code>make</code> directive (such as a variable assignment).
|
|
Recipes must always be associated with a target.
|
|
</p>
|
|
<p>The second form is generated if the line has a semicolon as the first
|
|
non-whitespace character; <code>make</code> interprets this to mean you left
|
|
out the "target: prerequisite" section of a rule. See <a href="#Rule-Syntax">Rule Syntax</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>No rule to make target `<var>xxx</var>'.</samp>’</dt>
|
|
<dt>‘<samp>No rule to make target `<var>xxx</var>', needed by `<var>yyy</var>'.</samp>’</dt>
|
|
<dd><p>This means that <code>make</code> decided it needed to build a target, but
|
|
then couldn’t find any instructions in the makefile on how to do that,
|
|
either explicit or implicit (including in the default rules database).
|
|
</p>
|
|
<p>If you want that file to be built, you will need to add a rule to your
|
|
makefile describing how that target can be built. Other possible
|
|
sources of this problem are typos in the makefile (if that file name is
|
|
wrong) or a corrupted source tree (if that file is not supposed to be
|
|
built, but rather only a prerequisite).
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>No targets specified and no makefile found. Stop.</samp>’</dt>
|
|
<dt>‘<samp>No targets. Stop.</samp>’</dt>
|
|
<dd><p>The former means that you didn’t provide any targets to be built on the
|
|
command line, and <code>make</code> couldn’t find any makefiles to read in.
|
|
The latter means that some makefile was found, but it didn’t contain any
|
|
default goal and none was given on the command line. GNU <code>make</code>
|
|
has nothing to do in these situations.
|
|
See <a href="#Makefile-Arguments">Arguments to Specify the Makefile</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>Makefile `<var>xxx</var>' was not found.</samp>’</dt>
|
|
<dt>‘<samp>Included makefile `<var>xxx</var>' was not found.</samp>’</dt>
|
|
<dd><p>A makefile specified on the command line (first form) or included
|
|
(second form) was not found.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>warning: overriding recipe for target `<var>xxx</var>'</samp>’</dt>
|
|
<dt>‘<samp>warning: ignoring old recipe for target `<var>xxx</var>'</samp>’</dt>
|
|
<dd><p>GNU <code>make</code> allows only one recipe to be specified per target
|
|
(except for double-colon rules). If you give a recipe for a target
|
|
which already has been defined to have one, this warning is issued and
|
|
the second recipe will overwrite the first. See <a href="#Multiple-Rules">Multiple Rules for One Target</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>Circular <var>xxx</var> <- <var>yyy</var> dependency dropped.</samp>’</dt>
|
|
<dd><p>This means that <code>make</code> detected a loop in the dependency graph:
|
|
after tracing the prerequisite <var>yyy</var> of target <var>xxx</var>, and its
|
|
prerequisites, etc., one of them depended on <var>xxx</var> again.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>Recursive variable `<var>xxx</var>' references itself (eventually). Stop.</samp>’</dt>
|
|
<dd><p>This means you’ve defined a normal (recursive) <code>make</code> variable
|
|
<var>xxx</var> that, when it’s expanded, will refer to itself (<var>xxx</var>).
|
|
This is not allowed; either use simply-expanded variables (‘<samp>:=</samp>’
|
|
or ‘<samp>::=</samp>’) or use the append operator (‘<samp>+=</samp>’). See <a href="#Using-Variables">How to Use Variables</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>Unterminated variable reference. Stop.</samp>’</dt>
|
|
<dd><p>This means you forgot to provide the proper closing parenthesis
|
|
or brace in your variable or function reference.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>insufficient arguments to function `<var>xxx</var>'. Stop.</samp>’</dt>
|
|
<dd><p>This means you haven’t provided the requisite number of arguments for
|
|
this function. See the documentation of the function for a description
|
|
of its arguments. See <a href="#Functions">Functions for Transforming Text</a>.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>missing target pattern. Stop.</samp>’</dt>
|
|
<dt>‘<samp>multiple target patterns. Stop.</samp>’</dt>
|
|
<dt>‘<samp>target pattern contains no `%'. Stop.</samp>’</dt>
|
|
<dt>‘<samp>mixed implicit and static pattern rules. Stop.</samp>’</dt>
|
|
<dd><p>These errors are generated for malformed static pattern rules
|
|
(see <a href="#Static-Usage">Syntax of Static Pattern Rules</a>). The first
|
|
means the target-pattern part of the rule is empty; the second means
|
|
there are multiple pattern characters (<code>%</code>) in the target-pattern
|
|
part; the third means there are no pattern characters in the
|
|
target-pattern part; and the fourth means that all three parts of the
|
|
static pattern rule contain pattern characters (<code>%</code>)–the first
|
|
part should not contain pattern characters.
|
|
</p>
|
|
<p>If you see these errors and you aren’t trying to create a static
|
|
pattern rule, check the value of any variables in your target and
|
|
prerequisite lists to be sure they do not contain colons.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>warning: -jN forced in submake: disabling jobserver mode.</samp>’</dt>
|
|
<dd><p>This warning and the next are generated if <code>make</code> detects error
|
|
conditions related to parallel processing on systems where
|
|
sub-<code>make</code>s can communicate (see <a href="#Options_002fRecursion">Communicating Options to a Sub-<code>make</code></a>). This warning is
|
|
generated if a recursive invocation of a <code>make</code> process is forced
|
|
to have ‘<samp>-j<var>N</var></samp>’ in its argument list (where <var>N</var> is greater
|
|
than one). This could happen, for example, if you set the <code>MAKE</code>
|
|
environment variable to ‘<samp>make -j2</samp>’. In this case, the
|
|
sub-<code>make</code> doesn’t communicate with other <code>make</code> processes and
|
|
will simply pretend it has two jobs of its own.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>warning: jobserver unavailable: using -j1. Add `+' to parent make rule.</samp>’</dt>
|
|
<dd><p>In order for <code>make</code> processes to communicate, the parent will pass
|
|
information to the child. Since this could result in problems if the
|
|
child process isn’t actually a <code>make</code>, the parent will only do this
|
|
if it thinks the child is a <code>make</code>. The parent uses the normal
|
|
algorithms to determine this (see <a href="#MAKE-Variable">How the <code>MAKE</code>
|
|
Variable Works</a>). If the makefile is constructed such that the parent
|
|
doesn’t know the child is a <code>make</code> process, then the child will
|
|
receive only part of the information necessary. In this case, the child
|
|
will generate this warning message and proceed with its build in a
|
|
sequential manner.
|
|
</p>
|
|
</dd>
|
|
<dt>‘<samp>warning: ignoring prerequisites on suffix rule definition</samp>’</dt>
|
|
<dd><p>According to POSIX, a suffix rule cannot contain prerequisites. If a rule
|
|
that could be a suffix rule has prerequisites it is interpreted as a simple
|
|
explicit rule, with an odd target name. This requirement is obeyed when
|
|
POSIX-conforming mode is enabled (the <code>.POSIX</code> target is defined). In
|
|
versions of GNU <code>make</code> prior to 4.3, no warning was emitted and a
|
|
suffix rule was created, however all prerequisites were ignored and were not
|
|
part of the suffix rule. Starting with GNU <code>make</code> 4.3 the behavior is
|
|
the same, and in addition this warning is generated. In a future version
|
|
the POSIX-conforming behavior will be the only behavior: no rule with a
|
|
prerequisite can be suffix rule and this warning will be removed.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<span id="Complex-Makefile"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#GNU-Free-Documentation-License" accesskey="n" rel="next">GNU Free Documentation License</a>, Previous: <a href="#Error-Messages" accesskey="p" rel="prev">Error Messages</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Complex-Makefile-Example"></span><h2 class="appendix">Appendix C Complex Makefile Example</h2>
|
|
|
|
<p>Here is the makefile for the GNU <code>tar</code> program. This is a
|
|
moderately complex makefile. The first line uses a <code>#!</code> setting
|
|
to allow the makefile to be executed directly.
|
|
</p>
|
|
<p>Because it is the first target, the default goal is ‘<samp>all</samp>’. An
|
|
interesting feature of this makefile is that <samp>testpad.h</samp> is a
|
|
source file automatically created by the <code>testpad</code> program,
|
|
itself compiled from <samp>testpad.c</samp>.
|
|
</p>
|
|
<p>If you type ‘<samp>make</samp>’ or ‘<samp>make all</samp>’, then <code>make</code> creates
|
|
the <samp>tar</samp> executable, the <samp>rmt</samp> daemon that provides
|
|
remote tape access, and the <samp>tar.info</samp> Info file.
|
|
</p>
|
|
<p>If you type ‘<samp>make install</samp>’, then <code>make</code> not only creates
|
|
<samp>tar</samp>, <samp>rmt</samp>, and <samp>tar.info</samp>, but also installs
|
|
them.
|
|
</p>
|
|
<p>If you type ‘<samp>make clean</samp>’, then <code>make</code> removes the ‘<samp>.o</samp>’
|
|
files, and the <samp>tar</samp>, <samp>rmt</samp>, <samp>testpad</samp>,
|
|
<samp>testpad.h</samp>, and <samp>core</samp> files.
|
|
</p>
|
|
<p>If you type ‘<samp>make distclean</samp>’, then <code>make</code> not only removes
|
|
the same files as does ‘<samp>make clean</samp>’ but also the
|
|
<samp>TAGS</samp>, <samp>Makefile</samp>, and <samp>config.status</samp> files.
|
|
(Although it is not evident, this makefile (and
|
|
<samp>config.status</samp>) is generated by the user with the
|
|
<code>configure</code> program, which is provided in the <code>tar</code>
|
|
distribution, but is not shown here.)
|
|
</p>
|
|
<p>If you type ‘<samp>make realclean</samp>’, then <code>make</code> removes the same
|
|
files as does ‘<samp>make distclean</samp>’ and also removes the Info files
|
|
generated from <samp>tar.texinfo</samp>.
|
|
</p>
|
|
<p>In addition, there are targets <code>shar</code> and <code>dist</code> that create
|
|
distribution kits.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">#!/usr/bin/make -f
|
|
# Generated automatically from Makefile.in by configure.
|
|
# Un*x Makefile for GNU tar program.
|
|
# Copyright (C) 1991 Free Software Foundation, Inc.
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example"># This program is free software; you can redistribute
|
|
# it and/or modify it under the terms of the GNU
|
|
# General Public License …
|
|
…
|
|
…
|
|
</pre><pre class="example">
|
|
|
|
SHELL = /bin/sh
|
|
|
|
#### Start of system configuration section. ####
|
|
|
|
srcdir = .
|
|
|
|
</pre><pre class="example"># If you use gcc, you should either run the
|
|
# fixincludes script that comes with it or else use
|
|
# gcc with the -traditional option. Otherwise ioctl
|
|
# calls will be compiled incorrectly on some systems.
|
|
CC = gcc -O
|
|
YACC = bison -y
|
|
INSTALL = /usr/local/bin/install -c
|
|
INSTALLDATA = /usr/local/bin/install -c -m 644
|
|
</pre><pre class="example">
|
|
|
|
# Things you might add to DEFS:
|
|
# -DSTDC_HEADERS If you have ANSI C headers and
|
|
# libraries.
|
|
# -DPOSIX If you have POSIX.1 headers and
|
|
# libraries.
|
|
# -DBSD42 If you have sys/dir.h (unless
|
|
# you use -DPOSIX), sys/file.h,
|
|
# and st_blocks in `struct stat'.
|
|
# -DUSG If you have System V/ANSI C
|
|
# string and memory functions
|
|
# and headers, sys/sysmacros.h,
|
|
# fcntl.h, getcwd, no valloc,
|
|
# and ndir.h (unless
|
|
# you use -DDIRENT).
|
|
# -DNO_MEMORY_H If USG or STDC_HEADERS but do not
|
|
# include memory.h.
|
|
# -DDIRENT If USG and you have dirent.h
|
|
# instead of ndir.h.
|
|
# -DSIGTYPE=int If your signal handlers
|
|
# return int, not void.
|
|
# -DNO_MTIO If you lack sys/mtio.h
|
|
# (magtape ioctls).
|
|
# -DNO_REMOTE If you do not have a remote shell
|
|
# or rexec.
|
|
# -DUSE_REXEC To use rexec for remote tape
|
|
# operations instead of
|
|
# forking rsh or remsh.
|
|
# -DVPRINTF_MISSING If you lack vprintf function
|
|
# (but have _doprnt).
|
|
# -DDOPRNT_MISSING If you lack _doprnt function.
|
|
# Also need to define
|
|
# -DVPRINTF_MISSING.
|
|
# -DFTIME_MISSING If you lack ftime system call.
|
|
# -DSTRSTR_MISSING If you lack strstr function.
|
|
# -DVALLOC_MISSING If you lack valloc function.
|
|
# -DMKDIR_MISSING If you lack mkdir and
|
|
# rmdir system calls.
|
|
# -DRENAME_MISSING If you lack rename system call.
|
|
# -DFTRUNCATE_MISSING If you lack ftruncate
|
|
# system call.
|
|
# -DV7 On Version 7 Unix (not
|
|
# tested in a long time).
|
|
# -DEMUL_OPEN3 If you lack a 3-argument version
|
|
# of open, and want to emulate it
|
|
# with system calls you do have.
|
|
# -DNO_OPEN3 If you lack the 3-argument open
|
|
# and want to disable the tar -k
|
|
# option instead of emulating open.
|
|
# -DXENIX If you have sys/inode.h
|
|
# and need it 94 to be included.
|
|
|
|
DEFS = -DSIGTYPE=int -DDIRENT -DSTRSTR_MISSING \
|
|
-DVPRINTF_MISSING -DBSD42
|
|
# Set this to rtapelib.o unless you defined NO_REMOTE,
|
|
# in which case make it empty.
|
|
RTAPELIB = rtapelib.o
|
|
LIBS =
|
|
DEF_AR_FILE = /dev/rmt8
|
|
DEFBLOCKING = 20
|
|
|
|
</pre><pre class="example">CDEBUG = -g
|
|
CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \
|
|
-DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \
|
|
-DDEFBLOCKING=$(DEFBLOCKING)
|
|
LDFLAGS = -g
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">prefix = /usr/local
|
|
# Prefix for each installed program,
|
|
# normally empty or `g'.
|
|
binprefix =
|
|
|
|
# The directory to install tar in.
|
|
bindir = $(prefix)/bin
|
|
|
|
# The directory to install the info files in.
|
|
infodir = $(prefix)/info
|
|
</pre><pre class="example">
|
|
|
|
#### End of system configuration section. ####
|
|
|
|
</pre><pre class="example">SRCS_C = tar.c create.c extract.c buffer.c \
|
|
getoldopt.c update.c gnu.c mangle.c \
|
|
version.c list.c names.c diffarch.c \
|
|
port.c wildmat.c getopt.c getopt1.c \
|
|
regex.c
|
|
SRCS_Y = getdate.y
|
|
SRCS = $(SRCS_C) $(SRCS_Y)
|
|
OBJS = $(SRCS_C:.c=.o) $(SRCS_Y:.y=.o) $(RTAPELIB)
|
|
</pre><pre class="example">AUX = README COPYING ChangeLog Makefile.in \
|
|
makefile.pc configure configure.in \
|
|
tar.texinfo tar.info* texinfo.tex \
|
|
tar.h port.h open3.h getopt.h regex.h \
|
|
rmt.h rmt.c rtapelib.c alloca.c \
|
|
msd_dir.h msd_dir.c tcexparg.c \
|
|
level-0 level-1 backup-specs testpad.c
|
|
</pre><pre class="example">
|
|
|
|
.PHONY: all
|
|
all: tar rmt tar.info
|
|
|
|
</pre><pre class="example">tar: $(OBJS)
|
|
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">rmt: rmt.c
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ rmt.c
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">tar.info: tar.texinfo
|
|
makeinfo tar.texinfo
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">.PHONY: install
|
|
install: all
|
|
$(INSTALL) tar $(bindir)/$(binprefix)tar
|
|
-test ! -f rmt || $(INSTALL) rmt /etc/rmt
|
|
$(INSTALLDATA) $(srcdir)/tar.info* $(infodir)
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">$(OBJS): tar.h port.h testpad.h
|
|
regex.o buffer.o tar.o: regex.h
|
|
# getdate.y has 8 shift/reduce conflicts.
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">testpad.h: testpad
|
|
./testpad
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">testpad: testpad.o
|
|
$(CC) -o $@ testpad.o
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">TAGS: $(SRCS)
|
|
etags $(SRCS)
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">.PHONY: clean
|
|
clean:
|
|
rm -f *.o tar rmt testpad testpad.h core
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">.PHONY: distclean
|
|
distclean: clean
|
|
rm -f TAGS Makefile config.status
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">.PHONY: realclean
|
|
realclean: distclean
|
|
rm -f tar.info*
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">.PHONY: shar
|
|
shar: $(SRCS) $(AUX)
|
|
shar $(SRCS) $(AUX) | compress \
|
|
> tar-`sed -e '/version_string/!d' \
|
|
-e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
|
|
-e q
|
|
version.c`.shar.Z
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">.PHONY: dist
|
|
dist: $(SRCS) $(AUX)
|
|
echo tar-`sed \
|
|
-e '/version_string/!d' \
|
|
-e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
|
|
-e q
|
|
version.c` > .fname
|
|
-rm -rf `cat .fname`
|
|
mkdir `cat .fname`
|
|
ln $(SRCS) $(AUX) `cat .fname`
|
|
tar chZf `cat .fname`.tar.Z `cat .fname`
|
|
-rm -rf `cat .fname` .fname
|
|
</pre><pre class="example">
|
|
|
|
</pre><pre class="example">tar.zoo: $(SRCS) $(AUX)
|
|
-rm -rf tmp.dir
|
|
-mkdir tmp.dir
|
|
-rm tar.zoo
|
|
for X in $(SRCS) $(AUX) ; do \
|
|
echo $$X ; \
|
|
sed 's/$$/^M/' $$X \
|
|
> tmp.dir/$$X ; done
|
|
cd tmp.dir ; zoo aM ../tar.zoo *
|
|
-rm -rf tmp.dir
|
|
</pre></div>
|
|
|
|
<hr>
|
|
<span id="GNU-Free-Documentation-License"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Concept-Index" accesskey="n" rel="next">Concept Index</a>, Previous: <a href="#Complex-Makefile" accesskey="p" rel="prev">Complex Makefile</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="GNU-Free-Documentation-License-1"></span><h2 class="appendix">Appendix D GNU Free Documentation License</h2>
|
|
<span id="index-FDL_002c-GNU-Free-Documentation-License"></span>
|
|
<div align="center">Version 1.3, 3 November 2008
|
|
</div>
|
|
|
|
<div class="display">
|
|
<pre class="display">Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
|
|
<a href="https://fsf.org/">https://fsf.org/</a>
|
|
|
|
Everyone is permitted to copy and distribute verbatim copies
|
|
of this license document, but changing it is not allowed.
|
|
</pre></div>
|
|
|
|
<ol start="0">
|
|
<li> PREAMBLE
|
|
|
|
<p>The purpose of this License is to make a manual, textbook, or other
|
|
functional and useful document <em>free</em> in the sense of freedom: to
|
|
assure everyone the effective freedom to copy and redistribute it,
|
|
with or without modifying it, either commercially or noncommercially.
|
|
Secondarily, this License preserves for the author and publisher a way
|
|
to get credit for their work, while not being considered responsible
|
|
for modifications made by others.
|
|
</p>
|
|
<p>This License is a kind of “copyleft”, which means that derivative
|
|
works of the document must themselves be free in the same sense. It
|
|
complements the GNU General Public License, which is a copyleft
|
|
license designed for free software.
|
|
</p>
|
|
<p>We have designed this License in order to use it for manuals for free
|
|
software, because free software needs free documentation: a free
|
|
program should come with manuals providing the same freedoms that the
|
|
software does. But this License is not limited to software manuals;
|
|
it can be used for any textual work, regardless of subject matter or
|
|
whether it is published as a printed book. We recommend this License
|
|
principally for works whose purpose is instruction or reference.
|
|
</p>
|
|
</li><li> APPLICABILITY AND DEFINITIONS
|
|
|
|
<p>This License applies to any manual or other work, in any medium, that
|
|
contains a notice placed by the copyright holder saying it can be
|
|
distributed under the terms of this License. Such a notice grants a
|
|
world-wide, royalty-free license, unlimited in duration, to use that
|
|
work under the conditions stated herein. The “Document”, below,
|
|
refers to any such manual or work. Any member of the public is a
|
|
licensee, and is addressed as “you”. You accept the license if you
|
|
copy, modify or distribute the work in a way requiring permission
|
|
under copyright law.
|
|
</p>
|
|
<p>A “Modified Version” of the Document means any work containing the
|
|
Document or a portion of it, either copied verbatim, or with
|
|
modifications and/or translated into another language.
|
|
</p>
|
|
<p>A “Secondary Section” is a named appendix or a front-matter section
|
|
of the Document that deals exclusively with the relationship of the
|
|
publishers or authors of the Document to the Document’s overall
|
|
subject (or to related matters) and contains nothing that could fall
|
|
directly within that overall subject. (Thus, if the Document is in
|
|
part a textbook of mathematics, a Secondary Section may not explain
|
|
any mathematics.) The relationship could be a matter of historical
|
|
connection with the subject or with related matters, or of legal,
|
|
commercial, philosophical, ethical or political position regarding
|
|
them.
|
|
</p>
|
|
<p>The “Invariant Sections” are certain Secondary Sections whose titles
|
|
are designated, as being those of Invariant Sections, in the notice
|
|
that says that the Document is released under this License. If a
|
|
section does not fit the above definition of Secondary then it is not
|
|
allowed to be designated as Invariant. The Document may contain zero
|
|
Invariant Sections. If the Document does not identify any Invariant
|
|
Sections then there are none.
|
|
</p>
|
|
<p>The “Cover Texts” are certain short passages of text that are listed,
|
|
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
|
the Document is released under this License. A Front-Cover Text may
|
|
be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
|
</p>
|
|
<p>A “Transparent” copy of the Document means a machine-readable copy,
|
|
represented in a format whose specification is available to the
|
|
general public, that is suitable for revising the document
|
|
straightforwardly with generic text editors or (for images composed of
|
|
pixels) generic paint programs or (for drawings) some widely available
|
|
drawing editor, and that is suitable for input to text formatters or
|
|
for automatic translation to a variety of formats suitable for input
|
|
to text formatters. A copy made in an otherwise Transparent file
|
|
format whose markup, or absence of markup, has been arranged to thwart
|
|
or discourage subsequent modification by readers is not Transparent.
|
|
An image format is not Transparent if used for any substantial amount
|
|
of text. A copy that is not “Transparent” is called “Opaque”.
|
|
</p>
|
|
<p>Examples of suitable formats for Transparent copies include plain
|
|
ASCII without markup, Texinfo input format, LaTeX input
|
|
format, SGML or XML using a publicly available
|
|
DTD, and standard-conforming simple HTML,
|
|
PostScript or PDF designed for human modification. Examples
|
|
of transparent image formats include PNG, XCF and
|
|
JPG. Opaque formats include proprietary formats that can be
|
|
read and edited only by proprietary word processors, SGML or
|
|
XML for which the DTD and/or processing tools are
|
|
not generally available, and the machine-generated HTML,
|
|
PostScript or PDF produced by some word processors for
|
|
output purposes only.
|
|
</p>
|
|
<p>The “Title Page” means, for a printed book, the title page itself,
|
|
plus such following pages as are needed to hold, legibly, the material
|
|
this License requires to appear in the title page. For works in
|
|
formats which do not have any title page as such, “Title Page” means
|
|
the text near the most prominent appearance of the work’s title,
|
|
preceding the beginning of the body of the text.
|
|
</p>
|
|
<p>The “publisher” means any person or entity that distributes copies
|
|
of the Document to the public.
|
|
</p>
|
|
<p>A section “Entitled XYZ” means a named subunit of the Document whose
|
|
title either is precisely XYZ or contains XYZ in parentheses following
|
|
text that translates XYZ in another language. (Here XYZ stands for a
|
|
specific section name mentioned below, such as “Acknowledgements”,
|
|
“Dedications”, “Endorsements”, or “History”.) To “Preserve the Title”
|
|
of such a section when you modify the Document means that it remains a
|
|
section “Entitled XYZ” according to this definition.
|
|
</p>
|
|
<p>The Document may include Warranty Disclaimers next to the notice which
|
|
states that this License applies to the Document. These Warranty
|
|
Disclaimers are considered to be included by reference in this
|
|
License, but only as regards disclaiming warranties: any other
|
|
implication that these Warranty Disclaimers may have is void and has
|
|
no effect on the meaning of this License.
|
|
</p>
|
|
</li><li> VERBATIM COPYING
|
|
|
|
<p>You may copy and distribute the Document in any medium, either
|
|
commercially or noncommercially, provided that this License, the
|
|
copyright notices, and the license notice saying this License applies
|
|
to the Document are reproduced in all copies, and that you add no other
|
|
conditions whatsoever to those of this License. You may not use
|
|
technical measures to obstruct or control the reading or further
|
|
copying of the copies you make or distribute. However, you may accept
|
|
compensation in exchange for copies. If you distribute a large enough
|
|
number of copies you must also follow the conditions in section 3.
|
|
</p>
|
|
<p>You may also lend copies, under the same conditions stated above, and
|
|
you may publicly display copies.
|
|
</p>
|
|
</li><li> COPYING IN QUANTITY
|
|
|
|
<p>If you publish printed copies (or copies in media that commonly have
|
|
printed covers) of the Document, numbering more than 100, and the
|
|
Document’s license notice requires Cover Texts, you must enclose the
|
|
copies in covers that carry, clearly and legibly, all these Cover
|
|
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
|
the back cover. Both covers must also clearly and legibly identify
|
|
you as the publisher of these copies. The front cover must present
|
|
the full title with all words of the title equally prominent and
|
|
visible. You may add other material on the covers in addition.
|
|
Copying with changes limited to the covers, as long as they preserve
|
|
the title of the Document and satisfy these conditions, can be treated
|
|
as verbatim copying in other respects.
|
|
</p>
|
|
<p>If the required texts for either cover are too voluminous to fit
|
|
legibly, you should put the first ones listed (as many as fit
|
|
reasonably) on the actual cover, and continue the rest onto adjacent
|
|
pages.
|
|
</p>
|
|
<p>If you publish or distribute Opaque copies of the Document numbering
|
|
more than 100, you must either include a machine-readable Transparent
|
|
copy along with each Opaque copy, or state in or with each Opaque copy
|
|
a computer-network location from which the general network-using
|
|
public has access to download using public-standard network protocols
|
|
a complete Transparent copy of the Document, free of added material.
|
|
If you use the latter option, you must take reasonably prudent steps,
|
|
when you begin distribution of Opaque copies in quantity, to ensure
|
|
that this Transparent copy will remain thus accessible at the stated
|
|
location until at least one year after the last time you distribute an
|
|
Opaque copy (directly or through your agents or retailers) of that
|
|
edition to the public.
|
|
</p>
|
|
<p>It is requested, but not required, that you contact the authors of the
|
|
Document well before redistributing any large number of copies, to give
|
|
them a chance to provide you with an updated version of the Document.
|
|
</p>
|
|
</li><li> MODIFICATIONS
|
|
|
|
<p>You may copy and distribute a Modified Version of the Document under
|
|
the conditions of sections 2 and 3 above, provided that you release
|
|
the Modified Version under precisely this License, with the Modified
|
|
Version filling the role of the Document, thus licensing distribution
|
|
and modification of the Modified Version to whoever possesses a copy
|
|
of it. In addition, you must do these things in the Modified Version:
|
|
</p>
|
|
<ol type="A" start="1">
|
|
<li> Use in the Title Page (and on the covers, if any) a title distinct
|
|
from that of the Document, and from those of previous versions
|
|
(which should, if there were any, be listed in the History section
|
|
of the Document). You may use the same title as a previous version
|
|
if the original publisher of that version gives permission.
|
|
|
|
</li><li> List on the Title Page, as authors, one or more persons or entities
|
|
responsible for authorship of the modifications in the Modified
|
|
Version, together with at least five of the principal authors of the
|
|
Document (all of its principal authors, if it has fewer than five),
|
|
unless they release you from this requirement.
|
|
|
|
</li><li> State on the Title page the name of the publisher of the
|
|
Modified Version, as the publisher.
|
|
|
|
</li><li> Preserve all the copyright notices of the Document.
|
|
|
|
</li><li> Add an appropriate copyright notice for your modifications
|
|
adjacent to the other copyright notices.
|
|
|
|
</li><li> Include, immediately after the copyright notices, a license notice
|
|
giving the public permission to use the Modified Version under the
|
|
terms of this License, in the form shown in the Addendum below.
|
|
|
|
</li><li> Preserve in that license notice the full lists of Invariant Sections
|
|
and required Cover Texts given in the Document’s license notice.
|
|
|
|
</li><li> Include an unaltered copy of this License.
|
|
|
|
</li><li> Preserve the section Entitled “History”, Preserve its Title, and add
|
|
to it an item stating at least the title, year, new authors, and
|
|
publisher of the Modified Version as given on the Title Page. If
|
|
there is no section Entitled “History” in the Document, create one
|
|
stating the title, year, authors, and publisher of the Document as
|
|
given on its Title Page, then add an item describing the Modified
|
|
Version as stated in the previous sentence.
|
|
|
|
</li><li> Preserve the network location, if any, given in the Document for
|
|
public access to a Transparent copy of the Document, and likewise
|
|
the network locations given in the Document for previous versions
|
|
it was based on. These may be placed in the “History” section.
|
|
You may omit a network location for a work that was published at
|
|
least four years before the Document itself, or if the original
|
|
publisher of the version it refers to gives permission.
|
|
|
|
</li><li> For any section Entitled “Acknowledgements” or “Dedications”, Preserve
|
|
the Title of the section, and preserve in the section all the
|
|
substance and tone of each of the contributor acknowledgements and/or
|
|
dedications given therein.
|
|
|
|
</li><li> Preserve all the Invariant Sections of the Document,
|
|
unaltered in their text and in their titles. Section numbers
|
|
or the equivalent are not considered part of the section titles.
|
|
|
|
</li><li> Delete any section Entitled “Endorsements”. Such a section
|
|
may not be included in the Modified Version.
|
|
|
|
</li><li> Do not retitle any existing section to be Entitled “Endorsements” or
|
|
to conflict in title with any Invariant Section.
|
|
|
|
</li><li> Preserve any Warranty Disclaimers.
|
|
</li></ol>
|
|
|
|
<p>If the Modified Version includes new front-matter sections or
|
|
appendices that qualify as Secondary Sections and contain no material
|
|
copied from the Document, you may at your option designate some or all
|
|
of these sections as invariant. To do this, add their titles to the
|
|
list of Invariant Sections in the Modified Version’s license notice.
|
|
These titles must be distinct from any other section titles.
|
|
</p>
|
|
<p>You may add a section Entitled “Endorsements”, provided it contains
|
|
nothing but endorsements of your Modified Version by various
|
|
parties—for example, statements of peer review or that the text has
|
|
been approved by an organization as the authoritative definition of a
|
|
standard.
|
|
</p>
|
|
<p>You may add a passage of up to five words as a Front-Cover Text, and a
|
|
passage of up to 25 words as a Back-Cover Text, to the end of the list
|
|
of Cover Texts in the Modified Version. Only one passage of
|
|
Front-Cover Text and one of Back-Cover Text may be added by (or
|
|
through arrangements made by) any one entity. If the Document already
|
|
includes a cover text for the same cover, previously added by you or
|
|
by arrangement made by the same entity you are acting on behalf of,
|
|
you may not add another; but you may replace the old one, on explicit
|
|
permission from the previous publisher that added the old one.
|
|
</p>
|
|
<p>The author(s) and publisher(s) of the Document do not by this License
|
|
give permission to use their names for publicity for or to assert or
|
|
imply endorsement of any Modified Version.
|
|
</p>
|
|
</li><li> COMBINING DOCUMENTS
|
|
|
|
<p>You may combine the Document with other documents released under this
|
|
License, under the terms defined in section 4 above for modified
|
|
versions, provided that you include in the combination all of the
|
|
Invariant Sections of all of the original documents, unmodified, and
|
|
list them all as Invariant Sections of your combined work in its
|
|
license notice, and that you preserve all their Warranty Disclaimers.
|
|
</p>
|
|
<p>The combined work need only contain one copy of this License, and
|
|
multiple identical Invariant Sections may be replaced with a single
|
|
copy. If there are multiple Invariant Sections with the same name but
|
|
different contents, make the title of each such section unique by
|
|
adding at the end of it, in parentheses, the name of the original
|
|
author or publisher of that section if known, or else a unique number.
|
|
Make the same adjustment to the section titles in the list of
|
|
Invariant Sections in the license notice of the combined work.
|
|
</p>
|
|
<p>In the combination, you must combine any sections Entitled “History”
|
|
in the various original documents, forming one section Entitled
|
|
“History”; likewise combine any sections Entitled “Acknowledgements”,
|
|
and any sections Entitled “Dedications”. You must delete all
|
|
sections Entitled “Endorsements.”
|
|
</p>
|
|
</li><li> COLLECTIONS OF DOCUMENTS
|
|
|
|
<p>You may make a collection consisting of the Document and other documents
|
|
released under this License, and replace the individual copies of this
|
|
License in the various documents with a single copy that is included in
|
|
the collection, provided that you follow the rules of this License for
|
|
verbatim copying of each of the documents in all other respects.
|
|
</p>
|
|
<p>You may extract a single document from such a collection, and distribute
|
|
it individually under this License, provided you insert a copy of this
|
|
License into the extracted document, and follow this License in all
|
|
other respects regarding verbatim copying of that document.
|
|
</p>
|
|
</li><li> AGGREGATION WITH INDEPENDENT WORKS
|
|
|
|
<p>A compilation of the Document or its derivatives with other separate
|
|
and independent documents or works, in or on a volume of a storage or
|
|
distribution medium, is called an “aggregate” if the copyright
|
|
resulting from the compilation is not used to limit the legal rights
|
|
of the compilation’s users beyond what the individual works permit.
|
|
When the Document is included in an aggregate, this License does not
|
|
apply to the other works in the aggregate which are not themselves
|
|
derivative works of the Document.
|
|
</p>
|
|
<p>If the Cover Text requirement of section 3 is applicable to these
|
|
copies of the Document, then if the Document is less than one half of
|
|
the entire aggregate, the Document’s Cover Texts may be placed on
|
|
covers that bracket the Document within the aggregate, or the
|
|
electronic equivalent of covers if the Document is in electronic form.
|
|
Otherwise they must appear on printed covers that bracket the whole
|
|
aggregate.
|
|
</p>
|
|
</li><li> TRANSLATION
|
|
|
|
<p>Translation is considered a kind of modification, so you may
|
|
distribute translations of the Document under the terms of section 4.
|
|
Replacing Invariant Sections with translations requires special
|
|
permission from their copyright holders, but you may include
|
|
translations of some or all Invariant Sections in addition to the
|
|
original versions of these Invariant Sections. You may include a
|
|
translation of this License, and all the license notices in the
|
|
Document, and any Warranty Disclaimers, provided that you also include
|
|
the original English version of this License and the original versions
|
|
of those notices and disclaimers. In case of a disagreement between
|
|
the translation and the original version of this License or a notice
|
|
or disclaimer, the original version will prevail.
|
|
</p>
|
|
<p>If a section in the Document is Entitled “Acknowledgements”,
|
|
“Dedications”, or “History”, the requirement (section 4) to Preserve
|
|
its Title (section 1) will typically require changing the actual
|
|
title.
|
|
</p>
|
|
</li><li> TERMINATION
|
|
|
|
<p>You may not copy, modify, sublicense, or distribute the Document
|
|
except as expressly provided under this License. Any attempt
|
|
otherwise to copy, modify, sublicense, or distribute it is void, and
|
|
will automatically terminate your rights under this License.
|
|
</p>
|
|
<p>However, if you cease all violation of this License, then your license
|
|
from a particular copyright holder is reinstated (a) provisionally,
|
|
unless and until the copyright holder explicitly and finally
|
|
terminates your license, and (b) permanently, if the copyright holder
|
|
fails to notify you of the violation by some reasonable means prior to
|
|
60 days after the cessation.
|
|
</p>
|
|
<p>Moreover, your license from a particular copyright holder is
|
|
reinstated permanently if the copyright holder notifies you of the
|
|
violation by some reasonable means, this is the first time you have
|
|
received notice of violation of this License (for any work) from that
|
|
copyright holder, and you cure the violation prior to 30 days after
|
|
your receipt of the notice.
|
|
</p>
|
|
<p>Termination of your rights under this section does not terminate the
|
|
licenses of parties who have received copies or rights from you under
|
|
this License. If your rights have been terminated and not permanently
|
|
reinstated, receipt of a copy of some or all of the same material does
|
|
not give you any rights to use it.
|
|
</p>
|
|
</li><li> FUTURE REVISIONS OF THIS LICENSE
|
|
|
|
<p>The Free Software Foundation may publish new, revised versions
|
|
of the GNU Free Documentation License from time to time. Such new
|
|
versions will be similar in spirit to the present version, but may
|
|
differ in detail to address new problems or concerns. See
|
|
<a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>.
|
|
</p>
|
|
<p>Each version of the License is given a distinguishing version number.
|
|
If the Document specifies that a particular numbered version of this
|
|
License “or any later version” applies to it, you have the option of
|
|
following the terms and conditions either of that specified version or
|
|
of any later version that has been published (not as a draft) by the
|
|
Free Software Foundation. If the Document does not specify a version
|
|
number of this License, you may choose any version ever published (not
|
|
as a draft) by the Free Software Foundation. If the Document
|
|
specifies that a proxy can decide which future versions of this
|
|
License can be used, that proxy’s public statement of acceptance of a
|
|
version permanently authorizes you to choose that version for the
|
|
Document.
|
|
</p>
|
|
</li><li> RELICENSING
|
|
|
|
<p>“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
|
|
World Wide Web server that publishes copyrightable works and also
|
|
provides prominent facilities for anybody to edit those works. A
|
|
public wiki that anybody can edit is an example of such a server. A
|
|
“Massive Multiauthor Collaboration” (or “MMC”) contained in the
|
|
site means any set of copyrightable works thus published on the MMC
|
|
site.
|
|
</p>
|
|
<p>“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
|
|
license published by Creative Commons Corporation, a not-for-profit
|
|
corporation with a principal place of business in San Francisco,
|
|
California, as well as future copyleft versions of that license
|
|
published by that same organization.
|
|
</p>
|
|
<p>“Incorporate” means to publish or republish a Document, in whole or
|
|
in part, as part of another Document.
|
|
</p>
|
|
<p>An MMC is “eligible for relicensing” if it is licensed under this
|
|
License, and if all works that were first published under this License
|
|
somewhere other than this MMC, and subsequently incorporated in whole
|
|
or in part into the MMC, (1) had no cover texts or invariant sections,
|
|
and (2) were thus incorporated prior to November 1, 2008.
|
|
</p>
|
|
<p>The operator of an MMC Site may republish an MMC contained in the site
|
|
under CC-BY-SA on the same site at any time before August 1, 2009,
|
|
provided the MMC is eligible for relicensing.
|
|
</p>
|
|
</li></ol>
|
|
|
|
<span id="ADDENDUM_003a-How-to-use-this-License-for-your-documents"></span><h3 class="heading">ADDENDUM: How to use this License for your documents</h3>
|
|
|
|
<p>To use this License in a document you have written, include a copy of
|
|
the License in the document and put the following copyright and
|
|
license notices just after the title page:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"> Copyright (C) <var>year</var> <var>your name</var>.
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3
|
|
or any later version published by the Free Software Foundation;
|
|
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
|
|
Texts. A copy of the license is included in the section entitled ``GNU
|
|
Free Documentation License''.
|
|
</pre></div>
|
|
|
|
<p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
|
|
replace the “with…Texts.” line with this:
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"> with the Invariant Sections being <var>list their titles</var>, with
|
|
the Front-Cover Texts being <var>list</var>, and with the Back-Cover Texts
|
|
being <var>list</var>.
|
|
</pre></div>
|
|
|
|
<p>If you have Invariant Sections without Cover Texts, or some other
|
|
combination of the three, merge those two alternatives to suit the
|
|
situation.
|
|
</p>
|
|
<p>If your document contains nontrivial examples of program code, we
|
|
recommend releasing these examples in parallel under your choice of
|
|
free software license, such as the GNU General Public License,
|
|
to permit their use in free software.
|
|
</p>
|
|
|
|
<hr>
|
|
<span id="Concept-Index"></span><div class="header">
|
|
<p>
|
|
Next: <a href="#Name-Index" accesskey="n" rel="next">Name Index</a>, Previous: <a href="#GNU-Free-Documentation-License" accesskey="p" rel="prev">GNU Free Documentation License</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Index-of-Concepts"></span><h2 class="unnumbered">Index of Concepts</h2>
|
|
|
|
<table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Concept-Index_cp_symbol-1"><b>!</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-2"><b>#</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-3"><b>$</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-4"><b>%</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-5"><b>*</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-6"><b>+</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-7"><b>,</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-8"><b>-</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-9"><b>.</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-10"><b>:</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-11"><b>=</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-12"><b>?</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-13"><b>@</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-14"><b>[</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-15"><b>\</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-16"><b>_</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-17"><b>~</b></a>
|
|
|
|
<br>
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-G"><b>G</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-J"><b>J</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-L"><b>L</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-Q"><b>Q</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-U"><b>U</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-Y"><b>Y</b></a>
|
|
|
|
</td></tr></table>
|
|
<table class="index-cp" border="0">
|
|
<tr><td></td><th align="left">Index Entry</th><td> </td><th align="left"> Section</th></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-1">!</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0021_003d">!=</a>:</td><td> </td><td valign="top"><a href="#Setting">Setting</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0021_003d_002c-expansion">!=, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-2">#</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0023-_0028comments_0029_002c-in-makefile"><code>#</code> (comments), in makefile</a>:</td><td> </td><td valign="top"><a href="#Makefile-Contents">Makefile Contents</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0023-_0028comments_0029_002c-in-recipes"><code>#</code> (comments), in recipes</a>:</td><td> </td><td valign="top"><a href="#Recipe-Syntax">Recipe Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0023include"><code>#include</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-3">$</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_002c-in-function-call"><code>$</code>, in function call</a>:</td><td> </td><td valign="top"><a href="#Syntax-of-Functions">Syntax of Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_002c-in-rules"><code>$</code>, in rules</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_002c-in-variable-name"><code>$</code>, in variable name</a>:</td><td> </td><td valign="top"><a href="#Computed-Names">Computed Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_002c-in-variable-reference"><code>$</code>, in variable reference</a>:</td><td> </td><td valign="top"><a href="#Reference">Reference</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-4">%</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025_002c-in-pattern-rules"><code>%</code>, in pattern rules</a>:</td><td> </td><td valign="top"><a href="#Pattern-Intro">Pattern Intro</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025_002c-quoting-in-patsubst"><code>%</code>, quoting in <code>patsubst</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025_002c-quoting-in-static-pattern"><code>%</code>, quoting in static pattern</a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025_002c-quoting-in-vpath"><code>%</code>, quoting in <code>vpath</code></a>:</td><td> </td><td valign="top"><a href="#Selective-Search">Selective Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025_002c-quoting-with-_005c-_0028backslash_0029"><code>%</code>, quoting with <code>\</code> (backslash)</a>:</td><td> </td><td valign="top"><a href="#Selective-Search">Selective Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025_002c-quoting-with-_005c-_0028backslash_0029-1"><code>%</code>, quoting with <code>\</code> (backslash)</a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025_002c-quoting-with-_005c-_0028backslash_0029-2"><code>%</code>, quoting with <code>\</code> (backslash)</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-5">*</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002a-_0028wildcard-character_0029"><code>*</code> (wildcard character)</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-6">+</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002b_002c-and-define">+, and <code>define</code></a>:</td><td> </td><td valign="top"><a href="#Canned-Recipes">Canned Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002b_002c-and-recipe-execution">+, and recipe execution</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002b_002c-and-recipes">+, and recipes</a>:</td><td> </td><td valign="top"><a href="#MAKE-Variable">MAKE Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002b_003d">+=</a>:</td><td> </td><td valign="top"><a href="#Appending">Appending</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002b_003d_002c-expansion">+=, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002b_003d_002c-expansion-1">+=, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-7">,</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002cv-_0028RCS-file-extension_0029"><code>,v <span class="roman">(RCS file extension)</span></code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-8">-</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d-_0028in-recipes_0029"><code>-</code> (in recipes)</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002c-and-define">-, and <code>define</code></a>:</td><td> </td><td valign="top"><a href="#Canned-Recipes">Canned Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dalways_002dmake"><code>--always-make</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dassume_002dnew"><code>--assume-new</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dassume_002dnew-1"><code>--assume-new</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dassume_002dnew_002c-and-recursion"><code>--assume-new</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dassume_002dold"><code>--assume-old</code></a>:</td><td> </td><td valign="top"><a href="#Avoiding-Compilation">Avoiding Compilation</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dassume_002dold-1"><code>--assume-old</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dassume_002dold_002c-and-recursion"><code>--assume-old</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dcheck_002dsymlink_002dtimes"><code>--check-symlink-times</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002ddebug"><code>--debug</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002ddirectory"><code>--directory</code></a>:</td><td> </td><td valign="top"><a href="#Recursion">Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002ddirectory-1"><code>--directory</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002ddirectory_002c-and-_002d_002dprint_002ddirectory"><code>--directory</code>, and <code>--print-directory</code></a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002ddirectory_002c-and-recursion"><code>--directory</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002ddry_002drun"><code>--dry-run</code></a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002ddry_002drun-1"><code>--dry-run</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002ddry_002drun-2"><code>--dry-run</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002denvironment_002doverrides"><code>--environment-overrides</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002deval"><code>--eval</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dfile"><code>--file</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dfile-1"><code>--file</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Arguments">Makefile Arguments</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dfile-2"><code>--file</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dfile_002c-and-recursion"><code>--file</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dhelp"><code>--help</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dignore_002derrors"><code>--ignore-errors</code></a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dignore_002derrors-1"><code>--ignore-errors</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dinclude_002ddir"><code>--include-dir</code></a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dinclude_002ddir-1"><code>--include-dir</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djobs"><code>--jobs</code></a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djobs-1"><code>--jobs</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djobs_002c-and-recursion"><code>--jobs</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djobserver_002dauth"><code>--jobserver-auth</code></a>:</td><td> </td><td valign="top"><a href="#Job-Slots">Job Slots</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djobserver_002dstyle"><code>--jobserver-style</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djobserver_002dstyle-1"><code>--jobserver-style</code></a>:</td><td> </td><td valign="top"><a href="#POSIX-Jobserver">POSIX Jobserver</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djobserver_002dstyle-for-Windows"><code>--jobserver-style</code> for Windows</a>:</td><td> </td><td valign="top"><a href="#Windows-Jobserver">Windows Jobserver</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djust_002dprint"><code>--just-print</code></a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djust_002dprint-1"><code>--just-print</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002djust_002dprint-2"><code>--just-print</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dkeep_002dgoing"><code>--keep-going</code></a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dkeep_002dgoing-1"><code>--keep-going</code></a>:</td><td> </td><td valign="top"><a href="#Testing">Testing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dkeep_002dgoing-2"><code>--keep-going</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dload_002daverage"><code>--load-average</code></a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dload_002daverage-1"><code>--load-average</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dmakefile"><code>--makefile</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dmakefile-1"><code>--makefile</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Arguments">Makefile Arguments</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dmakefile-2"><code>--makefile</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dmax_002dload"><code>--max-load</code></a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dmax_002dload-1"><code>--max-load</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dnew_002dfile"><code>--new-file</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dnew_002dfile-1"><code>--new-file</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dnew_002dfile_002c-and-recursion"><code>--new-file</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dno_002dbuiltin_002drules"><code>--no-builtin-rules</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dno_002dbuiltin_002dvariables"><code>--no-builtin-variables</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dno_002dkeep_002dgoing"><code>--no-keep-going</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dno_002dprint_002ddirectory"><code>--no-print-directory</code></a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dno_002dprint_002ddirectory-1"><code>--no-print-directory</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dold_002dfile"><code>--old-file</code></a>:</td><td> </td><td valign="top"><a href="#Avoiding-Compilation">Avoiding Compilation</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dold_002dfile-1"><code>--old-file</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dold_002dfile_002c-and-recursion"><code>--old-file</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002doutput_002dsync"><code>--output-sync</code></a>:</td><td> </td><td valign="top"><a href="#Parallel-Output">Parallel Output</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002doutput_002dsync-1"><code>--output-sync</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dprint_002ddata_002dbase"><code>--print-data-base</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dprint_002ddirectory"><code>--print-directory</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dprint_002ddirectory_002c-and-_002d_002ddirectory"><code>--print-directory</code>, and <code>--directory</code></a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dprint_002ddirectory_002c-and-recursion"><code>--print-directory</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dprint_002ddirectory_002c-disabling"><code>--print-directory</code>, disabling</a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dquestion"><code>--question</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dquestion-1"><code>--question</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dquiet"><code>--quiet</code></a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dquiet-1"><code>--quiet</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002drecon"><code>--recon</code></a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002drecon-1"><code>--recon</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002drecon-2"><code>--recon</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dshuffle"><code>--shuffle</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dsilent"><code>--silent</code></a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dsilent-1"><code>--silent</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dstop"><code>--stop</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dtouch"><code>--touch</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dtouch-1"><code>--touch</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dtouch_002c-and-recursion"><code>--touch</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#MAKE-Variable">MAKE Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dtrace"><code>--trace</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dversion"><code>--version</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dwarn_002dundefined_002dvariables"><code>--warn-undefined-variables</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dwhat_002dif"><code>--what-if</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002d_002dwhat_002dif-1"><code>--what-if</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002db"><code>-b</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dB"><code>-B</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dC"><code>-C</code></a>:</td><td> </td><td valign="top"><a href="#Recursion">Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dC-1"><code>-C</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dC_002c-and-_002dw"><code>-C</code>, and <code>-w</code></a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dC_002c-and-recursion"><code>-C</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dd"><code>-d</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002de"><code>-e</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dE"><code>-E</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002de-_0028shell-flag_0029"><code>-e</code> (shell flag)</a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002df"><code>-f</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002df-1"><code>-f</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Arguments">Makefile Arguments</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002df-2"><code>-f</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002df_002c-and-recursion"><code>-f</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dh"><code>-h</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dI"><code>-I</code></a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002di"><code>-i</code></a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002di-1"><code>-i</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dI-1"><code>-I</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dj"><code>-j</code></a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dj-1"><code>-j</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dj_002c-and-archive-update"><code>-j</code>, and archive update</a>:</td><td> </td><td valign="top"><a href="#Archive-Pitfalls">Archive Pitfalls</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dj_002c-and-recursion"><code>-j</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dk"><code>-k</code></a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dk-1"><code>-k</code></a>:</td><td> </td><td valign="top"><a href="#Testing">Testing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dk-2"><code>-k</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dl"><code>-l</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dL"><code>-L</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dl-_0028library-search_0029"><code>-l</code> (library search)</a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dl-_0028load-average_0029"><code>-l</code> (load average)</a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dm"><code>-m</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dM-_0028to-compiler_0029"><code>-M</code> (to compiler)</a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dMM-_0028to-GNU-compiler_0029"><code>-MM</code> (to GNU compiler)</a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dn"><code>-n</code></a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dn-1"><code>-n</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dn-2"><code>-n</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dO"><code>-O</code></a>:</td><td> </td><td valign="top"><a href="#Parallel-Output">Parallel Output</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002do"><code>-o</code></a>:</td><td> </td><td valign="top"><a href="#Avoiding-Compilation">Avoiding Compilation</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002do-1"><code>-o</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dO-1"><code>-O</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002do_002c-and-recursion"><code>-o</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dp"><code>-p</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dq"><code>-q</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dq-1"><code>-q</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dr"><code>-r</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dR"><code>-R</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ds"><code>-s</code></a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ds-1"><code>-s</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dS"><code>-S</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dt"><code>-t</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dt-1"><code>-t</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dt_002c-and-recursion"><code>-t</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#MAKE-Variable">MAKE Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dv"><code>-v</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dW"><code>-W</code></a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dw"><code>-w</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dW-1"><code>-W</code></a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dw_002c-and-_002dC"><code>-w</code>, and <code>-C</code></a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dW_002c-and-recursion"><code>-W</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dw_002c-and-recursion"><code>-w</code>, and recursion</a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dw_002c-disabling"><code>-w</code>, disabling</a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-9">.</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ea-_0028archives_0029"><code>.a</code> (archives)</a>:</td><td> </td><td valign="top"><a href="#Archive-Suffix-Rules">Archive Suffix Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ec"><code>.c</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eC"><code>.C</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ecc"><code>.cc</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ech"><code>.ch</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ecpp"><code>.cpp</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ed"><code>.d</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002edef"><code>.def</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002edvi"><code>.dvi</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ef"><code>.f</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eF"><code>.F</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002einfo"><code>.info</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002el"><code>.l</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eLIBPATTERNS_002c-and-link-libraries"><code>.LIBPATTERNS</code>, and link libraries</a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eln"><code>.ln</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002emod"><code>.mod</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eNOTPARALLEL-special-target">.NOTPARALLEL special target</a>:</td><td> </td><td valign="top"><a href="#Parallel-Disable">Parallel Disable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eo"><code>.o</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eo-1"><code>.o</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eONESHELL_002c-use-of"><code>.ONESHELL</code>, use of</a>:</td><td> </td><td valign="top"><a href="#One-Shell">One Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ep"><code>.p</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002er"><code>.r</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002es"><code>.s</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eS"><code>.S</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002esh"><code>.sh</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSHELLFLAGS_002c-value-of"><code>.SHELLFLAGS</code>, value of</a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002esym"><code>.sym</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002etex"><code>.tex</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002etexi"><code>.texi</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002etexinfo"><code>.texinfo</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002etxinfo"><code>.txinfo</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ew"><code>.w</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eWAIT-special-target">.WAIT special target</a>:</td><td> </td><td valign="top"><a href="#Parallel-Disable">Parallel Disable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eweb"><code>.web</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ey"><code>.y</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-10">:</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003a_003a-rules-_0028double_002dcolon_0029"><code>::</code> rules (double-colon)</a>:</td><td> </td><td valign="top"><a href="#Double_002dColon">Double-Colon</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003a_003a_003a_003d">:::=</a>:</td><td> </td><td valign="top"><a href="#Immediate-Assignment">Immediate Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003a_003a_003a_003d-1">:::=</a>:</td><td> </td><td valign="top"><a href="#Setting">Setting</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003a_003a_003d">::=</a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003a_003a_003d-1">::=</a>:</td><td> </td><td valign="top"><a href="#Setting">Setting</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003a_003d">:=</a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003a_003d-1">:=</a>:</td><td> </td><td valign="top"><a href="#Setting">Setting</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-11">=</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003d">=</a>:</td><td> </td><td valign="top"><a href="#Recursive-Assignment">Recursive Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003d-1">=</a>:</td><td> </td><td valign="top"><a href="#Setting">Setting</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003d_002c-expansion">=, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-12">?</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003f-_0028wildcard-character_0029"><code>?</code> (wildcard character)</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003f_003d">?=</a>:</td><td> </td><td valign="top"><a href="#Conditional-Assignment">Conditional Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003f_003d-1">?=</a>:</td><td> </td><td valign="top"><a href="#Setting">Setting</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003f_003d_002c-expansion">?=, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-13">@</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0040-_0028in-recipes_0029"><code>@</code> (in recipes)</a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0040_002c-and-define">@, and <code>define</code></a>:</td><td> </td><td valign="top"><a href="#Canned-Recipes">Canned Recipes</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-14">[</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005b_2026_005d-_0028wildcard-characters_0029"><code>[…]</code> (wildcard characters)</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-15">\</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005c-_0028backslash_0029_002c-for-continuation-lines"><code>\</code> (backslash), for continuation lines</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005c-_0028backslash_0029_002c-in-recipes"><code>\</code> (backslash), in recipes</a>:</td><td> </td><td valign="top"><a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005c-_0028backslash_0029_002c-to-quote-_0025"><code>\</code> (backslash), to quote <code>%</code></a>:</td><td> </td><td valign="top"><a href="#Selective-Search">Selective Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005c-_0028backslash_0029_002c-to-quote-_0025-1"><code>\</code> (backslash), to quote <code>%</code></a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005c-_0028backslash_0029_002c-to-quote-_0025-2"><code>\</code> (backslash), to quote <code>%</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-16">_</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005f_005f_002eSYMDEF"><code>__.SYMDEF</code></a>:</td><td> </td><td valign="top"><a href="#Archive-Symbols">Archive Symbols</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_symbol-17">~</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_007e-_0028tilde_0029"><code>~</code> (tilde)</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-A">A</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-abspath">abspath</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-algorithm-for-directory-search">algorithm for directory search</a>:</td><td> </td><td valign="top"><a href="#Search-Algorithm">Search Algorithm</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-all-_0028standard-target_0029"><code>all</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-appending-to-variables">appending to variables</a>:</td><td> </td><td valign="top"><a href="#Appending">Appending</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ar"><code>ar</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-archive">archive</a>:</td><td> </td><td valign="top"><a href="#Archives">Archives</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-archive-member-targets">archive member targets</a>:</td><td> </td><td valign="top"><a href="#Archive-Members">Archive Members</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-archive-symbol-directory-updating">archive symbol directory updating</a>:</td><td> </td><td valign="top"><a href="#Archive-Symbols">Archive Symbols</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-archive_002c-and-_002dj">archive, and <code>-j</code></a>:</td><td> </td><td valign="top"><a href="#Archive-Pitfalls">Archive Pitfalls</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-archive_002c-and-parallel-execution">archive, and parallel execution</a>:</td><td> </td><td valign="top"><a href="#Archive-Pitfalls">Archive Pitfalls</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-archive_002c-suffix-rule-for">archive, suffix rule for</a>:</td><td> </td><td valign="top"><a href="#Archive-Suffix-Rules">Archive Suffix Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Arg-list-too-long">Arg list too long</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-arguments-of-functions">arguments of functions</a>:</td><td> </td><td valign="top"><a href="#Syntax-of-Functions">Syntax of Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-as"><code>as</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-as-1"><code>as</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-assembly_002c-rule-to-compile">assembly, rule to compile</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-automatic-generation-of-prerequisites">automatic generation of prerequisites</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-automatic-generation-of-prerequisites-1">automatic generation of prerequisites</a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-automatic-variables">automatic variables</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-automatic-variables-in-prerequisites">automatic variables in prerequisites</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-B">B</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-backquotes">backquotes</a>:</td><td> </td><td valign="top"><a href="#Shell-Function">Shell Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-backslash-_0028_005c_0029_002c-for-continuation-lines">backslash (<code>\</code>), for continuation lines</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-backslash-_0028_005c_0029_002c-in-recipes">backslash (<code>\</code>), in recipes</a>:</td><td> </td><td valign="top"><a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-backslash-_0028_005c_0029_002c-to-quote-_0025">backslash (<code>\</code>), to quote <code>%</code></a>:</td><td> </td><td valign="top"><a href="#Selective-Search">Selective Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-backslash-_0028_005c_0029_002c-to-quote-_0025-1">backslash (<code>\</code>), to quote <code>%</code></a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-backslash-_0028_005c_0029_002c-to-quote-_0025-2">backslash (<code>\</code>), to quote <code>%</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-backslash-_0028_005c_0029_002c-to-quote-newlines">backslash (<code>\</code>), to quote newlines</a>:</td><td> </td><td valign="top"><a href="#Splitting-Lines">Splitting Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-backslashes-in-pathnames-and-wildcard-expansion">backslashes in pathnames and wildcard expansion</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Pitfall">Wildcard Pitfall</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-basename">basename</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-binary-packages">binary packages</a>:</td><td> </td><td valign="top"><a href="#Install-Command-Categories">Install Command Categories</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-broken-pipe">broken pipe</a>:</td><td> </td><td valign="top"><a href="#Parallel-Input">Parallel Input</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-bugs_002c-reporting">bugs, reporting</a>:</td><td> </td><td valign="top"><a href="#Bugs">Bugs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-built_002din-special-targets">built-in special targets</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-C">C</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-C_002b_002b_002c-rule-to-compile">C++, rule to compile</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-C_002c-rule-to-compile">C, rule to compile</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-canned-recipes">canned recipes</a>:</td><td> </td><td valign="top"><a href="#Canned-Recipes">Canned Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-cc"><code>cc</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-cc-1"><code>cc</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-cd-_0028shell-command_0029"><code>cd</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Execution">Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-cd-_0028shell-command_0029-1"><code>cd</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#MAKE-Variable">MAKE Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-chains-of-rules">chains of rules</a>:</td><td> </td><td valign="top"><a href="#Chained-Rules">Chained Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-check-_0028standard-target_0029"><code>check</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-clean-_0028standard-target_0029"><code>clean</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-clean-target"><code>clean</code> target</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-clean-target-1"><code>clean</code> target</a>:</td><td> </td><td valign="top"><a href="#Cleanup">Cleanup</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-cleaning-up">cleaning up</a>:</td><td> </td><td valign="top"><a href="#Cleanup">Cleanup</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-clobber-_0028standard-target_0029"><code>clobber</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-co"><code>co</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-co-1"><code>co</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-combining-rules-by-prerequisite">combining rules by prerequisite</a>:</td><td> </td><td valign="top"><a href="#Combine-By-Prerequisite">Combine By Prerequisite</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-command-expansion">command expansion</a>:</td><td> </td><td valign="top"><a href="#Shell-Function">Shell Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-command-line-variable-definitions_002c-and-recursion">command line variable definitions, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-command-line-variables">command line variables</a>:</td><td> </td><td valign="top"><a href="#Overriding">Overriding</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-commands_002c-sequences-of">commands, sequences of</a>:</td><td> </td><td valign="top"><a href="#Canned-Recipes">Canned Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-comments_002c-in-makefile">comments, in makefile</a>:</td><td> </td><td valign="top"><a href="#Makefile-Contents">Makefile Contents</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-comments_002c-in-recipes">comments, in recipes</a>:</td><td> </td><td valign="top"><a href="#Recipe-Syntax">Recipe Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-compatibility">compatibility</a>:</td><td> </td><td valign="top"><a href="#Features">Features</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-compatibility-in-exporting">compatibility in exporting</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-compilation_002c-testing">compilation, testing</a>:</td><td> </td><td valign="top"><a href="#Testing">Testing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-computed-variable-name">computed variable name</a>:</td><td> </td><td valign="top"><a href="#Computed-Names">Computed Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-conditional-expansion">conditional expansion</a>:</td><td> </td><td valign="top"><a href="#Conditional-Functions">Conditional Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-conditional-variable-assignment">conditional variable assignment</a>:</td><td> </td><td valign="top"><a href="#Conditional-Assignment">Conditional Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-conditionals">conditionals</a>:</td><td> </td><td valign="top"><a href="#Conditionals">Conditionals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-continuation-lines">continuation lines</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-controlling-make">controlling make</a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-conventions-for-makefiles">conventions for makefiles</a>:</td><td> </td><td valign="top"><a href="#Makefile-Conventions">Makefile Conventions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-convert-guile-types">convert guile types</a>:</td><td> </td><td valign="top"><a href="#Guile-Types">Guile Types</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ctangle"><code>ctangle</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ctangle-1"><code>ctangle</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-cweave"><code>cweave</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-cweave-1"><code>cweave</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-D">D</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-data-base-of-make-rules">data base of <code>make</code> rules</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-deducing-recipes-_0028implicit-rules_0029">deducing recipes (implicit rules)</a>:</td><td> </td><td valign="top"><a href="#make-Deduces">make Deduces</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-default-directories-for-included-makefiles">default directories for included makefiles</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-default-goal">default goal</a>:</td><td> </td><td valign="top"><a href="#How-Make-Works">How Make Works</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-default-goal-1">default goal</a>:</td><td> </td><td valign="top"><a href="#Rules">Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-default-makefile-name">default makefile name</a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-default-rules_002c-last_002dresort">default rules, last-resort</a>:</td><td> </td><td valign="top"><a href="#Last-Resort">Last Resort</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-define_002c-expansion">define, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-defining-variables-verbatim">defining variables verbatim</a>:</td><td> </td><td valign="top"><a href="#Multi_002dLine">Multi-Line</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-deletion-of-target-files">deletion of target files</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-deletion-of-target-files-1">deletion of target files</a>:</td><td> </td><td valign="top"><a href="#Interrupts">Interrupts</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directive">directive</a>:</td><td> </td><td valign="top"><a href="#Makefile-Contents">Makefile Contents</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directories_002c-creating-installation">directories, creating installation</a>:</td><td> </td><td valign="top"><a href="#Directory-Variables">Directory Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directories_002c-printing-them">directories, printing them</a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directories_002c-updating-archive-symbol">directories, updating archive symbol</a>:</td><td> </td><td valign="top"><a href="#Archive-Symbols">Archive Symbols</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directory-part">directory part</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directory-search-_0028VPATH_0029">directory search (<code>VPATH</code>)</a>:</td><td> </td><td valign="top"><a href="#Directory-Search">Directory Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directory-search-_0028VPATH_0029_002c-and-implicit-rules">directory search (<code>VPATH</code>), and implicit rules</a>:</td><td> </td><td valign="top"><a href="#Implicit_002fSearch">Implicit/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directory-search-_0028VPATH_0029_002c-and-link-libraries">directory search (<code>VPATH</code>), and link libraries</a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directory-search-_0028VPATH_0029_002c-and-recipes">directory search (<code>VPATH</code>), and recipes</a>:</td><td> </td><td valign="top"><a href="#Recipes_002fSearch">Recipes/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directory-search-algorithm">directory search algorithm</a>:</td><td> </td><td valign="top"><a href="#Search-Algorithm">Search Algorithm</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-directory-search_002c-traditional-_0028GPATH_0029">directory search, traditional (GPATH)</a>:</td><td> </td><td valign="top"><a href="#Search-Algorithm">Search Algorithm</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-disabling-parallel-execution">disabling parallel execution</a>:</td><td> </td><td valign="top"><a href="#Parallel-Disable">Parallel Disable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-dist-_0028standard-target_0029"><code>dist</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-distclean-_0028standard-target_0029"><code>distclean</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-dollar-sign-_0028_0024_0029_002c-in-function-call">dollar sign (<code>$</code>), in function call</a>:</td><td> </td><td valign="top"><a href="#Syntax-of-Functions">Syntax of Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-dollar-sign-_0028_0024_0029_002c-in-rules">dollar sign (<code>$</code>), in rules</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-dollar-sign-_0028_0024_0029_002c-in-variable-name">dollar sign (<code>$</code>), in variable name</a>:</td><td> </td><td valign="top"><a href="#Computed-Names">Computed Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-dollar-sign-_0028_0024_0029_002c-in-variable-reference">dollar sign (<code>$</code>), in variable reference</a>:</td><td> </td><td valign="top"><a href="#Reference">Reference</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-DOS_002c-choosing-a-shell-in">DOS, choosing a shell in</a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-double_002dcolon-rules">double-colon rules</a>:</td><td> </td><td valign="top"><a href="#Double_002dColon">Double-Colon</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-duplicate-words_002c-removing">duplicate words, removing</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-E">E</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-E2BIG">E2BIG</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-echoing-of-recipes">echoing of recipes</a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-editor">editor</a>:</td><td> </td><td valign="top"><a href="#Introduction">Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Emacs-_0028M_002dx-compile_0029">Emacs (<code>M-x compile</code>)</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-empty-recipes">empty recipes</a>:</td><td> </td><td valign="top"><a href="#Empty-Recipes">Empty Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-empty-targets">empty targets</a>:</td><td> </td><td valign="top"><a href="#Empty-Targets">Empty Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-environment">environment</a>:</td><td> </td><td valign="top"><a href="#Environment">Environment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-environment_002c-and-recursion">environment, and recursion</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-environment_002c-SHELL-in">environment, <code>SHELL</code> in</a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-error_002c-stopping-on">error, stopping on</a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-errors-_0028in-recipes_0029">errors (in recipes)</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-errors-with-wildcards">errors with wildcards</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Pitfall">Wildcard Pitfall</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-evaluating-makefile-syntax">evaluating makefile syntax</a>:</td><td> </td><td valign="top"><a href="#Eval-Function">Eval Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-example-of-loaded-objects">example of loaded objects</a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-Example">Loaded Object Example</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-example-using-Guile">example using Guile</a>:</td><td> </td><td valign="top"><a href="#Guile-Example">Guile Example</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-execution_002c-in-parallel">execution, in parallel</a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-execution_002c-instead-of">execution, instead of</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-execution_002c-of-recipes">execution, of recipes</a>:</td><td> </td><td valign="top"><a href="#Execution">Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-exit-status-_0028errors_0029">exit status (errors)</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-exit-status-of-make">exit status of make</a>:</td><td> </td><td valign="top"><a href="#Running">Running</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-expansion_002c-secondary">expansion, secondary</a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-explicit-rule_002c-definition-of">explicit rule, definition of</a>:</td><td> </td><td valign="top"><a href="#Makefile-Contents">Makefile Contents</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-explicit-rule_002c-expansion">explicit rule, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-explicit-rules_002c-secondary-expansion-of">explicit rules, secondary expansion of</a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-exporting-variables">exporting variables</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-extensions_002c-Guile">extensions, Guile</a>:</td><td> </td><td valign="top"><a href="#Guile-Integration">Guile Integration</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-extensions_002c-load-directive">extensions, load directive</a>:</td><td> </td><td valign="top"><a href="#load-Directive">load Directive</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-extensions_002c-loading">extensions, loading</a>:</td><td> </td><td valign="top"><a href="#Loading-Objects">Loading Objects</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-F">F</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-f77"><code>f77</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-f77-1"><code>f77</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-FDL_002c-GNU-Free-Documentation-License">FDL, GNU Free Documentation License</a>:</td><td> </td><td valign="top"><a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-features-of-GNU-make">features of GNU <code>make</code></a>:</td><td> </td><td valign="top"><a href="#Features">Features</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-features_002c-missing">features, missing</a>:</td><td> </td><td valign="top"><a href="#Missing">Missing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name-functions">file name functions</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name-of-makefile">file name of makefile</a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name-of-makefile_002c-how-to-specify">file name of makefile, how to specify</a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name-prefix_002c-adding">file name prefix, adding</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name-suffix">file name suffix</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name-suffix_002c-adding">file name suffix, adding</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name-with-wildcards">file name with wildcards</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name_002c-abspath-of">file name, abspath of</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name_002c-basename-of">file name, basename of</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name_002c-directory-part">file name, directory part</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name_002c-nondirectory-part">file name, nondirectory part</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file-name_002c-realpath-of">file name, realpath of</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file_002c-reading-from">file, reading from</a>:</td><td> </td><td valign="top"><a href="#File-Function">File Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file_002c-writing-to">file, writing to</a>:</td><td> </td><td valign="top"><a href="#File-Function">File Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-files_002c-assuming-new">files, assuming new</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-files_002c-assuming-old">files, assuming old</a>:</td><td> </td><td valign="top"><a href="#Avoiding-Compilation">Avoiding Compilation</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-files_002c-avoiding-recompilation-of">files, avoiding recompilation of</a>:</td><td> </td><td valign="top"><a href="#Avoiding-Compilation">Avoiding Compilation</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-files_002c-intermediate">files, intermediate</a>:</td><td> </td><td valign="top"><a href="#Chained-Rules">Chained Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-filtering-out-words">filtering out words</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-filtering-words">filtering words</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-finding-strings">finding strings</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-flags">flags</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-flags-for-compilers">flags for compilers</a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-flavor-of-variable">flavor of variable</a>:</td><td> </td><td valign="top"><a href="#Flavor-Function">Flavor Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-flavors-of-variables">flavors of variables</a>:</td><td> </td><td valign="top"><a href="#Flavors">Flavors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-FORCE"><code>FORCE</code></a>:</td><td> </td><td valign="top"><a href="#Force-Targets">Force Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-force-targets">force targets</a>:</td><td> </td><td valign="top"><a href="#Force-Targets">Force Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Fortran_002c-rule-to-compile">Fortran, rule to compile</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-function-arguments_002c-special-characters-in">function arguments, special characters in</a>:</td><td> </td><td valign="top"><a href="#Syntax-of-Functions">Syntax of Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-functions">functions</a>:</td><td> </td><td valign="top"><a href="#Functions">Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-functions_002c-for-controlling-make">functions, for controlling make</a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-functions_002c-for-file-names">functions, for file names</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-functions_002c-for-text">functions, for text</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-functions_002c-syntax-of">functions, syntax of</a>:</td><td> </td><td valign="top"><a href="#Syntax-of-Functions">Syntax of Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-functions_002c-user-defined">functions, user defined</a>:</td><td> </td><td valign="top"><a href="#Call-Function">Call Function</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-G">G</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-g_002b_002b"><code>g++</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-g_002b_002b-1"><code>g++</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gcc"><code>gcc</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-generating-prerequisites-automatically">generating prerequisites automatically</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-generating-prerequisites-automatically-1">generating prerequisites automatically</a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-get"><code>get</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-get-1"><code>get</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-globbing-_0028wildcards_0029">globbing (wildcards)</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-goal">goal</a>:</td><td> </td><td valign="top"><a href="#How-Make-Works">How Make Works</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-goal_002c-default">goal, default</a>:</td><td> </td><td valign="top"><a href="#How-Make-Works">How Make Works</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-goal_002c-default-1">goal, default</a>:</td><td> </td><td valign="top"><a href="#Rules">Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-goal_002c-how-to-specify">goal, how to specify</a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-grouped-targets">grouped targets</a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Guile">Guile</a>:</td><td> </td><td valign="top"><a href="#Guile-Function">Guile Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Guile-1">Guile</a>:</td><td> </td><td valign="top"><a href="#Guile-Integration">Guile Integration</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Guile-example">Guile example</a>:</td><td> </td><td valign="top"><a href="#Guile-Example">Guile Example</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-guile_002c-conversion-of-types">guile, conversion of types</a>:</td><td> </td><td valign="top"><a href="#Guile-Types">Guile Types</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-H">H</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-home-directory">home directory</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-I">I</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-IEEE-Standard-1003_002e2">IEEE Standard 1003.2</a>:</td><td> </td><td valign="top"><a href="#Overview">Overview</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ifdef_002c-expansion">ifdef, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ifeq_002c-expansion">ifeq, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ifndef_002c-expansion">ifndef, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ifneq_002c-expansion">ifneq, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-immediate-variable-assignment">immediate variable assignment</a>:</td><td> </td><td valign="top"><a href="#Immediate-Assignment">Immediate Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule">implicit rule</a>:</td><td> </td><td valign="top"><a href="#Implicit-Rules">Implicit Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule_002c-and-directory-search">implicit rule, and directory search</a>:</td><td> </td><td valign="top"><a href="#Implicit_002fSearch">Implicit/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule_002c-and-VPATH">implicit rule, and <code>VPATH</code></a>:</td><td> </td><td valign="top"><a href="#Implicit_002fSearch">Implicit/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule_002c-definition-of">implicit rule, definition of</a>:</td><td> </td><td valign="top"><a href="#Makefile-Contents">Makefile Contents</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule_002c-expansion">implicit rule, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule_002c-how-to-use">implicit rule, how to use</a>:</td><td> </td><td valign="top"><a href="#Using-Implicit">Using Implicit</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule_002c-introduction-to">implicit rule, introduction to</a>:</td><td> </td><td valign="top"><a href="#make-Deduces">make Deduces</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule_002c-predefined">implicit rule, predefined</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rule_002c-search-algorithm">implicit rule, search algorithm</a>:</td><td> </td><td valign="top"><a href="#Implicit-Rule-Search">Implicit Rule Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-implicit-rules_002c-secondary-expansion-of">implicit rules, secondary expansion of</a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-included-makefiles_002c-default-directories">included makefiles, default directories</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-including-_0028MAKEFILES-variable_0029">including (<code>MAKEFILES</code> variable)</a>:</td><td> </td><td valign="top"><a href="#MAKEFILES-Variable">MAKEFILES Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-including-_0028MAKEFILE_005fLIST-variable_0029">including (<code>MAKEFILE_LIST</code> variable)</a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-including-other-makefiles">including other makefiles</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-incompatibilities">incompatibilities</a>:</td><td> </td><td valign="top"><a href="#Missing">Missing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-independent-targets">independent targets</a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Info_002c-rule-to-format">Info, rule to format</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-inheritance_002c-suppressing">inheritance, suppressing</a>:</td><td> </td><td valign="top"><a href="#Suppressing-Inheritance">Suppressing Inheritance</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-input-during-parallel-execution">input during parallel execution</a>:</td><td> </td><td valign="top"><a href="#Parallel-Input">Parallel Input</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-install-_0028standard-target_0029"><code>install</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-installation-directories_002c-creating">installation directories, creating</a>:</td><td> </td><td valign="top"><a href="#Directory-Variables">Directory Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-installations_002c-staged">installations, staged</a>:</td><td> </td><td valign="top"><a href="#DESTDIR">DESTDIR</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-interface-for-loaded-objects">interface for loaded objects</a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-intermediate-files">intermediate files</a>:</td><td> </td><td valign="top"><a href="#Chained-Rules">Chained Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-intermediate-files_002c-preserving">intermediate files, preserving</a>:</td><td> </td><td valign="top"><a href="#Chained-Rules">Chained Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-intermediate-targets_002c-explicit">intermediate targets, explicit</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-interrupt">interrupt</a>:</td><td> </td><td valign="top"><a href="#Interrupts">Interrupts</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-J">J</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-job-slots">job slots</a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-job-slots_002c-and-recursion">job slots, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-job-slots_002c-sharing">job slots, sharing</a>:</td><td> </td><td valign="top"><a href="#Job-Slots">Job Slots</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-jobs_002c-limiting-based-on-load">jobs, limiting based on load</a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-jobserver">jobserver</a>:</td><td> </td><td valign="top"><a href="#Job-Slots">Job Slots</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-jobserver-on-POSIX">jobserver on POSIX</a>:</td><td> </td><td valign="top"><a href="#POSIX-Jobserver">POSIX Jobserver</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-jobserver-on-Windows">jobserver on Windows</a>:</td><td> </td><td valign="top"><a href="#Windows-Jobserver">Windows Jobserver</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-joining-lists-of-words">joining lists of words</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-K">K</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-killing-_0028interruption_0029">killing (interruption)</a>:</td><td> </td><td valign="top"><a href="#Interrupts">Interrupts</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-L">L</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-last_002dresort-default-rules">last-resort default rules</a>:</td><td> </td><td valign="top"><a href="#Last-Resort">Last Resort</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ld"><code>ld</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-lex"><code>lex</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-lex-1"><code>lex</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Lex_002c-rule-to-run">Lex, rule to run</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-libraries-for-linking_002c-directory-search">libraries for linking, directory search</a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-library-archive_002c-suffix-rule-for">library archive, suffix rule for</a>:</td><td> </td><td valign="top"><a href="#Archive-Suffix-Rules">Archive Suffix Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-limiting-jobs-based-on-load">limiting jobs based on load</a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-link-libraries_002c-and-directory-search">link libraries, and directory search</a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-link-libraries_002c-patterns-matching">link libraries, patterns matching</a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-linking_002c-predefined-rule-for">linking, predefined rule for</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-lint"><code>lint</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-lint-1"><code>lint</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-lint_002c-rule-to-run"><code>lint</code>, rule to run</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-list-of-all-prerequisites">list of all prerequisites</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-list-of-changed-prerequisites">list of changed prerequisites</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-load-average">load average</a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-load-directive">load directive</a>:</td><td> </td><td valign="top"><a href="#load-Directive">load Directive</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-loaded-object-API">loaded object API</a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-loaded-object-example">loaded object example</a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-Example">Loaded Object Example</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-loaded-object-licensing">loaded object licensing</a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-loaded-objects">loaded objects</a>:</td><td> </td><td valign="top"><a href="#Loading-Objects">Loading Objects</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-loaded-objects_002c-remaking-of">loaded objects, remaking of</a>:</td><td> </td><td valign="top"><a href="#Remaking-Loaded-Objects">Remaking Loaded Objects</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-long-lines_002c-splitting">long lines, splitting</a>:</td><td> </td><td valign="top"><a href="#Splitting-Lines">Splitting Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-loops-in-variable-expansion">loops in variable expansion</a>:</td><td> </td><td valign="top"><a href="#Recursive-Assignment">Recursive Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-lpr-_0028shell-command_0029"><code>lpr</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Examples">Wildcard Examples</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-lpr-_0028shell-command_0029-1"><code>lpr</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Empty-Targets">Empty Targets</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-M">M</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-m2c"><code>m2c</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-m2c-1"><code>m2c</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-macro">macro</a>:</td><td> </td><td valign="top"><a href="#Using-Variables">Using Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-make-depend"><code>make depend</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-make-extensions">make extensions</a>:</td><td> </td><td valign="top"><a href="#Extending-make">Extending make</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-make-integration">make integration</a>:</td><td> </td><td valign="top"><a href="#Integrating-make">Integrating make</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-make-interface-to-guile">make interface to guile</a>:</td><td> </td><td valign="top"><a href="#Guile-Interface">Guile Interface</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-make-procedures-in-guile">make procedures in guile</a>:</td><td> </td><td valign="top"><a href="#Guile-Interface">Guile Interface</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile">makefile</a>:</td><td> </td><td valign="top"><a href="#Introduction">Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile-name">makefile name</a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile-name_002c-how-to-specify">makefile name, how to specify</a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile-rule-parts">makefile rule parts</a>:</td><td> </td><td valign="top"><a href="#Rule-Introduction">Rule Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile-syntax_002c-evaluating">makefile syntax, evaluating</a>:</td><td> </td><td valign="top"><a href="#Eval-Function">Eval Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-and-MAKEFILES-variable">makefile, and <code>MAKEFILES</code> variable</a>:</td><td> </td><td valign="top"><a href="#MAKEFILES-Variable">MAKEFILES Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-conventions-for">makefile, conventions for</a>:</td><td> </td><td valign="top"><a href="#Makefile-Conventions">Makefile Conventions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-how-make-processes">makefile, how <code>make</code> processes</a>:</td><td> </td><td valign="top"><a href="#How-Make-Works">How Make Works</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-how-to-write">makefile, how to write</a>:</td><td> </td><td valign="top"><a href="#Makefiles">Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-including">makefile, including</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-overriding">makefile, overriding</a>:</td><td> </td><td valign="top"><a href="#Overriding-Makefiles">Overriding Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-reading">makefile, reading</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-remaking-of">makefile, remaking of</a>:</td><td> </td><td valign="top"><a href="#Remaking-Makefiles">Remaking Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile_002c-simple">makefile, simple</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefiles_002c-and-MAKEFILE_005fLIST-variable">makefiles, and <code>MAKEFILE_LIST</code> variable</a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefiles_002c-and-special-variables">makefiles, and special variables</a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefiles_002c-parsing">makefiles, parsing</a>:</td><td> </td><td valign="top"><a href="#Parsing-Makefiles">Parsing Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makeinfo"><code>makeinfo</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makeinfo-1"><code>makeinfo</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKE_005fTMPDIR"><code>MAKE_TMPDIR</code></a>:</td><td> </td><td valign="top"><a href="#Temporary-Files">Temporary Files</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-match_002danything-rule">match-anything rule</a>:</td><td> </td><td valign="top"><a href="#Match_002dAnything-Rules">Match-Anything Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-match_002danything-rule_002c-used-to-override">match-anything rule, used to override</a>:</td><td> </td><td valign="top"><a href="#Overriding-Makefiles">Overriding Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-missing-features">missing features</a>:</td><td> </td><td valign="top"><a href="#Missing">Missing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-mistakes-with-wildcards">mistakes with wildcards</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Pitfall">Wildcard Pitfall</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-modified-variable-reference">modified variable reference</a>:</td><td> </td><td valign="top"><a href="#Substitution-Refs">Substitution Refs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Modula_002d2_002c-rule-to-compile">Modula-2, rule to compile</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-mostlyclean-_0028standard-target_0029"><code>mostlyclean</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-multi_002dline-variable-definition">multi-line variable definition</a>:</td><td> </td><td valign="top"><a href="#Multi_002dLine">Multi-Line</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-multiple-rules-for-one-target">multiple rules for one target</a>:</td><td> </td><td valign="top"><a href="#Multiple-Rules">Multiple Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-multiple-rules-for-one-target-_0028_003a_003a_0029">multiple rules for one target (<code>::</code>)</a>:</td><td> </td><td valign="top"><a href="#Double_002dColon">Double-Colon</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-multiple-targets">multiple targets</a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-multiple-targets_002c-in-pattern-rule">multiple targets, in pattern rule</a>:</td><td> </td><td valign="top"><a href="#Pattern-Intro">Pattern Intro</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-N">N</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-name-of-makefile">name of makefile</a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-name-of-makefile_002c-how-to-specify">name of makefile, how to specify</a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-nested-variable-reference">nested variable reference</a>:</td><td> </td><td valign="top"><a href="#Computed-Names">Computed Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-newline_002c-quoting_002c-in-makefile">newline, quoting, in makefile</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-newline_002c-quoting_002c-in-recipes">newline, quoting, in recipes</a>:</td><td> </td><td valign="top"><a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-nondirectory-part">nondirectory part</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-normal-prerequisites">normal prerequisites</a>:</td><td> </td><td valign="top"><a href="#Prerequisite-Types">Prerequisite Types</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-not-intermediate-targets_002c-explicit">not intermediate targets, explicit</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-O">O</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-obj"><code>obj</code></a>:</td><td> </td><td valign="top"><a href="#Variables-Simplify">Variables Simplify</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-OBJ"><code>OBJ</code></a>:</td><td> </td><td valign="top"><a href="#Variables-Simplify">Variables Simplify</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-objects"><code>objects</code></a>:</td><td> </td><td valign="top"><a href="#Variables-Simplify">Variables Simplify</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-OBJECTS"><code>OBJECTS</code></a>:</td><td> </td><td valign="top"><a href="#Variables-Simplify">Variables Simplify</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-objects_002c-loaded">objects, loaded</a>:</td><td> </td><td valign="top"><a href="#Loading-Objects">Loading Objects</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-objs"><code>objs</code></a>:</td><td> </td><td valign="top"><a href="#Variables-Simplify">Variables Simplify</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-OBJS"><code>OBJS</code></a>:</td><td> </td><td valign="top"><a href="#Variables-Simplify">Variables Simplify</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-old_002dfashioned-suffix-rules">old-fashioned suffix rules</a>:</td><td> </td><td valign="top"><a href="#Suffix-Rules">Suffix Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-options">options</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-options_002c-and-recursion">options, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-options_002c-setting-from-environment">options, setting from environment</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-options_002c-setting-in-makefiles">options, setting in makefiles</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-order-of-pattern-rules">order of pattern rules</a>:</td><td> </td><td valign="top"><a href="#Pattern-Match">Pattern Match</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-order_002donly-prerequisites">order-only prerequisites</a>:</td><td> </td><td valign="top"><a href="#Prerequisite-Types">Prerequisite Types</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-origin-of-variable">origin of variable</a>:</td><td> </td><td valign="top"><a href="#Origin-Function">Origin Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-output-during-parallel-execution">output during parallel execution</a>:</td><td> </td><td valign="top"><a href="#Parallel-Output">Parallel Output</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-output-during-parallel-execution-1">output during parallel execution</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-overriding-makefiles">overriding makefiles</a>:</td><td> </td><td valign="top"><a href="#Overriding-Makefiles">Overriding Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-overriding-variables-with-arguments">overriding variables with arguments</a>:</td><td> </td><td valign="top"><a href="#Overriding">Overriding</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-overriding-with-override">overriding with <code>override</code></a>:</td><td> </td><td valign="top"><a href="#Override-Directive">Override Directive</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-P">P</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parallel-execution">parallel execution</a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parallel-execution_002c-and-archive-update">parallel execution, and archive update</a>:</td><td> </td><td valign="top"><a href="#Archive-Pitfalls">Archive Pitfalls</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parallel-execution_002c-disabling">parallel execution, disabling</a>:</td><td> </td><td valign="top"><a href="#Parallel-Disable">Parallel Disable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parallel-execution_002c-input-during">parallel execution, input during</a>:</td><td> </td><td valign="top"><a href="#Parallel-Input">Parallel Input</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parallel-execution_002c-output-during">parallel execution, output during</a>:</td><td> </td><td valign="top"><a href="#Parallel-Output">Parallel Output</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parallel-execution_002c-output-during-1">parallel execution, output during</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parallel-execution_002c-overriding">parallel execution, overriding</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parallel-output-to-terminal">parallel output to terminal</a>:</td><td> </td><td valign="top"><a href="#Terminal-Output">Terminal Output</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parsing-makefiles">parsing makefiles</a>:</td><td> </td><td valign="top"><a href="#Parsing-Makefiles">Parsing Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-parts-of-makefile-rule">parts of makefile rule</a>:</td><td> </td><td valign="top"><a href="#Rule-Introduction">Rule Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Pascal_002c-rule-to-compile">Pascal, rule to compile</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pattern-rule">pattern rule</a>:</td><td> </td><td valign="top"><a href="#Pattern-Intro">Pattern Intro</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pattern-rule_002c-expansion">pattern rule, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pattern-rules_002c-order-of">pattern rules, order of</a>:</td><td> </td><td valign="top"><a href="#Pattern-Match">Pattern Match</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pattern-rules_002c-static-_0028not-implicit_0029">pattern rules, static (not implicit)</a>:</td><td> </td><td valign="top"><a href="#Static-Pattern">Static Pattern</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pattern-rules_002c-static_002c-syntax-of">pattern rules, static, syntax of</a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pattern_002dspecific-variables">pattern-specific variables</a>:</td><td> </td><td valign="top"><a href="#Pattern_002dspecific">Pattern-specific</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pc"><code>pc</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pc-1"><code>pc</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-phony-targets">phony targets</a>:</td><td> </td><td valign="top"><a href="#Phony-Targets">Phony Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-phony-targets-and-recipe-execution">phony targets and recipe execution</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pitfalls-of-wildcards">pitfalls of wildcards</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Pitfall">Wildcard Pitfall</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-plugin_005fis_005fGPL_005fcompatible">plugin_is_GPL_compatible</a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-portability">portability</a>:</td><td> </td><td valign="top"><a href="#Features">Features</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-POSIX">POSIX</a>:</td><td> </td><td valign="top"><a href="#Overview">Overview</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-POSIX-1">POSIX</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-POSIX_002dconforming-mode_002c-setting">POSIX-conforming mode, setting</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-post_002dinstallation-commands">post-installation commands</a>:</td><td> </td><td valign="top"><a href="#Install-Command-Categories">Install Command Categories</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-pre_002dinstallation-commands">pre-installation commands</a>:</td><td> </td><td valign="top"><a href="#Install-Command-Categories">Install Command Categories</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-precious-targets">precious targets</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-predefined-rules-and-variables_002c-printing">predefined rules and variables, printing</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prefix_002c-adding">prefix, adding</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisite">prerequisite</a>:</td><td> </td><td valign="top"><a href="#Rules">Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisite-pattern_002c-implicit">prerequisite pattern, implicit</a>:</td><td> </td><td valign="top"><a href="#Pattern-Intro">Pattern Intro</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisite-pattern_002c-static-_0028not-implicit_0029">prerequisite pattern, static (not implicit)</a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisite-types">prerequisite types</a>:</td><td> </td><td valign="top"><a href="#Prerequisite-Types">Prerequisite Types</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisite_002c-expansion">prerequisite, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites">prerequisites</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-and-automatic-variables">prerequisites, and automatic variables</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-automatic-generation">prerequisites, automatic generation</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-automatic-generation-1">prerequisites, automatic generation</a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-introduction-to">prerequisites, introduction to</a>:</td><td> </td><td valign="top"><a href="#Rule-Introduction">Rule Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-list-of-all">prerequisites, list of all</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-list-of-changed">prerequisites, list of changed</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-normal">prerequisites, normal</a>:</td><td> </td><td valign="top"><a href="#Prerequisite-Types">Prerequisite Types</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-order_002donly">prerequisites, order-only</a>:</td><td> </td><td valign="top"><a href="#Prerequisite-Types">Prerequisite Types</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prerequisites_002c-varying-_0028static-pattern_0029">prerequisites, varying (static pattern)</a>:</td><td> </td><td valign="top"><a href="#Static-Pattern">Static Pattern</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-preserving-intermediate-files">preserving intermediate files</a>:</td><td> </td><td valign="top"><a href="#Chained-Rules">Chained Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-preserving-with-_002ePRECIOUS">preserving with <code>.PRECIOUS</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-preserving-with-_002eSECONDARY">preserving with <code>.SECONDARY</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-print-_0028standard-target_0029"><code>print</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-print-target"><code>print</code> target</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Examples">Wildcard Examples</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-print-target-1"><code>print</code> target</a>:</td><td> </td><td valign="top"><a href="#Empty-Targets">Empty Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-printing-directories">printing directories</a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-printing-messages">printing messages</a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-printing-of-recipes">printing of recipes</a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-printing-user-warnings">printing user warnings</a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-problems-and-bugs_002c-reporting">problems and bugs, reporting</a>:</td><td> </td><td valign="top"><a href="#Bugs">Bugs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-problems-with-wildcards">problems with wildcards</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Pitfall">Wildcard Pitfall</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-processing-a-makefile">processing a makefile</a>:</td><td> </td><td valign="top"><a href="#How-Make-Works">How Make Works</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-Q">Q</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-question-mode">question mode</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-quoting-_0025_002c-in-patsubst">quoting <code>%</code>, in <code>patsubst</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-quoting-_0025_002c-in-static-pattern">quoting <code>%</code>, in static pattern</a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-quoting-_0025_002c-in-vpath">quoting <code>%</code>, in <code>vpath</code></a>:</td><td> </td><td valign="top"><a href="#Selective-Search">Selective Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-quoting-newline_002c-in-makefile">quoting newline, in makefile</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-quoting-newline_002c-in-recipes">quoting newline, in recipes</a>:</td><td> </td><td valign="top"><a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-R">R</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Ratfor_002c-rule-to-compile">Ratfor, rule to compile</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-RCS_002c-rule-to-extract-from">RCS, rule to extract from</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-reading-from-a-file">reading from a file</a>:</td><td> </td><td valign="top"><a href="#File-Function">File Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-reading-makefiles">reading makefiles</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-README"><code>README</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-realclean-_0028standard-target_0029"><code>realclean</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-realpath">realpath</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipe">recipe</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipe-execution_002c-single-invocation">recipe execution, single invocation</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipe-lines_002c-single-shell">recipe lines, single shell</a>:</td><td> </td><td valign="top"><a href="#One-Shell">One Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipe-syntax">recipe syntax</a>:</td><td> </td><td valign="top"><a href="#Recipe-Syntax">Recipe Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipe_002c-execution">recipe, execution</a>:</td><td> </td><td valign="top"><a href="#Execution">Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes">recipes</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes-1">recipes</a>:</td><td> </td><td valign="top"><a href="#Recipes">Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes-setting-shell-variables">recipes setting shell variables</a>:</td><td> </td><td valign="top"><a href="#Execution">Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-and-directory-search">recipes, and directory search</a>:</td><td> </td><td valign="top"><a href="#Recipes_002fSearch">Recipes/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-backslash-_0028_005c_0029-in">recipes, backslash (<code>\</code>) in</a>:</td><td> </td><td valign="top"><a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-canned">recipes, canned</a>:</td><td> </td><td valign="top"><a href="#Canned-Recipes">Canned Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-comments-in">recipes, comments in</a>:</td><td> </td><td valign="top"><a href="#Recipe-Syntax">Recipe Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-echoing">recipes, echoing</a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-empty">recipes, empty</a>:</td><td> </td><td valign="top"><a href="#Empty-Recipes">Empty Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-errors-in">recipes, errors in</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-execution-in-parallel">recipes, execution in parallel</a>:</td><td> </td><td valign="top"><a href="#Parallel">Parallel</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-how-to-write">recipes, how to write</a>:</td><td> </td><td valign="top"><a href="#Recipes">Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-instead-of-executing">recipes, instead of executing</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-introduction-to">recipes, introduction to</a>:</td><td> </td><td valign="top"><a href="#Rule-Introduction">Rule Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-quoting-newlines-in">recipes, quoting newlines in</a>:</td><td> </td><td valign="top"><a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-splitting">recipes, splitting</a>:</td><td> </td><td valign="top"><a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recipes_002c-using-variables-in">recipes, using variables in</a>:</td><td> </td><td valign="top"><a href="#Variables-in-Recipes">Variables in Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recompilation">recompilation</a>:</td><td> </td><td valign="top"><a href="#Introduction">Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recompilation_002c-avoiding">recompilation, avoiding</a>:</td><td> </td><td valign="top"><a href="#Avoiding-Compilation">Avoiding Compilation</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recording-events-with-empty-targets">recording events with empty targets</a>:</td><td> </td><td valign="top"><a href="#Empty-Targets">Empty Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion">recursion</a>:</td><td> </td><td valign="top"><a href="#Recursion">Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-_002dC">recursion, and <code>-C</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-_002df">recursion, and <code>-f</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-_002dj">recursion, and <code>-j</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-_002do">recursion, and <code>-o</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-_002dt">recursion, and <code>-t</code></a>:</td><td> </td><td valign="top"><a href="#MAKE-Variable">MAKE Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-_002dW">recursion, and <code>-W</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-_002dw">recursion, and <code>-w</code></a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-command-line-variable-definitions">recursion, and command line variable definitions</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-environment">recursion, and environment</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-MAKE-variable">recursion, and <code>MAKE</code> variable</a>:</td><td> </td><td valign="top"><a href="#MAKE-Variable">MAKE Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-MAKEFILES-variable">recursion, and <code>MAKEFILES</code> variable</a>:</td><td> </td><td valign="top"><a href="#MAKEFILES-Variable">MAKEFILES Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-options">recursion, and options</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-printing-directories">recursion, and printing directories</a>:</td><td> </td><td valign="top"><a href="#g_t_002dw-Option">-w Option</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-and-variables">recursion, and variables</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursion_002c-level-of">recursion, level of</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursive-variable-expansion">recursive variable expansion</a>:</td><td> </td><td valign="top"><a href="#Using-Variables">Using Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursive-variable-expansion-1">recursive variable expansion</a>:</td><td> </td><td valign="top"><a href="#Flavors">Flavors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-recursively-expanded-variables">recursively expanded variables</a>:</td><td> </td><td valign="top"><a href="#Flavors">Flavors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-reference-to-variables">reference to variables</a>:</td><td> </td><td valign="top"><a href="#Reference">Reference</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-reference-to-variables-1">reference to variables</a>:</td><td> </td><td valign="top"><a href="#Advanced">Advanced</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-relinking">relinking</a>:</td><td> </td><td valign="top"><a href="#How-Make-Works">How Make Works</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-remaking-loaded-objects">remaking loaded objects</a>:</td><td> </td><td valign="top"><a href="#Remaking-Loaded-Objects">Remaking Loaded Objects</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-remaking-makefiles">remaking makefiles</a>:</td><td> </td><td valign="top"><a href="#Remaking-Makefiles">Remaking Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-removal-of-target-files">removal of target files</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-removal-of-target-files-1">removal of target files</a>:</td><td> </td><td valign="top"><a href="#Interrupts">Interrupts</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-removing-duplicate-words">removing duplicate words</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-removing-targets-on-failure">removing targets on failure</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-removing-whitespace-from-split-lines">removing whitespace from split lines</a>:</td><td> </td><td valign="top"><a href="#Splitting-Lines">Splitting Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-removing_002c-to-clean-up">removing, to clean up</a>:</td><td> </td><td valign="top"><a href="#Cleanup">Cleanup</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-reporting-bugs">reporting bugs</a>:</td><td> </td><td valign="top"><a href="#Bugs">Bugs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rm"><code>rm</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rm-_0028shell-command_0029"><code>rm</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rm-_0028shell-command_0029-1"><code>rm</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Examples">Wildcard Examples</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rm-_0028shell-command_0029-2"><code>rm</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Phony-Targets">Phony Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rm-_0028shell-command_0029-3"><code>rm</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule-prerequisites">rule prerequisites</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule-syntax">rule syntax</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule-targets">rule targets</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-double_002dcolon-_0028_003a_003a_0029">rule, double-colon (<code>::</code>)</a>:</td><td> </td><td valign="top"><a href="#Double_002dColon">Double-Colon</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-explicit_002c-definition-of">rule, explicit, definition of</a>:</td><td> </td><td valign="top"><a href="#Makefile-Contents">Makefile Contents</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-how-to-write">rule, how to write</a>:</td><td> </td><td valign="top"><a href="#Rules">Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-implicit">rule, implicit</a>:</td><td> </td><td valign="top"><a href="#Implicit-Rules">Implicit Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-implicit_002c-and-directory-search">rule, implicit, and directory search</a>:</td><td> </td><td valign="top"><a href="#Implicit_002fSearch">Implicit/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-implicit_002c-and-VPATH">rule, implicit, and <code>VPATH</code></a>:</td><td> </td><td valign="top"><a href="#Implicit_002fSearch">Implicit/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-implicit_002c-chains-of">rule, implicit, chains of</a>:</td><td> </td><td valign="top"><a href="#Chained-Rules">Chained Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-implicit_002c-definition-of">rule, implicit, definition of</a>:</td><td> </td><td valign="top"><a href="#Makefile-Contents">Makefile Contents</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-implicit_002c-how-to-use">rule, implicit, how to use</a>:</td><td> </td><td valign="top"><a href="#Using-Implicit">Using Implicit</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-implicit_002c-introduction-to">rule, implicit, introduction to</a>:</td><td> </td><td valign="top"><a href="#make-Deduces">make Deduces</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-implicit_002c-predefined">rule, implicit, predefined</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-introduction-to">rule, introduction to</a>:</td><td> </td><td valign="top"><a href="#Rule-Introduction">Rule Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-multiple-for-one-target">rule, multiple for one target</a>:</td><td> </td><td valign="top"><a href="#Multiple-Rules">Multiple Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-no-recipe-or-prerequisites">rule, no recipe or prerequisites</a>:</td><td> </td><td valign="top"><a href="#Force-Targets">Force Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-pattern">rule, pattern</a>:</td><td> </td><td valign="top"><a href="#Pattern-Intro">Pattern Intro</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-static-pattern">rule, static pattern</a>:</td><td> </td><td valign="top"><a href="#Static-Pattern">Static Pattern</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-static-pattern-versus-implicit">rule, static pattern versus implicit</a>:</td><td> </td><td valign="top"><a href="#Static-versus-Implicit">Static versus Implicit</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rule_002c-with-multiple-targets">rule, with multiple targets</a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-rules_002c-and-_0024">rules, and <code>$</code></a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-S">S</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-s_002e-_0028SCCS-file-prefix_0029"><code>s. <span class="roman">(SCCS file prefix)</span></code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SCCS_002c-rule-to-extract-from">SCCS, rule to extract from</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-search-algorithm_002c-implicit-rule">search algorithm, implicit rule</a>:</td><td> </td><td valign="top"><a href="#Implicit-Rule-Search">Implicit Rule Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-search-path-for-prerequisites-_0028VPATH_0029">search path for prerequisites (<code>VPATH</code>)</a>:</td><td> </td><td valign="top"><a href="#Directory-Search">Directory Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-search-path-for-prerequisites-_0028VPATH_0029_002c-and-implicit-rules">search path for prerequisites (<code>VPATH</code>), and implicit rules</a>:</td><td> </td><td valign="top"><a href="#Implicit_002fSearch">Implicit/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-search-path-for-prerequisites-_0028VPATH_0029_002c-and-link-libraries">search path for prerequisites (<code>VPATH</code>), and link libraries</a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-searching-for-strings">searching for strings</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-secondary-expansion">secondary expansion</a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-secondary-expansion-and-explicit-rules">secondary expansion and explicit rules</a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-secondary-expansion-and-implicit-rules">secondary expansion and implicit rules</a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-secondary-expansion-and-static-pattern-rules">secondary expansion and static pattern rules</a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-secondary-files">secondary files</a>:</td><td> </td><td valign="top"><a href="#Chained-Rules">Chained Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-secondary-targets">secondary targets</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-sed-_0028shell-command_0029"><code>sed</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Automatic-Prerequisites">Automatic Prerequisites</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-selecting-a-word">selecting a word</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-selecting-word-lists">selecting word lists</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-sequences-of-commands">sequences of commands</a>:</td><td> </td><td valign="top"><a href="#Canned-Recipes">Canned Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-setting-options-from-environment">setting options from environment</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-setting-options-in-makefiles">setting options in makefiles</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-setting-variables">setting variables</a>:</td><td> </td><td valign="top"><a href="#Setting">Setting</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-several-rules-for-one-target">several rules for one target</a>:</td><td> </td><td valign="top"><a href="#Multiple-Rules">Multiple Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-several-targets-in-a-rule">several targets in a rule</a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-shar-_0028standard-target_0029"><code>shar</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-shell-command_002c-function-for">shell command, function for</a>:</td><td> </td><td valign="top"><a href="#Shell-Function">Shell Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-shell-file-name-pattern-_0028in-include_0029">shell file name pattern (in <code>include</code>)</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-shell-variables_002c-setting-in-recipes">shell variables, setting in recipes</a>:</td><td> </td><td valign="top"><a href="#Execution">Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-shell-wildcards-_0028in-include_0029">shell wildcards (in <code>include</code>)</a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-shell_002c-choosing-the">shell, choosing the</a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SHELL_002c-exported-value">SHELL, exported value</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SHELL_002c-import-from-environment">SHELL, import from environment</a>:</td><td> </td><td valign="top"><a href="#Environment">Environment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-shell_002c-in-DOS-and-Windows">shell, in DOS and Windows</a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SHELL_002c-MS_002dDOS-specifics"><code>SHELL</code>, MS-DOS specifics</a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SHELL_002c-value-of"><code>SHELL</code>, value of</a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-signal">signal</a>:</td><td> </td><td valign="top"><a href="#Interrupts">Interrupts</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-silent-operation">silent operation</a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-simple-makefile">simple makefile</a>:</td><td> </td><td valign="top"><a href="#Simple-Makefile">Simple Makefile</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-simple-variable-expansion">simple variable expansion</a>:</td><td> </td><td valign="top"><a href="#Using-Variables">Using Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-simplifying-with-variables">simplifying with variables</a>:</td><td> </td><td valign="top"><a href="#Variables-Simplify">Variables Simplify</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-simply-expanded-variables">simply expanded variables</a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-sorting-words">sorting words</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-spaces_002c-in-variable-values">spaces, in variable values</a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-spaces_002c-stripping">spaces, stripping</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-special-characters-in-function-arguments">special characters in function arguments</a>:</td><td> </td><td valign="top"><a href="#Syntax-of-Functions">Syntax of Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-special-targets">special targets</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-special-variables">special variables</a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-specifying-makefile-name">specifying makefile name</a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-splitting-long-lines">splitting long lines</a>:</td><td> </td><td valign="top"><a href="#Splitting-Lines">Splitting Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-splitting-recipes">splitting recipes</a>:</td><td> </td><td valign="top"><a href="#Splitting-Recipe-Lines">Splitting Recipe Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-staged-installs">staged installs</a>:</td><td> </td><td valign="top"><a href="#DESTDIR">DESTDIR</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-standard-input">standard input</a>:</td><td> </td><td valign="top"><a href="#Parallel-Input">Parallel Input</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-standards-conformance">standards conformance</a>:</td><td> </td><td valign="top"><a href="#Overview">Overview</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-standards-for-makefiles">standards for makefiles</a>:</td><td> </td><td valign="top"><a href="#Makefile-Conventions">Makefile Conventions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-static-pattern-rule">static pattern rule</a>:</td><td> </td><td valign="top"><a href="#Static-Pattern">Static Pattern</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-static-pattern-rule_002c-syntax-of">static pattern rule, syntax of</a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-static-pattern-rule_002c-versus-implicit">static pattern rule, versus implicit</a>:</td><td> </td><td valign="top"><a href="#Static-versus-Implicit">Static versus Implicit</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-static-pattern-rules_002c-secondary-expansion-of">static pattern rules, secondary expansion of</a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-stem">stem</a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-stem-1">stem</a>:</td><td> </td><td valign="top"><a href="#Pattern-Match">Pattern Match</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-stem_002c-shortest">stem, shortest</a>:</td><td> </td><td valign="top"><a href="#Pattern-Match">Pattern Match</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-stem_002c-variable-for">stem, variable for</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-stopping-make">stopping make</a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-strings_002c-searching-for">strings, searching for</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-stripping-whitespace">stripping whitespace</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-sub_002dmake">sub-<code>make</code></a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-subdirectories_002c-recursion-for">subdirectories, recursion for</a>:</td><td> </td><td valign="top"><a href="#Recursion">Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-substitution-variable-reference">substitution variable reference</a>:</td><td> </td><td valign="top"><a href="#Substitution-Refs">Substitution Refs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-suffix-rule">suffix rule</a>:</td><td> </td><td valign="top"><a href="#Suffix-Rules">Suffix Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-suffix-rule_002c-for-archive">suffix rule, for archive</a>:</td><td> </td><td valign="top"><a href="#Archive-Suffix-Rules">Archive Suffix Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-suffix_002c-adding">suffix, adding</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-suffix_002c-function-to-find">suffix, function to find</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-suffix_002c-substituting-in-variables">suffix, substituting in variables</a>:</td><td> </td><td valign="top"><a href="#Substitution-Refs">Substitution Refs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-suppressing-inheritance">suppressing inheritance</a>:</td><td> </td><td valign="top"><a href="#Suppressing-Inheritance">Suppressing Inheritance</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-switches">switches</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-symbol-directories_002c-updating-archive">symbol directories, updating archive</a>:</td><td> </td><td valign="top"><a href="#Archive-Symbols">Archive Symbols</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-syntax-of-recipe">syntax of recipe</a>:</td><td> </td><td valign="top"><a href="#Recipe-Syntax">Recipe Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-syntax-of-rules">syntax of rules</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-T">T</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tab-character-_0028in-commands_0029">tab character (in commands)</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tabs-in-rules">tabs in rules</a>:</td><td> </td><td valign="top"><a href="#Rule-Introduction">Rule Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-TAGS-_0028standard-target_0029"><code>TAGS</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tangle"><code>tangle</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tangle-1"><code>tangle</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tar-_0028standard-target_0029"><code>tar</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target">target</a>:</td><td> </td><td valign="top"><a href="#Rules">Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target-pattern_002c-implicit">target pattern, implicit</a>:</td><td> </td><td valign="top"><a href="#Pattern-Intro">Pattern Intro</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target-pattern_002c-static-_0028not-implicit_0029">target pattern, static (not implicit)</a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target_002c-deleting-on-error">target, deleting on error</a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target_002c-deleting-on-interrupt">target, deleting on interrupt</a>:</td><td> </td><td valign="top"><a href="#Interrupts">Interrupts</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target_002c-expansion">target, expansion</a>:</td><td> </td><td valign="top"><a href="#Reading-Makefiles">Reading Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target_002c-multiple-in-pattern-rule">target, multiple in pattern rule</a>:</td><td> </td><td valign="top"><a href="#Pattern-Intro">Pattern Intro</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target_002c-multiple-rules-for-one">target, multiple rules for one</a>:</td><td> </td><td valign="top"><a href="#Multiple-Rules">Multiple Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target_002c-touching">target, touching</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-target_002dspecific-variables">target-specific variables</a>:</td><td> </td><td valign="top"><a href="#Target_002dspecific">Target-specific</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets">targets</a>:</td><td> </td><td valign="top"><a href="#Rule-Syntax">Rule Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets-without-a-file">targets without a file</a>:</td><td> </td><td valign="top"><a href="#Phony-Targets">Phony Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets_002c-built_002din-special">targets, built-in special</a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets_002c-empty">targets, empty</a>:</td><td> </td><td valign="top"><a href="#Empty-Targets">Empty Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets_002c-force">targets, force</a>:</td><td> </td><td valign="top"><a href="#Force-Targets">Force Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets_002c-grouped">targets, grouped</a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets_002c-independent">targets, independent</a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets_002c-introduction-to">targets, introduction to</a>:</td><td> </td><td valign="top"><a href="#Rule-Introduction">Rule Introduction</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets_002c-multiple">targets, multiple</a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-targets_002c-phony">targets, phony</a>:</td><td> </td><td valign="top"><a href="#Phony-Targets">Phony Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-TEMP"><code>TEMP</code></a>:</td><td> </td><td valign="top"><a href="#Temporary-Files">Temporary Files</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-temporary-files">temporary files</a>:</td><td> </td><td valign="top"><a href="#Temporary-Files">Temporary Files</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-terminal-rule">terminal rule</a>:</td><td> </td><td valign="top"><a href="#Match_002dAnything-Rules">Match-Anything Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-terminal_002c-output-to">terminal, output to</a>:</td><td> </td><td valign="top"><a href="#Terminal-Output">Terminal Output</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-test-_0028standard-target_0029"><code>test</code> <span class="roman">(standard target)</span></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-testing-compilation">testing compilation</a>:</td><td> </td><td valign="top"><a href="#Testing">Testing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tex"><code>tex</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tex-1"><code>tex</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-TeX_002c-rule-to-run">TeX, rule to run</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-texi2dvi"><code>texi2dvi</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-texi2dvi-1"><code>texi2dvi</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Texinfo_002c-rule-to-format">Texinfo, rule to format</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tilde-_0028_007e_0029">tilde (<code>~</code>)</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-TMP"><code>TMP</code></a>:</td><td> </td><td valign="top"><a href="#Temporary-Files">Temporary Files</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-TMPDIR"><code>TMPDIR</code></a>:</td><td> </td><td valign="top"><a href="#Temporary-Files">Temporary Files</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-tools_002c-sharing-job-slots">tools, sharing job slots</a>:</td><td> </td><td valign="top"><a href="#Job-Slots">Job Slots</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-touch-_0028shell-command_0029"><code>touch</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Examples">Wildcard Examples</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-touch-_0028shell-command_0029-1"><code>touch</code> (shell command)</a>:</td><td> </td><td valign="top"><a href="#Empty-Targets">Empty Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-touching-files">touching files</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-traditional-directory-search-_0028GPATH_0029">traditional directory search (GPATH)</a>:</td><td> </td><td valign="top"><a href="#Search-Algorithm">Search Algorithm</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-types-of-prerequisites">types of prerequisites</a>:</td><td> </td><td valign="top"><a href="#Prerequisite-Types">Prerequisite Types</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-types_002c-conversion-of">types, conversion of</a>:</td><td> </td><td valign="top"><a href="#Guile-Types">Guile Types</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-U">U</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-undefined-variables_002c-warning-message">undefined variables, warning message</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-undefining-variable">undefining variable</a>:</td><td> </td><td valign="top"><a href="#Undefine-Directive">Undefine Directive</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-updating-archive-symbol-directories">updating archive symbol directories</a>:</td><td> </td><td valign="top"><a href="#Archive-Symbols">Archive Symbols</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-updating-loaded-objects">updating loaded objects</a>:</td><td> </td><td valign="top"><a href="#Remaking-Loaded-Objects">Remaking Loaded Objects</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-updating-makefiles">updating makefiles</a>:</td><td> </td><td valign="top"><a href="#Remaking-Makefiles">Remaking Makefiles</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-user-defined-functions">user defined functions</a>:</td><td> </td><td valign="top"><a href="#Call-Function">Call Function</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-V">V</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-value">value</a>:</td><td> </td><td valign="top"><a href="#Using-Variables">Using Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-value_002c-how-a-variable-gets-it">value, how a variable gets it</a>:</td><td> </td><td valign="top"><a href="#Values">Values</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variable">variable</a>:</td><td> </td><td valign="top"><a href="#Using-Variables">Using Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variable-definition">variable definition</a>:</td><td> </td><td valign="top"><a href="#Makefile-Contents">Makefile Contents</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variable-references-in-recipes">variable references in recipes</a>:</td><td> </td><td valign="top"><a href="#Variables-in-Recipes">Variables in Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables">variables</a>:</td><td> </td><td valign="top"><a href="#Variables-Simplify">Variables Simplify</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-_0024-in-name">variables, ‘<samp>$</samp>’ in name</a>:</td><td> </td><td valign="top"><a href="#Computed-Names">Computed Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-and-implicit-rule">variables, and implicit rule</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-appending-to">variables, appending to</a>:</td><td> </td><td valign="top"><a href="#Appending">Appending</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-automatic">variables, automatic</a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-command-line">variables, command line</a>:</td><td> </td><td valign="top"><a href="#Overriding">Overriding</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-command-line_002c-and-recursion">variables, command line, and recursion</a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-computed-names">variables, computed names</a>:</td><td> </td><td valign="top"><a href="#Computed-Names">Computed Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-conditional-assignment">variables, conditional assignment</a>:</td><td> </td><td valign="top"><a href="#Conditional-Assignment">Conditional Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-defining-verbatim">variables, defining verbatim</a>:</td><td> </td><td valign="top"><a href="#Multi_002dLine">Multi-Line</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-environment">variables, environment</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-environment-1">variables, environment</a>:</td><td> </td><td valign="top"><a href="#Environment">Environment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-exporting">variables, exporting</a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-flavor-of">variables, flavor of</a>:</td><td> </td><td valign="top"><a href="#Flavor-Function">Flavor Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-flavors">variables, flavors</a>:</td><td> </td><td valign="top"><a href="#Flavors">Flavors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-how-they-get-their-values">variables, how they get their values</a>:</td><td> </td><td valign="top"><a href="#Values">Values</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-how-to-reference">variables, how to reference</a>:</td><td> </td><td valign="top"><a href="#Reference">Reference</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-immediate-assignment">variables, immediate assignment</a>:</td><td> </td><td valign="top"><a href="#Immediate-Assignment">Immediate Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-local">variables, local</a>:</td><td> </td><td valign="top"><a href="#Let-Function">Let Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-loops-in-expansion">variables, loops in expansion</a>:</td><td> </td><td valign="top"><a href="#Recursive-Assignment">Recursive Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-modified-reference">variables, modified reference</a>:</td><td> </td><td valign="top"><a href="#Substitution-Refs">Substitution Refs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-multi_002dline">variables, multi-line</a>:</td><td> </td><td valign="top"><a href="#Multi_002dLine">Multi-Line</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-nested-references">variables, nested references</a>:</td><td> </td><td valign="top"><a href="#Computed-Names">Computed Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-origin-of">variables, origin of</a>:</td><td> </td><td valign="top"><a href="#Origin-Function">Origin Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-overriding">variables, overriding</a>:</td><td> </td><td valign="top"><a href="#Override-Directive">Override Directive</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-overriding-with-arguments">variables, overriding with arguments</a>:</td><td> </td><td valign="top"><a href="#Overriding">Overriding</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-pattern_002dspecific">variables, pattern-specific</a>:</td><td> </td><td valign="top"><a href="#Pattern_002dspecific">Pattern-specific</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-recursively-expanded">variables, recursively expanded</a>:</td><td> </td><td valign="top"><a href="#Flavors">Flavors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-setting">variables, setting</a>:</td><td> </td><td valign="top"><a href="#Setting">Setting</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-simply-expanded">variables, simply expanded</a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-spaces-in-values">variables, spaces in values</a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-substituting-suffix-in">variables, substituting suffix in</a>:</td><td> </td><td valign="top"><a href="#Substitution-Refs">Substitution Refs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-substitution-reference">variables, substitution reference</a>:</td><td> </td><td valign="top"><a href="#Substitution-Refs">Substitution Refs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-target_002dspecific">variables, target-specific</a>:</td><td> </td><td valign="top"><a href="#Target_002dspecific">Target-specific</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-unexpanded-value">variables, unexpanded value</a>:</td><td> </td><td valign="top"><a href="#Value-Function">Value Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-variables_002c-warning-for-undefined">variables, warning for undefined</a>:</td><td> </td><td valign="top"><a href="#Options-Summary">Options Summary</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-varying-prerequisites">varying prerequisites</a>:</td><td> </td><td valign="top"><a href="#Static-Pattern">Static Pattern</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-verbatim-variable-definition">verbatim variable definition</a>:</td><td> </td><td valign="top"><a href="#Multi_002dLine">Multi-Line</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-vpath">vpath</a>:</td><td> </td><td valign="top"><a href="#Directory-Search">Directory Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-VPATH_002c-and-implicit-rules"><code>VPATH</code>, and implicit rules</a>:</td><td> </td><td valign="top"><a href="#Implicit_002fSearch">Implicit/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-VPATH_002c-and-link-libraries"><code>VPATH</code>, and link libraries</a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-W">W</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-warnings_002c-printing">warnings, printing</a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-weave"><code>weave</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-weave-1"><code>weave</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Web_002c-rule-to-run">Web, rule to run</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-what-if">what if</a>:</td><td> </td><td valign="top"><a href="#Instead-of-Execution">Instead of Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-whitespace_002c-avoiding-on-line-split">whitespace, avoiding on line split</a>:</td><td> </td><td valign="top"><a href="#Splitting-Lines">Splitting Lines</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-whitespace_002c-in-variable-values">whitespace, in variable values</a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-whitespace_002c-stripping">whitespace, stripping</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wildcard">wildcard</a>:</td><td> </td><td valign="top"><a href="#Wildcards">Wildcards</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wildcard-pitfalls">wildcard pitfalls</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Pitfall">Wildcard Pitfall</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wildcard_002c-function">wildcard, function</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wildcard_002c-in-archive-member">wildcard, in archive member</a>:</td><td> </td><td valign="top"><a href="#Archive-Members">Archive Members</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wildcard_002c-in-include">wildcard, in <code>include</code></a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wildcards-and-MS_002dDOS_002fMS_002dWindows-backslashes">wildcards and MS-DOS/MS-Windows backslashes</a>:</td><td> </td><td valign="top"><a href="#Wildcard-Pitfall">Wildcard Pitfall</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Windows_002c-choosing-a-shell-in">Windows, choosing a shell in</a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-word_002c-selecting-a">word, selecting a</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-extracting-first">words, extracting first</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-extracting-last">words, extracting last</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-filtering">words, filtering</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-filtering-out">words, filtering out</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-finding-number">words, finding number</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-iterating-over">words, iterating over</a>:</td><td> </td><td valign="top"><a href="#Foreach-Function">Foreach Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-joining-lists">words, joining lists</a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-removing-duplicates">words, removing duplicates</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words_002c-selecting-lists-of">words, selecting lists of</a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-writing-recipes">writing recipes</a>:</td><td> </td><td valign="top"><a href="#Recipes">Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-writing-rules">writing rules</a>:</td><td> </td><td valign="top"><a href="#Rules">Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-writing-to-a-file">writing to a file</a>:</td><td> </td><td valign="top"><a href="#File-Function">File Function</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Concept-Index_cp_letter-Y">Y</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-yacc-1"><code>yacc</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-yacc-2"><code>yacc</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-yacc"><code>yacc</code></a>:</td><td> </td><td valign="top"><a href="#Canned-Recipes">Canned Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Yacc_002c-rule-to-run">Yacc, rule to run</a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
</table>
|
|
<table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Concept-Index_cp_symbol-1"><b>!</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-2"><b>#</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-3"><b>$</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-4"><b>%</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-5"><b>*</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-6"><b>+</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-7"><b>,</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-8"><b>-</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-9"><b>.</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-10"><b>:</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-11"><b>=</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-12"><b>?</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-13"><b>@</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-14"><b>[</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-15"><b>\</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-16"><b>_</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_symbol-17"><b>~</b></a>
|
|
|
|
<br>
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-G"><b>G</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-J"><b>J</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-L"><b>L</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-Q"><b>Q</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-U"><b>U</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a>
|
|
|
|
<a class="summary-letter" href="#Concept-Index_cp_letter-Y"><b>Y</b></a>
|
|
|
|
</td></tr></table>
|
|
|
|
<hr>
|
|
<span id="Name-Index"></span><div class="header">
|
|
<p>
|
|
Previous: <a href="#Concept-Index" accesskey="p" rel="prev">Concept Index</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<span id="Index-of-Functions_002c-Variables_002c-_0026-Directives"></span><h2 class="unnumbered">Index of Functions, Variables, & Directives</h2>
|
|
|
|
<table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Name-Index_fn_symbol-1"><b>$</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-2"><b>%</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-3"><b>*</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-4"><b>+</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-5"><b>-</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-6"><b>.</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-7"><b>/</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-8"><b><</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-9"><b>?</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-10"><b>@</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-11"><b>^</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-12"><b>|</b></a>
|
|
|
|
<br>
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-A"><b>A</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-B"><b>B</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-C"><b>C</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-D"><b>D</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-E"><b>E</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-F"><b>F</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-G"><b>G</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-I"><b>I</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-J"><b>J</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-L"><b>L</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-M"><b>M</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-N"><b>N</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-O"><b>O</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-P"><b>P</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-R"><b>R</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-S"><b>S</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-T"><b>T</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-U"><b>U</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-V"><b>V</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-W"><b>W</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-Y"><b>Y</b></a>
|
|
|
|
</td></tr></table>
|
|
<table class="index-fn" border="0">
|
|
<tr><td></td><th align="left">Index Entry</th><td> </td><th align="left"> Section</th></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-1">$</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0025"><code>$%</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_0025D_0029"><code>$(%D)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_0025F_0029"><code>$(%F)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_002aD_0029"><code>$(*D)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_002aF_0029"><code>$(*F)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_002bD_0029"><code>$(+D)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_002bF_0029"><code>$(+F)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_003cD_0029"><code>$(<D)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_003cF_0029"><code>$(<F)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_003fD_0029"><code>$(?D)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_003fF_0029"><code>$(?F)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_0040D_0029"><code>$(@D)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_0040F_0029"><code>$(@F)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_005eD_0029"><code>$(^D)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0028_005eF_0029"><code>$(^F)</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_002a"><code>$*</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_002a_002c-and-static-pattern"><code>$*<span class="roman">, and static pattern</span></code></a>:</td><td> </td><td valign="top"><a href="#Static-Usage">Static Usage</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_002b"><code>$+</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_003c"><code>$<</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_003f"><code>$?</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_0040"><code>$@</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_005e"><code>$^</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0024_007c"><code>$|</code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-2">%</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025-_0028automatic-variable_0029"><code>% <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025D-_0028automatic-variable_0029"><code>%D <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0025F-_0028automatic-variable_0029"><code>%F <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-3">*</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002a-_0028automatic-variable_0029"><code>* <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002a-_0028automatic-variable_0029_002c-unsupported-bizarre-usage"><code>* <span class="roman">(automatic variable), unsupported bizarre usage</span></code></a>:</td><td> </td><td valign="top"><a href="#Missing">Missing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002aD-_0028automatic-variable_0029"><code>*D <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002aF-_0028automatic-variable_0029"><code>*F <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-4">+</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002b-_0028automatic-variable_0029"><code>+ <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002bD-_0028automatic-variable_0029"><code>+D <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002bF-_0028automatic-variable_0029"><code>+F <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-5">-</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002dload"><code>-load</code></a>:</td><td> </td><td valign="top"><a href="#load-Directive">load Directive</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-6">.</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eDEFAULT"><code>.DEFAULT</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eDEFAULT-1"><code>.DEFAULT</code></a>:</td><td> </td><td valign="top"><a href="#Last-Resort">Last Resort</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eDEFAULT_002c-and-empty-recipes"><code>.DEFAULT<span class="roman">, and empty recipes</span></code></a>:</td><td> </td><td valign="top"><a href="#Empty-Recipes">Empty Recipes</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eDEFAULT_005fGOAL-_0028define-default-goal_0029"><code>.DEFAULT_GOAL <span class="roman">(define default goal)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eDELETE_005fON_005fERROR"><code>.DELETE_ON_ERROR</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eDELETE_005fON_005fERROR-1"><code>.DELETE_ON_ERROR</code></a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eEXPORT_005fALL_005fVARIABLES"><code>.EXPORT_ALL_VARIABLES</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eEXPORT_005fALL_005fVARIABLES-1"><code>.EXPORT_ALL_VARIABLES</code></a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eEXTRA_005fPREREQS-_0028prerequisites-not-added-to-automatic-variables_0029"><code>.EXTRA_PREREQS <span class="roman">(prerequisites not added to automatic variables)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eFEATURES-_0028list-of-supported-features_0029"><code>.FEATURES <span class="roman">(list of supported features)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eIGNORE"><code>.IGNORE</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eIGNORE-1"><code>.IGNORE</code></a>:</td><td> </td><td valign="top"><a href="#Errors">Errors</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eINCLUDE_005fDIRS-_0028list-of-include-directories_0029"><code>.INCLUDE_DIRS <span class="roman">(list of include directories)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eINTERMEDIATE"><code>.INTERMEDIATE</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eLIBPATTERNS"><code>.LIBPATTERNS</code></a>:</td><td> </td><td valign="top"><a href="#Libraries_002fSearch">Libraries/Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eLOADED"><code>.LOADED</code></a>:</td><td> </td><td valign="top"><a href="#load-Directive">load Directive</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eLOW_005fRESOLUTION_005fTIME"><code>.LOW_RESOLUTION_TIME</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eNOTINTERMEDIATE"><code>.NOTINTERMEDIATE</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eNOTPARALLEL"><code>.NOTPARALLEL</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eNOTPARALLEL-1"><code>.NOTPARALLEL</code></a>:</td><td> </td><td valign="top"><a href="#Parallel-Disable">Parallel Disable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eONESHELL"><code>.ONESHELL</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eONESHELL-1"><code>.ONESHELL</code></a>:</td><td> </td><td valign="top"><a href="#One-Shell">One Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ePHONY"><code>.PHONY</code></a>:</td><td> </td><td valign="top"><a href="#Phony-Targets">Phony Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ePHONY-1"><code>.PHONY</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ePOSIX"><code>.POSIX</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ePOSIX-1"><code>.POSIX</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ePRECIOUS"><code>.PRECIOUS</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002ePRECIOUS-1"><code>.PRECIOUS</code></a>:</td><td> </td><td valign="top"><a href="#Interrupts">Interrupts</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eRECIPEPREFIX-_0028change-the-recipe-prefix-character_0029"><code>.RECIPEPREFIX <span class="roman">(change the recipe prefix character)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSECONDARY"><code>.SECONDARY</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSECONDEXPANSION"><code>.SECONDEXPANSION</code></a>:</td><td> </td><td valign="top"><a href="#Secondary-Expansion">Secondary Expansion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSECONDEXPANSION-1"><code>.SECONDEXPANSION</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSHELLFLAGS"><code>.SHELLFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSHELLFLAGS-1"><code>.SHELLFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSHELLSTATUS"><code>.SHELLSTATUS</code></a>:</td><td> </td><td valign="top"><a href="#Shell-Function">Shell Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSILENT"><code>.SILENT</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSILENT-1"><code>.SILENT</code></a>:</td><td> </td><td valign="top"><a href="#Echoing">Echoing</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSUFFIXES"><code>.SUFFIXES</code></a>:</td><td> </td><td valign="top"><a href="#Special-Targets">Special Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eSUFFIXES-1"><code>.SUFFIXES</code></a>:</td><td> </td><td valign="top"><a href="#Suffix-Rules">Suffix Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eVARIABLES-_0028list-of-variables_0029"><code>.VARIABLES <span class="roman">(list of variables)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002eWAIT"><code>.WAIT</code></a>:</td><td> </td><td valign="top"><a href="#Parallel-Disable">Parallel Disable</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-7">/</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002fusr_002fgnu_002finclude"><code>/usr/gnu/include</code></a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002fusr_002finclude"><code>/usr/include</code></a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_002fusr_002flocal_002finclude"><code>/usr/local/include</code></a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-8"><</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003c-_0028automatic-variable_0029"><code>< <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003cD-_0028automatic-variable_0029"><code><D <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003cF-_0028automatic-variable_0029"><code><F <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-9">?</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003f-_0028automatic-variable_0029"><code>? <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003fD-_0028automatic-variable_0029"><code>?D <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_003fF-_0028automatic-variable_0029"><code>?F <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-10">@</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0040-_0028automatic-variable_0029"><code>@ <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0040D-_0028automatic-variable_0029"><code>@D <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_0040F-_0028automatic-variable_0029"><code>@F <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-11">^</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005e-_0028automatic-variable_0029"><code>^ <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005eD-_0028automatic-variable_0029"><code>^D <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_005eF-_0028automatic-variable_0029"><code>^F <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_symbol-12">|</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-_007c-_0028automatic-variable_0029"><code>| <span class="roman">(automatic variable)</span></code></a>:</td><td> </td><td valign="top"><a href="#Automatic-Variables">Automatic Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-A">A</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-abspath-1"><code>abspath</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-addprefix"><code>addprefix</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-addsuffix"><code>addsuffix</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-and"><code>and</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Functions">Conditional Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-AR"><code>AR</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ARFLAGS"><code>ARFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-AS"><code>AS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ASFLAGS"><code>ASFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-B">B</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-basename-1"><code>basename</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-bindir"><code>bindir</code></a>:</td><td> </td><td valign="top"><a href="#Directory-Variables">Directory Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-C">C</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-call"><code>call</code></a>:</td><td> </td><td valign="top"><a href="#Call-Function">Call Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CC"><code>CC</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CFLAGS"><code>CFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CO"><code>CO</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-COFLAGS"><code>COFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-COMSPEC"><code>COMSPEC</code></a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CPP"><code>CPP</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CPPFLAGS"><code>CPPFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CTANGLE"><code>CTANGLE</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CURDIR"><code><code>CURDIR</code></code></a>:</td><td> </td><td valign="top"><a href="#Recursion">Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CWEAVE"><code>CWEAVE</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CXX"><code>CXX</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-CXXFLAGS"><code>CXXFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-D">D</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-define"><code>define</code></a>:</td><td> </td><td valign="top"><a href="#Multi_002dLine">Multi-Line</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-DESTDIR"><code>DESTDIR</code></a>:</td><td> </td><td valign="top"><a href="#DESTDIR">DESTDIR</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-dir"><code>dir</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-E">E</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-else"><code>else</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Syntax">Conditional Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-endef"><code>endef</code></a>:</td><td> </td><td valign="top"><a href="#Multi_002dLine">Multi-Line</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-endif"><code>endif</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Syntax">Conditional Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-error"><code>error</code></a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-eval"><code>eval</code></a>:</td><td> </td><td valign="top"><a href="#Eval-Function">Eval Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-exec_005fprefix"><code>exec_prefix</code></a>:</td><td> </td><td valign="top"><a href="#Directory-Variables">Directory Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-export"><code>export</code></a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-F">F</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-FC"><code>FC</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-FFLAGS"><code>FFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-file"><code>file</code></a>:</td><td> </td><td valign="top"><a href="#File-Function">File Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-filter"><code>filter</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-filter_002dout"><code>filter-out</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-findstring"><code>findstring</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-firstword"><code>firstword</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-flavor"><code>flavor</code></a>:</td><td> </td><td valign="top"><a href="#Flavor-Function">Flavor Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-foreach"><code>foreach</code></a>:</td><td> </td><td valign="top"><a href="#Foreach-Function">Foreach Function</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-G">G</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-GET"><code>GET</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-GFLAGS"><code>GFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gmk_002deval"><code>gmk-eval</code></a>:</td><td> </td><td valign="top"><a href="#Guile-Interface">Guile Interface</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gmk_002dexpand"><code>gmk-expand</code></a>:</td><td> </td><td valign="top"><a href="#Guile-Interface">Guile Interface</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gmk_005fadd_005ffunction"><code>gmk_add_function</code></a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gmk_005falloc"><code>gmk_alloc</code></a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gmk_005feval"><code>gmk_eval</code></a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gmk_005fexpand"><code>gmk_expand</code></a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gmk_005ffree"><code>gmk_free</code></a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-gmk_005ffunc_005fptr"><code>gmk_func_ptr</code></a>:</td><td> </td><td valign="top"><a href="#Loaded-Object-API">Loaded Object API</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-GNUmakefile"><code>GNUmakefile</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-GPATH"><code>GPATH</code></a>:</td><td> </td><td valign="top"><a href="#Search-Algorithm">Search Algorithm</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-guile"><code>guile</code></a>:</td><td> </td><td valign="top"><a href="#Guile-Function">Guile Function</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-I">I</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-if"><code>if</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Functions">Conditional Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-if-1"><code>if</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Functions">Conditional Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ifdef"><code>ifdef</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Syntax">Conditional Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ifeq"><code>ifeq</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Syntax">Conditional Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ifndef"><code>ifndef</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Syntax">Conditional Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-ifneq"><code>ifneq</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Syntax">Conditional Syntax</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-include"><code>include</code></a>:</td><td> </td><td valign="top"><a href="#Include">Include</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-info"><code>info</code></a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-intcmp"><code>intcmp</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Functions">Conditional Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-J">J</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-join"><code>join</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-L">L</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-lastword"><code>lastword</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-LDFLAGS"><code>LDFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-LDLIBS"><code>LDLIBS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-let"><code>let</code></a>:</td><td> </td><td valign="top"><a href="#Let-Function">Let Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-LEX"><code>LEX</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-LFLAGS"><code>LFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-libexecdir"><code>libexecdir</code></a>:</td><td> </td><td valign="top"><a href="#Directory-Variables">Directory Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-LINT"><code>LINT</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-LINTFLAGS"><code>LINTFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-load"><code>load</code></a>:</td><td> </td><td valign="top"><a href="#load-Directive">load Directive</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-LOADLIBES"><code>LOADLIBES</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-M">M</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-M2C"><code>M2C</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKE"><code>MAKE</code></a>:</td><td> </td><td valign="top"><a href="#MAKE-Variable">MAKE Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKE-1"><code>MAKE</code></a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKECMDGOALS"><code>MAKECMDGOALS</code></a>:</td><td> </td><td valign="top"><a href="#Goals">Goals</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-Makefile"><code>Makefile</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-makefile-1"><code>makefile</code></a>:</td><td> </td><td valign="top"><a href="#Makefile-Names">Makefile Names</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKEFILES"><code>MAKEFILES</code></a>:</td><td> </td><td valign="top"><a href="#MAKEFILES-Variable">MAKEFILES Variable</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKEFILES-1"><code>MAKEFILES</code></a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKEFILE_005fLIST-_0028list-of-parsed-makefiles_0029"><code>MAKEFILE_LIST <span class="roman">(list of parsed makefiles)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKEFLAGS"><code>MAKEFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKEINFO"><code>MAKEINFO</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKELEVEL"><code>MAKELEVEL</code></a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKELEVEL-1"><code>MAKELEVEL</code></a>:</td><td> </td><td valign="top"><a href="#Simple-Assignment">Simple Assignment</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKEOVERRIDES"><code>MAKEOVERRIDES</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKESHELL-_0028MS_002dDOS-alternative-to-SHELL_0029"><code><code>MAKESHELL</code> <span class="roman">(MS-DOS alternative to <code>SHELL</code>)</span></code></a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKE_005fHOST"><code>MAKE_HOST</code></a>:</td><td> </td><td valign="top"><a href="#Quick-Reference">Quick Reference</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKE_005fRESTARTS-_0028number-of-times-make-has-restarted_0029"><code>MAKE_RESTARTS <span class="roman">(number of times <code>make</code> has restarted)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKE_005fTERMERR-_0028whether-stderr-is-a-terminal_0029"><code>MAKE_TERMERR <span class="roman">(whether stderr is a terminal)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKE_005fTERMOUT-_0028whether-stdout-is-a-terminal_0029"><code>MAKE_TERMOUT <span class="roman">(whether stdout is a terminal)</span></code></a>:</td><td> </td><td valign="top"><a href="#Special-Variables">Special Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MAKE_005fVERSION"><code>MAKE_VERSION</code></a>:</td><td> </td><td valign="top"><a href="#Quick-Reference">Quick Reference</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-MFLAGS"><code>MFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Options_002fRecursion">Options/Recursion</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-N">N</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-notdir"><code>notdir</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-O">O</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-or"><code>or</code></a>:</td><td> </td><td valign="top"><a href="#Conditional-Functions">Conditional Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-origin"><code>origin</code></a>:</td><td> </td><td valign="top"><a href="#Origin-Function">Origin Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-OUTPUT_005fOPTION"><code>OUTPUT_OPTION</code></a>:</td><td> </td><td valign="top"><a href="#Catalogue-of-Rules">Catalogue of Rules</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-override"><code>override</code></a>:</td><td> </td><td valign="top"><a href="#Override-Directive">Override Directive</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-P">P</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-patsubst"><code>patsubst</code></a>:</td><td> </td><td valign="top"><a href="#Substitution-Refs">Substitution Refs</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-patsubst-1"><code>patsubst</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-PC"><code>PC</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-PFLAGS"><code>PFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-prefix"><code>prefix</code></a>:</td><td> </td><td valign="top"><a href="#Directory-Variables">Directory Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-private"><code>private</code></a>:</td><td> </td><td valign="top"><a href="#Suppressing-Inheritance">Suppressing Inheritance</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-R">R</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-realpath-1"><code>realpath</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-RFLAGS"><code>RFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-RM"><code>RM</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-S">S</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-sbindir"><code>sbindir</code></a>:</td><td> </td><td valign="top"><a href="#Directory-Variables">Directory Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SHELL"><code>SHELL</code></a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SHELL-1"><code>SHELL</code></a>:</td><td> </td><td valign="top"><a href="#Choosing-the-Shell">Choosing the Shell</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-shell"><code>shell</code></a>:</td><td> </td><td valign="top"><a href="#Shell-Function">Shell Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SHELL-_0028recipe-execution_0029"><code><code>SHELL</code> <span class="roman">(recipe execution)</span></code></a>:</td><td> </td><td valign="top"><a href="#Execution">Execution</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-sort"><code>sort</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-strip"><code>strip</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-subst"><code>subst</code></a>:</td><td> </td><td valign="top"><a href="#Multiple-Targets">Multiple Targets</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-subst-1"><code>subst</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-suffix"><code>suffix</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-SUFFIXES"><code>SUFFIXES</code></a>:</td><td> </td><td valign="top"><a href="#Suffix-Rules">Suffix Rules</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-T">T</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-TANGLE"><code>TANGLE</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-TEX"><code>TEX</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-TEXI2DVI"><code>TEXI2DVI</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-U">U</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-undefine"><code>undefine</code></a>:</td><td> </td><td valign="top"><a href="#Undefine-Directive">Undefine Directive</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-unexport"><code>unexport</code></a>:</td><td> </td><td valign="top"><a href="#Variables_002fRecursion">Variables/Recursion</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-V">V</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-value-1"><code>value</code></a>:</td><td> </td><td valign="top"><a href="#Value-Function">Value Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-VPATH"><code>VPATH</code></a>:</td><td> </td><td valign="top"><a href="#Directory-Search">Directory Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-VPATH-1"><code>VPATH</code></a>:</td><td> </td><td valign="top"><a href="#General-Search">General Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-vpath-1"><code>vpath</code></a>:</td><td> </td><td valign="top"><a href="#Directory-Search">Directory Search</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-vpath-2"><code>vpath</code></a>:</td><td> </td><td valign="top"><a href="#Selective-Search">Selective Search</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-W">W</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-warning"><code>warning</code></a>:</td><td> </td><td valign="top"><a href="#Make-Control-Functions">Make Control Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-WEAVE"><code>WEAVE</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wildcard-1"><code>wildcard</code></a>:</td><td> </td><td valign="top"><a href="#Wildcard-Function">Wildcard Function</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wildcard-2"><code>wildcard</code></a>:</td><td> </td><td valign="top"><a href="#File-Name-Functions">File Name Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-word"><code>word</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-wordlist"><code>wordlist</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-words"><code>words</code></a>:</td><td> </td><td valign="top"><a href="#Text-Functions">Text Functions</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
<tr><th id="Name-Index_fn_letter-Y">Y</th><td></td><td></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-YACC"><code>YACC</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td></td><td valign="top"><a href="#index-YFLAGS"><code>YFLAGS</code></a>:</td><td> </td><td valign="top"><a href="#Implicit-Variables">Implicit Variables</a></td></tr>
|
|
<tr><td colspan="4"> <hr></td></tr>
|
|
</table>
|
|
<table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Name-Index_fn_symbol-1"><b>$</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-2"><b>%</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-3"><b>*</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-4"><b>+</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-5"><b>-</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-6"><b>.</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-7"><b>/</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-8"><b><</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-9"><b>?</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-10"><b>@</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-11"><b>^</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_symbol-12"><b>|</b></a>
|
|
|
|
<br>
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-A"><b>A</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-B"><b>B</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-C"><b>C</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-D"><b>D</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-E"><b>E</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-F"><b>F</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-G"><b>G</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-I"><b>I</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-J"><b>J</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-L"><b>L</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-M"><b>M</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-N"><b>N</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-O"><b>O</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-P"><b>P</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-R"><b>R</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-S"><b>S</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-T"><b>T</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-U"><b>U</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-V"><b>V</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-W"><b>W</b></a>
|
|
|
|
<a class="summary-letter" href="#Name-Index_fn_letter-Y"><b>Y</b></a>
|
|
|
|
</td></tr></table>
|
|
|
|
<div class="footnote">
|
|
<hr>
|
|
<h4 class="footnotes-heading">Footnotes</h4>
|
|
|
|
<h5><a id="FOOT1" href="#DOCF1">(1)</a></h3>
|
|
<p>GNU Make compiled for MS-DOS and MS-Windows behaves as if
|
|
<var>prefix</var> has been defined to be the root of the DJGPP tree
|
|
hierarchy.</p>
|
|
<h5><a id="FOOT2" href="#DOCF2">(2)</a></h3>
|
|
<p>Some older versions of GNU <code>make</code> did not sort the
|
|
results of wildcard expansion.</p>
|
|
<h5><a id="FOOT3" href="#DOCF3">(3)</a></h3>
|
|
<p>On
|
|
MS-DOS, the value of current working directory is <strong>global</strong>, so
|
|
changing it <em>will</em> affect the following recipe lines on those
|
|
systems.</p>
|
|
</div>
|
|
<hr>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|