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

1.44    ! deraadt     1: .\"    $OpenBSD: make.1,v 1.43 2002/03/06 17:48:33 espie Exp $
1.40      espie       2: .\"    $OpenPackages$
1.10      millert     3: .\"    $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $
1.7       briggs      4: .\"
1.9       millert     5: .\" Copyright (c) 1990, 1993
                      6: .\"    The Regents of the University of California.  All rights reserved.
1.1       deraadt     7: .\"
                      8: .\" Redistribution and use in source and binary forms, with or without
                      9: .\" modification, are permitted provided that the following conditions
                     10: .\" are met:
                     11: .\" 1. Redistributions of source code must retain the above copyright
                     12: .\"    notice, this list of conditions and the following disclaimer.
                     13: .\" 2. Redistributions in binary form must reproduce the above copyright
                     14: .\"    notice, this list of conditions and the following disclaimer in the
                     15: .\"    documentation and/or other materials provided with the distribution.
                     16: .\" 3. All advertising materials mentioning features or use of this software
                     17: .\"    must display the following acknowledgement:
                     18: .\"    This product includes software developed by the University of
                     19: .\"    California, Berkeley and its contributors.
                     20: .\" 4. Neither the name of the University nor the names of its contributors
                     21: .\"    may be used to endorse or promote products derived from this software
                     22: .\"    without specific prior written permission.
                     23: .\"
                     24: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34: .\" SUCH DAMAGE.
                     35: .\"
1.9       millert    36: .\"    from: @(#)make.1        8.4 (Berkeley) 3/19/94
1.1       deraadt    37: .\"
1.9       millert    38: .Dd March 19, 1994
1.1       deraadt    39: .Dt MAKE 1
                     40: .Os
                     41: .Sh NAME
                     42: .Nm make
                     43: .Nd maintain program dependencies
                     44: .Sh SYNOPSIS
1.19      aaron      45: .Nm make
1.15      espie      46: .Op Fl BPSeiknqrst
1.1       deraadt    47: .Op Fl D Ar variable
                     48: .Op Fl d Ar flags
                     49: .Op Fl f Ar makefile
                     50: .Op Fl I Ar directory
                     51: .Bk -words
                     52: .Op Fl j Ar max_jobs
1.5       niklas     53: .Op Fl m Ar directory
1.1       deraadt    54: .Ek
1.9       millert    55: .Op Fl V Ar variable
1.19      aaron      56: .Op Ar variable Ns No = Ns Ar value
1.1       deraadt    57: .Op Ar target ...
                     58: .Sh DESCRIPTION
1.19      aaron      59: .Nm
1.1       deraadt    60: is a program designed to simplify the maintenance of other programs.
                     61: Its input is a list of specifications as to the files upon which programs
                     62: and other files depend.
                     63: If the file
1.40      espie      64: .Ql Pa BSDmakefile
1.12      niklas     65: exists, it is read for this list of specifications.
                     66: If it does not exist, the files
1.40      espie      67: .Ql Pa makefile
1.12      niklas     68: and
1.40      espie      69: .Ql Pa Makefile
1.12      niklas     70: are tried in order.
1.1       deraadt    71: If the file
1.40      espie      72: .Ql Pa .depend
                     73: exists, it is read in addition to the makefile (see
1.42      mpech      74: .Xr mkdep 1 ) .
1.1       deraadt    75: .Pp
1.43      espie      76: The handling of
                     77: .Ql Pa BSDmakefile
                     78: and
                     79: .Ql Pa .depend
                     80: are BSD extensions.
                     81: .Pp
                     82: Standard options are as follows:
                     83: .Bl -tag -width Ds
                     84: .It Fl e
                     85: Specify that environment variables override macro assignments within
                     86: makefiles.
                     87: .It Fl f Ar makefile
                     88: Specify a makefile to read instead of the default
                     89: .Ql Pa makefile
                     90: and
                     91: .Ql Pa Makefile .
                     92: If
                     93: .Ar makefile
                     94: is
                     95: .Ql \- ,
                     96: standard input is read.
                     97: Multiple makefiles may be specified, and are read in the order specified.
                     98: .It Fl i
                     99: Ignore non-zero exit of shell commands in the makefile.
                    100: Equivalent to specifying
                    101: .Ql \-
                    102: before each command line in the makefile.
                    103: .It Fl k
                    104: Continue processing after errors are encountered, but only on those targets
                    105: that do not depend on the target whose creation caused the error.
                    106: .It Fl n
                    107: Display the commands that would have been executed, but do not actually
                    108: execute them.
                    109: .It Fl q
                    110: Do not execute any commands, but exit with status 0 if the specified targets
                    111: are up-to-date, and 1 otherwise.
                    112: .It Fl r
                    113: Do not use the built-in rules specified in the system makefile.
                    114: .It Fl S
                    115: Stop processing when an error is encountered.
                    116: This is the default behavior.
                    117: This is needed to negate the
                    118: .Fl k
                    119: option during recursive builds.
                    120: .It Fl s
                    121: Do not echo commands as they are executed.
                    122: Equivalent to specifying
                    123: .Ql Ic @
                    124: before each command line in the makefile.
                    125: .It Fl t
                    126: Rather than re-building a target as specified in the makefile, create it
                    127: or update its modification time to make it appear up-to-date.
                    128: .It Ar variable Ns No = Ns Ar value
                    129: Set the value of the variable
                    130: .Ar variable
                    131: to
                    132: .Ar value .
                    133: .El
1.1       deraadt   134: .Pp
1.43      espie     135: Extended options are as follows:
1.1       deraadt   136: .Bl -tag -width Ds
1.9       millert   137: .It Fl B
1.3       deraadt   138: Try to be backwards compatible by executing a single shell per command and
                    139: by executing the commands to make the sources of a dependency line in sequence.
1.15      espie     140: This is turned on by default unless
                    141: .Fl j
                    142: is used.
1.1       deraadt   143: .It Fl D Ar variable
                    144: Define
                    145: .Ar variable
1.40      espie     146: to be 1.
1.1       deraadt   147: .It Fl d Ar flags
                    148: Turn on debugging, and specify which portions of
1.19      aaron     149: .Nm
1.1       deraadt   150: are to print debugging information.
1.14      aaron     151: .Ar flags
1.1       deraadt   152: is one or more of the following:
                    153: .Bl -tag -width Ds
                    154: .It Ar A
                    155: Print all possible debugging information;
                    156: equivalent to specifying all of the debugging flags.
                    157: .It Ar a
                    158: Print debugging information about archive searching and caching.
                    159: .It Ar c
                    160: Print debugging information about conditional evaluation.
                    161: .It Ar d
                    162: Print debugging information about directory searching and caching.
1.15      espie     163: .It Ar f
1.40      espie     164: Print debugging information about the expansion of for loops.
1.1       deraadt   165: .It Ar "g1"
                    166: Print the input graph before making anything.
                    167: .It Ar "g2"
                    168: Print the input graph after making everything, or before exiting
                    169: on error.
                    170: .It Ar j
                    171: Print debugging information about running multiple shells.
