-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile-Name-Functions.html
More file actions
136 lines (105 loc) · 5.82 KB
/
File-Name-Functions.html
File metadata and controls
136 lines (105 loc) · 5.82 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<html lang="en">
<head>
<title>GNU `make'</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU `make'">
<meta name="generator" content="makeinfo 4.3">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
</head>
<body>
<div class="node">
<p>
Node:<a name="File%20Name%20Functions">File Name Functions</a>,
Next:<a rel="next" accesskey="n" href="Foreach-Function.html#Foreach%20Function">Foreach Function</a>,
Previous:<a rel="previous" accesskey="p" href="Text-Functions.html#Text%20Functions">Text Functions</a>,
Up:<a rel="up" accesskey="u" href="Functions.html#Functions">Functions</a>
<hr><br>
</div>
<h3 class="section">Functions for File Names</h3>
<p>Several of the built-in expansion functions relate specifically to
taking apart file names or lists of file names.
<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.
<dl>
<dt><code>$(dir </code><var>names</var><code>...)</code>
<dd>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 <code>./</code>. For example,
<pre class="example"> $(dir src/foo.c hacks)
</pre>
<p>produces the result <code>src/ ./</code>.
<br><dt><code>$(notdir </code><var>names</var><code>...)</code>
<dd>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>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>For example,
<pre class="example"> $(notdir src/foo.c hacks)
</pre>
<p>produces the result <code>foo.c hacks</code>.
<br><dt><code>$(suffix </code><var>names</var><code>...)</code>
<dd>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>For example,
<pre class="example"> $(suffix src/foo.c src-1.0/bar.c hacks)
</pre>
<p>produces the result <code>.c .c</code>.
<br><dt><code>$(basename </code><var>names</var><code>...)</code>
<dd>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,
<pre class="example"> $(basename src/foo.c src-1.0/bar hacks)
</pre>
<p>produces the result <code>src/foo src-1.0/bar hacks</code>.
<br><dt><code>$(addsuffix </code><var>suffix</var><code>,</code><var>names</var><code>...)</code>
<dd>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,
<pre class="example"> $(addsuffix .c,foo bar)
</pre>
<p>produces the result <code>foo.c bar.c</code>.
<br><dt><code>$(addprefix </code><var>prefix</var><code>,</code><var>names</var><code>...)</code>
<dd>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,
<pre class="example"> $(addprefix src/,foo bar)
</pre>
<p>produces the result <code>src/foo src/bar</code>.
<br><dt><code>$(join </code><var>list1</var><code>,</code><var>list2</var><code>)</code>
<dd>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>For example, <code>$(join a b,.c .o)</code> produces <code>a.c b.o</code>.
<p>Whitespace between the words in the lists is not preserved; it is
replaced with a single space.
<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.
<br><dt><code>$(wildcard </code><var>pattern</var><code>)</code>
<dd>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.html#Wildcards">Using Wildcard Characters in File Names</a>.
</dl>
</body></html>