Linux 进行安装,但不安装到默认目录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3239343/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 20:15:22  来源:igfitidea点击:

Make install, but not to default directories?

linuxgccmakefileautotools

提问by Jon Phenow

I want to run 'make install' so I have everything I need, but I'd like it to install the things in their own folder as opposed to the system's /usr/bin etc. is that possible? even if it references tools in the /usr/bin etc.?

我想运行'make install',所以我有我需要的一切,但我希望它把东西安装在他们自己的文件夹中,而不是系统的/usr/bin 等。这可能吗?即使它引用了 /usr/bin 等中的工具?

采纳答案by Thomas

It depends on the package. If the Makefile is generated by GNU autotools (./configure) you can usually set the target location like so:

这取决于包。如果 Makefile 是由 GNU autotools ( ./configure)生成的,您通常可以像这样设置目标位置:

./configure --prefix=/somewhere/else/than/usr/local

If the Makefile is not generated by autotools, but distributed along with the software, simply open it up in an editor and change it. The install target directory is probably defined in a variable somewhere.

如果 Makefile 不是由 autotools 生成的,而是随软件一起分发的,只需在编辑器中打开并更改它即可。安装目标目录可能定义在某个变量中。

回答by Tree77

It could be dependent upon what is supported by the module you are trying to compile. If your makefile is generated by using autotools, use:

它可能取决于您尝试编译的模块所支持的内容。如果您的 makefile 是使用 autotools 生成的,请使用:

--prefix=<myinstalldir>

--prefix=<myinstalldir>

when running the ./configure

运行 ./configure 时

some packages allow you to also override when running:

一些软件包允许您在运行时也覆盖:

make prefix=<myinstalldir>

however, if your not using ./configure, only way to know for sure is to open up the makefile and check. It should be one of the first few variables at the top.

但是,如果您不使用 ./configure,唯一确定的方法是打开 makefile 并检查。它应该是顶部的前几个变量之一。

回答by Andor

Since don't know which version of automake you can use DESTDIRenvironment variable.
See Makefile to be sure.

由于不知道哪个版本的 automake 可以使用DESTDIR环境变量。
请参阅 Makefile 以确保。

For example:

例如:

 export DESTDIR="$HOME/Software/LocalInstall" && make -j4 install

回答by Christopher

try using INSTALL_ROOT.

尝试使用 INSTALL_ROOT。

make install INSTALL_ROOT=$INSTALL_DIRECTORY

回答by samasat

make DESTDIR=./new/customized/path install

This quick command worked for me for opencv release 3.2.0 installation on Ubuntu 16. DESTDIR path can be relative as well as absolute.

这个快速命令适用于我在 Ubuntu 16 上安装 opencv 3.2.0 版。DESTDIR 路径可以是相对的,也可以是绝对的。

Such redirection can also be useful in case user does not have admin privileges as long as DESTDIR location has right access for the user. e.g /home//

在用户没有管理员权限的情况下,只要 DESTDIR 位置对用户具有正确的访问权限,这种重定向也很有用。例如/家//

回答by Majid Azimi

I tried the above solutions. None worked.

我尝试了上述解决方案。没有一个工作。

In the end I opened Makefile file and manually changed prefix path to desired installation path like below.

最后,我打开了 Makefile 文件并手动将前缀路径更改为所需的安装路径,如下所示。

PREFIX ?= "installation path"

When I tried --prefix, "make" complained that there is not such command input. However, perhaps some packages accepts --prefix which is of course a cleaner solution.

当我尝试 --prefix 时,“make”抱怨没有这样的命令输入。然而,也许有些软件包接受 --prefix 这当然是一个更干净的解决方案。

回答by eli

If the package provides a Makefile.PL- one can use:

如果包提供了Makefile.PL- 一个可以使用:

perl Makefile.PL PREFIX=/home/my/local/lib LIB=/home/my/local/lib
make
make test
make install

* further explanation: https://www.perlmonks.org/?node_id=564720

* 进一步说明:https: //www.perlmonks.org/?node_id=564720