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

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

1.161   ! sjg         1: .\"    $NetBSD: make.1,v 1.160 2009/08/26 23:18:57 sjg Exp $
1.15      thorpej     2: .\"
1.16      christos    3: .\" Copyright (c) 1990, 1993
                      4: .\"    The Regents of the University of California.  All rights reserved.
1.1       cgd         5: .\"
                      6: .\" Redistribution and use in source and binary forms, with or without
                      7: .\" modification, are permitted provided that the following conditions
                      8: .\" are met:
                      9: .\" 1. Redistributions of source code must retain the above copyright
                     10: .\"    notice, this list of conditions and the following disclaimer.
                     11: .\" 2. Redistributions in binary form must reproduce the above copyright
                     12: .\"    notice, this list of conditions and the following disclaimer in the
                     13: .\"    documentation and/or other materials provided with the distribution.
1.84      agc        14: .\" 3. Neither the name of the University nor the names of its contributors
1.1       cgd        15: .\"    may be used to endorse or promote products derived from this software
                     16: .\"    without specific prior written permission.
                     17: .\"
                     18: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     19: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     20: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     21: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     22: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     23: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     24: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     25: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     26: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     27: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     28: .\" SUCH DAMAGE.
                     29: .\"
1.16      christos   30: .\"    from: @(#)make.1        8.4 (Berkeley) 3/19/94
1.1       cgd        31: .\"
1.161   ! sjg        32: .Dd September 7, 2009
1.1       cgd        33: .Dt MAKE 1
                     34: .Os
                     35: .Sh NAME
                     36: .Nm make
                     37: .Nd maintain program dependencies
                     38: .Sh SYNOPSIS
1.74      wiz        39: .Nm
1.75      thorpej    40: .Op Fl BeikNnqrstWX
1.30      mycroft    41: .Bk -words
1.159     sjg        42: .Op Fl C Ar directory
                     43: .Ek
                     44: .Bk -words
1.1       cgd        45: .Op Fl D Ar variable
1.30      mycroft    46: .Ek
                     47: .Bk -words
1.1       cgd        48: .Op Fl d Ar flags
1.30      mycroft    49: .Ek
                     50: .Bk -words
1.1       cgd        51: .Op Fl f Ar makefile
1.30      mycroft    52: .Ek
                     53: .Bk -words
1.1       cgd        54: .Op Fl I Ar directory
1.30      mycroft    55: .Ek
1.1       cgd        56: .Bk -words
1.104     wiz        57: .Op Fl J Ar private
1.30      mycroft    58: .Ek
                     59: .Bk -words
1.104     wiz        60: .Op Fl j Ar max_jobs
1.44      sommerfe   61: .Ek
                     62: .Bk -words
1.13      christos   63: .Op Fl m Ar directory
1.1       cgd        64: .Ek
1.30      mycroft    65: .Bk -words
1.44      sommerfe   66: .Op Fl T Ar file
                     67: .Ek
                     68: .Bk -words
1.16      christos   69: .Op Fl V Ar variable
1.30      mycroft    70: .Ek
1.1       cgd        71: .Op Ar variable=value
1.30      mycroft    72: .Bk -words
1.1       cgd        73: .Op Ar target ...
1.30      mycroft    74: .Ek
1.1       cgd        75: .Sh DESCRIPTION
1.25      lukem      76: .Nm
1.1       cgd        77: is a program designed to simplify the maintenance of other programs.
                     78: Its input is a list of specifications as to the files upon which programs
                     79: and other files depend.
1.128     dsl        80: If no
                     81: .Fl f Ar makefile
                     82: makefile option is given,
                     83: .Nm
                     84: will try to open
1.1       cgd        85: .Ql Pa makefile
1.128     dsl        86: then
1.1       cgd        87: .Ql Pa Makefile
1.128     dsl        88: in order to find the specifications.
1.1       cgd        89: If the file
                     90: .Ql Pa .depend
                     91: exists, it is read (see
1.66      wiz        92: .Xr mkdep 1 ) .
1.1       cgd        93: .Pp
                     94: This manual page is intended as a reference document only.
                     95: For a more thorough description of
1.25      lukem      96: .Nm
1.1       cgd        97: and makefiles, please refer to
                     98: .%T "Make \- A Tutorial" .
                     99: .Pp
1.128     dsl       100: .Nm
                    101: will prepend the contents of the
                    102: .Va MAKEFLAGS
                    103: environment variable to the command line arguments before parsing them.
                    104: .Pp
1.1       cgd       105: The options are as follows:
                    106: .Bl -tag -width Ds
1.16      christos  107: .It Fl B
1.10      christos  108: Try to be backwards compatible by executing a single shell per command and
                    109: by executing the commands to make the sources of a dependency line in sequence.
1.159     sjg       110: .It Fl C Ar directory
                    111: Change to
                    112: .Ar directory
                    113: before reading the makefiles or doing anything else.
                    114: If multiple
                    115: .Fl C
                    116: options are specified, each is interpreted relative to the previous one:
                    117: .Fl C Pa / Fl C Pa etc
                    118: is equivalent to
                    119: .Fl C Pa /etc .
1.1       cgd       120: .It Fl D Ar variable
1.8       christos  121: Define
                    122: .Ar variable
1.1       cgd       123: to be 1, in the global context.
1.128     dsl       124: .It Fl d Ar [-]flags
1.1       cgd       125: Turn on debugging, and specify which portions of
1.25      lukem     126: .Nm
1.1       cgd       127: are to print debugging information.
1.128     dsl       128: Unless the flags are preceded by
                    129: .Ql -
                    130: they are added to the
                    131: .Va MAKEFLAGS
                    132: environment variable and will be processed by any child make processes.
1.141     apb       133: By default, debugging information is printed to standard error,
1.138     apb       134: but this can be changed using the
1.140     wiz       135: .Ar F
1.138     apb       136: debugging flag.
1.139     apb       137: The debugging output is always unbuffered; in addition, if debugging
                    138: is enabled but debugging output is not directed to standard output,
                    139: then the standard output is line buffered.
1.1       cgd       140: .Ar Flags
                    141: is one or more of the following:
                    142: .Bl -tag -width Ds
                    143: .It Ar A
                    144: Print all possible debugging information;
                    145: equivalent to specifying all of the debugging flags.
                    146: .It Ar a
                    147: Print debugging information about archive searching and caching.
1.147     christos  148: .It Ar C
                    149: Print debugging information about current working directory.
1.1       cgd       150: .It Ar c
                    151: Print debugging information about conditional evaluation.
                    152: .It Ar d
                    153: Print debugging information about directory searching and caching.
1.88      jmmv      154: .It Ar e
                    155: Print debugging information about failed commands and targets.
1.138     apb       156: .It Ar F Ns Oo Sy \&+ Oc Ns Ar filename
                    157: Specify where debugging output is written.
                    158: This must be the last flag, because it consumes the remainder of
                    159: the argument.
                    160: If the character immediately after the
                    161: .Ql F
                    162: flag is
                    163: .Ql \&+ ,
                    164: then the file will be opened in append mode;
                    165: otherwise the file will be overwritten.
                    166: If the file name is
                    167: .Ql stdout
                    168: or
                    169: .Ql stderr
                    170: then debugging output will be written to the
                    171: standard output or standard error output file descriptors respectively
                    172: (and the
                    173: .Ql \&+
                    174: option has no effect).
                    175: Otherwise, the output will be written to the named file.
                    176: If the file name ends
1.128     dsl       177: .Ql .%d
                    178: then the
                    179: .Ql %d
                    180: is replaced by the pid.
1.87      jmmv      181: .It Ar f
                    182: Print debugging information about loop evaluation.
1.1       cgd       183: .It Ar "g1"
                    184: Print the input graph before making anything.
                    185: .It Ar "g2"
                    186: Print the input graph after making everything, or before exiting
1.93      dsl       187: on error.
1.92      dsl       188: .It Ar "g3"
                    189: Print the input graph before exiting on error.
1.1       cgd       190: .It Ar j
                    191: Print debugging information about running multiple shells.
1.135     sjg       192: .It Ar l
                    193: Print commands in Makefiles regardless of whether or not they are prefixed by
1.137     wiz       194: .Ql @
1.135     sjg       195: or other "quiet" flags.
                    196: Also known as "loud" behavior.
1.1       cgd       197: .It Ar m
                    198: Print debugging information about making targets, including modification
                    199: dates.
1.111     jmc       200: .It Ar n
1.154     apb       201: Don't delete the temporary command scripts created when running commands.
                    202: These temporary scripts are created in the directory
                    203: referred to by the
                    204: .Ev TMPDIR
                    205: environment variable, or in
1.112     wiz       206: .Pa /tmp
1.154     apb       207: if
                    208: .Ev TMPDIR
                    209: is unset or set to the empty string.
                    210: The temporary scripts are created by
                    211: .Xr mkstemp 3 ,
1.112     wiz       212: and have names of the form
1.154     apb       213: .Pa makeXXXXXX .
1.123     wiz       214: .Em NOTE :
1.156     snj       215: This can create many files in
1.154     apb       216: .Ev TMPDIR
                    217: or
                    218: .Pa /tmp ,
1.123     wiz       219: so use with care.
1.119     dsl       220: .It Ar p
                    221: Print debugging information about makefile parsing.
1.1       cgd       222: .It Ar s
                    223: Print debugging information about suffix-transformation rules.
                    224: .It Ar t
                    225: Print debugging information about target list maintenance.
                    226: .It Ar v
                    227: Print debugging information about variable assignment.
1.49      sjg       228: .It Ar x
1.57      wiz       229: Run shell commands with
                    230: .Fl x
                    231: so the actual commands are printed as they are executed.
1.1       cgd       232: .El
                    233: .It Fl e
1.68      perry     234: Specify that environment variables override macro assignments within
1.1       cgd       235: makefiles.
                    236: .It Fl f Ar makefile
                    237: Specify a makefile to read instead of the default
