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

1.90    ! jdolecek    1: .\"    $NetBSD: make.1,v 1.89 2003/09/27 21:29:37 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.87      jmmv       32: .Dd September 10, 2003
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.1       cgd        42: .Op Fl D Ar variable
1.30      mycroft    43: .Ek
                     44: .Bk -words
1.1       cgd        45: .Op Fl d Ar flags
1.30      mycroft    46: .Ek
                     47: .Bk -words
1.1       cgd        48: .Op Fl f Ar makefile
1.30      mycroft    49: .Ek
                     50: .Bk -words
1.1       cgd        51: .Op Fl I Ar directory
1.30      mycroft    52: .Ek
1.1       cgd        53: .Bk -words
                     54: .Op Fl j Ar max_jobs
1.30      mycroft    55: .Ek
                     56: .Bk -words
1.44      sommerfe   57: .Op Fl J Ar private
                     58: .Ek
                     59: .Bk -words
1.13      christos   60: .Op Fl m Ar directory
1.1       cgd        61: .Ek
1.30      mycroft    62: .Bk -words
1.44      sommerfe   63: .Op Fl T Ar file
                     64: .Ek
                     65: .Bk -words
1.16      christos   66: .Op Fl V Ar variable
1.30      mycroft    67: .Ek
1.1       cgd        68: .Op Ar variable=value
1.30      mycroft    69: .Bk -words
1.1       cgd        70: .Op Ar target ...
1.30      mycroft    71: .Ek
1.1       cgd        72: .Sh DESCRIPTION
1.25      lukem      73: .Nm
1.1       cgd        74: is a program designed to simplify the maintenance of other programs.
                     75: Its input is a list of specifications as to the files upon which programs
                     76: and other files depend.
                     77: If the file
                     78: .Ql Pa makefile
                     79: exists, it is read for this list of specifications.
                     80: If it does not exist, the file
                     81: .Ql Pa Makefile
                     82: is read.
                     83: If the file
                     84: .Ql Pa .depend
                     85: exists, it is read (see
1.66      wiz        86: .Xr mkdep 1 ) .
1.1       cgd        87: .Pp
                     88: This manual page is intended as a reference document only.
                     89: For a more thorough description of
1.25      lukem      90: .Nm
1.1       cgd        91: and makefiles, please refer to
                     92: .%T "Make \- A Tutorial" .
                     93: .Pp
                     94: The options are as follows:
                     95: .Bl -tag -width Ds
1.16      christos   96: .It Fl B
1.10      christos   97: Try to be backwards compatible by executing a single shell per command and
                     98: by executing the commands to make the sources of a dependency line in sequence.
1.1       cgd        99: .It Fl D Ar variable
1.8       christos  100: Define
                    101: .Ar variable
1.1       cgd       102: to be 1, in the global context.
                    103: .It Fl d Ar flags
                    104: Turn on debugging, and specify which portions of
1.25      lukem     105: .Nm
1.1       cgd       106: are to print debugging information.
                    107: .Ar Flags
                    108: is one or more of the following:
                    109: .Bl -tag -width Ds
                    110: .It Ar A
                    111: Print all possible debugging information;
                    112: equivalent to specifying all of the debugging flags.
                    113: .It Ar a
                    114: Print debugging information about archive searching and caching.
                    115: .It Ar c
                    116: Print debugging information about conditional evaluation.
                    117: .It Ar d
                    118: Print debugging information about directory searching and caching.
1.88      jmmv      119: .It Ar e
                    120: Print debugging information about failed commands and targets.
1.87      jmmv      121: .It Ar f
                    122: Print debugging information about loop evaluation.
1.1       cgd       123: .It Ar "g1"
                    124: Print the input graph before making anything.
                    125: .It Ar "g2"
                    126: Print the input graph after making everything, or before exiting
                    127: on error.
                    128: .It Ar j
                    129: Print debugging information about running multiple shells.
                    130: .It Ar m
                    131: Print debugging information about making targets, including modification
                    132: dates.
                    133: .It Ar s
                    134: Print debugging information about suffix-transformation rules.
                    135: .It Ar t
                    136: Print debugging information about target list maintenance.
                    137: .It Ar v
                    138: Print debugging information about variable assignment.
1.49      sjg       139: .It Ar x
1.57      wiz       140: Run shell commands with
                    141: .Fl x
                    142: so the actual commands are printed as they are executed.
1.1       cgd       143: .El
                    144: .It Fl e
1.68      perry     145: Specify that environment variables override macro assignments within
1.1       cgd       146: makefiles.
                    147: .It Fl f Ar makefile
                    148: Specify a makefile to read instead of the default
                    149: .Ql Pa makefile
                    150: and
                    151: If
                    152: .Ar makefile
                    153: is
                    154: .Ql Fl ,
                    155: standard input is read.
                    156: Multiple makefile's may be specified, and are read in the order specified.
                    157: .It Fl I Ar directory
                    158: Specify a directory in which to search for makefiles and included makefiles.
1.13      christos  159: The system makefile directory (or directories, see the
                    160: .Fl m
                    161: option) is automatically included as part of this list.
1.1       cgd       162: .It Fl i
                    163: Ignore non-zero exit of shell commands in the makefile.
                    164: Equivalent to specifying
                    165: .Ql Fl
                    166: before each command line in the makefile.
1.44      sommerfe  167: .It Fl J Ar private
                    168: This option should
                    169: .Em not
                    170: be specified by the user.
                    171: .Pp
                    172: When the
                    173: .Ar j
                    174: option is in use in a recursive build, this option is passed by a make
                    175: to child makes to allow all the make processes in the build to
                    176: cooperate to avoid overloading the system.
1.1       cgd       177: .It Fl j Ar max_jobs
                    178: Specify the maximum number of jobs that
1.25      lukem     179: .Nm
1.67      grant     180: may have running at any one time.
                    181: Turns compatibility mode off, unless the
1.11      christos  182: .Ar B
                    183: flag is also specified.
1.1       cgd       184: .It Fl k
                    185: Continue processing after errors are encountered, but only on those targets
                    186: that do not depend on the target whose creation caused the error.
1.13      christos  187: .It Fl m Ar directory
                    188: Specify a directory in which to search for sys.mk and makefiles included
1.67      grant     189: via the \*[Lt]...\*[Gt] style.
                    190: Multiple directories can be added to form a search path.
1.13      christos  191: This path will override the default system include path: /usr/share/mk.
                    192: Furthermore the system include path will be appended to the search path used
                    193: for "..."-style inclusions (see the
                    194: .Fl I
                    195: option).
1.1       cgd       196: .It Fl n
1.45      sommerfe  197: Display the commands that would have been executed, but do not
                    198: actually execute them unless the target depends on the .MAKE special
1.64      wiz       199: source (see below).
1.45      sommerfe  200: .It Fl N
                    201: Display the commands which would have been executed, but do not
                    202: actually execute any of them; useful for debugging top-level makefiles
                    203: without descending into subdirectories.
1.1       cgd       204: .It Fl q
                    205: Do not execute any commands, but exit 0 if the specified targets are
                    206: up-to-date and 1, otherwise.
                    207: .It Fl r
                    208: Do not use the built-in rules specified in the system makefile.
                    209: .It Fl s
                    210: Do not echo any commands as they are executed.
                    211: Equivalent to specifying
                    212: .Ql Ic @
                    213: before each command line in the makefile.
