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 1/3] libtraceevent: Add a way to uninstall
Date: Tue, 15 Dec 2020 23:36:38 -0500	[thread overview]
Message-ID: <20201216043716.818873731@goodmis.org> (raw)
In-Reply-To: 20201216043637.453360298@goodmis.org

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

Add an uninstall target. The way this works is to create a temp directory,
build and install into it. The examine the files in that directory, to know
what files need to be removed. The DESTDIR and prefix need to be the same as
how the install happened.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile                 | 26 ++++++++++++++++++++++++++
 scripts/Makefile.include |  1 +
 2 files changed, 27 insertions(+)

diff --git a/Makefile b/Makefile
index 12ae490276f4..c85114beef96 100644
--- a/Makefile
+++ b/Makefile
@@ -292,6 +292,32 @@ clean: clean_plugins clean_src
 		$(RM) $(OUTPUT)*.o $(OUTPUT)*~ $(TARGETS) $(OUTPUT)*.a $(OUTPUT)*.so $(VERSION_FILES) $(OUTPUT).*.d $(OUTPUT).*.cmd; \
 		$(RM) TRACEEVENT-CFLAGS $(OUTPUT)tags $(OUTPUT)TAGS; \
 		$(RM) $(PKG_CONFIG_FILE)
+ifneq ($(OUTPUT),)
+else
+BUILD_OUTPUT := $(shell pwd)
+endif
+
+define build_uninstall_script
+	$(Q)mkdir $(BUILD_OUTPUT)/tmp_build
+	$(Q)$(MAKE) -C $(srctree) 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_UNINST,$(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 += doc
 doc:
diff --git a/scripts/Makefile.include b/scripts/Makefile.include
index 5257bd6637a9..d505b2f20b92 100644
--- a/scripts/Makefile.include
+++ b/scripts/Makefile.include
@@ -124,6 +124,7 @@ ifneq ($(silent),1)
 		$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
 
 	PRINT_INSTALL  = printf '  INSTALL  %s\n' $1;
+	PRINT_UNINST   = printf '  UNINST   %s\n' $1;
 	QUIET_CLEAN    = @printf '  CLEAN    %s\n' $1;
 	QUIET_INSTALL  = @printf '  INSTALL  %s\n' $1;
 	QUIET_UNINST   = @printf '  UNINST   %s\n' $1;
-- 
2.29.2



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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16  4:36 [PATCH 0/3] libtraceevent: Add uninstall and fix build dependency of libtraceevent.pc Steven Rostedt
2020-12-16  4:36 ` Steven Rostedt [this message]
2020-12-16  4:36 ` [PATCH 2/3] libtraceevent: Update libtraceevent.pc if prefix is different Steven Rostedt
2020-12-16  4:36 ` [PATCH 3/3] libtraceevent: 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=20201216043716.818873731@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).