1.103     wiz       238: .Ql Pa makefile .
1.1       cgd       239: If
                    240: .Ar makefile
                    241: is
                    242: .Ql Fl ,
                    243: standard input is read.
1.103     wiz       244: Multiple makefiles may be specified, and are read in the order specified.
1.1       cgd       245: .It Fl I Ar directory
                    246: Specify a directory in which to search for makefiles and included makefiles.
1.13      christos  247: The system makefile directory (or directories, see the
                    248: .Fl m
                    249: option) is automatically included as part of this list.
1.1       cgd       250: .It Fl i
                    251: Ignore non-zero exit of shell commands in the makefile.
                    252: Equivalent to specifying
                    253: .Ql Fl
                    254: before each command line in the makefile.
1.44      sommerfe  255: .It Fl J Ar private
                    256: This option should
                    257: .Em not
                    258: be specified by the user.
                    259: .Pp
                    260: When the
                    261: .Ar j
                    262: option is in use in a recursive build, this option is passed by a make
                    263: to child makes to allow all the make processes in the build to
                    264: cooperate to avoid overloading the system.
1.1       cgd       265: .It Fl j Ar max_jobs
                    266: Specify the maximum number of jobs that
1.25      lukem     267: .Nm
1.67      grant     268: may have running at any one time.
                    269: Turns compatibility mode off, unless the
1.11      christos  270: .Ar B
                    271: flag is also specified.
1.148     christos  272: When compatibility mode is off, all commands associated with a
                    273: target are executed in a single shell invocation as opposed to the
                    274: traditional one shell invocation per line.
                    275: This can break traditional scripts which change directories on each
                    276: command invocation and then expect to start with a fresh environment
                    277: on the next line.
                    278: It is more efficient to correct the scripts rather than turn backwards
                    279: compatibility on.
1.1       cgd       280: .It Fl k
                    281: Continue processing after errors are encountered, but only on those targets
                    282: that do not depend on the target whose creation caused the error.
1.13      christos  283: .It Fl m Ar directory
                    284: Specify a directory in which to search for sys.mk and makefiles included
1.99      wiz       285: via the
                    286: .Ao Ar file Ac Ns -style
                    287: include statement.
1.98      chuck     288: The
                    289: .Fl m
                    290: option can be used multiple times to form a search path.
1.13      christos  291: This path will override the default system include path: /usr/share/mk.
                    292: Furthermore the system include path will be appended to the search path used
1.99      wiz       293: for
                    294: .Qo Ar file Qc Ns -style
                    295: include statements (see the
1.13      christos  296: .Fl I
                    297: option).
1.98      chuck     298: .Pp
                    299: If a file or directory name in the
                    300: .Fl m
1.99      wiz       301: argument (or the
                    302: .Ev MAKESYSPATH
                    303: environment variable) starts with the string
                    304: .Qq \&.../
                    305: then
                    306: .Nm
                    307: will search for the specified file or directory named in the remaining part
                    308: of the argument string.
                    309: The search starts with the current directory of
1.98      chuck     310: the Makefile and then works upward towards the root of the filesystem.
1.99      wiz       311: If the search is successful, then the resulting directory replaces the
                    312: .Qq \&.../
                    313: specification in the
1.98      chuck     314: .Fl m
1.99      wiz       315: argument.
                    316: If used, this feature allows
1.98      chuck     317: .Nm
                    318: to easily search in the current source tree for customized sys.mk files
1.99      wiz       319: (e.g., by using
                    320: .Qq \&.../mk/sys.mk
                    321: as an argument).
1.1       cgd       322: .It Fl n
1.45      sommerfe  323: Display the commands that would have been executed, but do not
                    324: actually execute them unless the target depends on the .MAKE special
1.64      wiz       325: source (see below).
1.45      sommerfe  326: .It Fl N
                    327: Display the commands which would have been executed, but do not
                    328: actually execute any of them; useful for debugging top-level makefiles
                    329: without descending into subdirectories.
1.1       cgd       330: .It Fl q
                    331: Do not execute any commands, but exit 0 if the specified targets are
                    332: up-to-date and 1, otherwise.
                    333: .It Fl r
                    334: Do not use the built-in rules specified in the system makefile.
                    335: .It Fl s
                    336: Do not echo any commands as they are executed.
                    337: Equivalent to specifying
                    338: .Ql Ic @
                    339: before each command line in the makefile.
1.44      sommerfe  340: .It Fl T Ar tracefile
                    341: When used with the
1.48      wiz       342: .Fl j
1.44      sommerfe  343: flag,
                    344: append a trace record to
                    345: .Ar tracefile
                    346: for each job started and completed.
1.1       cgd       347: .It Fl t
                    348: Rather than re-building a target as specified in the makefile, create it
                    349: or update its modification time to make it appear up-to-date.
1.16      christos  350: .It Fl V Ar variable
                    351: Print
1.74      wiz       352: .Nm Ns 's
1.16      christos  353: idea of the value of
                    354: .Ar variable ,
                    355: in the global context.
                    356: Do not build any targets.
                    357: Multiple instances of this option may be specified;
                    358: the variables will be printed one per line,
                    359: with a blank line for each null or undefined variable.
1.85      sjg       360: If
                    361: .Ar variable
                    362: contains a
                    363: .Ql \&$
                    364: then the value will be expanded before printing.
1.46      christos  365: .It Fl W
                    366: Treat any warnings during makefile parsing as errors.
1.75      thorpej   367: .It Fl X
                    368: Don't export variables passed on the command line to the environment
                    369: individually.
                    370: Variables passed on the command line are still exported
                    371: via the
                    372: .Va MAKEFLAGS
                    373: environment variable.
                    374: This option may be useful on systems which have a small limit on the
                    375: size of command arguments.
1.1       cgd       376: .It Ar variable=value
                    377: Set the value of the variable
                    378: .Ar variable
                    379: to
                    380: .Ar value .
1.75      thorpej   381: Normally, all values passed on the command line are also exported to
                    382: sub-makes in the environment.
                    383: The
                    384: .Fl X
                    385: flag disables this behavior.
1.101     wiz       386: Variable assignments should follow options for POSIX compatibility
1.100     ross      387: but no ordering is enforced.
1.1       cgd       388: .El
                    389: .Pp
1.6       cgd       390: There are seven different types of lines in a makefile: file dependency
1.1       cgd       391: specifications, shell commands, variable assignments, include statements,
1.6       cgd       392: conditional directives, for loops, and comments.
1.1       cgd       393: .Pp
                    394: In general, lines may be continued from one line to the next by ending
                    395: them with a backslash
                    396: .Pq Ql \e .
                    397: The trailing newline character and initial whitespace on the following
                    398: line are compressed into a single space.
                    399: .Sh FILE DEPENDENCY SPECIFICATIONS
                    400: Dependency lines consist of one or more targets, an operator, and zero
                    401: or more sources.
1.137     wiz       402: This creates a relationship where the targets
                    403: .Dq depend
                    404: on the sources
1.1       cgd       405: and are usually created from them.
                    406: The exact relationship between the target and the source is determined
                    407: by the operator that separates them.
                    408: The three operators are as follows:
                    409: .Bl -tag -width flag
                    410: .It Ic \&:
                    411: A target is considered out-of-date if its modification time is less than
                    412: those of any of its sources.
                    413: Sources for a target accumulate over dependency lines when this operator
                    414: is used.
                    415: The target is removed if
1.25      lukem     416: .Nm
1.1       cgd       417: is interrupted.
                    418: .It Ic \&!
                    419: Targets are always re-created, but not until all sources have been
                    420: examined and re-created as necessary.
                    421: Sources for a target accumulate over dependency lines when this operator
                    422: is used.
                    423: The target is removed if
1.25      lukem     424: .Nm
1.1       cgd       425: is interrupted.
                    426: .It Ic \&::
                    427: If no sources are specified, the target is always re-created.
                    428: Otherwise, a target is considered out-of-date if any of its sources has
                    429: been modified more recently than the target.
                    430: Sources for a target do not accumulate over dependency lines when this
                    431: operator is used.
                    432: The target will not be removed if
1.25      lukem     433: .Nm
1.1       cgd       434: is interrupted.
                    435: .El
                    436: .Pp
                    437: Targets and sources may contain the shell wildcard values
1.80      wiz       438: .Ql \&? ,
1.1       cgd       439: .Ql * ,
1.103     wiz       440: .Ql [] ,
1.1       cgd       441: and
                    442: .Ql {} .
                    443: The values
1.80      wiz       444: .Ql \&? ,
1.103     wiz       445: .Ql * ,
1.1       cgd       446: and
                    447: .Ql []
                    448: may only be used as part of the final
                    449: component of the target or source, and must be used to describe existing
                    450: files.
                    451: The value
                    452: .Ql {}
                    453: need not necessarily be used to describe existing files.
                    454: Expansion is in directory order, not alphabetically as done in the shell.
                    455: .Sh SHELL COMMANDS
                    456: Each target may have associated with it a series of shell commands, normally
                    457: used to create the target.
                    458: Each of the commands in this script
                    459: .Em must
                    460: be preceded by a tab.
                    461: While any target may appear on a dependency line, only one of these
                    462: dependencies may be followed by a creation script, unless the
1.91      lukem     463: .Ql Ic \&::
1.1       cgd       464: operator is used.
                    465: .Pp
1.102     sjg       466: If the first characters of the command line are any combination of
                    467: .Ql Ic @ ,
1.103     wiz       468: .Ql Ic + ,
1.102     sjg       469: or
1.1       cgd       470: .Ql Ic \- ,
                    471: the command is treated specially.
                    472: A
                    473: .Ql Ic @
                    474: causes the command not to be echoed before it is executed.
                    475: A
1.102     sjg       476: .Ql Ic +
                    477: causes the command to be executed even when
                    478: .Fl n
                    479: is given.
                    480: This is similar to the effect of the .MAKE special source,
                    481: except that the effect can be limited to a single line of a script.
                    482: A
1.1       cgd       483: .Ql Ic \-
                    484: causes any non-zero exit status of the command line to be ignored.
                    485: .Sh VARIABLE ASSIGNMENTS
                    486: Variables in make are much like variables in the shell, and, by tradition,
                    487: consist of all upper-case letters.
1.91      lukem     488: .Ss Variable assignment modifiers
1.1       cgd       489: The five operators that can be used to assign values to variables are as
                    490: follows:
                    491: .Bl -tag -width Ds
                    492: .It Ic \&=
                    493: Assign the value to the variable.
                    494: Any previous value is overridden.
                    495: .It Ic \&+=
                    496: Append the value to the current value of the variable.
                    497: .It Ic \&?=
                    498: Assign the value to the variable if it is not already defined.
                    499: .It Ic \&:=
                    500: Assign with expansion, i.e. expand the value before assigning it
                    501: to the variable.
                    502: Normally, expansion is not done until the variable is referenced.
1.124     sjg       503: .Em NOTE :
                    504: References to undefined variables are
                    505: .Em not
1.125     wiz       506: expanded.
                    507: This can cause problems when variable modifiers are used.
1.1       cgd       508: .It Ic \&!=
                    509: Expand the value and pass it to the shell for execution and assign
                    510: the result to the variable.
                    511: Any newlines in the result are replaced with spaces.
                    512: .El
                    513: .Pp
                    514: Any white-space before the assigned
                    515: .Ar value
                    516: is removed; if the value is being appended, a single space is inserted
                    517: between the previous contents of the variable and the appended value.
                    518: .Pp
                    519: Variables are expanded by surrounding the variable name with either
                    520: curly braces
                    521: .Pq Ql {}
1.7       mycroft   522: or parentheses
1.1       cgd       523: .Pq Ql ()
                    524: and preceding it with
                    525: a dollar sign
                    526: .Pq Ql \&$ .
                    527: If the variable name contains only a single letter, the surrounding
1.7       mycroft   528: braces or parentheses are not required.
1.1       cgd       529: This shorter form is not recommended.
                    530: .Pp
1.149     dsl       531: If the variable name contains a dollar, then the name itself is expanded first.
                    532: This allows almost arbitrary variable names, however names containing dollar,
                    533: braces, parenthesis, or whitespace are really best avoided!
                    534: .Pp
                    535: If the result of expanding a variable contains a dollar sign
                    536: .Pq Ql \&$
                    537: the string is expanded again.
                    538: .Pp
1.1       cgd       539: Variable substitution occurs at two distinct times, depending on where
                    540: the variable is being used.
                    541: Variables in dependency lines are expanded as the line is read.
                    542: Variables in shell commands are expanded when the shell command is
                    543: executed.
1.91      lukem     544: .Ss Variable classes
1.1       cgd       545: The four different classes of variables (in order of increasing precedence)
                    546: are:
                    547: .Bl -tag -width Ds
                    548: .It Environment variables
                    549: Variables defined as part of
1.74      wiz       550: .Nm Ns 's
1.1       cgd       551: environment.
                    552: .It Global variables
                    553: Variables defined in the makefile or in included makefiles.
                    554: .It Command line variables
                    555: Variables defined as part of the command line.
                    556: .It Local variables
                    557: Variables that are defined specific to a certain target.
                    558: The seven local variables are as follows:
                    559: .Bl -tag -width ".ARCHIVE"
                    560: .It Va .ALLSRC
                    561: The list of all sources for this target; also known as
1.62      ross      562: .Ql Va \&\*[Gt] .
1.1       cgd       563: .It Va .ARCHIVE
                    564: The name of the archive file.
                    565: .It Va .IMPSRC
1.136     cube      566: In suffix-transformation rules, the name/path of the source from which the
1.137     wiz       567: target is to be transformed (the
                    568: .Dq implied
                    569: source); also known as
1.62      ross      570: .Ql Va \&\*[Lt] .
1.136     cube      571: It is not defined in explicit rules.
1.1       cgd       572: .It Va .MEMBER
                    573: The name of the archive member.
                    574: .It Va .OODATE
                    575: The list of sources for this target that were deemed out-of-date; also
                    576: known as
                    577: .Ql Va \&? .
                    578: .It Va .PREFIX
                    579: The file prefix of the file, containing only the file portion, no suffix
                    580: or preceding directory components; also known as
                    581: .Ql Va * .
                    582: .It Va .TARGET
                    583: The name of the target; also known as
                    584: .Ql Va @ .
                    585: .El
                    586: .Pp
                    587: The shorter forms
                    588: .Ql Va @ ,
1.80      wiz       589: .Ql Va \&? ,
1.65      christos  590: .Ql Va \&\*[Lt] ,
                    591: .Ql Va \&\*[Gt] ,
1.1       cgd       592: and
                    593: .Ql Va *
                    594: are permitted for backward
                    595: compatibility with historical makefiles and are not recommended.
                    596: The six variables
                    597: .Ql Va "@F" ,
                    598: .Ql Va "@D" ,
1.62      ross      599: .Ql Va "\*[Lt]F" ,
                    600: .Ql Va "\*[Lt]D" ,
1.66      wiz       601: .Ql Va "*F" ,
1.1       cgd       602: and
                    603: .Ql Va "*D"
1.66      wiz       604: are permitted for compatibility with
1.1       cgd       605: .At V
                    606: makefiles and are not recommended.
                    607: .Pp
                    608: Four of the local variables may be used in sources on dependency lines
                    609: because they expand to the proper value for each target on the line.
                    610: These variables are
                    611: .Ql Va .TARGET ,
                    612: .Ql Va .PREFIX ,
                    613: .Ql Va .ARCHIVE ,
                    614: and
                    615: .Ql Va .MEMBER .
1.59      bgrayson  616: .El
1.145     christos  617: .Ss Additional built-in variables
1.1       cgd       618: In addition,
1.25      lukem     619: .Nm
1.1       cgd       620: sets or knows about the following variables:
1.50      sjg       621: .Bl -tag -width .MAKEOVERRIDES
1.1       cgd       622: .It Va \&$
                    623: A single dollar sign
                    624: .Ql \&$ ,
                    625: i.e.
                    626: .Ql \&$$
                    627: expands to a single dollar
                    628: sign.
1.56      tv        629: .It Va .ALLTARGETS
1.67      grant     630: The list of all targets encountered in the Makefile.
                    631: If evaluated during
1.56      tv        632: Makefile parsing, lists only those targets encountered thus far.
1.1       cgd       633: .It Va .CURDIR
                    634: A path to the directory where
1.25      lukem     635: .Nm
1.1       cgd       636: was executed.
1.117     lukem     637: Refer to the description of
                    638: .Ql Ev PWD
                    639: for more details.
1.78      christos  640: .It Ev MAKE
1.55      tv        641: The name that
                    642: .Nm
1.89      sjg       643: was executed with
                    644: .Pq Va argv[0] .
1.126     reed      645: For compatibility
1.78      christos  646: .Nm
                    647: also sets
                    648: .Va .MAKE
                    649: with the same value.
1.97      lukem     650: The preferred variable to use is the environment variable
1.78      christos  651: .Ev MAKE
                    652: because it is more compatible with other versions of
                    653: .Nm
                    654: and cannot be confused with the special target with the same name.
1.134     sjg       655: .It Va .MAKE.EXPORTED
                    656: The list of variables exported by
                    657: .Nm .
                    658: .It Va .MAKE.MAKEFILES
                    659: The list of makefiles read by
                    660: .Nm ,
                    661: which is useful for tracking dependencies.
                    662: Each makefile is recorded only once, regardless of the number of times read.
1.161   ! sjg       663: .It Va .MAKE.LEVEL
        !           664: The recursion depth of
        !           665: .Nm .
        !           666: The initial instance of
        !           667: .Nm
        !           668: will be 0, and an incremented value is put into the environment
        !           669: to be seen by the next generation.
        !           670: This allows tests like:
        !           671: .Li .if ${.MAKE.LEVEL} == 0
        !           672: to protect things which should only be evaluated in the initial instance of
        !           673: .Nm .
1.132     sjg       674: .It Va .MAKE.PID
1.137     wiz       675: The process-id of
1.132     sjg       676: .Nm .
                    677: .It Va .MAKE.PPID
1.137     wiz       678: The parent process-id of
1.132     sjg       679: .Nm .
                    680: .It Va .MAKE.JOB.PREFIX
1.137     wiz       681: If
1.132     sjg       682: .Nm
                    683: is run with
                    684: .Ar j
1.137     wiz       685: then output for each target is prefixed with a token
1.132     sjg       686: .Ql --- target ---
                    687: the first part of which can be controlled via
                    688: .Va .MAKE.JOB.PREFIX .
                    689: .br
1.137     wiz       690: For example:
1.132     sjg       691: .Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
                    692: would produce tokens like
                    693: .Ql ---make[1234] target ---
                    694: making it easier to track the degree of parallelism being achieved.
1.1       cgd       695: .It Ev MAKEFLAGS
                    696: The environment variable
                    697: .Ql Ev MAKEFLAGS
                    698: may contain anything that
                    699: may be specified on
1.74      wiz       700: .Nm Ns 's
1.1       cgd       701: command line.
                    702: Anything specified on
1.74      wiz       703: .Nm Ns 's
1.1       cgd       704: command line is appended to the
                    705: .Ql Ev MAKEFLAGS
                    706: variable which is then
                    707: entered into the environment for all programs which
1.25      lukem     708: .Nm
1.1       cgd       709: executes.
1.50      sjg       710: .It Va .MAKEOVERRIDES
1.57      wiz       711: This variable is used to record the names of variables assigned to
                    712: on the command line, so that they may be exported as part of
1.50      sjg       713: .Ql Ev MAKEFLAGS .
1.57      wiz       714: This behaviour can be disabled by assigning an empty value to
1.50      sjg       715: .Ql Va .MAKEOVERRIDES
1.67      grant     716: within a makefile.
                    717: Extra variables can be exported from a makefile