1.40      espie     172: .It Ar l
                    173: Print commands in Makefile targets regardless of whether or not they are
                    174: prefixed by @.
                    175: Also known as loud behavior.
1.1       deraadt   176: .It Ar m
                    177: Print debugging information about making targets, including modification
                    178: dates.
                    179: .It Ar s
                    180: Print debugging information about suffix-transformation rules.
                    181: .It Ar t
                    182: Print debugging information about target list maintenance.
                    183: .It Ar v
                    184: Print debugging information about variable assignment.
                    185: .El
                    186: .It Fl I Ar directory
                    187: Specify a directory in which to search for makefiles and included makefiles.
1.5       niklas    188: The system makefile directory (or directories, see the
                    189: .Fl m
                    190: option) is automatically included as part of this list.
1.1       deraadt   191: .It Fl j Ar max_jobs
                    192: Specify the maximum number of jobs that
1.19      aaron     193: .Nm
1.28      aaron     194: may have running at any one time.
                    195: Turns compatibility mode off, unless the
1.3       deraadt   196: .Ar B
                    197: flag is also specified.
1.5       niklas    198: .It Fl m Ar directory
1.40      espie     199: Specify a directory in which to search for
                    200: .Pa sys.mk
                    201: and makefiles included
1.28      aaron     202: via the <...> style.
                    203: Multiple directories can be added to form a search path.
1.14      aaron     204: This path will override the default system include path:
                    205: .Pa /usr/share/mk .
                    206: Furthermore, the system include path will be appended to the search path used
1.5       niklas    207: for "..."-style inclusions (see the
                    208: .Fl I
                    209: option).
1.15      espie     210: .It Fl P
1.19      aaron     211: Collate the output of a given job and display it only when the job finishes,
                    212: instead of mixing the output of parallel jobs together.
                    213: This option has no effect unless
1.15      espie     214: .Fl j
                    215: is used too.
1.9       millert   216: .It Fl V Ar variable
                    217: Print
                    218: .Nm make Ns 's
                    219: idea of the value of
1.40      espie     220: .Ar variable .
1.9       millert   221: Do not build any targets.
                    222: Multiple instances of this option may be specified;
                    223: the variables will be printed one per line,
                    224: with a blank line for each null or undefined variable.
1.1       deraadt   225: .El
                    226: .Pp
                    227: There are seven different types of lines in a makefile: file dependency
                    228: specifications, shell commands, variable assignments, include statements,
                    229: conditional directives, for loops, and comments.
1.43      espie     230: Of these, include statements, conditional directives and for loops are
                    231: extensions.
1.1       deraadt   232: .Pp
                    233: In general, lines may be continued from one line to the next by ending
                    234: them with a backslash
                    235: .Pq Ql \e .
                    236: The trailing newline character and initial whitespace on the following
                    237: line are compressed into a single space.
                    238: .Sh FILE DEPENDENCY SPECIFICATIONS
                    239: Dependency lines consist of one or more targets, an operator, and zero
                    240: or more sources.
1.19      aaron     241: This creates a relationship where the targets
                    242: .Dq depend
                    243: on the sources
1.1       deraadt   244: and are usually created from them.
                    245: The exact relationship between the target and the source is determined
                    246: by the operator that separates them.
1.43      espie     247: Note that the use of several targets is merely a shorthand for duplicate
                    248: rules.
                    249: Specifically,
                    250: .Bd -literal
                    251: target1 target2: depa depb
                    252:        cmd1
                    253:        cmd2
                    254: .Ed
                    255: is just a short form of
                    256: .Bd -literal
                    257: target1: depa depb
                    258:        cmd1
                    259:        cmd2
                    260: target2: depa depb
                    261:        cmd1
                    262:        cmd2
                    263: .Ed
                    264: .Pp
                    265: .Nm
                    266: does not support Solaris syntax for true multiple targets:
                    267: .Bd -literal
                    268: target1 + target2: depa depb
                    269:        cmd1
                    270:        cmd2
                    271: .Ed
                    272: .Pp
1.40      espie     273: The operators are as follows:
1.1       deraadt   274: .Bl -tag -width flag
                    275: .It Ic \&:
                    276: A target is considered out-of-date if its modification time is less than
                    277: those of any of its sources.
                    278: Sources for a target accumulate over dependency lines when this operator
                    279: is used.
                    280: The target is removed if
1.19      aaron     281: .Nm
1.1       deraadt   282: is interrupted.
                    283: .It Ic \&!
                    284: Targets are always re-created, but not until all sources have been
                    285: examined and re-created as necessary.
                    286: Sources for a target accumulate over dependency lines when this operator
                    287: is used.
                    288: The target is removed if
1.19      aaron     289: .Nm
1.1       deraadt   290: is interrupted.
                    291: .It Ic \&::
                    292: If no sources are specified, the target is always re-created.
                    293: Otherwise, a target is considered out-of-date if any of its sources has
                    294: been modified more recently than the target.
                    295: Sources for a target do not accumulate over dependency lines when this
                    296: operator is used.
                    297: The target will not be removed if
1.19      aaron     298: .Nm
1.1       deraadt   299: is interrupted.
                    300: .El
                    301: .Pp
1.43      espie     302: The
                    303: .Ic \&::
                    304: operator is a fairly standard extension.
                    305: The
                    306: .Ic \&!
                    307: operator is a BSD extension.
                    308: .Pp
                    309: As an extension, targets and sources may contain the shell wildcard
                    310: expressions
1.1       deraadt   311: .Ql ? ,
                    312: .Ql * ,
                    313: .Ql []
                    314: and
                    315: .Ql {} .
1.15      espie     316: The expressions
1.1       deraadt   317: .Ql ? ,
                    318: .Ql *
                    319: and
                    320: .Ql []
                    321: may only be used as part of the final
                    322: component of the target or source, and must be used to describe existing
                    323: files.
1.15      espie     324: The expression
1.1       deraadt   325: .Ql {}
                    326: need not necessarily be used to describe existing files.
                    327: Expansion is in directory order, not alphabetically as done in the shell.
1.43      espie     328: .Pp
                    329: For maximum portability, target names should only consist of periods,
                    330: underscores, digits and alphabetic characters.
1.1       deraadt   331: .Sh SHELL COMMANDS
                    332: Each target may have associated with it a series of shell commands, normally
                    333: used to create the target.
                    334: Each of the commands in this script
                    335: .Em must
                    336: be preceded by a tab.
                    337: While any target may appear on a dependency line, only one of these
                    338: dependencies may be followed by a creation script, unless the
                    339: .Ql Ic ::
                    340: operator is used.
                    341: .Pp
1.34      espie     342: If a command line begins with a combination of the characters,
1.33      espie     343: .Ql Ic @ ,
                    344: .Ql Ic \-
