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

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

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

CVSweb <webmaster@jp.NetBSD.org>