1.44      sommerfe  214: .It Fl T Ar tracefile
                    215: When used with the
1.48      wiz       216: .Fl j
1.44      sommerfe  217: flag,
                    218: append a trace record to
                    219: .Ar tracefile
                    220: for each job started and completed.
1.1       cgd       221: .It Fl t
                    222: Rather than re-building a target as specified in the makefile, create it
                    223: or update its modification time to make it appear up-to-date.
1.16      christos  224: .It Fl V Ar variable
                    225: Print
1.74      wiz       226: .Nm Ns 's
1.16      christos  227: idea of the value of
                    228: .Ar variable ,
                    229: in the global context.
                    230: Do not build any targets.
                    231: Multiple instances of this option may be specified;
                    232: the variables will be printed one per line,
                    233: with a blank line for each null or undefined variable.
1.85      sjg       234: If
                    235: .Ar variable
                    236: contains a
                    237: .Ql \&$
                    238: then the value will be expanded before printing.
1.46      christos  239: .It Fl W
                    240: Treat any warnings during makefile parsing as errors.
1.75      thorpej   241: .It Fl X
                    242: Don't export variables passed on the command line to the environment
                    243: individually.
                    244: Variables passed on the command line are still exported
                    245: via the
                    246: .Va MAKEFLAGS
                    247: environment variable.
                    248: This option may be useful on systems which have a small limit on the
                    249: size of command arguments.
1.1       cgd       250: .It Ar variable=value
                    251: Set the value of the variable
                    252: .Ar variable
                    253: to
                    254: .Ar value .
1.75      thorpej   255: Normally, all values passed on the command line are also exported to
                    256: sub-makes in the environment.
                    257: The
                    258: .Fl X
                    259: flag disables this behavior.
1.1       cgd       260: .El
                    261: .Pp
1.6       cgd       262: There are seven different types of lines in a makefile: file dependency
1.1       cgd       263: specifications, shell commands, variable assignments, include statements,
1.6       cgd       264: conditional directives, for loops, and comments.
1.1       cgd       265: .Pp
                    266: In general, lines may be continued from one line to the next by ending
                    267: them with a backslash
                    268: .Pq Ql \e .
                    269: The trailing newline character and initial whitespace on the following
                    270: line are compressed into a single space.
                    271: .Sh FILE DEPENDENCY SPECIFICATIONS
                    272: Dependency lines consist of one or more targets, an operator, and zero
                    273: or more sources.
                    274: This creates a relationship where the targets ``depend'' on the sources
                    275: and are usually created from them.
                    276: The exact relationship between the target and the source is determined
                    277: by the operator that separates them.
                    278: The three operators are as follows:
                    279: .Bl -tag -width flag
                    280: .It Ic \&:
                    281: A target is considered out-of-date if its modification time is less than
                    282: those of any of its sources.
                    283: Sources for a target accumulate over dependency lines when this operator
                    284: is used.
                    285: The target is removed if
1.25      lukem     286: .Nm
1.1       cgd       287: is interrupted.
                    288: .It Ic \&!
                    289: Targets are always re-created, but not until all sources have been
                    290: examined and re-created as necessary.
                    291: Sources for a target accumulate over dependency lines when this operator
                    292: is used.
                    293: The target is removed if
1.25      lukem     294: .Nm
1.1       cgd       295: is interrupted.
                    296: .It Ic \&::
                    297: If no sources are specified, the target is always re-created.
                    298: Otherwise, a target is considered out-of-date if any of its sources has
                    299: been modified more recently than the target.
                    300: Sources for a target do not accumulate over dependency lines when this
                    301: operator is used.
                    302: The target will not be removed if
1.25      lukem     303: .Nm
1.1       cgd       304: is interrupted.
                    305: .El
                    306: .Pp
                    307: Targets and sources may contain the shell wildcard values
1.80      wiz       308: .Ql \&? ,
1.1       cgd       309: .Ql * ,
                    310: .Ql []
                    311: and
                    312: .Ql {} .
                    313: The values
1.80      wiz       314: .Ql \&? ,
1.1       cgd       315: .Ql *
                    316: and
                    317: .Ql []
                    318: may only be used as part of the final
                    319: component of the target or source, and must be used to describe existing
                    320: files.
                    321: The value
                    322: .Ql {}
                    323: need not necessarily be used to describe existing files.
                    324: Expansion is in directory order, not alphabetically as done in the shell.
                    325: .Sh SHELL COMMANDS
                    326: Each target may have associated with it a series of shell commands, normally
                    327: used to create the target.
                    328: Each of the commands in this script
                    329: .Em must
                    330: be preceded by a tab.
                    331: While any target may appear on a dependency line, only one of these
                    332: dependencies may be followed by a creation script, unless the
                    333: .Ql Ic ::
                    334: operator is used.
                    335: .Pp
                    336: If the first or first two characters of the command line are
                    337: .Ql Ic @
                    338: and/or
                    339: .Ql Ic \- ,
                    340: the command is treated specially.
                    341: A
                    342: .Ql Ic @
                    343: causes the command not to be echoed before it is executed.
                    344: A
                    345: .Ql Ic \-
                    346: causes any non-zero exit status of the command line to be ignored.
                    347: .Sh VARIABLE ASSIGNMENTS
                    348: Variables in make are much like variables in the shell, and, by tradition,
                    349: consist of all upper-case letters.
                    350: The five operators that can be used to assign values to variables are as
                    351: follows:
                    352: .Bl -tag -width Ds
                    353: .It Ic \&=
                    354: Assign the value to the variable.
                    355: Any previous value is overridden.
                    356: .It Ic \&+=
                    357: Append the value to the current value of the variable.
                    358: .It Ic \&?=
                    359: Assign the value to the variable if it is not already defined.
                    360: .It Ic \&:=
                    361: Assign with expansion, i.e. expand the value before assigning it
                    362: to the variable.
                    363: Normally, expansion is not done until the variable is referenced.
                    364: .It Ic \&!=
                    365: Expand the value and pass it to the shell for execution and assign
                    366: the result to the variable.
                    367: Any newlines in the result are replaced with spaces.
                    368: .El
                    369: .Pp
                    370: Any white-space before the assigned
                    371: .Ar value
                    372: is removed; if the value is being appended, a single space is inserted
                    373: between the previous contents of the variable and the appended value.
                    374: .Pp
                    375: Variables are expanded by surrounding the variable name with either
                    376: curly braces
                    377: .Pq Ql {}
1.7       mycroft   378: or parentheses
1.1       cgd       379: .Pq Ql ()
                    380: and preceding it with
                    381: a dollar sign
                    382: .Pq Ql \&$ .
                    383: If the variable name contains only a single letter, the surrounding
1.7       mycroft   384: braces or parentheses are not required.
1.1       cgd       385: This shorter form is not recommended.
                    386: .Pp
                    387: Variable substitution occurs at two distinct times, depending on where
                    388: the variable is being used.
                    389: Variables in dependency lines are expanded as the line is read.
                    390: Variables in shell commands are expanded when the shell command is
                    391: executed.
                    392: .Pp
                    393: The four different classes of variables (in order of increasing precedence)
                    394: are:
                    395: .Bl -tag -width Ds
                    396: .It Environment variables
                    397: Variables defined as part of
