summaryrefslogtreecommitdiff
path: root/devdocs/gnu_make/recursion.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/gnu_make/recursion.html')
-rw-r--r--devdocs/gnu_make/recursion.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/devdocs/gnu_make/recursion.html b/devdocs/gnu_make/recursion.html
new file mode 100644
index 00000000..4f7c86a5
--- /dev/null
+++ b/devdocs/gnu_make/recursion.html
@@ -0,0 +1,32 @@
+ <h1 class="section">Recursive Use of make</h1> <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 &amp;&amp; $(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> <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> <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="_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><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/Recursion.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Recursion.html</a>
+ </p>
+</div>