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

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

CVSweb <webmaster@jp.NetBSD.org>