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

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

1.4       deraadt     1: .\"    $NetBSD: make.1,v 1.12 1995/12/16 05:03:09 christos Exp $
1.1       deraadt     2: .\" Copyright (c) 1990 The Regents of the University of California.
                      3: .\" All rights reserved.
                      4: .\"
                      5: .\" Redistribution and use in source and binary forms, with or without
                      6: .\" modification, are permitted provided that the following conditions
                      7: .\" are met:
                      8: .\" 1. Redistributions of source code must retain the above copyright
                      9: .\"    notice, this list of conditions and the following disclaimer.
                     10: .\" 2. Redistributions in binary form must reproduce the above copyright
                     11: .\"    notice, this list of conditions and the following disclaimer in the
                     12: .\"    documentation and/or other materials provided with the distribution.
                     13: .\" 3. All advertising materials mentioning features or use of this software
                     14: .\"    must display the following acknowledgement:
                     15: .\"    This product includes software developed by the University of
                     16: .\"    California, Berkeley and its contributors.
                     17: .\" 4. Neither the name of the University nor the names of its contributors
                     18: .\"    may be used to endorse or promote products derived from this software
                     19: .\"    without specific prior written permission.
                     20: .\"
                     21: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31: .\" SUCH DAMAGE.
                     32: .\"
                     33: .\"    from: @(#)make.1        5.7 (Berkeley) 7/24/91
                     34: .\"
                     35: .Dd July 24, 1991
                     36: .Dt MAKE 1
                     37: .Os
                     38: .Sh NAME
                     39: .Nm make
                     40: .Nd maintain program dependencies
                     41: .Sh SYNOPSIS
                     42: .Nm make
1.3       deraadt    43: .Op Fl Beiknqrstv
1.1       deraadt    44: .Op Fl D Ar variable
                     45: .Op Fl d Ar flags
                     46: .Op Fl f Ar makefile
                     47: .Op Fl I Ar directory
                     48: .Bk -words
                     49: .Op Fl j Ar max_jobs
1.5     ! niklas     50: .Op Fl m Ar directory
1.1       deraadt    51: .Ek
                     52: .Op Ar variable=value
                     53: .Op Ar target ...
                     54: .Sh DESCRIPTION
                     55: .Nm Make
                     56: is a program designed to simplify the maintenance of other programs.
                     57: Its input is a list of specifications as to the files upon which programs
                     58: and other files depend.
                     59: If the file
                     60: .Ql Pa makefile
                     61: exists, it is read for this list of specifications.
                     62: If it does not exist, the file
                     63: .Ql Pa Makefile
                     64: is read.
                     65: If the file
                     66: .Ql Pa .depend
                     67: exists, it is read (see
                     68: .Xr mkdep 1) .
                     69: .Pp
                     70: This manual page is intended as a reference document only.
                     71: For a more thorough description of
                     72: .Nm make
                     73: and makefiles, please refer to
                     74: .%T "Make \- A Tutorial" .
                     75: .Pp
                     76: The options are as follows:
                     77: .Bl -tag -width Ds
1.3       deraadt    78: .It Fl B
                     79: Try to be backwards compatible by executing a single shell per command and
                     80: by executing the commands to make the sources of a dependency line in sequence.
1.1       deraadt    81: .It Fl D Ar variable
                     82: Define
                     83: .Ar variable
                     84: to be 1, in the global context.
                     85: .It Fl d Ar flags
                     86: Turn on debugging, and specify which portions of
                     87: .Nm make
                     88: are to print debugging information.
                     89: .Ar Flags
                     90: is one or more of the following:
                     91: .Bl -tag -width Ds
                     92: .It Ar A
                     93: Print all possible debugging information;
                     94: equivalent to specifying all of the debugging flags.
                     95: .It Ar a
                     96: Print debugging information about archive searching and caching.
                     97: .It Ar c
                     98: Print debugging information about conditional evaluation.
                     99: .It Ar d
                    100: Print debugging information about directory searching and caching.
                    101: .It Ar "g1"
                    102: Print the input graph before making anything.
                    103: .It Ar "g2"
                    104: Print the input graph after making everything, or before exiting
                    105: on error.
                    106: .It Ar j
                    107: Print debugging information about running multiple shells.
                    108: .It Ar m
                    109: Print debugging information about making targets, including modification
                    110: dates.
                    111: .It Ar s
                    112: Print debugging information about suffix-transformation rules.
                    113: .It Ar t
                    114: Print debugging information about target list maintenance.
                    115: .It Ar v
                    116: Print debugging information about variable assignment.
                    117: .El
                    118: .It Fl e