1.57      wiz       718: by appending their names to
1.51      sjg       719: .Ql Va .MAKEOVERRIDES .
                    720: .Ql Ev MAKEFLAGS
1.57      wiz       721: is re-exported whenever
1.51      sjg       722: .Ql Va .MAKEOVERRIDES
                    723: is modified.
1.55      tv        724: .It Va MAKE_PRINT_VAR_ON_ERROR
1.57      wiz       725: When
1.55      tv        726: .Nm
                    727: stops due to an error, it prints its name and the value of
                    728: .Ql Va .CURDIR
1.57      wiz       729: as well as the value of any variables named in
1.55      tv        730: .Ql Va MAKE_PRINT_VAR_ON_ERROR .
                    731: .It Va .newline
                    732: This variable is simply assigned a newline character as its value.
1.91      lukem     733: This allows expansions using the
                    734: .Cm \&:@
                    735: modifier to put a newline between
1.67      grant     736: iterations of the loop rather than a space.
                    737: For example, the printing of
1.55      tv        738: .Ql Va MAKE_PRINT_VAR_ON_ERROR
                    739: could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
                    740: .It Va .OBJDIR
                    741: A path to the directory where the targets are built.
1.117     lukem     742: Its value is determined by trying to
                    743: .Xr chdir 2
                    744: to the following directories in order and using the first match:
                    745: .Bl -enum
                    746: .It
1.118     wiz       747: .Ev ${MAKEOBJDIRPREFIX}${.CURDIR}
                    748: .Pp
1.117     lukem     749: (Only if
                    750: .Ql Ev MAKEOBJDIRPREFIX
                    751: is set in the environment or on the command line.)
                    752: .It
1.118     wiz       753: .Ev ${MAKEOBJDIR}
                    754: .Pp
1.117     lukem     755: (Only if
                    756: .Ql Ev MAKEOBJDIR
                    757: is set in the environment or on the command line.)
                    758: .It
                    759: .Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE}
                    760: .It
                    761: .Ev ${.CURDIR} Ns Pa /obj
                    762: .It
                    763: .Pa /usr/obj/ Ns Ev ${.CURDIR}
                    764: .It
                    765: .Ev ${.CURDIR}
                    766: .El
                    767: .Pp
                    768: Variable expansion is performed on the value before it's used,
                    769: so expressions such as
                    770: .Dl ${.CURDIR:C,^/usr/src,/var/obj,}
                    771: may be used.
                    772: .Pp
                    773: .Ql Va .OBJDIR
                    774: may be modified in the makefile as a global variable.
1.137     wiz       775: In all cases,
1.117     lukem     776: .Nm
                    777: will
                    778: .Xr chdir 2
                    779: to
                    780: .Ql Va .OBJDIR
                    781: and set
                    782: .Ql Ev PWD
                    783: to that directory before executing any targets.
                    784: .
1.55      tv        785: .It Va .PARSEDIR
                    786: A path to the directory of the current
                    787: .Ql Pa Makefile
                    788: being parsed.
                    789: .It Va .PARSEFILE
                    790: The basename of the current
                    791: .Ql Pa Makefile
                    792: being parsed.
                    793: This variable and
                    794: .Ql Va .PARSEDIR
                    795: are both set only while the
                    796: .Ql Pa Makefiles
                    797: are being parsed.
1.69      sjg       798: .It Va .PATH
1.82      wiz       799: A variable that represents the list of directories that
1.69      sjg       800: .Nm
1.70      wiz       801: will search for files.
                    802: The search list should be updated using the target
1.69      sjg       803: .Ql Va .PATH
                    804: rather than the variable.
1.16      christos  805: .It Ev PWD
                    806: Alternate path to the current directory.
1.25      lukem     807: .Nm
1.16      christos  808: normally sets
                    809: .Ql Va .CURDIR
                    810: to the canonical path given by
1.48      wiz       811: .Xr getcwd 3 .
1.16      christos  812: However, if the environment variable
                    813: .Ql Ev PWD
                    814: is set and gives a path to the current directory, then
1.25      lukem     815: .Nm
1.16      christos  816: sets
                    817: .Ql Va .CURDIR
                    818: to the value of
                    819: .Ql Ev PWD
1.67      grant     820: instead.
                    821: This behaviour is disabled if
1.40      sjg       822: .Ql Ev MAKEOBJDIRPREFIX
1.117     lukem     823: is set or
                    824: .Ql Ev MAKEOBJDIR
                    825: contains a variable transform.
1.16      christos  826: .Ql Ev PWD
                    827: is set to the value of
                    828: .Ql Va .OBJDIR
                    829: for all programs which
1.25      lukem     830: .Nm
1.16      christos  831: executes.
1.145     christos  832: .It Ev VPATH
1.146     wiz       833: Colon-separated
                    834: .Pq Dq \&:
                    835: lists of directories that
                    836: .Nm
                    837: will search for files.
1.145     christos  838: The variable is supported for compatibility with old make programs only,
                    839: use
                    840: .Ql Va .PATH
                    841: instead.
1.1       cgd       842: .El
1.91      lukem     843: .Ss Variable modifiers
1.1       cgd       844: Variable expansion may be modified to select or modify each word of the
1.137     wiz       845: variable (where a
                    846: .Dq word
                    847: is white-space delimited sequence of characters).
1.1       cgd       848: The general format of a variable expansion is as follows:
                    849: .Pp
1.120     sjg       850: .Dl ${variable[:modifier[:...]]}
1.1       cgd       851: .Pp
1.97      lukem     852: Each modifier begins with a colon,
                    853: which may be escaped with a backslash
1.1       cgd       854: .Pq Ql \e .
1.120     sjg       855: .Pp
                    856: A set of modifiers can be specified via a variable, as follows:
                    857: .Pp
                    858: .Dl modifier_variable=modifier[:...]
                    859: .Dl ${variable:${modifier_variable}[:...]}
                    860: .Pp
                    861: In this case the first modifier in the modifier_variable does not
                    862: start with a colon, since that must appear in the referencing
                    863: variable.
                    864: If any of the modifiers in the modifier_variable contain a dollar sign
                    865: .Pq Ql $ ,
                    866: these must be doubled to avoid early expansion.
                    867: .Pp
1.97      lukem     868: The supported modifiers are:
1.61      ross      869: .Bl -tag -width EEE
1.91      lukem     870: .It Cm \&:E
1.1       cgd       871: Replaces each word in the variable with its suffix.
1.91      lukem     872: .It Cm \&:H
1.1       cgd       873: Replaces each word in the variable with everything but the last component.
1.91      lukem     874: .It Cm \&:M Ns Ar pattern
1.72      uebayasi  875: Select only those words that match
                    876: .Ar pattern .
1.1       cgd       877: The standard shell wildcard characters
                    878: .Pf ( Ql * ,
1.80      wiz       879: .Ql \&? ,
1.1       cgd       880: and
                    881: .Ql Op )
                    882: may
                    883: be used.
                    884: The wildcard characters may be escaped with a backslash
                    885: .Pq Ql \e .
1.91      lukem     886: .It Cm \&:N Ns Ar pattern
1.1       cgd       887: This is identical to
1.91      lukem     888: .Ql Cm \&:M ,
1.1       cgd       889: but selects all words which do not match
1.72      uebayasi  890: .Ar pattern .
1.91      lukem     891: .It Cm \&:O
1.109     wiz       892: Order every word in variable alphabetically.
                    893: To sort words in
                    894: reverse order use the
1.108     sjg       895: .Ql Cm \&:O:[-1..1]
                    896: combination of modifiers.
                    897: .It Cm \&:Ox
1.109     wiz       898: Randomize words in variable.
                    899: The results will be different each time you are referring to the
                    900: modified variable; use the assignment with expansion
1.108     sjg       901: .Pq Ql Cm \&:=
1.109     wiz       902: to prevent such behaviour.
                    903: For example,
1.108     sjg       904: .Bd -literal -offset indent
                    905: LIST=                  uno due tre quattro
                    906: RANDOM_LIST=           ${LIST:Ox}
                    907: STATIC_RANDOM_LIST:=   ${LIST:Ox}
                    908:
                    909: all:
                    910:        @echo "${RANDOM_LIST}"
                    911:        @echo "${RANDOM_LIST}"
                    912:        @echo "${STATIC_RANDOM_LIST}"
                    913:        @echo "${STATIC_RANDOM_LIST}"
                    914: .Ed
1.109     wiz       915: may produce output similar to:
1.108     sjg       916: .Bd -literal -offset indent
                    917: quattro due tre uno
                    918: tre due quattro uno
                    919: due uno quattro tre
                    920: due uno quattro tre
                    921: .Ed
1.91      lukem     922: .It Cm \&:Q
1.17      christos  923: Quotes every shell meta-character in the variable, so that it can be passed
                    924: safely through recursive invocations of
1.74      wiz       925: .Nm .
1.91      lukem     926: .It Cm \&:R
1.1       cgd       927: Replaces each word in the variable with everything but its suffix.
1.91      lukem     928: .It Cm \&:tl
1.60      pk        929: Converts variable to lower-case letters.
1.91      lukem     930: .It Cm \&:ts Ns Ar c
1.81      sjg       931: Words in the variable are normally separated by a space on expansion.
                    932: This modifier sets the separator to the character
                    933: .Ar c .
                    934: If
                    935: .Ar c
                    936: is omitted, then no separator is used.
1.91      lukem     937: .It Cm \&:tu
1.82      wiz       938: Converts variable to upper-case letters.
1.91      lukem     939: .It Cm \&:tW
1.89      sjg       940: Causes the value to be treated as a single word
                    941: (possibly containing embedded white space).
                    942: See also
1.91      lukem     943: .Ql Cm \&:[*] .
                    944: .It Cm \&:tw
1.89      sjg       945: Causes the value to be treated as a sequence of
                    946: words delimited by white space.
                    947: See also