1.74      wiz       398: .Nm Ns 's
1.1       cgd       399: environment.
                    400: .It Global variables
                    401: Variables defined in the makefile or in included makefiles.
                    402: .It Command line variables
                    403: Variables defined as part of the command line.
                    404: .It Local variables
                    405: Variables that are defined specific to a certain target.
                    406: The seven local variables are as follows:
                    407: .Bl -tag -width ".ARCHIVE"
                    408: .It Va .ALLSRC
                    409: The list of all sources for this target; also known as
1.62      ross      410: .Ql Va \&\*[Gt] .
1.1       cgd       411: .It Va .ARCHIVE
                    412: The name of the archive file.
                    413: .It Va .IMPSRC
                    414: The name/path of the source from which the target is to be transformed
                    415: (the ``implied'' source); also known as
1.62      ross      416: .Ql Va \&\*[Lt] .
1.1       cgd       417: .It Va .MEMBER
                    418: The name of the archive member.
                    419: .It Va .OODATE
                    420: The list of sources for this target that were deemed out-of-date; also
                    421: known as
                    422: .Ql Va \&? .
                    423: .It Va .PREFIX
                    424: The file prefix of the file, containing only the file portion, no suffix
                    425: or preceding directory components; also known as
                    426: .Ql Va * .
                    427: .It Va .TARGET
                    428: The name of the target; also known as
                    429: .Ql Va @ .
                    430: .El
                    431: .Pp
                    432: The shorter forms
                    433: .Ql Va @ ,
1.80      wiz       434: .Ql Va \&? ,
1.65      christos  435: .Ql Va \&\*[Lt] ,
                    436: .Ql Va \&\*[Gt] ,
1.1       cgd       437: and
                    438: .Ql Va *
                    439: are permitted for backward
                    440: compatibility with historical makefiles and are not recommended.
                    441: The six variables
                    442: .Ql Va "@F" ,
                    443: .Ql Va "@D" ,
1.62      ross      444: .Ql Va "\*[Lt]F" ,
                    445: .Ql Va "\*[Lt]D" ,
1.66      wiz       446: .Ql Va "*F" ,
1.1       cgd       447: and
                    448: .Ql Va "*D"
1.66      wiz       449: are permitted for compatibility with
1.1       cgd       450: .At V
                    451: makefiles and are not recommended.
                    452: .Pp
                    453: Four of the local variables may be used in sources on dependency lines
                    454: because they expand to the proper value for each target on the line.
                    455: These variables are
                    456: .Ql Va .TARGET ,
                    457: .Ql Va .PREFIX ,
                    458: .Ql Va .ARCHIVE ,
                    459: and
                    460: .Ql Va .MEMBER .
1.59      bgrayson  461: .El
1.1       cgd       462: .Pp
                    463: In addition,
1.25      lukem     464: .Nm
1.1       cgd       465: sets or knows about the following variables:
1.50      sjg       466: .Bl -tag -width .MAKEOVERRIDES
1.1       cgd       467: .It Va \&$
                    468: A single dollar sign
                    469: .Ql \&$ ,
                    470: i.e.
                    471: .Ql \&$$
                    472: expands to a single dollar
                    473: sign.
1.56      tv        474: .It Va .ALLTARGETS
1.67      grant     475: The list of all targets encountered in the Makefile.
                    476: If evaluated during
1.56      tv        477: Makefile parsing, lists only those targets encountered thus far.
1.1       cgd       478: .It Va .CURDIR
                    479: A path to the directory where
1.25      lukem     480: .Nm
1.1       cgd       481: was executed.
1.78      christos  482: .It Ev MAKE
1.55      tv        483: The name that
                    484: .Nm
1.89      sjg       485: was executed with
                    486: .Pq Va argv[0] .
1.79      wiz       487: For compatibily
1.78      christos  488: .Nm
                    489: also sets
                    490: .Va .MAKE
                    491: with the same value.
                    492: The preferred variable to use is
                    493: .Ev MAKE
                    494: because it is more compatible with other versions of
                    495: .Nm
                    496: and cannot be confused with the special target with the same name.
1.1       cgd       497: .It Ev MAKEFLAGS
                    498: The environment variable
                    499: .Ql Ev MAKEFLAGS
                    500: may contain anything that
                    501: may be specified on
1.74      wiz       502: .Nm Ns 's
1.1       cgd       503: command line.
                    504: Anything specified on
1.74      wiz       505: .Nm Ns 's
1.1       cgd       506: command line is appended to the
                    507: .Ql Ev MAKEFLAGS
                    508: variable which is then
                    509: entered into the environment for all programs which
1.25      lukem     510: .Nm
1.1       cgd       511: executes.
1.50      sjg       512: .It Va .MAKEOVERRIDES
1.57      wiz       513: This variable is used to record the names of variables assigned to
                    514: on the command line, so that they may be exported as part of
1.50      sjg       515: .Ql Ev MAKEFLAGS .
1.57      wiz       516: This behaviour can be disabled by assigning an empty value to
1.50      sjg       517: .Ql Va .MAKEOVERRIDES
1.67      grant     518: within a makefile.
                    519: Extra variables can be exported from a makefile
1.57      wiz       520: by appending their names to
1.51      sjg       521: .Ql Va .MAKEOVERRIDES .
                    522: .Ql Ev MAKEFLAGS
1.57      wiz       523: is re-exported whenever
1.51      sjg       524: .Ql Va .MAKEOVERRIDES
                    525: is modified.
1.55      tv        526: .It Va MAKE_PRINT_VAR_ON_ERROR
1.57      wiz       527: When
1.55      tv        528: .Nm
                    529: stops due to an error, it prints its name and the value of
                    530: .Ql Va .CURDIR
1.57      wiz       531: as well as the value of any variables named in
1.55      tv        532: .Ql Va MAKE_PRINT_VAR_ON_ERROR .
                    533: .It Va .newline
                    534: This variable is simply assigned a newline character as its value.
                    535: This allows expansions using the :@ modifier to put a newline between
1.67      grant     536: iterations of the loop rather than a space.
                    537: For example, the printing of
1.55      tv        538: .Ql Va MAKE_PRINT_VAR_ON_ERROR
                    539: could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
                    540: .It Va .OBJDIR
                    541: A path to the directory where the targets are built.
                    542: .It Va .PARSEDIR
                    543: A path to the directory of the current
                    544: .Ql Pa Makefile
                    545: being parsed.
                    546: .It Va .PARSEFILE
                    547: The basename of the current
                    548: .Ql Pa Makefile
                    549: being parsed.
                    550: This variable and
                    551: .Ql Va .PARSEDIR
                    552: are both set only while the
                    553: .Ql Pa Makefiles
                    554: are being parsed.
1.69      sjg       555: .It Va .PATH
1.82      wiz       556: A variable that represents the list of directories that
1.69      sjg       557: .Nm
1.70      wiz       558: will search for files.
                    559: The search list should be updated using the target
1.69      sjg       560: .Ql Va .PATH
                    561: rather than the variable.
1.16      christos  562: .It Ev PWD
                    563: Alternate path to the current directory.
1.25      lukem     564: .Nm
1.16      christos  565: normally sets
                    566: .Ql Va .CURDIR
                    567: to the canonical path given by
1.48      wiz       568: .Xr getcwd 3 .
1.16      christos  569: However, if the environment variable
                    570: .Ql Ev PWD
                    571: is set and gives a path to the current directory, then
