1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<h1 class="chapter">Features of GNU make</h1> <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>’ 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><div class="_attribution">
<p class="_attribution-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. <br>Licensed under the GNU Free Documentation License.<br>
<a href="https://www.gnu.org/software/make/manual/html_node/Features.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Features.html</a>
</p>
</div>
|