1.3       deraadt   119: Specify that environmental variables override macro assignments within
1.1       deraadt   120: makefiles.
                    121: .It Fl f Ar makefile
                    122: Specify a makefile to read instead of the default
                    123: .Ql Pa makefile
                    124: and
                    125: .Ql Pa Makefile .
                    126: If
                    127: .Ar makefile
                    128: is
                    129: .Ql Fl ,
                    130: standard input is read.
                    131: Multiple makefile's may be specified, and are read in the order specified.
                    132: .It Fl I Ar directory
                    133: Specify a directory in which to search for makefiles and included makefiles.
1.5     ! niklas    134: The system makefile directory (or directories, see the
        !           135: .Fl m
        !           136: option) is automatically included as part of this list.
1.1       deraadt   137: .It Fl i
                    138: Ignore non-zero exit of shell commands in the makefile.
                    139: Equivalent to specifying
                    140: .Ql Fl
                    141: before each command line in the makefile.
                    142: .It Fl j Ar max_jobs
                    143: Specify the maximum number of jobs that
                    144: .Nm make
1.3       deraadt   145: may have running at any one time. Turns compatibility mode off, unless the
                    146: .Ar B
                    147: flag is also specified.
1.1       deraadt   148: .It Fl k
                    149: Continue processing after errors are encountered, but only on those targets
                    150: that do not depend on the target whose creation caused the error.
1.5     ! niklas    151: .It Fl m Ar directory
        !           152: Specify a directory in which to search for sys.mk and makefiles included
        !           153: via the <...> style.  Multiple directories can be added to form a search path.
        !           154: This path will override the default system include path: /usr/share/mk.
        !           155: Furthermore the system include path will be appended to the search path used
        !           156: for "..."-style inclusions (see the
        !           157: .Fl I
        !           158: option).
1.1       deraadt   159: .It Fl n
                    160: Display the commands that would have been executed, but do not actually
                    161: execute them.
                    162: .It Fl q
                    163: Do not execute any commands, but exit 0 if the specified targets are
                    164: up-to-date and 1, otherwise.
                    165: .It Fl r
                    166: Do not use the built-in rules specified in the system makefile.
                    167: .It Fl s
                    168: Do not echo any commands as they are executed.
                    169: Equivalent to specifying
                    170: .Ql Ic @
                    171: before each command line in the makefile.
                    172: .It Fl t
                    173: Rather than re-building a target as specified in the makefile, create it
                    174: or update its modification time to make it appear up-to-date.
                    175: .It Ar variable=value
                    176: Set the value of the variable
                    177: .Ar variable
                    178: to
                    179: .Ar value .
                    180: .El
                    181: .Pp
                    182: There are seven different types of lines in a makefile: file dependency
                    183: specifications, shell commands, variable assignments, include statements,
                    184: conditional directives, for loops, and comments.
                    185: .Pp
                    186: In general, lines may be continued from one line to the next by ending
                    187: them with a backslash
                    188: .Pq Ql \e .
                    189: The trailing newline character and initial whitespace on the following
                    190: line are compressed into a single space.
                    191: .Sh FILE DEPENDENCY SPECIFICATIONS
                    192: Dependency lines consist of one or more targets, an operator, and zero
                    193: or more sources.
                    194: This creates a relationship where the targets ``depend'' on the sources
                    195: and are usually created from them.
                    196: The exact relationship between the target and the source is determined
                    197: by the operator that separates them.
                    198: The three operators are as follows:
                    199: .Bl -tag -width flag
                    200: .It Ic \&:
                    201: A target is considered out-of-date if its modification time is less than
                    202: those of any of its sources.
                    203: Sources for a target accumulate over dependency lines when this operator
                    204: is used.
                    205: The target is removed if
                    206: .Nm make
                    207: is interrupted.
                    208: .It Ic \&!
                    209: Targets are always re-created, but not until all sources have been
                    210: examined and re-created as necessary.
                    211: Sources for a target accumulate over dependency lines when this operator
                    212: is used.
                    213: The target is removed if
                    214: .Nm make
                    215: is interrupted.
                    216: .It Ic \&::
                    217: If no sources are specified, the target is always re-created.
                    218: Otherwise, a target is considered out-of-date if any of its sources has
                    219: been modified more recently than the target.
                    220: Sources for a target do not accumulate over dependency lines when this
                    221: operator is used.
                    222: The target will not be removed if
                    223: .Nm make
                    224: is interrupted.
                    225: .El
                    226: .Pp
                    227: Targets and sources may contain the shell wildcard values
                    228: .Ql ? ,
                    229: .Ql * ,
                    230: .Ql []
                    231: and
                    232: .Ql {} .
                    233: The values
                    234: .Ql ? ,
                    235: .Ql *
                    236: and
                    237: .Ql []
                    238: may only be used as part of the final
                    239: component of the target or source, and must be used to describe existing
                    240: files.
                    241: The value
                    242: .Ql {}
                    243: need not necessarily be used to describe existing files.
                    244: Expansion is in directory order, not alphabetically as done in the shell.
                    245: .Sh SHELL COMMANDS
                    246: Each target may have associated with it a series of shell commands, normally
                    247: used to create the target.
                    248: Each of the commands in this script
                    249: .Em must
                    250: be preceded by a tab.
                    251: While any target may appear on a dependency line, only one of these
                    252: dependencies may be followed by a creation script, unless the
                    253: .Ql Ic ::
                    254: operator is used.
                    255: .Pp
                    256: If the first or first two characters of the command line are
                    257: .Ql Ic @
                    258: and/or
                    259: .Ql Ic \- ,
                    260: the command is treated specially.
                    261: A
                    262: .Ql Ic @
                    263: causes the command not to be echoed before it is executed.
                    264: A
                    265: .Ql Ic \-
                    266: causes any non-zero exit status of the command line to be ignored.
                    267: .Sh VARIABLE ASSIGNMENTS
                    268: Variables in make are much like variables in the shell, and, by tradition,
                    269: consist of all upper-case letters.
                    270: The five operators that can be used to assign values to variables are as
                    271: follows:
                    272: .Bl -tag -width Ds
                    273: .It Ic \&=
                    274: Assign the value to the variable.
                    275: Any previous value is overridden.
                    276: .It Ic \&+=
                    277: Append the value to the current value of the variable.
                    278: .It Ic \&?=
                    279: Assign the value to the variable if it is not already defined.
                    280: .It Ic \&:=
                    281: Assign with expansion, i.e. expand the value before assigning it
                    282: to the variable.
                    283: Normally, expansion is not done until the variable is referenced.
                    284: .It Ic \&!=
                    285: Expand the value and pass it to the shell for execution and assign
                    286: the result to the variable.
                    287: Any newlines in the result are replaced with spaces.
                    288: .El
                    289: .Pp
                    290: Any white-space before the assigned
                    291: .Ar value
                    292: is removed; if the value is being appended, a single space is inserted
                    293: between the previous contents of the variable and the appended value.
                    294: .Pp
                    295: Variables are expanded by surrounding the variable name with either
                    296: curly braces
                    297: .Pq Ql {}
                    298: or parentheses
                    299: .Pq Ql ()
                    300: and preceding it with
                    301: a dollar sign
                    302: .Pq Ql \&$ .
                    303: If the variable name contains only a single letter, the surrounding
                    304: braces or parentheses are not required.
                    305: This shorter form is not recommended.
                    306: .Pp
                    307: Variable substitution occurs at two distinct times, depending on where
                    308: the variable is being used.
                    309: Variables in dependency lines are expanded as the line is read.
                    310: Variables in shell commands are expanded when the shell command is
                    311: executed.
                    312: .Pp
                    313: The four different classes of variables (in order of increasing precedence)
                    314: are:
                    315: .Bl -tag -width Ds
                    316: .It Environment variables
                    317: Variables defined as part of
                    318: .Nm make Ns 's
                    319: environment.
                    320: .It Global variables
                    321: Variables defined in the makefile or in included makefiles.
                    322: .It Command line variables
                    323: Variables defined as part of the command line.
                    324: .It Local variables
                    325: Variables that are defined specific to a certain target.
                    326: The seven local variables are as follows:
                    327: .Bl -tag -width ".ARCHIVE"
                    328: .It Va .ALLSRC
                    329: The list of all sources for this target; also known as
                    330: .Ql Va \&> .
                    331: .It Va .ARCHIVE
                    332: The name of the archive file.
                    333: .It Va .IMPSRC
                    334: The name/path of the source from which the target is to be transformed
                    335: (the ``implied'' source); also known as
                    336: .Ql Va \&< .
                    337: .It Va .MEMBER
                    338: The name of the archive member.
                    339: .It Va .OODATE
                    340: The list of sources for this target that were deemed out-of-date; also
                    341: known as
                    342: .Ql Va \&? .
                    343: .It Va .PREFIX
                    344: The file prefix of the file, containing only the file portion, no suffix
                    345: or preceding directory components; also known as
                    346: .Ql Va * .
                    347: .It Va .TARGET
                    348: The name of the target; also known as
                    349: .Ql Va @ .
                    350: .El
                    351: .Pp
                    352: The shorter forms
                    353: .Ql Va @ ,
                    354: .Ql Va ? ,
                    355: .Ql Va \&>
                    356: and
                    357: .Ql Va *
                    358: are permitted for backward
                    359: compatibility with historical makefiles and are not recommended.
                    360: The six variables
                    361: .Ql Va "@F" ,
                    362: .Ql Va "@D" ,
                    363: .Ql Va "<F" ,
                    364: .Ql Va "<D" ,
                    365: .Ql Va "*F"
                    366: and
                    367: .Ql Va "*D"
                    368: are
                    369: permitted for compatibility with
                    370: .At V
                    371: makefiles and are not recommended.
                    372: .Pp
                    373: Four of the local variables may be used in sources on dependency lines
                    374: because they expand to the proper value for each target on the line.
                    375: These variables are
                    376: .Ql Va .TARGET ,
                    377: .Ql Va .PREFIX ,
                    378: .Ql Va .ARCHIVE ,
                    379: and
                    380: .Ql Va .MEMBER .
                    381: .Pp
                    382: In addition,
                    383: .Nm make
                    384: sets or knows about the following variables:
                    385: .Bl -tag -width MAKEFLAGS
                    386: .It Va \&$
                    387: A single dollar sign
                    388: .Ql \&$ ,
                    389: i.e.
                    390: .Ql \&$$
                    391: expands to a single dollar
                    392: sign.
                    393: .It Va .MAKE
                    394: The name that
                    395: .Nm make
                    396: was executed with
                    397: .Pq Va argv Op 0
                    398: .It Va .CURDIR
                    399: A path to the directory where
                    400: .Nm make
                    401: was executed.
                    402: .It Va .OBJDIR
                    403: A path to the directory where the targets are built.
                    404: .It Ev MAKEFLAGS
                    405: The environment variable
                    406: .Ql Ev MAKEFLAGS
                    407: may contain anything that
                    408: may be specified on
                    409: .Nm make Ns 's
                    410: command line.
                    411: Anything specified on
                    412: .Nm make Ns 's
                    413: command line is appended to the
                    414: .Ql Ev MAKEFLAGS
                    415: variable which is then
                    416: entered into the environment for all programs which
                    417: .Nm make
                    418: executes.
                    419: .El
                    420: .Pp
                    421: Variable expansion may be modified to select or modify each word of the
                    422: variable (where a ``word'' is white-space delimited sequence of characters).
                    423: The general format of a variable expansion is as follows:
                    424: .Pp
                    425: .Dl {variable[:modifier[:...]]}
                    426: .Pp
                    427: Each modifier begins with a colon and one of the following
                    428: special characters.
                    429: The colon may be escaped with a backslash
                    430: .Pq Ql \e .
                    431: .Bl -tag -width Cm E\&
                    432: .It Cm E
                    433: Replaces each word in the variable with its suffix.
                    434: .It Cm H
                    435: Replaces each word in the variable with everything but the last component.
                    436: .It Cm M Ns Ar pattern
                    437: Select only those words that match the rest of the modifier.
                    438: The standard shell wildcard characters
                    439: .Pf ( Ql * ,
                    440: .Ql ? ,
                    441: and
                    442: .Ql Op )
                    443: may
                    444: be used.
                    445: The wildcard characters may be escaped with a backslash
                    446: .Pq Ql \e .
                    447: .It Cm N Ns Ar pattern
                    448: This is identical to
                    449: .Ql Cm M ,
                    450: but selects all words which do not match
                    451: the rest of the modifier.
                    452: .It Cm R
                    453: Replaces each word in the variable with everything but its suffix.
                    454: .Sm off
                    455: .It Cm S No \&/ Ar old_pattern Xo
                    456: .No \&/ Ar new_pattern
                    457: .No \&/ Op Cm g
                    458: .Xc
                    459: .Sm on
                    460: Modify the first occurrence of
                    461: .Ar old_pattern
                    462: in each word to be replaced with
                    463: .Ar new_pattern .
                    464: If a
                    465: .Ql g
                    466: is appended to the last slash of the pattern, all occurrences
                    467: in each word are replaced.
                    468: If
                    469: .Ar old_pattern
                    470: begins with a carat
                    471: .Pq Ql ^ ,
                    472: .Ar old_pattern
                    473: is anchored at the beginning of each word.
                    474: If
                    475: .Ar old_pattern
                    476: ends with a dollar sign
                    477: .Pq Ql \&$ ,
                    478: it is anchored at the end of each word.
                    479: Inside
                    480: .Ar new_string ,
                    481: an ampersand
                    482: .Pq Ql &
                    483: is replaced by
                    484: .Ar old_pattern .
                    485: Any character may be used as a delimiter for the parts of the modifier
                    486: string.
                    487: The anchoring, ampersand and delimiter characters may be escaped with a
                    488: backslash
                    489: .Pq Ql \e .
                    490: .Pp
                    491: Variable expansion occurs in the normal fashion inside both
                    492: .Ar old_string
                    493: and
                    494: .Ar new_string
                    495: with the single exception that a backslash is used to prevent the expansion
                    496: of a dollar sign
                    497: .Pq Ql \&$
                    498: not a preceding dollar sign as is usual.
                    499: .It Cm T
                    500: Replaces each word in the variable with its last component.
                    501: .It Ar old_string=new_string
                    502: This is the
                    503: .At V
                    504: style variable substitution.
                    505: It must be the last modifier specified.
                    506: If
                    507: .Ar old_string
                    508: or
                    509: .Ar new_string
                    510: do not contain the pattern matching character
                    511: .Ar %
                    512: then it is assumed that they are
                    513: anchored at the end of each word, so only suffixes or entire
                    514: words may be replaced. Otherwise
                    515: .Ar %
                    516: is the substring of
                    517: .Ar old_string
                    518: to be replaced in
                    519: .Ar new_string
                    520: .El
                    521: .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
                    522: Makefile inclusion, conditional structures and for loops  reminiscent
                    523: of the C programming language are provided in
                    524: .Nm make .
                    525: All such structures are identified by a line beginning with a single
                    526: dot
                    527: .Pq Ql \&.
                    528: character.
                    529: Files are included with either
                    530: .Ql .include <file>
                    531: or
                    532: .Ql .include \*qfile\*q .
                    533: Variables between the angle brackets or double quotes are expanded
                    534: to form the file name.
                    535: If angle brackets are used, the included makefile is expected to be in
                    536: the system makefile directory.
                    537: If double quotes are used, the including makefile's directory and any
                    538: directories specified using the
                    539: .Fl I
                    540: option are searched before the system
                    541: makefile directory.
                    542: .Pp
                    543: Conditional expressions are also preceded by a single dot as the first
                    544: character of a line.
                    545: The possible conditionals are as follows:
                    546: .Bl -tag -width Ds
                    547: .It Ic .undef Ar variable
                    548: Un-define the specified global variable.
                    549: Only global variables may be un-defined.
                    550: .It Xo
                    551: .Ic \&.if
                    552: .Oo \&! Oc Ns Ar expression
                    553: .Op Ar operator expression ...
                    554: .Xc
                    555: Test the value of an expression.
                    556: .It Xo
                    557: .Ic .ifdef
                    558: .Oo \&! Oc Ns Ar variable
                    559: .Op Ar operator variable ...
                    560: .Xc
                    561: Test the value of a variable.
                    562: .It Xo
                    563: .Ic .ifndef
                    564: .Oo \&! Oc Ns Ar variable
                    565: .Op Ar operator variable ...
                    566: .Xc
                    567: Test the value of a variable.
                    568: .It Xo
                    569: .Ic .ifmake
                    570: .Oo \&! Oc Ns Ar target
                    571: .Op Ar operator target ...
                    572: .Xc
                    573: Test the target being built.
                    574: .It Xo
                    575: .Ic .ifnmake
                    576: .Oo \&! Oc Ar target
                    577: .Op Ar operator target ...
                    578: .Xc
                    579: Test the target being built.
                    580: .It Ic .else
                    581: Reverse the sense of the last conditional.
                    582: .It Xo
                    583: .Ic .elif
                    584: .Oo \&! Oc Ar expression
                    585: .Op Ar operator expression ...
                    586: .Xc
                    587: A combination of
                    588: .Ql Ic .else
                    589: followed by
                    590: .Ql Ic .if .
                    591: .It Xo
                    592: .Ic .elifdef
                    593: .Oo \&! Oc Ns Ar variable
                    594: .Op Ar operator variable ...
                    595: .Xc
                    596: A combination of
                    597: .Ql Ic .else
                    598: followed by
                    599: .Ql Ic .ifdef .
                    600: .It Xo
                    601: .Ic .elifndef
                    602: .Oo \&! Oc Ns Ar variable
                    603: .Op Ar operator variable ...
                    604: .Xc
                    605: A combination of
                    606: .Ql Ic .else
                    607: followed by
                    608: .Ql Ic .ifndef .
                    609: .It Xo
                    610: .Ic .elifmake
                    611: .Oo \&! Oc Ns Ar target
                    612: .Op Ar operator target ...
                    613: .Xc
                    614: A combination of
                    615: .Ql Ic .else
                    616: followed by
                    617: .Ql Ic .ifmake .
                    618: .It Xo
                    619: .Ic .elifnmake
                    620: .Oo \&! Oc Ns Ar target
                    621: .Op Ar operator target ...
                    622: .Xc
                    623: A combination of
                    624: .Ql Ic .else
                    625: followed by
                    626: .Ql Ic .ifnmake .
                    627: .It Ic .endif
                    628: End the body of the conditional.
                    629: .El
                    630: .Pp
                    631: The
                    632: .Ar operator
                    633: may be any one of the following:
                    634: .Bl -tag -width "Cm XX"
                    635: .It Cm \&|\&|
                    636: logical OR
                    637: .It Cm \&&&
                    638: Logical
                    639: .Tn AND ;
                    640: of higher precedence than
                    641: .Dq .
                    642: .El
                    643: .Pp
                    644: As in C,
                    645: .Nm make
                    646: will only evaluate a conditional as far as is necessary to determine
                    647: its value.
                    648: Parenthesis may be used to change the order of evaluation.
                    649: The boolean operator
                    650: .Ql Ic \&!
                    651: may be used to logically negate an entire
                    652: conditional.
                    653: It is of higher precedence than
                    654: .Ql Ic \&&& .
                    655: .Pp
                    656: The value of
                    657: .Ar expression
                    658: may be any of the following:
                    659: .Bl -tag -width Ic defined
                    660: .It Ic defined
                    661: Takes a variable name as an argument and evaluates to true if the variable
                    662: has been defined.
                    663: .It Ic make
                    664: Takes a target name as an argument and evaluates to true if the target
                    665: was specified as part of
                    666: .Nm make Ns 's
                    667: command line or was declared the default target (either implicitly or
                    668: explicitly, see
                    669: .Va .MAIN )
                    670: before the line containing the conditional.
                    671: .It Ic empty
                    672: Takes a variable, with possible modifiers, and evaluates to true if
                    673: the expansion of the variable would result in an empty string.
                    674: .It Ic exists
                    675: Takes a file name as an argument and evaluates to true if the file exists.
                    676: The file is searched for on the system search path (see
                    677: .Va .PATH ) .
                    678: .It Ic target
                    679: Takes a target name as an argument and evaluates to true if the target
                    680: has been defined.
                    681: .El
                    682: .Pp
                    683: .Ar Expression
                    684: may also be an arithmetic or string comparison.  Variable expansion is
                    685: performed on both sides of the comparison, after which the integral
                    686: values are compared.  A value is interpreted as hexadecimal if it is
                    687: preceded by 0x, otherwise it is decimal; octal numbers are not supported.
                    688: The standard C relational operators are all supported.  If after
                    689: variable expansion, either the left or right hand side of a
                    690: .Ql Ic ==
                    691: or
                    692: .Ql Ic "!="
                    693: operator is not an integral value, then
                    694: string comparison is performed between the expanded
                    695: variables.
                    696: If no relational operator is given, it is assumed that the expanded
                    697: variable is being compared against 0.
                    698: .Pp
                    699: When
                    700: .Nm make
                    701: is evaluating one of these conditional expression, and it encounters
                    702: a word it doesn't recognize, either the ``make'' or ``defined''
                    703: expression is applied to it, depending on the form of the conditional.
                    704: If the form is
                    705: .Ql Ic .ifdef
                    706: or
                    707: .Ql Ic .ifndef ,
                    708: the ``defined'' expression
                    709: is applied.
                    710: Similarly, if the form is
                    711: .Ql Ic .ifmake
                    712: or
                    713: .Ql Ic .ifnmake , the ``make''
                    714: expression is applied.
                    715: .Pp
                    716: If the conditional evaluates to true the parsing of the makefile continues
                    717: as before.
                    718: If it evaluates to false, the following lines are skipped.
                    719: In both cases this continues until a
                    720: .Ql Ic .else
                    721: or
                    722: .Ql Ic .endif
                    723: is found.
                    724: .Pp
                    725: For loops are typically used to apply a set of rules to a list of files.
                    726: The syntax of a for loop is:
                    727: .Bl -tag -width Ds
                    728: .It Xo
                    729: .Ic \&.for
                    730: .Ar variable
                    731: .Ic in
                    732: .Ar expression
                    733: .Xc
                    734: .It Xo
                    735: <make-rules>
                    736: .Xc
                    737: .It Xo
                    738: .Ic \&.endfor
                    739: .Xc
                    740: .El
                    741: After the for
                    742: .Ic expression
                    743: is evaluated, it is split into words. The
                    744: iteration
                    745: .Ic variable
                    746: is successively set to each word, and substituted in the
                    747: .Ic make-rules
                    748: inside the body of the for loop.
                    749: .Sh COMMENTS
                    750: Comments begin with a hash
                    751: .Pq Ql \&#
                    752: character, anywhere but in a shell
                    753: command line, and continue to the end of the line.
                    754: .Sh SPECIAL SOURCES
                    755: .Bl -tag -width Ic .IGNORE
                    756: .It Ic .IGNORE
                    757: Ignore any errors from the commands associated with this target, exactly
                    758: as if they all were preceded by a dash
                    759: .Pq Ql \- .
                    760: .It Ic .MAKE
                    761: Execute the commands associated with this target even if the
                    762: .Fl n
                    763: or
                    764: .Fl t
                    765: options were specified.
                    766: Normally used to mark recursive
                    767: .Nm make Ns 's .
                    768: .It Ic .NOTMAIN
                    769: Normally
                    770: .Nm make
                    771: selects the first target it encounters as the default target to be built
                    772: if no target was specified.
                    773: This source prevents this target from being selected.
                    774: .It Ic .OPTIONAL
                    775: If a target is marked with this attribute and
                    776: .Nm make
                    777: can't figure out how to create it, it will ignore this fact and assume
                    778: the file isn't needed or already exists.
                    779: .It Ic .PRECIOUS
                    780: When
                    781: .Nm make
                    782: is interrupted, it removes any partially made targets.
                    783: This source prevents the target from being removed.
                    784: .It Ic .SILENT
                    785: Do not echo any of the commands associated with this target, exactly
                    786: as if they all were preceded by an at sign
                    787: .Pq Ql @ .
                    788: .It Ic .USE
                    789: Turn the target into
                    790: .Nm make Ns 's .
                    791: version of a macro.
                    792: When the target is used as a source for another target, the other target
                    793: acquires the commands, sources, and attributes (except for
                    794: .Ic .USE )
                    795: of the
                    796: source.
                    797: If the target already has commands, the
                    798: .Ic .USE
                    799: target's commands are appended
                    800: to them.
