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

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