diff options
Diffstat (limited to 'devdocs/gnu_make/selective-search.html')
| -rw-r--r-- | devdocs/gnu_make/selective-search.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/devdocs/gnu_make/selective-search.html b/devdocs/gnu_make/selective-search.html new file mode 100644 index 00000000..2892e300 --- /dev/null +++ b/devdocs/gnu_make/selective-search.html @@ -0,0 +1,18 @@ + <h1 class="subsection">The vpath Directive</h1> <p>Similar to the <code>VPATH</code> variable, but more selective, is the <code>vpath</code> directive (note lower case), which allows you to specify a search path for a particular class of file names: those that match a particular pattern. Thus you can supply certain search directories for one class of file names and other directories (or none) for other file names. </p> <p>There are three forms of the <code>vpath</code> directive: </p> <dl compact> <dt id="vpath pattern directories"><code>vpath <var>pattern</var> <var>directories</var></code></dt> <dd> +<p>Specify the search path <var>directories</var> for file names that match <var>pattern</var>. </p> <p>The search path, <var>directories</var>, is a list of directories to be searched, separated by colons (semi-colons on MS-DOS and MS-Windows) or blanks, just like the search path used in the <code>VPATH</code> variable. </p> </dd> <dt id="vpath pattern"><code>vpath <var>pattern</var></code></dt> <dd> +<p>Clear out the search path associated with <var>pattern</var>. </p> </dd> <dt id="vpath"><code>vpath</code></dt> <dd> <p>Clear all search paths previously specified with <code>vpath</code> directives. </p> +</dd> </dl> <p>A <code>vpath</code> pattern is a string containing a ‘<samp>%</samp>’ character. The string must match the file name of a prerequisite that is being searched for, the ‘<samp>%</samp>’ character matching any sequence of zero or more characters (as in pattern rules; see <a href="pattern-rules">Defining and Redefining Pattern Rules</a>). For example, <code>%.h</code> matches files that end in <code>.h</code>. (If there is no ‘<samp>%</samp>’, the pattern must match the prerequisite exactly, which is not useful very often.) </p> <p>‘<samp>%</samp>’ characters in a <code>vpath</code> directive’s pattern can be quoted with preceding backslashes (‘<samp>\</samp>’). Backslashes that would otherwise quote ‘<samp>%</samp>’ characters can be quoted with more backslashes. Backslashes that quote ‘<samp>%</samp>’ characters or other backslashes are removed from the pattern before it is compared to file names. Backslashes that are not in danger of quoting ‘<samp>%</samp>’ characters go unmolested. </p> <p>When a prerequisite fails to exist in the current directory, if the <var>pattern</var> in a <code>vpath</code> directive matches the name of the prerequisite file, then the <var>directories</var> in that directive are searched just like (and before) the directories in the <code>VPATH</code> variable. </p> <p>For example, </p> <div class="example"> <pre class="example">vpath %.h ../headers +</pre> +</div> <p>tells <code>make</code> to look for any prerequisite whose name ends in <samp>.h</samp> in the directory <samp>../headers</samp> if the file is not found in the current directory. </p> <p>If several <code>vpath</code> patterns match the prerequisite file’s name, then <code>make</code> processes each matching <code>vpath</code> directive one by one, searching all the directories mentioned in each directive. <code>make</code> handles multiple <code>vpath</code> directives in the order in which they appear in the makefile; multiple directives with the same pattern are independent of each other. </p> <p>Thus, </p> <div class="example"> <pre class="example">vpath %.c foo +vpath % blish +vpath %.c bar +</pre> +</div> <p>will look for a file ending in ‘<samp>.c</samp>’ in <samp>foo</samp>, then <samp>blish</samp>, then <samp>bar</samp>, while </p> <div class="example"> <pre class="example">vpath %.c foo:bar +vpath % blish +</pre> +</div> <p>will look for a file ending in ‘<samp>.c</samp>’ in <samp>foo</samp>, then <samp>bar</samp>, then <samp>blish</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/Selective-Search.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Selective-Search.html</a> + </p> +</div> |
