diff options
Diffstat (limited to 'devdocs/gnu_make/archive-suffix-rules.html')
| -rw-r--r-- | devdocs/gnu_make/archive-suffix-rules.html | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/devdocs/gnu_make/archive-suffix-rules.html b/devdocs/gnu_make/archive-suffix-rules.html new file mode 100644 index 00000000..e0c75430 --- /dev/null +++ b/devdocs/gnu_make/archive-suffix-rules.html @@ -0,0 +1,16 @@ + <h1 class="section">Suffix Rules for Archive Files</h1> <p>You can write a special kind of suffix rule for dealing with archive files. See <a href="suffix-rules">Suffix Rules</a>, for a full explanation of suffix rules. Archive suffix rules are obsolete in GNU <code>make</code>, because pattern rules for archives are a more general mechanism (see <a href="archive-update">Archive Update</a>). But they are retained for compatibility with other <code>make</code>s. </p> <p>To write a suffix rule for archives, you simply write a suffix rule using the target suffix ‘<samp>.a</samp>’ (the usual suffix for archive files). For example, here is the old-fashioned suffix rule to update a library archive from C source files: </p> <div class="example"> <pre class="example">.c.a: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o + $(AR) r $@ $*.o + $(RM) $*.o +</pre> +</div> <p>This works just as if you had written the pattern rule: </p> <div class="example"> <pre class="example">(%.o): %.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o + $(AR) r $@ $*.o + $(RM) $*.o +</pre> +</div> <p>In fact, this is just what <code>make</code> does when it sees a suffix rule with ‘<samp>.a</samp>’ as the target suffix. Any double-suffix rule ‘<samp>.<var>x</var>.a</samp>’ is converted to a pattern rule with the target pattern ‘<samp>(%.o)</samp>’ and a prerequisite pattern of ‘<samp>%.<var>x</var></samp>’. </p> <p>Since you might want to use ‘<samp>.a</samp>’ as the suffix for some other kind of file, <code>make</code> also converts archive suffix rules to pattern rules in the normal way (see <a href="suffix-rules">Suffix Rules</a>). Thus a double-suffix rule ‘<samp>.<var>x</var>.a</samp>’ produces two pattern rules: ‘<samp>(%.o): %.<var>x</var></samp>’ and ‘<samp>%.a: %.<var>x</var></samp>’. </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/Archive-Suffix-Rules.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Archive-Suffix-Rules.html</a> + </p> +</div> |
