GNU Autoconf is a tool for producing
configure scripts for building, installing, and packaging software on computer systems where a
Bourne shell
The Bourne shell (sh) is a shell command-line interpreter for computer operating systems.
The Bourne shell was the default shell for Version 7 Unix. Unix-like systems continue to have /bin/sh—which will be the Bourne shell, or a symbolic l ...
is available.
Autoconf is agnostic about the programming languages used, but it is often used for projects using
C,
C++,
Fortran, Fortran 77,
Erlang, or
Objective-C
Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was selected by NeXT for its NeXT ...
.
A configure script configures a software package for
installation on a particular target system. After running a series of tests on the target system, the configure script generates
header files
Many programming languages and other computer files have a directive, often called include (sometimes copy or import), that causes the contents of the specified file to be inserted into the original file. These included files are called copybooks ...
and a
makefile
In software development, Make is a build automation tool that automatically builds executable programs and libraries from source code by reading files called ''Makefiles'' which specify how to derive the target program. Though integrated ...
from templates, thus customizing the software package for the target system. Together with
Automake
In software development, GNU Automake is a programming tool to automate parts of the compilation process. It eases usual compilation problems. For example, it points to needed dependencies.
It automatically generates one or more ''Makefile.in ...
and
Libtool
In computer programming, GNU Libtool is a software development tool, part of the GNU build system, consisting of a shell script created to address the software portability problem when compiling shared libraries from source code.
It hides th ...
, Autoconf forms the
GNU Build System, which comprises several other tools, notably Autoheader.
Usage overview
The developer specifies the desired behaviour of the configure script by writing a list of instructions in the
GNU m4
m4 is a general-purpose macro processor included in most Unix-like operating systems, and is a component of the POSIX standard.
The language was designed by Brian Kernighan and Dennis Ritchie for the original versions of UNIX. It is an exten ...
language in a file called "configure.ac". A library of pre-defined m4
macros is available to describe common configure script instructions. Autoconf transforms the instructions in "configure.ac" into a portable configure script.
The system that will be doing the building need not have autoconf installed: autoconf is needed only to build the configure script, that is usually shipped with the software.
History
Autoconf was begun in the summer of 1991 by David Mackenzie to support his work at the
Free Software Foundation
The Free Software Foundation (FSF) is a 501(c)(3) non-profit organization founded by Richard Stallman on October 4, 1985, to support the free software movement, with the organization's preference for software being distributed under copyleft ( ...
. In the subsequent years it grew to include enhancements from a variety of authors and became the most widely used build configuration system for writing portable free or
open-source software
Open-source software (OSS) is computer software that is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute the software and its source code to anyone and for any purpose. ...
.
Approach
Autoconf is similar to the Metaconfig package used by
Perl
Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
. The
imake
imake is a build automation system written for the X Window System. It was used by X from X11R1 (1987) to X11R6.9 (2005), and continued to be used in XFree86 (last commit 2009). It is implemented on top of the C preprocessor and make. The first v ...
system formerly used by the
X Window System
The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems.
X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting wi ...
(up to X11R6.9) is closely related, but has a different philosophy.
The Autoconf approach to
portability is to test for
features, not for
versions
Version may refer to:
Computing
* Software version, a set of numbers that identify a unique evolution of a computer program
* VERSION (CONFIG.SYS directive), a configuration directive in FreeDOS
Music
* Cover version
* Dub version
* Remix
* ''Ve ...
. For example, the native C compiler on SunOS 4 did not support
ISO C
ANSI C, ISO C, and Standard C are successive standards for the C programming language published by the American National Standards Institute (ANSI) and ISO/IEC JTC 1/SC 22/WG 14 of the International Organization for Standardization (ISO) and th ...
. However, it is possible for the user or administrator to have installed an ISO C-compliant compiler. A pure version-based approach would not detect the presence of the ISO C compiler, but a feature-testing approach would be able to discover the ISO C compiler the user had installed. The rationale of this approach is to gain the following advantages:
* the configure script can get reasonable results on newer or unknown systems
* it allows
administrator
Administrator or admin may refer to:
Job roles Computing and internet
* Database administrator, a person who is responsible for the environmental aspects of a database
* Forum administrator, one who oversees discussions on an Internet forum
* N ...
s to customize their machines and have the configure script take advantage of the customizations
* there is no need to keep track of minute details of versions, patch numbers, etc., to figure out whether a particular feature is supported or not
Autoconf provides extensive documentation around the non-portability of many POSIX shell constructs to older shells and bugs therein. It also provides M4SH, a macro-based replacement for shell syntax.
Criticism
There is some criticism that states that Autoconf uses dated technologies, has a lot of legacy restrictions, and complicates simple scenarios unnecessarily for the author of ''configure.ac'' scripts. In particular, often cited weak points of Autoconf are:
* General complexity of used architecture, most projects use multiple repetitions.
* Generated 'configure' is written in
Bourne shell
The Bourne shell (sh) is a shell command-line interpreter for computer operating systems.
The Bourne shell was the default shell for Version 7 Unix. Unix-like systems continue to have /bin/sh—which will be the Bourne shell, or a symbolic l ...
and thus Makefile generation is slow.
* Some people think that 'configure' scripts generated by autoconf provide only manual-driven command-line interface without any standardization.
While it is true that some developers do not respect common conventions, such conventions do exist and are widely used.
* M4 is unusual and unknown to many developers. Developers will need to learn it to extend autoconf with non-standard checks.
* Weak backward and forward compatibility requires a wrapper script.
* Autoconf-generated scripts are usually large and rather complex. Although they produce extensive logging, debugging them can still be difficult.
Due to these limitations, several projects that used GNU Build System switched to different build systems, such as
CMake
In software development, CMake is cross-platform free and open-source software for build automation, testing, packaging and installation of software by using a compiler-independent method. CMake is not a build system itself; it generates a ...
and
SCons.
See also
*
CMake
In software development, CMake is cross-platform free and open-source software for build automation, testing, packaging and installation of software by using a compiler-independent method. CMake is not a build system itself; it generates a ...
– Alternative build system
*
Meson
In particle physics, a meson ( or ) is a type of hadronic subatomic particle composed of an equal number of quarks and antiquarks, usually one of each, bound together by the strong interaction. Because mesons are composed of quark subparticles, ...
Another build system
*
Configure script
*
GNU build system
*
pkg-config – Detecting package dependencies
References
External links
*
GNU Autoconf macro archive''The Goat Book'' homepage (aka the Autobook)Using Automake and Autoconf with C++Using C/C++ libraries with Automake and Autoconf
Autotoolset home pageAutotools: A practitioner's guide to Autoconf, Automake and LibtoolAutotools Mythbuster{{GNU
Build automation
Computer configuration
Cross-platform free software
Free computer libraries
GNU Project software
de:GNU Build System#GNU Autoconf