1.25      lukem     572: .Nm
1.16      christos  573: sets
                    574: .Ql Va .CURDIR
                    575: to the value of
                    576: .Ql Ev PWD
1.67      grant     577: instead.
                    578: This behaviour is disabled if
1.40      sjg       579: .Ql Ev MAKEOBJDIRPREFIX
                    580: is set.
1.16      christos  581: .Ql Ev PWD
                    582: is set to the value of
                    583: .Ql Va .OBJDIR
                    584: for all programs which
1.25      lukem     585: .Nm
1.16      christos  586: executes.
1.1       cgd       587: .El
                    588: .Pp
                    589: Variable expansion may be modified to select or modify each word of the
                    590: variable (where a ``word'' is white-space delimited sequence of characters).
                    591: The general format of a variable expansion is as follows:
                    592: .Pp
                    593: .Dl {variable[:modifier[:...]]}
                    594: .Pp
                    595: Each modifier begins with a colon and one of the following
                    596: special characters.
                    597: The colon may be escaped with a backslash
                    598: .Pq Ql \e .
1.61      ross      599: .Bl -tag -width EEE
1.1       cgd       600: .It Cm E
                    601: Replaces each word in the variable with its suffix.
                    602: .It Cm H
                    603: Replaces each word in the variable with everything but the last component.
                    604: .It Cm M Ns Ar pattern
1.72      uebayasi  605: Select only those words that match
                    606: .Ar pattern .
1.1       cgd       607: The standard shell wildcard characters
                    608: .Pf ( Ql * ,
1.80      wiz       609: .Ql \&? ,
1.1       cgd       610: and
                    611: .Ql Op )
                    612: may
                    613: be used.
                    614: The wildcard characters may be escaped with a backslash
                    615: .Pq Ql \e .
                    616: .It Cm N Ns Ar pattern
                    617: This is identical to
                    618: .Ql Cm M ,
                    619: but selects all words which do not match
1.72      uebayasi  620: .Ar pattern .
1.36      christos  621: .It Cm O
                    622: Order every word in variable alphabetically.
1.17      christos  623: .It Cm Q
                    624: Quotes every shell meta-character in the variable, so that it can be passed
                    625: safely through recursive invocations of
1.74      wiz       626: .Nm .
1.1       cgd       627: .It Cm R
                    628: Replaces each word in the variable with everything but its suffix.
1.60      pk        629: .It Cm tl
                    630: Converts variable to lower-case letters.
1.81      sjg       631: .It Cm ts Ar c
                    632: Words in the variable are normally separated by a space on expansion.
                    633: This modifier sets the separator to the character
                    634: .Ar c .
                    635: If
                    636: .Ar c
                    637: is omitted, then no separator is used.
1.82      wiz       638: .It Cm tu
                    639: Converts variable to upper-case letters.
1.89      sjg       640: .It Cm tW
                    641: Causes the value to be treated as a single word
                    642: (possibly containing embedded white space).
                    643: See also
                    644: .Ql \&:[*] .
                    645: .It Cm tw
                    646: Causes the value to be treated as a sequence of
                    647: words delimited by white space.
                    648: See also
                    649: .Ql \&:[@] .
1.1       cgd       650: .Sm off
1.17      christos  651: .It Cm S No \&/ Ar old_string Xo
                    652: .No \&/ Ar new_string
1.89      sjg       653: .No \&/ Op Cm 1gW
1.1       cgd       654: .Xc
                    655: .Sm on
                    656: Modify the first occurrence of
1.17      christos  657: .Ar old_string
                    658: in the variable's value, replacing it with
                    659: .Ar new_string .
1.1       cgd       660: If a
                    661: .Ql g
                    662: is appended to the last slash of the pattern, all occurrences
                    663: in each word are replaced.
1.17      christos  664: If a
                    665: .Ql 1
                    666: is appended to the last slash of the pattern, only the first word
                    667: is affected.
1.89      sjg       668: If a
                    669: .Ql W
                    670: is appended to the last slash of the pattern,
                    671: then the value is treated as a single word
                    672: (possibly containing embedded white space).
1.1       cgd       673: If
1.17      christos  674: .Ar old_string
                    675: begins with a caret
1.1       cgd       676: .Pq Ql ^ ,
1.17      christos  677: .Ar old_string
1.1       cgd       678: is anchored at the beginning of each word.
                    679: If
1.17      christos  680: .Ar old_string
1.1       cgd       681: ends with a dollar sign
                    682: .Pq Ql \&$ ,
                    683: it is anchored at the end of each word.
                    684: Inside
                    685: .Ar new_string ,
                    686: an ampersand
1.62      ross      687: .Pq Ql \*[Am]
1.1       cgd       688: is replaced by
1.17      christos  689: .Ar old_string
                    690: (without any
                    691: .Ql ^
                    692: or
                    693: .Ql \&$ ) .
1.1       cgd       694: Any character may be used as a delimiter for the parts of the modifier
                    695: string.
                    696: The anchoring, ampersand and delimiter characters may be escaped with a
                    697: backslash
                    698: .Pq Ql \e .
                    699: .Pp
                    700: Variable expansion occurs in the normal fashion inside both
                    701: .Ar old_string
                    702: and
                    703: .Ar new_string
                    704: with the single exception that a backslash is used to prevent the expansion
                    705: of a dollar sign
1.17      christos  706: .Pq Ql \&$ ,
1.1       cgd       707: not a preceding dollar sign as is usual.
1.17      christos  708: .Sm off
                    709: .It Cm C No \&/ Ar pattern Xo
                    710: .No \&/ Ar replacement
1.89      sjg       711: .No \&/ Op Cm 1gW
1.17      christos  712: .Xc
                    713: .Sm on
                    714: The
                    715: .Cm C
                    716: modifier is just like the
                    717: .Cm S
1.37      msaitoh   718: modifier except that the old and new strings, instead of being
1.17      christos  719: simple strings, are a regular expression (see
                    720: .Xr regex 3 )
1.72      uebayasi  721: string
                    722: .Ar pattern
1.17      christos  723: and an
                    724: .Xr ed 1 Ns \-style
1.72      uebayasi  725: string
                    726: .Ar replacement .
                    727: Normally, the first occurrence of the pattern
                    728: .Ar pattern
                    729: in each word of the value is substituted with
                    730: .Ar replacement .
1.67      grant     731: The
1.17      christos  732: .Ql 1
                    733: modifier causes the substitution to apply to at most one word; the
                    734: .Ql g
                    735: modifier causes the substitution to apply to as many instances of the
1.72      uebayasi  736: search pattern
                    737: .Ar pattern
1.89      sjg       738: as occur in the word or words it is found in; the
                    739: .Ql W
                    740: modifier causes the value to be treated as a single word
                    741: (possibly containing embedded white space).
1.67      grant     742: Note that
1.17      christos  743: .Ql 1
                    744: and
                    745: .Ql g
                    746: are orthogonal; the former specifies whether multiple words are
                    747: potentially affected, the latter whether multiple substitutions can
                    748: potentially occur within each affected word.
1.1       cgd       749: .It Cm T
                    750: Replaces each word in the variable with its last component.
1.43      christos  751: .It Cm u
                    752: Remove adjacent duplicate words (like
1.57      wiz       753: .Xr uniq 1 ) .
1.80      wiz       754: .It Cm \&? Ar true_string Cm : Ar false_string
1.27      christos  755: If the variable evaluates to true, return as its value the
1.57      wiz       756: .Ar true_string ,
1.27      christos  757: otherwise return the
1.57      wiz       758: .Ar false_string .
1.1       cgd       759: .It Ar old_string=new_string
                    760: This is the
                    761: .At V
                    762: style variable substitution.
                    763: It must be the last modifier specified.
1.16      christos  764: If
1.6       cgd       765: .Ar old_string
                    766: or
                    767: .Ar new_string
                    768: do not contain the pattern matching character
                    769: .Ar %
1.16      christos  770: then it is assumed that they are
1.6       cgd       771: anchored at the end of each word, so only suffixes or entire
1.67      grant     772: words may be replaced.
                    773: Otherwise
1.6       cgd       774: .Ar %
1.16      christos  775: is the substring of
                    776: .Ar old_string
1.6       cgd       777: to be replaced in
1.64      wiz       778: .Ar new_string .
1.40      sjg       779: .It Cm @ Ar temp Cm @ Xo
1.80      wiz       780: .Ar string Cm @
1.40      sjg       781: .Xc
                    782: This is the loop expansion mechanism from the OSF Development
1.67      grant     783: Environment (ODE) make.
                    784: Unlike
1.48      wiz       785: .Cm \&.for
1.40      sjg       786: loops expansion occurs at the time of
1.67      grant     787: reference.
                    788: Assign
1.40      sjg       789: .Ar temp
                    790: to each word in the variable and evaluate
                    791: .Ar string .
1.48      wiz       792: The ODE convention is that
1.40      sjg       793: .Ar temp
1.67      grant     794: should start and end with a period.
                    795: For example.
1.40      sjg       796: .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
                    797: .It Cm U Ar newval
                    798: If the variable is undefined
                    799: .Ar newval
1.63      lukem     800: is the value.
                    801: If the variable is defined, the existing value is returned.
1.67      grant     802: This is another ODE make feature.
                    803: It is handy for setting per-target CFLAGS for instance:
1.40      sjg       804: .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1.63      lukem     805: If a value is only required if the variable is undefined, use:
                    806: .Dl ${VAR:D:Unewval}
1.40      sjg       807: .It Cm D Ar newval
                    808: If the variable is defined
                    809: .Ar newval
                    810: is the value.
                    811: .It Cm L
                    812: The name of the variable is the value.
                    813: .It Cm P
                    814: The path of the node which has the same name as the variable
1.67      grant     815: is the value.
                    816: If no such node exists or its path is null, then the
1.40      sjg       817: name of the variable is used.
1.80      wiz       818: .It Cm \&! Ar cmd Cm \&!
1.40      sjg       819: The output of running
                    820: .Ar cmd
                    821: is the value.
                    822: .It Cm sh
                    823: If the variable is non-empty it is run as a command and the output
                    824: becomes the new value.
1.42      sjg       825: .It Cm \&:= Ar str
1.48      wiz       826: The variable is assigned the value
1.41      sjg       827: .Ar str
1.67      grant     828: after substitution.
                    829: This modifier and its variations are useful in
1.48      wiz       830: obscure situations such as wanting to apply modifiers to
1.41      sjg       831: .Cm \&.for
1.48      wiz       832: loop iteration variables which won't work due to the way
1.41      sjg       833: .Cm \&.for
1.67      grant     834: loops are implemented.
                    835: These assignment modifiers always expand to
1.41      sjg       836: nothing, so if appearing in a rule line by themselves should be
1.48      wiz       837: preceded with something to keep
1.41      sjg       838: .Nm
1.67      grant     839: happy.
                    840: As in:
1.41      sjg       841: .Bd -literal
                    842: use_foo: \&.USE
                    843: \&.for i in ${\&.TARGET} ${\&.TARGET:R}\&.gz
1.42      sjg       844:        @: ${t::=$i}
1.41      sjg       845:        @echo t:R:T=${t:R:T}
                    846: \&.endfor
                    847:
                    848: .Ed
1.42      sjg       849: The double
                    850: .Cm \&:
                    851: helps avoid false matches with the
                    852: .At V
1.48      wiz       853: style
1.42      sjg       854: .Cm \&=
1.48      wiz       855: modifier and since substitution always occurs the
1.42      sjg       856: .Cm \&:=
                    857: form is vaguely appropriate.
                    858: .It Cm \&:?= Ar str
1.41      sjg       859: As for
1.42      sjg       860: .Cm \&:=
1.41      sjg       861: but only if the variable does not already have a value.
1.42      sjg       862: .It Cm \&:+= Ar str
1.48      wiz       863: Append
1.41      sjg       864: .Ar str
                    865: to the variable.
1.42      sjg       866: .It Cm \&:!= Ar cmd
1.48      wiz       867: Assign the output of
1.41      sjg       868: .Ar cmd
                    869: to the variable.
1.89      sjg       870: .It Cm \&[ Ns Ar range Ns Cm \&]
                    871: Selects one or more words from the value,
                    872: or performs other operations related to the way in which the
                    873: value is divided into words.
                    874: .Pp
                    875: Ordinarily, a value is treated as a sequence of words
                    876: delimited by white space.
                    877: Some modifiers suppress this behaviour,
                    878: causing a value to be treated as a single word
                    879: (possibly containing embedded white space).
                    880: An empty value, or a value that consists entirely of white-space,
                    881: is treated as a single word.
                    882: For the purposes of the
                    883: .Ql \&:[]
                    884: modifier, the words are indexed both forwards using positive integers
                    885: (where index 1 represents the first word),
                    886: and backwards using negative integers
                    887: (where index -1 represents the last word).
                    888: .Pp
                    889: The
                    890: .Ar range
                    891: is subjected to variable expansion, and the expanded result is
                    892: then interpreted as follows:
                    893: .Bl -tag -width index
1.90    ! jdolecek  894: .\" :[n]
1.89      sjg       895: .It Ar index
                    896: Selects a single word from the value.
1.90    ! jdolecek  897: .\" :[start..end]
1.89      sjg       898: .It Ar start Ns Cm \&.. Ns Ar end
                    899: Selects all words from
                    900: .Ar start
                    901: to
                    902: .Ar end ,
                    903: inclusive.
                    904: For example,
                    905: .Ql \&:[2..-1]
                    906: selects all words from the second word to the last word.
                    907: If
                    908: .Ar start
                    909: is greater than
                    910: .Ar end ,
                    911: then the words are output in reverse order.  For example,
                    912: .Ql \&:[-1..1]
                    913: selects all the words from last to first.
1.90    ! jdolecek  914: .\" :[*]
1.89      sjg       915: .It Cm \&*
                    916: Causes subsequent modifiers to treat the value as a single word
                    917: (possibly containing embedded white space).  Analogous to the effect of
                    918: \&"$*\&"
                    919: in Bourne shell.
1.90    ! jdolecek  920: .\" :[0]
1.89      sjg       921: .It 0
                    922: Means the same as
                    923: .Ql \&:[*] .
1.90    ! jdolecek  924: .\" :[*]
1.89      sjg       925: .It Cm \&@
                    926: Causes subsequent modifiers to treat the value as a sequence of words
                    927: delimited by white space.  Analogous to the effect of
                    928: \&"$@\&"
                    929: in Bourne shell.
1.90    ! jdolecek  930: .\" :[#]
1.89      sjg       931: .It Cm \&#
                    932: Returns the number of words in the value.
                    933: .El \" :[range]
