MAN page from Mandrake Other pmake-1.0-9.i386.rpm
MAKE
Section: User Commands (1)
IndexBSD mandoc
NAME
make - maintain program dependencies
SYNOPSIS
make[-
eiknqrstv][-
D variable][-
d flags][-
f makefile][-
I directory]-words[-
j max_jobs][
variable=value][
target ...]
DESCRIPTION
Makeis a program designed to simplify the maintenance of other programs.Its input is a list of specifications as to the files upon which programsand other files depend.If the file`makefile'exists, it is read for this list of specifications.If it does not exist, the file`Makefile'is read.If the file`.depend'exists, it is read (see
mkdep(1)).
This manual page is intended as a reference document only.For a more thorough description ofmakeand makefiles, please refer to"Make - A Tutorial" .
The options are as follows:
- -D variable
- Define Ar variableto be 1, in the global context.
- -d flags
- Turn on debugging, and specify which portions ofmakeare to print debugging information.Flagsis one or more of the following:
- A
- Print all possible debugging information;equivalent to specifying all of the debugging flags.
- a
- Print debugging information about archive searching and caching.
- c
- Print debugging information about conditional evaluation.
- d
- Print debugging information about directory searching and caching.
- g1
- Print the input graph before making anything.
- g2
- Print the input graph after making everything, or before exitingon error.
- j
- Print debugging information about running multiple shells.
- m
- Print debugging information about making targets, including modificationdates.
- s
- Print debugging information about suffix-transformation rules.
- t
- Print debugging information about target list maintenance.
- v
- Print debugging information about variable assignment.
- -e
- Specify that environmental variables override macro assignments withinmakefiles.
- -f makefile
- Specify a makefile to read instead of the default`makefile'and`Makefile'Ifmakefileis`-' standard input is read.Multiple makefile's may be specified, and are read in the order specified.
- -I directory
- Specify a directory in which to search for makefiles and included makefiles.The system makefile directory is automatically included as part of thislist.
- -i
- Ignore non-zero exit of shell commands in the makefile.Equivalent to specifying`-'beforeeach command line in the makefile.
- -j max_jobs
- Specify the maximum number of jobs thatmakemay have running at any one time.
- -k
- Continue processing after errors are encountered, but only on those targetsthat do not depend on the target whose creation caused the error.
- -n
- Display the commands that would have been executed, but do not actuallyexecute them.
- -q
- Do not execute any commands, but exit 0 if the specified targets areup-to-date and 1, otherwise.
- -r
- Do not use the built-in rules specified in the system makefile.
- -s
- Do not echo any commands as they are executed.Equivalent to specifying`@'before each command line in the makefile.
- -t
- Rather than re-building a target as specified in the makefile, create itor update its modification time to make it appear up-to-date.
- variable=value
- Set the value of the variablevariabletovalue
There are six different types of lines in a makefile: file dependencyspecifications, shell commands, variable assignments, include statements,conditional directives, and comments.
In general, lines may be continued from one line to the next by endingthem with a backslash(`\') The trailing newline character and initial whitespace on the followingline are compressed into a single space.
FILE DEPENDENCY SPECIFICATIONS
Dependency lines consist of one or more targets, an operator, and zeroor more sources.This creates a relationship where the targets ``depend'' on the sourcesand are usually created from them.The exact relationship between the target and the source is determinedby the operator that separates them.The three operators are as follows:
- :
- A target is considered out-of-date if its modification time is less thanthose of any of its sources.Sources for a target accumulate over dependency lines when this operatoris used.The target is removed ifmakeis interrupted.
- !
- Targets are always re-created, but not until all sources have beenexamined and re-created as necessary.Sources for a target accumulate over dependency lines when this operatoris used.The target is removed ifmakeis interrupted.
- ::
- If no sources are specified, the target is always re-created.Otherwise, a target is considered out-of-date if any of its sources hasbeen modified more recently than the target.Sources for a target do not accumulate over dependency lines when thisoperator is used.The target will not be removed ifmakeis interrupted.
Targets and sources may contain the shell wildcard values`?',`*',`[]'and`{}'The values`?',`*'and`[]'may only be used as part of the finalcomponent of the target or source, and must be used to describe existingfiles.The value`{}'need not necessarily be used to describe existing files.Expansion is in directory order, not alphabetically as done in the shell.
SHELL COMMANDS
Each target may have associated with it a series of shell commands, normallyused to create the target.Each of the commands in this script
mustbe preceded by a tab.While any target may appear on a dependency line, only one of thesedependencies may be followed by a creation script, unless the`
::'operator is used.
If the first or first two characters of the command line are`@'and/or`-',the command is treated specially.A`@'causes the command not to be echoed before it is executed.A`-'causes any non-zero exit status of the command line to be ignored.
VARIABLE ASSIGNMENTS
Variables in make 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 asfollows:
- =
- Assign the value to the variable.Any previous value is overridden.
- +=
- Append the value to the current value of the variable.
- ?=
- Assign the value to the variable if it is not already defined.
- :=
- Assign with expansion, i.e. expand the value before assigning itto the variable.Normally, expansion is not done until the variable is referenced.
- !=
- Expand the value and pass it to the shell for execution and assignthe result to the variable.Any newlines in the result are replaced with spaces.
Any white-space before the assignedvalueis removed; if the value is being appended, a single space is insertedbetween the previous contents of the variable and the appended value.
Variables are expanded by surrounding the variable name with eithercurly braces(`{}')or parenthesis(`()')and preceding it witha dollar sign(`$') If the variable name contains only a single letter, the surroundingbraces or parenthesis are not required.This shorter form is not recommended.
Variable substitution occurs at two distinct times, depending on wherethe 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 isexecuted.
The four different classes of variables (in order of increasing precedence)are:
- Environment variables
- Variables defined as part ofmake 'senvironment.
- Global variables
- Variables defined in the makefile or in included makefiles.
- Command line variables
- Variables defined as part of the command line.
- Local variables
- Variables that are defined specific to a certain target.The seven local variables are as follows:
- .ALLSRC
- The list of all sources for this target; also known as`>'
- .ARCHIVE
- The name of the archive file.
- .IMPSRC
- The name/path of the source from which the target is to be transformed(the ``implied'' source); also known as`<'
- .MEMBER
- The name of the archive member.
- .OODATE
- The list of sources for this target that were deemed out-of-date; alsoknown as`?'
- .PREFIX
- The file prefix of the file, containing only the file portion, no suffixor preceding directory components; also known as`*'
- .TARGET
- The name of the target; also known as`@'
The shorter forms`@',`?',`>'and`*'are permitted for backwardcompatibility with historical makefiles and are not recommended.The six variables`@F',`@D',`<F',`<D',`*F'and`*D'arepermitted for compatibility withAT&T SystemVmakefiles and are not recommended.
Four of the local variables may be used in sources on dependency linesbecause they expand to the proper value for each target on the line.These variables are`.TARGET',`.PREFIX',`.ARCHIVE',and`.MEMBER'
In addition,makesets or knows about the following variables:
- $
- A single dollar sign`$',i.e.`$$'expands to a single dollarsign.
- .MAKE
- The name thatmakewas executed with(argv [0])
- .CURDIR
- A path to the directory wheremakewas executed.
- MAKEFLAGS
- The environment variable`MAKEFLAGS'may contain anything thatmay be specified onmake 'scommand line.Anything specified onmake 'scommand line is appended to the`MAKEFLAGS'variable which is thenentered into the environment for all programs whichmakeexecutes.
Variable expansion may be modified to select or modify each word of thevariable (where a ``word'' is white-space delimited sequence of characters).The general format of a variable expansion is as follows:
{variable[:modifier[:...]]}
Each modifier begins with a colon and one of the followingspecial characters.The colon may be escaped with a backslash(`\')
- E
- Replaces each word in the variable with its suffix.
- H
- Replaces each word in the variable with everything but the last component.
- M pattern
- Select only those words that match the rest of the modifier.The standard shell wildcard characters( `*' `?',and`[)]'maybe used.The wildcard characters may be escaped with a backslash(`\')
- N pattern
- This is identical to`M',but selects all words which do not matchthe rest of the modifier.
- R
- Replaces each word in the variable with everything but its suffix.
- S / old_pattern / new_pattern/ [g]
- Modify the first occurrence ofold_patternin each word to be replaced withnew_pattern If a`g'is appended to the last slash of the pattern, all occurrencesin each word are replaced.Ifold_patternbegins with a carat(`^') old_patternis anchored at the beginning of each word.Ifold_patternends with a dollar sign(`$') it is anchored at the end of each word.Insidenew_string an ampersand(`&')is replaced byold_pattern Any character may be used as a delimiter for the parts of the modifierstring.The anchoring, ampersand and delimiter characters may be escaped with abackslash(`\')
Variable expansion occurs in the normal fashion inside bothold_stringandnew_stringwith the single exception that a backslash is used to prevent the expansionof a dollar sign(`$')not a preceding dollar sign as is usual.
- T
- Replaces each word in the variable with its last component.
- old_string=new_string
- This is theAT&T SystemVstyle variable substitution.It must be the last modifier specified.Old_stringis anchored at the end of each word, so only suffixes or entirewords may be replaced.
INCLUDE STATEMENTS AND CONDITIONALS
Makefile inclusion and conditional structures reminiscent of the Cprogramming language are provided in
make All such structures are identified by a line beginning with a singledot(`.')character.Files are included with either`.include'<file>or`.include'"file" .Variables between the angle brackets or double quotes are expandedto form the file name.If angle brackets are used, the included makefile is expected to be inthe system makefile directory.If double quotes are used, the including makefile's directory and anydirectories specified using the-
Ioption are searched before the systemmakefile directory.
Conditional expressions are also preceded by a single dot as the firstchraracter of a line.The possible conditionals are as follows:
- .undef variable
- Un-define the specified global variable.Only global variables may be un-defined.
- .if[! expression][operator expression ...]
- Test the value of an expression.
- .ifdef[! variable][operator variable ...]
- Test the value of an variable.
- .ifndef[! variable][operator variable ...]
- Test the value of an variable.
- .ifmake[! target][operator target ...]
- Test the the target being built.
- .ifnmake[! target][operator target ...]
- Test the target being built.
- .else
- Reverse the sense of the last conditional.
- .elif[! expression][operator expression ...]
- A combination of`.else'followed by`.if'
- .elifdef[! variable][operator variable ...]
- A combination of`.else'followed by`.ifdef'
- .elifndef[! variable][operator variable ...]
- A combination of`.else'followed by`.ifndef'
- .elifmake[! target][operator target ...]
- A combination of`.else'followed by`.ifmake'
- .elifnmake[! target][operator target ...]
- A combination of`.else'followed by`.ifnmake'
- .endif
- End the body of the conditional.
Theoperatormay be any one of the following:
- ||
- logical OR
- &&
- LogicalAND of higher precedence than``.''
As in C,makewill only evaluate a conditional as far as is necessary to determineits value.Parenthesis may be used to change the order of evaluation.The boolean operator`!'may be used to logically negate an entireconditional.It is of higher precendence than`&&'
The value ofexpressionmay be any of the following:
- defined
- Takes a variable name as an argument and evaluates to true if the variablehas been defined.
- make
- Takes a target name as an argument and evaluates to true if the targetwas specified as part ofmake 'scommand line or was declared the default target (either implicitly orexplicitly, see.MAIN before the line containing the conditional.
- empty
- Takes a variable, with possible modifiers, and evalutes to true ifthe expansion of the variable would result in an empty string.
- 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.PATH )
- target
- Takes a target name as an argument and evaluates to true if the targethas been defined.
Expressionmay also be an arithmetic or string comparison, with the left-hand sidebeing a variable expansion.The standard C relational operators are all supported, and the usualnumber/base conversion is performed.Note, octal numbers are not supported.If the righthand value of a`=='or`!='operator begins with aquotation mark(`"')a string comparison is done between the expandedvariable and the text between the quotation marks.If no relational operator is given, it is assumed that the expandedvariable is being compared against 0.
Whenmakeis evaluating one of these conditional expression, and it encountersa word it doesn't recognize, either the ``make'' or ``defined''expression is applied to it, depending on the form of the conditional.If the form is`.ifdef'or`.ifndef',the ``defined'' expressionis applied.Similarly, if the form is`.ifmake'or`.ifnmake', the ``make''expression is applied.
If the conditional evaluates to true the parsing of the makefile continuesas before.If it evaluates to false, the following lines are skipped.In both cases this continues until a`.else'or`.endif'is found.
COMMENTS
Comments begin with a hash(`#')character, anywhere but in a shellcommand line, and continue to the end of the line.
SPECIAL SOURCES
- .IGNORE
- Ignore any errors from the commands associated with this target, exactlyas if they all were preceded by a dash(`-')
- .MAKE
- Execute the commands associated with this target even if the-nor-toptions were specified.Normally used to mark recursivemake 's
- .NOTMAIN
- Normallymakeselects the first target it encounters as the default target to be builtif no target was specified.This source prevents this target from being selected.
- .OPTIONAL
- If a target is marked with this attribute andmakecan't figure out how to create it, it will ignore this fact and assumethe file isn't needed or already exists.
- .PRECIOUS
- Whenmakeis interrupted, it removes any partially made targets.This source prevents the target from being removed.
- .SILENT
- Do not echo any of the commands associated with this target, exactlyas if they all were preceded by an at sign(`@')
- .USE
- Turn the target intomake 's version of a macro.When the target is used as a source for another target, the other targetacquires the commands, sources, and attributes (except for.USE of thesource.If the target already has commands, the.USEtarget's commands are appendedto them.
SPECIAL TARGETS
Special targets may not be included with other targets, i.e. they must bethe only target specified.
- .BEGIN
- Any command lines attached to this target are executed before anythingelse is done.
- .DEFAULT
- This is sort of a.USErule for any target (that was used only as asource) thatmakecan't figure out any other way to create.Only the shell script is used.The.IMPSRCvariable of a target that inherits.DEFAULT 'scommands is setto the target's own name.
- .END
- Any command lines attached to this target are executed after everythingelse is done.
- .IGNORE
- Mark each of the sources with the.IGNOREattribute.If no sources are specified, this is the equivalent of specifying the-ioption.
- .INTERRUPT
- Ifmakeis interrupted, the commands for this target will be executed.
- .MAIN
- If no target is specified whenmakeis invoked, this target will be built.
- .MAKEFLAGS
- This target provides a way to specify flags formakewhen the makefile is used.The flags are as if typed to the shell, though the-foption will haveno effect.
- .PATH
- The sources are directories which are to be searched for files notfound in the current directory.If no sources are specified, any previously specified directories aredeleted.
- .PRECIOUS
- Apply the.PRECIOUSattribute to any specified sources.If no sources are specified, the.PRECIOUSattribute is applied to everytarget in the file.
- .SILENT
- Apply the.SILENTattribute to any specified sources.If no sources are specified, the.SILENTattribute is applied to everycommand in the file.
- .SUFFIXES
- Each source specifies a suffix tomake If no sources are specified, any previous specifies suffices are deleted.
ENVIRONMENT
Makeutilizes the following environment variables, if they exist:
MAKE MAKEFLAGSand
MAKEOBJDIR FILES
- .depend
- list of dependencies
- Makefile
- list of dependencies
- makefile
- list of dependencies
- sys.mk
- system makefile
- /usr/share/mk
- system makefile directory
SEE ALSO
mkdep(1)
HISTORY
A
Makecommand appeared inAT&T Systemv7 .
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- FILE DEPENDENCY SPECIFICATIONS
- SHELL COMMANDS
- VARIABLE ASSIGNMENTS
- INCLUDE STATEMENTS AND CONDITIONALS
- COMMENTS
- SPECIAL SOURCES
- SPECIAL TARGETS
- ENVIRONMENT
- FILES
- SEE ALSO
- HISTORY
This document was created byman2html,using the manual pages.