Linux make 的 DESTDIR 和 PREFIX
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11307465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DESTDIR and PREFIX of make
提问by Sean
I am trying to make software install to a specific directory. I found several ways, but not sure what are the differences between them.
我正在尝试将软件安装到特定目录。我找到了几种方法,但不确定它们之间有什么区别。
./configure --prefix=***
make install DESTDIR=***
make install prefix=***
./configure --prefix=***
make install DESTDIR=***
make install prefix=***
I am confused about the functions of these three. Do they achieve the same goal?
我对这三个的功能感到困惑。他们是否实现了相同的目标?
采纳答案by Alan Curry
./configure --prefix=***
./configure --prefix=***
Number 1determines 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.
数字 1确定安装包时将安装到何处,以及在运行时将查找其关联文件的位置。如果您只是为了在单个主机上使用而编译某些东西,那么您应该使用它。
make install DESTDIR=***
make install DESTDIR=***
Number 2is 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
编号 2用于安装到临时目录,该目录不是运行包的位置。例如,这在构建deb
包时使用。构建包的人实际上并没有将所有东西都安装到他自己系统上的最终位置。他可能已经安装了不同的版本并且不想打扰它,或者他甚至可能不是 root。所以他用
./configure --prefix=/usr
so the program will expect to be installed in /usr
when it runs, then
所以程序将期望在/usr
运行时安装,然后
make install DESTDIR=debian/tmp
to actually create the directory structure.
实际创建目录结构。
make install prefix=***
make install prefix=***
Number 3is 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
数字 3将把它安装到不同的地方,但不会像DESTDIR=/foo/bar/baz
那样创建所有目录。它通常与 GNU stow 一起使用
./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,
,这将在/usr/local/stow/foo/bin
. 通过比较,
make install DESTDIR=/usr/local/stow/foo
would install binaries in /usr/local/stow/foo/usr/local/bin
.
将在/usr/local/stow/foo/usr/local/bin
.
回答by sancho.s ReinstateMonicaCellio
This can help illustrating the use of DESTDIR
and --prefix
(from here):
这可以帮助说明使用DESTDIR
和--prefix
(来自这里):
Multiple installs using --prefix and DESTDIR:
Sepcify a different --prefix location/option for each build - at configure time. For eg:
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
使用 --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
回答by kyb
From openssl/INSTALL
从 openssl/INSTALL
Package builders who want to configure the library for standard locations, but have the package installed somewhere else so that it can easily be packaged, can use
$ make INSTALL_PREFIX=/tmp/package-root install
(or specify "--install_prefix=/tmp/package-root" as a configure option). The specified prefix will be prepended to all installation target filenames.
想要为标准位置配置库但将包安装在其他位置以便可以轻松打包的包构建器可以使用
$ make INSTALL_PREFIX=/tmp/package-root install
(或指定“--install_prefix=/tmp/package-root”作为配置选项)。指定的前缀将被添加到所有安装目标文件名之前。
This is non-standard but INSTALL_PREFIX is used in some other programs.
这是非标准的,但 INSTALL_PREFIX 用于其他一些程序。
This works for OpenSSL versions before 1.1.x. OpenSSL 1.1.x and later are able to recognize usual DESTDIR
.
这适用于 1.1.x 之前的 OpenSSL 版本。OpenSSL 1.1.x 及更高版本能够识别通常的DESTDIR
.