From f22889764135f304bf93d5638a8a830f32e93f38 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Fri, 19 Oct 2018 09:49:44 +0200 Subject: [PATCH] make: Add uninstall target --- Makefile | 17 +++++++++++++++++ tools/dmake.cpp | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Makefile b/Makefile index c04915cb6..f92a6c532 100644 --- a/Makefile +++ b/Makefile @@ -300,6 +300,23 @@ ifdef CFGDIR install -m 644 cfg/* ${DESTDIR}${CFGDIR} endif +uninstall: + @if test -d ${BIN}; then \ + files="cppcheck cppcheck-htmlreport \ + `ls -d addons/*.py addons/*/*.py 2>/dev/null | sed 's,^.*/,,'`"; \ + echo '(' cd ${BIN} '&&' rm -f $$files ')'; \ + ( cd ${BIN} && rm -f $$files ); \ + fi +ifdef CFGDIR + @if test -d ${DESTDIR}${CFGDIR}; then \ + files="`cd cfg 2>/dev/null && ls`"; \ + if test -n "$$files"; then \ + echo '(' cd ${DESTDIR}${CFGDIR} '&&' rm -f $$files ')'; \ + ( cd ${DESTDIR}${CFGDIR} && rm -f $$files ); \ + fi; \ + fi +endif + # Validation of library files: ConfigFiles := $(wildcard cfg/*.cfg) ConfigFilesCHECKED := $(patsubst %.cfg,%.checked,$(ConfigFiles)) diff --git a/tools/dmake.cpp b/tools/dmake.cpp index 9a45e4780..8c34f6c85 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -400,6 +400,22 @@ int main(int argc, char **argv) fout << "\tinstall -d ${DESTDIR}${CFGDIR}\n"; fout << "\tinstall -m 644 cfg/* ${DESTDIR}${CFGDIR}\n"; fout << "endif\n\n"; + fout << "uninstall:\n"; + fout << "\t@if test -d ${BIN}; then \\\n"; + fout << "\t files=\"cppcheck cppcheck-htmlreport \\\n"; + fout << "\t `ls -d addons/*.py addons/*/*.py 2>/dev/null | sed 's,^.*/,,'`\"; \\\n"; + fout << "\t echo '(' cd ${BIN} '&&' rm -f $$files ')'; \\\n"; + fout << "\t ( cd ${BIN} && rm -f $$files ); \\\n"; + fout << "\tfi\n"; + fout << "ifdef CFGDIR \n"; + fout << "\t@if test -d ${DESTDIR}${CFGDIR}; then \\\n"; + fout << "\t files=\"`cd cfg 2>/dev/null && ls`\"; \\\n"; + fout << "\t if test -n \"$$files\"; then \\\n"; + fout << "\t echo '(' cd ${DESTDIR}${CFGDIR} '&&' rm -f $$files ')'; \\\n"; + fout << "\t ( cd ${DESTDIR}${CFGDIR} && rm -f $$files ); \\\n"; + fout << "\t fi; \\\n"; + fout << "\tfi\n"; + fout << "endif\n\n"; fout << "# Validation of library files:\n"; fout << "ConfigFiles := $(wildcard cfg/*.cfg)\n"; fout << "ConfigFilesCHECKED := $(patsubst %.cfg,%.checked,$(ConfigFiles))\n";