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