1.91      lukem     948: .Ql Cm \&:[@] .
1.1       cgd       949: .Sm off
1.91      lukem     950: .It Cm \&:S No \&/ Ar old_string Xo
1.17      christos  951: .No \&/ Ar new_string
1.89      sjg       952: .No \&/ Op Cm 1gW
1.1       cgd       953: .Xc
                    954: .Sm on
                    955: Modify the first occurrence of
1.17      christos  956: .Ar old_string
                    957: in the variable's value, replacing it with
                    958: .Ar new_string .
1.1       cgd       959: If a
                    960: .Ql g
                    961: is appended to the last slash of the pattern, all occurrences
                    962: in each word are replaced.
1.17      christos  963: If a
                    964: .Ql 1
                    965: is appended to the last slash of the pattern, only the first word
                    966: is affected.
1.89      sjg       967: If a
                    968: .Ql W
                    969: is appended to the last slash of the pattern,
                    970: then the value is treated as a single word
                    971: (possibly containing embedded white space).
1.1       cgd       972: If
1.17      christos  973: .Ar old_string
                    974: begins with a caret
1.1       cgd       975: .Pq Ql ^ ,
1.17      christos  976: .Ar old_string
1.1       cgd       977: is anchored at the beginning of each word.
                    978: If
1.17      christos  979: .Ar old_string
1.1       cgd       980: ends with a dollar sign
                    981: .Pq Ql \&$ ,
                    982: it is anchored at the end of each word.
                    983: Inside
                    984: .Ar new_string ,
                    985: an ampersand
1.62      ross      986: .Pq Ql \*[Am]
1.1       cgd       987: is replaced by
1.17      christos  988: .Ar old_string
                    989: (without any
                    990: .Ql ^
                    991: or
                    992: .Ql \&$ ) .
1.1       cgd       993: Any character may be used as a delimiter for the parts of the modifier
                    994: string.
                    995: The anchoring, ampersand and delimiter characters may be escaped with a
                    996: backslash
                    997: .Pq Ql \e .
                    998: .Pp
                    999: Variable expansion occurs in the normal fashion inside both
                   1000: .Ar old_string
                   1001: and
                   1002: .Ar new_string
                   1003: with the single exception that a backslash is used to prevent the expansion
                   1004: of a dollar sign
1.17      christos 1005: .Pq Ql \&$ ,
1.1       cgd      1006: not a preceding dollar sign as is usual.
1.17      christos 1007: .Sm off
1.91      lukem    1008: .It Cm \&:C No \&/ Ar pattern Xo
1.17      christos 1009: .No \&/ Ar replacement
1.89      sjg      1010: .No \&/ Op Cm 1gW
1.17      christos 1011: .Xc
                   1012: .Sm on
                   1013: The
1.91      lukem    1014: .Cm \&:C
1.17      christos 1015: modifier is just like the
1.91      lukem    1016: .Cm \&:S
1.37      msaitoh  1017: modifier except that the old and new strings, instead of being
1.17      christos 1018: simple strings, are a regular expression (see
                   1019: .Xr regex 3 )
1.72      uebayasi 1020: string
                   1021: .Ar pattern
1.17      christos 1022: and an
                   1023: .Xr ed 1 Ns \-style
1.72      uebayasi 1024: string
                   1025: .Ar replacement .
                   1026: Normally, the first occurrence of the pattern
                   1027: .Ar pattern
                   1028: in each word of the value is substituted with
                   1029: .Ar replacement .
1.67      grant    1030: The
1.17      christos 1031: .Ql 1
                   1032: modifier causes the substitution to apply to at most one word; the
                   1033: .Ql g
                   1034: modifier causes the substitution to apply to as many instances of the
1.72      uebayasi 1035: search pattern
                   1036: .Ar pattern
1.89      sjg      1037: as occur in the word or words it is found in; the
                   1038: .Ql W
                   1039: modifier causes the value to be treated as a single word
                   1040: (possibly containing embedded white space).
1.67      grant    1041: Note that
1.17      christos 1042: .Ql 1
                   1043: and
                   1044: .Ql g
                   1045: are orthogonal; the former specifies whether multiple words are
                   1046: potentially affected, the latter whether multiple substitutions can
                   1047: potentially occur within each affected word.
1.91      lukem    1048: .It Cm \&:T
1.1       cgd      1049: Replaces each word in the variable with its last component.
1.91      lukem    1050: .It Cm \&:u
1.43      christos 1051: Remove adjacent duplicate words (like
1.57      wiz      1052: .Xr uniq 1 ) .
1.91      lukem    1053: .Sm off
                   1054: .It Cm \&:\&? Ar true_string Cm \&: Ar false_string
                   1055: .Sm on
1.152     dsl      1056: If the variable name (not its value), when parsed as a .if conditional
                   1057: expression, evaluates to true, return as its value the
1.57      wiz      1058: .Ar true_string ,
1.27      christos 1059: otherwise return the
1.57      wiz      1060: .Ar false_string .
1.152     dsl      1061: Since the variable name is used as the expression, \&:\&? must be the
                   1062: first modifier after the variable name itself - which will, of course,
                   1063: usually contain variable expansions.
                   1064: If the expression is a single token, it will likely be treated as a check
                   1065: for the name being defined.
1.91      lukem    1066: .It Ar :old_string=new_string
1.1       cgd      1067: This is the
                   1068: .At V
                   1069: style variable substitution.
                   1070: It must be the last modifier specified.
1.16      christos 1071: If
1.6       cgd      1072: .Ar old_string
                   1073: or
                   1074: .Ar new_string
                   1075: do not contain the pattern matching character
                   1076: .Ar %
1.16      christos 1077: then it is assumed that they are
1.6       cgd      1078: anchored at the end of each word, so only suffixes or entire
1.67      grant    1079: words may be replaced.
                   1080: Otherwise
1.6       cgd      1081: .Ar %
1.16      christos 1082: is the substring of
                   1083: .Ar old_string
1.6       cgd      1084: to be replaced in
1.64      wiz      1085: .Ar new_string .
1.95      jmc      1086: .Pp
                   1087: Variable expansion occurs in the normal fashion inside both
                   1088: .Ar old_string
                   1089: and
                   1090: .Ar new_string
1.96      wiz      1091: with the single exception that a backslash is used to prevent the
                   1092: expansion of a dollar sign
                   1093: .Pq Ql \&$ ,
                   1094: not a preceding dollar sign as is usual.
1.91      lukem    1095: .Sm off
                   1096: .It Cm \&:@ Ar temp Cm @ Xo
1.80      wiz      1097: .Ar string Cm @
1.91      lukem    1098: .Sm on
1.40      sjg      1099: .Xc
                   1100: This is the loop expansion mechanism from the OSF Development
1.67      grant    1101: Environment (ODE) make.
                   1102: Unlike
1.48      wiz      1103: .Cm \&.for
1.40      sjg      1104: loops expansion occurs at the time of
1.67      grant    1105: reference.
                   1106: Assign
1.40      sjg      1107: .Ar temp
                   1108: to each word in the variable and evaluate
                   1109: .Ar string .
1.48      wiz      1110: The ODE convention is that
1.40      sjg      1111: .Ar temp
1.67      grant    1112: should start and end with a period.
                   1113: For example.
1.40      sjg      1114: .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1.91      lukem    1115: .It Cm \&:U Ns Ar newval
1.40      sjg      1116: If the variable is undefined
                   1117: .Ar newval
1.63      lukem    1118: is the value.
                   1119: If the variable is defined, the existing value is returned.
1.67      grant    1120: This is another ODE make feature.
                   1121: It is handy for setting per-target CFLAGS for instance:
1.40      sjg      1122: .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1.63      lukem    1123: If a value is only required if the variable is undefined, use:
                   1124: .Dl ${VAR:D:Unewval}
1.91      lukem    1125: .It Cm \&:D Ns Ar newval
1.40      sjg      1126: If the variable is defined
                   1127: .Ar newval
                   1128: is the value.
1.91      lukem    1129: .It Cm \&:L
1.40      sjg      1130: The name of the variable is the value.
1.91      lukem    1131: .It Cm \&:P
1.40      sjg      1132: The path of the node which has the same name as the variable
1.67      grant    1133: is the value.
                   1134: If no such node exists or its path is null, then the
1.40      sjg      1135: name of the variable is used.
1.91      lukem    1136: .Sm off
                   1137: .It Cm \&:\&! Ar cmd Cm \&!
                   1138: .Sm on
1.40      sjg      1139: The output of running
                   1140: .Ar cmd
                   1141: is the value.
1.91      lukem    1142: .It Cm \&:sh
1.40      sjg      1143: If the variable is non-empty it is run as a command and the output
                   1144: becomes the new value.
1.91      lukem    1145: .It Cm \&::= Ns Ar str
1.48      wiz      1146: The variable is assigned the value
1.41      sjg      1147: .Ar str
1.67      grant    1148: after substitution.
                   1149: This modifier and its variations are useful in
1.149     dsl      1150: obscure situations such as wanting to set a variable when shell commands
                   1151: are being parsed.
1.67      grant    1152: These assignment modifiers always expand to
1.41      sjg      1153: nothing, so if appearing in a rule line by themselves should be
1.48      wiz      1154: preceded with something to keep
1.41      sjg      1155: .Nm
1.67      grant    1156: happy.
1.149     dsl      1157: .Pp
1.91      lukem    1158: The
                   1159: .Ql Cm \&::
1.42      sjg      1160: helps avoid false matches with the
                   1161: .At V
1.48      wiz      1162: style
1.91      lukem    1163: .Cm \&:=
1.48      wiz      1164: modifier and since substitution always occurs the
1.91      lukem    1165: .Cm \&::=
1.42      sjg      1166: form is vaguely appropriate.
1.91      lukem    1167: .It Cm \&::?= Ns Ar str
1.41      sjg      1168: As for
1.91      lukem    1169: .Cm \&::=
1.41      sjg      1170: but only if the variable does not already have a value.
1.91      lukem    1171: .It Cm \&::+= Ns Ar str
1.48      wiz      1172: Append
1.41      sjg      1173: .Ar str
                   1174: to the variable.
