📄 make.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>make</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_1365"> </a>NAME</h4><blockquote>make - maintain, update and regenerate groups of programs(<b>DEVELOPMENT</b>)</blockquote><h4><a name = "tag_001_014_1366"> </a>SYNOPSIS</h4><blockquote><pre><code>make <b>[</b>-einpqrst<b>][</b>-f <i>makefile</i><b>]</b>...<b>[</b> -k| -S<b>][</b><i>macros</i>=<i>name</i><b>]</b>...<b>[</b><i>target_name</i>...<b>]</b></code></pre></blockquote><h4><a name = "tag_001_014_1367"> </a>DESCRIPTION</h4><blockquote>The<i>make</i>utility can be used as a part of software development to updatefiles that are derived from other files.A typical case is onewhere object files are derived from the corresponding source files.The<i>make</i>utility examines time relationships and updates those derived files(called targets) that have modified times earlier thanthe modified times of the files(called prerequisites) from which they are derived.A descriptionfile (makefile) contains a description of the relationships betweenfiles, and the commands that must be executed to update the targetsto reflect changes in their prerequisites.Each specification, or rule, consists of a target,optional prerequisites andoptional commands to be executed when a prerequisiteis newer than the target.There are two types of rule:<ul><p><li>inference rules,which have one target name with at least one period(.)and no slash(/)<p><li>target rules, which can have more than one target name.<p></ul><p>In addition,<i>make</i>has a collection ofbuilt-in macros and inference rules that infer prerequisiterelationships to simplify maintenance of programs.<p>To receive exactly the behaviour described in this section,a portable makefile must:<ul><p><li>include the special target<b>.POSIX</b><p><li>omit any special target reserved for implementations(a leading period followed by upper-case letters)that has not been specified by this section.<p></ul><p>The behaviour of<i>make</i>is unspecified ifeither or both of these conditions are not met.</blockquote><h4><a name = "tag_001_014_1368"> </a>OPTIONS</h4><blockquote>The<i>make</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> .<p>The following options are supported:<dl compact><dt><b>-e</b><dd>Cause environment variables, including those with null values,to override macro assignments within makefiles.<dt><b>-f </b><i>makefile</i><dd>Specify a different makefile.The argument<i>makefile</i>is a pathname of a description file,which is also referred to as the<i>makefile</i>.A pathname of "-" denotes the standard input.There can be multiple instances of this option, and they will beprocessed in the order specified.The effect of specifying the sameoption-argument more than onceis unspecified.<dt><b>-i</b><dd>Ignore error codes returned by invoked commands.This mode is the same as if the special target<b>.IGNORE</b>were specifiedwithout prerequisites.<dt><b>-k</b><dd>Continue to update othertargets that do not depend on the current targetif a non-ignored error occurs while executing the commands tobring a target up-to-date.<dt><b>-n</b><dd>Write commands that would be executed on standard output,but do not execute them.However, lines with a plus sign(+)prefix will be executed.In this mode,lines with an at sign(@)character prefix will be written to standard output.<dt><b>-p</b><dd>Write to standard output the complete set of macro definitionsand target descriptions.The output format is unspecified.<dt><b>-q</b><dd>Return a zero exit valueif the target file is up-to-date;otherwise,return an exit value of 1.Targets will not be updated if this option is specified.However, a command line(associated with the targets) with a plus sign(+)prefix will be executed.<dt><b>-r</b><dd>Clear the suffix list and do not use the built-in rules.<dt><b>-S</b><dd>Terminate<i>make</i>if an error occurs while executing the commands to bring atarget up-to-date.This will be the default and the opposite of<b>-k</b>.<dt><b>-s</b><dd>Do not write command lines or touch messages (see<b>-t</b>)to standard output before executing.This mode is the same as if the special target<b>.SILENT</b>were specified without prerequisites.<dt><b>-t</b><dd>Update the modification time of each target as though a<i><a href="touch.html">touch</a></i><i>target</i>had been executed.Targets that have prerequisites but no commands (see<xref href=mktarg><a href="#tag_001_014_1377_003">Target Rules</a></xref>),or that are already up-to-date,will not be touched in this manner.Write messages to standard output for each target fileindicating the name of the file and that it was touched.Normally, the command lines associated with each targetare not executed.However, a command linewith a plus sign(+)prefix will be executed.</dl><p>If the<b>-k</b>and<b>-S</b>options are both specified on the command line, by the<i>MAKEFLAGS</i>environment variable, or by the<b>MAKEFLAGS</b>macro, the last one evaluated will take precedence.The<i>MAKEFLAGS</i>environment variable will beevaluated first and the command line will be evaluated second.Assignments to the<b>MAKEFLAGS</b>macro will be evaluated as described in the ENVIRONMENT VARIABLES section.</blockquote><h4><a name = "tag_001_014_1369"> </a>OPERANDS</h4><blockquote>The following operands are supported:<dl compact><dt><i>target_name</i><dd>Target names, as defined in the EXTENDED DESCRIPTION section.If no target is specified, while<i>make</i>is processing the makefiles,the first target that<i>make</i>encounters that is not a special target or an inference rule will be used.<dt><i>macro=name</i><dd>Macro definitions, as defined in<xref href=mkmacro><a href="#tag_001_014_1377_004">Macros</a></xref>.</dl><p>If the<i>target_name</i>and<i>macro=name</i>operands are intermixed on the command line,the results are unspecified.</blockquote><h4><a name = "tag_001_014_1370"> </a>STDIN</h4><blockquote>The standard input will be used only if the<i>makefile</i>option-argument is "-".See the INPUT FILES section.</blockquote><h4><a name = "tag_001_014_1371"> </a>INPUT FILES</h4><blockquote>The input file, otherwise known as the makefile,is a text file containingrules, macro definitions and comments.</blockquote><h4><a name = "tag_001_014_1372"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>make</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments and input files).<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard error.<dt><i>MAKEFLAGS</i><dd>This variable is interpreted as a character string representinga series of option characters to be used as the default options.The implementation will accept both of the following formats(but need not accept them when intermixed):<ol><li>The characters are option letters without the leading hyphens orblank characterseparation used on a command line.<li>The characters are formatted in a manner similar to a portion of the<i>make</i>command line:options are preceded by hyphens andblank-character-separatedas described inthe <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> .The<i>macro=name</i>macro definition operands can also be included.The difference between the contents of<i>MAKEFLAGS</i>and the command line is thatthe contents of the variable will not be subjected to the word expansions(see<xref href=wordexp><a href="chap2.html#tag_001_006">Word Expansions</a></xref>)associated with parsing the command line values.</ol>When the command-line options<b>-f</b>or<b>-p</b>are used, they will take effectregardless of whether they also appear in<i>MAKEFLAGS .</i>If they otherwise appear in<i>MAKEFLAGS ,</i>the result is undefined.The<i>MAKEFLAGS</i>variable will be accessed from the environmentbefore the makefile is read.At that time,all of the options (except<b>-f</b>and<b>-p</b>)and command-line macrosnot already included in<b>MAKEFLAGS</b>are added to the<b>MAKEFLAGS</b>macro.The<b>MAKEFLAGS</b>macro will be passed into the environment asan environment variable for all child processes.If the<b>MAKEFLAGS</b>macro is subsequently set by the makefile, itreplaces the<i>MAKEFLAGS</i>variable currently found in the environment.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i><dt><i>PROJECTDIR</i><dd>Provide a directory to be used to search for SCCS files not foundin the current directory.In all of the following cases, thesearch for SCCS files will be made in the directory<b>SCCS</b>in theidentified directory.If the value of<i>PROJECTDIR</i>begins with aslash, it is considered an absolute pathname;otherwise, the homedirectory of a user of that name is examined for a subdirectory<b>src</b>or<b>source</b>.If such a directory is found, it is used.Otherwise, the value is used as a relative pathname.If<i>PROJECTDIR</i>is not set or has a null value, the search for SCCSfiles will be made in the directory<b>SCCS</b>in the current directory.The setting of<i>PROJECTDIR</i>affects all files listed in theremainder of this utility description for files with a componentnamed<b>SCCS</b>.</dl><p>The value of the<i>SHELL</i>environment variablewill not be used as a macro andwill not be modified by defining the<b>SHELL</b>macro in a makefile or on the command line.All other environment variables,including those with null values,are used as macros, as defined in<xref href=mkmacro><a href="#tag_001_014_1377_004">Macros</a></xref>.</blockquote><h4><a name = "tag_001_014_1373"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>If not already ignored,<i>make</i>will trap SIGHUP, SIGTERM, SIGINT and SIGQUITand remove the currenttarget unless the target is a directory or the target is aprerequisite of the special target<b>.PRECIOUS</b>or unless one of the<b>-n</b>,<b>-p</b>or<b>-q</b>options was specified.Any targets removed in this manner will be reportedin diagnostic messages of unspecified format,written to standard error.After this cleanup process, if any,<i>make</i>will take the standard action for all other signals.</blockquote><h4><a name = "tag_001_014_1374"> </a>STDOUT</h4><blockquote>The<i>make</i>utility will write all commands to be executed to standard outputunless the<b>-s</b>option was specified, the commandis prefixed with an at sign,or the special target<b>.SILENT</b>has either the current target as a prerequisite or has no prerequisites.If<i>make</i>is invoked without any workneeding to be done, it will write a message to standard outputindicating that no action was taken.</blockquote><h4><a name = "tag_001_014_1375"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_1376"> </a>OUTPUT FILES</h4><blockquote>None.However, utilities invoked by<i>make</i>may create additional files.</blockquote><h4><a name = "tag_001_014_1377"> </a>EXTENDED DESCRIPTION</h4><blockquote>The<i>make</i>utility attempts to perform the actions requiredto ensure that the specified targets are up-to-date.A target is considered out-of-date if it is older than anyof its prerequisitesor if it does not exist.The<i>make</i>utility treats all prerequisites astargets themselves and recursively ensures that they areup-to-date, processing them in the order in which theyappear in the rule.The<i>make</i>utility uses the modification times offiles to determine if thecorresponding targets are out-of-date.<p>After<i>make</i>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -