Annotation of src/usr.bin/make/make.1, Revision 1.87
1.87 ! espie 1: .\" $OpenBSD: make.1,v 1.86 2010/02/04 07:46:20 jmc Exp $
1.10 millert 2: .\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $
1.7 briggs 3: .\"
1.9 millert 4: .\" Copyright (c) 1990, 1993
5: .\" The Regents of the University of California. All rights reserved.
1.1 deraadt 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.
1.51 millert 15: .\" 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 16: .\" may be used to endorse or promote products derived from this software
17: .\" without specific prior written permission.
18: .\"
19: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29: .\" SUCH DAMAGE.
30: .\"
1.9 millert 31: .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
1.1 deraadt 32: .\"
1.87 ! espie 33: .Dd $Mdocdate: February 4 2010 $
1.1 deraadt 34: .Dt MAKE 1
35: .Os
36: .Sh NAME
37: .Nm make
38: .Nd maintain program dependencies
39: .Sh SYNOPSIS
1.19 aaron 40: .Nm make
1.63 jmc 41: .Op Fl BeiknPqrSst
1.1 deraadt 42: .Op Fl D Ar variable
43: .Op Fl d Ar flags
44: .Op Fl f Ar makefile
45: .Op Fl I Ar directory
46: .Op Fl j Ar max_jobs
1.5 niklas 47: .Op Fl m Ar directory
1.9 millert 48: .Op Fl V Ar variable
1.60 espie 49: .Op Ar NAME Ns = Ns Ar value
1.50 jmc 50: .Bk -words
1.1 deraadt 51: .Op Ar target ...
1.50 jmc 52: .Ek
1.1 deraadt 53: .Sh DESCRIPTION
1.19 aaron 54: .Nm
1.1 deraadt 55: is a program designed to simplify the maintenance of other programs.
56: Its input is a list of specifications as to the files upon which programs
57: and other files depend.
58: If the file
1.54 jmc 59: .Sq Pa BSDmakefile
1.12 niklas 60: exists, it is read for this list of specifications.
61: If it does not exist, the files
1.54 jmc 62: .Sq Pa makefile
1.12 niklas 63: and
1.54 jmc 64: .Sq Pa Makefile
1.12 niklas 65: are tried in order.
1.1 deraadt 66: If the file
1.54 jmc 67: .Sq Pa .depend
1.40 espie 68: exists, it is read in addition to the makefile (see
1.42 mpech 69: .Xr mkdep 1 ) .
1.1 deraadt 70: .Pp
1.43 espie 71: The handling of
1.54 jmc 72: .Sq Pa BSDmakefile
1.43 espie 73: and
1.54 jmc 74: .Sq Pa .depend
1.43 espie 75: are BSD extensions.
76: .Pp
77: Standard options are as follows:
78: .Bl -tag -width Ds
79: .It Fl e
80: Specify that environment variables override macro assignments within
81: makefiles.
82: .It Fl f Ar makefile
83: Specify a makefile to read instead of the default
1.54 jmc 84: .Sq Pa makefile
1.43 espie 85: and
1.54 jmc 86: .Sq Pa Makefile .
1.43 espie 87: If
88: .Ar makefile
89: is
90: .Ql \- ,
91: standard input is read.
92: Multiple makefiles may be specified, and are read in the order specified.
93: .It Fl i
94: Ignore non-zero exit of shell commands in the makefile.
95: Equivalent to specifying
96: .Ql \-
97: before each command line in the makefile.
98: .It Fl k
99: Continue processing after errors are encountered, but only on those targets
100: that do not depend on the target whose creation caused the error.
101: .It Fl n
102: Display the commands that would have been executed, but do not actually
103: execute them.
104: .It Fl q
1.50 jmc 105: Do not execute any commands, but exit with status 0 if the specified targets
1.43 espie 106: are up-to-date, and 1 otherwise.
107: .It Fl r
108: Do not use the built-in rules specified in the system makefile.
109: .It Fl S
110: Stop processing when an error is encountered.
111: This is the default behavior.
112: This is needed to negate the
113: .Fl k
114: option during recursive builds.
115: .It Fl s
116: Do not echo commands as they are executed.
117: Equivalent to specifying
1.54 jmc 118: .Sq Ic @
1.43 espie 119: before each command line in the makefile.
120: .It Fl t
121: Rather than re-building a target as specified in the makefile, create it
122: or update its modification time to make it appear up-to-date.
1.60 espie 123: .It Ar NAME Ns = Ns Ar value
1.43 espie 124: Set the value of the variable
1.60 espie 125: .Ar NAME
1.43 espie 126: to
127: .Ar value .
128: .El
1.1 deraadt 129: .Pp
1.43 espie 130: Extended options are as follows:
1.1 deraadt 131: .Bl -tag -width Ds
1.9 millert 132: .It Fl B
1.3 deraadt 133: Try to be backwards compatible by executing a single shell per command and
134: by executing the commands to make the sources of a dependency line in sequence.
1.15 espie 135: This is turned on by default unless
136: .Fl j
137: is used.
1.1 deraadt 138: .It Fl D Ar variable
139: Define
140: .Ar variable
1.40 espie 141: to be 1.
1.1 deraadt 142: .It Fl d Ar flags
143: Turn on debugging, and specify which portions of
1.19 aaron 144: .Nm
1.1 deraadt 145: are to print debugging information.
1.14 aaron 146: .Ar flags
1.1 deraadt 147: is one or more of the following:
148: .Bl -tag -width Ds
149: .It Ar A
150: Print all possible debugging information;
151: equivalent to specifying all of the debugging flags.
152: .It Ar a
153: Print debugging information about archive searching and caching.
154: .It Ar c
155: Print debugging information about conditional evaluation.
156: .It Ar d
157: Print debugging information about directory searching and caching.
1.15 espie 158: .It Ar f
1.40 espie 159: Print debugging information about the expansion of for loops.
1.1 deraadt 160: .It Ar "g1"
161: Print the input graph before making anything.
162: .It Ar "g2"
163: Print the input graph after making everything, or before exiting
164: on error.
1.72 jmc 165: .It Ar J
166: Print job tokens showing which output corresponds to what job.
1.1 deraadt 167: .It Ar j
168: Print debugging information about running multiple shells.
1.40 espie 169: .It Ar l
170: Print commands in Makefile targets regardless of whether or not they are
171: prefixed by @.
172: Also known as loud behavior.
1.1 deraadt 173: .It Ar m
174: Print debugging information about making targets, including modification
175: dates.
1.82 espie 176: .It Ar n
177: Print debugging information about target names equivalence computations.
1.75 espie 178: .It Ar p
1.77 jmc 179: Help finding concurrency issues for parallel make by adding some
1.76 espie 180: randomization.
1.75 espie 181: If
182: .Va RANDOM_ORDER
183: is defined,
184: targets will be shuffled before being built.
185: If
186: .Va RANDOM_DELAY
1.76 espie 187: is defined,
1.75 espie 188: .Nm
189: will wait between 0 and ${RANDOM_DELAY} seconds at the start of each job.
190: A given random seed can be forced by setting
191: .Va RANDOM_SEED ,
192: but this does not guarantee reproductibility.
1.1 deraadt 193: .It Ar s
194: Print debugging information about suffix-transformation rules.
195: .It Ar t
196: Print debugging information about target list maintenance.
197: .It Ar v
198: Print debugging information about variable assignment.
199: .El
200: .It Fl I Ar directory
201: Specify a directory in which to search for makefiles and included makefiles.
1.5 niklas 202: The system makefile directory (or directories, see the
203: .Fl m
204: option) is automatically included as part of this list.
1.1 deraadt 205: .It Fl j Ar max_jobs
206: Specify the maximum number of jobs that
1.19 aaron 207: .Nm
1.28 aaron 208: may have running at any one time.
209: Turns compatibility mode off, unless the
1.57 jmc 210: .Fl B
1.3 deraadt 211: flag is also specified.
1.5 niklas 212: .It Fl m Ar directory
1.50 jmc 213: Specify a directory in which to search for
214: .Pa sys.mk
1.40 espie 215: and makefiles included
1.28 aaron 216: via the <...> style.
217: Multiple directories can be added to form a search path.
1.14 aaron 218: This path will override the default system include path:
219: .Pa /usr/share/mk .
220: Furthermore, the system include path will be appended to the search path used
1.5 niklas 221: for "..."-style inclusions (see the
222: .Fl I
223: option).
1.15 espie 224: .It Fl P
1.19 aaron 225: Collate the output of a given job and display it only when the job finishes,
226: instead of mixing the output of parallel jobs together.
227: This option has no effect unless
1.15 espie 228: .Fl j
229: is used too.
1.9 millert 230: .It Fl V Ar variable
231: Print
232: .Nm make Ns 's
233: idea of the value of
1.40 espie 234: .Ar variable .
1.9 millert 235: Do not build any targets.
236: Multiple instances of this option may be specified;
237: the variables will be printed one per line,
238: with a blank line for each null or undefined variable.
1.1 deraadt 239: .El
240: .Pp
241: There are seven different types of lines in a makefile: file dependency
242: specifications, shell commands, variable assignments, include statements,
243: conditional directives, for loops, and comments.
1.43 espie 244: Of these, include statements, conditional directives and for loops are
245: extensions.
1.1 deraadt 246: .Pp
247: In general, lines may be continued from one line to the next by ending
248: them with a backslash
249: .Pq Ql \e .
250: The trailing newline character and initial whitespace on the following
251: line are compressed into a single space.
252: .Sh FILE DEPENDENCY SPECIFICATIONS
253: Dependency lines consist of one or more targets, an operator, and zero
254: or more sources.
1.19 aaron 255: This creates a relationship where the targets
256: .Dq depend
257: on the sources
1.1 deraadt 258: and are usually created from them.
259: The exact relationship between the target and the source is determined
260: by the operator that separates them.
1.43 espie 261: Note that the use of several targets is merely a shorthand for duplicate
1.50 jmc 262: rules.
1.43 espie 263: Specifically,
1.57 jmc 264: .Bd -literal -offset indent
1.43 espie 265: target1 target2: depa depb
266: cmd1
267: cmd2
268: .Ed
1.57 jmc 269: .Pp
1.43 espie 270: is just a short form of
1.57 jmc 271: .Bd -literal -offset indent
1.43 espie 272: target1: depa depb
273: cmd1
274: cmd2
275: target2: depa depb
276: cmd1
277: cmd2
278: .Ed
279: .Pp
280: .Nm
281: does not support Solaris syntax for true multiple targets:
1.57 jmc 282: .Bd -literal -offset indent
1.43 espie 283: target1 + target2: depa depb
284: cmd1
285: cmd2
286: .Ed
287: .Pp
1.40 espie 288: The operators are as follows:
1.1 deraadt 289: .Bl -tag -width flag
290: .It Ic \&:
291: A target is considered out-of-date if its modification time is less than
292: those of any of its sources.
293: Sources for a target accumulate over dependency lines when this operator
294: is used.
295: The target is removed if
1.19 aaron 296: .Nm
1.1 deraadt 297: is interrupted.
298: .It Ic \&!
299: Targets are always re-created, but not until all sources have been
300: examined and re-created as necessary.
301: Sources for a target accumulate over dependency lines when this operator
302: is used.
303: The target is removed if
1.19 aaron 304: .Nm
1.1 deraadt 305: is interrupted.
306: .It Ic \&::
307: If no sources are specified, the target is always re-created.
308: Otherwise, a target is considered out-of-date if any of its sources has
309: been modified more recently than the target.
310: Sources for a target do not accumulate over dependency lines when this
311: operator is used.
312: The target will not be removed if
1.19 aaron 313: .Nm
1.1 deraadt 314: is interrupted.
315: .El
316: .Pp
1.43 espie 317: The
318: .Ic \&::
319: operator is a fairly standard extension.
320: The
1.56 jmc 321: .Ic !\&
1.43 espie 322: operator is a BSD extension.
323: .Pp
1.50 jmc 324: As an extension, targets and sources may contain the shell wildcard
1.43 espie 325: expressions
1.55 jmc 326: .Ql \&? ,
1.1 deraadt 327: .Ql * ,
328: .Ql []
329: and
330: .Ql {} .
1.15 espie 331: The expressions
1.55 jmc 332: .Ql \&? ,
1.1 deraadt 333: .Ql *
334: and
335: .Ql []
336: may only be used as part of the final
337: component of the target or source, and must be used to describe existing
338: files.
1.15 espie 339: The expression
1.1 deraadt 340: .Ql {}
341: need not necessarily be used to describe existing files.
342: Expansion is in directory order, not alphabetically as done in the shell.
1.43 espie 343: .Pp
344: For maximum portability, target names should only consist of periods,
345: underscores, digits and alphabetic characters.
1.1 deraadt 346: .Sh SHELL COMMANDS
347: Each target may have associated with it a series of shell commands, normally
348: used to create the target.
349: Each of the commands in this script
350: .Em must
351: be preceded by a tab.
352: While any target may appear on a dependency line, only one of these
353: dependencies may be followed by a creation script, unless the
1.54 jmc 354: .Sq Ic ::
1.1 deraadt 355: operator is used.
356: .Pp
1.34 espie 357: If a command line begins with a combination of the characters,
1.54 jmc 358: .Sq Ic @ ,
359: .Sq Ic \-
1.1 deraadt 360: and/or
1.54 jmc 361: .Sq Ic + ,
1.57 jmc 362: the command is treated specially:
1.33 espie 363: .Bl -tag -width `@'
1.54 jmc 364: .It Sq Ic @
1.1 deraadt 365: causes the command not to be echoed before it is executed.
1.54 jmc 366: .It Sq Ic \-
1.1 deraadt 367: causes any non-zero exit status of the command line to be ignored.
1.54 jmc 368: .It Sq Ic +
1.33 espie 369: causes the command to be executed even if
370: .Fl n
1.57 jmc 371: has been specified.
372: (This can be useful to debug recursive Makefiles.)
1.33 espie 373: .El
1.43 espie 374: .Pp
1.50 jmc 375: The command is always executed using
1.43 espie 376: .Pa /bin/sh
377: in
378: .Qq set -e
379: mode.
1.1 deraadt 380: .Sh VARIABLE ASSIGNMENTS
1.14 aaron 381: Variables in
1.19 aaron 382: .Nm
1.14 aaron 383: are much like variables in the shell, and, by tradition,
1.1 deraadt 384: consist of all upper-case letters.
1.60 espie 385: They are also called
386: .Sq macros
387: in various texts.
1.43 espie 388: For portability, only periods, underscores, digits and letters should be
389: used for variable names.
1.1 deraadt 390: The five operators that can be used to assign values to variables are as
391: follows:
392: .Bl -tag -width Ds
393: .It Ic \&=
394: Assign the value to the variable.
395: Any previous value is overridden.
1.43 espie 396: .It Ic \&:=
397: Assign with expansion, i.e., expand the value before assigning it
1.57 jmc 398: to the variable (extension).
1.1 deraadt 399: .It Ic \&+=
1.43 espie 400: Append the value to the current value of the variable (extension).
1.1 deraadt 401: .It Ic \&?=
1.43 espie 402: Assign the value to the variable if it is not already defined (BSD
403: extension).
1.1 deraadt 404: Normally, expansion is not done until the variable is referenced.
405: .It Ic \&!=
406: Expand the value and pass it to the shell for execution and assign
407: the result to the variable.
1.43 espie 408: Any newlines in the result are replaced with spaces (BSD extension).
1.1 deraadt 409: .El
410: .Pp
1.14 aaron 411: Any whitespace before the assigned
1.1 deraadt 412: .Ar value
413: is removed; if the value is being appended, a single space is inserted
414: between the previous contents of the variable and the appended value.
415: .Pp
416: Variables are expanded by surrounding the variable name with either
417: curly braces
418: .Pq Ql {}
419: or parentheses
420: .Pq Ql ()
421: and preceding it with
422: a dollar sign
423: .Pq Ql \&$ .
424: If the variable name contains only a single letter, the surrounding
425: braces or parentheses are not required.
426: This shorter form is not recommended.
427: .Pp
428: Variable substitution occurs at two distinct times, depending on where
429: the variable is being used.
430: Variables in dependency lines are expanded as the line is read.
431: Variables in shell commands are expanded when the shell command is
432: executed.
433: .Pp
434: The four different classes of variables (in order of increasing precedence)
435: are:
436: .Bl -tag -width Ds
437: .It Environment variables
438: Variables defined as part of
439: .Nm make Ns 's
440: environment.
441: .It Global variables
442: Variables defined in the makefile or in included makefiles.
443: .It Command line variables
444: Variables defined as part of the command line.
445: .It Local variables
446: Variables that are defined specific to a certain target.
1.43 espie 447: Standard local variables are as follows:
1.1 deraadt 448: .Bl -tag -width ".ARCHIVE"
1.43 espie 449: .It Va @
450: The name of the target.
451: .It Va \&%
452: The name of the archive member (only valid for library rules).
453: .It Va \&!
454: The name of the archive file (only valid for library rules).
455: .It Va \&?
456: The list of prerequisites for this target that were deemed out-of-date.
457: .It Va \&<
458: The name of the source from which this target is to be built, if a valid
459: implied rule (suffix rule) is in scope.
460: .It Va *
461: The file prefix of the file, containing only the file portion,
462: no suffix or preceding directory components.
463: .El
464: .Pp
465: The six variables
1.54 jmc 466: .Sq Va "@F" ,
467: .Sq Va "@D" ,
468: .Sq Va "<F" ,
469: .Sq Va "<D" ,
470: .Sq Va "*F" ,
1.43 espie 471: and
1.54 jmc 472: .Sq Va "*D"
1.43 espie 473: yield the
474: .Qq filename
475: and
476: .Qq directory
477: parts of the corresponding macros.
478: .Pp
479: For maximum compatibility,
1.54 jmc 480: .Sq Va \&<
1.43 espie 481: should only be used for actual implied rules.
482: It is also set when there is an implied rule that matches the current
1.54 jmc 483: dependency in scope.
484: That is, in
1.57 jmc 485: .Bd -literal -offset indent
1.65 jmc 486: \&.SUFFIXES: .c .o
1.43 espie 487: file.o: file.c
488: cmd1 $<
489:
490: \&.c.o:
491: cmd2
492: .Ed
1.57 jmc 493: .Pp
1.43 espie 494: building
495: .Pa file.o
496: will execute
497: .Qq cmd1 file.c .
498: .Pp
499: As an extension,
500: .Nm
1.47 jsyn 501: supports the following local variables:
1.43 espie 502: .Bl -tag -width ".ARCHIVE"
503: .It Va \&>
504: The list of all sources for this target.
1.1 deraadt 505: .It Va .ALLSRC
1.43 espie 506: Synonym for
1.54 jmc 507: .Sq Va \&> .
1.1 deraadt 508: .It Va .ARCHIVE
1.43 espie 509: Synonym for
1.54 jmc 510: .Sq Va \&! .
1.1 deraadt 511: .It Va .IMPSRC
1.43 espie 512: Synonym for
1.54 jmc 513: .Sq Va \&< .
1.1 deraadt 514: .It Va .MEMBER
1.43 espie 515: Synonym for
1.54 jmc 516: .Sq Va \&% .
1.1 deraadt 517: .It Va .OODATE
1.43 espie 518: Synonym for
1.54 jmc 519: .Sq Va \&? .
1.1 deraadt 520: .It Va .PREFIX
1.43 espie 521: Synonym for
1.54 jmc 522: .Sq Va * .
1.1 deraadt 523: .It Va .TARGET
1.43 espie 524: Synonym for
1.54 jmc 525: .Sq Va @ .
1.1 deraadt 526: .El
527: .Pp
1.43 espie 528: These variables may be used on the dependency half of dependency
529: lines, when they make sense.
1.15 espie 530: .El
1.1 deraadt 531: .Pp
532: In addition,
1.19 aaron 533: .Nm
534: sets or knows about the following internal variables, or environment
1.15 espie 535: variables:
1.1 deraadt 536: .Bl -tag -width MAKEFLAGS
537: .It Va \&$
538: A single dollar sign
539: .Ql \&$ ,
1.29 aaron 540: i.e.,
1.1 deraadt 541: .Ql \&$$
542: expands to a single dollar
543: sign.
544: .It Va .MAKE
545: The name that
1.19 aaron 546: .Nm
1.1 deraadt 547: was executed with
1.14 aaron 548: .Pq Va argv Ns Op 0 .
1.1 deraadt 549: .It Va .CURDIR
550: A path to the directory where
1.19 aaron 551: .Nm
1.1 deraadt 552: was executed.
553: .It Va .OBJDIR
554: A path to the directory where the targets are built.
1.8 deraadt 555: At startup,
1.19 aaron 556: .Nm
1.8 deraadt 557: searches for an alternate directory to place target files -- it
558: will attempt to change into this special directory.
1.19 aaron 559: First, if
560: .Ev MAKEOBJDIRPREFIX
561: is defined,
562: .Nm
1.18 espie 563: prepends its contents to the current directory name and tries for
1.28 aaron 564: the resulting directory.
565: If that fails,
1.19 aaron 566: .Nm
1.18 espie 567: remains in the current directory.
1.19 aaron 568: If
1.15 espie 569: .Ev MAKEOBJDIRPREFIX
1.18 espie 570: is not defined,
1.19 aaron 571: .Nm
1.18 espie 572: checks
1.19 aaron 573: .Ev MAKEOBJDIR
1.28 aaron 574: and tries to change into that directory.
575: Should that fail,
1.19 aaron 576: .Nm
1.28 aaron 577: remains in the current directory.
578: If
1.18 espie 579: .Ev MAKEOBJDIR
580: is not defined, it tries to change into the directory named
581: .Pa obj.${MACHINE}
1.19 aaron 582: (see
583: .Va MACHINE
1.28 aaron 584: variable).
585: If it still has found no special directory,
1.19 aaron 586: .Nm
1.18 espie 587: next tries the directory named
588: .Pa obj .
589: If this fails,
1.19 aaron 590: .Nm
591: tries to prepend
592: .Pa /usr/obj
593: to the current directory name.
1.18 espie 594: Finally, if none of these directories are available
1.19 aaron 595: .Nm
1.8 deraadt 596: will settle for and use the current directory.
1.15 espie 597: .It Va .MAKEFLAGS
1.1 deraadt 598: The environment variable
1.14 aaron 599: .Ev MAKEFLAGS
1.1 deraadt 600: may contain anything that
601: may be specified on
602: .Nm make Ns 's
1.28 aaron 603: command line.
604: Its contents are stored in
1.15 espie 605: .Nm make Ns 's
1.19 aaron 606: .Va .MAKEFLAGS
1.15 espie 607: variable.
1.40 espie 608: Anything specified on
1.1 deraadt 609: .Nm make Ns 's
610: command line is appended to the
1.15 espie 611: .Va .MAKEFLAGS
612: variable which is then
1.19 aaron 613: entered into the environment as
1.14 aaron 614: .Ev MAKEFLAGS
1.15 espie 615: for all programs which
1.19 aaron 616: .Nm
1.1 deraadt 617: executes.
1.15 espie 618: .It Va MFLAGS
1.19 aaron 619: A shorter synonym for
1.15 espie 620: .Va .MAKEFLAGS .
1.9 millert 621: .It Ev PWD
622: Alternate path to the current directory.
1.19 aaron 623: .Nm
1.9 millert 624: normally sets
1.54 jmc 625: .Sq Va .CURDIR
1.9 millert 626: to the canonical path given by
1.49 jmc 627: .Xr getcwd 3 .
1.9 millert 628: However, if the environment variable
1.14 aaron 629: .Ev PWD
1.9 millert 630: is set and gives a path to the current directory, then
1.19 aaron 631: .Nm
1.9 millert 632: sets
1.54 jmc 633: .Sq Va .CURDIR
1.9 millert 634: to the value of
1.14 aaron 635: .Ev PWD
1.9 millert 636: instead.
1.14 aaron 637: .Ev PWD
1.15 espie 638: is always set to the value of
1.54 jmc 639: .Sq Va .OBJDIR
1.9 millert 640: for all programs which
1.19 aaron 641: .Nm
1.9 millert 642: executes.
1.15 espie 643: .It Va .TARGETS
1.19 aaron 644: List of targets
645: .Nm
1.18 espie 646: is currently building.
1.15 espie 647: .It Va .INCLUDES
1.19 aaron 648: See
1.18 espie 649: .Ic .INCLUDES
1.57 jmc 650: special target.
1.15 espie 651: .It Va .LIBS
1.19 aaron 652: See
1.18 espie 653: .Ic .LIBS
1.57 jmc 654: special target.
1.15 espie 655: .It Va MACHINE
1.19 aaron 656: Name of the machine architecture
657: .Nm
1.18 espie 658: is running on, obtained from the
659: .Ev MACHINE
1.19 aaron 660: environment variable, or through
1.44 deraadt 661: .Xr uname 3
1.18 espie 662: if not defined.
1.15 espie 663: .It Va MACHINE_ARCH
1.18 espie 664: Name of the machine architecture
1.19 aaron 665: .Nm
1.18 espie 666: was compiled for, obtained from the
1.19 aaron 667: .Ev MACHINE_ARCH
1.18 espie 668: environment variable, or defined at compilation time.
1.85 miod 669: .It Va MACHINE_CPU
670: Name of the machine processor
671: .Nm
672: was compiled for, obtained from the
673: .Ev MACHINE_CPU
674: environment variable, or defined at compilation time.
675: On processors where only one endianness is possible, the value of this
676: variable is always the same as
677: .Ev MACHINE_ARCH .
1.80 bluhm 678: .It Va MAKEFILE
679: Possibly the file name of the last makefile that has been read.
680: It should not be used; see the
681: .Sx BUGS
682: section below.
1.1 deraadt 683: .El
684: .Pp
685: Variable expansion may be modified to select or modify each word of the
1.48 pvalchev 686: variable (where
1.19 aaron 687: .Dq word
1.48 pvalchev 688: is a whitespace delimited sequence of characters).
1.1 deraadt 689: The general format of a variable expansion is as follows:
690: .Pp
691: .Dl {variable[:modifier[:...]]}
692: .Pp
693: Each modifier begins with a colon and one of the following
694: special characters.
695: The colon may be escaped with a backslash
696: .Pq Ql \e .
1.54 jmc 697: .Bl -tag -width Ds
1.58 espie 698: .It Cm :E
1.1 deraadt 699: Replaces each word in the variable with its suffix.
1.58 espie 700: .It Cm :H
1.1 deraadt 701: Replaces each word in the variable with everything but the last component.
1.58 espie 702: .It Cm :L
1.20 espie 703: Replaces each word in the variable with its lower case equivalent.
1.58 espie 704: .It Cm :U
1.20 espie 705: Replaces each word in the variable with its upper case equivalent.
1.58 espie 706: .It Cm :M Ns Ar pattern
1.1 deraadt 707: Select only those words that match the rest of the modifier.
708: The standard shell wildcard characters
709: .Pf ( Ql * ,
1.55 jmc 710: .Ql \&? ,
1.1 deraadt 711: and
1.54 jmc 712: .Ql [] )
1.1 deraadt 713: may
714: be used.
715: The wildcard characters may be escaped with a backslash
716: .Pq Ql \e .
1.58 espie 717: .It Cm :N Ns Ar pattern
1.1 deraadt 718: This is identical to
1.58 espie 719: .Cm :M ,
1.1 deraadt 720: but selects all words which do not match
721: the rest of the modifier.
1.58 espie 722: .It Cm :Q
1.10 millert 723: Quotes every shell meta-character in the variable, so that it can be passed
724: safely through recursive invocations of
1.14 aaron 725: .Nm make .
1.58 espie 726: .It Cm :R
1.1 deraadt 727: Replaces each word in the variable with everything but its suffix.
728: .Sm off
1.58 espie 729: .It Cm :S No \&/ Ar old_string Xo
1.10 millert 730: .No \&/ Ar new_string
731: .No \&/ Op Cm 1g
1.1 deraadt 732: .Xc
733: .Sm on
734: Modify the first occurrence of
1.10 millert 735: .Ar old_string
736: in the variable's value, replacing it with
737: .Ar new_string .
1.1 deraadt 738: If a
739: .Ql g
740: is appended to the last slash of the pattern, all occurrences
741: in each word are replaced.
1.10 millert 742: If a
743: .Ql 1
744: is appended to the last slash of the pattern, only the first word
745: is affected.
1.1 deraadt 746: If
1.10 millert 747: .Ar old_string
748: begins with a caret
1.1 deraadt 749: .Pq Ql ^ ,
1.10 millert 750: .Ar old_string
1.1 deraadt 751: is anchored at the beginning of each word.
752: If
1.10 millert 753: .Ar old_string
1.1 deraadt 754: ends with a dollar sign
755: .Pq Ql \&$ ,
756: it is anchored at the end of each word.
757: Inside
758: .Ar new_string ,
759: an ampersand
760: .Pq Ql &
761: is replaced by
1.10 millert 762: .Ar old_string
763: (without any
764: .Ql ^
765: or
766: .Ql \&$ ) .
1.1 deraadt 767: Any character may be used as a delimiter for the parts of the modifier
768: string.
769: The anchoring, ampersand and delimiter characters may be escaped with a
770: backslash
771: .Pq Ql \e .
772: .Pp
773: Variable expansion occurs in the normal fashion inside both
774: .Ar old_string
775: and
776: .Ar new_string
777: with the single exception that a backslash is used to prevent the expansion
778: of a dollar sign
1.10 millert 779: .Pq Ql \&$ ,
1.1 deraadt 780: not a preceding dollar sign as is usual.
1.10 millert 781: .Sm off
1.58 espie 782: .It Cm :C No \&/ Ar pattern Xo
1.10 millert 783: .No \&/ Ar replacement
784: .No \&/ Op Cm 1g
785: .Xc
786: .Sm on
787: The
1.58 espie 788: .Cm :C
1.10 millert 789: modifier is just like the
1.58 espie 790: .Cm :S
1.13 deraadt 791: modifier except that the old and new strings, instead of being
1.10 millert 792: simple strings, are a regular expression (see
793: .Xr regex 3 )
794: and an
795: .Xr ed 1 Ns \-style
1.28 aaron 796: replacement string.
797: Normally, the first occurrence of the pattern in
798: each word of the value is changed.
799: The
1.10 millert 800: .Ql 1
801: modifier causes the substitution to apply to at most one word; the
802: .Ql g
803: modifier causes the substitution to apply to as many instances of the
1.28 aaron 804: search pattern as occur in the word or words it is found in.
805: Note that
1.10 millert 806: .Ql 1
807: and
808: .Ql g
809: are orthogonal; the former specifies whether multiple words are
810: potentially affected, the latter whether multiple substitutions can
811: potentially occur within each affected word.
1.58 espie 812: .It Cm :T
1.1 deraadt 813: Replaces each word in the variable with its last component.
1.59 jmc 814: .It Ar :old_string Ns = Ns Ar new_string
1.1 deraadt 815: This is the
816: .At V
817: style variable substitution.
818: It must be the last modifier specified.
1.9 millert 819: If
1.1 deraadt 820: .Ar old_string
821: or
822: .Ar new_string
823: do not contain the pattern matching character
824: .Ar %
1.9 millert 825: then it is assumed that they are
1.1 deraadt 826: anchored at the end of each word, so only suffixes or entire
1.28 aaron 827: words may be replaced.
828: Otherwise
1.1 deraadt 829: .Ar %
1.9 millert 830: is the substring of
831: .Ar old_string
1.1 deraadt 832: to be replaced in
1.53 jmc 833: .Ar new_string .
1.1 deraadt 834: .El
1.53 jmc 835: .Pp
1.50 jmc 836: All modifiers are BSD extensions, except for the standard
1.46 espie 837: .At V
838: style variable substitution.
1.1 deraadt 839: .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1.28 aaron 840: Makefile inclusion, conditional structures and for loops reminiscent
1.1 deraadt 841: of the C programming language are provided in
842: .Nm make .
843: All such structures are identified by a line beginning with a single
844: dot
845: .Pq Ql \&.
846: character.
1.46 espie 847: Whitespace characters may follow this dot, e.g.,
1.57 jmc 848: .Bd -literal -offset indent
849: \&.include <file>
1.46 espie 850: .Ed
851: and
1.57 jmc 852: .Bd -literal -offset indent -compact
853: \&. include <file>
1.46 espie 854: .Ed
1.57 jmc 855: .Pp
1.46 espie 856: are identical constructs.
1.1 deraadt 857: Files are included with either
858: .Ql .include <file>
859: or
860: .Ql .include \*qfile\*q .
861: Variables between the angle brackets or double quotes are expanded
862: to form the file name.
863: If angle brackets are used, the included makefile is expected to be in
864: the system makefile directory.
865: If double quotes are used, the including makefile's directory and any
866: directories specified using the
867: .Fl I
868: option are searched before the system
869: makefile directory.
870: .Pp
871: Conditional expressions are also preceded by a single dot as the first
872: character of a line.
873: The possible conditionals are as follows:
874: .Bl -tag -width Ds
875: .It Ic .undef Ar variable
876: Un-define the specified global variable.
877: Only global variables may be un-defined.
1.69 espie 878: .It Ic .poison Ar variable
879: Poison the specified global variable.
1.70 jmc 880: Any further reference to
1.69 espie 881: .Ar variable
882: will be flagged as an error.
1.70 jmc 883: .It Ic .poison !defined Pq Ar variable
1.69 espie 884: It is an error to try to use the value of
885: .Ar variable
1.70 jmc 886: in a context where it is not defined.
887: .It Ic .poison empty Pq Ar variable
1.69 espie 888: It is an error to try to use the value of
889: .Ar variable
1.70 jmc 890: in a context where it is not defined or empty.
1.1 deraadt 891: .It Xo
892: .Ic \&.if
893: .Oo \&! Oc Ns Ar expression
894: .Op Ar operator expression ...
895: .Xc
896: Test the value of an expression.
897: .It Xo
898: .Ic .ifdef
899: .Oo \&! Oc Ns Ar variable
900: .Op Ar operator variable ...
901: .Xc
902: Test the value of a variable.
903: .It Xo
904: .Ic .ifndef
905: .Oo \&! Oc Ns Ar variable
906: .Op Ar operator variable ...
907: .Xc
908: Test the value of a variable.
909: .It Xo
910: .Ic .ifmake
911: .Oo \&! Oc Ns Ar target
912: .Op Ar operator target ...
913: .Xc
914: Test the target being built.
915: .It Xo
916: .Ic .ifnmake
917: .Oo \&! Oc Ar target
918: .Op Ar operator target ...
919: .Xc
920: Test the target being built.
921: .It Ic .else
922: Reverse the sense of the last conditional.
923: .It Xo
924: .Ic .elif
925: .Oo \&! Oc Ar expression
926: .Op Ar operator expression ...
927: .Xc
928: A combination of
1.54 jmc 929: .Sq Ic .else
1.1 deraadt 930: followed by
1.54 jmc 931: .Sq Ic .if .
1.1 deraadt 932: .It Xo
933: .Ic .elifdef
934: .Oo \&! Oc Ns Ar variable
935: .Op Ar operator variable ...
936: .Xc
937: A combination of
1.54 jmc 938: .Sq Ic .else
1.1 deraadt 939: followed by
1.54 jmc 940: .Sq Ic .ifdef .
1.1 deraadt 941: .It Xo
942: .Ic .elifndef
943: .Oo \&! Oc Ns Ar variable
944: .Op Ar operator variable ...
945: .Xc
946: A combination of
1.54 jmc 947: .Sq Ic .else
1.1 deraadt 948: followed by
1.54 jmc 949: .Sq Ic .ifndef .
1.1 deraadt 950: .It Xo
951: .Ic .elifmake
952: .Oo \&! Oc Ns Ar target
953: .Op Ar operator target ...
954: .Xc
955: A combination of
1.54 jmc 956: .Sq Ic .else
1.1 deraadt 957: followed by
1.54 jmc 958: .Sq Ic .ifmake .
1.1 deraadt 959: .It Xo
960: .Ic .elifnmake
961: .Oo \&! Oc Ns Ar target
962: .Op Ar operator target ...
963: .Xc
964: A combination of
1.54 jmc 965: .Sq Ic .else
1.1 deraadt 966: followed by
1.54 jmc 967: .Sq Ic .ifnmake .
1.1 deraadt 968: .It Ic .endif
969: End the body of the conditional.
970: .El
971: .Pp
972: The
973: .Ar operator
974: may be any one of the following:
975: .Bl -tag -width "Cm XX"
976: .It Cm \&|\&|
977: logical OR
978: .It Cm \&&&
979: Logical
980: .Tn AND ;
981: of higher precedence than
1.46 espie 982: .Dq \&|\&| .
1.1 deraadt 983: .El
984: .Pp
985: As in C,
1.19 aaron 986: .Nm
1.1 deraadt 987: will only evaluate a conditional as far as is necessary to determine
988: its value.
1.9 millert 989: Parentheses may be used to change the order of evaluation.
1.1 deraadt 990: The boolean operator
1.54 jmc 991: .Sq Ic \&!
1.1 deraadt 992: may be used to logically negate an entire
993: conditional.
994: It is of higher precedence than
1.54 jmc 995: .Sq Ic \&&& .
1.1 deraadt 996: .Pp
997: The value of
998: .Ar expression
999: may be any of the following:
1.54 jmc 1000: .Bl -tag -width defined
1.1 deraadt 1001: .It Ic defined
1002: Takes a variable name as an argument and evaluates to true if the variable
1003: has been defined.
1004: .It Ic make
1005: Takes a target name as an argument and evaluates to true if the target
1006: was specified as part of
1007: .Nm make Ns 's
1008: command line or was declared the default target (either implicitly or
1009: explicitly, see
1010: .Va .MAIN )
1011: before the line containing the conditional.
1012: .It Ic empty
1013: Takes a variable, with possible modifiers, and evaluates to true if
1014: the expansion of the variable would result in an empty string.
1015: .It Ic exists
1016: Takes a file name as an argument and evaluates to true if the file exists.
1017: The file is searched for on the system search path (see
1018: .Va .PATH ) .
1019: .It Ic target
1020: Takes a target name as an argument and evaluates to true if the target
1021: has been defined.
1022: .El
1023: .Pp
1.14 aaron 1024: .Ar expression
1.28 aaron 1025: may also be an arithmetic or string comparison.
1026: Variable expansion is
1.1 deraadt 1027: performed on both sides of the comparison, after which the integral
1.28 aaron 1028: values are compared.
1029: A value is interpreted as hexadecimal if it is
1.1 deraadt 1030: preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1.28 aaron 1031: The standard C relational operators are all supported.
1032: If after
1.1 deraadt 1033: variable expansion, either the left or right hand side of a
1.54 jmc 1034: .Sq Ic ==
1.1 deraadt 1035: or
1.54 jmc 1036: .Sq Ic "!="
1.1 deraadt 1037: operator is not an integral value, then
1038: string comparison is performed between the expanded
1039: variables.
1040: If no relational operator is given, it is assumed that the expanded
1041: variable is being compared against 0.
1042: .Pp
1043: When
1.19 aaron 1044: .Nm
1.14 aaron 1045: is evaluating one of these conditional expressions, and it encounters
1.19 aaron 1046: a word it doesn't recognize, either the
1047: .Dq make
1048: or
1049: .Dq defined
1.1 deraadt 1050: expression is applied to it, depending on the form of the conditional.
1051: If the form is
1.54 jmc 1052: .Sq Ic .ifdef
1.1 deraadt 1053: or
1.54 jmc 1054: .Sq Ic .ifndef ,
1.19 aaron 1055: the
1056: .Dq defined
1057: expression is applied.
1.1 deraadt 1058: Similarly, if the form is
1.54 jmc 1059: .Sq Ic .ifmake
1.1 deraadt 1060: or
1.54 jmc 1061: .Sq Ic .ifnmake ,
1.19 aaron 1062: the
1063: .Dq make
1.1 deraadt 1064: expression is applied.
1065: .Pp
1066: If the conditional evaluates to true the parsing of the makefile continues
1067: as before.
1068: If it evaluates to false, the following lines are skipped.
1069: In both cases this continues until a
1.54 jmc 1070: .Sq Ic .else
1.1 deraadt 1071: or
1.54 jmc 1072: .Sq Ic .endif
1.1 deraadt 1073: is found.
1.9 millert 1074: .Pp
1.1 deraadt 1075: For loops are typically used to apply a set of rules to a list of files.
1076: The syntax of a for loop is:
1.54 jmc 1077: .Bd -unfilled -offset indent
1078: .Xo
1079: .Ic .for Ar variable Op Ar variable ...
1.9 millert 1080: .Ic in
1.1 deraadt 1081: .Ar expression
1082: .Xc
1.54 jmc 1083: <make-rules>
1.1 deraadt 1084: .Ic \&.endfor
1.54 jmc 1085: .Ed
1086: .Pp
1.1 deraadt 1087: After the for
1.14 aaron 1088: .Ar expression
1.28 aaron 1089: is evaluated, it is split into words.
1.50 jmc 1090: On each iteration of the loop, one word is assigned to each
1.41 espie 1091: .Ar variable ,
1092: in order,
1.50 jmc 1093: and these
1094: .Ar variables
1.41 espie 1095: are substituted in the
1.9 millert 1096: .Ic make-rules
1.1 deraadt 1097: inside the body of the for loop.
1.41 espie 1098: The number of words must match the number of iteration variables;
1099: that is, if there are three iteration variables, the number of words
1.48 pvalchev 1100: must be a multiple of three.
1.45 espie 1101: .Pp
1102: Loops and conditional expressions may nest arbitrarily, but
1103: they may not cross include file boundaries.
1.1 deraadt 1104: .Sh COMMENTS
1105: Comments begin with a hash
1106: .Pq Ql \&#
1107: character, anywhere but in a shell
1108: command line, and continue to the end of the line.
1109: .Sh SPECIAL SOURCES
1.54 jmc 1110: .Bl -tag -width ".PRECIOUS"
1.1 deraadt 1111: .It Ic .IGNORE
1112: Ignore any errors from the commands associated with this target, exactly
1113: as if they all were preceded by a dash
1114: .Pq Ql \- .
1.10 millert 1115: .It Ic .MADE
1.19 aaron 1116: Mark all sources of this target as being up-to-date.
1.1 deraadt 1117: .It Ic .MAKE
1118: Execute the commands associated with this target even if the
1119: .Fl n
1120: or
1121: .Fl t
1122: options were specified.
1123: Normally used to mark recursive
1124: .Nm make Ns 's .
1125: .It Ic .NOTMAIN
1126: Normally
1.19 aaron 1127: .Nm
1.1 deraadt 1128: selects the first target it encounters as the default target to be built
1129: if no target was specified.
1130: This source prevents this target from being selected.
1131: .It Ic .OPTIONAL
1132: If a target is marked with this attribute and
1.19 aaron 1133: .Nm
1.1 deraadt 1134: can't figure out how to create it, it will ignore this fact and assume
1135: the file isn't needed or already exists.
1136: .It Ic .PRECIOUS
1137: When
1.19 aaron 1138: .Nm
1.1 deraadt 1139: is interrupted, it removes any partially made targets.
1140: This source prevents the target from being removed.
1141: .It Ic .SILENT
1142: Do not echo any of the commands associated with this target, exactly
1143: as if they all were preceded by an at sign
1144: .Pq Ql @ .
1145: .It Ic .USE
1146: Turn the target into
1.14 aaron 1147: .Nm make Ns 's
1.1 deraadt 1148: version of a macro.
1149: When the target is used as a source for another target, the other target
1150: acquires the commands, sources, and attributes (except for
1151: .Ic .USE )
1152: of the
1153: source.
1154: If the target already has commands, the
1155: .Ic .USE
1156: target's commands are appended
1157: to them.
1.4 deraadt 1158: .It Ic .WAIT
1.48 pvalchev 1159: If
1.4 deraadt 1160: .Ic .WAIT
1.48 pvalchev 1161: appears in a dependency line, the sources that precede it are
1.28 aaron 1162: made before the sources that succeed it in the line.
1.48 pvalchev 1163: Loops are not
1.4 deraadt 1164: detected and targets that form loops will be silently ignored.
1.1 deraadt 1165: .El
1.81 jmc 1166: .Sh SPECIAL TARGETS
1.29 aaron 1167: Special targets may not be included with other targets, i.e., they must be
1.1 deraadt 1168: the only target specified.
1.54 jmc 1169: .Bl -tag -width ".NOTPARALLEL"
1.1 deraadt 1170: .It Ic .BEGIN
1171: Any command lines attached to this target are executed before anything
1172: else is done.
1173: .It Ic .DEFAULT
1174: This is sort of a
1175: .Ic .USE
1176: rule for any target (that was used only as a
1177: source) that
1.19 aaron 1178: .Nm
1.1 deraadt 1179: can't figure out any other way to create.
1180: Only the shell script is used.
1181: The
1182: .Ic .IMPSRC
1183: variable of a target that inherits
1184: .Ic .DEFAULT Ns 's
1185: commands is set
1186: to the target's own name.
1187: .It Ic .END
1188: Any command lines attached to this target are executed after everything
1189: else is done.
1190: .It Ic .IGNORE
1191: Mark each of the sources with the
1192: .Ic .IGNORE
1193: attribute.
1194: If no sources are specified, this is the equivalent of specifying the
1195: .Fl i
1196: option.
1.18 espie 1197: .It Ic .INCLUDES
1198: A list of suffixes that indicate files that can be included in a source
1.28 aaron 1199: file.
1200: The suffix must have already been declared with
1.18 espie 1201: .Ic .SUFFIXES ,
1.48 pvalchev 1202: any suffix so declared will have the directories in its search path (see
1.18 espie 1203: .Ic .PATH )
1.19 aaron 1204: placed in the
1.18 espie 1205: .Va .INCLUDES
1.19 aaron 1206: special variable, each preceded by a
1207: .Fl I
1.18 espie 1208: flag.
1.1 deraadt 1209: .It Ic .INTERRUPT
1210: If
1.19 aaron 1211: .Nm
1.1 deraadt 1212: is interrupted, the commands for this target will be executed.
1.18 espie 1213: .It Ic .LIBS
1.19 aaron 1214: This does for libraries what
1215: .Ic .INCLUDES
1.18 espie 1216: does for include files, except that the flag used is
1217: .Fl L .
1.1 deraadt 1218: .It Ic .MAIN
1219: If no target is specified when
1.19 aaron 1220: .Nm
1.28 aaron 1221: is invoked, this target will be built.
1222: This is always set, either
1.19 aaron 1223: explicitly, or implicitly when
1224: .Nm
1.16 espie 1225: selects the default target, to give the user a way to refer to the default
1226: target on the command line.
1.1 deraadt 1227: .It Ic .MAKEFLAGS
1228: This target provides a way to specify flags for
1.19 aaron 1229: .Nm
1.1 deraadt 1230: when the makefile is used.
1231: The flags are as if typed to the shell, though the
1232: .Fl f
1233: option will have
1234: no effect.
1.4 deraadt 1235: .\" XXX: NOT YET!!!!
1236: .\" .It Ic .NOTPARALLEL
1237: .\" The named targets are executed in non parallel mode. If no targets are
1238: .\" specified, then all targets are executed in non parallel mode.
1239: .It Ic .NOTPARALLEL
1240: Disable parallel mode.
1241: .It Ic .NO_PARALLEL
1242: Same as above, for compatibility with other pmake variants.
1243: .It Ic .ORDER
1244: The named targets are made in sequence.
1245: .\" XXX: NOT YET!!!!
1246: .\" .It Ic .PARALLEL
1247: .\" The named targets are executed in parallel mode. If no targets are
1248: .\" specified, then all targets are executed in parallel mode.
1.1 deraadt 1249: .It Ic .PATH
1250: The sources are directories which are to be searched for files not
1251: found in the current directory.
1252: If no sources are specified, any previously specified directories are
1253: deleted.
1.18 espie 1254: .It Ic .PATH\fIsuffix\fR
1255: The sources are directories which are to be searched for suffixed files
1256: not found in the current directory.
1.19 aaron 1257: .Nm
1258: first searches the suffixed search path, before reverting to the default
1.18 espie 1259: path if the file is not found there.
1.6 niklas 1260: .It Ic .PHONY
1261: Apply the
1262: .Ic .PHONY
1.28 aaron 1263: attribute to any specified sources.
1264: Targets with this attribute are always
1.6 niklas 1265: considered to be out of date.
1.1 deraadt 1266: .It Ic .PRECIOUS
1267: Apply the
1268: .Ic .PRECIOUS
1269: attribute to any specified sources.
1270: If no sources are specified, the
1271: .Ic .PRECIOUS
1272: attribute is applied to every
1273: target in the file.
1274: .It Ic .SILENT
1275: Apply the
1276: .Ic .SILENT
1277: attribute to any specified sources.
1278: If no sources are specified, the
1279: .Ic .SILENT
1280: attribute is applied to every
1281: command in the file.
1282: .It Ic .SUFFIXES
1283: Each source specifies a suffix to
1284: .Nm make .
1.61 jmc 1285: If no sources are specified, any previously specified suffixes are deleted.
1.35 aaron 1286: .El
1.1 deraadt 1287: .Sh ENVIRONMENT
1.19 aaron 1288: .Nm
1.15 espie 1289: uses the following environment variables, if they exist:
1.9 millert 1290: .Ev MACHINE ,
1.15 espie 1291: .Ev MACHINE_ARCH ,
1.86 jmc 1292: .Ev MACHINE_CPU ,
1.9 millert 1293: .Ev MAKEFLAGS ,
1294: .Ev MAKEOBJDIR ,
1.15 espie 1295: .Ev MAKEOBJDIRPREFIX ,
1.1 deraadt 1296: and
1.9 millert 1297: .Ev PWD .
1.30 espie 1298: .Nm
1.31 aaron 1299: also ignores and unsets
1.30 espie 1300: .Ev CDPATH .
1.1 deraadt 1301: .Sh FILES
1302: .Bl -tag -width /usr/share/mk -compact
1.14 aaron 1303: .It Pa .depend
1.1 deraadt 1304: list of dependencies
1.15 espie 1305: .It Pa BSDmakefile
1.66 jmc 1306: default makefile
1307: .It Pa makefile
1308: default makefile if
1309: .Pa BSDmakefile
1310: does not exist
1.14 aaron 1311: .It Pa Makefile
1.66 jmc 1312: default makefile if
1313: .Pa makefile
1314: does not exist
1.14 aaron 1315: .It Pa sys.mk
1.1 deraadt 1316: system makefile
1.14 aaron 1317: .It Pa /usr/share/mk
1.1 deraadt 1318: system makefile directory
1.62 jmc 1319: .It Pa /usr/obj
1.19 aaron 1320: default
1.52 jmc 1321: .Ev MAKEOBJDIRPREFIX
1.57 jmc 1322: directory
1.1 deraadt 1323: .El
1.37 aaron 1324: .Sh SEE ALSO
1.57 jmc 1325: .Xr ed 1 ,
1326: .Xr mkdep 1 ,
1327: .Xr sh 1 ,
1328: .Xr getcwd 3 ,
1329: .Xr regex 3 ,
1330: .Xr uname 3
1.37 aaron 1331: .Pp
1.63 jmc 1332: "Make \(em A Tutorial",
1333: .Pa /usr/share/doc/psd/12.make/ .
1.52 jmc 1334: .Sh STANDARDS
1.67 jmc 1335: The
1.43 espie 1336: .Nm
1.67 jmc 1337: utility is compliant with the
1.83 jmc 1338: .St -p1003.1-2008
1.84 jmc 1339: specification,
1340: though its presence is optional.
1.67 jmc 1341: .Pp
1342: The flags
1343: .Op Fl BDdIjmPV
1344: are extensions to that specification.
1.43 espie 1345: .Pp
1.37 aaron 1346: Older versions of
1347: .Nm
1348: used
1349: .Ev MAKE
1350: instead of
1351: .Ev MAKEFLAGS .
1352: This was removed for POSIX compatibility.
1353: The internal variable
1354: .Va MAKE
1355: is set to the same value as
1.48 pvalchev 1356: .Va .MAKE .
1357: Support for this may be removed in the future.
1.37 aaron 1358: .Pp
1359: Most of the more esoteric features of
1360: .Nm
1361: should probably be avoided for greater compatibility.
1362: .Sh HISTORY
1363: A
1364: .Nm
1365: command appeared in
1366: .At v7 .
1.17 espie 1367: .Sh BUGS
1.18 espie 1368: The determination of
1369: .Va .OBJDIR
1.19 aaron 1370: is contorted to the point of absurdity.
1.18 espie 1371: .Pp
1.50 jmc 1372: If the same target is specified several times in normal dependency rules,
1.31 aaron 1373: .Nm
1.27 espie 1374: silently ignores all commands after the first non empty set of commands,
1.31 aaron 1375: e.g., in
1.57 jmc 1376: .Bd -literal -offset indent
1.27 espie 1377: a:
1378: @echo "Executed"
1379: a:
1380: @echo "Bad luck"
1381: .Ed
1382: .Pp
1383: @echo "Bad luck" will be silently ignored.
1.18 espie 1384: .Pp
1385: .Va .TARGETS
1386: is not set to the default target when
1.19 aaron 1387: .Nm
1.18 espie 1388: is invoked without a target name and no
1.19 aaron 1389: .Ic MAIN
1.18 espie 1390: special target exists.
1391: .Pp
1.17 espie 1392: The evaluation of
1393: .Ar expression
1.28 aaron 1394: in a test is very simple-minded.
1395: Currently, the only form that works is
1.48 pvalchev 1396: .Ql .if ${VAR} op something \.
1.50 jmc 1397: For instance, tests should be written as
1.64 mbalmer 1398: .Ql .if ${VAR} == "string" ,
1.17 espie 1399: not the other way around, which doesn't work.
1400: .Pp
1401: For loops are expanded before tests, so a fragment such as:
1.57 jmc 1402: .Bd -literal -offset indent
1.17 espie 1403: \&.for TMACHINE in ${SHARED_ARCHS}
1.64 mbalmer 1404: \&.if ${TMACHINE} == ${MACHINE}
1.17 espie 1405: ...
1406: \&.endif
1.32 ericj 1407: \&.endfor
1.17 espie 1408: .Ed
1.25 espie 1409: .Pp
1.17 espie 1410: won't work, and should be rewritten the other way around.
1.21 espie 1411: .Pp
1.31 aaron 1412: When handling pre-BSD 4.4 archives,
1.21 espie 1413: .Nm
1414: may erroneously mark archive members as out of date if the archive name
1415: was truncated.
1.26 espie 1416: .Pp
1.57 jmc 1417: The handling of
1418: .Sq ;\&
1419: and other special characters in tests may be utterly bogus.
1.28 aaron 1420: For instance, in
1.57 jmc 1421: .Bd -literal -offset indent
1.25 espie 1422: \&A=abcd;c.c
1423: \&.if ${A:R} == "abcd;c"
1424: .Ed
1425: .Pp
1426: the test will never match, even though the value is correct.
1.26 espie 1427: .Pp
1.28 aaron 1428: The conditional handler is incredibly lame.
1429: Junk such as
1.57 jmc 1430: .Pp
1431: .Dl \&.if defined anything goes (A)
1.26 espie 1432: .Pp
1433: will be accepted silently.
1.25 espie 1434: .Pp
1.57 jmc 1435: In a .for loop, only the variable value is used; assignments will be
1.25 espie 1436: evaluated later, e.g., in
1.57 jmc 1437: .Bd -literal -offset indent
1.25 espie 1438: \&.for I in a b c d
1439: I:=${I:S/a/z}
1440: A+=$I
1441: \&.endfor
1442: .Ed
1.57 jmc 1443: .Pp
1444: .Sq A
1445: will evaluate to a b c d after the loop, not z b c d.
1.73 espie 1446: .Pp
1447: .Ic ORDER
1448: is only used in parallel mode, so
1.74 jmc 1449: keep dependency ordered for sequential mode!
1.78 espie 1450: .Pp
1.79 jmc 1451: Distinct target names are treated separately, even though they might
1.78 espie 1452: correspond to the same file in the file system.
1453: This can cause excessive rebuilds of some targets, and bogus
1454: races in parallel mode.
1455: This can also prevent
1456: .Nm
1457: from finding a rule to solve a dependency if the target name is not
1458: exactly the same as the dependency.
1459: .Pp
1460: In parallel mode,
1461: .Fl j Ar n
1462: only limits the number of concurrent makes it knows about.
1463: During recursive invocations, each level will multiply the number
1464: of processes by
1.79 jmc 1465: .Ar n .
1.80 bluhm 1466: .Pp
1467: The
1468: .Va MAKEFILE
1469: variable cannot be used reliably.
1470: It is a compatibility feature and may get set to the last makefile
1471: specified, as it is set by System V make.