1.91      lukem    1175: .It Cm \&::!= Ns Ar cmd
1.48      wiz      1176: Assign the output of
1.41      sjg      1177: .Ar cmd
                   1178: to the variable.
1.91      lukem    1179: .It Cm \&:\&[ Ns Ar range Ns Cm \&]
1.89      sjg      1180: Selects one or more words from the value,
                   1181: or performs other operations related to the way in which the
                   1182: value is divided into words.
                   1183: .Pp
                   1184: Ordinarily, a value is treated as a sequence of words
                   1185: delimited by white space.
                   1186: Some modifiers suppress this behaviour,
                   1187: causing a value to be treated as a single word
                   1188: (possibly containing embedded white space).
                   1189: An empty value, or a value that consists entirely of white-space,
                   1190: is treated as a single word.
                   1191: For the purposes of the
1.91      lukem    1192: .Ql Cm \&:[]
1.89      sjg      1193: modifier, the words are indexed both forwards using positive integers
                   1194: (where index 1 represents the first word),
                   1195: and backwards using negative integers
                   1196: (where index -1 represents the last word).
                   1197: .Pp
                   1198: The
                   1199: .Ar range
                   1200: is subjected to variable expansion, and the expanded result is
                   1201: then interpreted as follows:
                   1202: .Bl -tag -width index
1.90      jdolecek 1203: .\" :[n]
1.89      sjg      1204: .It Ar index
                   1205: Selects a single word from the value.
1.90      jdolecek 1206: .\" :[start..end]
1.89      sjg      1207: .It Ar start Ns Cm \&.. Ns Ar end
                   1208: Selects all words from
                   1209: .Ar start
                   1210: to
                   1211: .Ar end ,
                   1212: inclusive.
                   1213: For example,
1.91      lukem    1214: .Ql Cm \&:[2..-1]
1.89      sjg      1215: selects all words from the second word to the last word.
                   1216: If
                   1217: .Ar start
                   1218: is greater than
                   1219: .Ar end ,
1.91      lukem    1220: then the words are output in reverse order.
                   1221: For example,
                   1222: .Ql Cm \&:[-1..1]
1.89      sjg      1223: selects all the words from last to first.
1.90      jdolecek 1224: .\" :[*]
1.89      sjg      1225: .It Cm \&*
                   1226: Causes subsequent modifiers to treat the value as a single word
1.109     wiz      1227: (possibly containing embedded white space).
                   1228: Analogous to the effect of
1.94      wiz      1229: \&"$*\&"
1.89      sjg      1230: in Bourne shell.
1.90      jdolecek 1231: .\" :[0]
1.89      sjg      1232: .It 0
                   1233: Means the same as
1.91      lukem    1234: .Ql Cm \&:[*] .
1.90      jdolecek 1235: .\" :[*]
1.89      sjg      1236: .It Cm \&@
                   1237: Causes subsequent modifiers to treat the value as a sequence of words
1.109     wiz      1238: delimited by white space.
                   1239: Analogous to the effect of
1.94      wiz      1240: \&"$@\&"
1.89      sjg      1241: in Bourne shell.
1.90      jdolecek 1242: .\" :[#]
1.89      sjg      1243: .It Cm \&#
                   1244: Returns the number of words in the value.
                   1245: .El \" :[range]
1.6       cgd      1246: .El
                   1247: .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1.16      christos 1248: Makefile inclusion, conditional structures and for loops  reminiscent
1.6       cgd      1249: of the C programming language are provided in
1.74      wiz      1250: .Nm .
1.1       cgd      1251: All such structures are identified by a line beginning with a single
                   1252: dot
                   1253: .Pq Ql \&.
                   1254: character.
                   1255: Files are included with either
1.29      ross     1256: .Cm \&.include Aq Ar file
1.1       cgd      1257: or
1.29      ross     1258: .Cm \&.include Pf \*q Ar file Ns \*q .
1.1       cgd      1259: Variables between the angle brackets or double quotes are expanded
                   1260: to form the file name.
                   1261: If angle brackets are used, the included makefile is expected to be in
                   1262: the system makefile directory.
                   1263: If double quotes are used, the including makefile's directory and any
                   1264: directories specified using the
                   1265: .Fl I
                   1266: option are searched before the system
                   1267: makefile directory.
1.28      christos 1268: For compatibility with other versions of
                   1269: .Nm
                   1270: .Ql include file ...
1.67      grant    1271: is also accepted.
                   1272: If the include statement is written as
1.29      ross     1273: .Cm .-include
                   1274: or as
                   1275: .Cm .sinclude
1.28      christos 1276: then errors locating and/or opening include files are ignored.
1.1       cgd      1277: .Pp
                   1278: Conditional expressions are also preceded by a single dot as the first
1.5       jtc      1279: character of a line.
1.1       cgd      1280: The possible conditionals are as follows:
                   1281: .Bl -tag -width Ds
1.133     sjg      1282: .It Ic .export Ar variable
                   1283: Export the specified global variable.
                   1284: If no variable is provided, all globals are exported
                   1285: except for internal variables (those that start with
1.157     wiz      1286: .Ql \&. ) .
1.133     sjg      1287: This is not affected by the
                   1288: .Fl X
                   1289: flag, so should be used with caution.
                   1290: Appending a variable name to
                   1291: .Va .MAKE.EXPORTED
                   1292: is equivalent to exporting a variable.
1.1       cgd      1293: .It Ic .undef Ar variable
                   1294: Un-define the specified global variable.
                   1295: Only global variables may be un-defined.
                   1296: .It Xo
                   1297: .Ic \&.if
                   1298: .Oo \&! Oc Ns Ar expression
                   1299: .Op Ar operator expression ...
                   1300: .Xc
                   1301: Test the value of an expression.
                   1302: .It Xo
                   1303: .Ic .ifdef
                   1304: .Oo \&! Oc Ns Ar variable
                   1305: .Op Ar operator variable ...
                   1306: .Xc
1.7       mycroft  1307: Test the value of a variable.
1.1       cgd      1308: .It Xo
                   1309: .Ic .ifndef
                   1310: .Oo \&! Oc Ns Ar variable
                   1311: .Op Ar operator variable ...
                   1312: .Xc
1.7       mycroft  1313: Test the value of a variable.
1.1       cgd      1314: .It Xo
                   1315: .Ic .ifmake
                   1316: .Oo \&! Oc Ns Ar target
                   1317: .Op Ar operator target ...
                   1318: .Xc
1.7       mycroft  1319: Test the target being built.
1.1       cgd      1320: .It Xo
                   1321: .Ic .ifnmake
1.80      wiz      1322: .Oo \&! Ns Oc Ar target
1.1       cgd      1323: .Op Ar operator target ...
                   1324: .Xc
                   1325: Test the target being built.
                   1326: .It Ic .else
                   1327: Reverse the sense of the last conditional.
                   1328: .It Xo
                   1329: .Ic .elif
1.80      wiz      1330: .Oo \&! Ns Oc Ar expression
1.1       cgd      1331: .Op Ar operator expression ...
                   1332: .Xc
                   1333: A combination of
                   1334: .Ql Ic .else
                   1335: followed by
                   1336: .Ql Ic .if .
                   1337: .It Xo
                   1338: .Ic .elifdef
                   1339: .Oo \&! Oc Ns Ar variable
                   1340: .Op Ar operator variable ...
                   1341: .Xc
                   1342: A combination of
                   1343: .Ql Ic .else
                   1344: followed by
                   1345: .Ql Ic .ifdef .
                   1346: .It Xo
                   1347: .Ic .elifndef
                   1348: .Oo \&! Oc Ns Ar variable
                   1349: .Op Ar operator variable ...
                   1350: .Xc
                   1351: A combination of
                   1352: .Ql Ic .else
                   1353: followed by
                   1354: .Ql Ic .ifndef .
                   1355: .It Xo
                   1356: .Ic .elifmake
                   1357: .Oo \&! Oc Ns Ar target
                   1358: .Op Ar operator target ...
                   1359: .Xc
                   1360: A combination of
                   1361: .Ql Ic .else
                   1362: followed by
                   1363: .Ql Ic .ifmake .
                   1364: .It Xo
                   1365: .Ic .elifnmake
                   1366: .Oo \&! Oc Ns Ar target
                   1367: .Op Ar operator target ...
                   1368: .Xc
                   1369: A combination of
                   1370: .Ql Ic .else
                   1371: followed by
                   1372: .Ql Ic .ifnmake .
                   1373: .It Ic .endif
                   1374: End the body of the conditional.
                   1375: .El
                   1376: .Pp
                   1377: The
                   1378: .Ar operator
                   1379: may be any one of the following:
                   1380: .Bl -tag -width "Cm XX"
                   1381: .It Cm \&|\&|
1.64      wiz      1382: Logical OR.
1.62      ross     1383: .It Cm \&\*[Am]\*[Am]
1.1       cgd      1384: Logical
                   1385: .Tn AND ;
                   1386: of higher precedence than
1.26      hubertf  1387: .Dq \&|\&| .
1.1       cgd      1388: .El
                   1389: .Pp
                   1390: As in C,
1.25      lukem    1391: .Nm
1.1       cgd      1392: will only evaluate a conditional as far as is necessary to determine
                   1393: its value.
1.16      christos 1394: Parentheses may be used to change the order of evaluation.
1.1       cgd      1395: The boolean operator
                   1396: .Ql Ic \&!
                   1397: may be used to logically negate an entire
                   1398: conditional.
1.5       jtc      1399: It is of higher precedence than
1.62      ross     1400: .Ql Ic \&\*[Am]\*[Am] .
1.1       cgd      1401: .Pp
                   1402: The value of
                   1403: .Ar expression
                   1404: may be any of the following:
1.61      ross     1405: .Bl -tag -width defined
1.1       cgd      1406: .It Ic defined
                   1407: Takes a variable name as an argument and evaluates to true if the variable
                   1408: has been defined.
                   1409: .It Ic make
                   1410: Takes a target name as an argument and evaluates to true if the target
                   1411: was specified as part of
