How can you uninstall software that was built and installed from source? (Using make install?)
4 Answers
Do you still have the source package? You can parse the Makefile for install commands, or you can install it again (with another $PREFIX) to capture a list of installed files. Also, it is printed to STDOUT. You could then remove those files from the directory where they were installed originally.
Edit:
I just dug up my notes on making an uninstaller script. Bear with me, I am paraphrasing here.
After you build and install to a temporary target directory, do the following. (Where $PREFIX is whatever you used with ./configure.)
cd $PREFIX
find . -type f | cut -b 1 --complement | sed 's/^/rm -f \/usr\/local/g' > uninstall.sh
find . -type d | cut -b 1 --complement | sed 's/^/rmdir --ignore-fail-on-non-empty \/usr\/local/g' >> uninstall.sh
The output will look like:
rm -f /usr/local/lib/somelib.so
rm -f /usr/local/bin/somebin
rm -f /usr/local/include/someapp/someheaders.h
rmdir --ignore-fail-on-non-empty /usr/local/share
rmdir --ignore-fail-on-non-empty /usr/local/bin
rmdir --ignore-fail-on-non-empty /usr/local/include/someapp
...
This doesn't actually remove the critical system directories (/usr/local/bin, etc) because they'll be non-empty. Also, you'll want to confirm that your ./configure script uses /usr/local as the default $PREFIX. Adjust the sed command as necessary.
-
1Damn Linux. I really should start using a different prefix for each program isntead of /usr/localmxmlnkn– mxmlnkn2017-09-27 02:10:12 +00:00Commented Sep 27, 2017 at 2:10
I checked with php version 5.4.16
cd php-5.4.16
make clean
make clean all
find / -name php
rm -fr /usr/local/php /usr/local/lib/php /usr/local/bin/php /usr/local/include/php
whereis {php-config,phpize,php-cgi}
rm /usr/local/bin/php-config /usr/local/bin/phpize /usr/local/bin/php-cgi
whereis {pear,peardev}
rm /usr/local/bin/pear
rm /usr/local/bin/peardev
why I select phpize and php-config
because after ./configure I got this output
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h
You could try to brute force it:
Do a find / > /tmp/all_files and save to a file all_files. (Exclude sysfs and procfs and other if you know the files are not there)
Do a rpm -qa | xargs rpm -al > /tmp/all_owned_files to get a list of all files "owned" by rpm. (Assuming this is a rpm based system, use other commands for non-rpm systems)
Do a diff between these two files, and comb through it.
check the command in source directory
make clean
make clean all
Or you have to remove all the files as described by Aaron
-
1
make cleanvery rarely, in my experience, removes the installed binaries; it only cleans out compilation-related cruft from the build directory.MadHatter– MadHatter2013-06-19 19:25:46 +00:00Commented Jun 19, 2013 at 19:25 -
1
make cleanin fact does not removed installed files. It simply removes things like object files (.o) so they can be re-compiled (say, if the configure or Makefile is changed).Nathan C– Nathan C2013-06-19 19:38:18 +00:00Commented Jun 19, 2013 at 19:38 -
I am just downloading the php source code to check what steps should be followed.Sharad Chhetri– Sharad Chhetri2013-06-19 19:40:20 +00:00Commented Jun 19, 2013 at 19:40
make installchoose the target directory, it might have ended up in/usr/local/bin, which usually has precedence over/usr/bin, hence you still use the firstphpbinary found in yourPATH. You could trymake -n installand see where and what it wants to install stuff, and remove by hand. Untested and dangerous, of course.Makefileprovides the means, then yes. Always generate packages, even for upstream built sources.