Configure script: Difference between revisions

Content deleted Content added
It's for/from autotools
This is about GNU Build System; not something more general
Line 1:
{{Short description|AutotoolsGNU Build System script for generating build configuration files}}
{{Lowercase title}}
[[Image:Autoconf-automake-process.svg|thumb|280px|Flow diagram including configure, [[autoconf]] and [[automake]], three tools in the GNU Build System]]
A '''configure script''' is an executable script designed to aid in developing a [[computer program|program]] to be run on a wide number of different computers. It matches the [[Library (computer science)|libraries]] on the user's computer, with those required by the program before [[compiler|compiling]] it from its [[source code]].
 
As generated by the [[GNU Build System]], a '''configure script''' is an [[Bash (Unix shell)|Bash shell]] script that generates [[software build|build]] configuration files for a [[codebase]] to facilitate cross-platform support. It matches the [[Library (computer science)|libraries]] on the build host computer with those required by the codebase before the [[source code]] is [[compiler|compiled]].
As a common practice, all configure scripts are named <code>configure</code>. Usually, configure scripts are written for the [[Bourne shell]], but they may be written for execution in any desired shell.
 
== UsageUse ==
 
Obtaining software directly from the source code is a common procedure on [[Unix]] computers, and generally involves the following three steps: configuring the [[makefile]], compiling the code, and finally installing the executable to standard locations. A configure script accomplishes the first of these steps. Using configure scripts is an automated method of generating [[makefile]]s before compilation to tailor the software to the system on which the executable is to be compiled and run. The final executable software is most commonly obtained by executing the following commands in a shell that is currently pointing to the directory containing the source code:
Obtaining software directly from the source code is a common procedure on [[Unix]] and [[Unix-like]] environements. It generally involves the following steps:
 
# Generate a [[makefile]]
# Compile the code
# Install the result to an accessible ___location
 
A configure script accomplishes the first step. The script automates generating a [[makefile]]; allowing for tailoring it and the resulting software to the system on which it is compiled and run.
 
OneAfter mustnavigating typea <code>./configure</code> rather than simply <code>configure</code> to indicateterminal to the shelldirectory that the script is incontains the currentsource directory. This is becausecode, as a security precaution, [[Unix]] configurations don't search the current directory for executables. So, to execute programs in that directory, one mustfollowing explicitlycommands specifyare theirtypically ___location.executed:<ref>{{cite web |url=http://www.control-escape.com/linux/lx-swinstall-tar.html |title=Compiling Linux Software from Source Code |publisher=Control-Escape's Linux Help Engine |access-date=20 November 2010}}</ref>
 
<syntaxhighlight lang="sh">
Line 15 ⟶ 23:
</syntaxhighlight>
 
A report of the configuration operation can be found in file ''config.log''. Running <code>./configure --help</code> outputs command line syntax options.
One must type <code>./configure</code> rather than simply <code>configure</code> to indicate to the shell that the script is in the current directory. This is because, as a security precaution, [[Unix]] configurations don't search the current directory for executables. So, to execute programs in that directory, one must explicitly specify their ___location.<ref>{{cite web |url=http://www.control-escape.com/linux/lx-swinstall-tar.html |title=Compiling Linux Software from Source Code |publisher=Control-Escape's Linux Help Engine |access-date=20 November 2010}}</ref>
 
Often, a document with instructions is included.; often Thisin cana befile helpful ifnamed <code>configureINSTALL</code> fails. This filecan isbe commonlyhelpful namedif <code>INSTALLconfigure</code> fails.
Upon its completion, <code>configure</code> prints a report to <code>config.log</code>. Running <code>./configure --help</code> gives a list of command line arguments, for enabling or disabling additional features such as:
 
== Generating <code>configure</code> ==
<syntaxhighlight lang="sh">
Software[[GNU developersBuild simplifySystem]] simplifies some of the the challenge of [[cross-platform software]] development by using [[GNU Autotools]].<ref>{{cite web |url=https://www.gnu.org/software/autoconf/ |title=Autoconf - GNU Project - Free Software Foundation (FSF) |publisher=GNU Operating System |access-date=20 November 2010}}</ref> These scriptstools query the host system on which they run for environment settings, platform architecture, and the existence and ___location of required build and runtime dependencies. They store the gathered information in <code>configure.ac</code> or the now deprecated <code>configure.in</code> to be read by <code>configure</code> during the installation phase.
./configure --libs="-lmpfr -lgmp"
./configure --prefix=/home/user/local
</syntaxhighlight>
 
The first line includes the <code>mpfr</code> and <code>gmp</code> libraries. The second line tells <code>[[make (software)|make]]</code> to install the final version in <code>/home/user/local</code>.
 
Often, a document with instructions is included. This can be helpful if <code>configure</code> fails. This file is commonly named <code>INSTALL</code>.
 
== Generating <code>configure</code> ==
Software developers simplify the challenge of [[cross-platform software]] development by using [[GNU Autotools]].<ref>{{cite web |url=https://www.gnu.org/software/autoconf/ |title=Autoconf - GNU Project - Free Software Foundation (FSF) |publisher=GNU Operating System |access-date=20 November 2010}}</ref> These scripts query the system on which they run for environment settings, platform architecture, and the existence and ___location of required build and runtime dependencies. They store the gathered information in <code>configure.ac</code> or the now deprecated <code>configure.in</code> to be read by <code>configure</code> during the installation phase.
 
== Dependency checking ==
Line 38 ⟶ 37:
 
Since then, an ecosystem of programs has grown up to automate the creation of configure scripts as far as possible, of which the most common is the [[Autoconf|GNU Autoconf]] system.
 
== See also ==
* [[Autoconf]]
* [[Software build]]
* [[GNU Build System]]
 
== References ==