1.74      wiz      1412: .Nm Ns 's
1.1       cgd      1413: command line or was declared the default target (either implicitly or
                   1414: explicitly, see
                   1415: .Va .MAIN )
                   1416: before the line containing the conditional.
                   1417: .It Ic empty
1.5       jtc      1418: Takes a variable, with possible modifiers, and evaluates to true if
1.1       cgd      1419: the expansion of the variable would result in an empty string.
                   1420: .It Ic exists
                   1421: Takes a file name as an argument and evaluates to true if the file exists.
                   1422: The file is searched for on the system search path (see
                   1423: .Va .PATH ) .
                   1424: .It Ic target
                   1425: Takes a target name as an argument and evaluates to true if the target
                   1426: has been defined.
1.47      christos 1427: .It Ic commands
                   1428: Takes a target name as an argument and evaluates to true if the target
                   1429: has been defined and has commands associated with it.
1.1       cgd      1430: .El
                   1431: .Pp
                   1432: .Ar Expression
1.67      grant    1433: may also be an arithmetic or string comparison.
                   1434: Variable expansion is
1.6       cgd      1435: performed on both sides of the comparison, after which the integral
1.67      grant    1436: values are compared.
                   1437: A value is interpreted as hexadecimal if it is
1.6       cgd      1438: preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1.67      grant    1439: The standard C relational operators are all supported.
                   1440: If after
1.6       cgd      1441: variable expansion, either the left or right hand side of a
1.1       cgd      1442: .Ql Ic ==
                   1443: or
                   1444: .Ql Ic "!="
1.6       cgd      1445: operator is not an integral value, then
                   1446: string comparison is performed between the expanded
                   1447: variables.
1.1       cgd      1448: If no relational operator is given, it is assumed that the expanded
1.102     sjg      1449: variable is being compared against 0 or an empty string in the case
                   1450: of a string comparison.
1.1       cgd      1451: .Pp
                   1452: When
1.25      lukem    1453: .Nm
1.150     dsl      1454: is evaluating one of these conditional expressions, and it encounters
                   1455: a (white-space separated) word it doesn't recognize, either the
1.137     wiz      1456: .Dq make
                   1457: or
                   1458: .Dq defined
1.1       cgd      1459: expression is applied to it, depending on the form of the conditional.
                   1460: If the form is
1.150     dsl      1461: .Ql Ic .ifdef ,
                   1462: .Ql Ic .ifndef ,
1.1       cgd      1463: or
1.150     dsl      1464: .Ql Ic .if
1.137     wiz      1465: the
                   1466: .Dq defined
                   1467: expression is applied.
1.1       cgd      1468: Similarly, if the form is
                   1469: .Ql Ic .ifmake
                   1470: or
1.137     wiz      1471: .Ql Ic .ifnmake , the
                   1472: .Dq make
1.1       cgd      1473: expression is applied.
                   1474: .Pp
                   1475: If the conditional evaluates to true the parsing of the makefile continues
                   1476: as before.
                   1477: If it evaluates to false, the following lines are skipped.
                   1478: In both cases this continues until a
                   1479: .Ql Ic .else
                   1480: or
                   1481: .Ql Ic .endif
                   1482: is found.
1.16      christos 1483: .Pp
1.6       cgd      1484: For loops are typically used to apply a set of rules to a list of files.
                   1485: The syntax of a for loop is:
1.59      bgrayson 1486: .Pp
                   1487: .Bl -tag -compact -width Ds
1.6       cgd      1488: .It Xo
                   1489: .Ic \&.for
1.48      wiz      1490: .Ar variable
1.39      christos 1491: .Op Ar variable ...
1.16      christos 1492: .Ic in
1.6       cgd      1493: .Ar expression
                   1494: .Xc
1.80      wiz      1495: .It Aq make-rules
                   1496: .It Ic \&.endfor
1.6       cgd      1497: .El
1.59      bgrayson 1498: .Pp
1.6       cgd      1499: After the for
1.16      christos 1500: .Ic expression
1.67      grant    1501: is evaluated, it is split into words.
                   1502: On each iteration of the loop, one word is taken and assigned to each
1.39      christos 1503: .Ic variable ,
                   1504: in order, and these
                   1505: .Ic variables
                   1506: are substituted into the
1.16      christos 1507: .Ic make-rules
1.6       cgd      1508: inside the body of the for loop.
1.39      christos 1509: The number of words must come out even; that is, if there are three
                   1510: iteration variables, the number of words provided must be a multiple
                   1511: of three.
1.1       cgd      1512: .Sh COMMENTS
                   1513: Comments begin with a hash
                   1514: .Pq Ql \&#
                   1515: character, anywhere but in a shell
1.114     wiz      1516: command line, and continue to the end of an unescaped new line.
1.97      lukem    1517: .Sh SPECIAL SOURCES (ATTRIBUTES)
1.61      ross     1518: .Bl -tag -width .IGNOREx
1.97      lukem    1519: .It Ic .EXEC
                   1520: Target is never out of date, but always execute commands anyway.
1.1       cgd      1521: .It Ic .IGNORE
                   1522: Ignore any errors from the commands associated with this target, exactly
                   1523: as if they all were preceded by a dash
                   1524: .Pq Ql \- .
1.97      lukem    1525: .\" .It Ic .INVISIBLE
                   1526: .\" XXX
                   1527: .\" .It Ic .JOIN
                   1528: .\" XXX
1.18      christos 1529: .It Ic .MADE
1.48      wiz      1530: Mark all sources of this target as being up-to-date.
1.1       cgd      1531: .It Ic .MAKE
                   1532: Execute the commands associated with this target even if the
                   1533: .Fl n
                   1534: or
                   1535: .Fl t
                   1536: options were specified.
                   1537: Normally used to mark recursive
1.74      wiz      1538: .Nm Ns 's .
1.97      lukem    1539: .It Ic .NOPATH
                   1540: Do not search for the target in the directories specified by
                   1541: .Ic .PATH .
1.1       cgd      1542: .It Ic .NOTMAIN
                   1543: Normally
1.25      lukem    1544: .Nm
1.1       cgd      1545: selects the first target it encounters as the default target to be built
                   1546: if no target was specified.
                   1547: This source prevents this target from being selected.
                   1548: .It Ic .OPTIONAL
                   1549: If a target is marked with this attribute and
1.25      lukem    1550: .Nm
1.1       cgd      1551: can't figure out how to create it, it will ignore this fact and assume
                   1552: the file isn't needed or already exists.
1.97      lukem    1553: .It Ic .PHONY
                   1554: The target does not
                   1555: correspond to an actual file; it is always considered to be out of date,
                   1556: and will not be created with the
                   1557: .Fl t
                   1558: option.
1.1       cgd      1559: .It Ic .PRECIOUS
                   1560: When
1.25      lukem    1561: .Nm
1.131     rillig   1562: is interrupted, it normally removes any partially made targets.
1.1       cgd      1563: This source prevents the target from being removed.
1.97      lukem    1564: .It Ic .RECURSIVE
                   1565: Synonym for
                   1566: .Ic .MAKE .
1.1       cgd      1567: .It Ic .SILENT
                   1568: Do not echo any of the commands associated with this target, exactly
                   1569: as if they all were preceded by an at sign
                   1570: .Pq Ql @ .
                   1571: .It Ic .USE
                   1572: Turn the target into
1.74      wiz      1573: .Nm Ns 's
1.1       cgd      1574: version of a macro.
                   1575: When the target is used as a source for another target, the other target
                   1576: acquires the commands, sources, and attributes (except for
                   1577: .Ic .USE )
                   1578: of the
                   1579: source.
                   1580: If the target already has commands, the
                   1581: .Ic .USE
                   1582: target's commands are appended
                   1583: to them.
1.52      christos 1584: .It Ic .USEBEFORE
                   1585: Exactly like
                   1586: .Ic .USE ,
1.57      wiz      1587: but prepend the
1.52      christos 1588: .Ic .USEBEFORE
                   1589: target commands to the target.
1.12      christos 1590: .It Ic .WAIT
1.71      mjl      1591: If
1.12      christos 1592: .Ic .WAIT
1.71      mjl      1593: appears in a dependency line, the sources that precede it are
1.67      grant    1594: made before the sources that succeed it in the line.
1.128     dsl      1595: Since the dependents of files are not made until the file itself
                   1596: could be made, this also stops the dependents being built unless they
                   1597: are needed for another branch of the dependency tree.
                   1598: So given:
                   1599: .Bd -literal
                   1600: x: a .WAIT b
                   1601:        echo x
                   1602: a:
                   1603:        echo a
                   1604: b: b1
                   1605:        echo b
                   1606: b1:
                   1607:        echo b1
                   1608:
                   1609: .Ed
                   1610: the output is always
1.151     dholland 1611: .Ql a ,
1.128     dsl      1612: .Ql b1 ,
                   1613: .Ql b ,
                   1614: .Ql x .
                   1615: .br
1.122     apb      1616: The ordering imposed by
                   1617: .Ic .WAIT
1.128     dsl      1618: is only relevant for parallel makes.
1.1       cgd      1619: .El
1.57      wiz      1620: .Sh SPECIAL TARGETS
1.1       cgd      1621: Special targets may not be included with other targets, i.e. they must be
                   1622: the only target specified.
1.61      ross     1623: .Bl -tag -width .BEGINx
1.1       cgd      1624: .It Ic .BEGIN
                   1625: Any command lines attached to this target are executed before anything
                   1626: else is done.
                   1627: .It Ic .DEFAULT
                   1628: This is sort of a
                   1629: .Ic .USE
                   1630: rule for any target (that was used only as a
                   1631: source) that
