1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<h1 class="section">Defining and Redefining Pattern Rules</h1> <p>You define an implicit rule by writing a <em>pattern rule</em>. A pattern rule looks like an ordinary rule, except that its target contains the character ‘<samp>%</samp>’ (exactly one of them). The target is considered a pattern for matching file names; the ‘<samp>%</samp>’ can match any nonempty substring, while other characters match only themselves. The prerequisites likewise use ‘<samp>%</samp>’ to show how their names relate to the target name. </p> <p>Thus, a pattern rule ‘<samp>%.o : %.c</samp>’ says how to make any file <samp><var>stem</var>.o</samp> from another file <samp><var>stem</var>.c</samp>. </p> <p>Note that expansion using ‘<samp>%</samp>’ in pattern rules occurs <strong>after</strong> any variable or function expansions, which take place when the makefile is read. See <a href="using-variables">How to Use Variables</a>, and <a href="functions">Functions for Transforming Text</a>. </p> <table class="menu" border="0" cellspacing="0"> <tr>
<td align="left" valign="top">• <a href="pattern-intro" accesskey="1">Pattern Intro</a>
</td>
<td> </td>
<td align="left" valign="top">An introduction to pattern rules. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="pattern-examples" accesskey="2">Pattern Examples</a>
</td>
<td> </td>
<td align="left" valign="top">Examples of pattern rules. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="automatic-variables" accesskey="3">Automatic Variables</a>
</td>
<td> </td>
<td align="left" valign="top">How to use automatic variables in the recipe of implicit rules. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="pattern-match" accesskey="4">Pattern Match</a>
</td>
<td> </td>
<td align="left" valign="top">How patterns match. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="match_002danything-rules" accesskey="5">Match-Anything Rules</a>
</td>
<td> </td>
<td align="left" valign="top">Precautions you should take prior to defining rules that can match any target file whatever. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="canceling-rules" accesskey="6">Canceling Rules</a>
</td>
<td> </td>
<td align="left" valign="top">How to override or cancel built-in rules. </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/Pattern-Rules.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Pattern-Rules.html</a>
</p>
</div>
|