summaryrefslogtreecommitdiff
path: root/devdocs/gnu_make/cleanup.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/gnu_make/cleanup.html
new repository
Diffstat (limited to 'devdocs/gnu_make/cleanup.html')
-rw-r--r--devdocs/gnu_make/cleanup.html13
1 files changed, 13 insertions, 0 deletions
diff --git a/devdocs/gnu_make/cleanup.html b/devdocs/gnu_make/cleanup.html
new file mode 100644
index 00000000..ca46429d
--- /dev/null
+++ b/devdocs/gnu_make/cleanup.html
@@ -0,0 +1,13 @@
+ <h1 class="section">Rules for Cleaning the Directory</h1> <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> <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><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/Cleanup.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Cleanup.html</a>
+ </p>
+</div>