summaryrefslogtreecommitdiff
path: root/devdocs/gnu_make/archive-update.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/archive-update.html
new repository
Diffstat (limited to 'devdocs/gnu_make/archive-update.html')
-rw-r--r--devdocs/gnu_make/archive-update.html17
1 files changed, 17 insertions, 0 deletions
diff --git a/devdocs/gnu_make/archive-update.html b/devdocs/gnu_make/archive-update.html
new file mode 100644
index 00000000..b11e9d50
--- /dev/null
+++ b/devdocs/gnu_make/archive-update.html
@@ -0,0 +1,17 @@
+ <h1 class="section">Implicit Rule for Archive Member Targets</h1> <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><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/Archive-Update.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Archive-Update.html</a>
+ </p>
+</div>