Autoconf
Encyclopedia
GNU Autoconf is a tool for producing configure scripts
Configure script (computing)
Developing a program to be run on a wide number of different computers is a complex task. A Configure script matches the libraries on the user's computer, with those required by the program, just before compiling it from its source code....

 for building, installing and packaging software on computer systems where a Bourne shell
Bourne shell
The Bourne shell, or sh, was the default Unix shell of Unix Version 7 and most Unix-like systems continue to have /bin/sh - which will be the Bourne shell, or a symbolic link or hard link to a compatible shell - even when more modern shells are used by most users.Developed by Stephen Bourne at AT&T...

 is available.

Autoconf is agnostic about the programming languages used, but it is often used for projects using C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

, Fortran
Fortran
Fortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing...

, Fortran 77, Erlang or Objective-C
Objective-C
Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it...

.

A configure script configures a software package for installation
Installation (computer programs)
Installation of a program is the act of putting the program onto a computer system so that it can be executed....

 on a particular target system. After running a series of tests on the target system the configure script generates header files and a makefile from templates, thus customizing the software package for the target system. Together with Automake
Automake
GNU Automake is a programming tool that produces portable makefiles for use by the make program, used in compiling software. It is made by the Free Software Foundation as one of GNU programs, and is part of the GNU build system. The makefiles produced follow the GNU Coding Standards.It is written...

 and Libtool
Libtool
GNU Libtool is a GNU programming tool from the GNU build system used for creating portable compiled libraries. To quote the introduction in the :Libtool is typically used with Autoconf and Automake, two other tools of the GNU build system....

, Autoconf forms the GNU build system
GNU build system
The GNU build system, also known as the Autotools, is a suite of programming tools designed to assist in making source-code packages portable to many Unix-like systems....

. It 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
GNU m4
GNU m4 is the GNU version of the m4 macro preprocessor. It is designed to avoid many kinds of limits found in traditional m4s: limits like maximum line lengths, maximum size of a macro, number of macros, etc...

 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 building system is not supposed to have autoconf installed: autoconf is needed only to build the configure script, that is usually shipped with the software.

configure.ac format

The GNU Autoconf manual suggests the following format for the configure.ac file:
Autoconf requirements
The AC_PREREQ(version) macro can be used to ensure that a recent enough version of the autoconf program is available to process the configure.ac file

AC_INIT(package, version, bug-report-address)
This macro is required in every configure.ac file. It specifies the name and version of the software package for which to generate a configure script and the email address of the developer.

information on the package
checks for programs
checks for libraries
checks for header files
checks for types
checks for structures
checks for compiler characteristics
checks for library functions
checks for system services
AC_CONFIG_FILES([file...])
AC_OUTPUT

History

Autoconf was begun in the summer of 1991 by David Mackenzie to support his work at the Free Software Foundation
Free Software Foundation
The Free Software Foundation is a non-profit corporation founded by Richard Stallman on 4 October 1985 to support the free software movement, a copyleft-based movement which aims to promote the universal freedom to create, distribute and modify computer software...

. 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.

Approach

Autoconf is similar to the Metaconfig package used by Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

. The imake
Imake
imake is a build automation system implemented on top of the C preprocessor.imake generates makefiles from a template, a set of cpp macro functions, and a per-directory input file called an Imakefile...

 system formerly used by the X Window System
X Window System
The X window system is a computer software system and network protocol that provides a basis for graphical user interfaces and rich input device capability for networked computers...

 (up to X11R6.9) is closely related, but has a different philosophy.

The Autoconf approach to portability
Porting
In computer science, porting is the process of adapting software so that an executable program can be created for a computing environment that is different from the one for which it was originally designed...

 is to test for feature
Feature (software design)
The Institute of Electrical and Electronics Engineers defines the term feature in IEEE 829 as "A distinguishing characteristic of a software item ." - Feature-rich :...

s, not for versions. For example, the native C compiler on SunOS 4 did not support ISO C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

. 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
    System administrator
    A system administrator, IT systems administrator, systems administrator, or sysadmin is a person employed to maintain and operate a computer system and/or network...

    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

Criticism

Autoconf is an old and mature product that, when properly used, provides a very simple interface even in complex cross-compiling scenarios. However 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 Unix shell and thus Makefile generation is slow. Some projects, such as KDE, tried to work around this issue by introducing distinct Makefile generators written in other languages.
  • Some people think that 'configure' scripts generated by autoconf provides only manual-driven command-line interface without any standardization. While it is true that some developers do not respect common conventions, such conventions still 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, some projects that used GNU Build System started to switch to other build systems:
  • KDE
    KDE
    KDE is an international free software community producing an integrated set of cross-platform applications designed to run on Linux, FreeBSD, Microsoft Windows, Solaris and Mac OS X systems...

     project switched to CMake
    CMake
    CMake is a cross-platform, open-source system for managing the build process of software using a compiler-independent method. It is designed to support directory hierarchies and applications that depend on multiple libraries, and for use in conjunction with native build environments such as Make,...

    , starting with KDE 4.
  • Scribus
    Scribus
    Scribus is a desktop publishing application, released under the GNU General Public License as free software. It is based on the free Qt toolkit, therefore native versions are available for Linux, Unix-like operating systems, Mac OS X, Microsoft Windows, and OS/2...

     switched to CMake
    CMake
    CMake is a cross-platform, open-source system for managing the build process of software using a compiler-independent method. It is designed to support directory hierarchies and applications that depend on multiple libraries, and for use in conjunction with native build environments such as Make,...

    .
  • Blender
    Blender (software)
    Blender is a free and open-source 3D computer graphics software product used for creating animated films, visual effects, interactive 3D applications or video games. The current release version is 2.60, and was released on October 19, 2011...

     switched to SCons
    SCons
    SCons is a computer software construction tool that automatically analyzes source code file dependencies and operating system adaptation requirements from a software project description and generates final binary executables for installation on the target operating system platform...

     on 2004-02-15.

See also

  • CMake
    CMake
    CMake is a cross-platform, open-source system for managing the build process of software using a compiler-independent method. It is designed to support directory hierarchies and applications that depend on multiple libraries, and for use in conjunction with native build environments such as Make,...

     Alternative build system
  • Configure script
  • GNU build system
    GNU build system
    The GNU build system, also known as the Autotools, is a suite of programming tools designed to assist in making source-code packages portable to many Unix-like systems....

  • pkg-config
    Pkg-config
    pkg-config is computer software that provides a unified interface for querying installed libraries for the purpose of compiling software from its source code. pkg-config was originally designed for Linux but is now also available for the various BSDs, Microsoft Windows, Mac OS X, and Solaris.It...

    Detecting package dependencies

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK