linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Subject: [PATCH 3/5] libtracefs: Add make uninstall
Date: Tue, 15 Dec 2020 23:38:55 -0500	[thread overview]
Message-ID: <20201216043921.621289635@goodmis.org> (raw)
In-Reply-To: 20201216043852.168982058@goodmis.org

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Create the logic to remove the files that would normally be installed.

Note, this does take the DESTDIR and prefix variables into account. Where
the uninstall may only work for an install with the same variables.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile         | 22 ++++++++++++++++++++++
 scripts/utils.mk |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/Makefile b/Makefile
index 5094966f4d06..653fdc448f45 100644
--- a/Makefile
+++ b/Makefile
@@ -264,6 +264,28 @@ install_doc:
 install_doc_gui:
 	$(MAKE) -C $(kshark-dir)/Documentation install
 
+define build_uninstall_script
+	$(Q)mkdir $(BUILD_OUTPUT)/tmp_build
+	$(Q)$(MAKE) -C $(src) DESTDIR=$(BUILD_OUTPUT)/tmp_build/ O=$(BUILD_OUTPUT) $1 > /dev/null
+	$(Q)find $(BUILD_OUTPUT)/tmp_build ! -type d -printf "%P\n" > $(BUILD_OUTPUT)/build_$2
+	$(Q)$(RM) -rf $(BUILD_OUTPUT)/tmp_build
+endef
+
+build_uninstall:
+	$(call build_uninstall_script,install,uninstall)
+
+$(BUILD_OUTPUT)/build_uninstall: build_uninstall
+
+define uninstall_file
+	if [ -f $(DESTDIR)/$1 -o -h $(DESTDIR)/$1 ]; then \
+		$(call print_uninstall,$(DESTDIR)/$1)$(RM) $(DESTDIR)/$1; \
+	fi;
+endef
+
+uninstall: $(BUILD_OUTPUT)/build_uninstall
+	@$(foreach file,$(shell cat $(BUILD_OUTPUT)/build_uninstall),$(call uninstall_file,$(file)))
+	$(Q)$(RM) $<
+
 PHONY += force
 force:
 
diff --git a/scripts/utils.mk b/scripts/utils.mk
index 398b88a75bfb..74b138eefed6 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -22,6 +22,7 @@ ifeq ($(findstring 1,$(SILENT)$(VERBOSE)),1)
   print_plugin_obj_compile =
   print_plugin_build =
   print_install =
+  print_uninstall =
   print_update =
 else
   print_compile =		echo '  COMPILE            '$(GOBJ);
@@ -32,6 +33,7 @@ else
   print_plugin_build =		echo '  BUILD PLUGIN       '$(GOBJ);
   print_static_lib_build =	echo '  BUILD STATIC LIB   '$(GOBJ);
   print_install =		echo '  INSTALL     '$1'	to	$(DESTDIR_SQ)$2';
+  print_uninstall =		echo '  UNINSTALL     $(DESTDIR_SQ)$1';
   print_update =		echo '  UPDATE             '$(GOBJ);
 endif
 
-- 
2.29.2



  parent reply	other threads:[~2020-12-16  4:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16  4:38 [PATCH 0/5] libtracefs: Makefile fixes, add uninstall and fix dependency of libtracefs.pc Steven Rostedt
2020-12-16  4:38 ` [PATCH 1/5] libtracefs: Have etcdir always be at the root directory Steven Rostedt
2020-12-16  4:38 ` [PATCH 2/5] libtracefs: Remove obsolete do_install_ld call Steven Rostedt
2020-12-16  4:38 ` Steven Rostedt [this message]
2020-12-16  4:38 ` [PATCH 4/5] libtracefs: Update libtracefs.pc if prefix is different Steven Rostedt
2020-12-16  4:38 ` [PATCH 5/5] libtracefs: Keep build_install file around Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201216043921.621289635@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).