1.6       cgd       934: .El
                    935: .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1.16      christos  936: Makefile inclusion, conditional structures and for loops  reminiscent
1.6       cgd       937: of the C programming language are provided in
1.74      wiz       938: .Nm .
1.1       cgd       939: All such structures are identified by a line beginning with a single
                    940: dot
                    941: .Pq Ql \&.
                    942: character.
                    943: Files are included with either
1.29      ross      944: .Cm \&.include Aq Ar file
1.1       cgd       945: or
1.29      ross      946: .Cm \&.include Pf \*q Ar file Ns \*q .
1.1       cgd       947: Variables between the angle brackets or double quotes are expanded
                    948: to form the file name.
                    949: If angle brackets are used, the included makefile is expected to be in
                    950: the system makefile directory.
                    951: If double quotes are used, the including makefile's directory and any
                    952: directories specified using the
                    953: .Fl I
                    954: option are searched before the system
                    955: makefile directory.
1.28      christos  956: For compatibility with other versions of
                    957: .Nm
                    958: .Ql include file ...
1.67      grant     959: is also accepted.
                    960: If the include statement is written as
1.29      ross      961: .Cm .-include
                    962: or as
                    963: .Cm .sinclude
1.28      christos  964: then errors locating and/or opening include files are ignored.
1.1       cgd       965: .Pp
                    966: Conditional expressions are also preceded by a single dot as the first
1.5       jtc       967: character of a line.
1.1       cgd       968: The possible conditionals are as follows:
                    969: .Bl -tag -width Ds
                    970: .It Ic .undef Ar variable
                    971: Un-define the specified global variable.
                    972: Only global variables may be un-defined.
                    973: .It Xo
                    974: .Ic \&.if
                    975: .Oo \&! Oc Ns Ar expression
                    976: .Op Ar operator expression ...
                    977: .Xc
                    978: Test the value of an expression.
                    979: .It Xo
                    980: .Ic .ifdef
                    981: .Oo \&! Oc Ns Ar variable
                    982: .Op Ar operator variable ...
                    983: .Xc
1.7       mycroft   984: Test the value of a variable.
1.1       cgd       985: .It Xo
                    986: .Ic .ifndef
                    987: .Oo \&! Oc Ns Ar variable
                    988: .Op Ar operator variable ...
                    989: .Xc
1.7       mycroft   990: Test the value of a variable.
1.1       cgd       991: .It Xo
                    992: .Ic .ifmake
                    993: .Oo \&! Oc Ns Ar target
                    994: .Op Ar operator target ...
                    995: .Xc
1.7       mycroft   996: Test the target being built.
1.1       cgd       997: .It Xo
                    998: .Ic .ifnmake
1.80      wiz       999: .Oo \&! Ns Oc Ar target
1.1       cgd      1000: .Op Ar operator target ...
                   1001: .Xc
                   1002: Test the target being built.
                   1003: .It Ic .else
                   1004: Reverse the sense of the last conditional.
                   1005: .It Xo
                   1006: .Ic .elif
1.80      wiz      1007: .Oo \&! Ns Oc Ar expression
1.1       cgd      1008: .Op Ar operator expression ...
                   1009: .Xc
                   1010: A combination of
                   1011: .Ql Ic .else
                   1012: followed by
                   1013: .Ql Ic .if .
                   1014: .It Xo
                   1015: .Ic .elifdef
                   1016: .Oo \&! Oc Ns Ar variable
                   1017: .Op Ar operator variable ...
                   1018: .Xc
                   1019: A combination of
                   1020: .Ql Ic .else
                   1021: followed by
                   1022: .Ql Ic .ifdef .
                   1023: .It Xo
                   1024: .Ic .elifndef
                   1025: .Oo \&! Oc Ns Ar variable
                   1026: .Op Ar operator variable ...
                   1027: .Xc
                   1028: A combination of
                   1029: .Ql Ic .else
                   1030: followed by
                   1031: .Ql Ic .ifndef .
                   1032: .It Xo
                   1033: .Ic .elifmake
                   1034: .Oo \&! Oc Ns Ar target
                   1035: .Op Ar operator target ...
                   1036: .Xc
                   1037: A combination of
                   1038: .Ql Ic .else
                   1039: followed by
                   1040: .Ql Ic .ifmake .
                   1041: .It Xo
                   1042: .Ic .elifnmake
                   1043: .Oo \&! Oc Ns Ar target
                   1044: .Op Ar operator target ...
                   1045: .Xc
                   1046: A combination of
                   1047: .Ql Ic .else
                   1048: followed by
                   1049: .Ql Ic .ifnmake .
                   1050: .It Ic .endif
                   1051: End the body of the conditional.
                   1052: .El
                   1053: .Pp
                   1054: The
                   1055: .Ar operator
                   1056: may be any one of the following:
                   1057: .Bl -tag -width "Cm XX"
                   1058: .It Cm \&|\&|
1.64      wiz      1059: Logical OR.
1.62      ross     1060: .It Cm \&\*[Am]\*[Am]
1.1       cgd      1061: Logical
                   1062: .Tn AND ;
                   1063: of higher precedence than
1.26      hubertf  1064: .Dq \&|\&| .
1.1       cgd      1065: .El
                   1066: .Pp
                   1067: As in C,
1.25      lukem    1068: .Nm
1.1       cgd      1069: will only evaluate a conditional as far as is necessary to determine
                   1070: its value.
1.16      christos 1071: Parentheses may be used to change the order of evaluation.
1.1       cgd      1072: The boolean operator
                   1073: .Ql Ic \&!
                   1074: may be used to logically negate an entire
                   1075: conditional.
1.5       jtc      1076: It is of higher precedence than
1.62      ross     1077: .Ql Ic \&\*[Am]\*[Am] .
1.1       cgd      1078: .Pp
                   1079: The value of
                   1080: .Ar expression
                   1081: may be any of the following:
1.61      ross     1082: .Bl -tag -width defined
1.1       cgd      1083: .It Ic defined
                   1084: Takes a variable name as an argument and evaluates to true if the variable
                   1085: has been defined.
                   1086: .It Ic make
                   1087: Takes a target name as an argument and evaluates to true if the target
                   1088: was specified as part of
1.74      wiz      1089: .Nm Ns 's
1.1       cgd      1090: command line or was declared the default target (either implicitly or
                   1091: explicitly, see
                   1092: .Va .MAIN )
                   1093: before the line containing the conditional.
                   1094: .It Ic empty
1.5       jtc      1095: Takes a variable, with possible modifiers, and evaluates to true if
1.1       cgd      1096: the expansion of the variable would result in an empty string.
                   1097: .It Ic exists
                   1098: Takes a file name as an argument and evaluates to true if the file exists.
                   1099: The file is searched for on the system search path (see
                   1100: .Va .PATH ) .
                   1101: .It Ic target
                   1102: Takes a target name as an argument and evaluates to true if the target
                   1103: has been defined.
1.47      christos 1104: .It Ic commands
                   1105: Takes a target name as an argument and evaluates to true if the target
                   1106: has been defined and has commands associated with it.
1.1       cgd      1107: .El
                   1108: .Pp
                   1109: .Ar Expression
1.67      grant    1110: may also be an arithmetic or string comparison.
                   1111: Variable expansion is
1.6       cgd      1112: performed on both sides of the comparison, after which the integral
1.67      grant    1113: values are compared.
                   1114: A value is interpreted as hexadecimal if it is
