没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Managing Projects with GNU Make, Third Edition
by Robert Mecklenburg
Copyright © 2005, 1991, 1986 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (safari.oreilly.com). For more information, contact our corporate/insti-
tutional sales department: (800) 998-9938 or corporate@oreilly.com.
Editor:
Andy Oram
Production Editor:
Matt Hutchinson
Production Services:
Octal Publishing, Inc.
Cover Designer:
Edie Freedman
Interior Designer:
David Futato
Printing History:
1986: First Edition.
October 1991: Second Edition.
November 2004: Third Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Managing Projects with GNU Make, the image of a potto, and related trade dress
are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
Permission is granted to copy, distribute, and/or modify this document under the terms of the GNU
Free Documentation License, Version 1.1 or any later version published by the Free Software
Foundation. A copy of this license is included in Appendix C.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.
This book uses RepKover
™
, a durable and flexible lay-flat binding.
ISBN: 0-596-00610-1
[M]
vii
Table of Contents
Foreword
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xi
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xiii
Part I. Basic Concepts
1. How to Write a Simple Makefile
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
Targets and Prerequisites 4
Dependency Checking 6
Minimizing Rebuilds 7
Invoking make 7
Basic Makefile Syntax 8
2. Rules
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
Explicit Rules 10
Variables 16
Finding Files with VPATH and vpath 17
Pattern Rules 21
The Implicit Rules Database 25
Special Targets 30
Automatic Dependency Generation 31
Managing Libraries 34
3. Variables and Macros
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
41
What Variables Are Used For 42
Variable Types 43
Macros 45
,make3TOC.fm.12345 Page vii Friday, March 25, 2005 3:17 PM
viii | Table of Contents
When Variables Are Expanded 47
Target- and Pattern-Specific Variables 50
Where Variables Come From 51
Conditional and include Processing 54
Standard make Variables 57
4. Functions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
61
User-Defined Functions 61
Built-in Functions 64
Advanced User-Defined Functions 80
5. Commands
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
88
Parsing Commands 88
Which Shell to Use 96
Empty Commands 97
Command Environment 98
Evaluating Commands 99
Command-Line Limits 100
Part II. Advanced and Specialized Topics
6. Managing Large Projects
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
107
Recursive make 108
Nonrecursive make 117
Components of Large Systems 124
Filesystem Layout 126
Automating Builds and Testing 128
7. Portable Makefiles
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
129
Portability Issues 130
Cygwin 131
Managing Programs and Files 134
Working with Nonportable Tools 137
Automake 139
8. C and C++
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
141
Separating Source and Binary 141
Read-Only Source 149
Dependency Generation 149
,make3TOC.fm.12345 Page viii Friday, March 25, 2005 3:17 PM
Table of Contents | ix
Supporting Multiple Binary Trees 154
Partial Source Trees 156
Reference Builds, Libraries, and Installers 157
9. Java
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
159
Alternatives to make 160
A Generic Java Makefile 164
Compiling Java 168
Managing Jars 175
Reference Trees and Third-Party Jars 177
Enterprise JavaBeans 178
10. Improving the Performance of make
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
182
Benchmarking 182
Identifying and Handling Bottlenecks 186
Parallel make 190
Distributed make 194
11. Example Makefiles
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
196
The Book Makefile 196
The Linux Kernel Makefile 218
12. Debugging Makefiles
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
229
Debugging Features of make 229
Writing Code for Debugging 236
Common Error Messages 241
Part III. Appendixes
A. Running make
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
249
B. The Outer Limits
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
252
C. GNU Free Documentation License—GNU Project—Free Software
Foundation (FSF)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
263
Index
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
271
,make3TOC.fm.12345 Page ix Friday, March 25, 2005 3:17 PM
剩余284页未读,继续阅读
资源评论
loopum
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功