1.4       deraadt   801: .It Ic .WAIT
                    802: If special
                    803: .Ic .WAIT
                    804: source is appears in a dependency line, the sources that precede it are
                    805: made before the sources that succeed it in the line. Loops are not being
                    806: detected and targets that form loops will be silently ignored.
1.1       deraadt   807: .El
                    808: .Sh "SPECIAL TARGETS"
                    809: Special targets may not be included with other targets, i.e. they must be
                    810: the only target specified.
                    811: .Bl -tag -width Ic .BEGIN
                    812: .It Ic .BEGIN
                    813: Any command lines attached to this target are executed before anything
                    814: else is done.
                    815: .It Ic .DEFAULT
                    816: This is sort of a
                    817: .Ic .USE
                    818: rule for any target (that was used only as a
                    819: source) that
                    820: .Nm make
                    821: can't figure out any other way to create.
                    822: Only the shell script is used.
                    823: The
                    824: .Ic .IMPSRC
                    825: variable of a target that inherits
                    826: .Ic .DEFAULT Ns 's
                    827: commands is set
                    828: to the target's own name.
                    829: .It Ic .END
                    830: Any command lines attached to this target are executed after everything
                    831: else is done.
                    832: .It Ic .IGNORE
                    833: Mark each of the sources with the
                    834: .Ic .IGNORE
                    835: attribute.
                    836: If no sources are specified, this is the equivalent of specifying the
                    837: .Fl i
                    838: option.
                    839: .It Ic .INTERRUPT
                    840: If
                    841: .Nm make
                    842: is interrupted, the commands for this target will be executed.
                    843: .It Ic .MAIN
                    844: If no target is specified when
                    845: .Nm make
                    846: is invoked, this target will be built.
                    847: .It Ic .MAKEFLAGS
                    848: This target provides a way to specify flags for
                    849: .Nm make
                    850: when the makefile is used.
                    851: The flags are as if typed to the shell, though the
                    852: .Fl f
                    853: option will have
                    854: no effect.
1.4       deraadt   855: .\" XXX: NOT YET!!!!
                    856: .\" .It Ic .NOTPARALLEL
                    857: .\" The named targets are executed in non parallel mode. If no targets are
                    858: .\" specified, then all targets are executed in non parallel mode.
                    859: .It Ic .NOTPARALLEL
                    860: Disable parallel mode.
                    861: .It Ic .NO_PARALLEL
                    862: Same as above, for compatibility with other pmake variants.
                    863: .It Ic .ORDER
                    864: The named targets are made in sequence.
                    865: .\" XXX: NOT YET!!!!
                    866: .\" .It Ic .PARALLEL
                    867: .\" The named targets are executed in parallel mode. If no targets are
                    868: .\" specified, then all targets are executed in parallel mode.
1.1       deraadt   869: .It Ic .PATH
                    870: The sources are directories which are to be searched for files not
                    871: found in the current directory.
                    872: If no sources are specified, any previously specified directories are
                    873: deleted.
                    874: .It Ic .PRECIOUS
                    875: Apply the
                    876: .Ic .PRECIOUS
                    877: attribute to any specified sources.
                    878: If no sources are specified, the
                    879: .Ic .PRECIOUS
                    880: attribute is applied to every
                    881: target in the file.
                    882: .It Ic .SILENT
                    883: Apply the
                    884: .Ic .SILENT
                    885: attribute to any specified sources.
                    886: If no sources are specified, the
                    887: .Ic .SILENT
                    888: attribute is applied to every
                    889: command in the file.
                    890: .It Ic .SUFFIXES
                    891: Each source specifies a suffix to
                    892: .Nm make .
                    893: If no sources are specified, any previous specified suffices are deleted.
                    894: .Sh ENVIRONMENT
                    895: .Nm Make
                    896: utilizes the following environment variables, if they exist:
                    897: .Ev MAKE ,
                    898: .Ev MAKEFLAGS
                    899: and
                    900: .Ev MAKEOBJDIR .
                    901: .Sh FILES
                    902: .Bl -tag -width /usr/share/mk -compact
                    903: .It .depend
                    904: list of dependencies
                    905: .It Makefile
                    906: list of dependencies
                    907: .It makefile
                    908: list of dependencies
                    909: .It sys.mk
                    910: system makefile
                    911: .It /usr/share/mk
                    912: system makefile directory
                    913: .El
                    914: .Sh SEE ALSO
                    915: .Xr mkdep 1
                    916: .Sh HISTORY
                    917: A
                    918: .Nm Make
                    919: command appeared in
                    920: .At v7 .