1
2
3
4
5
6
7
8
9
|
<h1 class="subsection">How the MAKE Variable Works</h1> <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. </p> <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>’) 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 && make <span class="nolinebreak">-t</span></samp>’; but that would require executing the recipe, and ‘<samp>-t</samp>’ says not to execute recipes. </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><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/MAKE-Variable.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html</a>
</p>
</div>
|