1.6       cgd      1115: preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1.67      grant    1116: The standard C relational operators are all supported.
                   1117: If after
1.6       cgd      1118: variable expansion, either the left or right hand side of a
1.1       cgd      1119: .Ql Ic ==
                   1120: or
                   1121: .Ql Ic "!="
1.6       cgd      1122: operator is not an integral value, then
                   1123: string comparison is performed between the expanded
                   1124: variables.
1.1       cgd      1125: If no relational operator is given, it is assumed that the expanded
                   1126: variable is being compared against 0.
                   1127: .Pp
                   1128: When
1.25      lukem    1129: .Nm
1.1       cgd      1130: is evaluating one of these conditional expression, and it encounters
                   1131: a word it doesn't recognize, either the ``make'' or ``defined''
                   1132: expression is applied to it, depending on the form of the conditional.
                   1133: If the form is
                   1134: .Ql Ic .ifdef
                   1135: or
                   1136: .Ql Ic .ifndef ,
                   1137: the ``defined'' expression
                   1138: is applied.
                   1139: Similarly, if the form is
                   1140: .Ql Ic .ifmake
                   1141: or
                   1142: .Ql Ic .ifnmake , the ``make''
                   1143: expression is applied.
                   1144: .Pp
                   1145: If the conditional evaluates to true the parsing of the makefile continues
                   1146: as before.
                   1147: If it evaluates to false, the following lines are skipped.
                   1148: In both cases this continues until a
                   1149: .Ql Ic .else
                   1150: or
                   1151: .Ql Ic .endif
                   1152: is found.
1.16      christos 1153: .Pp
1.6       cgd      1154: For loops are typically used to apply a set of rules to a list of files.
                   1155: The syntax of a for loop is:
1.59      bgrayson 1156: .Pp
                   1157: .Bl -tag -compact -width Ds
1.6       cgd      1158: .It Xo
                   1159: .Ic \&.for
1.48      wiz      1160: .Ar variable
1.39      christos 1161: .Op Ar variable ...
1.16      christos 1162: .Ic in
1.6       cgd      1163: .Ar expression
                   1164: .Xc
1.80      wiz      1165: .It Aq make-rules
                   1166: .It Ic \&.endfor
1.6       cgd      1167: .El
1.59      bgrayson 1168: .Pp
1.6       cgd      1169: After the for
1.16      christos 1170: .Ic expression
1.67      grant    1171: is evaluated, it is split into words.
                   1172: On each iteration of the loop, one word is taken and assigned to each
1.39      christos 1173: .Ic variable ,
                   1174: in order, and these
                   1175: .Ic variables
                   1176: are substituted into the
1.16      christos 1177: .Ic make-rules
1.6       cgd      1178: inside the body of the for loop.
1.39      christos 1179: The number of words must come out even; that is, if there are three
                   1180: iteration variables, the number of words provided must be a multiple
                   1181: of three.
1.1       cgd      1182: .Sh COMMENTS
                   1183: Comments begin with a hash
                   1184: .Pq Ql \&#
                   1185: character, anywhere but in a shell
                   1186: command line, and continue to the end of the line.
                   1187: .Sh SPECIAL SOURCES
1.61      ross     1188: .Bl -tag -width .IGNOREx
1.1       cgd      1189: .It Ic .IGNORE
                   1190: Ignore any errors from the commands associated with this target, exactly
                   1191: as if they all were preceded by a dash
                   1192: .Pq Ql \- .
1.18      christos 1193: .It Ic .MADE
1.48      wiz      1194: Mark all sources of this target as being up-to-date.
1.1       cgd      1195: .It Ic .MAKE
                   1196: Execute the commands associated with this target even if the
                   1197: .Fl n
                   1198: or
                   1199: .Fl t
                   1200: options were specified.
                   1201: Normally used to mark recursive
1.74      wiz      1202: .Nm Ns 's .
1.1       cgd      1203: .It Ic .NOTMAIN
                   1204: Normally
1.25      lukem    1205: .Nm
1.1       cgd      1206: selects the first target it encounters as the default target to be built
                   1207: if no target was specified.
                   1208: This source prevents this target from being selected.
                   1209: .It Ic .OPTIONAL
                   1210: If a target is marked with this attribute and
1.25      lukem    1211: .Nm
1.1       cgd      1212: can't figure out how to create it, it will ignore this fact and assume
                   1213: the file isn't needed or already exists.
                   1214: .It Ic .PRECIOUS
                   1215: When
1.25      lukem    1216: .Nm
1.1       cgd      1217: is interrupted, it removes any partially made targets.
                   1218: This source prevents the target from being removed.
                   1219: .It Ic .SILENT
                   1220: Do not echo any of the commands associated with this target, exactly
                   1221: as if they all were preceded by an at sign
                   1222: .Pq Ql @ .
                   1223: .It Ic .USE
                   1224: Turn the target into
1.74      wiz      1225: .Nm Ns 's
1.1       cgd      1226: version of a macro.
                   1227: When the target is used as a source for another target, the other target
                   1228: acquires the commands, sources, and attributes (except for
                   1229: .Ic .USE )
                   1230: of the
                   1231: source.
                   1232: If the target already has commands, the
                   1233: .Ic .USE
                   1234: target's commands are appended
                   1235: to them.
1.52      christos 1236: .It Ic .USEBEFORE
                   1237: Exactly like
                   1238: .Ic .USE ,
1.57      wiz      1239: but prepend the
1.52      christos 1240: .Ic .USEBEFORE
                   1241: target commands to the target.
1.12      christos 1242: .It Ic .WAIT
1.71      mjl      1243: If
1.12      christos 1244: .Ic .WAIT
1.71      mjl      1245: appears in a dependency line, the sources that precede it are
1.67      grant    1246: made before the sources that succeed it in the line.
1.71      mjl      1247: Loops are not
1.12      christos 1248: detected and targets that form loops will be silently ignored.
1.1       cgd      1249: .El
1.57      wiz      1250: .Sh SPECIAL TARGETS
1.1       cgd      1251: Special targets may not be included with other targets, i.e. they must be
                   1252: the only target specified.
1.61      ross     1253: .Bl -tag -width .BEGINx
1.1       cgd      1254: .It Ic .BEGIN
                   1255: Any command lines attached to this target are executed before anything
                   1256: else is done.
                   1257: .It Ic .DEFAULT
                   1258: This is sort of a
                   1259: .Ic .USE
                   1260: rule for any target (that was used only as a
                   1261: source) that
1.25      lukem    1262: .Nm
1.1       cgd      1263: can't figure out any other way to create.
                   1264: Only the shell script is used.
                   1265: The
                   1266: .Ic .IMPSRC
                   1267: variable of a target that inherits
                   1268: .Ic .DEFAULT Ns 's
                   1269: commands is set
                   1270: to the target's own name.
                   1271: .It Ic .END
                   1272: Any command lines attached to this target are executed after everything
                   1273: else is done.
                   1274: .It Ic .IGNORE
                   1275: Mark each of the sources with the
                   1276: .Ic .IGNORE
                   1277: attribute.
                   1278: If no sources are specified, this is the equivalent of specifying the
                   1279: .Fl i
                   1280: option.
                   1281: .It Ic .INTERRUPT
                   1282: If
