summaryrefslogtreecommitdiff
path: root/devdocs/gnu_make/file-name-functions.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/gnu_make/file-name-functions.html')
-rw-r--r--devdocs/gnu_make/file-name-functions.html29
1 files changed, 29 insertions, 0 deletions
diff --git a/devdocs/gnu_make/file-name-functions.html b/devdocs/gnu_make/file-name-functions.html
new file mode 100644
index 00000000..c8e7abcd
--- /dev/null
+++ b/devdocs/gnu_make/file-name-functions.html
@@ -0,0 +1,29 @@
+ <h1 class="section">Functions for File Names</h1> <p>Several of the built-in expansion functions relate specifically to taking apart file names or lists of file names. </p> <p>Each of the following functions performs a specific transformation on a file name. The argument of the function is regarded as a series of file names, separated by whitespace. (Leading and trailing whitespace is ignored.) Each file name in the series is transformed in the same way and the results are concatenated with single spaces between them. </p> <dl compact> <dt id="$(dir names…)"><code>$(dir <var>names</var>…)</code></dt> <dd>
+ <p>Extracts the directory-part of each file name in <var>names</var>. The directory-part of the file name is everything up through (and including) the last slash in it. If the file name contains no slash, the directory part is the string ‘<samp>./</samp>’. For example, </p> <div class="example"> <pre class="example">$(dir src/foo.c hacks)
+</pre>
+</div> <p>produces the result ‘<samp>src/ ./</samp>’. </p> </dd> <dt id="$(notdir names…)"><code>$(notdir <var>names</var>…)</code></dt> <dd>
+ <p>Extracts all but the directory-part of each file name in <var>names</var>. If the file name contains no slash, it is left unchanged. Otherwise, everything through the last slash is removed from it. </p> <p>A file name that ends with a slash becomes an empty string. This is unfortunate, because it means that the result does not always have the same number of whitespace-separated file names as the argument had; but we do not see any other valid alternative. </p> <p>For example, </p> <div class="example"> <pre class="example">$(notdir src/foo.c hacks)
+</pre>
+</div> <p>produces the result ‘<samp>foo.c hacks</samp>’. </p> </dd> <dt id="$(suffix names…)"><code>$(suffix <var>names</var>…)</code></dt> <dd>
+ <p>Extracts the suffix of each file name in <var>names</var>. If the file name contains a period, the suffix is everything starting with the last period. Otherwise, the suffix is the empty string. This frequently means that the result will be empty when <var>names</var> is not, and if <var>names</var> contains multiple file names, the result may contain fewer file names. </p> <p>For example, </p> <div class="example"> <pre class="example">$(suffix src/foo.c src-1.0/bar.c hacks)
+</pre>
+</div> <p>produces the result ‘<samp>.c .c</samp>’. </p> </dd> <dt id="$(basename names…)"><code>$(basename <var>names</var>…)</code></dt> <dd>
+ <p>Extracts all but the suffix of each file name in <var>names</var>. If the file name contains a period, the basename is everything starting up to (and not including) the last period. Periods in the directory part are ignored. If there is no period, the basename is the entire file name. For example, </p> <div class="example"> <pre class="example">$(basename src/foo.c src-1.0/bar hacks)
+</pre>
+</div> <p>produces the result ‘<samp>src/foo src-1.0/bar hacks</samp>’. </p> </dd> <dt id="$(addsuffix suffix,names…)"><code>$(addsuffix <var>suffix</var>,<var>names</var>…)</code></dt> <dd>
+ <p>The argument <var>names</var> is regarded as a series of names, separated by whitespace; <var>suffix</var> is used as a unit. The value of <var>suffix</var> is appended to the end of each individual name and the resulting larger names are concatenated with single spaces between them. For example, </p> <div class="example"> <pre class="example">$(addsuffix .c,foo bar)
+</pre>
+</div> <p>produces the result ‘<samp>foo.c bar.c</samp>’. </p> </dd> <dt id="$(addprefix prefix,names…)"><code>$(addprefix <var>prefix</var>,<var>names</var>…)</code></dt> <dd>
+ <p>The argument <var>names</var> is regarded as a series of names, separated by whitespace; <var>prefix</var> is used as a unit. The value of <var>prefix</var> is prepended to the front of each individual name and the resulting larger names are concatenated with single spaces between them. For example, </p> <div class="example"> <pre class="example">$(addprefix src/,foo bar)
+</pre>
+</div> <p>produces the result ‘<samp>src/foo src/bar</samp>’. </p> </dd> <dt id="$(join list1,list2)"><code>$(join <var>list1</var>,<var>list2</var>)</code></dt> <dd>
+ <p>Concatenates the two arguments word by word: the two first words (one from each argument) concatenated form the first word of the result, the two second words form the second word of the result, and so on. So the <var>n</var>th word of the result comes from the <var>n</var>th word of each argument. If one argument has more words that the other, the extra words are copied unchanged into the result. </p> <p>For example, ‘<samp>$(join a b,.c .o)</samp>’ produces ‘<samp>a.c b.o</samp>’. </p> <p>Whitespace between the words in the lists is not preserved; it is replaced with a single space. </p> <p>This function can merge the results of the <code>dir</code> and <code>notdir</code> functions, to produce the original list of files which was given to those two functions. </p> </dd> <dt id="$(wildcard pattern)"><code>$(wildcard <var>pattern</var>)</code></dt> <dd>
+ <p>The argument <var>pattern</var> is a file name pattern, typically containing wildcard characters (as in shell file name patterns). The result of <code>wildcard</code> is a space-separated list of the names of existing files that match the pattern. See <a href="wildcards">Using Wildcard Characters in File Names</a>. </p> </dd> <dt id="$(realpath names…)"><code>$(realpath <var>names</var>…)</code></dt> <dd>
+ <p>For each file name in <var>names</var> return the canonical absolute name. A canonical name does not contain any <code>.</code> or <code>..</code> components, nor any repeated path separators (<code>/</code>) or symlinks. In case of a failure the empty string is returned. Consult the <code>realpath(3)</code> documentation for a list of possible failure causes. </p> </dd> <dt id="$(abspath names…)"><code>$(abspath <var>names</var>…)</code></dt> <dd>
+ <p>For each file name in <var>names</var> return an absolute name that does not contain any <code>.</code> or <code>..</code> components, nor any repeated path separators (<code>/</code>). Note that, in contrast to <code>realpath</code> function, <code>abspath</code> does not resolve symlinks and does not require the file names to refer to an existing file or directory. Use the <code>wildcard</code> function to test for existence. </p>
+</dd> </dl><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/File-Name-Functions.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html</a>
+ </p>
+</div>