GNU Build System

GNU logo

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 can be difficult to make a software program portable: the C compiler differs from system to system; certain library functions are missing on some systems; header files may have different names. One way to handle this is to write conditional code, with code blocks selected by means of preprocessor directives (`#ifdef`); but because of the wide variety of build environments this approach quickly becomes unmanageable. Autotools is designed to address this problem more manageably.

Autotools is part of the GNU toolchain and is widely used in many free software and open source packages. Its component tools are free software-licensed under the GNU General Public License with special license exceptions[1][2] permitting its use with proprietary software.

The GNU Build System makes it possible to build many programs using a two-step process: configure followed by make.[3]

## Contents

* 1 Components
* 1.1 GNU Autoconf
* 1.2 GNU Automake
* 1.3 GNU Libtool
* 1.4 Gnulib
* 2 Usage
* 3 Criticism
* 4 See also
* 5 References
* 6 External links

## Components

Flow diagram of autoconf and automake

Autotools consists of the GNU utility programs Autoconf, Automake, and Libtool.[4] Other related tools frequently used alongside it include GNU's make program, GNU gettext, pkg-config, and the GNU Compiler Collection, also called GCC.

### GNU Autoconf

Autoconf generates a `configure` script based on the contents of a `configure.ac` file which characterizes a particular body of source code. The `configure` script, when run, scans the build environment and generates a subordinate `config.status` script which, in turn, converts other input files and most commonly `Makefile.in` into output files (`Makefile`) which are appropriate for that build environment. Finally the `make` program uses `Makefile` to generate executable programs from source code.

The complexity of Autotools reflects the variety of circumstances under which a body of source code may be built.

* If a source code file is changed then it suffices to re-run `make` which only re-compiles that part of the body of the source code affected by the change.
* If a `.in` file has changed then it suffices to re-run `config.status` and `make`.
* If the body of source code is copied to another computer then it is sufficient to re-run `configure` (which runs `config.status`) and `make`. (For this reason source code using Autotools is normally distributed without the files that `configure` generates.)
* If the body of source code is changed more fundamentally, then `configure.ac` and the `.in` files need to be changed and all subsequent steps also followed.

To process files, autoconf uses the GNU implementation of the m4 macro system.

Autoconf comes with several auxiliary programs such as Autoheader, which is used to help manage C header files; Autoscan, which can create an initial input file for Autoconf; and `ifnames`, which can list C pre-processor identifiers used in the program.

### GNU Automake

Automake helps to create portable `Makefile`s, which are in turn processed with the make utility. It takes its input as `Makefile.am`, and turns it into `Makefile.in`, which is used by the configure script to generate the file `Makefile` output. It also performs automatic dependency tracking; every time a source file is compiled, the list of dependencies (e.g., C header files) is recorded. Later, any time make is run and a dependency appears to have changed, the dependent files will be rebuilt.

### GNU Libtool

Libtool helps manage the creation of static and dynamic libraries on various Unix-like operating systems. Libtool accomplishes this by abstracting the library-creation process, hiding differences between various systems (e.g. GNU/Linux systems vs. Solaris).

### Gnulib

Gnulib simplifies the process of making software that uses Autoconf and Automake portable to a wide range of systems.

## Usage

Autotools assists a software development person or team to write cross-platform software and make it available to a much wider user community, including in its source code form to those users who wish to build the software themselves. In most cases users simply run the supplied `configure` script (which has no dependencies other than the presence of a Bourne-compatible shell), and then a `make` program.[5] They do not need to have the Autotools themselves installed on the computer.

It can be used both for building native programs on the build machine and also for cross-compiling to other architectures.[6]

Cross-compiling software to run on a Windows host from a GNU/Linux or other Unix-like build system is also possible, using MinGW, however native compilation is often desirable on operating systems (such as the Microsoft Windows family of systems) that cannot run Bourne shell scripts on their own. This makes building such software on the Windows operating system a bit harder than on a Unix-like system which provides the Bourne shell as a standard component. One can install the Cygwin or MSYS system on top of Windows to provide a Unix-like compatibility layer, though, allowing configure scripts to run. Cygwin also provides the GNU Compiler Collection, GNU make, and other software that provides a nearly complete Unix-like system within Windows; MSYS also provides GNU make and other tools designed to work with the MinGW version of GCC.

Although the developer is expected to provide a configure script for the end-user, occasionally the user may wish to re-generate the configure script itself. Such working might be necessary if the user wishes to amend the source code itself. Such users would need to have Autotools installed, and to use components such as its autoreconf.

The autoconf-generated `configure` can be slow because it executes programs such as a C compiler many times in order to test whether various libraries, header files, and language features are present. This particularly affects Cygwin, which, due to its lack of a native fork system call, may execute configure scripts considerably slower than Linux.[7]

