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

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