Make install, but not to default directories?

LinuxGccMakefileAutotools

Linux Problem Overview


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

Linux Solutions


Solution 1 - Linux

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

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

Solution 2 - Linux

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

For example:

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

Solution 3 - Linux

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.

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//

Solution 4 - Linux

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:

--prefix=<myinstalldir>

when running the ./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.

Solution 5 - Linux

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

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

Solution 6 - Linux

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.

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.

Solution 7 - Linux

try using INSTALL_ROOT.

make install INSTALL_ROOT=$INSTALL_DIRECTORY

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJon PhenowView Question on Stackoverflow
Solution 1 - LinuxThomasView Answer on Stackoverflow
Solution 2 - LinuxAndorView Answer on Stackoverflow
Solution 3 - LinuxsamasatView Answer on Stackoverflow
Solution 4 - LinuxTree77View Answer on Stackoverflow
Solution 5 - LinuxMacMartinView Answer on Stackoverflow
Solution 6 - LinuxMajid AzimiView Answer on Stackoverflow
Solution 7 - LinuxChristopherView Answer on Stackoverflow