| @@ -1,2069 +1,2072 @@ | | | @@ -1,2069 +1,2072 @@ |
1 | .\" $NetBSD: make.1,v 1.197 2011/11/13 18:18:35 dholland Exp $ | | 1 | .\" $NetBSD: make.1,v 1.198 2011/12/17 04:43:45 sjg Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 1990, 1993 | | 3 | .\" Copyright (c) 1990, 1993 |
4 | .\" The Regents of the University of California. All rights reserved. | | 4 | .\" The Regents of the University of California. All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" Redistribution and use in source and binary forms, with or without | | 6 | .\" Redistribution and use in source and binary forms, with or without |
7 | .\" modification, are permitted provided that the following conditions | | 7 | .\" modification, are permitted provided that the following conditions |
8 | .\" are met: | | 8 | .\" are met: |
9 | .\" 1. Redistributions of source code must retain the above copyright | | 9 | .\" 1. Redistributions of source code must retain the above copyright |
10 | .\" notice, this list of conditions and the following disclaimer. | | 10 | .\" notice, this list of conditions and the following disclaimer. |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright |
12 | .\" notice, this list of conditions and the following disclaimer in the | | 12 | .\" notice, this list of conditions and the following disclaimer in the |
13 | .\" documentation and/or other materials provided with the distribution. | | 13 | .\" documentation and/or other materials provided with the distribution. |
14 | .\" 3. Neither the name of the University nor the names of its contributors | | 14 | .\" 3. Neither the name of the University nor the names of its contributors |
15 | .\" may be used to endorse or promote products derived from this software | | 15 | .\" may be used to endorse or promote products derived from this software |
16 | .\" without specific prior written permission. | | 16 | .\" without specific prior written permission. |
17 | .\" | | 17 | .\" |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 | .\" SUCH DAMAGE. | | 28 | .\" SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 | | 30 | .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 |
31 | .\" | | 31 | .\" |
32 | .Dd November 6, 2011 | | 32 | .Dd December 16, 2011 |
33 | .Dt MAKE 1 | | 33 | .Dt MAKE 1 |
34 | .Os | | 34 | .Os |
35 | .Sh NAME | | 35 | .Sh NAME |
36 | .Nm make | | 36 | .Nm make |
37 | .Nd maintain program dependencies | | 37 | .Nd maintain program dependencies |
38 | .Sh SYNOPSIS | | 38 | .Sh SYNOPSIS |
39 | .Nm | | 39 | .Nm |
40 | .Op Fl BeikNnqrstWX | | 40 | .Op Fl BeikNnqrstWX |
41 | .Bk -words | | 41 | .Bk -words |
42 | .Op Fl C Ar directory | | 42 | .Op Fl C Ar directory |
43 | .Ek | | 43 | .Ek |
44 | .Bk -words | | 44 | .Bk -words |
45 | .Op Fl D Ar variable | | 45 | .Op Fl D Ar variable |
46 | .Ek | | 46 | .Ek |
47 | .Bk -words | | 47 | .Bk -words |
48 | .Op Fl d Ar flags | | 48 | .Op Fl d Ar flags |
49 | .Ek | | 49 | .Ek |
50 | .Bk -words | | 50 | .Bk -words |
51 | .Op Fl f Ar makefile | | 51 | .Op Fl f Ar makefile |
52 | .Ek | | 52 | .Ek |
53 | .Bk -words | | 53 | .Bk -words |
54 | .Op Fl I Ar directory | | 54 | .Op Fl I Ar directory |
55 | .Ek | | 55 | .Ek |
56 | .Bk -words | | 56 | .Bk -words |
57 | .Op Fl J Ar private | | 57 | .Op Fl J Ar private |
58 | .Ek | | 58 | .Ek |
59 | .Bk -words | | 59 | .Bk -words |
60 | .Op Fl j Ar max_jobs | | 60 | .Op Fl j Ar max_jobs |
61 | .Ek | | 61 | .Ek |
62 | .Bk -words | | 62 | .Bk -words |
63 | .Op Fl m Ar directory | | 63 | .Op Fl m Ar directory |
64 | .Ek | | 64 | .Ek |
65 | .Bk -words | | 65 | .Bk -words |
66 | .Op Fl T Ar file | | 66 | .Op Fl T Ar file |
67 | .Ek | | 67 | .Ek |
68 | .Bk -words | | 68 | .Bk -words |
69 | .Op Fl V Ar variable | | 69 | .Op Fl V Ar variable |
70 | .Ek | | 70 | .Ek |
71 | .Op Ar variable=value | | 71 | .Op Ar variable=value |
72 | .Bk -words | | 72 | .Bk -words |
73 | .Op Ar target ... | | 73 | .Op Ar target ... |
74 | .Ek | | 74 | .Ek |
75 | .Sh DESCRIPTION | | 75 | .Sh DESCRIPTION |
76 | .Nm | | 76 | .Nm |
77 | is a program designed to simplify the maintenance of other programs. | | 77 | is a program designed to simplify the maintenance of other programs. |
78 | Its input is a list of specifications as to the files upon which programs | | 78 | Its input is a list of specifications as to the files upon which programs |
79 | and other files depend. | | 79 | and other files depend. |
80 | If no | | 80 | If no |
81 | .Fl f Ar makefile | | 81 | .Fl f Ar makefile |
82 | makefile option is given, | | 82 | makefile option is given, |
83 | .Nm | | 83 | .Nm |
84 | will try to open | | 84 | will try to open |
85 | .Ql Pa makefile | | 85 | .Ql Pa makefile |
86 | then | | 86 | then |
87 | .Ql Pa Makefile | | 87 | .Ql Pa Makefile |
88 | in order to find the specifications. | | 88 | in order to find the specifications. |
89 | If the file | | 89 | If the file |
90 | .Ql Pa .depend | | 90 | .Ql Pa .depend |
91 | exists, it is read (see | | 91 | exists, it is read (see |
92 | .Xr mkdep 1 ) . | | 92 | .Xr mkdep 1 ) . |
93 | .Pp | | 93 | .Pp |
94 | This manual page is intended as a reference document only. | | 94 | This manual page is intended as a reference document only. |
95 | For a more thorough description of | | 95 | For a more thorough description of |
96 | .Nm | | 96 | .Nm |
97 | and makefiles, please refer to | | 97 | and makefiles, please refer to |
98 | .%T "PMake \- A Tutorial" . | | 98 | .%T "PMake \- A Tutorial" . |
99 | .Pp | | 99 | .Pp |
100 | .Nm | | 100 | .Nm |
101 | will prepend the contents of the | | 101 | will prepend the contents of the |
102 | .Va MAKEFLAGS | | 102 | .Va MAKEFLAGS |
103 | environment variable to the command line arguments before parsing them. | | 103 | environment variable to the command line arguments before parsing them. |
104 | .Pp | | 104 | .Pp |
105 | The options are as follows: | | 105 | The options are as follows: |
106 | .Bl -tag -width Ds | | 106 | .Bl -tag -width Ds |
107 | .It Fl B | | 107 | .It Fl B |
108 | Try to be backwards compatible by executing a single shell per command and | | 108 | Try to be backwards compatible by executing a single shell per command and |
109 | by executing the commands to make the sources of a dependency line in sequence. | | 109 | by executing the commands to make the sources of a dependency line in sequence. |
110 | .It Fl C Ar directory | | 110 | .It Fl C Ar directory |
111 | Change to | | 111 | Change to |
112 | .Ar directory | | 112 | .Ar directory |
113 | before reading the makefiles or doing anything else. | | 113 | before reading the makefiles or doing anything else. |
114 | If multiple | | 114 | If multiple |
115 | .Fl C | | 115 | .Fl C |
116 | options are specified, each is interpreted relative to the previous one: | | 116 | options are specified, each is interpreted relative to the previous one: |
117 | .Fl C Pa / Fl C Pa etc | | 117 | .Fl C Pa / Fl C Pa etc |
118 | is equivalent to | | 118 | is equivalent to |
119 | .Fl C Pa /etc . | | 119 | .Fl C Pa /etc . |
120 | .It Fl D Ar variable | | 120 | .It Fl D Ar variable |
121 | Define | | 121 | Define |
122 | .Ar variable | | 122 | .Ar variable |
123 | to be 1, in the global context. | | 123 | to be 1, in the global context. |
124 | .It Fl d Ar [-]flags | | 124 | .It Fl d Ar [-]flags |
125 | Turn on debugging, and specify which portions of | | 125 | Turn on debugging, and specify which portions of |
126 | .Nm | | 126 | .Nm |
127 | are to print debugging information. | | 127 | are to print debugging information. |
128 | Unless the flags are preceded by | | 128 | Unless the flags are preceded by |
129 | .Ql \- | | 129 | .Ql \- |
130 | they are added to the | | 130 | they are added to the |
131 | .Va MAKEFLAGS | | 131 | .Va MAKEFLAGS |
132 | environment variable and will be processed by any child make processes. | | 132 | environment variable and will be processed by any child make processes. |
133 | By default, debugging information is printed to standard error, | | 133 | By default, debugging information is printed to standard error, |
134 | but this can be changed using the | | 134 | but this can be changed using the |
135 | .Ar F | | 135 | .Ar F |
136 | debugging flag. | | 136 | debugging flag. |
137 | The debugging output is always unbuffered; in addition, if debugging | | 137 | The debugging output is always unbuffered; in addition, if debugging |
138 | is enabled but debugging output is not directed to standard output, | | 138 | is enabled but debugging output is not directed to standard output, |
139 | then the standard output is line buffered. | | 139 | then the standard output is line buffered. |
140 | .Ar Flags | | 140 | .Ar Flags |
141 | is one or more of the following: | | 141 | is one or more of the following: |
142 | .Bl -tag -width Ds | | 142 | .Bl -tag -width Ds |
143 | .It Ar A | | 143 | .It Ar A |
144 | Print all possible debugging information; | | 144 | Print all possible debugging information; |
145 | equivalent to specifying all of the debugging flags. | | 145 | equivalent to specifying all of the debugging flags. |
146 | .It Ar a | | 146 | .It Ar a |
147 | Print debugging information about archive searching and caching. | | 147 | Print debugging information about archive searching and caching. |
148 | .It Ar C | | 148 | .It Ar C |
149 | Print debugging information about current working directory. | | 149 | Print debugging information about current working directory. |
150 | .It Ar c | | 150 | .It Ar c |
151 | Print debugging information about conditional evaluation. | | 151 | Print debugging information about conditional evaluation. |
152 | .It Ar d | | 152 | .It Ar d |
153 | Print debugging information about directory searching and caching. | | 153 | Print debugging information about directory searching and caching. |
154 | .It Ar e | | 154 | .It Ar e |
155 | Print debugging information about failed commands and targets. | | 155 | Print debugging information about failed commands and targets. |
156 | .It Ar F Ns Oo Sy \&+ Oc Ns Ar filename | | 156 | .It Ar F Ns Oo Sy \&+ Oc Ns Ar filename |
157 | Specify where debugging output is written. | | 157 | Specify where debugging output is written. |
158 | This must be the last flag, because it consumes the remainder of | | 158 | This must be the last flag, because it consumes the remainder of |
159 | the argument. | | 159 | the argument. |
160 | If the character immediately after the | | 160 | If the character immediately after the |
161 | .Ql F | | 161 | .Ql F |
162 | flag is | | 162 | flag is |
163 | .Ql \&+ , | | 163 | .Ql \&+ , |
164 | then the file will be opened in append mode; | | 164 | then the file will be opened in append mode; |
165 | otherwise the file will be overwritten. | | 165 | otherwise the file will be overwritten. |
166 | If the file name is | | 166 | If the file name is |
167 | .Ql stdout | | 167 | .Ql stdout |
168 | or | | 168 | or |
169 | .Ql stderr | | 169 | .Ql stderr |
170 | then debugging output will be written to the | | 170 | then debugging output will be written to the |
171 | standard output or standard error output file descriptors respectively | | 171 | standard output or standard error output file descriptors respectively |
172 | (and the | | 172 | (and the |
173 | .Ql \&+ | | 173 | .Ql \&+ |
174 | option has no effect). | | 174 | option has no effect). |
175 | Otherwise, the output will be written to the named file. | | 175 | Otherwise, the output will be written to the named file. |
176 | If the file name ends | | 176 | If the file name ends |
177 | .Ql .%d | | 177 | .Ql .%d |
178 | then the | | 178 | then the |
179 | .Ql %d | | 179 | .Ql %d |
180 | is replaced by the pid. | | 180 | is replaced by the pid. |
181 | .It Ar f | | 181 | .It Ar f |
182 | Print debugging information about loop evaluation. | | 182 | Print debugging information about loop evaluation. |
183 | .It Ar "g1" | | 183 | .It Ar "g1" |
184 | Print the input graph before making anything. | | 184 | Print the input graph before making anything. |
185 | .It Ar "g2" | | 185 | .It Ar "g2" |
186 | Print the input graph after making everything, or before exiting | | 186 | Print the input graph after making everything, or before exiting |
187 | on error. | | 187 | on error. |
188 | .It Ar "g3" | | 188 | .It Ar "g3" |
189 | Print the input graph before exiting on error. | | 189 | Print the input graph before exiting on error. |
190 | .It Ar j | | 190 | .It Ar j |
191 | Print debugging information about running multiple shells. | | 191 | Print debugging information about running multiple shells. |
192 | .It Ar l | | 192 | .It Ar l |
193 | Print commands in Makefiles regardless of whether or not they are prefixed by | | 193 | Print commands in Makefiles regardless of whether or not they are prefixed by |
194 | .Ql @ | | 194 | .Ql @ |
195 | or other "quiet" flags. | | 195 | or other "quiet" flags. |
196 | Also known as "loud" behavior. | | 196 | Also known as "loud" behavior. |
197 | .It Ar M | | 197 | .It Ar M |
198 | Print debugging information about "meta" mode decisions about targets. | | 198 | Print debugging information about "meta" mode decisions about targets. |
199 | .It Ar m | | 199 | .It Ar m |
200 | Print debugging information about making targets, including modification | | 200 | Print debugging information about making targets, including modification |
201 | dates. | | 201 | dates. |
202 | .It Ar n | | 202 | .It Ar n |
203 | Don't delete the temporary command scripts created when running commands. | | 203 | Don't delete the temporary command scripts created when running commands. |
204 | These temporary scripts are created in the directory | | 204 | These temporary scripts are created in the directory |
205 | referred to by the | | 205 | referred to by the |
206 | .Ev TMPDIR | | 206 | .Ev TMPDIR |
207 | environment variable, or in | | 207 | environment variable, or in |
208 | .Pa /tmp | | 208 | .Pa /tmp |
209 | if | | 209 | if |
210 | .Ev TMPDIR | | 210 | .Ev TMPDIR |
211 | is unset or set to the empty string. | | 211 | is unset or set to the empty string. |
212 | The temporary scripts are created by | | 212 | The temporary scripts are created by |
213 | .Xr mkstemp 3 , | | 213 | .Xr mkstemp 3 , |
214 | and have names of the form | | 214 | and have names of the form |
215 | .Pa makeXXXXXX . | | 215 | .Pa makeXXXXXX . |
216 | .Em NOTE : | | 216 | .Em NOTE : |
217 | This can create many files in | | 217 | This can create many files in |
218 | .Ev TMPDIR | | 218 | .Ev TMPDIR |
219 | or | | 219 | or |
220 | .Pa /tmp , | | 220 | .Pa /tmp , |
221 | so use with care. | | 221 | so use with care. |
222 | .It Ar p | | 222 | .It Ar p |
223 | Print debugging information about makefile parsing. | | 223 | Print debugging information about makefile parsing. |
224 | .It Ar s | | 224 | .It Ar s |
225 | Print debugging information about suffix-transformation rules. | | 225 | Print debugging information about suffix-transformation rules. |
226 | .It Ar t | | 226 | .It Ar t |
227 | Print debugging information about target list maintenance. | | 227 | Print debugging information about target list maintenance. |
228 | .It Ar v | | 228 | .It Ar v |
229 | Print debugging information about variable assignment. | | 229 | Print debugging information about variable assignment. |
230 | .It Ar x | | 230 | .It Ar x |
231 | Run shell commands with | | 231 | Run shell commands with |
232 | .Fl x | | 232 | .Fl x |
233 | so the actual commands are printed as they are executed. | | 233 | so the actual commands are printed as they are executed. |
234 | .El | | 234 | .El |
235 | .It Fl e | | 235 | .It Fl e |
236 | Specify that environment variables override macro assignments within | | 236 | Specify that environment variables override macro assignments within |
237 | makefiles. | | 237 | makefiles. |
238 | .It Fl f Ar makefile | | 238 | .It Fl f Ar makefile |
239 | Specify a makefile to read instead of the default | | 239 | Specify a makefile to read instead of the default |
240 | .Ql Pa makefile . | | 240 | .Ql Pa makefile . |
241 | If | | 241 | If |
242 | .Ar makefile | | 242 | .Ar makefile |
243 | is | | 243 | is |
244 | .Ql Fl , | | 244 | .Ql Fl , |
245 | standard input is read. | | 245 | standard input is read. |
246 | Multiple makefiles may be specified, and are read in the order specified. | | 246 | Multiple makefiles may be specified, and are read in the order specified. |
247 | .It Fl I Ar directory | | 247 | .It Fl I Ar directory |
248 | Specify a directory in which to search for makefiles and included makefiles. | | 248 | Specify a directory in which to search for makefiles and included makefiles. |
249 | The system makefile directory (or directories, see the | | 249 | The system makefile directory (or directories, see the |
250 | .Fl m | | 250 | .Fl m |
251 | option) is automatically included as part of this list. | | 251 | option) is automatically included as part of this list. |
252 | .It Fl i | | 252 | .It Fl i |
253 | Ignore non-zero exit of shell commands in the makefile. | | 253 | Ignore non-zero exit of shell commands in the makefile. |
254 | Equivalent to specifying | | 254 | Equivalent to specifying |
255 | .Ql Fl | | 255 | .Ql Fl |
256 | before each command line in the makefile. | | 256 | before each command line in the makefile. |
257 | .It Fl J Ar private | | 257 | .It Fl J Ar private |
258 | This option should | | 258 | This option should |
259 | .Em not | | 259 | .Em not |
260 | be specified by the user. | | 260 | be specified by the user. |
261 | .Pp | | 261 | .Pp |
262 | When the | | 262 | When the |
263 | .Ar j | | 263 | .Ar j |
264 | option is in use in a recursive build, this option is passed by a make | | 264 | option is in use in a recursive build, this option is passed by a make |
265 | to child makes to allow all the make processes in the build to | | 265 | to child makes to allow all the make processes in the build to |
266 | cooperate to avoid overloading the system. | | 266 | cooperate to avoid overloading the system. |
267 | .It Fl j Ar max_jobs | | 267 | .It Fl j Ar max_jobs |
268 | Specify the maximum number of jobs that | | 268 | Specify the maximum number of jobs that |
269 | .Nm | | 269 | .Nm |
270 | may have running at any one time. | | 270 | may have running at any one time. |
271 | The value is saved in | | 271 | The value is saved in |
272 | .Va .MAKE.JOBS . | | 272 | .Va .MAKE.JOBS . |
273 | Turns compatibility mode off, unless the | | 273 | Turns compatibility mode off, unless the |
274 | .Ar B | | 274 | .Ar B |
275 | flag is also specified. | | 275 | flag is also specified. |
276 | When compatibility mode is off, all commands associated with a | | 276 | When compatibility mode is off, all commands associated with a |
277 | target are executed in a single shell invocation as opposed to the | | 277 | target are executed in a single shell invocation as opposed to the |
278 | traditional one shell invocation per line. | | 278 | traditional one shell invocation per line. |
279 | This can break traditional scripts which change directories on each | | 279 | This can break traditional scripts which change directories on each |
280 | command invocation and then expect to start with a fresh environment | | 280 | command invocation and then expect to start with a fresh environment |
281 | on the next line. | | 281 | on the next line. |
282 | It is more efficient to correct the scripts rather than turn backwards | | 282 | It is more efficient to correct the scripts rather than turn backwards |
283 | compatibility on. | | 283 | compatibility on. |
284 | .It Fl k | | 284 | .It Fl k |
285 | Continue processing after errors are encountered, but only on those targets | | 285 | Continue processing after errors are encountered, but only on those targets |
286 | that do not depend on the target whose creation caused the error. | | 286 | that do not depend on the target whose creation caused the error. |
287 | .It Fl m Ar directory | | 287 | .It Fl m Ar directory |
288 | Specify a directory in which to search for sys.mk and makefiles included | | 288 | Specify a directory in which to search for sys.mk and makefiles included |
289 | via the | | 289 | via the |
290 | .Ao Ar file Ac Ns -style | | 290 | .Ao Ar file Ac Ns -style |
291 | include statement. | | 291 | include statement. |
292 | The | | 292 | The |
293 | .Fl m | | 293 | .Fl m |
294 | option can be used multiple times to form a search path. | | 294 | option can be used multiple times to form a search path. |
295 | This path will override the default system include path: /usr/share/mk. | | 295 | This path will override the default system include path: /usr/share/mk. |
296 | Furthermore the system include path will be appended to the search path used | | 296 | Furthermore the system include path will be appended to the search path used |
297 | for | | 297 | for |
298 | .Qo Ar file Qc Ns -style | | 298 | .Qo Ar file Qc Ns -style |
299 | include statements (see the | | 299 | include statements (see the |
300 | .Fl I | | 300 | .Fl I |
301 | option). | | 301 | option). |
302 | .Pp | | 302 | .Pp |
303 | If a file or directory name in the | | 303 | If a file or directory name in the |
304 | .Fl m | | 304 | .Fl m |
305 | argument (or the | | 305 | argument (or the |
306 | .Ev MAKESYSPATH | | 306 | .Ev MAKESYSPATH |
307 | environment variable) starts with the string | | 307 | environment variable) starts with the string |
308 | .Qq \&.../ | | 308 | .Qq \&.../ |
309 | then | | 309 | then |
310 | .Nm | | 310 | .Nm |
311 | will search for the specified file or directory named in the remaining part | | 311 | will search for the specified file or directory named in the remaining part |
312 | of the argument string. | | 312 | of the argument string. |
313 | The search starts with the current directory of | | 313 | The search starts with the current directory of |
314 | the Makefile and then works upward towards the root of the filesystem. | | 314 | the Makefile and then works upward towards the root of the filesystem. |
315 | If the search is successful, then the resulting directory replaces the | | 315 | If the search is successful, then the resulting directory replaces the |
316 | .Qq \&.../ | | 316 | .Qq \&.../ |
317 | specification in the | | 317 | specification in the |
318 | .Fl m | | 318 | .Fl m |
319 | argument. | | 319 | argument. |
320 | If used, this feature allows | | 320 | If used, this feature allows |
321 | .Nm | | 321 | .Nm |
322 | to easily search in the current source tree for customized sys.mk files | | 322 | to easily search in the current source tree for customized sys.mk files |
323 | (e.g., by using | | 323 | (e.g., by using |
324 | .Qq \&.../mk/sys.mk | | 324 | .Qq \&.../mk/sys.mk |
325 | as an argument). | | 325 | as an argument). |
326 | .It Fl n | | 326 | .It Fl n |
327 | Display the commands that would have been executed, but do not | | 327 | Display the commands that would have been executed, but do not |
328 | actually execute them unless the target depends on the .MAKE special | | 328 | actually execute them unless the target depends on the .MAKE special |
329 | source (see below). | | 329 | source (see below). |
330 | .It Fl N | | 330 | .It Fl N |
331 | Display the commands which would have been executed, but do not | | 331 | Display the commands which would have been executed, but do not |
332 | actually execute any of them; useful for debugging top-level makefiles | | 332 | actually execute any of them; useful for debugging top-level makefiles |
333 | without descending into subdirectories. | | 333 | without descending into subdirectories. |
334 | .It Fl q | | 334 | .It Fl q |
335 | Do not execute any commands, but exit 0 if the specified targets are | | 335 | Do not execute any commands, but exit 0 if the specified targets are |
336 | up-to-date and 1, otherwise. | | 336 | up-to-date and 1, otherwise. |
337 | .It Fl r | | 337 | .It Fl r |
338 | Do not use the built-in rules specified in the system makefile. | | 338 | Do not use the built-in rules specified in the system makefile. |
339 | .It Fl s | | 339 | .It Fl s |
340 | Do not echo any commands as they are executed. | | 340 | Do not echo any commands as they are executed. |
341 | Equivalent to specifying | | 341 | Equivalent to specifying |
342 | .Ql Ic @ | | 342 | .Ql Ic @ |
343 | before each command line in the makefile. | | 343 | before each command line in the makefile. |
344 | .It Fl T Ar tracefile | | 344 | .It Fl T Ar tracefile |
345 | When used with the | | 345 | When used with the |
346 | .Fl j | | 346 | .Fl j |
347 | flag, | | 347 | flag, |
348 | append a trace record to | | 348 | append a trace record to |
349 | .Ar tracefile | | 349 | .Ar tracefile |
350 | for each job started and completed. | | 350 | for each job started and completed. |
351 | .It Fl t | | 351 | .It Fl t |
352 | Rather than re-building a target as specified in the makefile, create it | | 352 | Rather than re-building a target as specified in the makefile, create it |
353 | or update its modification time to make it appear up-to-date. | | 353 | or update its modification time to make it appear up-to-date. |
354 | .It Fl V Ar variable | | 354 | .It Fl V Ar variable |
355 | Print | | 355 | Print |
356 | .Nm Ns 's | | 356 | .Nm Ns 's |
357 | idea of the value of | | 357 | idea of the value of |
358 | .Ar variable , | | 358 | .Ar variable , |
359 | in the global context. | | 359 | in the global context. |
360 | Do not build any targets. | | 360 | Do not build any targets. |
361 | Multiple instances of this option may be specified; | | 361 | Multiple instances of this option may be specified; |
362 | the variables will be printed one per line, | | 362 | the variables will be printed one per line, |
363 | with a blank line for each null or undefined variable. | | 363 | with a blank line for each null or undefined variable. |
364 | If | | 364 | If |
365 | .Ar variable | | 365 | .Ar variable |
366 | contains a | | 366 | contains a |
367 | .Ql \&$ | | 367 | .Ql \&$ |
368 | then the value will be expanded before printing. | | 368 | then the value will be expanded before printing. |
369 | .It Fl W | | 369 | .It Fl W |
370 | Treat any warnings during makefile parsing as errors. | | 370 | Treat any warnings during makefile parsing as errors. |
371 | .It Fl X | | 371 | .It Fl X |
372 | Don't export variables passed on the command line to the environment | | 372 | Don't export variables passed on the command line to the environment |
373 | individually. | | 373 | individually. |
374 | Variables passed on the command line are still exported | | 374 | Variables passed on the command line are still exported |
375 | via the | | 375 | via the |
376 | .Va MAKEFLAGS | | 376 | .Va MAKEFLAGS |
377 | environment variable. | | 377 | environment variable. |
378 | This option may be useful on systems which have a small limit on the | | 378 | This option may be useful on systems which have a small limit on the |
379 | size of command arguments. | | 379 | size of command arguments. |
380 | .It Ar variable=value | | 380 | .It Ar variable=value |
381 | Set the value of the variable | | 381 | Set the value of the variable |
382 | .Ar variable | | 382 | .Ar variable |
383 | to | | 383 | to |
384 | .Ar value . | | 384 | .Ar value . |
385 | Normally, all values passed on the command line are also exported to | | 385 | Normally, all values passed on the command line are also exported to |
386 | sub-makes in the environment. | | 386 | sub-makes in the environment. |
387 | The | | 387 | The |
388 | .Fl X | | 388 | .Fl X |
389 | flag disables this behavior. | | 389 | flag disables this behavior. |
390 | Variable assignments should follow options for POSIX compatibility | | 390 | Variable assignments should follow options for POSIX compatibility |
391 | but no ordering is enforced. | | 391 | but no ordering is enforced. |
392 | .El | | 392 | .El |
393 | .Pp | | 393 | .Pp |
394 | There are seven different types of lines in a makefile: file dependency | | 394 | There are seven different types of lines in a makefile: file dependency |
395 | specifications, shell commands, variable assignments, include statements, | | 395 | specifications, shell commands, variable assignments, include statements, |
396 | conditional directives, for loops, and comments. | | 396 | conditional directives, for loops, and comments. |
397 | .Pp | | 397 | .Pp |
398 | In general, lines may be continued from one line to the next by ending | | 398 | In general, lines may be continued from one line to the next by ending |
399 | them with a backslash | | 399 | them with a backslash |
400 | .Pq Ql \e . | | 400 | .Pq Ql \e . |
401 | The trailing newline character and initial whitespace on the following | | 401 | The trailing newline character and initial whitespace on the following |
402 | line are compressed into a single space. | | 402 | line are compressed into a single space. |
403 | .Sh FILE DEPENDENCY SPECIFICATIONS | | 403 | .Sh FILE DEPENDENCY SPECIFICATIONS |
404 | Dependency lines consist of one or more targets, an operator, and zero | | 404 | Dependency lines consist of one or more targets, an operator, and zero |
405 | or more sources. | | 405 | or more sources. |
406 | This creates a relationship where the targets | | 406 | This creates a relationship where the targets |
407 | .Dq depend | | 407 | .Dq depend |
408 | on the sources | | 408 | on the sources |
409 | and are usually created from them. | | 409 | and are usually created from them. |
410 | The exact relationship between the target and the source is determined | | 410 | The exact relationship between the target and the source is determined |
411 | by the operator that separates them. | | 411 | by the operator that separates them. |
412 | The three operators are as follows: | | 412 | The three operators are as follows: |
413 | .Bl -tag -width flag | | 413 | .Bl -tag -width flag |
414 | .It Ic \&: | | 414 | .It Ic \&: |
415 | A target is considered out-of-date if its modification time is less than | | 415 | A target is considered out-of-date if its modification time is less than |
416 | those of any of its sources. | | 416 | those of any of its sources. |
417 | Sources for a target accumulate over dependency lines when this operator | | 417 | Sources for a target accumulate over dependency lines when this operator |
418 | is used. | | 418 | is used. |
419 | The target is removed if | | 419 | The target is removed if |
420 | .Nm | | 420 | .Nm |
421 | is interrupted. | | 421 | is interrupted. |
422 | .It Ic \&! | | 422 | .It Ic \&! |
423 | Targets are always re-created, but not until all sources have been | | 423 | Targets are always re-created, but not until all sources have been |
424 | examined and re-created as necessary. | | 424 | examined and re-created as necessary. |
425 | Sources for a target accumulate over dependency lines when this operator | | 425 | Sources for a target accumulate over dependency lines when this operator |
426 | is used. | | 426 | is used. |
427 | The target is removed if | | 427 | The target is removed if |
428 | .Nm | | 428 | .Nm |
429 | is interrupted. | | 429 | is interrupted. |
430 | .It Ic \&:: | | 430 | .It Ic \&:: |
431 | If no sources are specified, the target is always re-created. | | 431 | If no sources are specified, the target is always re-created. |
432 | Otherwise, a target is considered out-of-date if any of its sources has | | 432 | Otherwise, a target is considered out-of-date if any of its sources has |
433 | been modified more recently than the target. | | 433 | been modified more recently than the target. |
434 | Sources for a target do not accumulate over dependency lines when this | | 434 | Sources for a target do not accumulate over dependency lines when this |
435 | operator is used. | | 435 | operator is used. |
436 | The target will not be removed if | | 436 | The target will not be removed if |
437 | .Nm | | 437 | .Nm |
438 | is interrupted. | | 438 | is interrupted. |
439 | .El | | 439 | .El |
440 | .Pp | | 440 | .Pp |
441 | Targets and sources may contain the shell wildcard values | | 441 | Targets and sources may contain the shell wildcard values |
442 | .Ql \&? , | | 442 | .Ql \&? , |
443 | .Ql * , | | 443 | .Ql * , |
444 | .Ql [] , | | 444 | .Ql [] , |
445 | and | | 445 | and |
446 | .Ql {} . | | 446 | .Ql {} . |
447 | The values | | 447 | The values |
448 | .Ql \&? , | | 448 | .Ql \&? , |
449 | .Ql * , | | 449 | .Ql * , |
450 | and | | 450 | and |
451 | .Ql [] | | 451 | .Ql [] |
452 | may only be used as part of the final | | 452 | may only be used as part of the final |
453 | component of the target or source, and must be used to describe existing | | 453 | component of the target or source, and must be used to describe existing |
454 | files. | | 454 | files. |
455 | The value | | 455 | The value |
456 | .Ql {} | | 456 | .Ql {} |
457 | need not necessarily be used to describe existing files. | | 457 | need not necessarily be used to describe existing files. |
458 | Expansion is in directory order, not alphabetically as done in the shell. | | 458 | Expansion is in directory order, not alphabetically as done in the shell. |
459 | .Sh SHELL COMMANDS | | 459 | .Sh SHELL COMMANDS |
460 | Each target may have associated with it a series of shell commands, normally | | 460 | Each target may have associated with it a series of shell commands, normally |
461 | used to create the target. | | 461 | used to create the target. |
462 | Each of the commands in this script | | 462 | Each of the commands in this script |
463 | .Em must | | 463 | .Em must |
464 | be preceded by a tab. | | 464 | be preceded by a tab. |
465 | While any target may appear on a dependency line, only one of these | | 465 | While any target may appear on a dependency line, only one of these |
466 | dependencies may be followed by a creation script, unless the | | 466 | dependencies may be followed by a creation script, unless the |
467 | .Ql Ic \&:: | | 467 | .Ql Ic \&:: |
468 | operator is used. | | 468 | operator is used. |
469 | .Pp | | 469 | .Pp |
470 | If the first characters of the command line are any combination of | | 470 | If the first characters of the command line are any combination of |
471 | .Ql Ic @ , | | 471 | .Ql Ic @ , |
472 | .Ql Ic + , | | 472 | .Ql Ic + , |
473 | or | | 473 | or |
474 | .Ql Ic \- , | | 474 | .Ql Ic \- , |
475 | the command is treated specially. | | 475 | the command is treated specially. |
476 | A | | 476 | A |
477 | .Ql Ic @ | | 477 | .Ql Ic @ |
478 | causes the command not to be echoed before it is executed. | | 478 | causes the command not to be echoed before it is executed. |
479 | A | | 479 | A |
480 | .Ql Ic + | | 480 | .Ql Ic + |
481 | causes the command to be executed even when | | 481 | causes the command to be executed even when |
482 | .Fl n | | 482 | .Fl n |
483 | is given. | | 483 | is given. |
484 | This is similar to the effect of the .MAKE special source, | | 484 | This is similar to the effect of the .MAKE special source, |
485 | except that the effect can be limited to a single line of a script. | | 485 | except that the effect can be limited to a single line of a script. |
486 | A | | 486 | A |
487 | .Ql Ic \- | | 487 | .Ql Ic \- |
488 | causes any non-zero exit status of the command line to be ignored. | | 488 | causes any non-zero exit status of the command line to be ignored. |
489 | .Sh VARIABLE ASSIGNMENTS | | 489 | .Sh VARIABLE ASSIGNMENTS |
490 | Variables in make are much like variables in the shell, and, by tradition, | | 490 | Variables in make are much like variables in the shell, and, by tradition, |
491 | consist of all upper-case letters. | | 491 | consist of all upper-case letters. |
492 | .Ss Variable assignment modifiers | | 492 | .Ss Variable assignment modifiers |
493 | The five operators that can be used to assign values to variables are as | | 493 | The five operators that can be used to assign values to variables are as |
494 | follows: | | 494 | follows: |
495 | .Bl -tag -width Ds | | 495 | .Bl -tag -width Ds |
496 | .It Ic \&= | | 496 | .It Ic \&= |
497 | Assign the value to the variable. | | 497 | Assign the value to the variable. |
498 | Any previous value is overridden. | | 498 | Any previous value is overridden. |
499 | .It Ic \&+= | | 499 | .It Ic \&+= |
500 | Append the value to the current value of the variable. | | 500 | Append the value to the current value of the variable. |
501 | .It Ic \&?= | | 501 | .It Ic \&?= |
502 | Assign the value to the variable if it is not already defined. | | 502 | Assign the value to the variable if it is not already defined. |
503 | .It Ic \&:= | | 503 | .It Ic \&:= |
504 | Assign with expansion, i.e. expand the value before assigning it | | 504 | Assign with expansion, i.e. expand the value before assigning it |
505 | to the variable. | | 505 | to the variable. |
506 | Normally, expansion is not done until the variable is referenced. | | 506 | Normally, expansion is not done until the variable is referenced. |
507 | .Em NOTE : | | 507 | .Em NOTE : |
508 | References to undefined variables are | | 508 | References to undefined variables are |
509 | .Em not | | 509 | .Em not |
510 | expanded. | | 510 | expanded. |
511 | This can cause problems when variable modifiers are used. | | 511 | This can cause problems when variable modifiers are used. |
512 | .It Ic \&!= | | 512 | .It Ic \&!= |
513 | Expand the value and pass it to the shell for execution and assign | | 513 | Expand the value and pass it to the shell for execution and assign |
514 | the result to the variable. | | 514 | the result to the variable. |
515 | Any newlines in the result are replaced with spaces. | | 515 | Any newlines in the result are replaced with spaces. |
516 | .El | | 516 | .El |
517 | .Pp | | 517 | .Pp |
518 | Any white-space before the assigned | | 518 | Any white-space before the assigned |
519 | .Ar value | | 519 | .Ar value |
520 | is removed; if the value is being appended, a single space is inserted | | 520 | is removed; if the value is being appended, a single space is inserted |
521 | between the previous contents of the variable and the appended value. | | 521 | between the previous contents of the variable and the appended value. |
522 | .Pp | | 522 | .Pp |
523 | Variables are expanded by surrounding the variable name with either | | 523 | Variables are expanded by surrounding the variable name with either |
524 | curly braces | | 524 | curly braces |
525 | .Pq Ql {} | | 525 | .Pq Ql {} |
526 | or parentheses | | 526 | or parentheses |
527 | .Pq Ql () | | 527 | .Pq Ql () |
528 | and preceding it with | | 528 | and preceding it with |
529 | a dollar sign | | 529 | a dollar sign |
530 | .Pq Ql \&$ . | | 530 | .Pq Ql \&$ . |
531 | If the variable name contains only a single letter, the surrounding | | 531 | If the variable name contains only a single letter, the surrounding |
532 | braces or parentheses are not required. | | 532 | braces or parentheses are not required. |
533 | This shorter form is not recommended. | | 533 | This shorter form is not recommended. |
534 | .Pp | | 534 | .Pp |
535 | If the variable name contains a dollar, then the name itself is expanded first. | | 535 | If the variable name contains a dollar, then the name itself is expanded first. |
536 | This allows almost arbitrary variable names, however names containing dollar, | | 536 | This allows almost arbitrary variable names, however names containing dollar, |
537 | braces, parenthesis, or whitespace are really best avoided! | | 537 | braces, parenthesis, or whitespace are really best avoided! |
538 | .Pp | | 538 | .Pp |
539 | If the result of expanding a variable contains a dollar sign | | 539 | If the result of expanding a variable contains a dollar sign |
540 | .Pq Ql \&$ | | 540 | .Pq Ql \&$ |
541 | the string is expanded again. | | 541 | the string is expanded again. |
542 | .Pp | | 542 | .Pp |
543 | Variable substitution occurs at three distinct times, depending on where | | 543 | Variable substitution occurs at three distinct times, depending on where |
544 | the variable is being used. | | 544 | the variable is being used. |
545 | .Bl -enum | | 545 | .Bl -enum |
546 | .It | | 546 | .It |
547 | Variables in dependency lines are expanded as the line is read. | | 547 | Variables in dependency lines are expanded as the line is read. |
548 | .It | | 548 | .It |
549 | Variables in shell commands are expanded when the shell command is | | 549 | Variables in shell commands are expanded when the shell command is |
550 | executed. | | 550 | executed. |
551 | .It | | 551 | .It |
552 | .Dq .for | | 552 | .Dq .for |
553 | loop index variables are expanded on each loop iteration. | | 553 | loop index variables are expanded on each loop iteration. |
554 | Note that other variables are not expanded inside loops so | | 554 | Note that other variables are not expanded inside loops so |
555 | the following example code: | | 555 | the following example code: |
556 | .Bd -literal -offset indent | | 556 | .Bd -literal -offset indent |
557 | | | 557 | |
558 | .Dv .for i in 1 2 3 | | 558 | .Dv .for i in 1 2 3 |
559 | a+= ${i} | | 559 | a+= ${i} |
560 | j= ${i} | | 560 | j= ${i} |
561 | b+= ${j} | | 561 | b+= ${j} |
562 | .Dv .endfor | | 562 | .Dv .endfor |
563 | | | 563 | |
564 | all: | | 564 | all: |
565 | @echo ${a} | | 565 | @echo ${a} |
566 | @echo ${b} | | 566 | @echo ${b} |
567 | | | 567 | |
568 | .Ed | | 568 | .Ed |
569 | will print: | | 569 | will print: |
570 | .Bd -literal -offset indent | | 570 | .Bd -literal -offset indent |
571 | 1 2 3 | | 571 | 1 2 3 |
572 | 3 3 3 | | 572 | 3 3 3 |
573 | | | 573 | |
574 | .Ed | | 574 | .Ed |
575 | Because while ${a} contains | | 575 | Because while ${a} contains |
576 | .Dq 1 2 3 | | 576 | .Dq 1 2 3 |
577 | after the loop is executed, ${b} | | 577 | after the loop is executed, ${b} |
578 | contains | | 578 | contains |
579 | .Dq ${j} ${j} ${j} | | 579 | .Dq ${j} ${j} ${j} |
580 | which expands to | | 580 | which expands to |
581 | .Dq 3 3 3 | | 581 | .Dq 3 3 3 |
582 | since after the loop completes ${j} contains | | 582 | since after the loop completes ${j} contains |
583 | .Dq 3 . | | 583 | .Dq 3 . |
584 | .El | | 584 | .El |
585 | .Ss Variable classes | | 585 | .Ss Variable classes |
586 | The four different classes of variables (in order of increasing precedence) | | 586 | The four different classes of variables (in order of increasing precedence) |
587 | are: | | 587 | are: |
588 | .Bl -tag -width Ds | | 588 | .Bl -tag -width Ds |
589 | .It Environment variables | | 589 | .It Environment variables |
590 | Variables defined as part of | | 590 | Variables defined as part of |
591 | .Nm Ns 's | | 591 | .Nm Ns 's |
592 | environment. | | 592 | environment. |
593 | .It Global variables | | 593 | .It Global variables |
594 | Variables defined in the makefile or in included makefiles. | | 594 | Variables defined in the makefile or in included makefiles. |
595 | .It Command line variables | | 595 | .It Command line variables |
596 | Variables defined as part of the command line. | | 596 | Variables defined as part of the command line. |
597 | .It Local variables | | 597 | .It Local variables |
598 | Variables that are defined specific to a certain target. | | 598 | Variables that are defined specific to a certain target. |
599 | The seven local variables are as follows: | | 599 | The seven local variables are as follows: |
600 | .Bl -tag -width ".ARCHIVE" | | 600 | .Bl -tag -width ".ARCHIVE" |
601 | .It Va .ALLSRC | | 601 | .It Va .ALLSRC |
602 | The list of all sources for this target; also known as | | 602 | The list of all sources for this target; also known as |
603 | .Ql Va \&\*[Gt] . | | 603 | .Ql Va \&\*[Gt] . |
604 | .It Va .ARCHIVE | | 604 | .It Va .ARCHIVE |
605 | The name of the archive file. | | 605 | The name of the archive file. |
606 | .It Va .IMPSRC | | 606 | .It Va .IMPSRC |
607 | In suffix-transformation rules, the name/path of the source from which the | | 607 | In suffix-transformation rules, the name/path of the source from which the |
608 | target is to be transformed (the | | 608 | target is to be transformed (the |
609 | .Dq implied | | 609 | .Dq implied |
610 | source); also known as | | 610 | source); also known as |
611 | .Ql Va \&\*[Lt] . | | 611 | .Ql Va \&\*[Lt] . |
612 | It is not defined in explicit rules. | | 612 | It is not defined in explicit rules. |
613 | .It Va .MEMBER | | 613 | .It Va .MEMBER |
614 | The name of the archive member. | | 614 | The name of the archive member. |
615 | .It Va .OODATE | | 615 | .It Va .OODATE |
616 | The list of sources for this target that were deemed out-of-date; also | | 616 | The list of sources for this target that were deemed out-of-date; also |
617 | known as | | 617 | known as |
618 | .Ql Va \&? . | | 618 | .Ql Va \&? . |
619 | .It Va .PREFIX | | 619 | .It Va .PREFIX |
620 | The file prefix of the target, containing only the file portion, no suffix | | 620 | The file prefix of the target, containing only the file portion, no suffix |
621 | or preceding directory components; also known as | | 621 | or preceding directory components; also known as |
622 | .Ql Va * . | | 622 | .Ql Va * . |
623 | .It Va .TARGET | | 623 | .It Va .TARGET |
624 | The name of the target; also known as | | 624 | The name of the target; also known as |
625 | .Ql Va @ . | | 625 | .Ql Va @ . |
626 | .El | | 626 | .El |
627 | .Pp | | 627 | .Pp |
628 | The shorter forms | | 628 | The shorter forms |
629 | .Ql Va @ , | | 629 | .Ql Va @ , |
630 | .Ql Va \&? , | | 630 | .Ql Va \&? , |
631 | .Ql Va \&\*[Lt] , | | 631 | .Ql Va \&\*[Lt] , |
632 | .Ql Va \&\*[Gt] , | | 632 | .Ql Va \&\*[Gt] , |
633 | and | | 633 | and |
634 | .Ql Va * | | 634 | .Ql Va * |
635 | are permitted for backward | | 635 | are permitted for backward |
636 | compatibility with historical makefiles and are not recommended. | | 636 | compatibility with historical makefiles and are not recommended. |
637 | The six variables | | 637 | The six variables |
638 | .Ql Va "@F" , | | 638 | .Ql Va "@F" , |
639 | .Ql Va "@D" , | | 639 | .Ql Va "@D" , |
640 | .Ql Va "\*[Lt]F" , | | 640 | .Ql Va "\*[Lt]F" , |
641 | .Ql Va "\*[Lt]D" , | | 641 | .Ql Va "\*[Lt]D" , |
642 | .Ql Va "*F" , | | 642 | .Ql Va "*F" , |
643 | and | | 643 | and |
644 | .Ql Va "*D" | | 644 | .Ql Va "*D" |
645 | are permitted for compatibility with | | 645 | are permitted for compatibility with |
646 | .At V | | 646 | .At V |
647 | makefiles and are not recommended. | | 647 | makefiles and are not recommended. |
648 | .Pp | | 648 | .Pp |
649 | Four of the local variables may be used in sources on dependency lines | | 649 | Four of the local variables may be used in sources on dependency lines |
650 | because they expand to the proper value for each target on the line. | | 650 | because they expand to the proper value for each target on the line. |
651 | These variables are | | 651 | These variables are |
652 | .Ql Va .TARGET , | | 652 | .Ql Va .TARGET , |
653 | .Ql Va .PREFIX , | | 653 | .Ql Va .PREFIX , |
654 | .Ql Va .ARCHIVE , | | 654 | .Ql Va .ARCHIVE , |
655 | and | | 655 | and |
656 | .Ql Va .MEMBER . | | 656 | .Ql Va .MEMBER . |
657 | .El | | 657 | .El |
658 | .Ss Additional built-in variables | | 658 | .Ss Additional built-in variables |
659 | In addition, | | 659 | In addition, |
660 | .Nm | | 660 | .Nm |
661 | sets or knows about the following variables: | | 661 | sets or knows about the following variables: |
662 | .Bl -tag -width .MAKEOVERRIDES | | 662 | .Bl -tag -width .MAKEOVERRIDES |
663 | .It Va \&$ | | 663 | .It Va \&$ |
664 | A single dollar sign | | 664 | A single dollar sign |
665 | .Ql \&$ , | | 665 | .Ql \&$ , |
666 | i.e. | | 666 | i.e. |
667 | .Ql \&$$ | | 667 | .Ql \&$$ |
668 | expands to a single dollar | | 668 | expands to a single dollar |
669 | sign. | | 669 | sign. |
670 | .It Va .ALLTARGETS | | 670 | .It Va .ALLTARGETS |
671 | The list of all targets encountered in the Makefile. | | 671 | The list of all targets encountered in the Makefile. |
672 | If evaluated during | | 672 | If evaluated during |
673 | Makefile parsing, lists only those targets encountered thus far. | | 673 | Makefile parsing, lists only those targets encountered thus far. |
674 | .It Va .CURDIR | | 674 | .It Va .CURDIR |
675 | A path to the directory where | | 675 | A path to the directory where |
676 | .Nm | | 676 | .Nm |
677 | was executed. | | 677 | was executed. |
678 | Refer to the description of | | 678 | Refer to the description of |
679 | .Ql Ev PWD | | 679 | .Ql Ev PWD |
680 | for more details. | | 680 | for more details. |
681 | .It Ev MAKE | | 681 | .It Ev MAKE |
682 | The name that | | 682 | The name that |
683 | .Nm | | 683 | .Nm |
684 | was executed with | | 684 | was executed with |
685 | .Pq Va argv[0] . | | 685 | .Pq Va argv[0] . |
686 | For compatibility | | 686 | For compatibility |
687 | .Nm | | 687 | .Nm |
688 | also sets | | 688 | also sets |
689 | .Va .MAKE | | 689 | .Va .MAKE |
690 | with the same value. | | 690 | with the same value. |
691 | The preferred variable to use is the environment variable | | 691 | The preferred variable to use is the environment variable |
692 | .Ev MAKE | | 692 | .Ev MAKE |
693 | because it is more compatible with other versions of | | 693 | because it is more compatible with other versions of |
694 | .Nm | | 694 | .Nm |
695 | and cannot be confused with the special target with the same name. | | 695 | and cannot be confused with the special target with the same name. |
696 | .It Va .MAKE.DEPENDFILE | | 696 | .It Va .MAKE.DEPENDFILE |
697 | Names the makefile (default | | 697 | Names the makefile (default |
698 | .Ql Pa .depend ) | | 698 | .Ql Pa .depend ) |
699 | from which generated dependencies are read. | | 699 | from which generated dependencies are read. |
700 | .It Va .MAKE.EXPORTED | | 700 | .It Va .MAKE.EXPORTED |
701 | The list of variables exported by | | 701 | The list of variables exported by |
702 | .Nm . | | 702 | .Nm . |
703 | .It Va .MAKE.JOBS | | 703 | .It Va .MAKE.JOBS |
704 | The argument to the | | 704 | The argument to the |
705 | .Fl j | | 705 | .Fl j |
706 | option. | | 706 | option. |
707 | .It Va .MAKE.JOB.PREFIX | | 707 | .It Va .MAKE.JOB.PREFIX |
708 | If | | 708 | If |
709 | .Nm | | 709 | .Nm |
710 | is run with | | 710 | is run with |
711 | .Ar j | | 711 | .Ar j |
712 | then output for each target is prefixed with a token | | 712 | then output for each target is prefixed with a token |
713 | .Ql --- target --- | | 713 | .Ql --- target --- |
714 | the first part of which can be controlled via | | 714 | the first part of which can be controlled via |
715 | .Va .MAKE.JOB.PREFIX . | | 715 | .Va .MAKE.JOB.PREFIX . |
716 | .br | | 716 | .br |
717 | For example: | | 717 | For example: |
718 | .Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}] | | 718 | .Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}] |
719 | would produce tokens like | | 719 | would produce tokens like |
720 | .Ql ---make[1234] target --- | | 720 | .Ql ---make[1234] target --- |
721 | making it easier to track the degree of parallelism being achieved. | | 721 | making it easier to track the degree of parallelism being achieved. |
722 | .It Ev MAKEFLAGS | | 722 | .It Ev MAKEFLAGS |
723 | The environment variable | | 723 | The environment variable |
724 | .Ql Ev MAKEFLAGS | | 724 | .Ql Ev MAKEFLAGS |
725 | may contain anything that | | 725 | may contain anything that |
726 | may be specified on | | 726 | may be specified on |
727 | .Nm Ns 's | | 727 | .Nm Ns 's |
728 | command line. | | 728 | command line. |
729 | Anything specified on | | 729 | Anything specified on |
730 | .Nm Ns 's | | 730 | .Nm Ns 's |
731 | command line is appended to the | | 731 | command line is appended to the |
732 | .Ql Ev MAKEFLAGS | | 732 | .Ql Ev MAKEFLAGS |
733 | variable which is then | | 733 | variable which is then |
734 | entered into the environment for all programs which | | 734 | entered into the environment for all programs which |
735 | .Nm | | 735 | .Nm |
736 | executes. | | 736 | executes. |
737 | .It Va .MAKE.LEVEL | | 737 | .It Va .MAKE.LEVEL |
738 | The recursion depth of | | 738 | The recursion depth of |
739 | .Nm . | | 739 | .Nm . |
740 | The initial instance of | | 740 | The initial instance of |
741 | .Nm | | 741 | .Nm |
742 | will be 0, and an incremented value is put into the environment | | 742 | will be 0, and an incremented value is put into the environment |
743 | to be seen by the next generation. | | 743 | to be seen by the next generation. |
744 | This allows tests like: | | 744 | This allows tests like: |
745 | .Li .if ${.MAKE.LEVEL} == 0 | | 745 | .Li .if ${.MAKE.LEVEL} == 0 |
746 | to protect things which should only be evaluated in the initial instance of | | 746 | to protect things which should only be evaluated in the initial instance of |
747 | .Nm . | | 747 | .Nm . |
748 | .It Va .MAKE.MAKEFILE_PREFERENCE | | 748 | .It Va .MAKE.MAKEFILE_PREFERENCE |
749 | The ordered list of makefile names | | 749 | The ordered list of makefile names |
750 | (default | | 750 | (default |
751 | .Ql Pa makefile , | | 751 | .Ql Pa makefile , |
752 | .Ql Pa Makefile ) | | 752 | .Ql Pa Makefile ) |
753 | that | | 753 | that |
754 | .Nm | | 754 | .Nm |
755 | will look for. | | 755 | will look for. |
756 | .It Va .MAKE.MAKEFILES | | 756 | .It Va .MAKE.MAKEFILES |
757 | The list of makefiles read by | | 757 | The list of makefiles read by |
758 | .Nm , | | 758 | .Nm , |
759 | which is useful for tracking dependencies. | | 759 | which is useful for tracking dependencies. |
760 | Each makefile is recorded only once, regardless of the number of times read. | | 760 | Each makefile is recorded only once, regardless of the number of times read. |
761 | .It Va .MAKE.MODE | | 761 | .It Va .MAKE.MODE |
762 | Processed after reading all makefiles. | | 762 | Processed after reading all makefiles. |
763 | Can affect the mode that | | 763 | Can affect the mode that |
764 | .Nm | | 764 | .Nm |
765 | runs in. | | 765 | runs in. |
766 | It can contain a number of keywords: | | 766 | It can contain a number of keywords: |
767 | .Bl -hang -width ignore-cmd | | 767 | .Bl -hang -width ignore-cmd |
768 | .It Pa compat | | 768 | .It Pa compat |
769 | Like | | 769 | Like |
770 | .Fl B , | | 770 | .Fl B , |
771 | puts | | 771 | puts |
772 | .Nm | | 772 | .Nm |
773 | into "compat" mode. | | 773 | into "compat" mode. |
774 | .It Pa meta | | 774 | .It Pa meta |
775 | Puts | | 775 | Puts |
776 | .Nm | | 776 | .Nm |
777 | into "meta" mode, where meta files are created for each target | | 777 | into "meta" mode, where meta files are created for each target |
778 | to capture the command run, the output generated and if | | 778 | to capture the command run, the output generated and if |
779 | .Xr filemon 4 | | 779 | .Xr filemon 4 |
780 | is available, the system calls which are of interest to | | 780 | is available, the system calls which are of interest to |
781 | .Nm . | | 781 | .Nm . |
782 | The captured output can be very useful when diagnosing errors. | | 782 | The captured output can be very useful when diagnosing errors. |
783 | .It Pa curdirOk= Ar bf | | 783 | .It Pa curdirOk= Ar bf |
784 | Normally | | 784 | Normally |
785 | .Nm | | 785 | .Nm |
786 | will not create .meta files in | | 786 | will not create .meta files in |
787 | .Ql Va .CURDIR . | | 787 | .Ql Va .CURDIR . |
788 | This can be overridden by setting | | 788 | This can be overridden by setting |
789 | .Va bf | | 789 | .Va bf |
790 | to a value which represents True. | | 790 | to a value which represents True. |
791 | .It Pa verbose | | 791 | .It Pa verbose |
792 | If in "meta" mode, print a clue about the target being built. | | 792 | If in "meta" mode, print a clue about the target being built. |
793 | This is useful if the build is otherwise running silently. | | 793 | This is useful if the build is otherwise running silently. |
794 | The message printed the value of: | | 794 | The message printed the value of: |
795 | .Va .MAKE.META.PREFIX . | | 795 | .Va .MAKE.META.PREFIX . |
796 | .It Pa ignore-cmd | | 796 | .It Pa ignore-cmd |
797 | Some makefiles have commands which are simply not stable. | | 797 | Some makefiles have commands which are simply not stable. |
798 | This keyword causes them to be ignored for | | 798 | This keyword causes them to be ignored for |
799 | determining whether a target is out of date in "meta" mode. | | 799 | determining whether a target is out of date in "meta" mode. |
800 | See also | | 800 | See also |
801 | .Ic .NOMETA_CMP . | | 801 | .Ic .NOMETA_CMP . |
802 | .It Pa silent= Ar bf | | 802 | .It Pa silent= Ar bf |
803 | If | | 803 | If |
804 | .Va bf | | 804 | .Va bf |
805 | is True, when a .meta file is created, mark the target | | 805 | is True, when a .meta file is created, mark the target |
806 | .El | | 806 | .El |
807 | .It Va .MAKE.META.BAILIWICK | | 807 | .It Va .MAKE.META.BAILIWICK |
808 | In "meta" mode, provides a list of prefixes which | | 808 | In "meta" mode, provides a list of prefixes which |
809 | match the directories controlled by | | 809 | match the directories controlled by |
810 | .Nm . | | 810 | .Nm . |
811 | If a file that was generated outside of | | 811 | If a file that was generated outside of |
812 | .Va .OBJDIR | | 812 | .Va .OBJDIR |
813 | but within said bailiwick is missing, | | 813 | but within said bailiwick is missing, |
814 | the current target is considered out-of-date. | | 814 | the current target is considered out-of-date. |
815 | .It Va .MAKE.META.CREATED | | 815 | .It Va .MAKE.META.CREATED |
816 | In "meta" mode, this variable contains a list of all the meta files | | 816 | In "meta" mode, this variable contains a list of all the meta files |
817 | updated. | | 817 | updated. |
818 | If not empty, it can be used to trigger processing of | | 818 | If not empty, it can be used to trigger processing of |
819 | .Va .MAKE.META.FILES . | | 819 | .Va .MAKE.META.FILES . |
820 | .It Va .MAKE.META.FILES | | 820 | .It Va .MAKE.META.FILES |
821 | In "meta" mode, this variable contains a list of all the meta files | | 821 | In "meta" mode, this variable contains a list of all the meta files |
822 | used (updated or not). | | 822 | used (updated or not). |
823 | This list can be used to process the meta files to extract dependency | | 823 | This list can be used to process the meta files to extract dependency |
824 | information. | | 824 | information. |
825 | .It Va .MAKE.META.PREFIX | | 825 | .It Va .MAKE.META.PREFIX |
826 | Defines the message printed for each meta file updated in "meta verbose" mode. | | 826 | Defines the message printed for each meta file updated in "meta verbose" mode. |
827 | The default value is: | | 827 | The default value is: |
828 | .Dl Building ${.TARGET:H:tA}/${.TARGET:T} | | 828 | .Dl Building ${.TARGET:H:tA}/${.TARGET:T} |
829 | .It Va .MAKEOVERRIDES | | 829 | .It Va .MAKEOVERRIDES |
830 | This variable is used to record the names of variables assigned to | | 830 | This variable is used to record the names of variables assigned to |
831 | on the command line, so that they may be exported as part of | | 831 | on the command line, so that they may be exported as part of |
832 | .Ql Ev MAKEFLAGS . | | 832 | .Ql Ev MAKEFLAGS . |
833 | This behaviour can be disabled by assigning an empty value to | | 833 | This behaviour can be disabled by assigning an empty value to |
834 | .Ql Va .MAKEOVERRIDES | | 834 | .Ql Va .MAKEOVERRIDES |
835 | within a makefile. | | 835 | within a makefile. |
836 | Extra variables can be exported from a makefile | | 836 | Extra variables can be exported from a makefile |
837 | by appending their names to | | 837 | by appending their names to |
838 | .Ql Va .MAKEOVERRIDES . | | 838 | .Ql Va .MAKEOVERRIDES . |
839 | .Ql Ev MAKEFLAGS | | 839 | .Ql Ev MAKEFLAGS |
840 | is re-exported whenever | | 840 | is re-exported whenever |
841 | .Ql Va .MAKEOVERRIDES | | 841 | .Ql Va .MAKEOVERRIDES |
842 | is modified. | | 842 | is modified. |
843 | .It Va .MAKE.PID | | 843 | .It Va .MAKE.PID |
844 | The process-id of | | 844 | The process-id of |
845 | .Nm . | | 845 | .Nm . |
846 | .It Va .MAKE.PPID | | 846 | .It Va .MAKE.PPID |
847 | The parent process-id of | | 847 | The parent process-id of |
848 | .Nm . | | 848 | .Nm . |
849 | .It Va MAKE_PRINT_VAR_ON_ERROR | | 849 | .It Va MAKE_PRINT_VAR_ON_ERROR |
850 | When | | 850 | When |
851 | .Nm | | 851 | .Nm |
852 | stops due to an error, it prints its name and the value of | | 852 | stops due to an error, it prints its name and the value of |
853 | .Ql Va .CURDIR | | 853 | .Ql Va .CURDIR |
854 | as well as the value of any variables named in | | 854 | as well as the value of any variables named in |
855 | .Ql Va MAKE_PRINT_VAR_ON_ERROR . | | 855 | .Ql Va MAKE_PRINT_VAR_ON_ERROR . |
856 | .It Va .newline | | 856 | .It Va .newline |
857 | This variable is simply assigned a newline character as its value. | | 857 | This variable is simply assigned a newline character as its value. |
858 | This allows expansions using the | | 858 | This allows expansions using the |
859 | .Cm \&:@ | | 859 | .Cm \&:@ |
860 | modifier to put a newline between | | 860 | modifier to put a newline between |
861 | iterations of the loop rather than a space. | | 861 | iterations of the loop rather than a space. |
862 | For example, the printing of | | 862 | For example, the printing of |
863 | .Ql Va MAKE_PRINT_VAR_ON_ERROR | | 863 | .Ql Va MAKE_PRINT_VAR_ON_ERROR |
864 | could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}. | | 864 | could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}. |
865 | .It Va .OBJDIR | | 865 | .It Va .OBJDIR |
866 | A path to the directory where the targets are built. | | 866 | A path to the directory where the targets are built. |
867 | Its value is determined by trying to | | 867 | Its value is determined by trying to |
868 | .Xr chdir 2 | | 868 | .Xr chdir 2 |
869 | to the following directories in order and using the first match: | | 869 | to the following directories in order and using the first match: |
870 | .Bl -enum | | 870 | .Bl -enum |
871 | .It | | 871 | .It |
872 | .Ev ${MAKEOBJDIRPREFIX}${.CURDIR} | | 872 | .Ev ${MAKEOBJDIRPREFIX}${.CURDIR} |
873 | .Pp | | 873 | .Pp |
874 | (Only if | | 874 | (Only if |
875 | .Ql Ev MAKEOBJDIRPREFIX | | 875 | .Ql Ev MAKEOBJDIRPREFIX |
876 | is set in the environment or on the command line.) | | 876 | is set in the environment or on the command line.) |
877 | .It | | 877 | .It |
878 | .Ev ${MAKEOBJDIR} | | 878 | .Ev ${MAKEOBJDIR} |
879 | .Pp | | 879 | .Pp |
880 | (Only if | | 880 | (Only if |
881 | .Ql Ev MAKEOBJDIR | | 881 | .Ql Ev MAKEOBJDIR |
882 | is set in the environment or on the command line.) | | 882 | is set in the environment or on the command line.) |
883 | .It | | 883 | .It |
884 | .Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE} | | 884 | .Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE} |
885 | .It | | 885 | .It |
886 | .Ev ${.CURDIR} Ns Pa /obj | | 886 | .Ev ${.CURDIR} Ns Pa /obj |
887 | .It | | 887 | .It |
888 | .Pa /usr/obj/ Ns Ev ${.CURDIR} | | 888 | .Pa /usr/obj/ Ns Ev ${.CURDIR} |
889 | .It | | 889 | .It |
890 | .Ev ${.CURDIR} | | 890 | .Ev ${.CURDIR} |
891 | .El | | 891 | .El |
892 | .Pp | | 892 | .Pp |
893 | Variable expansion is performed on the value before it's used, | | 893 | Variable expansion is performed on the value before it's used, |
894 | so expressions such as | | 894 | so expressions such as |
895 | .Dl ${.CURDIR:S,^/usr/src,/var/obj,} | | 895 | .Dl ${.CURDIR:S,^/usr/src,/var/obj,} |
896 | may be used. | | 896 | may be used. |
897 | This is especially useful with | | 897 | This is especially useful with |
898 | .Ql Ev MAKEOBJDIR . | | 898 | .Ql Ev MAKEOBJDIR . |
899 | .Pp | | 899 | .Pp |
900 | .Ql Va .OBJDIR | | 900 | .Ql Va .OBJDIR |
901 | may be modified in the makefile as a global variable. | | 901 | may be modified in the makefile as a global variable. |
902 | In all cases, | | 902 | In all cases, |
903 | .Nm | | 903 | .Nm |
904 | will | | 904 | will |
905 | .Xr chdir 2 | | 905 | .Xr chdir 2 |
906 | to | | 906 | to |
907 | .Ql Va .OBJDIR | | 907 | .Ql Va .OBJDIR |
908 | and set | | 908 | and set |
909 | .Ql Ev PWD | | 909 | .Ql Ev PWD |
910 | to that directory before executing any targets. | | 910 | to that directory before executing any targets. |
911 | . | | 911 | . |
912 | .It Va .PARSEDIR | | 912 | .It Va .PARSEDIR |
913 | A path to the directory of the current | | 913 | A path to the directory of the current |
914 | .Ql Pa Makefile | | 914 | .Ql Pa Makefile |
915 | being parsed. | | 915 | being parsed. |
916 | .It Va .PARSEFILE | | 916 | .It Va .PARSEFILE |
917 | The basename of the current | | 917 | The basename of the current |
918 | .Ql Pa Makefile | | 918 | .Ql Pa Makefile |
919 | being parsed. | | 919 | being parsed. |
920 | This variable and | | 920 | This variable and |
921 | .Ql Va .PARSEDIR | | 921 | .Ql Va .PARSEDIR |
922 | are both set only while the | | 922 | are both set only while the |
923 | .Ql Pa Makefiles | | 923 | .Ql Pa Makefiles |
924 | are being parsed. | | 924 | are being parsed. |
925 | If you want to retain their current values, assign them to a variable | | 925 | If you want to retain their current values, assign them to a variable |
926 | using assignment with expansion: | | 926 | using assignment with expansion: |
927 | .Pq Ql Cm \&:= . | | 927 | .Pq Ql Cm \&:= . |
928 | .It Va .PATH | | 928 | .It Va .PATH |
929 | A variable that represents the list of directories that | | 929 | A variable that represents the list of directories that |
930 | .Nm | | 930 | .Nm |
931 | will search for files. | | 931 | will search for files. |
932 | The search list should be updated using the target | | 932 | The search list should be updated using the target |
933 | .Ql Va .PATH | | 933 | .Ql Va .PATH |
934 | rather than the variable. | | 934 | rather than the variable. |
935 | .It Ev PWD | | 935 | .It Ev PWD |
936 | Alternate path to the current directory. | | 936 | Alternate path to the current directory. |
937 | .Nm | | 937 | .Nm |
938 | normally sets | | 938 | normally sets |
939 | .Ql Va .CURDIR | | 939 | .Ql Va .CURDIR |
940 | to the canonical path given by | | 940 | to the canonical path given by |
941 | .Xr getcwd 3 . | | 941 | .Xr getcwd 3 . |
942 | However, if the environment variable | | 942 | However, if the environment variable |
943 | .Ql Ev PWD | | 943 | .Ql Ev PWD |
944 | is set and gives a path to the current directory, then | | 944 | is set and gives a path to the current directory, then |
945 | .Nm | | 945 | .Nm |
946 | sets | | 946 | sets |
947 | .Ql Va .CURDIR | | 947 | .Ql Va .CURDIR |
948 | to the value of | | 948 | to the value of |
949 | .Ql Ev PWD | | 949 | .Ql Ev PWD |
950 | instead. | | 950 | instead. |
951 | This behaviour is disabled if | | 951 | This behaviour is disabled if |
952 | .Ql Ev MAKEOBJDIRPREFIX | | 952 | .Ql Ev MAKEOBJDIRPREFIX |
953 | is set or | | 953 | is set or |
954 | .Ql Ev MAKEOBJDIR | | 954 | .Ql Ev MAKEOBJDIR |
955 | contains a variable transform. | | 955 | contains a variable transform. |
956 | .Ql Ev PWD | | 956 | .Ql Ev PWD |
957 | is set to the value of | | 957 | is set to the value of |
958 | .Ql Va .OBJDIR | | 958 | .Ql Va .OBJDIR |
959 | for all programs which | | 959 | for all programs which |
960 | .Nm | | 960 | .Nm |
961 | executes. | | 961 | executes. |
962 | .It Ev .TARGETS | | 962 | .It Ev .TARGETS |
963 | The list of targets explicitly specified on the command line, if any. | | 963 | The list of targets explicitly specified on the command line, if any. |
964 | .It Ev VPATH | | 964 | .It Ev VPATH |
965 | Colon-separated | | 965 | Colon-separated |
966 | .Pq Dq \&: | | 966 | .Pq Dq \&: |
967 | lists of directories that | | 967 | lists of directories that |
968 | .Nm | | 968 | .Nm |
969 | will search for files. | | 969 | will search for files. |
970 | The variable is supported for compatibility with old make programs only, | | 970 | The variable is supported for compatibility with old make programs only, |
971 | use | | 971 | use |
972 | .Ql Va .PATH | | 972 | .Ql Va .PATH |
973 | instead. | | 973 | instead. |
974 | .El | | 974 | .El |
975 | .Ss Variable modifiers | | 975 | .Ss Variable modifiers |
976 | Variable expansion may be modified to select or modify each word of the | | 976 | Variable expansion may be modified to select or modify each word of the |
977 | variable (where a | | 977 | variable (where a |
978 | .Dq word | | 978 | .Dq word |
979 | is white-space delimited sequence of characters). | | 979 | is white-space delimited sequence of characters). |
980 | The general format of a variable expansion is as follows: | | 980 | The general format of a variable expansion is as follows: |
981 | .Pp | | 981 | .Pp |
982 | .Dl ${variable[:modifier[:...]]} | | 982 | .Dl ${variable[:modifier[:...]]} |
983 | .Pp | | 983 | .Pp |
984 | Each modifier begins with a colon, | | 984 | Each modifier begins with a colon, |
985 | which may be escaped with a backslash | | 985 | which may be escaped with a backslash |
986 | .Pq Ql \e . | | 986 | .Pq Ql \e . |
987 | .Pp | | 987 | .Pp |
988 | A set of modifiers can be specified via a variable, as follows: | | 988 | A set of modifiers can be specified via a variable, as follows: |
989 | .Pp | | 989 | .Pp |
990 | .Dl modifier_variable=modifier[:...] | | 990 | .Dl modifier_variable=modifier[:...] |
991 | .Dl ${variable:${modifier_variable}[:...]} | | 991 | .Dl ${variable:${modifier_variable}[:...]} |
992 | .Pp | | 992 | .Pp |
993 | In this case the first modifier in the modifier_variable does not | | 993 | In this case the first modifier in the modifier_variable does not |
994 | start with a colon, since that must appear in the referencing | | 994 | start with a colon, since that must appear in the referencing |
995 | variable. | | 995 | variable. |
996 | If any of the modifiers in the modifier_variable contain a dollar sign | | 996 | If any of the modifiers in the modifier_variable contain a dollar sign |
997 | .Pq Ql $ , | | 997 | .Pq Ql $ , |
998 | these must be doubled to avoid early expansion. | | 998 | these must be doubled to avoid early expansion. |
999 | .Pp | | 999 | .Pp |
1000 | The supported modifiers are: | | 1000 | The supported modifiers are: |
1001 | .Bl -tag -width EEE | | 1001 | .Bl -tag -width EEE |
1002 | .It Cm \&:E | | 1002 | .It Cm \&:E |
1003 | Replaces each word in the variable with its suffix. | | 1003 | Replaces each word in the variable with its suffix. |
1004 | .It Cm \&:H | | 1004 | .It Cm \&:H |
1005 | Replaces each word in the variable with everything but the last component. | | 1005 | Replaces each word in the variable with everything but the last component. |
1006 | .It Cm \&:M Ns Ar pattern | | 1006 | .It Cm \&:M Ns Ar pattern |
1007 | Select only those words that match | | 1007 | Select only those words that match |
1008 | .Ar pattern . | | 1008 | .Ar pattern . |
1009 | The standard shell wildcard characters | | 1009 | The standard shell wildcard characters |
1010 | .Pf ( Ql * , | | 1010 | .Pf ( Ql * , |
1011 | .Ql \&? , | | 1011 | .Ql \&? , |
1012 | and | | 1012 | and |
1013 | .Ql Oo Oc ) | | 1013 | .Ql Oo Oc ) |
1014 | may | | 1014 | may |
1015 | be used. | | 1015 | be used. |
1016 | The wildcard characters may be escaped with a backslash | | 1016 | The wildcard characters may be escaped with a backslash |
1017 | .Pq Ql \e . | | 1017 | .Pq Ql \e . |
1018 | .It Cm \&:N Ns Ar pattern | | 1018 | .It Cm \&:N Ns Ar pattern |
1019 | This is identical to | | 1019 | This is identical to |
1020 | .Ql Cm \&:M , | | 1020 | .Ql Cm \&:M , |
1021 | but selects all words which do not match | | 1021 | but selects all words which do not match |
1022 | .Ar pattern . | | 1022 | .Ar pattern . |
1023 | .It Cm \&:O | | 1023 | .It Cm \&:O |
1024 | Order every word in variable alphabetically. | | 1024 | Order every word in variable alphabetically. |
1025 | To sort words in | | 1025 | To sort words in |
1026 | reverse order use the | | 1026 | reverse order use the |
1027 | .Ql Cm \&:O:[-1..1] | | 1027 | .Ql Cm \&:O:[-1..1] |
1028 | combination of modifiers. | | 1028 | combination of modifiers. |
1029 | .It Cm \&:Ox | | 1029 | .It Cm \&:Ox |
1030 | Randomize words in variable. | | 1030 | Randomize words in variable. |
1031 | The results will be different each time you are referring to the | | 1031 | The results will be different each time you are referring to the |
1032 | modified variable; use the assignment with expansion | | 1032 | modified variable; use the assignment with expansion |
1033 | .Pq Ql Cm \&:= | | 1033 | .Pq Ql Cm \&:= |
1034 | to prevent such behaviour. | | 1034 | to prevent such behaviour. |
1035 | For example, | | 1035 | For example, |
1036 | .Bd -literal -offset indent | | 1036 | .Bd -literal -offset indent |
1037 | LIST= uno due tre quattro | | 1037 | LIST= uno due tre quattro |
1038 | RANDOM_LIST= ${LIST:Ox} | | 1038 | RANDOM_LIST= ${LIST:Ox} |
1039 | STATIC_RANDOM_LIST:= ${LIST:Ox} | | 1039 | STATIC_RANDOM_LIST:= ${LIST:Ox} |
1040 | | | 1040 | |
1041 | all: | | 1041 | all: |
1042 | @echo "${RANDOM_LIST}" | | 1042 | @echo "${RANDOM_LIST}" |
1043 | @echo "${RANDOM_LIST}" | | 1043 | @echo "${RANDOM_LIST}" |
1044 | @echo "${STATIC_RANDOM_LIST}" | | 1044 | @echo "${STATIC_RANDOM_LIST}" |
1045 | @echo "${STATIC_RANDOM_LIST}" | | 1045 | @echo "${STATIC_RANDOM_LIST}" |
1046 | .Ed | | 1046 | .Ed |
1047 | may produce output similar to: | | 1047 | may produce output similar to: |
1048 | .Bd -literal -offset indent | | 1048 | .Bd -literal -offset indent |
1049 | quattro due tre uno | | 1049 | quattro due tre uno |
1050 | tre due quattro uno | | 1050 | tre due quattro uno |
1051 | due uno quattro tre | | 1051 | due uno quattro tre |
1052 | due uno quattro tre | | 1052 | due uno quattro tre |
1053 | .Ed | | 1053 | .Ed |
1054 | .It Cm \&:Q | | 1054 | .It Cm \&:Q |
1055 | Quotes every shell meta-character in the variable, so that it can be passed | | 1055 | Quotes every shell meta-character in the variable, so that it can be passed |
1056 | safely through recursive invocations of | | 1056 | safely through recursive invocations of |
1057 | .Nm . | | 1057 | .Nm . |
1058 | .It Cm \&:R | | 1058 | .It Cm \&:R |
1059 | Replaces each word in the variable with everything but its suffix. | | 1059 | Replaces each word in the variable with everything but its suffix. |
1060 | .It Cm \&:gmtime | | 1060 | .It Cm \&:gmtime |
1061 | The value is a format string for | | 1061 | The value is a format string for |
1062 | .Xr strftime 3 , | | 1062 | .Xr strftime 3 , |
1063 | using the current | | 1063 | using the current |
1064 | .Xr gmtime 3 . | | 1064 | .Xr gmtime 3 . |
1065 | .It Cm \&:hash | | 1065 | .It Cm \&:hash |
1066 | Compute a 32bit hash of the value and encode it as hex digits. | | 1066 | Compute a 32bit hash of the value and encode it as hex digits. |
1067 | .It Cm \&:localtime | | 1067 | .It Cm \&:localtime |
1068 | The value is a format string for | | 1068 | The value is a format string for |
1069 | .Xr strftime 3 , | | 1069 | .Xr strftime 3 , |
1070 | using the current | | 1070 | using the current |
1071 | .Xr localtime 3 . | | 1071 | .Xr localtime 3 . |
1072 | .It Cm \&:tA | | 1072 | .It Cm \&:tA |
1073 | Attempt to convert variable to an absolute path using | | 1073 | Attempt to convert variable to an absolute path using |
1074 | .Xr realpath 3 , | | 1074 | .Xr realpath 3 , |
1075 | if that fails, the value is unchanged. | | 1075 | if that fails, the value is unchanged. |
1076 | .It Cm \&:tl | | 1076 | .It Cm \&:tl |
1077 | Converts variable to lower-case letters. | | 1077 | Converts variable to lower-case letters. |
1078 | .It Cm \&:ts Ns Ar c | | 1078 | .It Cm \&:ts Ns Ar c |
1079 | Words in the variable are normally separated by a space on expansion. | | 1079 | Words in the variable are normally separated by a space on expansion. |
1080 | This modifier sets the separator to the character | | 1080 | This modifier sets the separator to the character |
1081 | .Ar c . | | 1081 | .Ar c . |
1082 | If | | 1082 | If |
1083 | .Ar c | | 1083 | .Ar c |
1084 | is omitted, then no separator is used. | | 1084 | is omitted, then no separator is used. |
1085 | The common escapes (including octal numeric codes), work as expected. | | 1085 | The common escapes (including octal numeric codes), work as expected. |
1086 | .It Cm \&:tu | | 1086 | .It Cm \&:tu |
1087 | Converts variable to upper-case letters. | | 1087 | Converts variable to upper-case letters. |
1088 | .It Cm \&:tW | | 1088 | .It Cm \&:tW |
1089 | Causes the value to be treated as a single word | | 1089 | Causes the value to be treated as a single word |
1090 | (possibly containing embedded white space). | | 1090 | (possibly containing embedded white space). |
1091 | See also | | 1091 | See also |
1092 | .Ql Cm \&:[*] . | | 1092 | .Ql Cm \&:[*] . |
1093 | .It Cm \&:tw | | 1093 | .It Cm \&:tw |
1094 | Causes the value to be treated as a sequence of | | 1094 | Causes the value to be treated as a sequence of |
1095 | words delimited by white space. | | 1095 | words delimited by white space. |
1096 | See also | | 1096 | See also |
1097 | .Ql Cm \&:[@] . | | 1097 | .Ql Cm \&:[@] . |
1098 | .Sm off | | 1098 | .Sm off |
1099 | .It Cm \&:S No \&/ Ar old_string No \&/ Ar new_string No \&/ Op Cm 1gW | | 1099 | .It Cm \&:S No \&/ Ar old_string No \&/ Ar new_string No \&/ Op Cm 1gW |
1100 | .Sm on | | 1100 | .Sm on |
1101 | Modify the first occurrence of | | 1101 | Modify the first occurrence of |
1102 | .Ar old_string | | 1102 | .Ar old_string |
1103 | in the variable's value, replacing it with | | 1103 | in the variable's value, replacing it with |
1104 | .Ar new_string . | | 1104 | .Ar new_string . |
1105 | If a | | 1105 | If a |
1106 | .Ql g | | 1106 | .Ql g |
1107 | is appended to the last slash of the pattern, all occurrences | | 1107 | is appended to the last slash of the pattern, all occurrences |
1108 | in each word are replaced. | | 1108 | in each word are replaced. |
1109 | If a | | 1109 | If a |
1110 | .Ql 1 | | 1110 | .Ql 1 |
1111 | is appended to the last slash of the pattern, only the first word | | 1111 | is appended to the last slash of the pattern, only the first word |
1112 | is affected. | | 1112 | is affected. |
1113 | If a | | 1113 | If a |
1114 | .Ql W | | 1114 | .Ql W |
1115 | is appended to the last slash of the pattern, | | 1115 | is appended to the last slash of the pattern, |
1116 | then the value is treated as a single word | | 1116 | then the value is treated as a single word |
1117 | (possibly containing embedded white space). | | 1117 | (possibly containing embedded white space). |
1118 | If | | 1118 | If |
1119 | .Ar old_string | | 1119 | .Ar old_string |
1120 | begins with a caret | | 1120 | begins with a caret |
1121 | .Pq Ql ^ , | | 1121 | .Pq Ql ^ , |
1122 | .Ar old_string | | 1122 | .Ar old_string |
1123 | is anchored at the beginning of each word. | | 1123 | is anchored at the beginning of each word. |
1124 | If | | 1124 | If |
1125 | .Ar old_string | | 1125 | .Ar old_string |
1126 | ends with a dollar sign | | 1126 | ends with a dollar sign |
1127 | .Pq Ql \&$ , | | 1127 | .Pq Ql \&$ , |
1128 | it is anchored at the end of each word. | | 1128 | it is anchored at the end of each word. |
1129 | Inside | | 1129 | Inside |
1130 | .Ar new_string , | | 1130 | .Ar new_string , |
1131 | an ampersand | | 1131 | an ampersand |
1132 | .Pq Ql \*[Am] | | 1132 | .Pq Ql \*[Am] |
1133 | is replaced by | | 1133 | is replaced by |
1134 | .Ar old_string | | 1134 | .Ar old_string |
1135 | (without any | | 1135 | (without any |
1136 | .Ql ^ | | 1136 | .Ql ^ |
1137 | or | | 1137 | or |
1138 | .Ql \&$ ) . | | 1138 | .Ql \&$ ) . |
1139 | Any character may be used as a delimiter for the parts of the modifier | | 1139 | Any character may be used as a delimiter for the parts of the modifier |
1140 | string. | | 1140 | string. |
1141 | The anchoring, ampersand and delimiter characters may be escaped with a | | 1141 | The anchoring, ampersand and delimiter characters may be escaped with a |
1142 | backslash | | 1142 | backslash |
1143 | .Pq Ql \e . | | 1143 | .Pq Ql \e . |
1144 | .Pp | | 1144 | .Pp |
1145 | Variable expansion occurs in the normal fashion inside both | | 1145 | Variable expansion occurs in the normal fashion inside both |
1146 | .Ar old_string | | 1146 | .Ar old_string |
1147 | and | | 1147 | and |
1148 | .Ar new_string | | 1148 | .Ar new_string |
1149 | with the single exception that a backslash is used to prevent the expansion | | 1149 | with the single exception that a backslash is used to prevent the expansion |
1150 | of a dollar sign | | 1150 | of a dollar sign |
1151 | .Pq Ql \&$ , | | 1151 | .Pq Ql \&$ , |
1152 | not a preceding dollar sign as is usual. | | 1152 | not a preceding dollar sign as is usual. |
1153 | .Sm off | | 1153 | .Sm off |
1154 | .It Cm \&:C No \&/ Ar pattern No \&/ Ar replacement No \&/ Op Cm 1gW | | 1154 | .It Cm \&:C No \&/ Ar pattern No \&/ Ar replacement No \&/ Op Cm 1gW |
1155 | .Sm on | | 1155 | .Sm on |
1156 | The | | 1156 | The |
1157 | .Cm \&:C | | 1157 | .Cm \&:C |
1158 | modifier is just like the | | 1158 | modifier is just like the |
1159 | .Cm \&:S | | 1159 | .Cm \&:S |
1160 | modifier except that the old and new strings, instead of being | | 1160 | modifier except that the old and new strings, instead of being |
1161 | simple strings, are a regular expression (see | | 1161 | simple strings, are a regular expression (see |
1162 | .Xr regex 3 ) | | 1162 | .Xr regex 3 ) |
1163 | string | | 1163 | string |
1164 | .Ar pattern | | 1164 | .Ar pattern |
1165 | and an | | 1165 | and an |
1166 | .Xr ed 1 Ns \-style | | 1166 | .Xr ed 1 Ns \-style |
1167 | string | | 1167 | string |
1168 | .Ar replacement . | | 1168 | .Ar replacement . |
1169 | Normally, the first occurrence of the pattern | | 1169 | Normally, the first occurrence of the pattern |
1170 | .Ar pattern | | 1170 | .Ar pattern |
1171 | in each word of the value is substituted with | | 1171 | in each word of the value is substituted with |
1172 | .Ar replacement . | | 1172 | .Ar replacement . |
1173 | The | | 1173 | The |
1174 | .Ql 1 | | 1174 | .Ql 1 |
1175 | modifier causes the substitution to apply to at most one word; the | | 1175 | modifier causes the substitution to apply to at most one word; the |
1176 | .Ql g | | 1176 | .Ql g |
1177 | modifier causes the substitution to apply to as many instances of the | | 1177 | modifier causes the substitution to apply to as many instances of the |
1178 | search pattern | | 1178 | search pattern |
1179 | .Ar pattern | | 1179 | .Ar pattern |
1180 | as occur in the word or words it is found in; the | | 1180 | as occur in the word or words it is found in; the |
1181 | .Ql W | | 1181 | .Ql W |
1182 | modifier causes the value to be treated as a single word | | 1182 | modifier causes the value to be treated as a single word |
1183 | (possibly containing embedded white space). | | 1183 | (possibly containing embedded white space). |
1184 | Note that | | 1184 | Note that |
1185 | .Ql 1 | | 1185 | .Ql 1 |
1186 | and | | 1186 | and |
1187 | .Ql g | | 1187 | .Ql g |
1188 | are orthogonal; the former specifies whether multiple words are | | 1188 | are orthogonal; the former specifies whether multiple words are |
1189 | potentially affected, the latter whether multiple substitutions can | | 1189 | potentially affected, the latter whether multiple substitutions can |
1190 | potentially occur within each affected word. | | 1190 | potentially occur within each affected word. |
1191 | .It Cm \&:T | | 1191 | .It Cm \&:T |
1192 | Replaces each word in the variable with its last component. | | 1192 | Replaces each word in the variable with its last component. |
1193 | .It Cm \&:u | | 1193 | .It Cm \&:u |
1194 | Remove adjacent duplicate words (like | | 1194 | Remove adjacent duplicate words (like |
1195 | .Xr uniq 1 ) . | | 1195 | .Xr uniq 1 ) . |
1196 | .Sm off | | 1196 | .Sm off |
1197 | .It Cm \&:\&? Ar true_string Cm \&: Ar false_string | | 1197 | .It Cm \&:\&? Ar true_string Cm \&: Ar false_string |
1198 | .Sm on | | 1198 | .Sm on |
1199 | If the variable name (not its value), when parsed as a .if conditional | | 1199 | If the variable name (not its value), when parsed as a .if conditional |
1200 | expression, evaluates to true, return as its value the | | 1200 | expression, evaluates to true, return as its value the |
1201 | .Ar true_string , | | 1201 | .Ar true_string , |
1202 | otherwise return the | | 1202 | otherwise return the |
1203 | .Ar false_string . | | 1203 | .Ar false_string . |
1204 | Since the variable name is used as the expression, \&:\&? must be the | | 1204 | Since the variable name is used as the expression, \&:\&? must be the |
1205 | first modifier after the variable name itself - which will, of course, | | 1205 | first modifier after the variable name itself - which will, of course, |
1206 | usually contain variable expansions. | | 1206 | usually contain variable expansions. |
1207 | A common error is trying to use expressions like | | 1207 | A common error is trying to use expressions like |
1208 | .Dl ${NUMBERS:M42:?match:no} | | 1208 | .Dl ${NUMBERS:M42:?match:no} |
1209 | which actually tests defined(NUMBERS), | | 1209 | which actually tests defined(NUMBERS), |
1210 | to determine is any words match "42" you need to use something like: | | 1210 | to determine is any words match "42" you need to use something like: |
1211 | .Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} . | | 1211 | .Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} . |
1212 | .It Ar :old_string=new_string | | 1212 | .It Ar :old_string=new_string |
1213 | This is the | | 1213 | This is the |
1214 | .At V | | 1214 | .At V |
1215 | style variable substitution. | | 1215 | style variable substitution. |
1216 | It must be the last modifier specified. | | 1216 | It must be the last modifier specified. |
1217 | If | | 1217 | If |
1218 | .Ar old_string | | 1218 | .Ar old_string |
1219 | or | | 1219 | or |
1220 | .Ar new_string | | 1220 | .Ar new_string |
1221 | do not contain the pattern matching character | | 1221 | do not contain the pattern matching character |
1222 | .Ar % | | 1222 | .Ar % |
1223 | then it is assumed that they are | | 1223 | then it is assumed that they are |
1224 | anchored at the end of each word, so only suffixes or entire | | 1224 | anchored at the end of each word, so only suffixes or entire |
1225 | words may be replaced. | | 1225 | words may be replaced. |
1226 | Otherwise | | 1226 | Otherwise |
1227 | .Ar % | | 1227 | .Ar % |
1228 | is the substring of | | 1228 | is the substring of |
1229 | .Ar old_string | | 1229 | .Ar old_string |
1230 | to be replaced in | | 1230 | to be replaced in |
1231 | .Ar new_string . | | 1231 | .Ar new_string . |
1232 | .Pp | | 1232 | .Pp |
1233 | Variable expansion occurs in the normal fashion inside both | | 1233 | Variable expansion occurs in the normal fashion inside both |
1234 | .Ar old_string | | 1234 | .Ar old_string |
1235 | and | | 1235 | and |
1236 | .Ar new_string | | 1236 | .Ar new_string |
1237 | with the single exception that a backslash is used to prevent the | | 1237 | with the single exception that a backslash is used to prevent the |
1238 | expansion of a dollar sign | | 1238 | expansion of a dollar sign |
1239 | .Pq Ql \&$ , | | 1239 | .Pq Ql \&$ , |
1240 | not a preceding dollar sign as is usual. | | 1240 | not a preceding dollar sign as is usual. |
1241 | .Sm off | | 1241 | .Sm off |
1242 | .It Cm \&:@ Ar temp Cm @ Ar string Cm @ | | 1242 | .It Cm \&:@ Ar temp Cm @ Ar string Cm @ |
1243 | .Sm on | | 1243 | .Sm on |
1244 | This is the loop expansion mechanism from the OSF Development | | 1244 | This is the loop expansion mechanism from the OSF Development |
1245 | Environment (ODE) make. | | 1245 | Environment (ODE) make. |
1246 | Unlike | | 1246 | Unlike |
1247 | .Cm \&.for | | 1247 | .Cm \&.for |
1248 | loops expansion occurs at the time of | | 1248 | loops expansion occurs at the time of |
1249 | reference. | | 1249 | reference. |
1250 | Assign | | 1250 | Assign |
1251 | .Ar temp | | 1251 | .Ar temp |
1252 | to each word in the variable and evaluate | | 1252 | to each word in the variable and evaluate |
1253 | .Ar string . | | 1253 | .Ar string . |
1254 | The ODE convention is that | | 1254 | The ODE convention is that |
1255 | .Ar temp | | 1255 | .Ar temp |
1256 | should start and end with a period. | | 1256 | should start and end with a period. |
1257 | For example. | | 1257 | For example. |
1258 | .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@} | | 1258 | .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@} |
| | | 1259 | .Pp |
| | | 1260 | However a single character varaiable is often more readable: |
| | | 1261 | .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@} |
1259 | .It Cm \&:U Ns Ar newval | | 1262 | .It Cm \&:U Ns Ar newval |
1260 | If the variable is undefined | | 1263 | If the variable is undefined |
1261 | .Ar newval | | 1264 | .Ar newval |
1262 | is the value. | | 1265 | is the value. |
1263 | If the variable is defined, the existing value is returned. | | 1266 | If the variable is defined, the existing value is returned. |
1264 | This is another ODE make feature. | | 1267 | This is another ODE make feature. |
1265 | It is handy for setting per-target CFLAGS for instance: | | 1268 | It is handy for setting per-target CFLAGS for instance: |
1266 | .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}} | | 1269 | .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}} |
1267 | If a value is only required if the variable is undefined, use: | | 1270 | If a value is only required if the variable is undefined, use: |
1268 | .Dl ${VAR:D:Unewval} | | 1271 | .Dl ${VAR:D:Unewval} |
1269 | .It Cm \&:D Ns Ar newval | | 1272 | .It Cm \&:D Ns Ar newval |
1270 | If the variable is defined | | 1273 | If the variable is defined |
1271 | .Ar newval | | 1274 | .Ar newval |
1272 | is the value. | | 1275 | is the value. |
1273 | .It Cm \&:L | | 1276 | .It Cm \&:L |
1274 | The name of the variable is the value. | | 1277 | The name of the variable is the value. |
1275 | .It Cm \&:P | | 1278 | .It Cm \&:P |
1276 | The path of the node which has the same name as the variable | | 1279 | The path of the node which has the same name as the variable |
1277 | is the value. | | 1280 | is the value. |
1278 | If no such node exists or its path is null, then the | | 1281 | If no such node exists or its path is null, then the |
1279 | name of the variable is used. | | 1282 | name of the variable is used. |
1280 | .Sm off | | 1283 | .Sm off |
1281 | .It Cm \&:\&! Ar cmd Cm \&! | | 1284 | .It Cm \&:\&! Ar cmd Cm \&! |
1282 | .Sm on | | 1285 | .Sm on |
1283 | The output of running | | 1286 | The output of running |
1284 | .Ar cmd | | 1287 | .Ar cmd |
1285 | is the value. | | 1288 | is the value. |
1286 | .It Cm \&:sh | | 1289 | .It Cm \&:sh |
1287 | If the variable is non-empty it is run as a command and the output | | 1290 | If the variable is non-empty it is run as a command and the output |
1288 | becomes the new value. | | 1291 | becomes the new value. |
1289 | .It Cm \&::= Ns Ar str | | 1292 | .It Cm \&::= Ns Ar str |
1290 | The variable is assigned the value | | 1293 | The variable is assigned the value |
1291 | .Ar str | | 1294 | .Ar str |
1292 | after substitution. | | 1295 | after substitution. |
1293 | This modifier and its variations are useful in | | 1296 | This modifier and its variations are useful in |
1294 | obscure situations such as wanting to set a variable when shell commands | | 1297 | obscure situations such as wanting to set a variable when shell commands |
1295 | are being parsed. | | 1298 | are being parsed. |
1296 | These assignment modifiers always expand to | | 1299 | These assignment modifiers always expand to |
1297 | nothing, so if appearing in a rule line by themselves should be | | 1300 | nothing, so if appearing in a rule line by themselves should be |
1298 | preceded with something to keep | | 1301 | preceded with something to keep |
1299 | .Nm | | 1302 | .Nm |
1300 | happy. | | 1303 | happy. |
1301 | .Pp | | 1304 | .Pp |
1302 | The | | 1305 | The |
1303 | .Ql Cm \&:: | | 1306 | .Ql Cm \&:: |
1304 | helps avoid false matches with the | | 1307 | helps avoid false matches with the |
1305 | .At V | | 1308 | .At V |
1306 | style | | 1309 | style |
1307 | .Cm \&:= | | 1310 | .Cm \&:= |
1308 | modifier and since substitution always occurs the | | 1311 | modifier and since substitution always occurs the |
1309 | .Cm \&::= | | 1312 | .Cm \&::= |
1310 | form is vaguely appropriate. | | 1313 | form is vaguely appropriate. |
1311 | .It Cm \&::?= Ns Ar str | | 1314 | .It Cm \&::?= Ns Ar str |
1312 | As for | | 1315 | As for |
1313 | .Cm \&::= | | 1316 | .Cm \&::= |
1314 | but only if the variable does not already have a value. | | 1317 | but only if the variable does not already have a value. |
1315 | .It Cm \&::+= Ns Ar str | | 1318 | .It Cm \&::+= Ns Ar str |
1316 | Append | | 1319 | Append |
1317 | .Ar str | | 1320 | .Ar str |
1318 | to the variable. | | 1321 | to the variable. |
1319 | .It Cm \&::!= Ns Ar cmd | | 1322 | .It Cm \&::!= Ns Ar cmd |
1320 | Assign the output of | | 1323 | Assign the output of |
1321 | .Ar cmd | | 1324 | .Ar cmd |
1322 | to the variable. | | 1325 | to the variable. |
1323 | .It Cm \&:\&[ Ns Ar range Ns Cm \&] | | 1326 | .It Cm \&:\&[ Ns Ar range Ns Cm \&] |
1324 | Selects one or more words from the value, | | 1327 | Selects one or more words from the value, |
1325 | or performs other operations related to the way in which the | | 1328 | or performs other operations related to the way in which the |
1326 | value is divided into words. | | 1329 | value is divided into words. |
1327 | .Pp | | 1330 | .Pp |
1328 | Ordinarily, a value is treated as a sequence of words | | 1331 | Ordinarily, a value is treated as a sequence of words |
1329 | delimited by white space. | | 1332 | delimited by white space. |
1330 | Some modifiers suppress this behaviour, | | 1333 | Some modifiers suppress this behaviour, |
1331 | causing a value to be treated as a single word | | 1334 | causing a value to be treated as a single word |
1332 | (possibly containing embedded white space). | | 1335 | (possibly containing embedded white space). |
1333 | An empty value, or a value that consists entirely of white-space, | | 1336 | An empty value, or a value that consists entirely of white-space, |
1334 | is treated as a single word. | | 1337 | is treated as a single word. |
1335 | For the purposes of the | | 1338 | For the purposes of the |
1336 | .Ql Cm \&:[] | | 1339 | .Ql Cm \&:[] |
1337 | modifier, the words are indexed both forwards using positive integers | | 1340 | modifier, the words are indexed both forwards using positive integers |
1338 | (where index 1 represents the first word), | | 1341 | (where index 1 represents the first word), |
1339 | and backwards using negative integers | | 1342 | and backwards using negative integers |
1340 | (where index \-1 represents the last word). | | 1343 | (where index \-1 represents the last word). |
1341 | .Pp | | 1344 | .Pp |
1342 | The | | 1345 | The |
1343 | .Ar range | | 1346 | .Ar range |
1344 | is subjected to variable expansion, and the expanded result is | | 1347 | is subjected to variable expansion, and the expanded result is |
1345 | then interpreted as follows: | | 1348 | then interpreted as follows: |
1346 | .Bl -tag -width index | | 1349 | .Bl -tag -width index |
1347 | .\" :[n] | | 1350 | .\" :[n] |
1348 | .It Ar index | | 1351 | .It Ar index |
1349 | Selects a single word from the value. | | 1352 | Selects a single word from the value. |
1350 | .\" :[start..end] | | 1353 | .\" :[start..end] |
1351 | .It Ar start Ns Cm \&.. Ns Ar end | | 1354 | .It Ar start Ns Cm \&.. Ns Ar end |
1352 | Selects all words from | | 1355 | Selects all words from |
1353 | .Ar start | | 1356 | .Ar start |
1354 | to | | 1357 | to |
1355 | .Ar end , | | 1358 | .Ar end , |
1356 | inclusive. | | 1359 | inclusive. |
1357 | For example, | | 1360 | For example, |
1358 | .Ql Cm \&:[2..-1] | | 1361 | .Ql Cm \&:[2..-1] |
1359 | selects all words from the second word to the last word. | | 1362 | selects all words from the second word to the last word. |
1360 | If | | 1363 | If |
1361 | .Ar start | | 1364 | .Ar start |
1362 | is greater than | | 1365 | is greater than |
1363 | .Ar end , | | 1366 | .Ar end , |
1364 | then the words are output in reverse order. | | 1367 | then the words are output in reverse order. |
1365 | For example, | | 1368 | For example, |
1366 | .Ql Cm \&:[-1..1] | | 1369 | .Ql Cm \&:[-1..1] |
1367 | selects all the words from last to first. | | 1370 | selects all the words from last to first. |
1368 | .\" :[*] | | 1371 | .\" :[*] |
1369 | .It Cm \&* | | 1372 | .It Cm \&* |
1370 | Causes subsequent modifiers to treat the value as a single word | | 1373 | Causes subsequent modifiers to treat the value as a single word |
1371 | (possibly containing embedded white space). | | 1374 | (possibly containing embedded white space). |
1372 | Analogous to the effect of | | 1375 | Analogous to the effect of |
1373 | \&"$*\&" | | 1376 | \&"$*\&" |
1374 | in Bourne shell. | | 1377 | in Bourne shell. |
1375 | .\" :[0] | | 1378 | .\" :[0] |
1376 | .It 0 | | 1379 | .It 0 |
1377 | Means the same as | | 1380 | Means the same as |
1378 | .Ql Cm \&:[*] . | | 1381 | .Ql Cm \&:[*] . |
1379 | .\" :[*] | | 1382 | .\" :[*] |
1380 | .It Cm \&@ | | 1383 | .It Cm \&@ |
1381 | Causes subsequent modifiers to treat the value as a sequence of words | | 1384 | Causes subsequent modifiers to treat the value as a sequence of words |
1382 | delimited by white space. | | 1385 | delimited by white space. |
1383 | Analogous to the effect of | | 1386 | Analogous to the effect of |
1384 | \&"$@\&" | | 1387 | \&"$@\&" |
1385 | in Bourne shell. | | 1388 | in Bourne shell. |
1386 | .\" :[#] | | 1389 | .\" :[#] |
1387 | .It Cm \&# | | 1390 | .It Cm \&# |
1388 | Returns the number of words in the value. | | 1391 | Returns the number of words in the value. |
1389 | .El \" :[range] | | 1392 | .El \" :[range] |
1390 | .El | | 1393 | .El |
1391 | .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS | | 1394 | .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS |
1392 | Makefile inclusion, conditional structures and for loops reminiscent | | 1395 | Makefile inclusion, conditional structures and for loops reminiscent |
1393 | of the C programming language are provided in | | 1396 | of the C programming language are provided in |
1394 | .Nm . | | 1397 | .Nm . |
1395 | All such structures are identified by a line beginning with a single | | 1398 | All such structures are identified by a line beginning with a single |
1396 | dot | | 1399 | dot |
1397 | .Pq Ql \&. | | 1400 | .Pq Ql \&. |
1398 | character. | | 1401 | character. |
1399 | Files are included with either | | 1402 | Files are included with either |
1400 | .Cm \&.include Aq Ar file | | 1403 | .Cm \&.include Aq Ar file |
1401 | or | | 1404 | or |
1402 | .Cm \&.include Pf \*q Ar file Ns \*q . | | 1405 | .Cm \&.include Pf \*q Ar file Ns \*q . |
1403 | Variables between the angle brackets or double quotes are expanded | | 1406 | Variables between the angle brackets or double quotes are expanded |
1404 | to form the file name. | | 1407 | to form the file name. |
1405 | If angle brackets are used, the included makefile is expected to be in | | 1408 | If angle brackets are used, the included makefile is expected to be in |
1406 | the system makefile directory. | | 1409 | the system makefile directory. |
1407 | If double quotes are used, the including makefile's directory and any | | 1410 | If double quotes are used, the including makefile's directory and any |
1408 | directories specified using the | | 1411 | directories specified using the |
1409 | .Fl I | | 1412 | .Fl I |
1410 | option are searched before the system | | 1413 | option are searched before the system |
1411 | makefile directory. | | 1414 | makefile directory. |
1412 | For compatibility with other versions of | | 1415 | For compatibility with other versions of |
1413 | .Nm | | 1416 | .Nm |
1414 | .Ql include file ... | | 1417 | .Ql include file ... |
1415 | is also accepted. | | 1418 | is also accepted. |
1416 | If the include statement is written as | | 1419 | If the include statement is written as |
1417 | .Cm .-include | | 1420 | .Cm .-include |
1418 | or as | | 1421 | or as |
1419 | .Cm .sinclude | | 1422 | .Cm .sinclude |
1420 | then errors locating and/or opening include files are ignored. | | 1423 | then errors locating and/or opening include files are ignored. |
1421 | .Pp | | 1424 | .Pp |
1422 | Conditional expressions are also preceded by a single dot as the first | | 1425 | Conditional expressions are also preceded by a single dot as the first |
1423 | character of a line. | | 1426 | character of a line. |
1424 | The possible conditionals are as follows: | | 1427 | The possible conditionals are as follows: |
1425 | .Bl -tag -width Ds | | 1428 | .Bl -tag -width Ds |
1426 | .It Ic .error Ar message | | 1429 | .It Ic .error Ar message |
1427 | The message is printed along with the name of the makefile and line number, | | 1430 | The message is printed along with the name of the makefile and line number, |
1428 | then | | 1431 | then |
1429 | .Nm | | 1432 | .Nm |
1430 | will exit. | | 1433 | will exit. |
1431 | .It Ic .export Ar variable ... | | 1434 | .It Ic .export Ar variable ... |
1432 | Export the specified global variable. | | 1435 | Export the specified global variable. |
1433 | If no variable list is provided, all globals are exported | | 1436 | If no variable list is provided, all globals are exported |
1434 | except for internal variables (those that start with | | 1437 | except for internal variables (those that start with |
1435 | .Ql \&. ) . | | 1438 | .Ql \&. ) . |
1436 | This is not affected by the | | 1439 | This is not affected by the |
1437 | .Fl X | | 1440 | .Fl X |
1438 | flag, so should be used with caution. | | 1441 | flag, so should be used with caution. |
1439 | .Pp | | 1442 | .Pp |
1440 | Appending a variable name to | | 1443 | Appending a variable name to |
1441 | .Va .MAKE.EXPORTED | | 1444 | .Va .MAKE.EXPORTED |
1442 | is equivalent to exporting a variable. | | 1445 | is equivalent to exporting a variable. |
1443 | .It Ic .export-env Ar variable ... | | 1446 | .It Ic .export-env Ar variable ... |
1444 | The same as | | 1447 | The same as |
1445 | .Ql .export , | | 1448 | .Ql .export , |
1446 | except that the variable is not appended to | | 1449 | except that the variable is not appended to |
1447 | .Va .MAKE.EXPORTED . | | 1450 | .Va .MAKE.EXPORTED . |
1448 | This allows exporting a value to the environment which is different from that | | 1451 | This allows exporting a value to the environment which is different from that |
1449 | used by | | 1452 | used by |
1450 | .Nm | | 1453 | .Nm |
1451 | internally. | | 1454 | internally. |
1452 | .It Ic .info Ar message | | 1455 | .It Ic .info Ar message |
1453 | The message is printed along with the name of the makefile and line number. | | 1456 | The message is printed along with the name of the makefile and line number. |
1454 | .It Ic .undef Ar variable | | 1457 | .It Ic .undef Ar variable |
1455 | Un-define the specified global variable. | | 1458 | Un-define the specified global variable. |
1456 | Only global variables may be un-defined. | | 1459 | Only global variables may be un-defined. |
1457 | .It Ic .unexport Ar variable ... | | 1460 | .It Ic .unexport Ar variable ... |
1458 | The opposite of | | 1461 | The opposite of |
1459 | .Ql .export . | | 1462 | .Ql .export . |
1460 | The specified global | | 1463 | The specified global |
1461 | .Va variable | | 1464 | .Va variable |
1462 | will be removed from | | 1465 | will be removed from |
1463 | .Va .MAKE.EXPORTED . | | 1466 | .Va .MAKE.EXPORTED . |
1464 | If no variable list is provided, all globals are unexported, | | 1467 | If no variable list is provided, all globals are unexported, |
1465 | and | | 1468 | and |
1466 | .Va .MAKE.EXPORTED | | 1469 | .Va .MAKE.EXPORTED |
1467 | deleted. | | 1470 | deleted. |
1468 | .It Ic .unexport-env | | 1471 | .It Ic .unexport-env |
1469 | Unexport all globals previously exported and | | 1472 | Unexport all globals previously exported and |
1470 | clear the environment inherited from the parent. | | 1473 | clear the environment inherited from the parent. |
1471 | This operation will cause a memory leak of the original environment, | | 1474 | This operation will cause a memory leak of the original environment, |
1472 | so should be used sparingly. | | 1475 | so should be used sparingly. |
1473 | Testing for | | 1476 | Testing for |
1474 | .Va .MAKE.LEVEL | | 1477 | .Va .MAKE.LEVEL |
1475 | being 0, would make sense. | | 1478 | being 0, would make sense. |
1476 | Also note that any variables which originated in the parent environment | | 1479 | Also note that any variables which originated in the parent environment |
1477 | should be explicitly preserved if desired. | | 1480 | should be explicitly preserved if desired. |
1478 | For example: | | 1481 | For example: |
1479 | .Bd -literal -offset indent | | 1482 | .Bd -literal -offset indent |
1480 | .Li .if ${.MAKE.LEVEL} == 0 | | 1483 | .Li .if ${.MAKE.LEVEL} == 0 |
1481 | PATH := ${PATH} | | 1484 | PATH := ${PATH} |
1482 | .Li .unexport-env | | 1485 | .Li .unexport-env |
1483 | .Li .export PATH | | 1486 | .Li .export PATH |
1484 | .Li .endif | | 1487 | .Li .endif |
1485 | .Pp | | 1488 | .Pp |
1486 | .Ed | | 1489 | .Ed |
1487 | Would result in an environment containing only | | 1490 | Would result in an environment containing only |
1488 | .Ql Ev PATH , | | 1491 | .Ql Ev PATH , |
1489 | which is the minimal useful environment. | | 1492 | which is the minimal useful environment. |
1490 | Actually | | 1493 | Actually |
1491 | .Ql Ev .MAKE.LEVEL | | 1494 | .Ql Ev .MAKE.LEVEL |
1492 | will also be pushed into the new environment. | | 1495 | will also be pushed into the new environment. |
1493 | .It Ic .warning Ar message | | 1496 | .It Ic .warning Ar message |
1494 | The message prefixed by | | 1497 | The message prefixed by |
1495 | .Ql Pa warning: | | 1498 | .Ql Pa warning: |
1496 | is printed along with the name of the makefile and line number. | | 1499 | is printed along with the name of the makefile and line number. |
1497 | .It Ic \&.if Oo \&! Oc Ns Ar expression Op Ar operator expression ... | | 1500 | .It Ic \&.if Oo \&! Oc Ns Ar expression Op Ar operator expression ... |
1498 | Test the value of an expression. | | 1501 | Test the value of an expression. |
1499 | .It Ic .ifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ... | | 1502 | .It Ic .ifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ... |
1500 | Test the value of a variable. | | 1503 | Test the value of a variable. |
1501 | .It Ic .ifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ... | | 1504 | .It Ic .ifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ... |
1502 | Test the value of a variable. | | 1505 | Test the value of a variable. |
1503 | .It Ic .ifmake Oo \&! Oc Ns Ar target Op Ar operator target ... | | 1506 | .It Ic .ifmake Oo \&! Oc Ns Ar target Op Ar operator target ... |
1504 | Test the target being built. | | 1507 | Test the target being built. |
1505 | .It Ic .ifnmake Oo \&! Ns Oc Ar target Op Ar operator target ... | | 1508 | .It Ic .ifnmake Oo \&! Ns Oc Ar target Op Ar operator target ... |
1506 | Test the target being built. | | 1509 | Test the target being built. |
1507 | .It Ic .else | | 1510 | .It Ic .else |
1508 | Reverse the sense of the last conditional. | | 1511 | Reverse the sense of the last conditional. |
1509 | .It Ic .elif Oo \&! Ns Oc Ar expression Op Ar operator expression ... | | 1512 | .It Ic .elif Oo \&! Ns Oc Ar expression Op Ar operator expression ... |
1510 | A combination of | | 1513 | A combination of |
1511 | .Ql Ic .else | | 1514 | .Ql Ic .else |
1512 | followed by | | 1515 | followed by |
1513 | .Ql Ic .if . | | 1516 | .Ql Ic .if . |
1514 | .It Ic .elifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ... | | 1517 | .It Ic .elifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ... |
1515 | A combination of | | 1518 | A combination of |
1516 | .Ql Ic .else | | 1519 | .Ql Ic .else |
1517 | followed by | | 1520 | followed by |
1518 | .Ql Ic .ifdef . | | 1521 | .Ql Ic .ifdef . |
1519 | .It Ic .elifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ... | | 1522 | .It Ic .elifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ... |
1520 | A combination of | | 1523 | A combination of |
1521 | .Ql Ic .else | | 1524 | .Ql Ic .else |
1522 | followed by | | 1525 | followed by |
1523 | .Ql Ic .ifndef . | | 1526 | .Ql Ic .ifndef . |
1524 | .It Ic .elifmake Oo \&! Oc Ns Ar target Op Ar operator target ... | | 1527 | .It Ic .elifmake Oo \&! Oc Ns Ar target Op Ar operator target ... |
1525 | A combination of | | 1528 | A combination of |
1526 | .Ql Ic .else | | 1529 | .Ql Ic .else |
1527 | followed by | | 1530 | followed by |
1528 | .Ql Ic .ifmake . | | 1531 | .Ql Ic .ifmake . |
1529 | .It Ic .elifnmake Oo \&! Oc Ns Ar target Op Ar operator target ... | | 1532 | .It Ic .elifnmake Oo \&! Oc Ns Ar target Op Ar operator target ... |
1530 | A combination of | | 1533 | A combination of |
1531 | .Ql Ic .else | | 1534 | .Ql Ic .else |
1532 | followed by | | 1535 | followed by |
1533 | .Ql Ic .ifnmake . | | 1536 | .Ql Ic .ifnmake . |
1534 | .It Ic .endif | | 1537 | .It Ic .endif |
1535 | End the body of the conditional. | | 1538 | End the body of the conditional. |
1536 | .El | | 1539 | .El |
1537 | .Pp | | 1540 | .Pp |
1538 | The | | 1541 | The |
1539 | .Ar operator | | 1542 | .Ar operator |
1540 | may be any one of the following: | | 1543 | may be any one of the following: |
1541 | .Bl -tag -width "Cm XX" | | 1544 | .Bl -tag -width "Cm XX" |
1542 | .It Cm \&|\&| | | 1545 | .It Cm \&|\&| |
1543 | Logical OR. | | 1546 | Logical OR. |
1544 | .It Cm \&\*[Am]\*[Am] | | 1547 | .It Cm \&\*[Am]\*[Am] |
1545 | Logical | | 1548 | Logical |
1546 | .Tn AND ; | | 1549 | .Tn AND ; |
1547 | of higher precedence than | | 1550 | of higher precedence than |
1548 | .Dq \&|\&| . | | 1551 | .Dq \&|\&| . |
1549 | .El | | 1552 | .El |
1550 | .Pp | | 1553 | .Pp |
1551 | As in C, | | 1554 | As in C, |
1552 | .Nm | | 1555 | .Nm |
1553 | will only evaluate a conditional as far as is necessary to determine | | 1556 | will only evaluate a conditional as far as is necessary to determine |
1554 | its value. | | 1557 | its value. |
1555 | Parentheses may be used to change the order of evaluation. | | 1558 | Parentheses may be used to change the order of evaluation. |
1556 | The boolean operator | | 1559 | The boolean operator |
1557 | .Ql Ic \&! | | 1560 | .Ql Ic \&! |
1558 | may be used to logically negate an entire | | 1561 | may be used to logically negate an entire |
1559 | conditional. | | 1562 | conditional. |
1560 | It is of higher precedence than | | 1563 | It is of higher precedence than |
1561 | .Ql Ic \&\*[Am]\*[Am] . | | 1564 | .Ql Ic \&\*[Am]\*[Am] . |
1562 | .Pp | | 1565 | .Pp |
1563 | The value of | | 1566 | The value of |
1564 | .Ar expression | | 1567 | .Ar expression |
1565 | may be any of the following: | | 1568 | may be any of the following: |
1566 | .Bl -tag -width defined | | 1569 | .Bl -tag -width defined |
1567 | .It Ic defined | | 1570 | .It Ic defined |
1568 | Takes a variable name as an argument and evaluates to true if the variable | | 1571 | Takes a variable name as an argument and evaluates to true if the variable |
1569 | has been defined. | | 1572 | has been defined. |
1570 | .It Ic make | | 1573 | .It Ic make |
1571 | Takes a target name as an argument and evaluates to true if the target | | 1574 | Takes a target name as an argument and evaluates to true if the target |
1572 | was specified as part of | | 1575 | was specified as part of |
1573 | .Nm Ns 's | | 1576 | .Nm Ns 's |
1574 | command line or was declared the default target (either implicitly or | | 1577 | command line or was declared the default target (either implicitly or |
1575 | explicitly, see | | 1578 | explicitly, see |
1576 | .Va .MAIN ) | | 1579 | .Va .MAIN ) |
1577 | before the line containing the conditional. | | 1580 | before the line containing the conditional. |
1578 | .It Ic empty | | 1581 | .It Ic empty |
1579 | Takes a variable, with possible modifiers, and evaluates to true if | | 1582 | Takes a variable, with possible modifiers, and evaluates to true if |
1580 | the expansion of the variable would result in an empty string. | | 1583 | the expansion of the variable would result in an empty string. |
1581 | .It Ic exists | | 1584 | .It Ic exists |
1582 | Takes a file name as an argument and evaluates to true if the file exists. | | 1585 | Takes a file name as an argument and evaluates to true if the file exists. |
1583 | The file is searched for on the system search path (see | | 1586 | The file is searched for on the system search path (see |
1584 | .Va .PATH ) . | | 1587 | .Va .PATH ) . |
1585 | .It Ic target | | 1588 | .It Ic target |
1586 | Takes a target name as an argument and evaluates to true if the target | | 1589 | Takes a target name as an argument and evaluates to true if the target |
1587 | has been defined. | | 1590 | has been defined. |
1588 | .It Ic commands | | 1591 | .It Ic commands |
1589 | Takes a target name as an argument and evaluates to true if the target | | 1592 | Takes a target name as an argument and evaluates to true if the target |
1590 | has been defined and has commands associated with it. | | 1593 | has been defined and has commands associated with it. |
1591 | .El | | 1594 | .El |
1592 | .Pp | | 1595 | .Pp |
1593 | .Ar Expression | | 1596 | .Ar Expression |
1594 | may also be an arithmetic or string comparison. | | 1597 | may also be an arithmetic or string comparison. |
1595 | Variable expansion is | | 1598 | Variable expansion is |
1596 | performed on both sides of the comparison, after which the integral | | 1599 | performed on both sides of the comparison, after which the integral |
1597 | values are compared. | | 1600 | values are compared. |
1598 | A value is interpreted as hexadecimal if it is | | 1601 | A value is interpreted as hexadecimal if it is |
1599 | preceded by 0x, otherwise it is decimal; octal numbers are not supported. | | 1602 | preceded by 0x, otherwise it is decimal; octal numbers are not supported. |
1600 | The standard C relational operators are all supported. | | 1603 | The standard C relational operators are all supported. |
1601 | If after | | 1604 | If after |
1602 | variable expansion, either the left or right hand side of a | | 1605 | variable expansion, either the left or right hand side of a |
1603 | .Ql Ic == | | 1606 | .Ql Ic == |
1604 | or | | 1607 | or |
1605 | .Ql Ic "!=" | | 1608 | .Ql Ic "!=" |
1606 | operator is not an integral value, then | | 1609 | operator is not an integral value, then |
1607 | string comparison is performed between the expanded | | 1610 | string comparison is performed between the expanded |
1608 | variables. | | 1611 | variables. |
1609 | If no relational operator is given, it is assumed that the expanded | | 1612 | If no relational operator is given, it is assumed that the expanded |
1610 | variable is being compared against 0 or an empty string in the case | | 1613 | variable is being compared against 0 or an empty string in the case |
1611 | of a string comparison. | | 1614 | of a string comparison. |
1612 | .Pp | | 1615 | .Pp |
1613 | When | | 1616 | When |
1614 | .Nm | | 1617 | .Nm |
1615 | is evaluating one of these conditional expressions, and it encounters | | 1618 | is evaluating one of these conditional expressions, and it encounters |
1616 | a (white-space separated) word it doesn't recognize, either the | | 1619 | a (white-space separated) word it doesn't recognize, either the |
1617 | .Dq make | | 1620 | .Dq make |
1618 | or | | 1621 | or |
1619 | .Dq defined | | 1622 | .Dq defined |
1620 | expression is applied to it, depending on the form of the conditional. | | 1623 | expression is applied to it, depending on the form of the conditional. |
1621 | If the form is | | 1624 | If the form is |
1622 | .Ql Ic .ifdef , | | 1625 | .Ql Ic .ifdef , |
1623 | .Ql Ic .ifndef , | | 1626 | .Ql Ic .ifndef , |
1624 | or | | 1627 | or |
1625 | .Ql Ic .if | | 1628 | .Ql Ic .if |
1626 | the | | 1629 | the |
1627 | .Dq defined | | 1630 | .Dq defined |
1628 | expression is applied. | | 1631 | expression is applied. |
1629 | Similarly, if the form is | | 1632 | Similarly, if the form is |
1630 | .Ql Ic .ifmake | | 1633 | .Ql Ic .ifmake |
1631 | or | | 1634 | or |
1632 | .Ql Ic .ifnmake , the | | 1635 | .Ql Ic .ifnmake , the |
1633 | .Dq make | | 1636 | .Dq make |
1634 | expression is applied. | | 1637 | expression is applied. |
1635 | .Pp | | 1638 | .Pp |
1636 | If the conditional evaluates to true the parsing of the makefile continues | | 1639 | If the conditional evaluates to true the parsing of the makefile continues |
1637 | as before. | | 1640 | as before. |
1638 | If it evaluates to false, the following lines are skipped. | | 1641 | If it evaluates to false, the following lines are skipped. |
1639 | In both cases this continues until a | | 1642 | In both cases this continues until a |
1640 | .Ql Ic .else | | 1643 | .Ql Ic .else |
1641 | or | | 1644 | or |
1642 | .Ql Ic .endif | | 1645 | .Ql Ic .endif |
1643 | is found. | | 1646 | is found. |
1644 | .Pp | | 1647 | .Pp |
1645 | For loops are typically used to apply a set of rules to a list of files. | | 1648 | For loops are typically used to apply a set of rules to a list of files. |
1646 | The syntax of a for loop is: | | 1649 | The syntax of a for loop is: |
1647 | .Pp | | 1650 | .Pp |
1648 | .Bl -tag -compact -width Ds | | 1651 | .Bl -tag -compact -width Ds |
1649 | .It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression | | 1652 | .It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression |
1650 | .It Aq make-rules | | 1653 | .It Aq make-rules |
1651 | .It Ic \&.endfor | | 1654 | .It Ic \&.endfor |
1652 | .El | | 1655 | .El |
1653 | .Pp | | 1656 | .Pp |
1654 | After the for | | 1657 | After the for |
1655 | .Ic expression | | 1658 | .Ic expression |
1656 | is evaluated, it is split into words. | | 1659 | is evaluated, it is split into words. |
1657 | On each iteration of the loop, one word is taken and assigned to each | | 1660 | On each iteration of the loop, one word is taken and assigned to each |
1658 | .Ic variable , | | 1661 | .Ic variable , |
1659 | in order, and these | | 1662 | in order, and these |
1660 | .Ic variables | | 1663 | .Ic variables |
1661 | are substituted into the | | 1664 | are substituted into the |
1662 | .Ic make-rules | | 1665 | .Ic make-rules |
1663 | inside the body of the for loop. | | 1666 | inside the body of the for loop. |
1664 | The number of words must come out even; that is, if there are three | | 1667 | The number of words must come out even; that is, if there are three |
1665 | iteration variables, the number of words provided must be a multiple | | 1668 | iteration variables, the number of words provided must be a multiple |
1666 | of three. | | 1669 | of three. |
1667 | .Sh COMMENTS | | 1670 | .Sh COMMENTS |
1668 | Comments begin with a hash | | 1671 | Comments begin with a hash |
1669 | .Pq Ql \&# | | 1672 | .Pq Ql \&# |
1670 | character, anywhere but in a shell | | 1673 | character, anywhere but in a shell |
1671 | command line, and continue to the end of an unescaped new line. | | 1674 | command line, and continue to the end of an unescaped new line. |
1672 | .Sh SPECIAL SOURCES (ATTRIBUTES) | | 1675 | .Sh SPECIAL SOURCES (ATTRIBUTES) |
1673 | .Bl -tag -width .IGNOREx | | 1676 | .Bl -tag -width .IGNOREx |
1674 | .It Ic .EXEC | | 1677 | .It Ic .EXEC |
1675 | Target is never out of date, but always execute commands anyway. | | 1678 | Target is never out of date, but always execute commands anyway. |
1676 | .It Ic .IGNORE | | 1679 | .It Ic .IGNORE |
1677 | Ignore any errors from the commands associated with this target, exactly | | 1680 | Ignore any errors from the commands associated with this target, exactly |
1678 | as if they all were preceded by a dash | | 1681 | as if they all were preceded by a dash |
1679 | .Pq Ql \- . | | 1682 | .Pq Ql \- . |
1680 | .\" .It Ic .INVISIBLE | | 1683 | .\" .It Ic .INVISIBLE |
1681 | .\" XXX | | 1684 | .\" XXX |
1682 | .\" .It Ic .JOIN | | 1685 | .\" .It Ic .JOIN |
1683 | .\" XXX | | 1686 | .\" XXX |
1684 | .It Ic .MADE | | 1687 | .It Ic .MADE |
1685 | Mark all sources of this target as being up-to-date. | | 1688 | Mark all sources of this target as being up-to-date. |
1686 | .It Ic .MAKE | | 1689 | .It Ic .MAKE |
1687 | Execute the commands associated with this target even if the | | 1690 | Execute the commands associated with this target even if the |
1688 | .Fl n | | 1691 | .Fl n |
1689 | or | | 1692 | or |
1690 | .Fl t | | 1693 | .Fl t |
1691 | options were specified. | | 1694 | options were specified. |
1692 | Normally used to mark recursive | | 1695 | Normally used to mark recursive |
1693 | .Nm Ns 's . | | 1696 | .Nm Ns 's . |
1694 | .It Ic .META | | 1697 | .It Ic .META |
1695 | Create a meta file for the target, even if it is flagged as | | 1698 | Create a meta file for the target, even if it is flagged as |
1696 | .Ic .PHONY , | | 1699 | .Ic .PHONY , |
1697 | .Ic .MAKE , | | 1700 | .Ic .MAKE , |
1698 | or | | 1701 | or |
1699 | .Ic .SPECIAL . | | 1702 | .Ic .SPECIAL . |
1700 | Usage in conjunction with | | 1703 | Usage in conjunction with |
1701 | .Ic .MAKE | | 1704 | .Ic .MAKE |
1702 | is the most likely case. | | 1705 | is the most likely case. |
1703 | In "meta" mode, the target is out-of-date if the meta file is missing. | | 1706 | In "meta" mode, the target is out-of-date if the meta file is missing. |
1704 | .It Ic .NOMETA | | 1707 | .It Ic .NOMETA |
1705 | Do not create a meta file for the target. | | 1708 | Do not create a meta file for the target. |
1706 | Meta files are also not created for | | 1709 | Meta files are also not created for |
1707 | .Ic .PHONY , | | 1710 | .Ic .PHONY , |
1708 | .Ic .MAKE , | | 1711 | .Ic .MAKE , |
1709 | or | | 1712 | or |
1710 | .Ic .SPECIAL | | 1713 | .Ic .SPECIAL |
1711 | targets. | | 1714 | targets. |
1712 | .It Ic .NOMETA_CMP | | 1715 | .It Ic .NOMETA_CMP |
1713 | Ignore differences in commands when deciding if target is out of date. | | 1716 | Ignore differences in commands when deciding if target is out of date. |
1714 | This is useful if the command contains a value which always changes. | | 1717 | This is useful if the command contains a value which always changes. |
1715 | If the number of commands change, though, the target will still be out of date. | | 1718 | If the number of commands change, though, the target will still be out of date. |
1716 | .It Ic .NOPATH | | 1719 | .It Ic .NOPATH |
1717 | Do not search for the target in the directories specified by | | 1720 | Do not search for the target in the directories specified by |
1718 | .Ic .PATH . | | 1721 | .Ic .PATH . |
1719 | .It Ic .NOTMAIN | | 1722 | .It Ic .NOTMAIN |
1720 | Normally | | 1723 | Normally |
1721 | .Nm | | 1724 | .Nm |
1722 | selects the first target it encounters as the default target to be built | | 1725 | selects the first target it encounters as the default target to be built |
1723 | if no target was specified. | | 1726 | if no target was specified. |
1724 | This source prevents this target from being selected. | | 1727 | This source prevents this target from being selected. |
1725 | .It Ic .OPTIONAL | | 1728 | .It Ic .OPTIONAL |
1726 | If a target is marked with this attribute and | | 1729 | If a target is marked with this attribute and |
1727 | .Nm | | 1730 | .Nm |
1728 | can't figure out how to create it, it will ignore this fact and assume | | 1731 | can't figure out how to create it, it will ignore this fact and assume |
1729 | the file isn't needed or already exists. | | 1732 | the file isn't needed or already exists. |
1730 | .It Ic .PHONY | | 1733 | .It Ic .PHONY |
1731 | The target does not | | 1734 | The target does not |
1732 | correspond to an actual file; it is always considered to be out of date, | | 1735 | correspond to an actual file; it is always considered to be out of date, |
1733 | and will not be created with the | | 1736 | and will not be created with the |
1734 | .Fl t | | 1737 | .Fl t |
1735 | option. | | 1738 | option. |
1736 | Suffix-transformation rules are not applied to | | 1739 | Suffix-transformation rules are not applied to |
1737 | .Ic .PHONY | | 1740 | .Ic .PHONY |
1738 | targets. | | 1741 | targets. |
1739 | .It Ic .PRECIOUS | | 1742 | .It Ic .PRECIOUS |
1740 | When | | 1743 | When |
1741 | .Nm | | 1744 | .Nm |
1742 | is interrupted, it normally removes any partially made targets. | | 1745 | is interrupted, it normally removes any partially made targets. |
1743 | This source prevents the target from being removed. | | 1746 | This source prevents the target from being removed. |
1744 | .It Ic .RECURSIVE | | 1747 | .It Ic .RECURSIVE |
1745 | Synonym for | | 1748 | Synonym for |
1746 | .Ic .MAKE . | | 1749 | .Ic .MAKE . |
1747 | .It Ic .SILENT | | 1750 | .It Ic .SILENT |
1748 | Do not echo any of the commands associated with this target, exactly | | 1751 | Do not echo any of the commands associated with this target, exactly |
1749 | as if they all were preceded by an at sign | | 1752 | as if they all were preceded by an at sign |
1750 | .Pq Ql @ . | | 1753 | .Pq Ql @ . |
1751 | .It Ic .USE | | 1754 | .It Ic .USE |
1752 | Turn the target into | | 1755 | Turn the target into |
1753 | .Nm Ns 's | | 1756 | .Nm Ns 's |
1754 | version of a macro. | | 1757 | version of a macro. |
1755 | When the target is used as a source for another target, the other target | | 1758 | When the target is used as a source for another target, the other target |
1756 | acquires the commands, sources, and attributes (except for | | 1759 | acquires the commands, sources, and attributes (except for |
1757 | .Ic .USE ) | | 1760 | .Ic .USE ) |
1758 | of the | | 1761 | of the |
1759 | source. | | 1762 | source. |
1760 | If the target already has commands, the | | 1763 | If the target already has commands, the |
1761 | .Ic .USE | | 1764 | .Ic .USE |
1762 | target's commands are appended | | 1765 | target's commands are appended |
1763 | to them. | | 1766 | to them. |
1764 | .It Ic .USEBEFORE | | 1767 | .It Ic .USEBEFORE |
1765 | Exactly like | | 1768 | Exactly like |
1766 | .Ic .USE , | | 1769 | .Ic .USE , |
1767 | but prepend the | | 1770 | but prepend the |
1768 | .Ic .USEBEFORE | | 1771 | .Ic .USEBEFORE |
1769 | target commands to the target. | | 1772 | target commands to the target. |
1770 | .It Ic .WAIT | | 1773 | .It Ic .WAIT |
1771 | If | | 1774 | If |
1772 | .Ic .WAIT | | 1775 | .Ic .WAIT |
1773 | appears in a dependency line, the sources that precede it are | | 1776 | appears in a dependency line, the sources that precede it are |
1774 | made before the sources that succeed it in the line. | | 1777 | made before the sources that succeed it in the line. |
1775 | Since the dependents of files are not made until the file itself | | 1778 | Since the dependents of files are not made until the file itself |
1776 | could be made, this also stops the dependents being built unless they | | 1779 | could be made, this also stops the dependents being built unless they |
1777 | are needed for another branch of the dependency tree. | | 1780 | are needed for another branch of the dependency tree. |
1778 | So given: | | 1781 | So given: |
1779 | .Bd -literal | | 1782 | .Bd -literal |
1780 | x: a .WAIT b | | 1783 | x: a .WAIT b |
1781 | echo x | | 1784 | echo x |
1782 | a: | | 1785 | a: |
1783 | echo a | | 1786 | echo a |
1784 | b: b1 | | 1787 | b: b1 |
1785 | echo b | | 1788 | echo b |
1786 | b1: | | 1789 | b1: |
1787 | echo b1 | | 1790 | echo b1 |
1788 | | | 1791 | |
1789 | .Ed | | 1792 | .Ed |
1790 | the output is always | | 1793 | the output is always |
1791 | .Ql a , | | 1794 | .Ql a , |
1792 | .Ql b1 , | | 1795 | .Ql b1 , |
1793 | .Ql b , | | 1796 | .Ql b , |
1794 | .Ql x . | | 1797 | .Ql x . |
1795 | .br | | 1798 | .br |
1796 | The ordering imposed by | | 1799 | The ordering imposed by |
1797 | .Ic .WAIT | | 1800 | .Ic .WAIT |
1798 | is only relevant for parallel makes. | | 1801 | is only relevant for parallel makes. |
1799 | .El | | 1802 | .El |
1800 | .Sh SPECIAL TARGETS | | 1803 | .Sh SPECIAL TARGETS |
1801 | Special targets may not be included with other targets, i.e. they must be | | 1804 | Special targets may not be included with other targets, i.e. they must be |
1802 | the only target specified. | | 1805 | the only target specified. |
1803 | .Bl -tag -width .BEGINx | | 1806 | .Bl -tag -width .BEGINx |
1804 | .It Ic .BEGIN | | 1807 | .It Ic .BEGIN |
1805 | Any command lines attached to this target are executed before anything | | 1808 | Any command lines attached to this target are executed before anything |
1806 | else is done. | | 1809 | else is done. |
1807 | .It Ic .DEFAULT | | 1810 | .It Ic .DEFAULT |
1808 | This is sort of a | | 1811 | This is sort of a |
1809 | .Ic .USE | | 1812 | .Ic .USE |
1810 | rule for any target (that was used only as a | | 1813 | rule for any target (that was used only as a |
1811 | source) that | | 1814 | source) that |
1812 | .Nm | | 1815 | .Nm |
1813 | can't figure out any other way to create. | | 1816 | can't figure out any other way to create. |
1814 | Only the shell script is used. | | 1817 | Only the shell script is used. |
1815 | The | | 1818 | The |
1816 | .Ic .IMPSRC | | 1819 | .Ic .IMPSRC |
1817 | variable of a target that inherits | | 1820 | variable of a target that inherits |
1818 | .Ic .DEFAULT Ns 's | | 1821 | .Ic .DEFAULT Ns 's |
1819 | commands is set | | 1822 | commands is set |
1820 | to the target's own name. | | 1823 | to the target's own name. |
1821 | .It Ic .END | | 1824 | .It Ic .END |
1822 | Any command lines attached to this target are executed after everything | | 1825 | Any command lines attached to this target are executed after everything |
1823 | else is done. | | 1826 | else is done. |
1824 | .It Ic .ERROR | | 1827 | .It Ic .ERROR |
1825 | Any command lines attached to this target are executed when another target fails. | | 1828 | Any command lines attached to this target are executed when another target fails. |
1826 | The | | 1829 | The |
1827 | .Ic .ERROR_TARGET | | 1830 | .Ic .ERROR_TARGET |
1828 | variable is set to the target that failed. | | 1831 | variable is set to the target that failed. |
1829 | See also | | 1832 | See also |
1830 | .Ic MAKE_PRINT_VAR_ON_ERROR . | | 1833 | .Ic MAKE_PRINT_VAR_ON_ERROR . |
1831 | .It Ic .IGNORE | | 1834 | .It Ic .IGNORE |
1832 | Mark each of the sources with the | | 1835 | Mark each of the sources with the |
1833 | .Ic .IGNORE | | 1836 | .Ic .IGNORE |
1834 | attribute. | | 1837 | attribute. |
1835 | If no sources are specified, this is the equivalent of specifying the | | 1838 | If no sources are specified, this is the equivalent of specifying the |
1836 | .Fl i | | 1839 | .Fl i |
1837 | option. | | 1840 | option. |
1838 | .It Ic .INTERRUPT | | 1841 | .It Ic .INTERRUPT |
1839 | If | | 1842 | If |
1840 | .Nm | | 1843 | .Nm |
1841 | is interrupted, the commands for this target will be executed. | | 1844 | is interrupted, the commands for this target will be executed. |
1842 | .It Ic .MAIN | | 1845 | .It Ic .MAIN |
1843 | If no target is specified when | | 1846 | If no target is specified when |
1844 | .Nm | | 1847 | .Nm |
1845 | is invoked, this target will be built. | | 1848 | is invoked, this target will be built. |
1846 | .It Ic .MAKEFLAGS | | 1849 | .It Ic .MAKEFLAGS |
1847 | This target provides a way to specify flags for | | 1850 | This target provides a way to specify flags for |
1848 | .Nm | | 1851 | .Nm |
1849 | when the makefile is used. | | 1852 | when the makefile is used. |
1850 | The flags are as if typed to the shell, though the | | 1853 | The flags are as if typed to the shell, though the |
1851 | .Fl f | | 1854 | .Fl f |
1852 | option will have | | 1855 | option will have |
1853 | no effect. | | 1856 | no effect. |
1854 | .\" XXX: NOT YET!!!! | | 1857 | .\" XXX: NOT YET!!!! |
1855 | .\" .It Ic .NOTPARALLEL | | 1858 | .\" .It Ic .NOTPARALLEL |
1856 | .\" The named targets are executed in non parallel mode. | | 1859 | .\" The named targets are executed in non parallel mode. |
1857 | .\" If no targets are | | 1860 | .\" If no targets are |
1858 | .\" specified, then all targets are executed in non parallel mode. | | 1861 | .\" specified, then all targets are executed in non parallel mode. |
1859 | .It Ic .NOPATH | | 1862 | .It Ic .NOPATH |
1860 | Apply the | | 1863 | Apply the |
1861 | .Ic .NOPATH | | 1864 | .Ic .NOPATH |
1862 | attribute to any specified sources. | | 1865 | attribute to any specified sources. |
1863 | .It Ic .NOTPARALLEL | | 1866 | .It Ic .NOTPARALLEL |
1864 | Disable parallel mode. | | 1867 | Disable parallel mode. |
1865 | .It Ic .NO_PARALLEL | | 1868 | .It Ic .NO_PARALLEL |
1866 | Synonym for | | 1869 | Synonym for |
1867 | .Ic .NOTPARALLEL , | | 1870 | .Ic .NOTPARALLEL , |
1868 | for compatibility with other pmake variants. | | 1871 | for compatibility with other pmake variants. |
1869 | .It Ic .ORDER | | 1872 | .It Ic .ORDER |
1870 | The named targets are made in sequence. | | 1873 | The named targets are made in sequence. |
1871 | This ordering does not add targets to the list of targets to be made. | | 1874 | This ordering does not add targets to the list of targets to be made. |
1872 | Since the dependents of a target do not get built until the target itself | | 1875 | Since the dependents of a target do not get built until the target itself |
1873 | could be built, unless | | 1876 | could be built, unless |
1874 | .Ql a | | 1877 | .Ql a |
1875 | is built by another part of the dependency graph, | | 1878 | is built by another part of the dependency graph, |
1876 | the following is a dependency loop: | | 1879 | the following is a dependency loop: |
1877 | .Bd -literal | | 1880 | .Bd -literal |
1878 | \&.ORDER: b a | | 1881 | \&.ORDER: b a |
1879 | b: a | | 1882 | b: a |
1880 | .Ed | | 1883 | .Ed |
1881 | .Pp | | 1884 | .Pp |
1882 | The ordering imposed by | | 1885 | The ordering imposed by |
1883 | .Ic .ORDER | | 1886 | .Ic .ORDER |
1884 | is only relevant for parallel makes. | | 1887 | is only relevant for parallel makes. |
1885 | .\" XXX: NOT YET!!!! | | 1888 | .\" XXX: NOT YET!!!! |
1886 | .\" .It Ic .PARALLEL | | 1889 | .\" .It Ic .PARALLEL |
1887 | .\" The named targets are executed in parallel mode. | | 1890 | .\" The named targets are executed in parallel mode. |
1888 | .\" If no targets are | | 1891 | .\" If no targets are |
1889 | .\" specified, then all targets are executed in parallel mode. | | 1892 | .\" specified, then all targets are executed in parallel mode. |
1890 | .It Ic .PATH | | 1893 | .It Ic .PATH |
1891 | The sources are directories which are to be searched for files not | | 1894 | The sources are directories which are to be searched for files not |
1892 | found in the current directory. | | 1895 | found in the current directory. |
1893 | If no sources are specified, any previously specified directories are | | 1896 | If no sources are specified, any previously specified directories are |
1894 | deleted. | | 1897 | deleted. |
1895 | If the source is the special | | 1898 | If the source is the special |
1896 | .Ic .DOTLAST | | 1899 | .Ic .DOTLAST |
1897 | target, then the current working | | 1900 | target, then the current working |
1898 | directory is searched last. | | 1901 | directory is searched last. |
1899 | .It Ic .PHONY | | 1902 | .It Ic .PHONY |
1900 | Apply the | | 1903 | Apply the |
1901 | .Ic .PHONY | | 1904 | .Ic .PHONY |
1902 | attribute to any specified sources. | | 1905 | attribute to any specified sources. |
1903 | .It Ic .PRECIOUS | | 1906 | .It Ic .PRECIOUS |
1904 | Apply the | | 1907 | Apply the |
1905 | .Ic .PRECIOUS | | 1908 | .Ic .PRECIOUS |
1906 | attribute to any specified sources. | | 1909 | attribute to any specified sources. |
1907 | If no sources are specified, the | | 1910 | If no sources are specified, the |
1908 | .Ic .PRECIOUS | | 1911 | .Ic .PRECIOUS |
1909 | attribute is applied to every | | 1912 | attribute is applied to every |
1910 | target in the file. | | 1913 | target in the file. |
1911 | .It Ic .SHELL | | 1914 | .It Ic .SHELL |
1912 | Sets the shell that | | 1915 | Sets the shell that |
1913 | .Nm | | 1916 | .Nm |
1914 | will use to execute commands. | | 1917 | will use to execute commands. |
1915 | The sources are a set of | | 1918 | The sources are a set of |
1916 | .Ar field=value | | 1919 | .Ar field=value |
1917 | pairs. | | 1920 | pairs. |
1918 | .Bl -tag -width hasErrCtls | | 1921 | .Bl -tag -width hasErrCtls |
1919 | .It Ar name | | 1922 | .It Ar name |
1920 | This is the minimal specification, used to select one of the builtin | | 1923 | This is the minimal specification, used to select one of the builtin |
1921 | shell specs; | | 1924 | shell specs; |
1922 | .Ar sh , | | 1925 | .Ar sh , |
1923 | .Ar ksh , | | 1926 | .Ar ksh , |
1924 | and | | 1927 | and |
1925 | .Ar csh . | | 1928 | .Ar csh . |
1926 | .It Ar path | | 1929 | .It Ar path |
1927 | Specifies the path to the shell. | | 1930 | Specifies the path to the shell. |
1928 | .It Ar hasErrCtl | | 1931 | .It Ar hasErrCtl |
1929 | Indicates whether the shell supports exit on error. | | 1932 | Indicates whether the shell supports exit on error. |
1930 | .It Ar check | | 1933 | .It Ar check |
1931 | The command to turn on error checking. | | 1934 | The command to turn on error checking. |
1932 | .It Ar ignore | | 1935 | .It Ar ignore |
1933 | The command to disable error checking. | | 1936 | The command to disable error checking. |
1934 | .It Ar echo | | 1937 | .It Ar echo |
1935 | The command to turn on echoing of commands executed. | | 1938 | The command to turn on echoing of commands executed. |
1936 | .It Ar quiet | | 1939 | .It Ar quiet |
1937 | The command to turn off echoing of commands executed. | | 1940 | The command to turn off echoing of commands executed. |
1938 | .It Ar filter | | 1941 | .It Ar filter |
1939 | The output to filter after issuing the | | 1942 | The output to filter after issuing the |
1940 | .Ar quiet | | 1943 | .Ar quiet |
1941 | command. | | 1944 | command. |
1942 | It is typically identical to | | 1945 | It is typically identical to |
1943 | .Ar quiet . | | 1946 | .Ar quiet . |
1944 | .It Ar errFlag | | 1947 | .It Ar errFlag |
1945 | The flag to pass the shell to enable error checking. | | 1948 | The flag to pass the shell to enable error checking. |
1946 | .It Ar echoFlag | | 1949 | .It Ar echoFlag |
1947 | The flag to pass the shell to enable command echoing. | | 1950 | The flag to pass the shell to enable command echoing. |
1948 | .It Ar newline | | 1951 | .It Ar newline |
1949 | The string literal to pass the shell that results in a single newline | | 1952 | The string literal to pass the shell that results in a single newline |
1950 | character when used outside of any quoting characters. | | 1953 | character when used outside of any quoting characters. |
1951 | .El | | 1954 | .El |
1952 | Example: | | 1955 | Example: |
1953 | .Bd -literal | | 1956 | .Bd -literal |
1954 | \&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e | | 1957 | \&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e |
1955 | check="set \-e" ignore="set +e" \e | | 1958 | check="set \-e" ignore="set +e" \e |
1956 | echo="set \-v" quiet="set +v" filter="set +v" \e | | 1959 | echo="set \-v" quiet="set +v" filter="set +v" \e |
1957 | echoFlag=v errFlag=e newline="'\en'" | | 1960 | echoFlag=v errFlag=e newline="'\en'" |
1958 | .Ed | | 1961 | .Ed |
1959 | .It Ic .SILENT | | 1962 | .It Ic .SILENT |
1960 | Apply the | | 1963 | Apply the |
1961 | .Ic .SILENT | | 1964 | .Ic .SILENT |
1962 | attribute to any specified sources. | | 1965 | attribute to any specified sources. |
1963 | If no sources are specified, the | | 1966 | If no sources are specified, the |
1964 | .Ic .SILENT | | 1967 | .Ic .SILENT |
1965 | attribute is applied to every | | 1968 | attribute is applied to every |
1966 | command in the file. | | 1969 | command in the file. |
1967 | .It Ic .SUFFIXES | | 1970 | .It Ic .SUFFIXES |
1968 | Each source specifies a suffix to | | 1971 | Each source specifies a suffix to |
1969 | .Nm . | | 1972 | .Nm . |
1970 | If no sources are specified, any previously specified suffixes are deleted. | | 1973 | If no sources are specified, any previously specified suffixes are deleted. |
1971 | It allows the creation of suffix-transformation rules. | | 1974 | It allows the creation of suffix-transformation rules. |
1972 | .Pp | | 1975 | .Pp |
1973 | Example: | | 1976 | Example: |
1974 | .Bd -literal | | 1977 | .Bd -literal |
1975 | \&.SUFFIXES: .o | | 1978 | \&.SUFFIXES: .o |
1976 | \&.c.o: | | 1979 | \&.c.o: |
1977 | cc \-o ${.TARGET} \-c ${.IMPSRC} | | 1980 | cc \-o ${.TARGET} \-c ${.IMPSRC} |
1978 | .Ed | | 1981 | .Ed |
1979 | .El | | 1982 | .El |
1980 | .Sh ENVIRONMENT | | 1983 | .Sh ENVIRONMENT |
1981 | .Nm | | 1984 | .Nm |
1982 | uses the following environment variables, if they exist: | | 1985 | uses the following environment variables, if they exist: |
1983 | .Ev MACHINE , | | 1986 | .Ev MACHINE , |
1984 | .Ev MACHINE_ARCH , | | 1987 | .Ev MACHINE_ARCH , |
1985 | .Ev MAKE , | | 1988 | .Ev MAKE , |
1986 | .Ev MAKEFLAGS , | | 1989 | .Ev MAKEFLAGS , |
1987 | .Ev MAKEOBJDIR , | | 1990 | .Ev MAKEOBJDIR , |
1988 | .Ev MAKEOBJDIRPREFIX , | | 1991 | .Ev MAKEOBJDIRPREFIX , |
1989 | .Ev MAKESYSPATH , | | 1992 | .Ev MAKESYSPATH , |
1990 | .Ev PWD , | | 1993 | .Ev PWD , |
1991 | and | | 1994 | and |
1992 | .Ev TMPDIR . | | 1995 | .Ev TMPDIR . |
1993 | .Pp | | 1996 | .Pp |
1994 | .Ev MAKEOBJDIRPREFIX | | 1997 | .Ev MAKEOBJDIRPREFIX |
1995 | and | | 1998 | and |
1996 | .Ev MAKEOBJDIR | | 1999 | .Ev MAKEOBJDIR |
1997 | may only be set in the environment or on the command line to | | 2000 | may only be set in the environment or on the command line to |
1998 | .Nm | | 2001 | .Nm |
1999 | and not as makefile variables; | | 2002 | and not as makefile variables; |
2000 | see the description of | | 2003 | see the description of |
2001 | .Ql Va .OBJDIR | | 2004 | .Ql Va .OBJDIR |
2002 | for more details. | | 2005 | for more details. |
2003 | .Sh FILES | | 2006 | .Sh FILES |
2004 | .Bl -tag -width /usr/share/mk -compact | | 2007 | .Bl -tag -width /usr/share/mk -compact |
2005 | .It .depend | | 2008 | .It .depend |
2006 | list of dependencies | | 2009 | list of dependencies |
2007 | .It Makefile | | 2010 | .It Makefile |
2008 | list of dependencies | | 2011 | list of dependencies |
2009 | .It makefile | | 2012 | .It makefile |
2010 | list of dependencies | | 2013 | list of dependencies |
2011 | .It sys.mk | | 2014 | .It sys.mk |
2012 | system makefile | | 2015 | system makefile |
2013 | .It /usr/share/mk | | 2016 | .It /usr/share/mk |
2014 | system makefile directory | | 2017 | system makefile directory |
2015 | .El | | 2018 | .El |
2016 | .Sh COMPATIBILITY | | 2019 | .Sh COMPATIBILITY |
2017 | The basic make syntax is compatible between different versions of make, | | 2020 | The basic make syntax is compatible between different versions of make, |
2018 | however the special variables, variable modifiers and conditionals are not. | | 2021 | however the special variables, variable modifiers and conditionals are not. |
2019 | .Pp | | 2022 | .Pp |
2020 | The way that parallel makes are scheduled changed in | | 2023 | The way that parallel makes are scheduled changed in |
2021 | .Nx 4.0 | | 2024 | .Nx 4.0 |
2022 | so that .ORDER and .WAIT apply recursively to the dependent nodes. | | 2025 | so that .ORDER and .WAIT apply recursively to the dependent nodes. |
2023 | The algorithms used may change again in the future. | | 2026 | The algorithms used may change again in the future. |
2024 | .Pp | | 2027 | .Pp |
2025 | The way that .for loop variables are substituted changed after | | 2028 | The way that .for loop variables are substituted changed after |
2026 | .Nx 5.0 | | 2029 | .Nx 5.0 |
2027 | so that they still appear to be variable expansions. | | 2030 | so that they still appear to be variable expansions. |
2028 | In particular this stops them being treated as syntax, and removes some | | 2031 | In particular this stops them being treated as syntax, and removes some |
2029 | obscure problems using them in .if statements. | | 2032 | obscure problems using them in .if statements. |
2030 | .Pp | | 2033 | .Pp |
2031 | Unlike other | | 2034 | Unlike other |
2032 | .Nm | | 2035 | .Nm |
2033 | programs, this implementation by default executes all commands for a given | | 2036 | programs, this implementation by default executes all commands for a given |
2034 | target using a single shell invocation. | | 2037 | target using a single shell invocation. |
2035 | This is done for both efficiency and to simplify error handling in remote | | 2038 | This is done for both efficiency and to simplify error handling in remote |
2036 | command invocations. | | 2039 | command invocations. |
2037 | Typically this is transparent to the user, unless the target commands change | | 2040 | Typically this is transparent to the user, unless the target commands change |
2038 | the current working directory using | | 2041 | the current working directory using |
2039 | .Dq cd | | 2042 | .Dq cd |
2040 | or | | 2043 | or |
2041 | .Dq chdir . | | 2044 | .Dq chdir . |
2042 | To be compatible with Makefiles that do this, one can use | | 2045 | To be compatible with Makefiles that do this, one can use |
2043 | .Fl B | | 2046 | .Fl B |
2044 | to disable this behavior. | | 2047 | to disable this behavior. |
2045 | .Sh SEE ALSO | | 2048 | .Sh SEE ALSO |
2046 | .Xr mkdep 1 | | 2049 | .Xr mkdep 1 |
2047 | .Sh HISTORY | | 2050 | .Sh HISTORY |
2048 | A | | 2051 | A |
2049 | .Nm | | 2052 | .Nm |
2050 | command appeared in | | 2053 | command appeared in |
2051 | .At v7 . | | 2054 | .At v7 . |
2052 | This | | 2055 | This |
2053 | .Nm | | 2056 | .Nm |
2054 | implementation is based on Adam De Boor's pmake program which was written | | 2057 | implementation is based on Adam De Boor's pmake program which was written |
2055 | for Sprint at Berkeley. | | 2058 | for Sprint at Berkeley. |
2056 | It was designed to be a parallel distributed make running jobs on different | | 2059 | It was designed to be a parallel distributed make running jobs on different |
2057 | machines using a daemon called | | 2060 | machines using a daemon called |
2058 | .Dq customs . | | 2061 | .Dq customs . |
2059 | .Sh BUGS | | 2062 | .Sh BUGS |
2060 | The | | 2063 | The |
2061 | .Nm | | 2064 | .Nm |
2062 | syntax is difficult to parse without actually acting of the data. | | 2065 | syntax is difficult to parse without actually acting of the data. |
2063 | For instance finding the end of a variable use should involve scanning each | | 2066 | For instance finding the end of a variable use should involve scanning each |
2064 | the modifiers using the correct terminator for each field. | | 2067 | the modifiers using the correct terminator for each field. |
2065 | In many places | | 2068 | In many places |
2066 | .Nm | | 2069 | .Nm |
2067 | just counts {} and () in order to find the end of a variable expansion. | | 2070 | just counts {} and () in order to find the end of a variable expansion. |
2068 | .Pp | | 2071 | .Pp |
2069 | There is no way of escaping a space character in a filename. | | 2072 | There is no way of escaping a space character in a filename. |