[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.70

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