## Criticism

In his column for ACM Queue, FreeBSD developer Poul-Henning Kamp criticized the GNU Build System:[8]

> The idea is that the configure script performs approximately 200 automated tests, so that the user is not burdened with configuring libtool manually. This is a horribly bad idea, already much criticized back in the 1980s when it appeared, as it allows source code to pretend to be portable behind the veneer of the configure script, rather than actually having the quality of portability to begin with. It is a travesty that the configure idea survived.

Kamp sketches the history of the build system in the portability problems inherent in the multitude of 1980s Unix variants, and ridicules the build system because even in the standardized world of POSIX

> the 31,085 lines of configure for libtool still check if <sys/stat.h> and <stdlib.h> exist, even though the Unixen, which lacked them, had neither sufficient memory to execute libtool nor disks big enough for its 16-MB source code.

## See also

* List of build automation software § Build script generation tools
* Build automation
* CMake
* Gnits Standards
* GNU Coding Standards
* Waf
* SCons
* Meson build system
* Qmake

## References

1. ↑ "Savannah Git Hosting - autoconf.git/blob - COPYING.EXCEPTION". http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob;f=COPYING.EXCEPTION;h=469583528592cd69ac0847803b443849dcc9b1eb;hb=HEAD. Retrieved 2016-04-01. [yes|permanent dead link|dead link}}]
2. ↑ "libtool.git - GNU Libtool". 2005-01-08. http://git.savannah.gnu.org/cgit/libtool.git/tree/HACKING?id=9c9cde2c95f3f04f48288e1911038249d5ac424b. Retrieved 2016-04-01.
3. ↑ "The GNU configure and build system - Introduction". 1998-07-01. http://airs.com/ian/configure/configure_1.html#SEC5. Retrieved 2016-04-01.
4. ↑ "Learning the GNU development tools". http://autotoolset.sourceforge.net/tutorial.html#SEC40. Retrieved 2016-04-01.
5. ↑ "automake: GNU Build System". 2014-12-31. https://www.gnu.org/software/automake/manual/html_node/GNU-Build-System.html. Retrieved 2016-04-01.
6. ↑ "Archived copy". Archived from the original on October 13, 2008. https://web.archive.org/web/20081013213002/http://sources.redhat.com/autobook/autobook/autobook_258.html. Retrieved September 24, 2008.
7. ↑ "Robert Ögren - Slow shell script execution on Cygwin". http://cygwin.com/ml/cygwin/2005-04/msg00703.html. Retrieved 2016-04-01.
8. ↑ Kamp, Poul-Henning (2012). "A Generation Lost in the Bazaar". ACM Queue 10 (8). https://queue.acm.org/detail.cfm?id=2349257.

## External links

* The GNU configure and build system
* The pkg-config package
* GNU automake documentation
* GNU autoconf documentation
* Combined manual for Automake and Autoconf
* Autotools Tutorial
* GNU Autoconf, Automake, and Libtool
* Autotools: a practitioner's guide to Autoconf, Automake and Libtool
* A Guide to Integrating CUDA with Autotools
* Autotools Mythbuster
* Introduction to the Autotools

* v
* t
* e

GNU Project

History|

* GNU Manifesto
* Free Software Foundation
* Europe
* India
* Latin America
* History of free software

Licenses|

* GNU General Public License
* linking exception
* font exception
* GNU Lesser General Public License
* GNU Affero General Public License
* GNU Free Documentation License

Software|

* GNU (variants)
* Hurd
* Linux-libre
* glibc
* Bash
* coreutils
* findutils
* Build System
* GCC
* binutils
* GDB
* GRUB
* GNOME
* GNUstep
* GIMP
* Jami
* GNU Emacs
* GNU TeXmacs
* GNU Octave
* GNU R
* GSL
* GMP
* GNU Electric
* GNU Archimedes
* GNUnet
* GNU Privacy Guard
* Gnuzilla (IceCat)
* GNU Health
* GNUmed
* GNU LilyPond
* GNU Go
* GNU Chess
* Gnash
* Guix
* Guix System Distribution
* more...

Public
speakers|

* Alexandre Oliva
* Benjamin Mako Hill
* Bradley M. Kuhn
* Federico Heinz
* Frédéric Couchet
* Georg C. F. Greve
* John Sullivan
* José E. Marchesi
* Joshua Gay
* Kefah T. Issa
* Loïc Dachary
* Nagarjuna G.
* Peter Heath
* Richard M. Stallman

Other topics|

* GNU/Linux naming controversy
* Revolution OS
* Free Software Foundation anti-Windows campaigns
* Defective by Design

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:GNU_Build_System&oldid=703074"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template