logo资料库

GNU+Autoconf+Automake+and+Libtool.pdf

第1页 / 共208页
第2页 / 共208页
第3页 / 共208页
第4页 / 共208页
第5页 / 共208页
第6页 / 共208页
第7页 / 共208页
第8页 / 共208页
资料共208页,剩余部分请下载后查看
GNU Autoconf Automake and Libtool
Start.htm
Toc.htm
___left.htm
Chapter 1. History
1.1 The Diversity of Unix Systems
1.2 The First configure Programs
1.3 configure Development
1.4 Automake Development
1.5 Libtool Development
1.6 Microsoft Windows
Chapter 2. How to Run Configure, and The Most Useful Standard Makefile Targets
2.1 Configuring
2.2 Files Generated by 'configure'
2.3 The Most Useful 'Makefile' Targets
2.4 Configuration Names
Chapter 3. Introducing 'Makefile's
3.1 Targets and Dependencies
3.2 'Makefile' Syntax
3.3 Macros
Chapter 4. Using GNU Autotools to Manage a "Minimal Project"
4.1 User-Provided Input Files
4.2 Generated Output Files
4.3 Maintaining Input Files
4.4 Packaging Generated Files
4.5 Documentation and ChangeLogs
Chapter 5. Writing a Portable 'configure.in'
5.1 What Is Portability?
5.2 Brief Introduction to Portable sh
5.3 Ordering Tests
5.4 What to Check For
5.5 Using Configuration Names
Chapter 6. Introducing GNU Automake
6.1 General Automake Principles
6.2 Frequently Asked Questions
6.3 Introduction to Primaries
6.4 The Easy Primaries
6.5 Programs and Libraries
6.6 Multiple Directories
6.7 Testing
Chapter 7. A Small GNU Autotools Project
7.1 GNU Autotools in Practice
7.2 A Simple Shell Builders Library
7.3 A Sample Shell Application
Chapter 8. Bootstrapping
Chapter 9. Introducing GNU Libtool
9.1 Creating libtool
9.2 The Libtool Library
9.3 Linking an Executable
9.4 Linking a Library
9.5 Executing Uninstalled Binaries
9.6 Installing a Library
9.7 Installing an Executable
9.8 Uninstalling
9.4.1 Interlibrary Dependencies
9.4.2 Using Convenience Libraries
Chapter 10. Using GNU Libtool with 'configure.in' and 'Makefile.am'
10.1 Integration with 'configure.in'
10.2 Integration with 'Makefile.am'
10.3 Using libtoolize
10.4 Library Versioning
10.5 Convenience Libraries
Chapter 11. A Large GNU Autotools Project
11.1 Using Libtool Libraries
11.2 Removing '--foreign'
11.3 Installing Header Files
11.4 Including Texinfo Documentation
11.5 Adding a Test Suite
Chapter 12. Rolling Distribution Tarballs
12.1 Introduction to Distributions
12.2 What Goes In
12.3 The distcheck Rule
12.4 Some Caveats
12.5 Implementation
Chapter 13. Installing and Uninstalling Configured Packages
13.1 Where Files Are Installed
13.2 Fine-Grained Control of Install
13.3 Install Hooks
13.4 Uninstall
Chapter 14. Writing Portable C with GNU Autotools
14.1 C Language Portability
14.2 Cross-Unix Portability
14.3 Unix/Windows Portability
Chapter 15. Writing Portable C++ with GNU Autotools
15.1 Brief History of C++
15.2 Changeable C++
15.3 Compiler Quirks
15.4 How GNU Autotools Can Help
15.5 Further Reading
Chapter 16. Dynamic Loading
16.1 Dynamic Modules
16.2 Module Access Functions
16.3 Finding a Module
16.4 A Simple GNU/Linux Module Loader
16.5 A Simple GNU/Linux Dynamic Module
Chapter 17. Using GNU libltdl
17.1 Introducing libltdl
17.2 Using libltdl
17.3 Portable Library Design
17.4 dlpreopen Loading
17.5 User Module Loaders
Chapter 18. Advanced GNU Automake Usage
18.1 Conditionals
18.2 Language Support
18.3 Automatic Dependency Tracking
Chapter 19. A Complex GNU Autotools Project
19.1 A Module-Loading Subsystem
19.2 A Loadable Module
19.3 Interpreting Commands from a File
19.4 Integrating Dmalloc
Chapter 20. GNU M4
20.1 What Does M4 Do?
20.2 How GNU Autotools Uses M4
20.3 Fundamentals of M4 Processing
20.4 Features of M4
20.5 Writing Macros Within the GNU Autotools Framework
Chapter 21. Writing Portable Bourne Shell
21.1 Why Use the Bourne Shell?
21.2 Implementation
21.3 Environment
21.4 Utilities
Chapter 22. Writing New Macros for Autoconf
22.1 Autoconf Preliminaries
22.2 Reusing Existing Macros
22.3 Guidelines for Writing Macros
22.4 Implementation Specifics
22.5 Future Directions for Macro Writers
22.3.1 Noninteractive Behavior
22.3.2 Testing System Features at Application Runtime
22.3.3 Output from Macros
22.3.4 Naming Macros
22.3.5 Macro Interface
Chapter 23. Migrating an Existing Package to GNU Autotools
23.1 Why Autoconfiscate?
23.2 Overview of the Two Approaches
23.3 Example: Quick and Dirty
23.4 Example: The Full Pull
Chapter 24. Using GNU Autotools with Cygnus' Cygwin
24.1 Preliminaries
24.2 Installing GNU Autotools on Cygwin
24.3 Writing a Cygwin-Friendly Package
24.4 DLLs with Libtool
24.5 Package Installation
Chapter 25. Cross-Compilation with GNU Autotools
25.1 Host and Target
25.2 Specifying the Target
25.3 Using the Target Type
25.4 Building with a Cross-Compiler
About the Authors
About the Technical Reviewers
Acknowledgments
Tell Us What You Think
Foreword
Introduction
I.1 What This Book Is
I.2 What This Book Is Not
I.3 Who Should Read This Book
I.4 How This Book Is Organized
I.5 Conventions Used in This Book
Appendix A. Installing GNU Autotools
A.1 Prerequisite Tools
A.2 Downloading GNU Autotools
A.3 Installing the Tools
Appendix B. Platforms
Appendix C. Generated File Dependencies
C.1 aclocal
C.2 autoheader
C.3 automake and libtoolize
C.4 autoconf
C.5 configure
C.6 make
Appendix D. Autoconf Macro Reference
Chapter E. Open Publication License
I REQUIREMENTS ON BOTH UNMODIFIED AND MODIFIED VERSIONS
II COPYRIGHT
III SCOPE OF LICENSE
IV REQUIREMENTS ON MODIFIED WORKS
V GOOD-PRACTICE RECOMMENDATIONS
VI LICENSE OPTIONS
OPEN PUBLICATION POLICY APPENDIX
Copyright
GNU Autoconf Automake and Libtool
1 GNU Autoconf Automake and Libtool Vaughan , V. Gary, Ben Elliston, Tom Tromey, Ian Lance Taylor 1
2 If you are a developer and are looking to participate in the Open Source development growth area you will need to learn new Open Source tools. GNU autoconf, GNU automake and GNU libtool are key tools for Open Source application development. These tools are not easy to learn, so some of the leading authorities on these tools have agreed to work together on this book to teach developers how to boost their productivity and the portability of their application. This book place New Riders/MTP at the center of the Open Source development community. Autoconf, Automake and Libtool is an efficient discourse on the use of autoconf, automake and libtool aimed at reducing the steep learning curve normally associated with these tools. This is a study guide to the interactions between the tools, and how best to get them to cooperate. If you are a developer and have no GNU build environment expertise, this book will help you develop these tools completely and confidently. Copyright About the Authors About the Technical Reviewers Acknowledgments Tell Us What You Think Foreword Introduction Section I.1. What This Book Is Section I.2. What This Book Is Not Section I.3. Who Should Read This Book Section I.4. How This Book Is Organized Section I.5. Conventions Used in This Book Chapter 1. History Section 1.1. The Diversity of Unix Systems Section 1.2. The First configure Programs Section 1.3. configure Development Section 1.4. Automake Development Section 1.5. Libtool Development Section 1.6. Microsoft Windows Chapter 2. How to Run Configure, and The Most Useful Standard Makefile Targets Section 2.1. Configuring Section 2.2. Files Generated by 'configure' Section 2.3. The Most Useful 'Makefile' Targets 2
Section 2.4. Configuration Names Chapter 3. Introducing 'Makefile's Section 3.1. Targets and Dependencies Section 3.2. 'Makefile' Syntax Section 3.3. Macros Chapter 4. Using GNU Autotools to Manage a "Minimal Project" 3 Section 4.1. User-Provided Input Files Section 4.2. Generated Output Files Section 4.3. Maintaining Input Files Section 4.4. Packaging Generated Files Section 4.5. Documentation and ChangeLogs Chapter 5. Writing a Portable 'configure.in' Section 5.1. What Is Portability? Section 5.2. Brief Introduction to Portable sh Section 5.3. Ordering Tests Section 5.4. What to Check For Section 5.5. Using Configuration Names Chapter 6. Introducing GNU Automake Section 6.1. General Automake Principles Section 6.2. Frequently Asked Questions Section 6.3. Introduction to Primaries Section 6.4. The Easy Primaries Section 6.5. Programs and Libraries Section 6.6. Multiple Directories Section 6.7. Testing Chapter 7. A Small GNU Autotools Project Section 7.1. GNU Autotools in Practice Section 7.2. A Simple Shell Builders Library Section 7.3. A Sample Shell Application Chapter 8. Bootstrapping Chapter 9. Introducing GNU Libtool Section 9.1. Creating libtool Section 9.2. The Libtool Library Section 9.3. Linking an Executable Section 9.4. Linking a Library Section 9.4.1. Interlibrary Dependencies Section 9.4.2. Using Convenience Libraries Section 9.5. Executing Uninstalled Binaries Section 9.6. Installing a Library Section 9.7. Installing an Executable Section 9.8. Uninstalling Chapter 10. Using GNU Libtool with 'configure.in' and 'Makefile.am' Section 10.1. Integration with 'configure.in' Section 10.2. Integration with 'Makefile.am' Section 10.3. Using libtoolize Section 10.4. Library Versioning Section 10.5. Convenience Libraries Chapter 11. A Large GNU Autotools Project Section 11.1. Using Libtool Libraries Section 11.2. Removing '--foreign' Section 11.3. Installing Header Files Section 11.4. Including Texinfo Documentation Section 11.5. Adding a Test Suite Chapter 12. Rolling Distribution Tarballs Section 12.1. Introduction to Distributions Section 12.2. What Goes In Section 12.3. The distcheck Rule 3
4 Section 12.4. Some Caveats Section 12.5. Implementation Chapter 13. Installing and Uninstalling Configured Packages Section 13.1. Where Files Are Installed Section 13.2. Fine-Grained Control of Install Section 13.3. Install Hooks Section 13.4. Uninstall Chapter 14. Writing Portable C with GNU Autotools Section 14.1. C Language Portability Section 14.2. Cross-Unix Portability Section 14.3. Unix/Windows Portability Chapter 15. Writing Portable C++ with GNU Autotools Section 15.1. Brief History of C++ Section 15.2. Changeable C++ Section 15.3. Compiler Quirks Section 15.4. How GNU Autotools Can Help Section 15.5. Further Reading Chapter 16. Dynamic Loading Section 16.1. Dynamic Modules Section 16.2. Module Access Functions Section 16.3. Finding a Module Section 16.4. A Simple GNU/Linux Module Loader Section 16.5. A Simple GNU/Linux Dynamic Module Chapter 17. Using GNU libltdl Section 17.1. Introducing libltdl Section 17.2. Using libltdl Section 17.3. Portable Library Design Section 17.4. dlpreopen Loading Section 17.5. User Module Loaders Chapter 18. Advanced GNU Automake Usage Section 18.1. Conditionals Section 18.2. Language Support Section 18.3. Automatic Dependency Tracking Chapter 19. A Complex GNU Autotools Project Section 19.1. A Module-Loading Subsystem Section 19.2. A Loadable Module Section 19.3. Interpreting Commands from a File Section 19.4. Integrating Dmalloc Chapter 20. GNU M4 Section 20.1. What Does M4 Do? Section 20.2. How GNU Autotools Uses M4 Section 20.3. Fundamentals of M4 Processing Section 20.4. Features of M4 Section 20.5. Writing Macros Within the GNU Autotools Framework Chapter 21. Writing Portable Bourne Shell Section 21.1. Why Use the Bourne Shell? Section 21.2. Implementation Section 21.3. Environment Section 21.4. Utilities Chapter 22. Writing New Macros for Autoconf Section 22.1. Autoconf Preliminaries Section 22.2. Reusing Existing Macros Section 22.3. Guidelines for Writing Macros Section 22.3.1. Noninteractive Behavior Section 22.3.2. Testing System Features at Application Runtime Section 22.3.3. Output from Macros Section 22.3.4. Naming Macros 4
5 Section 22.3.5. Macro Interface Section 22.4. Implementation Specifics Section 22.5. Future Directions for Macro Writers Chapter 23. Migrating an Existing Package to GNU Autotools Section 23.1. Why Autoconfiscate? Section 23.2. Overview of the Two Approaches Section 23.3. Example: Quick and Dirty Section 23.4. Example: The Full Pull Chapter 24. Using GNU Autotools with Cygnus' Cygwin Section 24.1. Preliminaries Section 24.2. Installing GNU Autotools on Cygwin Section 24.3. Writing a Cygwin-Friendly Package Section 24.4. DLLs with Libtool Section 24.5. Package Installation Chapter 25. Cross-Compilation with GNU Autotools Section 25.1. Host and Target Section 25.2. Specifying the Target Section 25.3. Using the Target Type Section 25.4. Building with a Cross-Compiler Appendix A. Installing GNU Autotools Section A.1. Prerequisite Tools Section A.2. Downloading GNU Autotools Section A.3. Installing the Tools Appendix B. Platforms Appendix C. Generated File Dependencies Section C.1. aclocal Section C.2. autoheader Section C.3. automake and libtoolize Section C.4. autoconf Section C.5. configure Section C.6. make Appendix D. Autoconf Macro Reference Chapter E. Open Publication License Section I. REQUIREMENTS ON BOTH UNMODIFIED AND MODIFIED VERSIONS Section II. COPYRIGHT Section III. SCOPE OF LICENSE Section IV. REQUIREMENTS ON MODIFIED WORKS Section V. GOOD-PRACTICE RECOMMENDATIONS Section VI. LICENSE OPTIONS OPEN PUBLICATION POLICY APPENDIX Top open all | close all Generated by CHM Decoder Need you translate this to other language? Get CHM Editor Now! Chapter 1. History This chapter summarizes the history of the tools described in this book. Although you do not need to know this history to use the tools, the history of how the tools developed over time helps explain why the tools act the way that they do today. Also, in a book such as this, it is only fair for us to credit the original authors and sources of inspiration and to explain what they did. 5
6 1.1 The Diversity of Unix Systems Of the programs discussed in this book, the first to be developed was autoconf. The history of the Unix operating system determined its development. Dennis Ritchie of Bell Labs wrote the first version of Unix in 1969. During the 1970s, Bell Labs was not permitted to sell Unix commercially, but did distribute Unix to universities at relatively low cost. The University of California at Berkeley added their own improvements to the Unix sources; the result was known as the BSD version of Unix. In the early 1980s, AT&T signed an agreement permitting them to sell Unix commercially. The first AT&T version of Unix was known as System III. As the popularity of Unix increased during the 1980s, several other companies modified the Unix sources to create their own variants. Examples include SunOS from Sun Microsystems, Ultrix from Digital Equipment Corporation, and HP-UX from Hewlett Packard. Although all the Unix variants were fundamentally similar, various differences existed between them. They had slightly different sets of header files and slightly different lists of functions in the system libraries, as well as more significant differences in areas such as terminal handling and job control. The emerging POSIX standards helped to eliminate some of these differences. In some areas, however, POSIX introduced new features, leading to more variants. Also, different systems adopted the POSIX standard at different times, leading to further disparities. All these variations caused problems for programs distributed as source code. Even a function as straightforward as memcpy was not available everywhere; the BSD system library provided the similar function bcopy instead, but the order of arguments was reversed. Program authors who wanted their programs to run on a wide variety of Unix variants had to be familiar with the detailed differences between the variants. They also had to worry about the ways in which the variants changed from one version to another, as variants on the one hand converged on the POSIX standard and on the other continued to introduce new and different features. Although it was generally possible to use #ifdef to identify particular systems and versions, it became increasingly difficult to know which versions had which features. It became clear that some more organized approach was needed to handle the differences between Unix variants. By 1992, four different systems had been developed to help with source-code portability: • • • • The metaconfig program, by Larry Wall, Harlan Stenn, and Raphael Manfredi. The Cygnus 'configure' script, by K. Richard Pixley, and the original GCC 'configure' script, by Richard Stallman. These are quite similar, and the developers communicated regularly. GCC is the GNU Compiler Collection (formerly the GNU C compiler). The GNU Autoconf package, by David MacKenzie. Imake, part of the X Window system. These systems all split building a program into two steps: a configuration step and a build step. For all the systems, the build step used the standard Unix make program. The make program reads a set of rules in a 'Makefile', and uses them to build a program. The configuration step generates 'Makefile's, and perhaps other files, which are then used during the build step. Metaconfig and Autoconf both use feature tests to determine the capabilities of the system. They use Bourne shell scripts (all variants of Unix support the Bourne shell in one form or another) to run various tests to see what the system can support. 6
7 The Cygnus 'configure' script and the original GCC 'configure' script are also Bourne shell scripts. They rely on little configuration files for each system variant, both header files and 'Makefile' fragments. In early versions, the user compiling the program had to tell the script which type of system the program should be built for; they were later enhanced with a shell script written by Per Bothner, which determines the system type based on the standard Unix uname program and other information. imake is a portable C program. imake can be customized for a particular system, and run as part of building a package. It is more normally distributed with a package, however, including all the configuration information needed for supported systems. metaconfig and autoconf are programs used by program authors. They produce a shell script distributed with the program's source code. A user who wants to build the program runs the shell script to configure the source code for the particular system on which it is to be built. The Cygnus and GCC 'configure' scripts, and imake, do not have this clear distinction between use by the developer and use by the user. The Cygnus and GCC 'configure' scripts included features to support cross development, both to support building a cross-compiler (which compiles code to be run on another system) and to support building a program using a cross-compiler. autoconf, metaconfig, and imake did not have these features (they were later added to autoconf); they worked only for building a program on the system on which they were to run. The scripts generated by metaconfig are interactive by default: They ask questions of the users as they go along. This permits them to determine certain characteristics of the system, which it is difficult or impossible to test, such as the behavior of setuid programs. The Cygnus and GCC 'configure' scripts, and the scripts generated by autoconf, and the imake program, are not interactive; they determine everything themselves. When using autoconf, the package developer normally writes the script to accept command-line options for features that cannot be tested for, or sometimes requires the user to edit a header file after the 'configure' script has run. The Cygnus 'configure' script and the original GCC 'configure' script both had to be updated for each new Unix variant they supported. This meant that packages that used them were continually out of date as new Unix variants appeared. It was not hard for the developer to add support for a new system variant; however, package users could not do so easily themselves. The same was true of Imake as it was commonly used. Although it was possible for a user to build and configure Imake for a particular system, it was not commonly done. In practice, packages that use Imake (such as the X Window system) are shipped with configuration information detailed for specific Unix variants. Because Metaconfig and Autoconf used feature tests, the scripts they generated could often work correctly on new Unix variants without modification. This made them more flexible and easier to work with over time, and led to the wide adoption of Autoconf. In 1994, David MacKenzie extended Autoconf to incorporate the features of the Cygnus 'configure' script and the original GCC 'configure' script. This included support for using system-specified header file and 'Makefile' fragments, and support for cross-compilation. GCC has since been converted to use Autoconf, eliminating the GCC 'configure' script. Most programs that use the Cygnus 'configure' script have also been converted, and no new programs are being written to use the Cygnus 'configure' script. The metaconfig program is still used today to configure Perl and a few other programs. imake is still used to configure the X Window system. However, these tools are not generally used for new packages. 7
分享到:
收藏