AUTOTOOLS
2ND EDITION
A Practitioners Guide to GNU Autoconf, Automake, and Libtool
by John Calcote
San Francisco
AUTOTOOLS, 2ND EDITION. Copyright 2020 by John Calcote.
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.
ISBN-10: 1-59327-972-8
ISBN-13: 978-1-59327-972-1
Publisher: William Pollock
Production Editor: Janelle Ludowise
Cover and Interior Design: Octopod Studios
Developmental Editor: Ellie Bru
Technical Reviewer: Eric Blake
Copyeditor: Barton D. Reed
Compositors: Janelle Ludowise and Danielle Foster
Proofreader: Paula L. Fleming
Indexer: Beth Nauman-Montana
For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1.415.863.9900;
www.nostarch.com
The Library of Congress has catalogued the first edition as follows:
Calcote, John, 1964
Autotools : a practitioner's guide to GNU Autoconf, Automake, and Libtool / by John Calcote.
p. cm.
ISBN-13: 978-1-59327-206-7 (pbk.)
ISBN-10: 1-59327-206-5 (pbk.)
1. Autotools (Electronic resource) 2. Cross-platform software development. 3. Open source software.
4. UNIX (Computer file) I. Title.
QA76.76.D47C335 2010
005.3--dc22
2009040784
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The information in this book is distributed on an As Is basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.
For Michelle
But to see her was to love her; Love but her, and love forever.
Robert Burns
About the Author
John Calcote is currently a senior software engineer at Hammerspace.com, a software company specializing in cloud data management. Hes been writing portable networking and storage software for over 25 years and is active in developing, debugging, and analyzing diverse open source software packages. John is an advocate for the open source movement, participating in a number of open source communities.
About the Technical Reviewer
Eric Blake has contributed to a variety of open source projects since 2000. He became maintainer for GNU M4 in 2006, and GNU Autoconf in 2007. Eric currently works at Red Hat Inc. since 2010, where his primary focus has been on the qemu and libvirt virtualization software. He is also an active participant in the Austin Group which maintains the POSIX specification.
BRIEF CONTENTS
FOREWORD FOR THE FIRST EDITION
When I was asked to do a technical review on a book about the Autotools, I was rather skeptical. Several online tutorials and a few books already introduce readers to the use of GNU Autoconf, Automake, and Libtool. However, many of these texts are less than ideal in at least some ways: they were either written several years ago and are starting to show their age, contain at least some inaccuracies, or tend to be incomplete for typical beginners tasks. On the other hand, the GNU manuals for these programs are fairly large and rather technical, and as such, they may present a significant entry barrier to learning your ways around the Autotools.
John Calcote began this book with an online tutorial that shared at least some of the problems facing other tutorials. Around that time, he became a regular contributor to discussions on the Autotools mailing lists, too. John kept asking more and more questions, and discussions with him uncovered some bugs in the Autotools sources and documentation, as well as some issues in his tutorial.
Since that time, John has reworked the text a lot. The review uncovered several more issues in both software and book text, a nice mutual benefit. As a result, this book has become a great introductory text that still aims to be accurate, up to date with current Autotools, and quite comprehensive in a way that is easily understood.
Always going by example, John explores the various software layers, portability issues and standards involved, and features needed for package build development. If youre new to the topic, the entry path may just have become a bit less steep for you.
Ralf Wildenhues
Bonn, Germany
June 2010
FOREWORD FOR THE SECOND EDITION
The GNU Autotools have been around for a long time. My own introduction to Autoconf was back in 1999, around the same time I began my first foray into the world of Open Source Software. I had obtained employment in a research lab using the Java language to control FPGA hardware, and one of my co-workers showed me a program he had found, jikes , which compiled our project nearly 10 times faster than javac from Sun. But it crashed on one corner case of string concatenation, and I was assigned to figure out why. The jikes compiler was an Open Source project from IBM written in C++, and I soon found and fixed the problem, and got the pleasure of seeing my patch accepted upstream.
Whats more, since jikes used GNU Autoconf to allow building it on multiple platforms, after I had fixed the initial bug using the Solaris 7 machines at my work, I was able to experiment with further fixes to jikes at home on my Microsoft Windows 95 personal machine, using the Cygwin project that I found on the internet to provide gcc . I did not immediately appreciate the magnitude of the portability problems that had already been solved to be able to build software across vastly different systems, because the Autotools already hid so much of that complexity. But over time, my interests shifted away from Java and more into cross-platform compatibility, where I started contributing patches for GNU M4, and later GNU Autoconf, and eventually reached the point where I took over as the maintainer for both projects. Although my employment and my active project contributions have changed, in the meantime, I still find myself using the Autotools on a regular basis.
The point of all this? While the Java programming language is still around, it looks much different than 20 years ago. Between such changes as the introduction of generic typing, a change in ownership when Oracle bought Sun, and my own career taking me down a different path focused on the C language, I find it hard to compare modern Java projects to the work I did back then. And the jikes project that I worked on? It is now obsolete, unmaintained because it never kept up with the changes in the language, and because the javac compiler itself improved in quality and speed, where jikes was no longer a strong competition. But in all that time, the GNU Autotools have still been in active use, as a backbone behind the many GNU/Linux distributions. Even if most Linux users these days have never personally interacted with running a configure script, and instead rely on the distribution to pre-package binaries, they are beneficiaries of the power of the Autotools in making it easy for the distributions to bundle so many Open Source products.