Configure script(配置脚本)
From Wikipedia, the free encyclopedia
源于维基百科全书
A Configure script is an executable script designed to aid in developing a program to be run on a wide number of different computers. It matches the libraries on the user's computer, with those required by the program, just before compiling it from its source code.
配置脚本是旨在帮助开发的程序能够运行在不同电脑上的可执行脚本。在配置脚本所属的源代码编译之前,配置脚本在用户电脑上匹配程序运行所需的库文件。
As a common practice, all configure scripts are named "configure". Usually, configure scripts are written for the Bourne shell, but they may be written for execution in any desired shell.
作为惯例,所有的配置脚本都被命名为“configure”。配置脚本通常是用Bourne shell脚本编写的,但是配置脚本也可以由任何其他版本的shell脚本语言编写来用来执行。
Usage(用法)
Obtaining software directly from the source code (a standard procedure on Unix computers) generally involves the following three steps: configuring the makefile, compiling the code, and finally installing the executable in the appropriate places. A configure script accomplishes the first of these steps. Using configure scripts is an automated method of generating makefiles 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:
直接由源码生成软件(在Unix计算机上标准流程)通常涉及以下三步骤:配置makefile文件,编译代码,最终将可执行程序安装在合适的地方。配置脚本用来完成三步中的第一步。编译出与系统有良好兼容性的软件之前,用配置脚本产生makefile文件是一个自动化的方法。在源文件目录下执行包含以下命令的shell脚本将会最终生成可运行的软件。
One must type ./configure (dot slash configure) rather than simply configure to indicate to the shell that the script is in ".", i.e. the current directory. By default, for security reasons, Unix operating systems do not search the current directory for executables so one must give the full path explicitly to avoid an error.[1]
必须在configure之前加上点号和斜杠./configure这种格式用来告诉shell程序configure脚本所在的位置,比如在当前目录。默认情况下,处于安全考虑,Unix操作系统不会在当前目录下搜索可执行文件,所以为了避免错误发生必须给出完整的路径。
Upon its completion, configure prints a report to config.log. Running ./configure --help gives a list of command line arguments, for enabling or disabling additional features such as:
一旦配置脚本运行完成,它会在config.log中打印一份报告。运行./configure --help会得到一个命令行参数列表,用来使能额外的功能可以这样:
The first line includes the mpfr and gmp libraries. The second line tells make to install the final version in /home/myname/apps. Note that if you have a space character in your argument, you will need to enclose the text in quotation marks as shown on the first line. The INSTALL file contains instructions should the prescribed steps fail.
第一行包含mpfr库文件和gmp库文件。第二行是说在路径/home/myname/apps下安装最终版本。注意,如果在你的参数之间有一个空格,你需要如第一行所示将文本内容包含在双引号内。如果安装文件中包含安装指令,那么标准步骤将不会成功。
Generating configure(产生configure)
Software developers simplify the challenge of cross-platform software development by using GNU's Autotools.[2] 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 configure.ac or (the now deprecated) configure.in to be read by configure during the installation phase.
软件开发人员通过利用GNU下的Autotools工具使跨平台软件开发的难度降低。脚本在系统上查询:系统设置,平台架构,build和runtime所需的依赖关系的存在性和位置。收集的信息将被存储在configure.ac文件或configure.in(现在已经被废弃)被configure在安装阶段使用。
Dependency checking(依赖关系检测)
In new development, library dependency checking has been done in great part using pkg-config via the m4 macro, PKG_CHECK_MODULES. Before pkg-config's gained popularity, separate m4 macros were created to locate files known to be included in the distribution of libraries depended upon.
最新进展,库文件依赖检测大多数情况下已经可以通过pkg-config软件中的m4宏和PKG_CHECK_MODULES模块完成。在pkg-config得到普及之前,单独的m4宏被创建在linux发行版的依赖库中用来定位文件。
History(历史)
The first program to come with a Configure script was rn by Larry Wall in 1984. Notable for its wry and jocular running commentary, that script was written entirely by hand and still survives as part of the build system of the trn program.
第一个有配置脚本的程序是由拉里·沃尔在1984年开发的rn。令人感到讽刺的是,这个脚本是完全手工编写的,并且现在仍然作为贷款程序编译系统的一部分而存在。
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 GNU Autoconf system described above.
从那以后,程序的生态系统已经升级为尽可能像以上提到的GNU Autoconf系统那样自动产生配置脚本。