📄 make.html
字号:
<li><a href="#Appending">Appending</a>: How to append more text to the old value of a variable. <li><a href="#Override-Directive">Override Directive</a>: How to set a variable in the makefile even if the user has set it with a command argument. <li><a href="#Defining">Defining</a>: An alternate way to set a variable to a verbatim string. <li><a href="#Environment">Environment</a>: Variable values can come from the environment. <li><a href="#Target_002dspecific">Target-specific</a>: Variable values can be defined on a per-target basis. <li><a href="#Pattern_002dspecific">Pattern-specific</a>: Target-specific variable values can be applied to a group of targets that match a pattern.</li></ul><p>Advanced Features for Reference to Variables</p><ul class="menu"><li><a href="#Substitution-Refs">Substitution Refs</a>: Referencing a variable with substitutions on the value. <li><a href="#Computed-Names">Computed Names</a>: Computing the name of the variable to refer to.</li></ul><p>Conditional Parts of Makefiles</p><ul class="menu"><li><a href="#Conditional-Example">Conditional Example</a>: Example of a conditional<li><a href="#Conditional-Syntax">Conditional Syntax</a>: The syntax of conditionals. <li><a href="#Testing-Flags">Testing Flags</a>: Conditionals that test flags.</li></ul><p>Functions for Transforming Text</p><ul class="menu"><li><a href="#Syntax-of-Functions">Syntax of Functions</a>: How to write a function call. <li><a href="#Text-Functions">Text Functions</a>: General-purpose text manipulation functions. <li><a href="#File-Name-Functions">File Name Functions</a>: Functions for manipulating file names. <li><a href="#Conditional-Functions">Conditional Functions</a>: Functions that implement conditions. <li><a href="#Foreach-Function">Foreach Function</a>: Repeat some text with controlled variation. <li><a href="#Call-Function">Call Function</a>: Expand a user-defined function. <li><a href="#Value-Function">Value Function</a>: Return the un-expanded value of a variable. <li><a href="#Eval-Function">Eval Function</a>: Evaluate the arguments as makefile syntax. <li><a href="#Origin-Function">Origin Function</a>: Find where a variable got its value. <li><a href="#Flavor-Function">Flavor Function</a>: Find out the flavor of a variable. <li><a href="#Shell-Function">Shell Function</a>: Substitute the output of a shell command. <li><a href="#Make-Control-Functions">Make Control Functions</a>: Functions that control how make runs.</li></ul><p>How to Run <code>make</code></p><ul class="menu"><li><a href="#Makefile-Arguments">Makefile Arguments</a>: How to specify which makefile to use. <li><a href="#Goals">Goals</a>: How to use goal arguments to specify which parts of the makefile to use. <li><a href="#Instead-of-Execution">Instead of Execution</a>: How to use mode flags to specify what kind of thing to do with the commands in the makefile other than simply execute them. <li><a href="#Avoiding-Compilation">Avoiding Compilation</a>: How to avoid recompiling certain files. <li><a href="#Overriding">Overriding</a>: How to override a variable to specify an alternate compiler and other things. <li><a href="#Testing">Testing</a>: How to proceed past some errors, to test compilation. <li><a href="#Options-Summary">Options Summary</a>: Summary of Options</li></ul><p>Using Implicit Rules</p><ul class="menu"><li><a href="#Using-Implicit">Using Implicit</a>: How to use an existing implicit rule to get the commands for updating a file. <li><a href="#Catalogue-of-Rules">Catalogue of Rules</a>: A list of built-in implicit rules. <li><a href="#Implicit-Variables">Implicit Variables</a>: How to change what predefined rules do. <li><a href="#Chained-Rules">Chained Rules</a>: How to use a chain of implicit rules. <li><a href="#Pattern-Rules">Pattern Rules</a>: How to define new implicit rules. <li><a href="#Last-Resort">Last Resort</a>: How to define commands for rules which cannot find any. <li><a href="#Suffix-Rules">Suffix Rules</a>: The old-fashioned style of implicit rule. <li><a href="#Implicit-Rule-Search">Implicit Rule Search</a>: The precise algorithm for applying implicit rules.</li></ul><p>Defining and Redefining Pattern Rules</p><ul class="menu"><li><a href="#Pattern-Intro">Pattern Intro</a>: An introduction to pattern rules. <li><a href="#Pattern-Examples">Pattern Examples</a>: Examples of pattern rules. <li><a href="#Automatic-Variables">Automatic Variables</a>: How to use automatic variables in the commands of implicit rules. <li><a href="#Pattern-Match">Pattern Match</a>: How patterns match. <li><a href="#Match_002dAnything-Rules">Match-Anything Rules</a>: Precautions you should take prior to defining rules that can match any target file whatever. <li><a href="#Canceling-Rules">Canceling Rules</a>: How to override or cancel built-in rules.</li></ul><p>Using <code>make</code> to Update Archive Files</p><ul class="menu"><li><a href="#Archive-Members">Archive Members</a>: Archive members as targets. <li><a href="#Archive-Update">Archive Update</a>: The implicit rule for archive member targets. <li><a href="#Archive-Pitfalls">Archive Pitfalls</a>: Dangers to watch out for when using archives. <li><a href="#Archive-Suffix-Rules">Archive Suffix Rules</a>: You can write a special kind of suffix rule for updating archives.</li></ul><p>Implicit Rule for Archive Member Targets</p><ul class="menu"><li><a href="#Archive-Symbols">Archive Symbols</a>: How to update archive symbol directories. </ul><div class="node"><p><hr><a name="Overview"></a>Next: <a rel="next" accesskey="n" href="#Introduction">Introduction</a>,Previous: <a rel="previous" accesskey="p" href="#Top">Top</a>,Up: <a rel="up" accesskey="u" href="#Top">Top</a></div><!-- node-name, next, previous, up --><h2 class="chapter">1 Overview of <code>make</code></h2><p>The <code>make</code> utility automatically determines which pieces of a largeprogram need to be recompiled, and issues commands to recompile them. This manual describes GNU <code>make</code>, which was implemented by RichardStallman and Roland McGrath. Development since Version 3.76 has beenhandled by Paul D. Smith. <p>GNU <code>make</code> conforms to section 6.2 of <cite>IEEE Standard1003.2-1992</cite> (POSIX.2). <a name="index-POSIX-1"></a><a name="index-IEEE-Standard-1003_002e2-2"></a><a name="index-standards-conformance-3"></a>Our examples show C programs, since they are most common, but you can use<code>make</code> with any programming language whose compiler can be run with ashell command. Indeed, <code>make</code> is not limited to programs. You canuse it to describe any task where some files must be updated automaticallyfrom others whenever the others change.<ul class="menu"><li><a accesskey="1" href="#Preparing">Preparing</a>: Preparing and Running Make<li><a accesskey="2" href="#Reading">Reading</a>: On Reading this Text<li><a accesskey="3" href="#Bugs">Bugs</a>: Problems and Bugs</ul><div class="node"><p><hr><a name="Preparing"></a>Next: <a rel="next" accesskey="n" href="#Reading">Reading</a>,Previous: <a rel="previous" accesskey="p" href="#Overview">Overview</a>,Up: <a rel="up" accesskey="u" href="#Overview">Overview</a></div><h3 class="heading">Preparing and Running Make</h3> <p>To prepare to use <code>make</code>, you must write a file calledthe <dfn>makefile</dfn> that describes the relationships among filesin your program and provides commands for updating each file. In a program, typically, the executable file is updated from objectfiles, which are in turn made by compiling source files. <p>Once a suitable makefile exists, each time you change some source files,this simple shell command:<pre class="example"> make</pre> <p class="noindent">suffices to perform all necessary recompilations. The <code>make</code> programuses the makefile data base and the last-modification times of the files todecide which of the files need to be updated. For each of those files, itissues the commands recorded in the data base. <p>You can provide command line arguments to <code>make</code> to control whichfiles should be recompiled, or how. See <a href="#Running">How to Run <code>make</code></a>.<div class="node"><p><hr><a name="Reading"></a>Next: <a rel="next" accesskey="n" href="#Bugs">Bugs</a>,Previous: <a rel="previous" accesskey="p" href="#Preparing">Preparing</a>,Up: <a rel="up" accesskey="u" href="#Overview">Overview</a></div><h3 class="section">1.1 How to Read This Manual</h3><p>If you are new to <code>make</code>, or are looking for a generalintroduction, read the first few sections of each chapter, skipping thelater sections. In each chapter, the first few sections containintroductory or general information and the later sections containspecialized or technical information. The exception is the second chapter, <a href="#Introduction">An Introduction to Makefiles</a>, all of which is introductory. <p>If you are familiar with other <code>make</code> programs, see <a href="#Features">Features of GNU <code>make</code></a>, which lists the enhancements GNU<code>make</code> has, and <a href="#Missing">Incompatibilities and Missing Features</a>, which explains the few things GNU <code>make</code> lacks thatothers have. <p>For a quick summary, see <a href="#Options-Summary">Options Summary</a>, <a href="#Quick-Reference">Quick Reference</a>,and <a href="#Special-Targets">Special Targets</a>.<div class="node"><p><hr><a name="Bugs"></a>Previous: <a rel="previous" accesskey="p" href="#Reading">Reading</a>,Up: <a rel="up" accesskey="u" href="#Overview">Overview</a></div><h3 class="section">1.2 Problems and Bugs</h3><p><a name="index-reporting-bugs-4"></a><a name="index-bugs_002c-reporting-5"></a><a name="index-problems-and-bugs_002c-reporting-6"></a>If you have problems with GNU <code>make</code> or think you've found a bug,please report it to the developers; we cannot promise to do anything butwe might well want to fix it. <p>Before reporting a bug, make sure you've actually found a real bug. Carefully reread the documentation and see if it really says you can dowhat you're trying to do. If it's not clear whether you should be ableto do something or not, report that too; it's a bug in thedocumentation! <p>Before reporting a bug or trying to fix it yourself, try to isolate itto the smallest possible makefile that reproduces the problem. Thensend us the makefile and the exact results <code>make</code> gave you,including any error or warning messages. Please don't paraphrasethese messages: it's best to cut and paste them into your report. When generating this small makefile, be sure to not use any non-freeor unusual tools in your commands: you can almost always emulate whatsuch a tool would do with simple shell commands. Finally, be sure toexplain what you expected to occur; this will help us decide whetherthe problem was really in the documentation. <p>Once you have a precise problem you can report it in one of two ways. Either send electronic mail to:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -