Autotools Mythbuster

Diego Elio “Flameeyes” Pettenò

Author and Publisher 

David J. “user99” Cozatt

Miscellaneous Editing 

This text is released under the CreativeCommons license Attribution-NonCommercial-ShareAlike 3.0 Unported. Please refer to Appendix B, License for the complete text of the license.


Autotools Mythbuster is a no-nonsense guide to Autotools, written with the idea of providing a full, integrated view of the tools in the GNU build chain: autoconf, automake, libtool, pkg-config, and so on.

Instead of providing a full detailing of the workings of the components, which most consumers are not interested on, this guide focuses on building useful, solid and distribution-friendly packages, that developers can submit to distributions without having to jump through hoops to get them accepted.

Autotools Mythbuster is available as an eBook for those who want to read or reference it online. Profits from its sales are used to pay for hosting and domain name registration.

You can find the book on all major Amazon websites, as well as Kobo and their franchises.

Table of Contents

1. Foreword
2. Why another guide about autotools?
3. How does this work?
1. Configuring The Build — autoconf
1. M4sh
2. Canonical Systems
3. Adding Options
4. Finding Libraries
5. Custom Autoconf Tests
6. Autoconf Building Blocks: Macros
7. Caching Results
2. Harnessing Make — automake
1. Available options
2. Non-recursive Automake
3. Silent Building with Automake
4. Parallel Building Tricks
5. Maintainer mode and the missing script
6. Conditional Builds
3. Building All Kinds of Libraries — libtool
1. libtool wrappers
2. Building plugins
3. Exposing and Hiding Symbols
4. Library Versioning
5. Notes on Windows Support
6. Libtool Archives
4. Dependency discovery — pkg-config
1. File Format of *.pc Files
2. Dependencies
4. Additional Variables
5. Supporting Cross-Compilation
5. Forward Porting Notes
1. Changes in autoconf releases
2. Changes in automake release
3. Changes in libtool releases
A. Who's afraid of Autotools?
1. Basic Autotoolization
2. Adding libtool
B. License
C. Further Readings
D. Examples

List of Examples

1.1. Using AC_ARG_ENABLE without actions
1.2. Using AC_ARG_WITH to declare automatic dependencies.
1.3. Looking for two common system libraries with AC_SEARCH_LIBS
1.4. header present but cannot be compiled: wrong language dialect
1.5. Including an External Macro File without automake
2.1. Passing simple automake options
2.2. Grouping tests together in a non-recursive
2.3. Using Silent Rules Without Forcing Automake 1.11
2.4. Silent Custom Rule to Generate a File
2.5. Common case of broken install-exec-local target (directory assumed to be present)
2.6. Common case of broken install-exec-local target (directory created on a race condition)
2.7. Correct install-exec-local using AC_PROG_MKDIR_P
2.8. Suggested configuration for automake maintainer mode
2.9. Using AM_CONDITIONAL with configure Options
3.1. building a test program optimised for in-place execution
3.2. Buildsystem changes for bundled libltdl
3.3. Checking for libltdl
3.4. Building plug-ins for dlopen() usage
3.5. Exposing symbols for plugins with fixed interface
3.6. Exposing symbols for plugins with variable interface
3.7. Exposing only the public interface of a library via -export-symbols-regex
3.8. Library versions for PE DLL
4.1. Simple project's template file and code.
4.2. Example of module specifications for PKG_CHECK_MODULES
4.3. Reading target path for plugins via PKG_CHECK_VAR
4.4. Common pkg-config wrapper script for cross-compilation
5.1. Safe conversion of a relying on AM_C_PROTOTYPES without de-ANSI-fication.
5.2. Properly Fix missing C++ support with libtool 2.2
D.3. thisonlyworksonc99.h