GNU build system
Encyclopedia
The GNU build system, also known as the Autotools, is a suite of programming tool
Programming tool
A programming tool or software development tool is a program or application that software developers use to create, debug, maintain, or otherwise support other programs and applications...

s designed to assist in making source-code packages
Software package (installation)
In package management systems, which are commonly used with Linux-based operating systems, a package is a specific piece of software which the system can install and uninstall....

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

 to many Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 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 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. The GNU build system is designed to address this problem more manageably.

The GNU build system is part of the GNU toolchain
GNU toolchain
The GNU toolchain is a blanket term for a collection of programming tools produced by the GNU Project. These tools form a toolchain used for developing applications and operating systems....

 and is widely used in many free-software and open-source packages. The tools comprising the GNU build system are free-software-licensed under the GNU General Public License
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

 with special license exceptions permitting use of the GNU build system with proprietary software
Proprietary software
Proprietary software is computer software licensed under exclusive legal right of the copyright holder. The licensee is given the right to use the software under certain conditions, while restricted from other uses, such as modification, further distribution, or reverse engineering.Complementary...

.

Tools included in the GNU build system

The GNU build system comprises the GNU
GNU
GNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...

 utility programs Autoconf
Autoconf
GNU Autoconf is a tool for producing configure scripts for building, installing and packaging software on computer systems where a Bourne shell is available....

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

. Other related tools frequently used with the GNU build system are GNU’s make program, GNU gettext
Gettext
In computing, gettext is an internationalization and localization system commonly used for writing multilingual programs on Unix-like computer operating systems. The most commonly-used implementation of gettext is GNU gettext, released by the GNU Project in 1995.- History :gettext was originally...

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

, and the GNU Compiler Collection
GNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

, also called GCC.

GNU Autoconf

Autoconf
Autoconf
GNU Autoconf is a tool for producing configure scripts for building, installing and packaging software on computer systems where a Bourne shell is available....

 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 the GNU build system 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 suffices to re-run configure (which runs config.status) and make. (For this reason source code using the GNU build system 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
M4 (computer language)
m4 is a general purpose macro processor designed by Brian Kernighan and Dennis Ritchie. m4 is an extension of an earlier macro processor m3, written by Ritchie for the AP-3 minicomputer.-Use:...

 macro system.

Autoconf comes with several auxiliary programs such as Autoheader, which is used to help manage 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....

 header file
Header file
Some programming languages use header files. These files allow programmers to separate certain elements of a program's source code into reusable files. Header files commonly contain forward declarations of classes, subroutines, variables, and other identifiers...

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

 helps to create portable Makefiles, 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.

GNU Libtool

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

 helps manage the creation of static
Static library
In computer science, a static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable...

 and dynamic libraries on various Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 operating systems. Libtool accomplishes this by abstracting the library-creation process, hiding differences between various systems (e.g. GNU
GNU
GNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...

/Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 systems vs. Solaris
Solaris Operating System
Solaris is a Unix operating system originally developed by Sun Microsystems. It superseded their earlier SunOS in 1993. Oracle Solaris, as it is now known, has been owned by Oracle Corporation since Oracle's acquisition of Sun in January 2010....

).

Gnulib

Gnulib
Gnulib
Gnulib, also called the GNU portability library, is a collection of software subroutines which are designed to be usable on many operating systems. The goal of the project is to make it easy for free software authors to make their software run on many operating systems...

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

Advantages of the GNU build system

The GNU build system allows a programmer to write cross-platform
Cross-platform
In computing, cross-platform, or multi-platform, is an attribute conferred to computer software or computing methods and concepts that are implemented and inter-operate on multiple computer platforms...

 software. It also makes the build
Software build
In the field of computer software, the term software build refers either to the process of converting source code files into standalone software artifact that can be run on a computer, or the result of doing so...

 process easier on a user who wants to compile the program on his or her own computer. The user does not need to have GNU build system components installed on the computer but only needs to run the supplied configure script which has no dependencies other than the presence of a Bourne-compatible
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...

 shell.

Limitations of the GNU build system

The GNU build system uses Bourne-compatible shell scripts to assist the user in the configuration and build process. The GNU build system can be used both for building native programs on the build machine and also for cross-compiling to other architectures.

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
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 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
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 system which provides the Bourne shell as a standard component. One can install the Cygwin
Cygwin
Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment...

 or MSYS system on top of Windows to provide a Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 compatibility layer
Compatibility layer
A compatibility layer is a term that refers to components that allow for non-native support of components.In software engineering, a compatibility layer allows binaries for a legacy or foreign system to run on a host system. This translates system calls for the foreign system into native system...

, though, allowing configure scripts to run. Cygwin
Cygwin
Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment...

 also provides the GNU Compiler Collection
GNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

, 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
MinGW
MinGW , formerly mingw32, is a native software port of the GNU Compiler Collection and GNU Binutils for use in the development of native Microsoft Windows applications; MinGW can function either as a cross compiler targeting Windows or as a native toolchain run on Windows itself...

 version of GCC.

Projects which use the GNU build system may or may not provide a configure script within their Version control systems (such as CVS
Concurrent Versions System
The Concurrent Versions System , also known as the Concurrent Versioning System, is a client-server free software revision control system in the field of software development. Version control system software keeps track of all work and all changes in a set of files, and allows several developers ...

 or Subversion). If a project that uses the GNU build system does not have a generated ./configure file available for the user, the user must generate it. One possible way this can be done is to execute the autoreconf tool at a shell prompt:

$ autoreconf

This will invoke aclocal, autoconf, autoheader and automake as needed. In some cases, more commands may be necessary. Another common convention is then to provide a script, often named autogen.sh or bootstrap, that runs all the needed pre-build tools.

One limitation has been that the autoconf-generated configure can be slow because it executes programs like the C compiler many times in order to test whether various libraries, header files, and language features are present.

See also

  • Build automation
    Build Automation
    Build automation is the act of scripting or automating a wide variety of tasks that software developers do in their day-to-day activities including things like:* compiling computer source code into binary code* packaging binary code* running tests...

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

  • Gnits Standards
    Gnits Standards
    The Gnits standards are a collection of standards and recommendations for programming, maintaining, and distributing software. They are published by a group of GNU project maintainers who call themselves "Gnits", which is short for "GNU nit-pickers"...

  • GNU Coding Standards
    GNU Coding Standards
    The GNU Coding Standards are a set of rules and guidelines for writing programs that work consistently within the GNU system. The GNU Coding Standards were written by Richard Stallman and other GNU Project volunteers. The standards document is part of the GNU Project and is available from the GNU...

  • Waf
    Waf
    Waf is a Build automation tool - a program that assists in the automatic compilation and installation of other programs or libraries.-General:* Portable to Unix and non-Unix systems* Lightweight...


External links

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