Autotools: A Practitioner's Guide to GNU Autoconf, Automake, and Libtool

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

The long awaited update to the practitioner's guide to GNU Autoconf, Automake, and Libtool The GNU Autotools make it easy for developers to create software that is portable across many Unix-like operating systems, and even Windows. Although the Autotools are used by thousands of open source software packages, they have a notoriously steep learning curve. Autotools is the first book to offer programmers a tutorial-based guide to the GNU build system. Author John Calcote begins with an overview of high-level concepts and a hands-on tour of the philosophy and design of the Autotools. He then tackles more advanced details, like using the M4 macro processor with Autoconf, extending the framework provided by Automake, and building Java and C# sources. He concludes with solutions to frequent problems encountered by Autotools users. This thoroughly revised second edition has been updated to cover the latest versions of the Autotools. It includes five new chapters on topics like pkg-config, unit and integration testing with Autotest, internationalizing with GNU tools, the portability of gnulib, and using the Autotools with Windows. As with the first edition, you'll focus on two projects: Jupiter, a simple "Hello, world!" program, and FLAIM, an existing, complex open source effort containing four separate but interdependent projects. Follow along as the author takes Jupiter's build system from a basic makefile to a full-fledged Autotools project, and then as he converts the FLAIM projects from complex, hand-coded makefiles to the powerful and flexible GNU build system. Learn how to: • Master the Autotools build system to maximize your software's portability • Generate Autoconf configuration scripts to simplify the compilation process • Produce portable makefiles with Automake • Build cross-platform software libraries with Libtool • Write your own Autoconf macros This detailed introduction to the GNU Autotools is indispensable for developers and programmers looking to gain a deeper understanding of this complex suite of tools. Stop fighting against the system and make sense of it all with the second edition of Autotools!

Author(s): John Calcote
Edition: 2
Publisher: No Starch Press
Year: 2019

Language: English
Commentary: Vector PDF
Pages: 584
City: San Francisco, CA
Tags: Linux; Unix; C++; Go; C; Packaging System; Automation; Systems Programming

Brief Contents
Contents in Detail
Foreword for the First Edition
Foreword for the Second Edition
Preface
Why Use the Autotools?
Acknowledgments for the First Edition
Acknowledgments for the Second Edition
I Wish You the Very Best
Introduction
Who Should Read This Book
How This Book Is Organized
Conventions Used in This Book
Autotools Versions Used in This Book
Chapter 1: An End User’s Perspective on the GNU Autotools
Software Source Archives
Unpacking a Source Archive
Building the Software
Testing the Build
Installing the Built Software
Summary
Chapter 2: A Brief Introduction to the GNU Autotools
Who Should Use the Autotools?
When Should You Not Use the Autotools?
Apple Platforms and Mac OS X
The Choice of Language
Generating Your Package Build System
Configuration
Autoconf
autoreconf
autoheader
autoscan
autoupdate
ifnames
autom4te
Working Together
Automake
automake
aclocal
Libtool
libtool
libtoolize
ltdl, the Libtool C API
Building Your Package
Running configure
Running make
Installing the Most Up-to-Date Autotools
Summary
Chapter 3: Understanding the GNU Coding Standards
Creating a New Project Directory Structure
Project Structure
Makefile Basics
Rules
Variables
A Separate Shell for Each Command
Variable Binding
Rules in Detail
Resources for Makefile Authors
Creating a Source Distribution Archive
Forcing a Rule to Run
Leading Control Characters
Automatically Testing a Distribution
Unit Testing, Anyone?
Installing Products
Installation Choices
Uninstalling a Package
Testing Install and Uninstall
The Filesystem Hierarchy Standard
Supporting Standard Targets and Variables
Standard Targets
Standard Variables
Adding Location Variables to Jupiter
Getting Your Project into a Linux Distro
Build vs. Installation Prefix Overrides
User Variables
Nonrecursive Build Systems
Configuring Your Package
Summary
Chapter 4: Configuring Your Project with Autoconf
Autoconf Configuration Scripts
The Shortest configure.ac File
Comparing M4 to the C Preprocessor
The Nature of M4 Macros
Executing autoconf
Executing configure
Executing config.status
Adding Some Real Functionality
Generating Files from Templates
Adding VPATH Build Functionality
Let’s Take a Breather
An Even Quicker Start with autoscan
The Proverbial bootstrap.sh Script
Updating Makefile.in
Initialization and Package Information
AC_PREREQ
AC_INIT
AC_CONFIG_SRCDIR
The Instantiating Macros
Generating Header Files from Templates
Using autoheader to Generate an Include File Template
Back to Remote Builds for a Moment
Summary
Chapter 5: More Fun with Autoconf: Configuring User Options
Substitutions and Definitions
AC_SUBST
AC_DEFINE
Checking for Compilers
Checking for Other Programs
A Common Problem with Autoconf
Checks for Libraries and Header Files
Is It Right or Just Good Enough?
Printing Messages
Supporting Optional Features and Packages
Coding Up the Feature Option
Formatting Help Strings
Checks for Type and Structure Definitions
The AC_OUTPUT Macro
Summary
Chapter 6: Automatic Makefiles with Automake
Getting Down to Business
Enabling Automake in configure.ac
A Hidden Benefit: Automatic Dependency Tracking
What’s Actually in a Makefile.am File?
Analyzing Our New Build System
Product List Variables
Product Source Variables
PLV and PSV Modifiers
Unit Tests: Supporting make check
Reducing Complexity with Convenience Libraries
Product Option Variables
Per-Makefile Option Variables
Building the New Library
What Goes into a Distribution?
Maintainer Mode
Cutting Through the Noise
Nonrecursive Automake
Summary
Chapter 7: Building Libraries with Libtool
The Benefits of Shared Libraries
How Shared Libraries Work
Dynamic Linking at Load Time
Using Libtool
Abstracting the Build Process
Abstraction at Runtime
Installing Libtool
Adding Shared Libraries to Jupiter
Using the LTLIBRARIES Primary
Public Include Directories
Customizing Libtool with LT_INIT Options
Reconfigure and Build
So What Is PIC, Anyway?
Fixing the Jupiter PIC Problem
Summary
Chapter 8: Library Interface Versioning and Runtime Dynamic Linking
System-Specific Versioning
Linux and Solaris Library Versioning
IBM AIX Library Versioning
Microsoft DLL Versioning
HP-UX/AT&T SVR4 Library Versioning
The Libtool Library Versioning Scheme
Library Versioning Is Interface Versioning
When Library Versioning Just Isn’t Enough
Using libltdl
Necessary Infrastructure
Adding a Plug-In Interface
Doing It the Old-Fashioned Way
Converting to Libtool’s ltdl Library
Preloading Multiple Modules
Checking It All Out
Summary
Chapter 9: Unit and Integration Testing with Autotest
Autotest Overview
Wiring Up Autotest
Adding a Test
Defining Tests with AT_CHECK
Defining Test Groups with AT_SETUP and AT_CLEANUP
So What Happened?
Unit Testing vs. Integration Testing
Administrative Details
Distributing Test Files
Checking Installed Products
Cleaning Up
Niceties
A Minimal Approach
Summary
Chapter 10: Finding Build Dependencies with pkg-config
A pkg-config Overview
Diving In
Writing pkg-config Metadata Files
Informational Fields
Functional Fields
Generating .pc Files with Autoconf
Generating pc Files from pc.in Templates
Generating .pc Files with make
Uninstalled .pc Files
Using pkg-config in configure.ac
pkg-config Autoconf Macros
Summary
Chapter 11: Internationalization
Obligatory Disclaimer
Internationalization (I18n)
Instrumenting Source Code for Dynamic Messages
Instrumenting Source Code for Static Messages
Summary
Chapter 12: Localization
Getting Started
Language Selection
Building Message Catalogs
Integrating gettext with the Autotools
What Should Be Committed?
Adding a Language
Installing Language Files
Manual make Targets
Summary
Chapter 13: Maximum Portability with Gnulib
License Caveat
Getting Started
Adding Gnulib Modules to a Project
Summary
Chapter 14: FLAIM: An Autotools Example
What Is FLAIM?
Why FLAIM?
Logistics
An Initial Look
Getting Started
Adding the configure.ac Files
The Top-Level Makefile.am File
The FLAIM Subprojects
The FLAIM Toolkit configure.ac File
The FLAIM Toolkit Makefile.am File
Designing the ftk/src/Makefile.am File
Moving On to the ftk/util Directory
Designing the XFLAIM Build System
The XFLAIM configure.ac File
Creating the xflaim/src/Makefile.am File
Turning to the xflaim/util Directory
Summary
Chapter 15: FLAIM Part II: Pushing the Envelope
Building Java Sources Using the Autotools
Autotools Java Support
Using ac-archive Macros
Canonical System Information
The xflaim/java Directory Structure
The xflaim/src/Makefile.am File
Building the JNI C++ Sources
The Java Wrapper Classes and JNI Headers
A Caveat About Using the JAVA Primary
Building the C# Sources
Manual Installation
Cleaning Up Again
Configuring Compiler Options
Hooking Doxygen into the Build Process
Adding Nonstandard Targets
Summary
Chapter 16: Using the M4 Macro Processor with Autoconf
M4 Text Processing
Defining Macros
Macros with Arguments
The Recursive Nature of M4
Infinite Recursion
Quoting Rules
Autoconf and M4
Writing Autoconf Macros
Simple Text Replacement
Documenting Your Macros
M4 Conditionals
Diagnosing Problems
Summary
Chapter 17: Using the Autotools with Windows
Environment Options
Tool Chain Options
Getting Started
Cross-Compiling for Windows on Linux
Installing a Windows Cross Tool Chain
Testing the Build
Windows Subsystem for Linux
Cygwin
Installing Cygwin
Opening the Cygwin Terminal
Testing the Build
Building True Native Windows Software
Analyzing the Software
MinGW: Minimalist GNU for Windows
Installing MinGW
Testing the Build
Msys2
What’s Msys?
Installing Msys2
Installing Tools
Testing the Build
Summary
Chapter 18: A Catalog of Tips and Reusable Solutions for Creating Great Projects
Item 1: Keeping Private Details out of Public Interfaces
Solutions in C
Solutions in C++
Item 2: Implementing Recursive Extension Targets
Item 3: Using a Repository Revision Number in a Package Version
Item 4: Ensuring Your Distribution Packages Are Clean
Item 5: Hacking Autoconf Macros
Providing Library-Specific Autoconf Macros
Item 6: Cross-Compiling
Item 7: Emulating Autoconf Text Replacement Techniques
Item 8: Using the Autoconf Archive Project
Item 9: Using Incremental Installation Techniques
Item 10: Using Generated Source Code
Using the BUILT_SOURCES Variable
Dependency Management
Built Sources Done Right
Item 11: Disabling Undesirable Targets
Item 12: Watch Those Tab Characters!
Item 13: Packaging Choices
Wrapping Up
Index