[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Autoconf solves an important problem--reliable discovery of system-specific build and run-time information--but this is only one piece of the puzzle for the development of portable software. To this end, the GNU project has developed a suite of integrated utilities to finish the job Autoconf started: the GNU build system, whose most important components are Autoconf, Automake, and Libtool. In this chapter, we introduce you to those tools, point you to sources of more information, and try to convince you to use the entire GNU build system for your software.
2.1 Automake | Escaping Makefile hell | |
2.2 Libtool | Building libraries portably | |
2.3 Pointers | More info on the GNU build system |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The ubiquity of make
means that a `Makefile' is almost the
only viable way to distribute automatic build rules for software, but
one quickly runs into make
's numerous limitations. Its lack of
support for automatic dependency tracking, recursive builds in
subdirectories, reliable timestamps (e.g., for network filesystems), and
so on, mean that developers must painfully (and often incorrectly)
reinvent the wheel for each project. Portability is non-trivial, thanks
to the quirks of make
on many systems. On top of all this is the
manual labor required to implement the many standard targets that users
have come to expect (make install
, make distclean
,
make uninstall
, etc.). Since you are, of course, using Autoconf,
you also have to insert repetitive code in your Makefile.in
to
recognize @CC@
, @CFLAGS@
, and other substitutions
provided by configure
. Into this mess steps Automake.
Automake allows you to specify your build needs in a Makefile.am
file with a vastly simpler and more powerful syntax than that of a plain
Makefile
, and then generates a portable Makefile.in
for
use with Autoconf. For example, the Makefile.am
to build and
install a simple "Hello world" program might look like:
bin_PROGRAMS = hello hello_SOURCES = hello.c |
The resulting Makefile.in
(~400 lines) automatically supports all
the standard targets, the substitutions provided by Autoconf, automatic
dependency tracking, VPATH
building, and so on. make
will
build the hello
program, and make install
will install it
in `/usr/local/bin' (or whatever prefix was given to
configure
, if not `/usr/local').
Automake may require that additional tools be present on the
developer's machine. For example, the Makefile.in
that
the developer works with may not be portable (e.g., it might use special
features of your compiler to automatically generate dependency
information). Running make dist
, however, produces a
`hello-1.0.tar.gz' package (or whatever the program/version is)
with a Makefile.in
that will work on any system.
The benefits of Automake increase for larger packages (especially ones with subdirectories), but even for small programs the added convenience and portability can be substantial. And that's not all....
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Very often, one wants to build not only programs, but libraries, so that other programs can benefit from the fruits of your labor. Ideally, one would like to produce shared (dynamically linked) libraries, which can be used by multiple programs without duplication on disk or in memory and can be updated independently of the linked programs. Producing shared libraries portably, however, is the stuff of nightmares--each system has its own incompatible tools, compiler flags, and magic incantations. Fortunately, GNU provides a solution: Libtool.
Libtool handles all the requirements of building shared libraries for
you, and at this time seems to be the only way to do so with any
portability. It also handles many other headaches, such as: the
interaction of Makefile
rules with the variable suffixes of
shared libraries, linking reliably with shared libraries before they are
installed by the superuser, and supplying a consistent versioning system
(so that different versions of a library can be installed or upgraded
without breaking binary compatibility). Although Libtool, like
Autoconf, can be used on its own, it is most simply utilized in
conjunction with Automake--there, Libtool is used automatically
whenever shared libraries are needed, and you need not know its syntax.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Developers who are used to the simplicity of make
for small
projects on a single system might be daunted at the prospect of
learning to use Automake and Autoconf. As your software is
distributed to more and more users, however, you will otherwise
quickly find yourself putting lots of effort into reinventing the
services that the GNU build tools provide, and making the
same mistakes that they once made and overcame. (Besides, since
you're already learning Autoconf, Automake will be a piece of cake.)
There are a number of places that you can go to for more information on the GNU build tools.
Web
Automake Manual
See (automake)Top section `Automake' in GNU Automake, for more information on Automake.
Books
The book GNU Autoconf, Automake and Libtool(1) describes the complete GNU build environment. You can also find the entire book on-line at "The Goat Book" home page.
Tutorials and Examples
The Autoconf Developer Page maintains links to a number of Autoconf/Automake tutorials online, and also links to the Autoconf Macro Archive.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by John Paul Wallington on October, 29 2003 using texi2html 1.67.