version 1.42, 2001/08/20 05:57:55 |
version 1.43, 2002/03/06 17:48:33 |
|
|
exists, it is read in addition to the makefile (see |
exists, it is read in addition to the makefile (see |
.Xr mkdep 1 ) . |
.Xr mkdep 1 ) . |
.Pp |
.Pp |
This manual page is intended as a reference document only. |
The handling of |
For a more thorough introduction to |
.Ql Pa BSDmakefile |
.Nm |
and |
and makefiles, please refer to |
.Ql Pa .depend |
.%T "Make \- A Tutorial" . |
are BSD extensions. |
.Pp |
.Pp |
The options are as follows: |
Standard options are as follows: |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
|
.It Fl e |
|
Specify that environment variables override macro assignments within |
|
makefiles. |
|
.It Fl f Ar makefile |
|
Specify a makefile to read instead of the default |
|
.Ql Pa makefile |
|
and |
|
.Ql Pa Makefile . |
|
If |
|
.Ar makefile |
|
is |
|
.Ql \- , |
|
standard input is read. |
|
Multiple makefiles may be specified, and are read in the order specified. |
|
.It Fl i |
|
Ignore non-zero exit of shell commands in the makefile. |
|
Equivalent to specifying |
|
.Ql \- |
|
before each command line in the makefile. |
|
.It 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. |
|
.It Fl n |
|
Display the commands that would have been executed, but do not actually |
|
execute them. |
|
.It Fl q |
|
Do not execute any commands, but exit with status 0 if the specified targets |
|
are up-to-date, and 1 otherwise. |
|
.It Fl r |
|
Do not use the built-in rules specified in the system makefile. |
|
.It Fl S |
|
Stop processing when an error is encountered. |
|
This is the default behavior. |
|
This is needed to negate the |
|
.Fl k |
|
option during recursive builds. |
|
.It Fl s |
|
Do not echo commands as they are executed. |
|
Equivalent to specifying |
|
.Ql Ic @ |
|
before each command line in the makefile. |
|
.It 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. |
|
.It Ar variable Ns No = Ns Ar value |
|
Set the value of the variable |
|
.Ar variable |
|
to |
|
.Ar value . |
|
.El |
|
.Pp |
|
Extended options are as follows: |
|
.Bl -tag -width Ds |
.It Fl B |
.It Fl B |
Try to be backwards compatible by executing a single shell per command and |
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. |
by executing the commands to make the sources of a dependency line in sequence. |
|
|
.It Ar v |
.It Ar v |
Print debugging information about variable assignment. |
Print debugging information about variable assignment. |
.El |
.El |
.It Fl e |
|
Specify that environment variables override macro assignments within |
|
makefiles. |
|
.It Fl f Ar makefile |
|
Specify a makefile to read instead of the default |
|
.Ql Pa makefile |
|
and |
|
.Ql Pa Makefile . |
|
If |
|
.Ar makefile |
|
is |
|
.Ql \- , |
|
standard input is read. |
|
Multiple makefiles may be specified, and are read in the order specified. |
|
.It Fl I Ar directory |
.It Fl I Ar directory |
Specify a directory in which to search for makefiles and included makefiles. |
Specify a directory in which to search for makefiles and included makefiles. |
The system makefile directory (or directories, see the |
The system makefile directory (or directories, see the |
.Fl m |
.Fl m |
option) is automatically included as part of this list. |
option) is automatically included as part of this list. |
.It Fl i |
|
Ignore non-zero exit of shell commands in the makefile. |
|
Equivalent to specifying |
|
.Ql \- |
|
before each command line in the makefile. |
|
.It Fl j Ar max_jobs |
.It Fl j Ar max_jobs |
Specify the maximum number of jobs that |
Specify the maximum number of jobs that |
.Nm |
.Nm |
|
|
Turns compatibility mode off, unless the |
Turns compatibility mode off, unless the |
.Ar B |
.Ar B |
flag is also specified. |
flag is also specified. |
.It 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. |
|
.It Fl m Ar directory |
.It Fl m Ar directory |
Specify a directory in which to search for |
Specify a directory in which to search for |
.Pa sys.mk |
.Pa sys.mk |
|
|
for "..."-style inclusions (see the |
for "..."-style inclusions (see the |
.Fl I |
.Fl I |
option). |
option). |
.It Fl n |
|
Display the commands that would have been executed, but do not actually |
|
execute them. |
|
.It Fl P |
.It Fl P |
Collate the output of a given job and display it only when the job finishes, |
Collate the output of a given job and display it only when the job finishes, |
instead of mixing the output of parallel jobs together. |
instead of mixing the output of parallel jobs together. |
This option has no effect unless |
This option has no effect unless |
.Fl j |
.Fl j |
is used too. |
is used too. |
.It Fl q |
|
Do not execute any commands, but exit with status 0 if the specified targets |
|
are up-to-date, and 1 otherwise. |
|
.It Fl r |
|
Do not use the built-in rules specified in the system makefile. |
|
.It Fl S |
|
Stop processing when an error is encountered. |
|
Default behavior. |
|
This is needed to negate the |
|
.Fl k |
|
option during recursive builds. |
|
.It Fl s |
|
Do not echo commands as they are executed. |
|
Equivalent to specifying |
|
.Ql Ic @ |
|
before each command line in the makefile. |
|
.It 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. |
|
.It Fl V Ar variable |
.It Fl V Ar variable |
Print |
Print |
.Nm make Ns 's |
.Nm make Ns 's |
|
|
Multiple instances of this option may be specified; |
Multiple instances of this option may be specified; |
the variables will be printed one per line, |
the variables will be printed one per line, |
with a blank line for each null or undefined variable. |
with a blank line for each null or undefined variable. |
.It Ar variable Ns No = Ns Ar value |
|
Set the value of the variable |
|
.Ar variable |
|
to |
|
.Ar value . |
|
.El |
.El |
.Pp |
.Pp |
There are seven different types of lines in a makefile: file dependency |
There are seven different types of lines in a makefile: file dependency |
specifications, shell commands, variable assignments, include statements, |
specifications, shell commands, variable assignments, include statements, |
conditional directives, for loops, and comments. |
conditional directives, for loops, and comments. |
|
Of these, include statements, conditional directives and for loops are |
|
extensions. |
.Pp |
.Pp |
In general, lines may be continued from one line to the next by ending |
In general, lines may be continued from one line to the next by ending |
them with a backslash |
them with a backslash |
|
|
and are usually created from them. |
and are usually created from them. |
The exact relationship between the target and the source is determined |
The exact relationship between the target and the source is determined |
by the operator that separates them. |
by the operator that separates them. |
|
Note that the use of several targets is merely a shorthand for duplicate |
|
rules. |
|
Specifically, |
|
.Bd -literal |
|
target1 target2: depa depb |
|
cmd1 |
|
cmd2 |
|
.Ed |
|
is just a short form of |
|
.Bd -literal |
|
target1: depa depb |
|
cmd1 |
|
cmd2 |
|
target2: depa depb |
|
cmd1 |
|
cmd2 |
|
.Ed |
|
.Pp |
|
.Nm |
|
does not support Solaris syntax for true multiple targets: |
|
.Bd -literal |
|
target1 + target2: depa depb |
|
cmd1 |
|
cmd2 |
|
.Ed |
|
.Pp |
The operators are as follows: |
The operators are as follows: |
.Bl -tag -width flag |
.Bl -tag -width flag |
.It Ic \&: |
.It Ic \&: |
|
|
is interrupted. |
is interrupted. |
.El |
.El |
.Pp |
.Pp |
Targets and sources may contain the shell wildcard expressions |
The |
|
.Ic \&:: |
|
operator is a fairly standard extension. |
|
The |
|
.Ic \&! |
|
operator is a BSD extension. |
|
.Pp |
|
As an extension, targets and sources may contain the shell wildcard |
|
expressions |
.Ql ? , |
.Ql ? , |
.Ql * , |
.Ql * , |
.Ql [] |
.Ql [] |
|
|
.Ql {} |
.Ql {} |
need not necessarily be used to describe existing files. |
need not necessarily be used to describe existing files. |
Expansion is in directory order, not alphabetically as done in the shell. |
Expansion is in directory order, not alphabetically as done in the shell. |
|
.Pp |
|
For maximum portability, target names should only consist of periods, |
|
underscores, digits and alphabetic characters. |
.Sh SHELL COMMANDS |
.Sh SHELL COMMANDS |
Each target may have associated with it a series of shell commands, normally |
Each target may have associated with it a series of shell commands, normally |
used to create the target. |
used to create the target. |
|
|
.Fl n |
.Fl n |
has been specified (This can be useful to debug recursive Makefiles). |
has been specified (This can be useful to debug recursive Makefiles). |
.El |
.El |
|
.Pp |
|
The command is always executed using |
|
.Pa /bin/sh |
|
in |
|
.Qq set -e |
|
mode. |
.Sh VARIABLE ASSIGNMENTS |
.Sh VARIABLE ASSIGNMENTS |
Variables in |
Variables in |
.Nm |
.Nm |
are much like variables in the shell, and, by tradition, |
are much like variables in the shell, and, by tradition, |
consist of all upper-case letters. |
consist of all upper-case letters. |
|
For portability, only periods, underscores, digits and letters should be |
|
used for variable names. |
The five operators that can be used to assign values to variables are as |
The five operators that can be used to assign values to variables are as |
follows: |
follows: |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Ic \&= |
.It Ic \&= |
Assign the value to the variable. |
Assign the value to the variable. |
Any previous value is overridden. |
Any previous value is overridden. |
.It Ic \&+= |
|
Append the value to the current value of the variable. |
|
.It Ic \&?= |
|
Assign the value to the variable if it is not already defined. |
|
.It Ic \&:= |
.It Ic \&:= |
Assign with expansion, i.e., expand the value before assigning it |
Assign with expansion, i.e., expand the value before assigning it |
to the variable. |
to the variable (extension) |
|
.It Ic \&+= |
|
Append the value to the current value of the variable (extension). |
|
.It Ic \&?= |
|
Assign the value to the variable if it is not already defined (BSD |
|
extension). |
Normally, expansion is not done until the variable is referenced. |
Normally, expansion is not done until the variable is referenced. |
.It Ic \&!= |
.It Ic \&!= |
Expand the value and pass it to the shell for execution and assign |
Expand the value and pass it to the shell for execution and assign |
the result to the variable. |
the result to the variable. |
Any newlines in the result are replaced with spaces. |
Any newlines in the result are replaced with spaces (BSD extension). |
.El |
.El |
.Pp |
.Pp |
Any whitespace before the assigned |
Any whitespace before the assigned |
|
|
Variables defined as part of the command line. |
Variables defined as part of the command line. |
.It Local variables |
.It Local variables |
Variables that are defined specific to a certain target. |
Variables that are defined specific to a certain target. |
The seven local variables are as follows: |
Standard local variables are as follows: |
.Bl -tag -width ".ARCHIVE" |
.Bl -tag -width ".ARCHIVE" |
|
.It Va @ |
|
The name of the target. |
|
.It Va \&% |
|
The name of the archive member (only valid for library rules). |
|
.It Va \&! |
|
The name of the archive file (only valid for library rules). |
|
.It Va \&? |
|
The list of prerequisites for this target that were deemed out-of-date. |
|
.It Va \&< |
|
The name of the source from which this target is to be built, if a valid |
|
implied rule (suffix rule) is in scope. |
|
.It Va * |
|
The file prefix of the file, containing only the file portion, |
|
no suffix or preceding directory components. |
|
.El |
|
.Pp |
|
The six variables |
|
.Ql Va "@F" , |
|
.Ql Va "@D" , |
|
.Ql Va "<F" , |
|
.Ql Va "<D" , |
|
.Ql Va "*F" , |
|
and |
|
.Ql Va "*D" |
|
yield the |
|
.Qq filename |
|
and |
|
.Qq directory |
|
parts of the corresponding macros. |
|
.Pp |
|
For maximum compatibility, |
|
.Ql Va \&< |
|
should only be used for actual implied rules. |
|
It is also set when there is an implied rule that matches the current |
|
dependency in scope. That is, in |
|
.Bd -literal |
|
\&.SUFFIXES: .c.o |
|
file.o: file.c |
|
cmd1 $< |
|
|
|
\&.c.o: |
|
cmd2 |
|
.Ed |
|
building |
|
.Pa file.o |
|
will execute |
|
.Qq cmd1 file.c . |
|
|
|
.Pp |
|
As an extension, |
|
.Nm |
|
sports the following local variables: |
|
.Bl -tag -width ".ARCHIVE" |
|
.It Va \&> |
|
The list of all sources for this target. |
.It Va .ALLSRC |
.It Va .ALLSRC |
The list of all sources for this target; also known as |
Synonym for |
.Ql Va \&> . |
.Ql Va \&> . |
.It Va .ARCHIVE |
.It Va .ARCHIVE |
The name of the archive file; also known as |
Synonym for |
.Ql Va \&! . |
.Ql Va \&! . |
.It Va .IMPSRC |
.It Va .IMPSRC |
The name/path of the source from which the target is to be transformed |
Synonym for |
(the |
|
.Dq implied |
|
source); also known as |
|
.Ql Va \&< . |
.Ql Va \&< . |
.It Va .MEMBER |
.It Va .MEMBER |
The name of the archive member; also known as |
Synonym for |
.Ql Va \&% . |
.Ql Va \&% . |
.It Va .OODATE |
.It Va .OODATE |
The list of sources for this target that were deemed out-of-date; also |
Synonym for |
known as |
|
.Ql Va \&? . |
.Ql Va \&? . |
.It Va .PREFIX |
.It Va .PREFIX |
The file prefix of the file, containing only the file portion, no suffix |
Synonym for |
or preceding directory components; also known as |
|
.Ql Va * . |
.Ql Va * . |
.It Va .TARGET |
.It Va .TARGET |
The name of the target; also known as |
Synonym for |
.Ql Va @ . |
.Ql Va @ . |
.El |
.El |
.Pp |
.Pp |
The shorter forms |
These variables may be used on the dependency half of dependency |
.Ql Va @ , |
lines, when they make sense. |
.Ql Va ! , |
|
.Ql Va \&< , |
|
.Ql Va \&% , |
|
.Ql Va ? , |
|
.Ql Va \&> , |
|
and |
|
.Ql Va * |
|
are permitted for backward |
|
compatibility with historical makefiles and are not recommended. |
|
The six variables |
|
.Ql Va "@F" , |
|
.Ql Va "@D" , |
|
.Ql Va "<F" , |
|
.Ql Va "<D" , |
|
.Ql Va "*F" , |
|
and |
|
.Ql Va "*D" |
|
are |
|
permitted for compatibility with |
|
.At V |
|
makefiles and are not recommended. |
|
.Pp |
|
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 |
|
.Ql Va .TARGET , |
|
.Ql Va .PREFIX , |
|
.Ql Va .ARCHIVE , |
|
and |
|
.Ql Va .MEMBER . |
|
.El |
.El |
.Pp |
.Pp |
In addition, |
In addition, |
|
|
.Pp |
.Pp |
.%T "Make \- A Tutorial" . |
.%T "Make \- A Tutorial" . |
.Sh COMPATIBILITY |
.Sh COMPATIBILITY |
|
.Nm |
|
mostly conforms to the Single Unix Specification, Version 2, |
|
with some noted extensions and a few problems. |
|
.Pp |
Older versions of |
Older versions of |
.Nm |
.Nm |
used |
used |