1.25      lukem    1632: .Nm
1.1       cgd      1633: can't figure out any other way to create.
                   1634: Only the shell script is used.
                   1635: The
                   1636: .Ic .IMPSRC
                   1637: variable of a target that inherits
                   1638: .Ic .DEFAULT Ns 's
                   1639: commands is set
                   1640: to the target's own name.
                   1641: .It Ic .END
                   1642: Any command lines attached to this target are executed after everything
                   1643: else is done.
                   1644: .It Ic .IGNORE
                   1645: Mark each of the sources with the
                   1646: .Ic .IGNORE
                   1647: attribute.
                   1648: If no sources are specified, this is the equivalent of specifying the
                   1649: .Fl i
                   1650: option.
                   1651: .It Ic .INTERRUPT
                   1652: If
1.25      lukem    1653: .Nm
1.1       cgd      1654: is interrupted, the commands for this target will be executed.
                   1655: .It Ic .MAIN
                   1656: If no target is specified when
1.25      lukem    1657: .Nm
1.1       cgd      1658: is invoked, this target will be built.
                   1659: .It Ic .MAKEFLAGS
                   1660: This target provides a way to specify flags for
1.25      lukem    1661: .Nm
1.1       cgd      1662: when the makefile is used.
                   1663: The flags are as if typed to the shell, though the
                   1664: .Fl f
                   1665: option will have
                   1666: no effect.
1.12      christos 1667: .\" XXX: NOT YET!!!!
                   1668: .\" .It Ic .NOTPARALLEL
1.70      wiz      1669: .\" The named targets are executed in non parallel mode.
                   1670: .\" If no targets are
1.12      christos 1671: .\" specified, then all targets are executed in non parallel mode.
1.20      gwr      1672: .It Ic .NOPATH
                   1673: Apply the
                   1674: .Ic .NOPATH
1.67      grant    1675: attribute to any specified sources.
1.12      christos 1676: .It Ic .NOTPARALLEL
                   1677: Disable parallel mode.
                   1678: .It Ic .NO_PARALLEL
1.97      lukem    1679: Synonym for
                   1680: .Ic .NOTPARALLEL ,
                   1681: for compatibility with other pmake variants.
1.12      christos 1682: .It Ic .ORDER
                   1683: The named targets are made in sequence.
1.128     dsl      1684: This ordering does not add targets to the list of targets to be made.
                   1685: Since the dependents of a target do not get built until the target itself
                   1686: could be built, unless
                   1687: .Ql a
1.129     wiz      1688: is built by another part of the dependency graph,
1.128     dsl      1689: the following is a dependency loop:
                   1690: .Bd -literal
1.158     sjg      1691: \&.ORDER: a b
1.128     dsl      1692: b: a
                   1693: .Ed
1.129     wiz      1694: .Pp
1.122     apb      1695: The ordering imposed by
                   1696: .Ic .ORDER
1.128     dsl      1697: is only relevant for parallel makes.
1.12      christos 1698: .\" XXX: NOT YET!!!!
                   1699: .\" .It Ic .PARALLEL
1.70      wiz      1700: .\" The named targets are executed in parallel mode.
                   1701: .\" If no targets are
1.12      christos 1702: .\" specified, then all targets are executed in parallel mode.
1.1       cgd      1703: .It Ic .PATH
                   1704: The sources are directories which are to be searched for files not
                   1705: found in the current directory.
                   1706: If no sources are specified, any previously specified directories are
                   1707: deleted.
1.34      thorpej  1708: If the source is the special
                   1709: .Ic .DOTLAST
                   1710: target, then the current working
1.33      thorpej  1711: directory is searched last.
1.14      christos 1712: .It Ic .PHONY
                   1713: Apply the
                   1714: .Ic .PHONY
1.67      grant    1715: attribute to any specified sources.
1.1       cgd      1716: .It Ic .PRECIOUS
                   1717: Apply the
                   1718: .Ic .PRECIOUS
                   1719: attribute to any specified sources.
                   1720: If no sources are specified, the
                   1721: .Ic .PRECIOUS
                   1722: attribute is applied to every
                   1723: target in the file.
1.83      sjg      1724: .It Ic .SHELL
1.86      wiz      1725: Sets the shell that
1.83      sjg      1726: .Nm
1.86      wiz      1727: will use to execute commands.
                   1728: The sources are a set of
1.83      sjg      1729: .Ar field=value
1.86      wiz      1730: pairs.
1.83      sjg      1731: .Bl -tag -width hasErrCtls
                   1732: .It Ar name
                   1733: This is the minimal specification, used to select one of the builtin
                   1734: shell specs;
                   1735: .Ar sh ,
                   1736: .Ar ksh ,
                   1737: and
                   1738: .Ar csh .
                   1739: .It Ar path
                   1740: Specifies the path to the shell.
                   1741: .It Ar hasErrCtl
                   1742: Indicates whether the shell supports exit on error.
                   1743: .It Ar check
                   1744: The command to turn on error checking.
                   1745: .It Ar ignore
                   1746: The command to disable error checking.
                   1747: .It Ar echo
                   1748: The command to turn on echoing of commands executed.
                   1749: .It Ar quiet
                   1750: The command to turn off echoing of commands executed.
                   1751: .It Ar filter
                   1752: The output to filter after issuing the
                   1753: .Ar quiet
1.86      wiz      1754: command.
                   1755: It is typically identical to
1.83      sjg      1756: .Ar quiet .
                   1757: .It Ar errFlag
                   1758: The flag to pass the shell to enable error checking.
                   1759: .It Ar echoFlag
                   1760: The flag to pass the shell to enable command echoing.
1.127     rillig   1761: .It Ar newline
                   1762: The string literal to pass the shell that results in a single newline
                   1763: character when used outside of any quoting characters.
1.83      sjg      1764: .El
                   1765: Example:
                   1766: .Bd -literal
                   1767: \&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \\
                   1768:        check="set -e" ignore="set +e" \\
                   1769:        echo="set -v" quiet="set +v" filter="set +v" \\
1.127     rillig   1770:        echoFlag=v errFlag=e newline="'\\n'"
1.83      sjg      1771: .Ed
1.1       cgd      1772: .It Ic .SILENT
                   1773: Apply the
                   1774: .Ic .SILENT
                   1775: attribute to any specified sources.
                   1776: If no sources are specified, the
                   1777: .Ic .SILENT
                   1778: attribute is applied to every
                   1779: command in the file.
                   1780: .It Ic .SUFFIXES
                   1781: Each source specifies a suffix to
1.74      wiz      1782: .Nm .
1.71      mjl      1783: If no sources are specified, any previously specified suffixes are deleted.
1.136     cube     1784: It allows the creation of suffix-transformation rules.
                   1785: .Pp
                   1786: Example:
                   1787: .Bd -literal
                   1788: \&.SUFFIXES: .o
                   1789: \&.c.o:
                   1790:        cc -o ${.TARGET} -c ${.IMPSRC}
                   1791: .Ed
1.31      ross     1792: .El
1.1       cgd      1793: .Sh ENVIRONMENT
1.25      lukem    1794: .Nm
1.73      perry    1795: uses the following environment variables, if they exist:
1.16      christos 1796: .Ev MACHINE ,
1.26      hubertf  1797: .Ev MACHINE_ARCH ,
1.1       cgd      1798: .Ev MAKE ,
1.16      christos 1799: .Ev MAKEFLAGS ,
                   1800: .Ev MAKEOBJDIR ,
1.38      sjg      1801: .Ev MAKEOBJDIRPREFIX ,
1.76      jrf      1802: .Ev MAKESYSPATH ,
1.154     apb      1803: .Ev PWD ,
1.1       cgd      1804: and
1.154     apb      1805: .Ev TMPDIR .
1.57      wiz      1806: .Pp
1.38      sjg      1807: .Ev MAKEOBJDIRPREFIX
1.117     lukem    1808: and
1.38      sjg      1809: .Ev MAKEOBJDIR
1.117     lukem    1810: may only be set in the environment or on the command line to
1.38      sjg      1811: .Nm
1.117     lukem    1812: and not as makefile variables;
                   1813: see the description of
                   1814: .Ql Va .OBJDIR
                   1815: for more details.
1.1       cgd      1816: .Sh FILES
                   1817: .Bl -tag -width /usr/share/mk -compact
                   1818: .It .depend
                   1819: list of dependencies
                   1820: .It Makefile
                   1821: list of dependencies
                   1822: .It makefile
                   1823: list of dependencies
                   1824: .It sys.mk
                   1825: system makefile
                   1826: .It /usr/share/mk
                   1827: system makefile directory
                   1828: .El
1.128     dsl      1829: .Sh COMPATIBILITY
                   1830: The basic make syntax is compatible between different versions of make,
                   1831: however the special variables, variable modifiers and conditionals are not.
                   1832: .Pp
1.129     wiz      1833: The way that parallel makes are scheduled changed in
1.130     wiz      1834: .Nx 4.0
1.129     wiz      1835: so that .ORDER and .WAIT apply recursively to the dependant nodes.
1.128     dsl      1836: The algorithms used may change again in the future.
1.152     dsl      1837: .Pp
                   1838: The way that .for loop variables are substituted changed after
                   1839: .Nx 5.0
                   1840: so that they still appear to be variable expansions.
                   1841: In particular this stops them being treated as syntax, and removes some
                   1842: obscure problems using them in .if statements.
1.153     wiz      1843: .Sh SEE ALSO
                   1844: .Xr mkdep 1
                   1845: .Sh HISTORY
                   1846: A
                   1847: .Nm
                   1848: command appeared in
                   1849: .At v7 .
1.152     dsl      1850: .Sh BUGS
                   1851: The
                   1852: .Nm
                   1853: syntax is difficult to parse without actually acting of the data.
                   1854: For instance finding the end of a variable use should involve scanning each
                   1855: the modifiers using the correct terminator for each field.
                   1856: In many places
                   1857: .Nm
                   1858: just counts {} and () in order to find the end of a variable expansion.
                   1859: .Pp
1.153     wiz      1860: There is no way of escaping a space character in a filename.

CVSweb <webmaster@jp.NetBSD.org>