[BACK]Return to make.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Annotation of src/usr.bin/make/make.1, Revision 1.74

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