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