在运行

./configure --prefix=/mingw 

在我之前运行的一个库的MinGW/MSYS系统上

'./configure --prefix=/mingw && make && make install' 

我看到了这条信息:

警告:Vamp插件SDK的一个版本已经安装。如果您安装了新版本而没有先删除旧版本,那么您将会感到担忧和痛苦。(继续)

这让我很担心。“make install”的反义词是什么,即如何在Linux中卸载库?“清洁”能起作用吗,或者还有其他步骤吗?


当前回答

我知道很少有包支持“make uninstall”,但更多的包支持“make install DESTDIR=xxx”进行分期安装。

您可以使用它来创建一个包来安装,而不是直接从源代码安装。我没有运气与checkinstall,但fpm工作得很好。

这还可以帮助您删除之前使用make install安装的包。您只需强制在make installed的包上安装您构建的包,然后卸载它。

例如,我最近使用它来处理protobuf-3.3.0。 RHEL7:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t rpm -n protobuf -v 3.3.0 \
 --vendor "You Not RedHat" \
 --license "Google?" \
 --description "protocol buffers" \
 --rpm-dist el7 \
 -m you@youraddress.com \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 --rpm-autoreqprov \
 usr

 sudo rpm -i -f protobuf-3.3.0-1.el7.x86_64.rpm
 sudo rpm -e protobuf-3.3.0      

如果可以的话,你更喜欢yum而不是rpm。

Debian9:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t deb -n protobuf -v 3.3.0 \
-C `pwd` \
--prefix / \
--vendor "You Not Debian" \
--license "$(grep Copyright ../../LICENSE)" \
--description "$(cat README.adoc)" \
--deb-upstream-changelog ../../CHANGES.txt \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 usr/local/bin \
 usr/local/lib \
 usr/local/include

 sudo apt install -f *.deb
 sudo apt-get remove protobuf

在你能做到的地方,你更喜欢倾向于dpkg。

我也把答案贴在这里了

其他回答

根据makefile/configure脚本/autofoo魔法的问题,下面可能会解决你的问题:

make uninstall

问题是,您应该在已安装版本的源树上执行此操作,并使用与安装时完全相同的配置。

Make可以告诉你它知道什么,它会做什么。 假设你有一个“install”目标,它执行如下命令:

cp <filelist> <destdir>/

在你的通用规则中,添加:

uninstall :; MAKEFLAGS= ${MAKE} -j1 -spinf $(word 1,${MAKEFILE_LIST}) install \
              | awk '/^cp /{dest=$NF; for (i=NF; --i>0;) {print dest"/"$i}}' \
              | xargs rm -f

一个类似的技巧可以做一个通用的使干净。

如果你有一个清单文件,其中列出了所有安装make install的文件,你可以运行这个命令,这是我从另一个答案:

cat install_manifest.txt | xargs echo rm | sh

如果你有sudo make install,你需要添加一个sudo到你的卸载:

cat install_manifest.txt | xargs echo sudo rm | sh

我知道很少有包支持“make uninstall”,但更多的包支持“make install DESTDIR=xxx”进行分期安装。

您可以使用它来创建一个包来安装,而不是直接从源代码安装。我没有运气与checkinstall,但fpm工作得很好。

这还可以帮助您删除之前使用make install安装的包。您只需强制在make installed的包上安装您构建的包,然后卸载它。

例如,我最近使用它来处理protobuf-3.3.0。 RHEL7:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t rpm -n protobuf -v 3.3.0 \
 --vendor "You Not RedHat" \
 --license "Google?" \
 --description "protocol buffers" \
 --rpm-dist el7 \
 -m you@youraddress.com \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 --rpm-autoreqprov \
 usr

 sudo rpm -i -f protobuf-3.3.0-1.el7.x86_64.rpm
 sudo rpm -e protobuf-3.3.0      

如果可以的话,你更喜欢yum而不是rpm。

Debian9:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t deb -n protobuf -v 3.3.0 \
-C `pwd` \
--prefix / \
--vendor "You Not Debian" \
--license "$(grep Copyright ../../LICENSE)" \
--description "$(cat README.adoc)" \
--deb-upstream-changelog ../../CHANGES.txt \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 usr/local/bin \
 usr/local/lib \
 usr/local/include

 sudo apt install -f *.deb
 sudo apt-get remove protobuf

在你能做到的地方,你更喜欢倾向于dpkg。

我也把答案贴在这里了

Make clean通常只清理包含源代码本身的目录中的构建文件,很少涉及任何已安装的软件。

makefile通常不包含卸载目标——通常必须自己卸载,从安装它们的目录中删除文件。例如,如果您构建了一个程序并将其安装到/usr/local中(使用make install),那么您将希望查看/usr/local/bin、/usr/local/libexec、/usr/local/share/man等,并删除不需要的文件。有时Makefile包含卸载目标,但并非总是如此。

当然,通常在Linux系统上,您使用包管理器安装软件,包管理器能够“自动地”卸载软件。