1.25      lukem    1283: .Nm
1.1       cgd      1284: is interrupted, the commands for this target will be executed.
                   1285: .It Ic .MAIN
                   1286: If no target is specified when
1.25      lukem    1287: .Nm
1.1       cgd      1288: is invoked, this target will be built.
                   1289: .It Ic .MAKEFLAGS
                   1290: This target provides a way to specify flags for
1.25      lukem    1291: .Nm
1.1       cgd      1292: when the makefile is used.
                   1293: The flags are as if typed to the shell, though the
                   1294: .Fl f
                   1295: option will have
                   1296: no effect.
1.12      christos 1297: .\" XXX: NOT YET!!!!
                   1298: .\" .It Ic .NOTPARALLEL
1.70      wiz      1299: .\" The named targets are executed in non parallel mode.
                   1300: .\" If no targets are
1.12      christos 1301: .\" specified, then all targets are executed in non parallel mode.
1.20      gwr      1302: .It Ic .NOPATH
                   1303: Apply the
                   1304: .Ic .NOPATH
1.67      grant    1305: attribute to any specified sources.
                   1306: Targets with this attribute are not
1.21      mycroft  1307: searched for in the directories specified by
                   1308: .Ic .PATH .
1.12      christos 1309: .It Ic .NOTPARALLEL
                   1310: Disable parallel mode.
                   1311: .It Ic .NO_PARALLEL
                   1312: Same as above, for compatibility with other pmake variants.
                   1313: .It Ic .ORDER
                   1314: The named targets are made in sequence.
                   1315: .\" XXX: NOT YET!!!!
                   1316: .\" .It Ic .PARALLEL
1.70      wiz      1317: .\" The named targets are executed in parallel mode.
                   1318: .\" If no targets are
1.12      christos 1319: .\" specified, then all targets are executed in parallel mode.
1.1       cgd      1320: .It Ic .PATH
                   1321: The sources are directories which are to be searched for files not
                   1322: found in the current directory.
                   1323: If no sources are specified, any previously specified directories are
                   1324: deleted.
1.34      thorpej  1325: If the source is the special
                   1326: .Ic .DOTLAST
                   1327: target, then the current working
1.33      thorpej  1328: directory is searched last.
1.14      christos 1329: .It Ic .PHONY
                   1330: Apply the
                   1331: .Ic .PHONY
1.67      grant    1332: attribute to any specified sources.
                   1333: Targets with this attribute do not
1.19      mycroft  1334: correspond to actual files; they are always considered to be out of date,
                   1335: and will not be created with the
                   1336: .Fl t
                   1337: option.
1.1       cgd      1338: .It Ic .PRECIOUS
                   1339: Apply the
                   1340: .Ic .PRECIOUS
                   1341: attribute to any specified sources.
                   1342: If no sources are specified, the
                   1343: .Ic .PRECIOUS
                   1344: attribute is applied to every
                   1345: target in the file.
1.83      sjg      1346: .It Ic .SHELL
1.86      wiz      1347: Sets the shell that
1.83      sjg      1348: .Nm
1.86      wiz      1349: will use to execute commands.
                   1350: The sources are a set of
1.83      sjg      1351: .Ar field=value
1.86      wiz      1352: pairs.
1.83      sjg      1353: .Bl -tag -width hasErrCtls
                   1354: .It Ar name
                   1355: This is the minimal specification, used to select one of the builtin
                   1356: shell specs;
                   1357: .Ar sh ,
                   1358: .Ar ksh ,
                   1359: and
                   1360: .Ar csh .
                   1361: .It Ar path
                   1362: Specifies the path to the shell.
                   1363: .It Ar hasErrCtl
                   1364: Indicates whether the shell supports exit on error.
                   1365: .It Ar check
                   1366: The command to turn on error checking.
                   1367: .It Ar ignore
                   1368: The command to disable error checking.
                   1369: .It Ar echo
                   1370: The command to turn on echoing of commands executed.
                   1371: .It Ar quiet
                   1372: The command to turn off echoing of commands executed.
                   1373: .It Ar filter
                   1374: The output to filter after issuing the
                   1375: .Ar quiet
1.86      wiz      1376: command.
                   1377: It is typically identical to
1.83      sjg      1378: .Ar quiet .
                   1379: .It Ar errFlag
                   1380: The flag to pass the shell to enable error checking.
                   1381: .It Ar echoFlag
                   1382: The flag to pass the shell to enable command echoing.
                   1383: .El
                   1384: Example:
                   1385: .Bd -literal
                   1386: \&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \\
                   1387:        check="set -e" ignore="set +e" \\
                   1388:        echo="set -v" quiet="set +v" filter="set +v" \\
                   1389:        echoFlag=v errFlag=e
                   1390: .Ed
1.1       cgd      1391: .It Ic .SILENT
                   1392: Apply the
                   1393: .Ic .SILENT
                   1394: attribute to any specified sources.
                   1395: If no sources are specified, the
                   1396: .Ic .SILENT
                   1397: attribute is applied to every
                   1398: command in the file.
                   1399: .It Ic .SUFFIXES
                   1400: Each source specifies a suffix to
1.74      wiz      1401: .Nm .
1.71      mjl      1402: If no sources are specified, any previously specified suffixes are deleted.
1.31      ross     1403: .El
1.1       cgd      1404: .Sh ENVIRONMENT
1.25      lukem    1405: .Nm
1.73      perry    1406: uses the following environment variables, if they exist:
1.16      christos 1407: .Ev MACHINE ,
1.26      hubertf  1408: .Ev MACHINE_ARCH ,
1.1       cgd      1409: .Ev MAKE ,
1.16      christos 1410: .Ev MAKEFLAGS ,
                   1411: .Ev MAKEOBJDIR ,
1.38      sjg      1412: .Ev MAKEOBJDIRPREFIX ,
1.76      jrf      1413: .Ev MAKESYSPATH ,
1.1       cgd      1414: and
1.16      christos 1415: .Ev PWD .
1.57      wiz      1416: .Pp
1.38      sjg      1417: If
                   1418: .Ev MAKEOBJDIRPREFIX
                   1419: is set, then
                   1420: .Nm
1.48      wiz      1421: will
1.38      sjg      1422: .Xr chdir 2
                   1423: to ${MAKEOBJDIRPREFIX}${.CURDIR} if it exists.
                   1424: Otherwise if
                   1425: .Ev MAKEOBJDIR
                   1426: and the named directory exists
                   1427: .Nm
1.48      wiz      1428: will
1.38      sjg      1429: .Xr chdir 2
                   1430: to it.
1.48      wiz      1431: These actions are taken before any makefiles are read which is why they
1.38      sjg      1432: need to be set in the environment.
1.1       cgd      1433: .Sh FILES
                   1434: .Bl -tag -width /usr/share/mk -compact
                   1435: .It .depend
                   1436: list of dependencies
                   1437: .It Makefile
                   1438: list of dependencies
                   1439: .It makefile
                   1440: list of dependencies
                   1441: .It sys.mk
                   1442: system makefile
                   1443: .It /usr/share/mk
                   1444: system makefile directory
                   1445: .El
                   1446: .Sh SEE ALSO
                   1447: .Xr mkdep 1
                   1448: .Sh HISTORY
                   1449: A
1.25      lukem    1450: .Nm
1.1       cgd      1451: command appeared in
                   1452: .At v7 .

CVSweb <webmaster@jp.NetBSD.org>