1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<h1 class="section">Using Wildcard Characters in File Names</h1> <p>A single file name can specify many files using <em>wildcard characters</em>. The wildcard characters in <code>make</code> are ‘<samp>*</samp>’, ‘<samp>?</samp>’ and ‘<samp>[…]</samp>’, the same as in the Bourne shell. For example, <samp>*.c</samp> specifies a list of all the files (in the working directory) whose names end in ‘<samp>.c</samp>’. </p> <p>If an expression matches multiple files than the results will be sorted.<a id="DOCF2" href="#FOOT2"><sup>2</sup></a> However multiple expressions will not be globally sorted. For example, <samp>*.c *.h</samp> will list all the files whose names end in ‘<samp>.c</samp>’, sorted, followed by all the files whose names end in ‘<samp>.h</samp>’, sorted. </p> <p>The character ‘<samp>~</samp>’ at the beginning of a file name also has special significance. If alone, or followed by a slash, it represents your home directory. For example <samp>~/bin</samp> expands to <samp>/home/you/bin</samp>. If the ‘<samp>~</samp>’ is followed by a word, the string represents the home directory of the user named by that word. For example <samp>~john/bin</samp> expands to <samp>/home/john/bin</samp>. On systems which don’t have a home directory for each user (such as MS-DOS or MS-Windows), this functionality can be simulated by setting the environment variable <var>HOME</var>. </p> <p>Wildcard expansion is performed by <code>make</code> automatically in targets and in prerequisites. In recipes, the shell is responsible for wildcard expansion. In other contexts, wildcard expansion happens only if you request it explicitly with the <code>wildcard</code> function. </p> <p>The special significance of a wildcard character can be turned off by preceding it with a backslash. Thus, <samp>foo\*bar</samp> would refer to a specific file whose name consists of ‘<samp>foo</samp>’, an asterisk, and ‘<samp>bar</samp>’. </p> <table class="menu" border="0" cellspacing="0"> <tr>
<td align="left" valign="top">• <a href="wildcard-examples" accesskey="1">Wildcard Examples</a>
</td>
<td> </td>
<td align="left" valign="top">Several examples. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="wildcard-pitfall" accesskey="2">Wildcard Pitfall</a>
</td>
<td> </td>
<td align="left" valign="top">Problems to avoid. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="wildcard-function" accesskey="3">Wildcard Function</a>
</td>
<td> </td>
<td align="left" valign="top">How to cause wildcard expansion where it does not normally take place. </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/Wildcards.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Wildcards.html</a>
</p>
</div>
|