149

我正在尝试将软件安装到特定目录。我找到了几种方法,但不确定它们之间有什么区别。

  1. ./configure --prefix=***
  2. make install DESTDIR=***
  3. make install prefix=***

我对这三个的功能感到困惑。他们实现了相同的目标吗?

4

3 回答 3

223

./configure --prefix=***

Number 1 determines where the package will go when it is installed, and where it will look for its associated files when it is run. It's what you should use if you're just compiling something for use on a single host.


make install DESTDIR=***

Number 2 is for installing to a temporary directory which is not where the package will be run from. For example this is used when building deb packages. The person building the package doesn't actually install everything into its final place on his own system. He may have a different version installed already and not want to disturb it, or he may not even be root. So he uses

./configure --prefix=/usr

so the program will expect to be installed in /usr when it runs, then

make install DESTDIR=debian/tmp

to actually create the directory structure.


make install prefix=***

Number 3 is going to install it to a different place but not create all the directories as DESTDIR=/foo/bar/baz would. It's commonly used with GNU stow via

./configure --prefix=/usr/local && make && sudo make install prefix=/usr/local/stow/foo

, which would install binaries in /usr/local/stow/foo/bin. By comparison,

make install DESTDIR=/usr/local/stow/foo

would install binaries in /usr/local/stow/foo/usr/local/bin.

于 2012-07-03T09:09:19.673 回答
1

这可以帮助说明和的用法DESTDIR--prefix这里):

使用 --prefix 和 DESTDIR 进行多次安装:

在配置时为每个构建指定不同的 --prefix 位置/选项。例如:

untar petsc tar ball
./configure --prefix=/opt/petsc/petsc-3.9.0-mpich --with-mpi-dir=/opt/mpich
make
make install DESTDIR=/tmp/petsc-pkg
untar petsc tar ball
./configure --prefix=/opt/petsc/petsc-3.9.0-openmpi --with-mpi-dir=/opt/openmpi
make
make install DESTDIR=/tmp/petsc-pkg
于 2018-04-27T14:31:14.193 回答
0

openssl/INSTALL

想要为标准位置配置库但将包安装在其他地方以便可以轻松打包的包构建器可以使用

$ make INSTALL_PREFIX=/tmp/package-root install

(或指定“--install_prefix=/tmp/package-root”作为配置选项)。指定的前缀将添加到所有安装目标文件名。

这是非标准的,但 INSTALL_PREFIX 在其他一些程序中使用。

这适用于 1.1.x 之前的 OpenSSL 版本。OpenSSL 1.1.x 及更高版本能够识别通常的DESTDIR.

于 2019-04-16T16:42:06.120 回答