Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | .\" Copyright (c) 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms, with or without | |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
19 | .\" | |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
31 | .\" | |
32 | .\" @(#)make.1 5.7 (Berkeley) 7/24/91 | |
33 | .\" | |
34 | .\" PATCHES MAGIC LEVEL PATCH THAT GOT US HERE | |
35 | .\" -------------------- ----- ---------------------- | |
36 | .\" CURRENT PATCH LEVEL: 1 00130 | |
37 | .\" -------------------- ----- ---------------------- | |
38 | .\" | |
39 | .\" 06 Apr 93 Sascha Wildner Misc small fixes | |
40 | .\" | |
41 | .Dd July 24, 1991 | |
42 | .Dt MAKE 1 | |
43 | .Os | |
44 | .Sh NAME | |
45 | .Nm make | |
46 | .Nd maintain program dependencies | |
47 | .Sh SYNOPSIS | |
48 | .Nm make | |
49 | .Op Fl eiknqrstv | |
50 | .Op Fl D Ar variable | |
51 | .Op Fl d Ar flags | |
52 | .Op Fl f Ar makefile | |
53 | .Op Fl I Ar directory | |
54 | .Bk -words | |
55 | .Op Fl j Ar max_jobs | |
56 | .Ek | |
57 | .Op Ar variable=value | |
58 | .Op Ar target ... | |
59 | .Sh DESCRIPTION | |
60 | .Nm Make | |
61 | is a program designed to simplify the maintenance of other programs. | |
62 | Its input is a list of specifications as to the files upon which programs | |
63 | and other files depend. | |
64 | If the file | |
65 | .Ql Pa makefile | |
66 | exists, it is read for this list of specifications. | |
67 | If it does not exist, the file | |
68 | .Ql Pa Makefile | |
69 | is read. | |
70 | If the file | |
71 | .Ql Pa .depend | |
72 | exists, it is read (see | |
73 | .Xr mkdep 1) . | |
74 | .Pp | |
75 | This manual page is intended as a reference document only. | |
76 | For a more thorough description of | |
77 | .Nm make | |
78 | and makefiles, please refer to | |
79 | .%T "Make \- A Tutorial" . | |
80 | .Pp | |
81 | The options are as follows: | |
82 | .Bl -tag -width Ds | |
83 | .It Fl D Ar variable | |
84 | Define | |
85 | .Ar variable | |
86 | to be 1, in the global context. | |
87 | .It Fl d Ar flags | |
88 | Turn on debugging, and specify which portions of | |
89 | .Nm make | |
90 | are to print debugging information. | |
91 | .Ar Flags | |
92 | is one or more of the following: | |
93 | .Bl -tag -width Ds | |
94 | .It Ar A | |
95 | Print all possible debugging information; | |
96 | equivalent to specifying all of the debugging flags. | |
97 | .It Ar a | |
98 | Print debugging information about archive searching and caching. | |
99 | .It Ar c | |
100 | Print debugging information about conditional evaluation. | |
101 | .It Ar d | |
102 | Print debugging information about directory searching and caching. | |
103 | .It Ar "g1" | |
104 | Print the input graph before making anything. | |
105 | .It Ar "g2" | |
106 | Print the input graph after making everything, or before exiting | |
107 | on error. | |
108 | .It Ar j | |
109 | Print debugging information about running multiple shells. | |
110 | .It Ar m | |
111 | Print debugging information about making targets, including modification | |
112 | dates. | |
113 | .It Ar s | |
114 | Print debugging information about suffix-transformation rules. | |
115 | .It Ar t | |
116 | Print debugging information about target list maintenance. | |
117 | .It Ar v | |
118 | Print debugging information about variable assignment. | |
119 | .El | |
120 | .It Fl e | |
121 | Specify that environmental variables override macro assignments within | |
122 | makefiles. | |
123 | .It Fl f Ar makefile | |
124 | Specify a makefile to read instead of the default | |
125 | .Ql Pa makefile | |
126 | and | |
127 | .Ql Pa Makefile . | |
128 | If | |
129 | .Ar makefile | |
130 | is | |
131 | .Ql Fl , | |
132 | standard input is read. | |
133 | Multiple makefile's may be specified, and are read in the order specified. | |
134 | .It Fl I Ar directory | |
135 | Specify a directory in which to search for makefiles and included makefiles. | |
136 | The system makefile directory is automatically included as part of this | |
137 | list. | |
138 | .It Fl i | |
139 | Ignore non-zero exit of shell commands in the makefile. | |
140 | Equivalent to specifying | |
141 | .Ql Fl | |
142 | before each command line in the makefile. | |
143 | .It Fl j Ar max_jobs | |
144 | Specify the maximum number of jobs that | |
145 | .Nm make | |
146 | may have running at any one time. | |
147 | .It Fl k | |
148 | Continue processing after errors are encountered, but only on those targets | |
149 | that do not depend on the target whose creation caused the error. | |
150 | .It Fl n | |
151 | Display the commands that would have been executed, but do not actually | |
152 | execute them. | |
153 | .It Fl q | |
154 | Do not execute any commands, but exit 0 if the specified targets are | |
155 | up-to-date and 1, otherwise. | |
156 | .It Fl r | |
157 | Do not use the built-in rules specified in the system makefile. | |
158 | .It Fl s | |
159 | Do not echo any commands as they are executed. | |
160 | Equivalent to specifying | |
161 | .Ql Ic @ | |
162 | before each command line in the makefile. | |
163 | .It Fl t | |
164 | Rather than re-building a target as specified in the makefile, create it | |
165 | or update its modification time to make it appear up-to-date. | |
166 | .It Ar variable=value | |
167 | Set the value of the variable | |
168 | .Ar variable | |
169 | to | |
170 | .Ar value . | |
171 | .El | |
172 | .Pp | |
173 | There are six different types of lines in a makefile: file dependency | |
174 | specifications, shell commands, variable assignments, include statements, | |
175 | conditional directives, and comments. | |
176 | .Pp | |
177 | In general, lines may be continued from one line to the next by ending | |
178 | them with a backslash | |
179 | .Pq Ql \e . | |
180 | The trailing newline character and initial whitespace on the following | |
181 | line are compressed into a single space. | |
182 | .Sh FILE DEPENDENCY SPECIFICATIONS | |
183 | Dependency lines consist of one or more targets, an operator, and zero | |
184 | or more sources. | |
185 | This creates a relationship where the targets ``depend'' on the sources | |
186 | and are usually created from them. | |
187 | The exact relationship between the target and the source is determined | |
188 | by the operator that separates them. | |
189 | The three operators are as follows: | |
190 | .Bl -tag -width flag | |
191 | .It Ic \&: | |
192 | A target is considered out-of-date if its modification time is less than | |
193 | those of any of its sources. | |
194 | Sources for a target accumulate over dependency lines when this operator | |
195 | is used. | |
196 | The target is removed if | |
197 | .Nm make | |
198 | is interrupted. | |
199 | .It Ic \&! | |
200 | Targets are always re-created, but not until all sources have been | |
201 | examined and re-created as necessary. | |
202 | Sources for a target accumulate over dependency lines when this operator | |
203 | is used. | |
204 | The target is removed if | |
205 | .Nm make | |
206 | is interrupted. | |
207 | .It Ic \&:: | |
208 | If no sources are specified, the target is always re-created. | |
209 | Otherwise, a target is considered out-of-date if any of its sources has | |
210 | been modified more recently than the target. | |
211 | Sources for a target do not accumulate over dependency lines when this | |
212 | operator is used. | |
213 | The target will not be removed if | |
214 | .Nm make | |
215 | is interrupted. | |
216 | .El | |
217 | .Pp | |
218 | Targets and sources may contain the shell wildcard values | |
219 | .Ql ? , | |
220 | .Ql * , | |
221 | .Ql [] | |
222 | and | |
223 | .Ql {} . | |
224 | The values | |
225 | .Ql ? , | |
226 | .Ql * | |
227 | and | |
228 | .Ql [] | |
229 | may only be used as part of the final | |
230 | component of the target or source, and must be used to describe existing | |
231 | files. | |
232 | The value | |
233 | .Ql {} | |
234 | need not necessarily be used to describe existing files. | |
235 | Expansion is in directory order, not alphabetically as done in the shell. | |
236 | .Sh SHELL COMMANDS | |
237 | Each target may have associated with it a series of shell commands, normally | |
238 | used to create the target. | |
239 | Each of the commands in this script | |
240 | .Em must | |
241 | be preceded by a tab. | |
242 | While any target may appear on a dependency line, only one of these | |
243 | dependencies may be followed by a creation script, unless the | |
244 | .Ql Ic :: | |
245 | operator is used. | |
246 | .Pp | |
247 | If the first or first two characters of the command line are | |
248 | .Ql Ic @ | |
249 | and/or | |
250 | .Ql Ic \- , | |
251 | the command is treated specially. | |
252 | A | |
253 | .Ql Ic @ | |
254 | causes the command not to be echoed before it is executed. | |
255 | A | |
256 | .Ql Ic \- | |
257 | causes any non-zero exit status of the command line to be ignored. | |
258 | .Sh VARIABLE ASSIGNMENTS | |
259 | Variables in make are much like variables in the shell, and, by tradition, | |
260 | consist of all upper-case letters. | |
261 | The five operators that can be used to assign values to variables are as | |
262 | follows: | |
263 | .Bl -tag -width Ds | |
264 | .It Ic \&= | |
265 | Assign the value to the variable. | |
266 | Any previous value is overridden. | |
267 | .It Ic \&+= | |
268 | Append the value to the current value of the variable. | |
269 | .It Ic \&?= | |
270 | Assign the value to the variable if it is not already defined. | |
271 | .It Ic \&:= | |
272 | Assign with expansion, i.e. expand the value before assigning it | |
273 | to the variable. | |
274 | Normally, expansion is not done until the variable is referenced. | |
275 | .It Ic \&!= | |
276 | Expand the value and pass it to the shell for execution and assign | |
277 | the result to the variable. | |
278 | Any newlines in the result are replaced with spaces. | |
279 | .El | |
280 | .Pp | |
281 | Any white-space before the assigned | |
282 | .Ar value | |
283 | is removed; if the value is being appended, a single space is inserted | |
284 | between the previous contents of the variable and the appended value. | |
285 | .Pp | |
286 | Variables are expanded by surrounding the variable name with either | |
287 | curly braces | |
288 | .Pq Ql {} | |
289 | or parenthesis | |
290 | .Pq Ql () | |
291 | and preceding it with | |
292 | a dollar sign | |
293 | .Pq Ql \&$ . | |
294 | If the variable name contains only a single letter, the surrounding | |
295 | braces or parenthesis are not required. | |
296 | This shorter form is not recommended. | |
297 | .Pp | |
298 | Variable substitution occurs at two distinct times, depending on where | |
299 | the variable is being used. | |
300 | Variables in dependency lines are expanded as the line is read. | |
301 | Variables in shell commands are expanded when the shell command is | |
302 | executed. | |
303 | .Pp | |
304 | The four different classes of variables (in order of increasing precedence) | |
305 | are: | |
306 | .Bl -tag -width Ds | |
307 | .It Environment variables | |
308 | Variables defined as part of | |
309 | .Nm make Ns 's | |
310 | environment. | |
311 | .It Global variables | |
312 | Variables defined in the makefile or in included makefiles. | |
313 | .It Command line variables | |
314 | Variables defined as part of the command line. | |
315 | .It Local variables | |
316 | Variables that are defined specific to a certain target. | |
317 | The seven local variables are as follows: | |
318 | .Bl -tag -width ".ARCHIVE" | |
319 | .It Va .ALLSRC | |
320 | The list of all sources for this target; also known as | |
321 | .Ql Va \&> . | |
322 | .It Va .ARCHIVE | |
323 | The name of the archive file. | |
324 | .It Va .IMPSRC | |
325 | The name/path of the source from which the target is to be transformed | |
326 | (the ``implied'' source); also known as | |
327 | .Ql Va \&< . | |
328 | .It Va .MEMBER | |
329 | The name of the archive member. | |
330 | .It Va .OODATE | |
331 | The list of sources for this target that were deemed out-of-date; also | |
332 | known as | |
333 | .Ql Va \&? . | |
334 | .It Va .PREFIX | |
335 | The file prefix of the file, containing only the file portion, no suffix | |
336 | or preceding directory components; also known as | |
337 | .Ql Va * . | |
338 | .It Va .TARGET | |
339 | The name of the target; also known as | |
340 | .Ql Va @ . | |
341 | .El | |
342 | .Pp | |
343 | The shorter forms | |
344 | .Ql Va @ , | |
345 | .Ql Va ? , | |
346 | .Ql Va \&> | |
347 | and | |
348 | .Ql Va * | |
349 | are permitted for backward | |
350 | compatibility with historical makefiles and are not recommended. | |
351 | The six variables | |
352 | .Ql Va "@F" , | |
353 | .Ql Va "@D" , | |
354 | .Ql Va "<F" , | |
355 | .Ql Va "<D" , | |
356 | .Ql Va "*F" | |
357 | and | |
358 | .Ql Va "*D" | |
359 | are | |
360 | permitted for compatibility with | |
361 | .At V | |
362 | makefiles and are not recommended. | |
363 | .Pp | |
364 | Four of the local variables may be used in sources on dependency lines | |
365 | because they expand to the proper value for each target on the line. | |
366 | These variables are | |
367 | .Ql Va .TARGET , | |
368 | .Ql Va .PREFIX , | |
369 | .Ql Va .ARCHIVE , | |
370 | and | |
371 | .Ql Va .MEMBER . | |
372 | .Pp | |
373 | In addition, | |
374 | .Nm make | |
375 | sets or knows about the following variables: | |
376 | .Bl -tag -width MAKEFLAGS | |
377 | .It Va \&$ | |
378 | A single dollar sign | |
379 | .Ql \&$ , | |
380 | i.e. | |
381 | .Ql \&$$ | |
382 | expands to a single dollar | |
383 | sign. | |
384 | .It Va .MAKE | |
385 | The name that | |
386 | .Nm make | |
387 | was executed with | |
388 | .Pq Va argv Op 0 | |
389 | .It Va .CURDIR | |
390 | A path to the directory where | |
391 | .Nm make | |
392 | was executed. | |
393 | .It Ev MAKEFLAGS | |
394 | The environment variable | |
395 | .Ql Ev MAKEFLAGS | |
396 | may contain anything that | |
397 | may be specified on | |
398 | .Nm make Ns 's | |
399 | command line. | |
400 | Anything specified on | |
401 | .Nm make Ns 's | |
402 | command line is appended to the | |
403 | .Ql Ev MAKEFLAGS | |
404 | variable which is then | |
405 | entered into the environment for all programs which | |
406 | .Nm make | |
407 | executes. | |
408 | .El | |
409 | .Pp | |
410 | Variable expansion may be modified to select or modify each word of the | |
411 | variable (where a ``word'' is white-space delimited sequence of characters). | |
412 | The general format of a variable expansion is as follows: | |
413 | .Pp | |
414 | .Dl {variable[:modifier[:...]]} | |
415 | .Pp | |
416 | Each modifier begins with a colon and one of the following | |
417 | special characters. | |
418 | The colon may be escaped with a backslash | |
419 | .Pq Ql \e . | |
420 | .Bl -tag -width Cm E\& | |
421 | .It Cm E | |
422 | Replaces each word in the variable with its suffix. | |
423 | .It Cm H | |
424 | Replaces each word in the variable with everything but the last component. | |
425 | .It Cm M Ns Ar pattern | |
426 | Select only those words that match the rest of the modifier. | |
427 | The standard shell wildcard characters | |
428 | .Pf ( Ql * , | |
429 | .Ql ? , | |
430 | and | |
431 | .Ql Op ) | |
432 | may | |
433 | be used. | |
434 | The wildcard characters may be escaped with a backslash | |
435 | .Pq Ql \e . | |
436 | .It Cm N Ns Ar pattern | |
437 | This is identical to | |
438 | .Ql Cm M , | |
439 | but selects all words which do not match | |
440 | the rest of the modifier. | |
441 | .It Cm R | |
442 | Replaces each word in the variable with everything but its suffix. | |
443 | .Sm off | |
444 | .It Cm S No \&/ Ar old_pattern Xo | |
445 | .No \&/ Ar new_pattern | |
446 | .No \&/ Op Cm g | |
447 | .Xc | |
448 | .Sm on | |
449 | Modify the first occurrence of | |
450 | .Ar old_pattern | |
451 | in each word to be replaced with | |
452 | .Ar new_pattern . | |
453 | If a | |
454 | .Ql g | |
455 | is appended to the last slash of the pattern, all occurrences | |
456 | in each word are replaced. | |
457 | If | |
458 | .Ar old_pattern | |
459 | begins with a carat | |
460 | .Pq Ql ^ , | |
461 | .Ar old_pattern | |
462 | is anchored at the beginning of each word. | |
463 | If | |
464 | .Ar old_pattern | |
465 | ends with a dollar sign | |
466 | .Pq Ql \&$ , | |
467 | it is anchored at the end of each word. | |
468 | Inside | |
469 | .Ar new_string , | |
470 | an ampersand | |
471 | .Pq Ql & | |
472 | is replaced by | |
473 | .Ar old_pattern . | |
474 | Any character may be used as a delimiter for the parts of the modifier | |
475 | string. | |
476 | The anchoring, ampersand and delimiter characters may be escaped with a | |
477 | backslash | |
478 | .Pq Ql \e . | |
479 | .Pp | |
480 | Variable expansion occurs in the normal fashion inside both | |
481 | .Ar old_string | |
482 | and | |
483 | .Ar new_string | |
484 | with the single exception that a backslash is used to prevent the expansion | |
485 | of a dollar sign | |
486 | .Pq Ql \&$ | |
487 | not a preceding dollar sign as is usual. | |
488 | .It Cm T | |
489 | Replaces each word in the variable with its last component. | |
490 | .It Ar old_string=new_string | |
491 | This is the | |
492 | .At V | |
493 | style variable substitution. | |
494 | It must be the last modifier specified. | |
495 | .Ar Old_string | |
496 | is anchored at the end of each word, so only suffixes or entire | |
497 | words may be replaced. | |
498 | .El | |
499 | .Sh INCLUDE STATEMENTS AND CONDITIONALS | |
500 | Makefile inclusion and conditional structures reminiscent of the C | |
501 | programming language are provided in | |
502 | .Nm make . | |
503 | All such structures are identified by a line beginning with a single | |
504 | dot | |
505 | .Pq Ql \&. | |
506 | character. | |
507 | Files are included with either | |
508 | .Ql .include <file> | |
509 | or | |
510 | .Ql .include \*qfile\*q . | |
511 | Variables between the angle brackets or double quotes are expanded | |
512 | to form the file name. | |
513 | If angle brackets are used, the included makefile is expected to be in | |
514 | the system makefile directory. | |
515 | If double quotes are used, the including makefile's directory and any | |
516 | directories specified using the | |
517 | .Fl I | |
518 | option are searched before the system | |
519 | makefile directory. | |
520 | .Pp | |
521 | Conditional expressions are also preceded by a single dot as the first | |
522 | chraracter of a line. | |
523 | The possible conditionals are as follows: | |
524 | .Bl -tag -width Ds | |
525 | .It Ic .undef Ar variable | |
526 | Un-define the specified global variable. | |
527 | Only global variables may be un-defined. | |
528 | .It Xo | |
529 | .Ic \&.if | |
530 | .Oo \&! Oc Ns Ar expression | |
531 | .Op Ar operator expression ... | |
532 | .Xc | |
533 | Test the value of an expression. | |
534 | .It Xo | |
535 | .Ic .ifdef | |
536 | .Oo \&! Oc Ns Ar variable | |
537 | .Op Ar operator variable ... | |
538 | .Xc | |
539 | Test the value of an variable. | |
540 | .It Xo | |
541 | .Ic .ifndef | |
542 | .Oo \&! Oc Ns Ar variable | |
543 | .Op Ar operator variable ... | |
544 | .Xc | |
545 | Test the value of an variable. | |
546 | .It Xo | |
547 | .Ic .ifmake | |
548 | .Oo \&! Oc Ns Ar target | |
549 | .Op Ar operator target ... | |
550 | .Xc | |
551 | Test the the target being built. | |
552 | .It Xo | |
553 | .Ic .ifnmake | |
554 | .Oo \&! Oc Ar target | |
555 | .Op Ar operator target ... | |
556 | .Xc | |
557 | Test the target being built. | |
558 | .It Ic .else | |
559 | Reverse the sense of the last conditional. | |
560 | .It Xo | |
561 | .Ic .elif | |
562 | .Oo \&! Oc Ar expression | |
563 | .Op Ar operator expression ... | |
564 | .Xc | |
565 | A combination of | |
566 | .Ql Ic .else | |
567 | followed by | |
568 | .Ql Ic .if . | |
569 | .It Xo | |
570 | .Ic .elifdef | |
571 | .Oo \&! Oc Ns Ar variable | |
572 | .Op Ar operator variable ... | |
573 | .Xc | |
574 | A combination of | |
575 | .Ql Ic .else | |
576 | followed by | |
577 | .Ql Ic .ifdef . | |
578 | .It Xo | |
579 | .Ic .elifndef | |
580 | .Oo \&! Oc Ns Ar variable | |
581 | .Op Ar operator variable ... | |
582 | .Xc | |
583 | A combination of | |
584 | .Ql Ic .else | |
585 | followed by | |
586 | .Ql Ic .ifndef . | |
587 | .It Xo | |
588 | .Ic .elifmake | |
589 | .Oo \&! Oc Ns Ar target | |
590 | .Op Ar operator target ... | |
591 | .Xc | |
592 | A combination of | |
593 | .Ql Ic .else | |
594 | followed by | |
595 | .Ql Ic .ifmake . | |
596 | .It Xo | |
597 | .Ic .elifnmake | |
598 | .Oo \&! Oc Ns Ar target | |
599 | .Op Ar operator target ... | |
600 | .Xc | |
601 | A combination of | |
602 | .Ql Ic .else | |
603 | followed by | |
604 | .Ql Ic .ifnmake . | |
605 | .It Ic .endif | |
606 | End the body of the conditional. | |
607 | .El | |
608 | .Pp | |
609 | The | |
610 | .Ar operator | |
611 | may be any one of the following: | |
612 | .Bl -tag -width "Cm XX" | |
613 | .It Cm \&|\&| | |
614 | logical OR | |
615 | .It Cm \&&& | |
616 | Logical | |
617 | .Tn AND ; | |
618 | of higher precedence than | |
619 | .Dq . | |
620 | .El | |
621 | .Pp | |
622 | As in C, | |
623 | .Nm make | |
624 | will only evaluate a conditional as far as is necessary to determine | |
625 | its value. | |
626 | Parenthesis may be used to change the order of evaluation. | |
627 | The boolean operator | |
628 | .Ql Ic \&! | |
629 | may be used to logically negate an entire | |
630 | conditional. | |
631 | It is of higher precendence than | |
632 | .Ql Ic \&&& . | |
633 | .Pp | |
634 | The value of | |
635 | .Ar expression | |
636 | may be any of the following: | |
637 | .Bl -tag -width Ic defined | |
638 | .It Ic defined | |
639 | Takes a variable name as an argument and evaluates to true if the variable | |
640 | has been defined. | |
641 | .It Ic make | |
642 | Takes a target name as an argument and evaluates to true if the target | |
643 | was specified as part of | |
644 | .Nm make Ns 's | |
645 | command line or was declared the default target (either implicitly or | |
646 | explicitly, see | |
647 | .Va .MAIN ) | |
648 | before the line containing the conditional. | |
649 | .It Ic empty | |
650 | Takes a variable, with possible modifiers, and evalutes to true if | |
651 | the expansion of the variable would result in an empty string. | |
652 | .It Ic exists | |
653 | Takes a file name as an argument and evaluates to true if the file exists. | |
654 | The file is searched for on the system search path (see | |
655 | .Va .PATH ) . | |
656 | .It Ic target | |
657 | Takes a target name as an argument and evaluates to true if the target | |
658 | has been defined. | |
659 | .El | |
660 | .Pp | |
661 | .Ar Expression | |
662 | may also be an arithmetic or string comparison, with the left-hand side | |
663 | being a variable expansion. | |
664 | The standard C relational operators are all supported, and the usual | |
665 | number/base conversion is performed. | |
666 | Note, octal numbers are not supported. | |
667 | If the righthand value of a | |
668 | .Ql Ic == | |
669 | or | |
670 | .Ql Ic "!=" | |
671 | operator begins with a | |
672 | quotation mark | |
673 | .Pq Ql \*q | |
674 | a string comparison is done between the expanded | |
675 | variable and the text between the quotation marks. | |
676 | If no relational operator is given, it is assumed that the expanded | |
677 | variable is being compared against 0. | |
678 | .Pp | |
679 | When | |
680 | .Nm make | |
681 | is evaluating one of these conditional expression, and it encounters | |
682 | a word it doesn't recognize, either the ``make'' or ``defined'' | |
683 | expression is applied to it, depending on the form of the conditional. | |
684 | If the form is | |
685 | .Ql Ic .ifdef | |
686 | or | |
687 | .Ql Ic .ifndef , | |
688 | the ``defined'' expression | |
689 | is applied. | |
690 | Similarly, if the form is | |
691 | .Ql Ic .ifmake | |
692 | or | |
693 | .Ql Ic .ifnmake , the ``make'' | |
694 | expression is applied. | |
695 | .Pp | |
696 | If the conditional evaluates to true the parsing of the makefile continues | |
697 | as before. | |
698 | If it evaluates to false, the following lines are skipped. | |
699 | In both cases this continues until a | |
700 | .Ql Ic .else | |
701 | or | |
702 | .Ql Ic .endif | |
703 | is found. | |
704 | .Sh COMMENTS | |
705 | Comments begin with a hash | |
706 | .Pq Ql \&# | |
707 | character, anywhere but in a shell | |
708 | command line, and continue to the end of the line. | |
709 | .Sh SPECIAL SOURCES | |
710 | .Bl -tag -width Ic .IGNORE | |
711 | .It Ic .IGNORE | |
712 | Ignore any errors from the commands associated with this target, exactly | |
713 | as if they all were preceded by a dash | |
714 | .Pq Ql \- . | |
715 | .It Ic .MAKE | |
716 | Execute the commands associated with this target even if the | |
717 | .Fl n | |
718 | or | |
719 | .Fl t | |
720 | options were specified. | |
721 | Normally used to mark recursive | |
722 | .Nm make Ns 's . | |
723 | .It Ic .NOTMAIN | |
724 | Normally | |
725 | .Nm make | |
726 | selects the first target it encounters as the default target to be built | |
727 | if no target was specified. | |
728 | This source prevents this target from being selected. | |
729 | .It Ic .OPTIONAL | |
730 | If a target is marked with this attribute and | |
731 | .Nm make | |
732 | can't figure out how to create it, it will ignore this fact and assume | |
733 | the file isn't needed or already exists. | |
734 | .It Ic .PRECIOUS | |
735 | When | |
736 | .Nm make | |
737 | is interrupted, it removes any partially made targets. | |
738 | This source prevents the target from being removed. | |
739 | .It Ic .SILENT | |
740 | Do not echo any of the commands associated with this target, exactly | |
741 | as if they all were preceded by an at sign | |
742 | .Pq Ql @ . | |
743 | .It Ic .USE | |
744 | Turn the target into | |
745 | .Nm make Ns 's . | |
746 | version of a macro. | |
747 | When the target is used as a source for another target, the other target | |
748 | acquires the commands, sources, and attributes (except for | |
749 | .Ic .USE ) | |
750 | of the | |
751 | source. | |
752 | If the target already has commands, the | |
753 | .Ic .USE | |
754 | target's commands are appended | |
755 | to them. | |
756 | .El | |
757 | .Sh "SPECIAL TARGETS" | |
758 | Special targets may not be included with other targets, i.e. they must be | |
759 | the only target specified. | |
760 | .Bl -tag -width Ic .BEGIN | |
761 | .It Ic .BEGIN | |
762 | Any command lines attached to this target are executed before anything | |
763 | else is done. | |
764 | .It Ic .DEFAULT | |
765 | This is sort of a | |
766 | .Ic .USE | |
767 | rule for any target (that was used only as a | |
768 | source) that | |
769 | .Nm make | |
770 | can't figure out any other way to create. | |
771 | Only the shell script is used. | |
772 | The | |
773 | .Ic .IMPSRC | |
774 | variable of a target that inherits | |
775 | .Ic .DEFAULT Ns 's | |
776 | commands is set | |
777 | to the target's own name. | |
778 | .It Ic .END | |
779 | Any command lines attached to this target are executed after everything | |
780 | else is done. | |
781 | .It Ic .IGNORE | |
782 | Mark each of the sources with the | |
783 | .Ic .IGNORE | |
784 | attribute. | |
785 | If no sources are specified, this is the equivalent of specifying the | |
786 | .Fl i | |
787 | option. | |
788 | .It Ic .INTERRUPT | |
789 | If | |
790 | .Nm make | |
791 | is interrupted, the commands for this target will be executed. | |
792 | .It Ic .MAIN | |
793 | If no target is specified when | |
794 | .Nm make | |
795 | is invoked, this target will be built. | |
796 | .It Ic .MAKEFLAGS | |
797 | This target provides a way to specify flags for | |
798 | .Nm make | |
799 | when the makefile is used. | |
800 | The flags are as if typed to the shell, though the | |
801 | .Fl f | |
802 | option will have | |
803 | no effect. | |
804 | .It Ic .PATH | |
805 | The sources are directories which are to be searched for files not | |
806 | found in the current directory. | |
807 | If no sources are specified, any previously specified directories are | |
808 | deleted. | |
809 | .It Ic .PRECIOUS | |
810 | Apply the | |
811 | .Ic .PRECIOUS | |
812 | attribute to any specified sources. | |
813 | If no sources are specified, the | |
814 | .Ic .PRECIOUS | |
815 | attribute is applied to every | |
816 | target in the file. | |
817 | .It Ic .SILENT | |
818 | Apply the | |
819 | .Ic .SILENT | |
820 | attribute to any specified sources. | |
821 | If no sources are specified, the | |
822 | .Ic .SILENT | |
823 | attribute is applied to every | |
824 | command in the file. | |
825 | .It Ic .SUFFIXES | |
826 | Each source specifies a suffix to | |
827 | .Nm make . | |
828 | If no sources are specified, any previous specifies suffices are deleted. | |
829 | .Sh ENVIRONMENT | |
830 | .Nm Make | |
831 | utilizes the following environment variables, if they exist: | |
832 | .Ev MAKE , | |
833 | .Ev MAKEFLAGS | |
834 | and | |
835 | .Ev MAKEOBJDIR . | |
836 | .Sh FILES | |
837 | .Bl -tag -width /usr/share/mk -compact | |
838 | .It .depend | |
839 | list of dependencies | |
840 | .It Makefile | |
841 | list of dependencies | |
842 | .It makefile | |
843 | list of dependencies | |
844 | .It sys.mk | |
845 | system makefile | |
846 | .It /usr/share/mk | |
847 | system makefile directory | |
848 | .El | |
849 | .Sh SEE ALSO | |
850 | .Xr mkdep 1 | |
851 | .Sh HISTORY | |
852 | A | |
853 | .Nm Make | |
854 | command appeared in | |
855 | .At v7 . |