1.1       deraadt   345: and/or
1.33      espie     346: .Ql Ic + ,
1.1       deraadt   347: the command is treated specially.
1.33      espie     348: .Bl -tag -width `@'
                    349: .It Ql Ic @
1.1       deraadt   350: causes the command not to be echoed before it is executed.
1.33      espie     351: .It Ql Ic \-
1.1       deraadt   352: causes any non-zero exit status of the command line to be ignored.
1.33      espie     353: .It Ql Ic +
                    354: causes the command to be executed even if
                    355: .Fl n
                    356: has been specified (This can be useful to debug recursive Makefiles).
                    357: .El
1.43      espie     358: .Pp
                    359: The command is always executed using
                    360: .Pa /bin/sh
                    361: in
                    362: .Qq set -e
                    363: mode.
1.1       deraadt   364: .Sh VARIABLE ASSIGNMENTS
1.14      aaron     365: Variables in
1.19      aaron     366: .Nm
1.14      aaron     367: are much like variables in the shell, and, by tradition,
1.1       deraadt   368: consist of all upper-case letters.
1.43      espie     369: For portability, only periods, underscores, digits and letters should be
                    370: used for variable names.
1.1       deraadt   371: The five operators that can be used to assign values to variables are as
                    372: follows:
                    373: .Bl -tag -width Ds
                    374: .It Ic \&=
                    375: Assign the value to the variable.
                    376: Any previous value is overridden.
1.43      espie     377: .It Ic \&:=
                    378: Assign with expansion, i.e., expand the value before assigning it
                    379: to the variable (extension)
1.1       deraadt   380: .It Ic \&+=
1.43      espie     381: Append the value to the current value of the variable (extension).
1.1       deraadt   382: .It Ic \&?=
1.43      espie     383: Assign the value to the variable if it is not already defined (BSD
                    384: extension).
1.1       deraadt   385: Normally, expansion is not done until the variable is referenced.
                    386: .It Ic \&!=
                    387: Expand the value and pass it to the shell for execution and assign
                    388: the result to the variable.
1.43      espie     389: Any newlines in the result are replaced with spaces (BSD extension).
1.1       deraadt   390: .El
                    391: .Pp
1.14      aaron     392: Any whitespace before the assigned
1.1       deraadt   393: .Ar value
                    394: is removed; if the value is being appended, a single space is inserted
                    395: between the previous contents of the variable and the appended value.
                    396: .Pp
                    397: Variables are expanded by surrounding the variable name with either
                    398: curly braces
                    399: .Pq Ql {}
                    400: or parentheses
                    401: .Pq Ql ()
                    402: and preceding it with
                    403: a dollar sign
                    404: .Pq Ql \&$ .
                    405: If the variable name contains only a single letter, the surrounding
                    406: braces or parentheses are not required.
                    407: This shorter form is not recommended.
                    408: .Pp
                    409: Variable substitution occurs at two distinct times, depending on where
                    410: the variable is being used.
                    411: Variables in dependency lines are expanded as the line is read.
                    412: Variables in shell commands are expanded when the shell command is
                    413: executed.
                    414: .Pp
                    415: The four different classes of variables (in order of increasing precedence)
                    416: are:
                    417: .Bl -tag -width Ds
                    418: .It Environment variables
                    419: Variables defined as part of
                    420: .Nm make Ns 's
                    421: environment.
                    422: .It Global variables
                    423: Variables defined in the makefile or in included makefiles.
                    424: .It Command line variables
                    425: Variables defined as part of the command line.
                    426: .It Local variables
                    427: Variables that are defined specific to a certain target.
1.43      espie     428: Standard local variables are as follows:
1.1       deraadt   429: .Bl -tag -width ".ARCHIVE"
1.43      espie     430: .It Va @
                    431: The name of the target.
                    432: .It Va \&%
                    433: The name of the archive member (only valid for library rules).
                    434: .It Va \&!
                    435: The name of the archive file (only valid for library rules).
                    436: .It Va \&?
                    437: The list of prerequisites for this target that were deemed out-of-date.
                    438: .It Va \&<
                    439: The name of the source from which this target is to be built, if a valid
                    440: implied rule (suffix rule) is in scope.
                    441: .It Va *
                    442: The file prefix of the file, containing only the file portion,
                    443: no suffix or preceding directory components.
                    444: .El
                    445: .Pp
                    446: The six variables
                    447: .Ql Va "@F" ,
                    448: .Ql Va "@D" ,
                    449: .Ql Va "<F" ,
                    450: .Ql Va "<D" ,
                    451: .Ql Va "*F" ,
                    452: and
                    453: .Ql Va "*D"
                    454: yield the
                    455: .Qq filename
                    456: and
                    457: .Qq directory
                    458: parts of the corresponding macros.
                    459: .Pp
                    460: For maximum compatibility,
                    461: .Ql Va \&<
                    462: should only be used for actual implied rules.
                    463: It is also set when there is an implied rule that matches the current
                    464: dependency in scope. That is, in
                    465: .Bd -literal
                    466: \&.SUFFIXES: .c.o
                    467: file.o: file.c
                    468:        cmd1 $<
                    469:
                    470: \&.c.o:
                    471:        cmd2
                    472: .Ed
                    473: building
                    474: .Pa file.o
                    475: will execute
                    476: .Qq cmd1 file.c .
                    477:
                    478: .Pp
                    479: As an extension,
                    480: .Nm
                    481: sports the following local variables:
                    482: .Bl -tag -width ".ARCHIVE"
                    483: .It Va \&>
                    484: The list of all sources for this target.
1.1       deraadt   485: .It Va .ALLSRC
1.43      espie     486: Synonym for
1.1       deraadt   487: .Ql Va \&> .
                    488: .It Va .ARCHIVE
1.43      espie     489: Synonym for
1.15      espie     490: .Ql Va \&! .
1.1       deraadt   491: .It Va .IMPSRC
1.43      espie     492: Synonym for
1.1       deraadt   493: .Ql Va \&< .
                    494: .It Va .MEMBER
1.43      espie     495: Synonym for
1.15      espie     496: .Ql Va \&% .
1.1       deraadt   497: .It Va .OODATE
1.43      espie     498: Synonym for
1.1       deraadt   499: .Ql Va \&? .
                    500: .It Va .PREFIX
1.43      espie     501: Synonym for
1.1       deraadt   502: .Ql Va * .
                    503: .It Va .TARGET
1.43      espie     504: Synonym for
1.1       deraadt   505: .Ql Va @ .
                    506: .El
                    507: .Pp
1.43      espie     508: These variables may be used on the dependency half of dependency
                    509: lines, when they make sense.
1.15      espie     510: .El
1.1       deraadt   511: .Pp
                    512: In addition,
1.19      aaron     513: .Nm
                    514: sets or knows about the following internal variables, or environment
1.15      espie     515: variables:
1.1       deraadt   516: .Bl -tag -width MAKEFLAGS
                    517: .It Va \&$
                    518: A single dollar sign
                    519: .Ql \&$ ,
1.29      aaron     520: i.e.,
1.1       deraadt   521: .Ql \&$$
                    522: expands to a single dollar
                    523: sign.
                    524: .It Va .MAKE
                    525: The name that
1.19      aaron     526: .Nm
1.1       deraadt   527: was executed with
1.14      aaron     528: .Pq Va argv Ns Op 0 .
1.1       deraadt   529: .It Va .CURDIR
                    530: A path to the directory where
1.19      aaron     531: .Nm
1.1       deraadt   532: was executed.
                    533: .It Va .OBJDIR
                    534: A path to the directory where the targets are built.
1.8       deraadt   535: At startup,
1.19      aaron     536: .Nm
1.8       deraadt   537: searches for an alternate directory to place target files -- it
                    538: will attempt to change into this special directory.
1.19      aaron     539: First, if
                    540: .Ev MAKEOBJDIRPREFIX
                    541: is defined,
                    542: .Nm
1.18      espie     543: prepends its contents to the current directory name and tries for
1.28      aaron     544: the resulting directory.
                    545: If that fails,
1.19      aaron     546: .Nm
1.18      espie     547: remains in the current directory.
1.19      aaron     548: If
1.15      espie     549: .Ev MAKEOBJDIRPREFIX
1.18      espie     550: is not defined,
1.19      aaron     551: .Nm
1.18      espie     552: checks
1.19      aaron     553: .Ev MAKEOBJDIR
1.28      aaron     554: and tries to change into that directory.
                    555: Should that fail,
1.19      aaron     556: .Nm
1.28      aaron     557: remains in the current directory.
                    558: If
1.18      espie     559: .Ev MAKEOBJDIR
                    560: is not defined, it tries to change into the directory named
                    561: .Pa obj.${MACHINE}
1.19      aaron     562: (see
                    563: .Va MACHINE
1.28      aaron     564: variable).
                    565: If it still has found no special directory,
1.19      aaron     566: .Nm
1.18      espie     567: next tries the directory named
                    568: .Pa obj .
                    569: If this fails,
1.19      aaron     570: .Nm
                    571: tries to prepend
                    572: .Pa /usr/obj
                    573: to the current directory name.
1.18      espie     574: Finally, if none of these directories are available
1.19      aaron     575: .Nm
1.8       deraadt   576: will settle for and use the current directory.
1.15      espie     577: .It Va .MAKEFLAGS
1.1       deraadt   578: The environment variable
1.14      aaron     579: .Ev MAKEFLAGS
1.1       deraadt   580: may contain anything that
                    581: may be specified on
                    582: .Nm make Ns 's
1.28      aaron     583: command line.
                    584: Its contents are stored in
1.15      espie     585: .Nm make Ns 's
1.19      aaron     586: .Va .MAKEFLAGS
1.15      espie     587: variable.
1.40      espie     588: Anything specified on
1.1       deraadt   589: .Nm make Ns 's
                    590: command line is appended to the
1.15      espie     591: .Va .MAKEFLAGS
                    592: variable which is then
1.19      aaron     593: entered into the environment as
1.14      aaron     594: .Ev MAKEFLAGS
1.15      espie     595: for all programs which
1.19      aaron     596: .Nm
1.1       deraadt   597: executes.
1.15      espie     598: .It Va MFLAGS
1.19      aaron     599: A shorter synonym for
1.15      espie     600: .Va .MAKEFLAGS .
1.9       millert   601: .It Ev PWD
                    602: Alternate path to the current directory.
1.19      aaron     603: .Nm
1.9       millert   604: normally sets
                    605: .Ql Va .CURDIR
                    606: to the canonical path given by
                    607: .Xr getcwd 2 .
                    608: However, if the environment variable
1.14      aaron     609: .Ev PWD
1.9       millert   610: is set and gives a path to the current directory, then
1.19      aaron     611: .Nm
1.9       millert   612: sets
                    613: .Ql Va .CURDIR
                    614: to the value of
1.14      aaron     615: .Ev PWD
1.9       millert   616: instead.
1.14      aaron     617: .Ev PWD
1.15      espie     618: is always set to the value of
1.9       millert   619: .Ql Va .OBJDIR
                    620: for all programs which
1.19      aaron     621: .Nm
1.9       millert   622: executes.
1.15      espie     623: .It Va .TARGETS
1.19      aaron     624: List of targets
                    625: .Nm
1.18      espie     626: is currently building.
1.15      espie     627: .It Va .INCLUDES
1.19      aaron     628: See
1.18      espie     629: .Ic .INCLUDES
                    630: special target
1.15      espie     631: .It Va .LIBS
1.19      aaron     632: See
1.18      espie     633: .Ic .LIBS
                    634: special target
1.15      espie     635: .It Va MACHINE
1.19      aaron     636: Name of the machine architecture
                    637: .Nm
1.18      espie     638: is running on, obtained from the
                    639: .Ev MACHINE
1.19      aaron     640: environment variable, or through
1.44    ! deraadt   641: .Xr uname 3
1.18      espie     642: if not defined.
1.15      espie     643: .It Va MACHINE_ARCH
1.18      espie     644: Name of the machine architecture
1.19      aaron     645: .Nm
1.18      espie     646: was compiled for, obtained from the
1.19      aaron     647: .Ev MACHINE_ARCH
1.18      espie     648: environment variable, or defined at compilation time.
1.1       deraadt   649: .El
                    650: .Pp
                    651: Variable expansion may be modified to select or modify each word of the
1.19      aaron     652: variable (where a
                    653: .Dq word
                    654: is whitespace delimited sequence of characters).
1.1       deraadt   655: The general format of a variable expansion is as follows:
                    656: .Pp
                    657: .Dl {variable[:modifier[:...]]}
                    658: .Pp
                    659: Each modifier begins with a colon and one of the following
                    660: special characters.
                    661: The colon may be escaped with a backslash
                    662: .Pq Ql \e .
                    663: .Bl -tag -width Cm E\&
                    664: .It Cm E
                    665: Replaces each word in the variable with its suffix.
                    666: .It Cm H
                    667: Replaces each word in the variable with everything but the last component.
1.20      espie     668: .It Cm L
                    669: Replaces each word in the variable with its lower case equivalent.
                    670: .It Cm U
                    671: Replaces each word in the variable with its upper case equivalent.
1.1       deraadt   672: .It Cm M Ns Ar pattern
                    673: Select only those words that match the rest of the modifier.
                    674: The standard shell wildcard characters
                    675: .Pf ( Ql * ,
                    676: .Ql ? ,
                    677: and
                    678: .Ql Op )
                    679: may
                    680: be used.
                    681: The wildcard characters may be escaped with a backslash
                    682: .Pq Ql \e .
                    683: .It Cm N Ns Ar pattern
                    684: This is identical to
1.14      aaron     685: .Cm M ,
1.1       deraadt   686: but selects all words which do not match
                    687: the rest of the modifier.
1.10      millert   688: .It Cm Q
                    689: Quotes every shell meta-character in the variable, so that it can be passed
                    690: safely through recursive invocations of
1.14      aaron     691: .Nm make .
1.1       deraadt   692: .It Cm R
                    693: Replaces each word in the variable with everything but its suffix.
                    694: .Sm off
1.10      millert   695: .It Cm S No \&/ Ar old_string Xo
                    696: .No \&/ Ar new_string
                    697: .No \&/ Op Cm 1g
1.1       deraadt   698: .Xc
                    699: .Sm on
                    700: Modify the first occurrence of
1.10      millert   701: .Ar old_string
                    702: in the variable's value, replacing it with
                    703: .Ar new_string .
1.1       deraadt   704: If a
                    705: .Ql g
                    706: is appended to the last slash of the pattern, all occurrences
                    707: in each word are replaced.
1.10      millert   708: If a
                    709: .Ql 1
                    710: is appended to the last slash of the pattern, only the first word
                    711: is affected.
1.1       deraadt   712: If
1.10      millert   713: .Ar old_string
                    714: begins with a caret
1.1       deraadt   715: .Pq Ql ^ ,
1.10      millert   716: .Ar old_string
1.1       deraadt   717: is anchored at the beginning of each word.
                    718: If
1.10      millert   719: .Ar old_string
1.1       deraadt   720: ends with a dollar sign
                    721: .Pq Ql \&$ ,
                    722: it is anchored at the end of each word.
                    723: Inside
                    724: .Ar new_string ,
                    725: an ampersand
                    726: .Pq Ql &
                    727: is replaced by
1.10      millert   728: .Ar old_string
                    729: (without any
                    730: .Ql ^
                    731: or
                    732: .Ql \&$ ) .
1.1       deraadt   733: Any character may be used as a delimiter for the parts of the modifier
                    734: string.
                    735: The anchoring, ampersand and delimiter characters may be escaped with a
                    736: backslash
                    737: .Pq Ql \e .
                    738: .Pp
                    739: Variable expansion occurs in the normal fashion inside both
                    740: .Ar old_string
                    741: and
                    742: .Ar new_string
                    743: with the single exception that a backslash is used to prevent the expansion
                    744: of a dollar sign
1.10      millert   745: .Pq Ql \&$ ,
1.1       deraadt   746: not a preceding dollar sign as is usual.
1.10      millert   747: .Sm off
                    748: .It Cm C No \&/ Ar pattern Xo
                    749: .No \&/ Ar replacement
                    750: .No \&/ Op Cm 1g
                    751: .Xc
                    752: .Sm on
                    753: The
                    754: .Cm C
                    755: modifier is just like the
                    756: .Cm S
1.13      deraadt   757: modifier except that the old and new strings, instead of being
1.10      millert   758: simple strings, are a regular expression (see
                    759: .Xr regex 3 )
                    760: and an
                    761: .Xr ed 1 Ns \-style
1.28      aaron     762: replacement string.
                    763: Normally, the first occurrence of the pattern in
                    764: each word of the value is changed.
                    765: The
1.10      millert   766: .Ql 1
                    767: modifier causes the substitution to apply to at most one word; the
                    768: .Ql g
                    769: modifier causes the substitution to apply to as many instances of the
1.28      aaron     770: search pattern as occur in the word or words it is found in.
                    771: Note that
1.10      millert   772: .Ql 1
                    773: and
                    774: .Ql g
                    775: are orthogonal; the former specifies whether multiple words are
                    776: potentially affected, the latter whether multiple substitutions can
                    777: potentially occur within each affected word.
1.1       deraadt   778: .It Cm T
                    779: Replaces each word in the variable with its last component.
1.39      aaron     780: .It Ar old_string Ns No = Ns Ar new_string
1.1       deraadt   781: This is the
                    782: .At V
                    783: style variable substitution.
                    784: It must be the last modifier specified.
1.9       millert   785: If
1.1       deraadt   786: .Ar old_string
                    787: or
                    788: .Ar new_string
                    789: do not contain the pattern matching character
                    790: .Ar %
1.9       millert   791: then it is assumed that they are
1.1       deraadt   792: anchored at the end of each word, so only suffixes or entire
1.28      aaron     793: words may be replaced.
                    794: Otherwise
1.1       deraadt   795: .Ar %
1.9       millert   796: is the substring of
                    797: .Ar old_string
1.1       deraadt   798: to be replaced in
                    799: .Ar new_string
                    800: .El
                    801: .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1.28      aaron     802: Makefile inclusion, conditional structures and for loops reminiscent
1.1       deraadt   803: of the C programming language are provided in
                    804: .Nm make .
                    805: All such structures are identified by a line beginning with a single
                    806: dot
                    807: .Pq Ql \&.
                    808: character.
                    809: Files are included with either
                    810: .Ql .include <file>
                    811: or
                    812: .Ql .include \*qfile\*q .
                    813: Variables between the angle brackets or double quotes are expanded
                    814: to form the file name.
                    815: If angle brackets are used, the included makefile is expected to be in
                    816: the system makefile directory.
                    817: If double quotes are used, the including makefile's directory and any
                    818: directories specified using the
                    819: .Fl I
                    820: option are searched before the system
                    821: makefile directory.
                    822: .Pp
                    823: Conditional expressions are also preceded by a single dot as the first
                    824: character of a line.
                    825: The possible conditionals are as follows:
                    826: .Bl -tag -width Ds
                    827: .It Ic .undef Ar variable
                    828: Un-define the specified global variable.
                    829: Only global variables may be un-defined.
                    830: .It Xo
                    831: .Ic \&.if
                    832: .Oo \&! Oc Ns Ar expression
                    833: .Op Ar operator expression ...
                    834: .Xc
                    835: Test the value of an expression.
                    836: .It Xo
                    837: .Ic .ifdef
                    838: .Oo \&! Oc Ns Ar variable
                    839: .Op Ar operator variable ...
                    840: .Xc
                    841: Test the value of a variable.
                    842: .It Xo
                    843: .Ic .ifndef
                    844: .Oo \&! Oc Ns Ar variable
                    845: .Op Ar operator variable ...
                    846: .Xc
                    847: Test the value of a variable.
                    848: .It Xo
                    849: .Ic .ifmake
                    850: .Oo \&! Oc Ns Ar target
                    851: .Op Ar operator target ...
                    852: .Xc
                    853: Test the target being built.
                    854: .It Xo
                    855: .Ic .ifnmake
                    856: .Oo \&! Oc Ar target
                    857: .Op Ar operator target ...
                    858: .Xc
                    859: Test the target being built.
                    860: .It Ic .else
                    861: Reverse the sense of the last conditional.
                    862: .It Xo
                    863: .Ic .elif
                    864: .Oo \&! Oc Ar expression
                    865: .Op Ar operator expression ...
                    866: .Xc
                    867: A combination of
                    868: .Ql Ic .else
                    869: followed by
                    870: .Ql Ic .if .
                    871: .It Xo
                    872: .Ic .elifdef
                    873: .Oo \&! Oc Ns Ar variable
                    874: .Op Ar operator variable ...
                    875: .Xc
                    876: A combination of
                    877: .Ql Ic .else
                    878: followed by
                    879: .Ql Ic .ifdef .
                    880: .It Xo
                    881: .Ic .elifndef
                    882: .Oo \&! Oc Ns Ar variable
                    883: .Op Ar operator variable ...
                    884: .Xc
                    885: A combination of
                    886: .Ql Ic .else
                    887: followed by
                    888: .Ql Ic .ifndef .
                    889: .It Xo
                    890: .Ic .elifmake
                    891: .Oo \&! Oc Ns Ar target
                    892: .Op Ar operator target ...
                    893: .Xc
                    894: A combination of
                    895: .Ql Ic .else
                    896: followed by
                    897: .Ql Ic .ifmake .
                    898: .It Xo
                    899: .Ic .elifnmake
                    900: .Oo \&! Oc Ns Ar target
                    901: .Op Ar operator target ...
                    902: .Xc
                    903: A combination of
                    904: .Ql Ic .else
                    905: followed by
                    906: .Ql Ic .ifnmake .
                    907: .It Ic .endif
                    908: End the body of the conditional.
                    909: .El
                    910: .Pp
                    911: The
                    912: .Ar operator
                    913: may be any one of the following:
                    914: .Bl -tag -width "Cm XX"
                    915: .It Cm \&|\&|
                    916: logical OR
                    917: .It Cm \&&&
                    918: Logical
                    919: .Tn AND ;
                    920: of higher precedence than
                    921: .Dq .
                    922: .El
                    923: .Pp
                    924: As in C,
1.19      aaron     925: .Nm
1.1       deraadt   926: will only evaluate a conditional as far as is necessary to determine
                    927: its value.
1.9       millert   928: Parentheses may be used to change the order of evaluation.
1.1       deraadt   929: The boolean operator
                    930: .Ql Ic \&!
                    931: may be used to logically negate an entire
                    932: conditional.
                    933: It is of higher precedence than
                    934: .Ql Ic \&&& .
                    935: .Pp
                    936: The value of
                    937: .Ar expression
                    938: may be any of the following:
                    939: .Bl -tag -width Ic defined
                    940: .It Ic defined
                    941: Takes a variable name as an argument and evaluates to true if the variable
                    942: has been defined.
                    943: .It Ic make
                    944: Takes a target name as an argument and evaluates to true if the target
                    945: was specified as part of
                    946: .Nm make Ns 's
                    947: command line or was declared the default target (either implicitly or
                    948: explicitly, see
                    949: .Va .MAIN )
                    950: before the line containing the conditional.
                    951: .It Ic empty
                    952: Takes a variable, with possible modifiers, and evaluates to true if
                    953: the expansion of the variable would result in an empty string.
                    954: .It Ic exists
                    955: Takes a file name as an argument and evaluates to true if the file exists.
                    956: The file is searched for on the system search path (see
                    957: .Va .PATH ) .
                    958: .It Ic target
                    959: Takes a target name as an argument and evaluates to true if the target
                    960: has been defined.
                    961: .El
                    962: .Pp
1.14      aaron     963: .Ar expression
1.28      aaron     964: may also be an arithmetic or string comparison.
                    965: Variable expansion is
1.1       deraadt   966: performed on both sides of the comparison, after which the integral
1.28      aaron     967: values are compared.
                    968: A value is interpreted as hexadecimal if it is
1.1       deraadt   969: preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1.28      aaron     970: The standard C relational operators are all supported.
                    971: If after
1.1       deraadt   972: variable expansion, either the left or right hand side of a
                    973: .Ql Ic ==
                    974: or
                    975: .Ql Ic "!="
                    976: operator is not an integral value, then
                    977: string comparison is performed between the expanded
                    978: variables.
                    979: If no relational operator is given, it is assumed that the expanded
                    980: variable is being compared against 0.
                    981: .Pp
                    982: When
1.19      aaron     983: .Nm
1.14      aaron     984: is evaluating one of these conditional expressions, and it encounters
1.19      aaron     985: a word it doesn't recognize, either the
                    986: .Dq make
                    987: or
                    988: .Dq defined
1.1       deraadt   989: expression is applied to it, depending on the form of the conditional.
                    990: If the form is
                    991: .Ql Ic .ifdef
                    992: or
                    993: .Ql Ic .ifndef ,
1.19      aaron     994: the
                    995: .Dq defined
                    996: expression is applied.
1.1       deraadt   997: Similarly, if the form is
                    998: .Ql Ic .ifmake
                    999: or
1.14      aaron    1000: .Ql Ic .ifnmake ,
1.19      aaron    1001: the
                   1002: .Dq make
1.1       deraadt  1003: expression is applied.
                   1004: .Pp
                   1005: If the conditional evaluates to true the parsing of the makefile continues
                   1006: as before.
                   1007: If it evaluates to false, the following lines are skipped.
                   1008: In both cases this continues until a
                   1009: .Ql Ic .else
                   1010: or
                   1011: .Ql Ic .endif
                   1012: is found.
1.9       millert  1013: .Pp
1.1       deraadt  1014: For loops are typically used to apply a set of rules to a list of files.
                   1015: The syntax of a for loop is:
                   1016: .Bl -tag -width Ds
                   1017: .It Xo
                   1018: .Ic \&.for
1.9       millert  1019: .Ar variable
1.41      espie    1020: .Op Ar variable ...
1.9       millert  1021: .Ic in
1.1       deraadt  1022: .Ar expression
                   1023: .Xc
                   1024: .It Xo
                   1025: <make-rules>
                   1026: .Xc
                   1027: .It Xo
                   1028: .Ic \&.endfor
                   1029: .Xc
                   1030: .El
                   1031: After the for
1.14      aaron    1032: .Ar expression
1.28      aaron    1033: is evaluated, it is split into words.
1.41      espie    1034: On each iteration of the loop, one word is assigned to each
                   1035: .Ar variable ,
                   1036: in order,
                   1037: and these
                   1038: .Ar variables
                   1039: are substituted in the
1.9       millert  1040: .Ic make-rules
1.1       deraadt  1041: inside the body of the for loop.
1.41      espie    1042: The number of words must match the number of iteration variables;
                   1043: that is, if there are three iteration variables, the number of words
                   1044: must be a multiple a three.
1.1       deraadt  1045: .Sh COMMENTS
                   1046: Comments begin with a hash
                   1047: .Pq Ql \&#
                   1048: character, anywhere but in a shell
                   1049: command line, and continue to the end of the line.
                   1050: .Sh SPECIAL SOURCES
                   1051: .Bl -tag -width Ic .IGNORE
                   1052: .It Ic .IGNORE
                   1053: Ignore any errors from the commands associated with this target, exactly
                   1054: as if they all were preceded by a dash
                   1055: .Pq Ql \- .
1.10      millert  1056: .It Ic .MADE
1.19      aaron    1057: Mark all sources of this target as being up-to-date.
1.1       deraadt  1058: .It Ic .MAKE
                   1059: Execute the commands associated with this target even if the
                   1060: .Fl n
                   1061: or
                   1062: .Fl t
                   1063: options were specified.
                   1064: Normally used to mark recursive
                   1065: .Nm make Ns 's .
                   1066: .It Ic .NOTMAIN
                   1067: Normally
1.19      aaron    1068: .Nm
1.1       deraadt  1069: selects the first target it encounters as the default target to be built
                   1070: if no target was specified.
                   1071: This source prevents this target from being selected.
                   1072: .It Ic .OPTIONAL
                   1073: If a target is marked with this attribute and
1.19      aaron    1074: .Nm
1.1       deraadt  1075: can't figure out how to create it, it will ignore this fact and assume
                   1076: the file isn't needed or already exists.
                   1077: .It Ic .PRECIOUS
                   1078: When
1.19      aaron    1079: .Nm
1.1       deraadt  1080: is interrupted, it removes any partially made targets.
                   1081: This source prevents the target from being removed.
                   1082: .It Ic .SILENT
                   1083: Do not echo any of the commands associated with this target, exactly
                   1084: as if they all were preceded by an at sign
                   1085: .Pq Ql @ .
                   1086: .It Ic .USE
                   1087: Turn the target into
1.14      aaron    1088: .Nm make Ns 's
1.1       deraadt  1089: version of a macro.
                   1090: When the target is used as a source for another target, the other target
                   1091: acquires the commands, sources, and attributes (except for
                   1092: .Ic .USE )
                   1093: of the
                   1094: source.
                   1095: If the target already has commands, the
                   1096: .Ic .USE
                   1097: target's commands are appended
                   1098: to them.
1.4       deraadt  1099: .It Ic .WAIT
                   1100: If special
                   1101: .Ic .WAIT
                   1102: source is appears in a dependency line, the sources that precede it are
1.28      aaron    1103: made before the sources that succeed it in the line.
                   1104: Loops are not being
1.4       deraadt  1105: detected and targets that form loops will be silently ignored.
1.1       deraadt  1106: .El
                   1107: .Sh "SPECIAL TARGETS"
1.29      aaron    1108: Special targets may not be included with other targets, i.e., they must be
1.1       deraadt  1109: the only target specified.
                   1110: .Bl -tag -width Ic .BEGIN
                   1111: .It Ic .BEGIN
                   1112: Any command lines attached to this target are executed before anything
                   1113: else is done.
                   1114: .It Ic .DEFAULT
                   1115: This is sort of a
                   1116: .Ic .USE
                   1117: rule for any target (that was used only as a
                   1118: source) that
1.19      aaron    1119: .Nm
1.1       deraadt  1120: can't figure out any other way to create.
                   1121: Only the shell script is used.
                   1122: The
                   1123: .Ic .IMPSRC
                   1124: variable of a target that inherits
                   1125: .Ic .DEFAULT Ns 's
                   1126: commands is set
                   1127: to the target's own name.
                   1128: .It Ic .END
                   1129: Any command lines attached to this target are executed after everything
                   1130: else is done.
                   1131: .It Ic .IGNORE
                   1132: Mark each of the sources with the
                   1133: .Ic .IGNORE
                   1134: attribute.
                   1135: If no sources are specified, this is the equivalent of specifying the
                   1136: .Fl i
                   1137: option.
1.18      espie    1138: .It Ic .INCLUDES
                   1139: A list of suffixes that indicate files that can be included in a source
1.28      aaron    1140: file.
                   1141: The suffix must have already been declared with
1.18      espie    1142: .Ic .SUFFIXES ,
                   1143: any suffix so declared will have the directories on its search path (see
                   1144: .Ic .PATH )
1.19      aaron    1145: placed in the
1.18      espie    1146: .Va .INCLUDES
1.19      aaron    1147: special variable, each preceded by a
                   1148: .Fl I
1.18      espie    1149: flag.
1.1       deraadt  1150: .It Ic .INTERRUPT
                   1151: If
1.19      aaron    1152: .Nm
1.1       deraadt  1153: is interrupted, the commands for this target will be executed.
1.18      espie    1154: .It Ic .LIBS
1.19      aaron    1155: This does for libraries what
                   1156: .Ic .INCLUDES
1.18      espie    1157: does for include files, except that the flag used is
                   1158: .Fl L .
1.1       deraadt  1159: .It Ic .MAIN
                   1160: If no target is specified when
1.19      aaron    1161: .Nm
1.28      aaron    1162: is invoked, this target will be built.
                   1163: This is always set, either
1.19      aaron    1164: explicitly, or implicitly when
                   1165: .Nm
1.16      espie    1166: selects the default target, to give the user a way to refer to the default
                   1167: target on the command line.
1.1       deraadt  1168: .It Ic .MAKEFLAGS
                   1169: This target provides a way to specify flags for
1.19      aaron    1170: .Nm
1.1       deraadt  1171: when the makefile is used.
                   1172: The flags are as if typed to the shell, though the
                   1173: .Fl f
                   1174: option will have
                   1175: no effect.
1.4       deraadt  1176: .\" XXX: NOT YET!!!!
                   1177: .\" .It Ic .NOTPARALLEL
                   1178: .\" The named targets are executed in non parallel mode. If no targets are
                   1179: .\" specified, then all targets are executed in non parallel mode.
                   1180: .It Ic .NOTPARALLEL
                   1181: Disable parallel mode.
                   1182: .It Ic .NO_PARALLEL
                   1183: Same as above, for compatibility with other pmake variants.
                   1184: .It Ic .ORDER
                   1185: The named targets are made in sequence.
                   1186: .\" XXX: NOT YET!!!!
                   1187: .\" .It Ic .PARALLEL
                   1188: .\" The named targets are executed in parallel mode. If no targets are
                   1189: .\" specified, then all targets are executed in parallel mode.
1.1       deraadt  1190: .It Ic .PATH
                   1191: The sources are directories which are to be searched for files not
                   1192: found in the current directory.
                   1193: If no sources are specified, any previously specified directories are
                   1194: deleted.
1.18      espie    1195: .It Ic .PATH\fIsuffix\fR
                   1196: The sources are directories which are to be searched for suffixed files
                   1197: not found in the current directory.
1.19      aaron    1198: .Nm
                   1199: first searches the suffixed search path, before reverting to the default
1.18      espie    1200: path if the file is not found there.
1.6       niklas   1201: .It Ic .PHONY
                   1202: Apply the
                   1203: .Ic .PHONY
1.28      aaron    1204: attribute to any specified sources.
                   1205: Targets with this attribute are always
1.6       niklas   1206: considered to be out of date.
1.1       deraadt  1207: .It Ic .PRECIOUS
                   1208: Apply the
                   1209: .Ic .PRECIOUS
                   1210: attribute to any specified sources.
                   1211: If no sources are specified, the
                   1212: .Ic .PRECIOUS
                   1213: attribute is applied to every
                   1214: target in the file.
                   1215: .It Ic .SILENT
                   1216: Apply the
                   1217: .Ic .SILENT
                   1218: attribute to any specified sources.
                   1219: If no sources are specified, the
                   1220: .Ic .SILENT
                   1221: attribute is applied to every
                   1222: command in the file.
                   1223: .It Ic .SUFFIXES
                   1224: Each source specifies a suffix to
                   1225: .Nm make .
                   1226: If no sources are specified, any previous specified suffices are deleted.
1.35      aaron    1227: .El
1.1       deraadt  1228: .Sh ENVIRONMENT
1.19      aaron    1229: .Nm
1.15      espie    1230: uses the following environment variables, if they exist:
1.9       millert  1231: .Ev MACHINE ,
1.15      espie    1232: .Ev MACHINE_ARCH ,
1.9       millert  1233: .Ev MAKEFLAGS ,
                   1234: .Ev MAKEOBJDIR ,
1.15      espie    1235: .Ev MAKEOBJDIRPREFIX ,
1.1       deraadt  1236: and
1.9       millert  1237: .Ev PWD .
1.30      espie    1238: .Nm
1.31      aaron    1239: also ignores and unsets
1.30      espie    1240: .Ev CDPATH .
1.1       deraadt  1241: .Sh FILES
                   1242: .Bl -tag -width /usr/share/mk -compact
1.14      aaron    1243: .It Pa .depend
1.1       deraadt  1244: list of dependencies
1.15      espie    1245: .It Pa BSDmakefile
                   1246: list of dependencies
1.14      aaron    1247: .It Pa Makefile
1.1       deraadt  1248: list of dependencies
1.14      aaron    1249: .It Pa makefile
1.1       deraadt  1250: list of dependencies
1.14      aaron    1251: .It Pa sys.mk
1.1       deraadt  1252: system makefile
1.14      aaron    1253: .It Pa /usr/share/mk
1.1       deraadt  1254: system makefile directory
1.15      espie    1255: .IT Pa /usr/obj
1.19      aaron    1256: default
1.15      espie    1257: .Ev MAKEOBJDIRPREFIX directory.
1.1       deraadt  1258: .El
1.37      aaron    1259: .Sh SEE ALSO
                   1260: .Xr mkdep 1
                   1261: .Pp
                   1262: .%T "Make \- A Tutorial" .
                   1263: .Sh COMPATIBILITY
1.43      espie    1264: .Nm
                   1265: mostly conforms to the Single Unix Specification, Version 2,
                   1266: with some noted extensions and a few problems.
                   1267: .Pp
1.37      aaron    1268: Older versions of
                   1269: .Nm
                   1270: used
                   1271: .Ev MAKE
                   1272: instead of
                   1273: .Ev MAKEFLAGS .
                   1274: This was removed for POSIX compatibility.
                   1275: The internal variable
                   1276: .Va MAKE
                   1277: is set to the same value as
                   1278: .Va .MAKE ,
                   1279: support for this may be removed in the future.
                   1280: .Pp
                   1281: Most of the more esoteric features of
                   1282: .Nm
                   1283: should probably be avoided for greater compatibility.
                   1284: .Sh HISTORY
                   1285: A
                   1286: .Nm
                   1287: command appeared in
                   1288: .At v7 .
1.17      espie    1289: .Sh BUGS
1.18      espie    1290: The determination of
                   1291: .Va .OBJDIR
1.19      aaron    1292: is contorted to the point of absurdity.
1.18      espie    1293: .Pp
1.27      espie    1294: If you specify the same target several times in normal dependency rules,
1.31      aaron    1295: .Nm
1.27      espie    1296: silently ignores all commands after the first non empty set of commands,
1.31      aaron    1297: e.g., in
1.27      espie    1298: .Bd -literal
                   1299: a:
                   1300:        @echo "Executed"
                   1301: a:
                   1302:        @echo "Bad luck"
                   1303: .Ed
                   1304: .Pp
                   1305: @echo "Bad luck" will be silently ignored.
1.18      espie    1306: .Pp
                   1307: .Va .TARGETS
                   1308: is not set to the default target when
1.19      aaron    1309: .Nm
1.18      espie    1310: is invoked without a target name and no
1.19      aaron    1311: .Ic MAIN
1.18      espie    1312: special target exists.
                   1313: .Pp
1.17      espie    1314: The evaluation of
                   1315: .Ar expression
1.28      aaron    1316: in a test is very simple-minded.
                   1317: Currently, the only form that works is
1.17      espie    1318: .Ql .if ${VAR} op something
                   1319: For instance, you should write tests as
                   1320: .Ql .if ${VAR} = "string"
                   1321: not the other way around, which doesn't work.
                   1322: .Pp
                   1323: For loops are expanded before tests, so a fragment such as:
                   1324: .Bd -literal
                   1325: \&.for TMACHINE in ${SHARED_ARCHS}
                   1326: \&.if ${TMACHINE} = ${MACHINE}
                   1327:      ...
                   1328: \&.endif
1.32      ericj    1329: \&.endfor
1.17      espie    1330: .Ed
1.25      espie    1331: .Pp
1.17      espie    1332: won't work, and should be rewritten the other way around.
1.21      espie    1333: .Pp
1.31      aaron    1334: When handling pre-BSD 4.4 archives,
1.21      espie    1335: .Nm
                   1336: may erroneously mark archive members as out of date if the archive name
                   1337: was truncated.
1.26      espie    1338: .Pp
1.25      espie    1339: The handling of ; and other special characters in tests may be utterly
1.28      aaron    1340: bogus.
                   1341: For instance, in
1.25      espie    1342: .Bd -literal
                   1343: \&A=abcd;c.c
                   1344: \&.if ${A:R} == "abcd;c"
                   1345: .Ed
                   1346: .Pp
                   1347: the test will never match, even though the value is correct.
1.26      espie    1348: .Pp
1.28      aaron    1349: The conditional handler is incredibly lame.
                   1350: Junk such as
1.26      espie    1351: .Bd -literal
                   1352: \&.if defined anything goes (A)
                   1353: .Ed
                   1354: .Pp
                   1355: will be accepted silently.
1.25      espie    1356: .Pp
                   1357: In a .for loop, only the variable value is used, assignments will be
                   1358: evaluated later, e.g., in
                   1359: .Bd -literal
                   1360: \&.for I in a b c d
                   1361: I:=${I:S/a/z}
                   1362: A+=$I
                   1363: \&.endfor
                   1364: .Ed
                   1365: A will evaluate to a b c d after the loop, not z b c d.
1.33      espie    1366: .Pp
                   1367: The
                   1368: .Ql +
                   1369: command modificator is ignored in parallel make mode.