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