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

查看:163
本文介绍了为什么总是./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

人们为什么要分别执行这三个步骤?

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软件包站点.在这里,您会看到任何包都使用不同的configure参数(假设它们在构建系统中使用自动工具).

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

在这里,您会看到每个步骤实际上是一个不同的状态.这就是包管理器具有不同包装器的原因.下面是一个包装器的示例,它使您可以一步构建整个程序包.但是请记住,每个应用程序都有一个不同的包装器(实际上,这些包装器具有类似spec,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

这里可以使用自动工具,这意味着./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天全站免登陆