The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the University of
California, Berkeley and its contributors.
4. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
@(#)make.1 8.8 (Berkeley) 6/13/95
$FreeBSD: head/usr.bin/make/make.1 148580 2005-07-31 03:30:48Z keramida $
.Dd March 30, 2005 .Dt MAKE 1 .Os .Sh NAME .Nm make .Nd maintain program dependencies .Sh SYNOPSIS .Nm .Op Fl ABPSXeiknqrstv .Op Fl C Ar directory .Op Fl D Ar variable .Op Fl d Ar flags .Op Fl E Ar variable .Op Fl f Ar makefile .Op Fl I Ar directory k -words .Op Fl j Ar max_jobs .Op Fl m Ar directory .Ek .Op Fl V Ar variable .Op Fl x Ar warning_options .Op Ar variable Ns No = Ns Ar value .Op Ar target ... .Sh DESCRIPTION The .Nm utility is a program designed to simplify the maintenance of other programs. Its input is a list of specifications describing dependency relationships between the generation of files and programs. The first of
a BSDmakefile ,
a makefile and
a Makefile that can be found in either the current directory or a special object directory (see .Va .OBJDIR ) will be read for this list of specifications. If the file
a .depend can be found, it is also read (see .Xr mkdep 1 ) .
p This manual page is intended as a reference document only. For a more thorough introduction to .Nm and makefiles, please refer to .%T "Make - A Tutorial" .
p The options are as follows: l -tag -width Ds t Fl A Make archive errors non-fatal, causing .Nm to just skip the remainder or all of the archive and continue after printing a message. t Fl B Try to be backwards compatible by executing a single shell per command and by executing the commands to make the sources of a dependency line in sequence. This is turned on by default unless .Fl j is used. t Fl C Ar directory Change to .Ar directory before reading the makefiles or doing anything else. If multiple .Fl C options are specified, each is interpreted relative to the previous one: .Fl C Pa / Fl C Pa etc is equivalent to .Fl C Pa /etc . t Fl D Ar variable Define .Ar variable to be 1, in the global context. t Fl d Ar flags Turn on debugging, and specify which portions of .Nm are to print debugging information. Argument .Ar flags is one or more of the following: l -tag -width Ds t Ar A Print all possible debugging information; equivalent to specifying all of the debugging flags. t Ar a Print debugging information about archive searching and caching. t Ar c Print debugging information about conditional evaluation. t Ar d Print debugging information about directory searching and caching. t Ar f Print debugging information about the execution of for loops. t Ar "g1" Print the input graph before making anything. t Ar "g2" Print the input graph after making everything, or before exiting on error. t Ar j Print debugging information about running multiple shells. t Ar l Print commands in Makefiles regardless of whether or not they are prefixed by @ or other "quiet" flags. Also known as "loud" behavior. t Ar m Print debugging information about making targets, including modification dates. t Ar s Print debugging information about suffix-transformation rules. t Ar t Print debugging information about target list maintenance. t Ar v Print debugging information about variable assignment. .El t Fl E Ar variable Specify a variable whose environment value (if any) will override macro assignments within makefiles. t Fl e Specify that environment values override macro assignments within makefiles for all variables. t Fl f Ar makefile Specify a makefile to read instead of the default
a makefile and
a Makefile . If .Ar makefile is .Sq Fl , standard input is read. Multiple makefiles may be specified, and are read in the order specified. t Fl I Ar directory Specify a directory in which to search for makefiles and included makefiles. The system makefile directory (or directories, see the .Fl m option) is automatically included as part of this list. t Fl i Ignore non-zero exit of shell commands in the makefile. Equivalent to specifying .Sq Ic - before each command line in the makefile. t Fl j Ar max_jobs Specify the maximum number of jobs that .Nm may have running at any one time. Turns compatibility mode off, unless the .Ar B flag is also specified. t Fl k Continue processing after errors are encountered, but only on those targets that do not depend on the target whose creation caused the error. t Fl m Ar directory Specify a directory in which to search for
a sys.mk and makefiles included via the <...> style. Multiple directories can be added to form a search path. This path will override the default system include path:
a /usr/share/mk . Furthermore, the system include path will be appended to the search path used for "..."-style inclusions (see the .Fl I option). t Fl n Display the commands that would have been executed, but do not actually execute them. t Fl P Collate the output of a given job and display it only when the job finishes, instead of mixing the output of parallel jobs together. This option has no effect unless .Fl j is used too. t Fl q Do not execute any commands, but exit 0 if the specified targets are up-to-date and 1, otherwise. t Fl r Do not use the built-in rules specified in the system makefile. t Fl S Stop processing when an error is encountered. Default behaviour. This is needed to negate the .Fl k option during recursive builds. t Fl s Do not echo any commands as they are executed. Equivalent to specifying .Sq Ic @ before each command line in the makefile. t Fl t Rather than re-building a target as specified in the makefile, create it or update its modification time to make it appear up-to-date. t Fl V Ar variable Print .Nm Ns 's idea of the value of .Ar variable , in the global context. Do not build any targets. Multiple instances of this option may be specified; the variables will be printed one per line, with a blank line for each null or undefined variable. t Fl v Be extra verbose. For multi-job makes, this will cause file banners to be generated. t Fl X When using the .Fl V option to print the values of variables, do not recursively expand the values. t Ar variable Ns No = Ns Ar value Set the value of the variable .Ar variable to .Ar value . t Fl x Ar warning_options Specify extended warning options. This option may be specified several times. A .Ar warning_option can be prefixed with .Dq Li no in which case the warning is switched off. The currently available options are: l -tag -width indent t Li dirsyntax Warn if anything except blanks and comments follows an c .endif or c .else directive. .El
p See also the c .WARN special target. .El
p There are seven different types of lines in a makefile: file dependency specifications, shell commands, variable assignments, include statements, conditional directives, for loops, and comments.
p In general, lines may be continued from one line to the next by ending them with a backslash
q Ql \e . The trailing newline character and initial whitespace on the following line are compressed into a single space. .Sh FILE DEPENDENCY SPECIFICATIONS Dependency lines consist of one or more targets, an operator, and zero or more sources. This creates a relationship where the targets .Dq depend on the sources and are usually created from them. The exact relationship between the target and the source is determined by the operator that separates them. The three operators are as follows: l -tag -width flag t Ic : A target is considered out-of-date if its modification time is less than those of any of its sources. Sources for a target accumulate over dependency lines when this operator is used. The target is removed if .Nm is interrupted. t Ic ! Targets are always re-created, but not until all sources have been examined and re-created as necessary. Sources for a target accumulate over dependency lines when this operator is used. The target is removed if .Nm is interrupted. t Ic :: If no sources are specified, the target is always re-created. Otherwise, a target is considered out-of-date if any of its sources has been modified more recently than the target. Sources for a target do not accumulate over dependency lines when this operator is used. The target will not be removed if .Nm is interrupted. .El
p Targets and sources may contain the shell wildcard expressions .Ql ? , .Ql * , .Ql [] and .Ql {} . The expressions .Ql ? , .Ql * and .Ql [] may only be used as part of the final component of the target or source, and must be used to describe existing files. The expression .Ql {} need not necessarily be used to describe existing files. Expansion is in directory order, not alphabetically as done in the shell. .Sh SHELL COMMANDS Each target may have associated with it a series of shell commands, normally used to create the target. Each of the commands in this script .Em must be preceded by a tab. While any target may appear on a dependency line, only one of these dependencies may be followed by a creation script, unless the .Sq Ic :: operator is used.
p If the first characters of the command line are .Sq Ic @ , .Sq Ic - , and/or .Sq Ic + , the command is treated specially. A .Sq Ic @ causes the command not to be echoed before it is executed. A .Sq Ic - causes any non-zero exit status of the command line to be ignored. A .Sq Ic + causes the command to be executed even if .Fl n is specified on the command line. .Sh VARIABLE ASSIGNMENTS Variables in .Nm are much like variables in the shell, and, by tradition, consist of all upper-case letters. The five operators that can be used to assign values to variables are as follows: l -tag -width Ds t Ic = Assign the value to the variable. Any previous value is overridden. t Ic += Append the value to the current value of the variable. t Ic ?= Assign the value to the variable if it is not already defined. t Ic := Assign with expansion, i.e., expand the value before assigning it to the variable. Normally, expansion is not done until the variable is referenced. t Ic != Expand the value and pass it to the shell for execution and assign the result to the variable. Any newlines in the result are replaced with spaces. .El
p Any whitespace before the assigned .Ar value is removed; if the value is being appended, a single space is inserted between the previous contents of the variable and the appended value.
p Variables are expanded by surrounding the variable name with either curly braces
q Ql {} or parentheses
q Ql () and preceding it with a dollar sign
q Ql $ . If the variable name contains only a single letter, the surrounding braces or parentheses are not required. This shorter form is not recommended.
p Variable substitution occurs at two distinct times, depending on where the variable is being used. Variables in dependency lines are expanded as the line is read. Variables in shell commands are expanded when the shell command is executed.
p The four different classes of variables (in order of increasing precedence) are: l -tag -width Ds t Environment variables Variables defined as part of .Nm Ns 's environment. t Global variables Variables defined in the makefile or in included makefiles. t Command line variables Variables defined as part of the command line and variables obtained from the .Ev MAKEFLAGS environment variable or the c .MAKEFLAGS target. t Local variables Variables that are defined specific to a certain target. The seven local variables are as follows: l -tag -width ".ARCHIVE" t Va .ALLSRC The list of all sources for this target; also known as .Sq Va > . t Va .ARCHIVE The name of the archive file; also known as .Sq Va ! . t Va .IMPSRC The name/path of the source from which the target is to be transformed (the .Dq implied source); also known as .Sq Va < . t Va .MEMBER The name of the archive member; also known as .Sq Va % . t Va .OODATE The list of sources for this target that were deemed out-of-date; also known as .Sq Va ? . t Va .PREFIX The file prefix of the file, containing only the file portion, no suffix or preceding directory components; also known as .Sq Va * . t Va .TARGET The name of the target; also known as .Sq Va @ . .El
p The shorter forms .Sq Va @ , .Sq Va ! , .Sq Va < , .Sq Va % , .Sq Va ? , .Sq Va > , and .Sq Va * are permitted for backward compatibility and are not recommended. The six variables .Sq Va @F , .Sq Va @D , .Sq Va <F , .Sq Va <D , .Sq Va *F , and .Sq Va *D are permitted for compatibility with .At V makefiles and are not recommended.
p Four of the local variables may be used in sources on dependency lines because they expand to the proper value for each target on the line. These variables are .Va .TARGET , .Va .PREFIX , .Va .ARCHIVE , and .Va .MEMBER . .El
p In addition, .Nm sets or knows about the following internal variables or environment variables: l -tag -width ".Va .MAKEFILE_LIST" t Va $ A single dollar sign .Ql $ , i.e.\& .Ql $$ expands to a single dollar sign. t Va MAKE The name that .Nm was executed with
q Va argv Ns Op 0 . t Va .CURDIR A path to the directory where .Nm was executed. The .Nm utility sets .Va .CURDIR to the canonical path given by .Xr getcwd 3 . t Va .OBJDIR A path to the directory where the targets are built. At startup, .Nm searches for an alternate directory to place target files. It will attempt to change into this special directory and will search this directory for makefiles not found in the current directory. The following directories are tried in order:
p l -enum -compact t ${MAKEOBJDIRPREFIX}/`pwd` t ${MAKEOBJDIR} t obj.${MACHINE} t obj t /usr/obj/`pwd` .El
p The first directory that .Nm successfully changes into is used. If either .Ev MAKEOBJDIRPREFIX or .Ev MAKEOBJDIR is set in the environment but .Nm is unable to change into the corresponding directory, then the current directory is used without checking the remainder of the list. If they are undefined and .Nm is unable to change into any of the remaining three directories, then the current directory is used. Note, that .Ev MAKEOBJDIRPREFIX and .Ev MAKEOBJDIR must be environment variables and should not be set on .Nm Ns 's command line.
p The .Nm utility sets .Va .OBJDIR to the canonical path given by .Xr getcwd 3 . t Va .MAKEFILE_LIST As .Nm reads various makefiles, including the default files and any obtained from the command line and c .include directives, their names will be automatically appended to the .Va .MAKEFILE_LIST variable. They are added right before .Nm begins to parse them, so that the name of the current makefile is the last word in this variable. t Va .MAKEFLAGS The environment variable .Ev MAKEFLAGS may contain anything that may be specified on .Nm Ns 's command line. Its contents are stored in .Nm Ns 's .Va .MAKEFLAGS variable. All options and variable assignments specified on .Nm Ns 's command line are appended to the .Va .MAKEFLAGS variable which is then entered into the environment as .Ev MAKEFLAGS for all programs which .Nm executes. By modifying the contents of the .Va .MAKEFLAGS variable, makefile can alter the contents of the .Va MAKEFLAGS environment variable made available for all programs which .Nm executes; compare with the c .MAKEFLAGS special target below.
p When passing macro definitions and flag arguments in the .Ev MAKEFLAGS environment variable, space and tab characters are quoted by preceding them with a backslash. When reading the .Ev MAKEFLAGS variable from the environment, all sequences of a backslash and one of space or tab are replaced just with their second character without causing a word break. Any other occurrences of a backslash are retained. Groups of unquoted space, tab and newline characters cause word breaking. t Va MFLAGS This variable is provided for backward compatibility and contains all the options from the .Ev MAKEFLAGS environment variable plus any options specified on .Nm Ns 's command line. t Va .TARGETS List of targets .Nm is currently building. t Va .INCLUDES See c .INCLUDES special target. t Va .LIBS See c .LIBS special target. t Va MACHINE Name of the machine architecture .Nm is running on, obtained from the .Ev MACHINE environment variable, or through .Xr uname 3 if not defined. t Va MACHINE_ARCH Name of the machine architecture .Nm was compiled for, defined at compilation time. t Va VPATH Makefiles may assign a colon-delimited list of directories to .Va VPATH . These directories will be searched for source files by .Nm after it has finished parsing all input makefiles. .El
p Variable expansion may be modified to select or modify each word of the variable (where a .Dq word is whitespace-delimited sequence of characters). The general format of a variable expansion is as follows:
p .Dl {variable[:modifier[:...]]}
p Each modifier begins with a colon and one of the following special characters. The colon may be escaped with a backslash
q Ql \e . l -tag -width Cm .Sm off t Cm C No / Ar pattern Xo .No / Ar replacement .No / Op Cm 1g .Xc .Sm on Modify each word of the value, substituting every match of the extended regular expression .Ar pattern (see .Xr re_format 7 ) with the .Xr ed 1 Ns -style .Ar replacement string. Normally, the first occurrence of the pattern in each word of the value is changed. The .Ql 1 modifier causes the substitution to apply to at most one word; the .Ql g modifier causes the substitution to apply to as many instances of the search pattern as occur in the word or words it is found in. Note that .Ql 1 and .Ql g are orthogonal; the former specifies whether multiple words are potentially affected, the latter whether multiple substitutions can potentially occur within each affected word. t Cm E Replaces each word in the variable with its suffix. t Cm H Replaces each word in the variable with everything but the last component. t Cm L Converts variable to lower-case letters. t Cm M Ns Ar pattern Select only those words that match the rest of the modifier. The standard shell wildcard characters
f ( Ql * , .Ql ? , and .Ql [] ) may be used. The wildcard characters may be escaped with a backslash
q Ql \e . t Cm N Ns Ar pattern This is identical to .Cm M , but selects all words which do not match the rest of the modifier. t Cm O Order every word in the variable alphabetically. t Cm Q Quotes every shell meta-character in the variable, so that it can be passed safely through recursive invocations of .Nm . t Cm R Replaces each word in the variable with everything but its suffix. .Sm off t Cm S No / Ar old_string Xo .No / Ar new_string .No / Op Cm g .Xc .Sm on Modify the first occurrence of .Ar old_string in each word of the variable's value, replacing it with .Ar new_string . If a .Ql g is appended to the last slash of the pattern, all occurrences in each word are replaced. If .Ar old_string begins with a caret
q Ql ^ , .Ar old_string is anchored at the beginning of each word. If .Ar old_string ends with a dollar sign
q Ql $ , it is anchored at the end of each word. Inside .Ar new_string , an ampersand
q Ql & is replaced by .Ar old_string . Any character may be used as a delimiter for the parts of the modifier string. The anchoring, ampersand, and delimiter characters may be escaped with a backslash
q Ql \e .
p Variable expansion occurs in the normal fashion inside both .Ar old_string and .Ar new_string with the single exception that a backslash is used to prevent the expansion of a dollar sign
q Ql $ , not a preceding dollar sign as is usual. t Ar old_string=new_string This is the .At V style variable substitution. It must be the last modifier specified. If .Ar old_string or .Ar new_string do not contain the pattern matching character .Ar % then it is assumed that they are anchored at the end of each word, so only suffixes or entire words may be replaced. Otherwise .Ar % is the substring of .Ar old_string to be replaced in .Ar new_string t Cm T Replaces each word in the variable with its last component. t Cm U Converts variable to upper-case letters. .El .Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS Directives, conditionals, and for loops reminiscent of the C programming language are provided in .Nm . All such structures are identified by a line beginning with a single dot
q Ql . character. The following directives are supported: l -tag -width Ds t Ic .include Ar <file> t Ic .include Ar \*qfile\*q Include the specified makefile. Variables between the angle brackets or double quotes are expanded to form the file name. If angle brackets are used, the included makefile is expected to be in the system makefile directory. If double quotes are used, the including makefile's directory and any directories specified using the .Fl I option are searched before the system makefile directory. t Ic .undef Ar variable Un-define the specified global variable. Only global variables may be un-defined. t Ic .error Ar message Terminate processing of the makefile immediately. The filename of the makefile, the line on which the error was encountered and the specified message are printed to the standard error output and .Nm terminates with exit code 1. Variables in the message are expanded. t Ic .warning Ar message Emit a warning message. The filename of the makefile, the line on which the warning was encountered, and the specified message are printed to the standard error output. Variables in the message are expanded. .El
p Conditionals are used to determine which parts of the Makefile to process. They are used similarly to the conditionals supported by the C pre-processor. The following conditionals are supported: l -tag -width Ds t Xo c .if .Oo ! Oc Ns Ar expression .Op Ar operator expression ... .Xc Test the value of an expression. t Xo c .ifdef .Oo ! Oc Ns Ar variable .Op Ar operator variable ... .Xc Test the value of a variable. t Xo c .ifndef .Oo ! Oc Ns Ar variable .Op Ar operator variable ... .Xc Test the value of a variable. t Xo c .ifmake .Oo ! Oc Ns Ar target .Op Ar operator target ... .Xc Test the target being built. t Xo c .ifnmake .Oo ! Oc Ns Ar target .Op Ar operator target ... .Xc Test the target being built. t Ic .else Reverse the sense of the last conditional. t Xo c .elif .Oo ! Oc Ns Ar expression .Op Ar operator expression ... .Xc A combination of c .else followed by c .if . t Xo c .elifdef .Oo ! Oc Ns Ar variable .Op Ar operator variable ... .Xc A combination of c .else followed by c .ifdef . t Xo c .elifndef .Oo ! Oc Ns Ar variable .Op Ar operator variable ... .Xc A combination of c .else followed by c .ifndef . t Xo c .elifmake .Oo ! Oc Ns Ar target .Op Ar operator target ... .Xc A combination of c .else followed by c .ifmake . t Xo c .elifnmake .Oo ! Oc Ns Ar target .Op Ar operator target ... .Xc A combination of c .else followed by c .ifnmake . t Ic .endif End the body of the conditional. .El
p The .Ar operator may be any one of the following: l -tag -width "Cm XX" t Cm || logical .Tn OR t Cm && Logical .Tn AND ; of higher precedence than .Sq Ic || . .El
p As in C, .Nm will only evaluate a conditional as far as is necessary to determine its value. Parentheses may be used to change the order of evaluation. The boolean operator .Sq Ic !\& may be used to logically negate an entire conditional. It is of higher precedence than .Sq Ic && .
p The value of .Ar expression may be any of the following: l -tag -width Ic t Ic defined Takes a variable name as an argument and evaluates to true if the variable has been defined. t Ic make Takes a target name as an argument and evaluates to true if the target was specified as part of .Nm Ns 's command line or was declared the default target (either implicitly or explicitly, see .Va .MAIN ) before the line containing the conditional. t Ic empty Takes a variable, with possible modifiers, and evaluates to true if the expansion of the variable would result in an empty string. t Ic exists Takes a file name as an argument and evaluates to true if the file exists. The file is searched for on the system search path (see .Va .PATH ) . t Ic target Takes a target name as an argument and evaluates to true if the target has been defined. .El
p An .Ar expression may also be an arithmetic or string comparison, with the left-hand side being a variable expansion. Variable expansion is performed on both sides of the comparison, after which the integral values are compared. A value is interpreted as hexadecimal if it is preceded by 0x, otherwise it is decimal; octal numbers are not supported. The standard C relational operators are all supported. If after variable expansion, either the left or right hand side of a .Sq Ic == or .Sq Ic != operator is not an integral value, then string comparison is performed between the expanded variables. If no relational operator is given, it is assumed that the expanded variable is being compared against 0.
p When .Nm is evaluating one of these conditional expressions, and it encounters a word it does not recognize, either the .Dq make or .Dq defined expression is applied to it, depending on the form of the conditional. If the form is c .if , c .ifdef or c .ifndef , the .Dq defined expression is applied. Similarly, if the form is c .ifmake or c .ifnmake , the .Dq make expression is applied.
p If the conditional evaluates to true the parsing of the makefile continues as before. If it evaluates to false, the following lines are skipped. In both cases this continues until a c .else or c .endif is found.
p For loops are typically used to apply a set of rules to a list of files. The syntax of a for loop is:
p l -tag -width indent -compact t Ic .for Ar variable Ic in Ar expression t <make-rules> t Ic .endfor .El
p After the for .Ar expression is evaluated, it is split into words. The iteration .Ar variable is successively set to each word, and substituted in the c make-rules inside the body of the for loop. .Sh COMMENTS Comments begin with a hash
q Ql # character, anywhere but in a shell command line, and continue to the end of the line. .Sh SPECIAL SOURCES l -tag -width Ic t Ic .IGNORE Ignore any errors from the commands associated with this target, exactly as if they all were preceded by a dash
q Ql - . t Ic .MAKE Execute the commands associated with this target even if the .Fl n or .Fl t options were specified. Normally used to mark recursive .Nm Ns 's . t Ic .NOTMAIN Normally .Nm selects the first target it encounters as the default target to be built if no target was specified. This source prevents this target from being selected. t Ic .OPTIONAL If a target is marked with this attribute and .Nm cannot figure out how to create it, it will ignore this fact and assume the file is not needed or already exists. t Ic .PRECIOUS When .Nm is interrupted, it removes any partially made targets. This source prevents the target from being removed. t Ic .SILENT Do not echo any of the commands associated with this target, exactly as if they all were preceded by an at sign
q Ql @ .
t Ic .USE Turn the target into
.Nm Ns 's
version of a macro.
When the target is used as a source for another target, the other target
acquires the commands, sources, and attributes (except for
c .USE ) of the
source.
If the target already has commands, the
c .USE target's commands are appended
to them.
t Ic .WAIT If special
c .WAIT source is appears in a dependency line, the sources that precede it are
made before the sources that succeed it in the line.
Loops are not being
detected and targets that form loops will be silently ignored.
.El
.Sh "SPECIAL TARGETS"
Special targets may not be included with other targets, i.e., they must be
the only target specified.
l -tag -width Ic t Ic .BEGIN Any command lines attached to this target are executed before anything
else is done.
t Ic .DEFAULT This is sort of a
c .USE rule for any target (that was used only as a
source) that
.Nm
cannot figure out any other way to create.
Only the shell script is used.
The
c .IMPSRC variable of a target that inherits
c .DEFAULT Ns 's commands is set
to the target's own name.
t Ic .END Any command lines attached to this target are executed after everything
else is done.
t Ic .IGNORE Mark each of the sources with the
c .IGNORE attribute.
If no sources are specified, this is the equivalent of specifying the
.Fl i
option.
t Ic .INCLUDES A list of suffixes that indicate files that can be included in a source
file.
The suffix must have already been declared with
c .SUFFIXES ; any suffix so declared will have the directories on its search path (see
c .PATH ) placed in the
.Va .INCLUDES
special variable, each preceded by a
.Fl I
flag.
t Ic .INTERRUPT If
.Nm
is interrupted, the commands for this target will be executed.
t Ic .LIBS This does for libraries what
c .INCLUDES does for include files, except that the flag used is
.Fl L .
t Ic .MAIN If no target is specified when
.Nm
is invoked, this target will be built.
This is always set, either
explicitly, or implicitly when
.Nm
selects the default target, to give the user a way to refer to the default
target on the command line.
t Ic .MAKEFLAGS This target provides a way to specify flags for
.Nm
when the makefile is used.
The flags are as if typed to the shell, though the
.Fl f
option will have
no effect.
Flags (except for
.Fl f )
and variable assignments specified as the source
for this target are also appended to the
.Va .MAKEFLAGS
internal variable.
Please note the difference between this target and the
.Va .MAKEFLAGS
internal variable: specifying an option or variable
assignment as the source for this target will affect
.Em both
the current makefile and all processes that
.Nm
executes.
t Ic .MFLAGS Same as above, for backward compatibility.
XXX: NOT YET!!!!
.It Ic .NOTPARALLEL
The named targets are executed in non parallel mode. If no targets are
specified, then all targets are executed in non parallel mode.
t Ic .NOTPARALLEL Disable parallel mode.
t Ic .NO_PARALLEL Same as above, for compatibility with other
.Nm pmake
variants.
t Ic .ORDER The named targets are made in sequence.
XXX: NOT YET!!!!
.It Ic .PARALLEL
The named targets are executed in parallel mode. If no targets are
specified, then all targets are executed in parallel mode.
t Ic .PATH The sources are directories which are to be searched for files not
found in the current directory.
If no sources are specified, any previously specified directories are
deleted.
Where possible, use of
c .PATH is preferred over use of the
.Va VPATH
variable.
t Ic .PATHsuffix The sources are directories which are to be searched for suffixed files
not found in the current directory.
The
.Nm
utility
first searches the suffixed search path, before reverting to the default
path if the file is not found there.
This form is required for
c .LIBS and
c .INCLUDES to work.
t Ic .PHONY Apply the
c .PHONY attribute to any specified sources.
Targets with this attribute are always
considered to be out of date.
t Ic .PRECIOUS Apply the
c .PRECIOUS attribute to any specified sources.
If no sources are specified, the
c .PRECIOUS attribute is applied to every
target in the file.
t Ic .SHELL Select another shell.
The sources of this target have the format
.Ar key Ns = Ns Ar value .
The
.Ar key
is one of:
l -tag -width ".Va hasErrCtl" t Va path Specify the path to the new shell.
t Va name Specify the name of the new shell.
This may be either one of the three builtin shells (see below) or any
other name.
t Va quiet Specify the shell command to turn echoing off.
t Va echo Specify the shell command to turn echoing on.
t Va filter Usually shells print the echo off command before turning echoing off.
This is the exact string that will be printed by the shell and is used
to filter the shell output to remove the echo off command.
t Va echoFlag The shell option that turns echoing on.
t Va errFlag The shell option to turn on error checking.
If error checking is on, the shell should exit if a command returns
a non-zero status.
t Va hasErrCtl True if the shell has error control.
t Va check If
.Va hasErrCtl
is true then this is the shell command to turn error checking on.
If
.Va hasErrCtl
is false then this is a command template to echo commands for which error
checking is disabled.
The template must contain a
.Ql %s .
t Va ignore If
.Va hasErrCtl
is true, this is the shell command to turn error checking off.
If
.Va hasErrCtl
is false, this is a command template to execute a command so that errors
are ignored.
The template must contain a
.Ql %s .
t Va meta This is a string of meta characters of the shell.
t Va builtins This is a string holding all the shell's builtin commands separated by blanks.
The
.Va meta
and
.Va builtins
strings are used in compat mode.
When a command line contains neither a meta
character nor starts with a shell builtin, it is executed directly without
invoking a shell.
When one of these strings (or both) is empty all commands are executed
through a shell.
t Va unsetenv If true, remove the
.Ev ENV
environment variable before executing any command.
This is useful for the Korn-shell
q Nm ksh . .El
p Values that are strings must be surrounded by double quotes. Boolean values are specified as .Ql T or .Ql Y (in either case) to mean true. Any other value is taken to mean false.
p There are several uses of the c .SHELL target: l -bullet t Selecting one of the builtin shells. This is done by just specifying the name of the shell with the .Va name keyword. It is also possible to modify the parameters of the builtin shell by just specifying other keywords (except for .Va path ) . t Using another executable for one of the builtin shells. This is done by specifying the path to the executable with the .Va path keyword. If the last component is the same as the name of the builtin shell, no name needs to be specified; if it is different, the name must be given: d -literal -offset indent .SHELL: path="/usr/local/bin/sh" .Ed
p selects the builtin shell .Dq Li sh but will execute it from
a /usr/local/bin/sh . Like in the previous case, it is possible to modify parameters of the builtin shell by just specifying them. t Using an entirely different shell. This is done by specifying all keywords. .El
p The builtin shells are .Dq Li sh , .Dq Li csh and .Dq Li ksh . Because .Fx has no .Nm ksh in
a /bin , it is unwise to specify .Va name Ns = Ns Qq Li ksh without also specifying a path. t Ic .SILENT Apply the c .SILENT attribute to any specified sources. If no sources are specified, the c .SILENT attribute is applied to every command in the file. t Ic .SUFFIXES Each source specifies a suffix to .Nm . If no sources are specified, any previous specified suffices are deleted. t Ic .WARN Each source specifies a warning flag as previously described for the .Fl x command line option. Warning flags specified on the command line take precedence over flags specified in the makefile. Also, command line warning flags are pushed to sub-makes through the .Ev MAKEFLAGS environment variables so that a warning flag specified on the command line will influence all sub-makes. Several flags can be specified on a single c .WARN target by seperating them with blanks. .El .Sh ENVIRONMENT The .Nm utility uses the following environment variables, if they exist: .Ev MACHINE , .Ev MAKE , .Ev MAKEFLAGS , .Ev MAKEOBJDIR , and .Ev MAKEOBJDIRPREFIX . .Sh FILES l -tag -width /usr/share/doc/psd/12.make -compact t Pa .depend list of dependencies t Pa Makefile list of dependencies t Pa makefile list of dependencies t obj object directory t Pa sys.mk system makefile (processed before any other file, including
a makefile and
a Makefile ) t Pa /usr/share/mk system makefile directory t /usr/share/doc/psd/12.make PMake tutorial t Pa /usr/obj default .Ev MAKEOBJDIRPREFIX directory. .El .Sh EXAMPLES List all included makefiles in order visited:
p .Dl "make -V .MAKEFILE_LIST | tr \e \e\en" .Sh COMPATIBILITY Older versions of .Nm used .Ev MAKE instead of .Ev MAKEFLAGS . This was removed for POSIX compatibility. The internal variable .Va MAKE is set to the same value as .Va .MAKE ; support for this may be removed in the future.
p Most of the more esoteric features of .Nm should probably be avoided for greater compatibility. .Sh SEE ALSO .Xr mkdep 1 , .Xr make.conf 5 .Rs .%T "PMake - A Tutorial" .Re in
a /usr/share/doc/psd/12.make .Sh HISTORY A .Nm command appeared in PWB UNIX. .Sh BUGS The determination of .Va .OBJDIR is contorted to the point of absurdity.
p In the presence of several c .MAIN special targets, .Nm silently ignores all but the first.
p .Va .TARGETS is not set to the default target when .Nm is invoked without a target name and no c .MAIN special target exists.
p The evaluation of .Ar expression in a test is very simple-minded. Currently, the only form that works is .Ql .if ${VAR} op something For instance, you should write tests as .Ql .if ${VAR} == "string" not the other way around, which would give you an error.
p For loops are expanded before tests, so a fragment such as: d -literal -offset indent .for ARCH in ${SHARED_ARCHS} .if ${ARCH} == ${MACHINE} ... .endif .endfor .Ed
p will not work, and should be rewritten as: d -literal -offset indent .for ARCH in ${SHARED_ARCHS} .if ${MACHINE} == ${ARCH} ... .endif .endfor .Ed
p The parsing code is broken with respect to handling a semicolon after a colon, so a fragment like this will fail: d -literal -offset indent HDRS= foo.h bar.h all: .for h in ${HDRS:S;^;${.CURDIR}/;} ... .endfor .Ed
p A trailing backslash in a variable value defined on the command line causes the delimiting space in the .Ev MAKEFLAGS environment variable to be preceeded by that backslash. That causes a submake to not treat that space as a word delimiter. Fixing this requires a larger rewrite of the code handling command line macros and assignments to .Va .MAKEFLAGS .