为什么总是 ./configure;制作;进行安装;作为 3 个单独的步骤? [英] Why always ./configure; make; make install; as 3 separate steps?

查看:37
本文介绍了为什么总是 ./configure;制作;进行安装;作为 3 个单独的步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次从源代码编译某些内容时,都会经历相同的 3 个步骤:

Every time you compile something from source, you go through the same 3 steps:

$ ./configure
$ make
$ make install

我明白,将安装过程分成不同的步骤是有道理的,但我不明白,为什么这个星球上的每个编码人员都必须一遍又一遍地编写相同的三个命令只是为了得到一个任务完成.从我的角度来看,让 ./install.sh 脚本与包含以下文本的源代码一起自动交付是完全有意义的:

I understand, that it makes sense to divide the installing process into different steps, but I don't get it, why each and every coder on this planet has to write the same three commands again and again just to get one single job done. From my point of view it would make totally sense to have a ./install.sh script automatically delivered with the source code which contains the following text:

#!/bin/sh
./configure
make
make install

为什么人们会分别执行这 3 个步骤?

why would people do the 3 steps separately?

推荐答案

因为每一步做的事情都不一样

Because each step does different things

./configure

这个脚本有很多你应该改变的选项.像--prefix--with-dir=/foo.这意味着每个系统都有不同的配置.另外 ./configure 会检查是否缺少应该安装的库.此处的任何错误都会导致无法构建您的应用程序.这就是为什么发行版有安装在不同地方的包,因为每个发行版都认为最好将某些库和文件安装到某些目录中.据说运行 ./configure,但实际上你应该总是改变它.

This script has lots of options that you should change. Like --prefix or --with-dir=/foo. That means every system has a different configuration. Also ./configure checks for missing libraries that should be installed. Anything wrong here causes not to build your application. That's why distros have packages that are installed on different places, because every distro thinks it's better to install certain libraries and files to certain directories. It is said to run ./configure, but in fact you should change it always.

例如查看Arch Linux 软件包站点.在这里,您将看到任何包都使用不同的配置参数(假设它们为构建系统使用自动工具).

For example have a look at the Arch Linux packages site. Here you'll see that any package uses a different configure parameter (assume they are using autotools for the build system).

make

这实际上是默认的make all.每个品牌都有不同的动作要做.有些进行构建,有些在构建后进行测试,有些从外部 SCM 存储库中检出.通常你不必提供任何参数,但同样有些包以不同的方式执行它们.

This is actually make all by default. And every make has different actions to do. Some do building, some do tests after building, some do checkout from external SCM repositories. Usually you don't have to give any parameters, but again some packages execute them differently.

make install

这会将软件包安装在 configure 指定的位置.如果需要,您可以指定 ./configure 指向您的主目录.但是,许多配置选项都指向 /usr/usr/local.这意味着你必须实际使用 sudo make install 因为只有 root 可以将文件复制到/usr 和/usr/local.

This installs the package in the place specified with configure. If you want you can specify ./configure to point to your home directory. However, lots of configure options are pointing to /usr or /usr/local. That means then you have to use actually sudo make install because only root can copy files to /usr and /usr/local.

现在您看到每一步都是下一步的先决条件.每一步都是让事情顺利进行的准备.发行版使用这个比喻来构建包(如 RPM、deb 等).

Now you see that each step is a pre-requirement for next step. Each step is a preparation to make things work in a problemless flow. Distros use this metaphor to build packages (like RPM, deb, etc.).

在这里您会看到每个步骤实际上都是不同的状态.这就是包管理器具有不同包装器的原因.下面是一个包装器示例,可让您一步构建整个包.但请记住,每个应用程序都有不同的包装器(实际上这些包装器的名称类似于规范、PKGBUILD 等):

Here you'll see that each step is actually a different state. That's why package managers have different wrappers. Below is an example of a wrapper that lets you build the whole package in one step. But remember that each application has a different wrapper (actually these wrappers have a name like spec, PKGBUILD, etc.):

def setup:
... #use ./configure if autotools is used

def build:
... #use make if autotools is used

def install:
... #use make all if autotools is used

这里可以使用autotools,即./configuremakemake install.但是另一个可以使用 SCons、Python 相关设置或其他不同的东西.

Here one can use autotools, that means ./configure, make and make install. But another one can use SCons, Python related setup or something different.

正如您所见,拆分每个状态使维护和部署变得更加容易,尤其是对于软件包维护者和发行版而言.

As you see splitting each state makes things much easier for maintaining and deployment, especially for package maintainers and distros.

这篇关于为什么总是 ./configure;制作;进行安装;作为 3 个单独的步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