GNU Autotools

Last updated
GNU Autotools
Original author(s) Community
Developer(s) Free Software Foundation
Stable release
Multiple
Written in M4 (computer language), C
Operating system Cross-platform
Platform GNU and others
Included with GNU Operating System
Available inEnglish
License GNU General Public License version 2
Website www.gnu.org/software/software.html

The GNU Autotools, also known as the GNU Build System, is a suite of build automation tools designed to support building source code and packaging the resulting binaries. It supports building a codebase for multiple target systems without customizing or modifying the code. It is available on many Linux distributions and Unix-like environments.

Contents

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.

Motivation

It can be difficult to make a software program portable. Compilers differ from system to system. Certain library functions are missing on some systems. Compiler files (such as C headers) may have different names. Shared libraries may be compiled and installed in different ways. One way to handle platform differences is to write conditionally compiled code (i.e. via #ifdef), but because of the wide variety of build environments, this approach quickly becomes unmanageable. Autotools is designed to address this problem more manageably.

Components

Autotools consists of the GNU utilities Autoconf, Automake, and Libtool. [3] Other related tools include GNU make, GNU gettext, pkg-config, and the GNU Compiler Collection (GCC).

Usage

Flow diagram of Autotools tools. Autoconf-automake-process.svg
Flow diagram of Autotools tools.

Autotools assists with sharing cross-platform software with a relatively broad user community. It facilitates sharing the source code by providing relatively robust cross-platform build support so that consumers can build the software themselves. Generally, the source code is distributed with a script, named configure, that has no dependencies other than a Bourne-compatible shell. Autotools need not be available. The consumer runs configure which generates various files including a Makefile which the consumer uses by running make. [4] [5]

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

A consumer can re-generate the configure script which might be necessary if they amend the source code. In this case, they need to have Autotools installed.

The autoconf-generated configure script can be slow because it executes programs such as a C compiler multiple times 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 on 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 bemoans the need for such build systems to exist:

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.

Although critics of the Autotools frequently advocate for alternatives that provide greater simplicity to their users, some have argued that this is not necessarily a good thing. John Calcote, author [9] of the Autotools, 2nd Edition: A Practitioner's Guide to GNU Autoconf, Automake, and Libtool, opined: [10]

The Autotools are actually more transparent than any other build tools out there. All these other tools' (cmake, maven, etc) - that purport to be so much simpler because they insulate the user from the underlying details of the build process - these tool's primary failure is that this very insulation keeps users from being able to make the changes they need to accomplish their unique project-specific build goals.

Anyone who has nothing but good things to say about this aspect of cmake, maven, gradle, or whatever, has simply not worked on a project that requires them to move far enough away from the defaults. I've used them all and I've spent hours in frustration trying to determine how to work around the shortcomings of some "do-all" (except what I want) tool function. This is simply not an issue with the Autotools. As someone mentioned earlier in this thread, you can drop shell script into a configure.ac file, and make script into a Makefile.am file. That is the very definition of transparency. No other tool in existence allows this level of flexibility.

See also

Related Research Articles

<span class="mw-page-title-main">Cygwin</span> Unix-like environment for Windows

Cygwin is a free and open-source Unix-like environment and command-line interface (CLI) for Microsoft Windows. The project also provides a software repository containing many open-source packages. Cygwin allows source code for Unix-like operating systems to be compiled and run on Windows. Cygwin provides native integration of Windows-based applications.

GNU Autoconf is a software development tool for generating a configure script that in turn generates files for building a codebase and for packaging or installing the resulting files. Autoconf is part of the GNU Build System – along with Automake, Libtool, Autoheader and other tools.

<span class="mw-page-title-main">GNU Libtool</span> Shared library creation tool from GNU

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 the differences between computing platforms for the commands which compile shared libraries. It provides a command-line interface that is identical across platforms and it executes the platform's native commands.

In software development, Make is a command-line interface software tool that performs actions ordered by configured dependencies as defined in a configuration file called a makefile. It is commonly used for build automation to build executable code from source code. But, not limited to building, Make can perform any operation available via the operating system shell.

<span class="mw-page-title-main">KDevelop</span> Integrated development environment

KDevelop is a free and open-source integrated development environment (IDE) for Unix-like computer operating systems and Windows. It provides editing, navigation and debugging features for several programming languages, and integration with build automation and version-control systems, using a plugin-based architecture.

<span class="mw-page-title-main">Automake</span> Programming tool to automate parts of the compilation process

GNU Automake is a software development tool to automate parts of the compilation process. It eases common compilation problems. For example, it points to needed dependencies.

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a PC but generates code that runs on Android devices is a cross compiler.

<span class="mw-page-title-main">MinGW</span> Free and open-source software for developing applications in Microsoft Windows

MinGW, formerly mingw32, is a free and open source software development environment to create Microsoft Windows applications.

The GNU toolchain is a broad collection of programming tools produced by the GNU Project. These tools form a toolchain used for developing software applications and operating systems.

Perforce Jam was an open-source build system developed by Christopher Seiwald of Perforce Software. It was used as a replacement for make. Its primary feature was its ability to express build patterns in an imperative language which supported structured namespaces and simple lists. Jam could be used with autoconf, although it was often not necessary because of Jam's portability features. Perforce Jam ran on Unix, OpenVMS, Windows NT, Mac OS, and BeOS. It was also possible to configure it to work on Windows 9x using MinGW or Cygwin.

<span class="mw-page-title-main">CMake</span> Cross-platform build tool for configuring platform-specific builds

CMake is a free, cross-platform, software development tool for building applications via compiler-independent instructions. It also can automate testing, packaging and installation. It runs on a variety of platforms and supports many programming languages.

<span class="mw-page-title-main">Waf (build system)</span>

Waf is a build automation tool designed to assist in the automatic compilation and installation of computer software. It is written in Python and maintained by Thomas Nagy.

When installing a package on a Unix or Unix-like environment, a configure script is a shell script that generates build configuration files for a codebase to facilitate cross-platform support. It generates files tailoring for the host system – the environment on which the codebase is built and run.

lzip Data compression utility

lzip is a free, command-line tool for the compression of data; it employs the Lempel–Ziv–Markov chain algorithm (LZMA) with a user interface that is familiar to users of usual Unix compression tools, such as gzip and bzip2.

The following outline is provided as an overview of and topical guide to the Perl programming language:

Mingw-w64 is a free and open-source suite of development tools that generate Portable Executable (PE) binaries for Microsoft Windows. It was forked in 2005–2010 from MinGW.

<span class="mw-page-title-main">Meson (software)</span> Build automation tool

Meson is a software build automation tool for building a codebase. Meson adopts a convention over configuration approach to minimize the data required to configure the most common operations. Meson is free and open-source software under the Apache License 2.0.

References

  1. "Savannah Git Hosting - autoconf.git/blob - COPYING.EXCEPTION". Git.savannah.gnu.org. Archived from the original on 2011-07-21. Retrieved 2016-04-01.
  2. "libtool.git - GNU Libtool". Git.savannah.gnu.org. 2005-01-08. Retrieved 2016-04-01.
  3. "Learning the GNU development tools". Autotoolset.sourceforge.net. Retrieved 2016-04-01.
  4. "automake: GNU Build System". Gnu.org. 2014-12-31. Retrieved 2016-04-01.
  5. "The GNU configure and build system - Introduction". Airs.com. 1998-07-01. Retrieved 2016-04-01.
  6. "Cross Compilation with GNU Autotools". Archived from the original on October 13, 2008. Retrieved September 24, 2008.
  7. "Robert Ögren - Slow shell script execution on Cygwin". Cygwin.com. Retrieved 2016-04-01.
  8. Kamp, Poul-Henning (2012). "A Generation Lost in the Bazaar". ACM Queue. 10 (8): 20–23. doi: 10.1145/2346916.2349257 . S2CID   11656592.
  9. "Autotools, 2nd Edition by John Calcote | Penguin Random House Canada" . Retrieved January 22, 2021.
  10. "Re: Future plans for Autotools" . Retrieved January 22, 2021.