⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make.html

📁 Linux下Makefile的编写手册。全部是中文版
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<html lang="en"><head><title>GNU `make'</title><meta http-equiv="Content-Type" content="text/html"><meta name="description" content="GNU `make'"><meta name="generator" content="makeinfo 4.8"><link title="Top" rel="top" href="#Top"><link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"><!--This file documents the GNU `make' utility, which determinesautomatically which pieces of a large program need to be recompiled,and issues the commands to recompile them.This is Edition 0.70, last updated 1 April 2006,of `The GNU Make Manual', for GNU `make' version 3.81.Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006Free Software Foundation, Inc.     Permission is granted to copy, distribute and/or modify this     document under the terms of the GNU Free Documentation License,     Version 1.2 or any later version published by the Free Software     Foundation; with no Invariant Sections, with the Front-Cover Texts     being "A GNU Manual," and with the Back-Cover Texts as in (a)     below.  A copy of the license is included in the section entitled     "GNU Free Documentation License."     (a) The FSF's Back-Cover Text is: "You have freedom to copy and     modify this GNU Manual, like GNU software.  Copies published by     the Free Software Foundation raise funds for GNU development."   --><meta http-equiv="Content-Style-Type" content="text/css"><style type="text/css"><!--  pre.display { font-family:inherit }  pre.format  { font-family:inherit }  pre.smalldisplay { font-family:inherit; font-size:smaller }  pre.smallformat  { font-family:inherit; font-size:smaller }  pre.smallexample { font-size:smaller }  pre.smalllisp    { font-size:smaller }  span.sc    { font-variant:small-caps }  span.roman { font-family:serif; font-weight:normal; }   span.sansserif { font-family:sans-serif; font-weight:normal; } --></style></head><body><h1 class="settitle">GNU `make'</h1>   <div class="shortcontents"><h2>Short Contents</h2><ul><li><a href="#toc_Top">GNU <code>make</code></a></li><li><a href="#toc_Overview">1 Overview of <code>make</code></a></li><li><a href="#toc_Introduction">2 An Introduction to Makefiles</a></li><li><a href="#toc_Makefiles">3 Writing Makefiles</a></li><li><a href="#toc_Rules">4 Writing Rules</a></li><li><a href="#toc_Commands">5 Writing the Commands in Rules</a></li><li><a href="#toc_Using-Variables">6 How to Use Variables</a></li><li><a href="#toc_Conditionals">7 Conditional Parts of Makefiles</a></li><li><a href="#toc_Functions">8 Functions for Transforming Text</a></li><li><a href="#toc_Running">9 How to Run <code>make</code></a></li><li><a href="#toc_Implicit-Rules">10 Using Implicit Rules</a></li><li><a href="#toc_Archives">11 Using <code>make</code> to Update Archive Files</a></li><li><a href="#toc_Features">12 Features of GNU <code>make</code></a></li><li><a href="#toc_Missing">13 Incompatibilities and Missing Features</a></li><li><a href="#toc_Makefile-Conventions">14 Makefile Conventions</a></li><li><a href="#toc_Quick-Reference">Appendix A Quick Reference</a></li><li><a href="#toc_Error-Messages">Appendix B Errors Generated by Make</a></li><li><a href="#toc_Complex-Makefile">Appendix C Complex Makefile Example</a></li><li><a href="#toc_GNU-Free-Documentation-License">Appendix D GNU Free Documentation License</a></li><li><a href="#toc_Concept-Index">Index of Concepts</a></li><li><a href="#toc_Name-Index">Index of Functions, Variables, &amp; Directives</a></li></ul></div>   <div class="contents"><h2>Table of Contents</h2><ul><li><a name="toc_Top" href="#Top">GNU <code>make</code></a><li><a name="toc_Overview" href="#Overview">1 Overview of <code>make</code></a><ul><li><a href="#Reading">1.1 How to Read This Manual</a><li><a href="#Bugs">1.2 Problems and Bugs</a></li></ul><li><a name="toc_Introduction" href="#Introduction">2 An Introduction to Makefiles</a><ul><li><a href="#Rule-Introduction">2.1 What a Rule Looks Like</a><li><a href="#Simple-Makefile">2.2 A Simple Makefile</a><li><a href="#How-Make-Works">2.3 How <code>make</code> Processes a Makefile</a><li><a href="#Variables-Simplify">2.4 Variables Make Makefiles Simpler</a><li><a href="#make-Deduces">2.5 Letting <code>make</code> Deduce the Commands</a><li><a href="#Combine-By-Prerequisite">2.6 Another Style of Makefile</a><li><a href="#Cleanup">2.7 Rules for Cleaning the Directory</a></li></ul><li><a name="toc_Makefiles" href="#Makefiles">3 Writing Makefiles</a><ul><li><a href="#Makefile-Contents">3.1 What Makefiles Contain</a><li><a href="#Makefile-Names">3.2 What Name to Give Your Makefile</a><li><a href="#Include">3.3 Including Other Makefiles</a><li><a href="#MAKEFILES-Variable">3.4 The Variable <code>MAKEFILES</code></a><li><a href="#MAKEFILE_005fLIST-Variable">3.5 The Variable <code>MAKEFILE_LIST</code></a><li><a href="#Special-Variables">3.6 Other Special Variables</a><li><a href="#Remaking-Makefiles">3.7 How Makefiles Are Remade</a><li><a href="#Overriding-Makefiles">3.8 Overriding Part of Another Makefile</a><li><a href="#Reading-Makefiles">3.9 How <code>make</code> Reads a Makefile</a><li><a href="#Secondary-Expansion">3.10 Secondary Expansion</a></li></ul><li><a name="toc_Rules" href="#Rules">4 Writing Rules</a><ul><li><a href="#Rule-Example">4.1 Rule Example</a><li><a href="#Rule-Syntax">4.2 Rule Syntax</a><li><a href="#Prerequisite-Types">4.3 Types of Prerequisites</a><li><a href="#Wildcards">4.4 Using Wildcard Characters in File Names</a><ul><li><a href="#Wildcard-Examples">4.4.1 Wildcard Examples</a><li><a href="#Wildcard-Pitfall">4.4.2 Pitfalls of Using Wildcards</a><li><a href="#Wildcard-Function">4.4.3 The Function <code>wildcard</code></a></li></ul><li><a href="#Directory-Search">4.5 Searching Directories for Prerequisites</a><ul><li><a href="#General-Search">4.5.1 <code>VPATH</code>: Search Path for All Prerequisites</a><li><a href="#Selective-Search">4.5.2 The <code>vpath</code> Directive</a><li><a href="#Search-Algorithm">4.5.3 How Directory Searches are Performed</a><li><a href="#Commands_002fSearch">4.5.4 Writing Shell Commands with Directory Search</a><li><a href="#Implicit_002fSearch">4.5.5 Directory Search and Implicit Rules</a><li><a href="#Libraries_002fSearch">4.5.6 Directory Search for Link Libraries</a></li></ul><li><a href="#Phony-Targets">4.6 Phony Targets</a><li><a href="#Force-Targets">4.7 Rules without Commands or Prerequisites</a><li><a href="#Empty-Targets">4.8 Empty Target Files to Record Events</a><li><a href="#Special-Targets">4.9 Special Built-in Target Names</a><li><a href="#Multiple-Targets">4.10 Multiple Targets in a Rule</a><li><a href="#Multiple-Rules">4.11 Multiple Rules for One Target</a><li><a href="#Static-Pattern">4.12 Static Pattern Rules</a><ul><li><a href="#Static-Usage">4.12.1 Syntax of Static Pattern Rules</a><li><a href="#Static-versus-Implicit">4.12.2 Static Pattern Rules versus Implicit Rules</a></li></ul><li><a href="#Double_002dColon">4.13 Double-Colon Rules</a><li><a href="#Automatic-Prerequisites">4.14 Generating Prerequisites Automatically</a></li></ul><li><a name="toc_Commands" href="#Commands">5 Writing the Commands in Rules</a><ul><li><a href="#Command-Syntax">5.1 Command Syntax</a><ul><li><a href="#Splitting-Lines">5.1.1 Splitting Command Lines</a><li><a href="#Variables-in-Commands">5.1.2 Using Variables in Commands</a></li></ul><li><a href="#Echoing">5.2 Command Echoing</a><li><a href="#Execution">5.3 Command Execution</a><ul><li><a href="#Choosing-the-Shell">5.3.1 Choosing the Shell</a></li></ul><li><a href="#Parallel">5.4 Parallel Execution</a><li><a href="#Errors">5.5 Errors in Commands</a><li><a href="#Interrupts">5.6 Interrupting or Killing <code>make</code></a><li><a href="#Recursion">5.7 Recursive Use of <code>make</code></a><ul><li><a href="#MAKE-Variable">5.7.1 How the <code>MAKE</code> Variable Works</a><li><a href="#Variables_002fRecursion">5.7.2 Communicating Variables to a Sub-<code>make</code></a><li><a href="#Options_002fRecursion">5.7.3 Communicating Options to a Sub-<code>make</code></a><li><a href="#_002dw-Option">5.7.4 The `<samp><span class="samp">--print-directory</span></samp>' Option</a></li></ul><li><a href="#Sequences">5.8 Defining Canned Command Sequences</a><li><a href="#Empty-Commands">5.9 Using Empty Commands</a></li></ul><li><a name="toc_Using-Variables" href="#Using-Variables">6 How to Use Variables</a><ul><li><a href="#Reference">6.1 Basics of Variable References</a><li><a href="#Flavors">6.2 The Two Flavors of Variables</a><li><a href="#Advanced">6.3 Advanced Features for Reference to Variables</a><ul><li><a href="#Substitution-Refs">6.3.1 Substitution References</a><li><a href="#Computed-Names">6.3.2 Computed Variable Names</a></li></ul><li><a href="#Values">6.4 How Variables Get Their Values</a><li><a href="#Setting">6.5 Setting Variables</a><li><a href="#Appending">6.6 Appending More Text to Variables</a><li><a href="#Override-Directive">6.7 The <code>override</code> Directive</a><li><a href="#Defining">6.8 Defining Variables Verbatim</a><li><a href="#Environment">6.9 Variables from the Environment</a><li><a href="#Target_002dspecific">6.10 Target-specific Variable Values</a><li><a href="#Pattern_002dspecific">6.11 Pattern-specific Variable Values</a></li></ul><li><a name="toc_Conditionals" href="#Conditionals">7 Conditional Parts of Makefiles</a><ul><li><a href="#Conditional-Example">7.1 Example of a Conditional</a><li><a href="#Conditional-Syntax">7.2 Syntax of Conditionals</a><li><a href="#Testing-Flags">7.3 Conditionals that Test Flags</a></li></ul><li><a name="toc_Functions" href="#Functions">8 Functions for Transforming Text</a><ul><li><a href="#Syntax-of-Functions">8.1 Function Call Syntax</a><li><a href="#Text-Functions">8.2 Functions for String Substitution and Analysis</a><li><a href="#File-Name-Functions">8.3 Functions for File Names</a><li><a href="#Conditional-Functions">8.4 Functions for Conditionals</a><li><a href="#Foreach-Function">8.5 The <code>foreach</code> Function</a><li><a href="#Call-Function">8.6 The <code>call</code> Function</a><li><a href="#Value-Function">8.7 The <code>value</code> Function</a><li><a href="#Eval-Function">8.8 The <code>eval</code> Function</a><li><a href="#Origin-Function">8.9 The <code>origin</code> Function</a><li><a href="#Flavor-Function">8.10 The <code>flavor</code> Function</a><li><a href="#Shell-Function">8.11 The <code>shell</code> Function</a><li><a href="#Make-Control-Functions">8.12 Functions That Control Make</a></li></ul><li><a name="toc_Running" href="#Running">9 How to Run <code>make</code></a><ul><li><a href="#Makefile-Arguments">9.1 Arguments to Specify the Makefile</a><li><a href="#Goals">9.2 Arguments to Specify the Goals</a><li><a href="#Instead-of-Execution">9.3 Instead of Executing the Commands</a><li><a href="#Avoiding-Compilation">9.4 Avoiding Recompilation of Some Files</a><li><a href="#Overriding">9.5 Overriding Variables</a><li><a href="#Testing">9.6 Testing the Compilation of a Program</a><li><a href="#Options-Summary">9.7 Summary of Options</a></li></ul><li><a name="toc_Implicit-Rules" href="#Implicit-Rules">10 Using Implicit Rules</a><ul><li><a href="#Using-Implicit">10.1 Using Implicit Rules</a><li><a href="#Catalogue-of-Rules">10.2 Catalogue of Implicit Rules</a><li><a href="#Implicit-Variables">10.3 Variables Used by Implicit Rules</a><li><a href="#Chained-Rules">10.4 Chains of Implicit Rules</a><li><a href="#Pattern-Rules">10.5 Defining and Redefining Pattern Rules</a><ul><li><a href="#Pattern-Intro">10.5.1 Introduction to Pattern Rules</a><li><a href="#Pattern-Examples">10.5.2 Pattern Rule Examples</a><li><a href="#Automatic-Variables">10.5.3 Automatic Variables</a><li><a href="#Pattern-Match">10.5.4 How Patterns Match</a><li><a href="#Match_002dAnything-Rules">10.5.5 Match-Anything Pattern Rules</a><li><a href="#Canceling-Rules">10.5.6 Canceling Implicit Rules</a></li></ul><li><a href="#Last-Resort">10.6 Defining Last-Resort Default Rules</a><li><a href="#Suffix-Rules">10.7 Old-Fashioned Suffix Rules</a><li><a href="#Implicit-Rule-Search">10.8 Implicit Rule Search Algorithm</a></li></ul><li><a name="toc_Archives" href="#Archives">11 Using <code>make</code> to Update Archive Files</a><ul><li><a href="#Archive-Members">11.1 Archive Members as Targets</a><li><a href="#Archive-Update">11.2 Implicit Rule for Archive Member Targets</a><ul><li><a href="#Archive-Symbols">11.2.1 Updating Archive Symbol Directories</a></li></ul>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -