It is bad practice to use make install
. Period.
Why? Because it installs files everywhere on your system—if you’re lucky, only in /usr/local
—with no guaranteed way to cleanly remove them afterwards.
Yet, sometimes, there is no other option, for example if some software is not packaged for your Unix of choice and you don’t have time to do it yourself. There are some easy and rather straightforward ways around it, which I usually recommend to beginners.
It happened again today. So I recommended the use of /opt/PKG-VER
as an installation prefix and stow(8) to make the software seamlessly available to the rest of the system. Nothing fancy or novel, but I thought I’d share the summary email in the hope it would help others.
My email read as follows.
First of all, never do a bare
make install
. Always install to a directory specific to your software./opt
is rather standard base path, and this can be told tomake
with variables such asPREFIX
orDESTDIR
(though you might need to look into theMakefile
or documentation to find if it is different). Try a non-root run first to make sure it tries to install in the right place.sudo make PREFIX=/opt/PKG-VER installThen, your package is in
$PREFIX
, with the normal directory layout, but the system can’t see it because it is not in its usual paths. You can create symlinks to all the files in your package in the usual system paths usingstow
(8).stow -d /opt/ -t /usr/local/ PKG-VERYou can use -n to do a dry run to make sure it does what you want first. Removing the symlinks is equally easy.
sudo stow -D -d /opt -t /usr/local/ PKG-VERAs an added bonus: de-installing (well, deleting) files from a previous
make install
withoutPREFIX
. You need to have another copy of the installed layout, this time done with thePREFIX
cd $PREFIX find -type f -exec echo rm /usr/local/{} \; # Double check that we will only remove what we want sudo find -type f -exec rm /usr/local/{} \; # Do it for realNote the
-type f
option tofind
(1), which tells it to only work on files, and not directories. Otherwise, you might end up removing things such as/usr/local/lib
(particularly if you usedrm -rf
), and it will be painful.