All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] libtraceevent: Add uninstall and fix build dependency of libtraceevent.pc
@ 2020-12-16  4:36 Steven Rostedt
  2020-12-16  4:36 ` [PATCH 1/3] libtraceevent: Add a way to uninstall Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:36 UTC (permalink / raw)
  To: linux-trace-devel

Steven Rostedt (VMware) (3):
      libtraceevent: Add a way to uninstall
      libtraceevent: Update libtraceevent.pc if prefix is different
      libtraceevent: Keep build_install file around

----
 Makefile                 | 42 +++++++++++++++++++++++++++++++++++++++++-
 scripts/Makefile.include |  2 ++
 2 files changed, 43 insertions(+), 1 deletion(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] libtraceevent: Add a way to uninstall
  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
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:36 UTC (permalink / raw)
  To: linux-trace-devel

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] libtraceevent: Update libtraceevent.pc if prefix is different
  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 ` [PATCH 1/3] libtraceevent: Add a way to uninstall Steven Rostedt
@ 2020-12-16  4:36 ` Steven Rostedt
  2020-12-16  4:36 ` [PATCH 3/3] libtraceevent: Keep build_install file around Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:36 UTC (permalink / raw)
  To: linux-trace-devel

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

If a build is done with different DESTDIR and the prefix is changed, the
the libtraceevent.pc is not updated with the new prefix, and the one used may
not work with the installation being performed.

Add a "build_prefix" dependency, that creates a file "build_prefix" that has
the last prefix used to build the library. And if a new prefix is used, then
that file gets updated and so does libtraceevent.pc.

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

diff --git a/Makefile b/Makefile
index c85114beef96..f795e05d22a7 100644
--- a/Makefile
+++ b/Makefile
@@ -213,6 +213,21 @@ TAGS:	force
 	find . -name '*.[ch]' | xargs etags \
 	--regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
 
+define build_prefix
+	(echo $1 > $@.tmp;	\
+	if [ -r $@ ] && cmp -s $@ $@.tmp; then				\
+		rm -f $@.tmp;						\
+	else								\
+		$(PRINT_GEN)						\
+		mv -f $@.tmp $@;					\
+	fi);
+endef
+
+BUILD_PREFIX := $(OUTPUT)build_prefix
+
+$(BUILD_PREFIX): force
+	$(Q)$(call build_prefix,$(prefix))
+
 define do_install_mkdir
 	if [ ! -d '$(DESTDIR_SQ)$1' ]; then		\
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1';	\
@@ -232,7 +247,7 @@ define do_make_pkgconfig_file
 	sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE};
 endef
 
-$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template
+$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template $(BUILD_PREFIX)
 	$(QUIET_GEN) $(call do_make_pkgconfig_file,$(prefix))
 
 define do_install_pkgconfig_file
diff --git a/scripts/Makefile.include b/scripts/Makefile.include
index d505b2f20b92..1c9266c34d2a 100644
--- a/scripts/Makefile.include
+++ b/scripts/Makefile.include
@@ -110,6 +110,7 @@ ifneq ($(silent),1)
 	QUIET_AR       = @echo '  AR       '$@;
 	QUIET_LINK     = @echo '  LINK     '$@;
 	QUIET_MKDIR    = @echo '  MKDIR    '$@;
+	PRINT_GEN      = echo '  GEN      '$@;
 	QUIET_GEN      = @echo '  GEN      '$@;
 	QUIET_SUBDIR0  = +@subdir=
 	QUIET_SUBDIR1  = ;$(NO_SUBDIR) \
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] libtraceevent: Keep build_install file around
  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 ` [PATCH 1/3] libtraceevent: Add a way to uninstall Steven Rostedt
  2020-12-16  4:36 ` [PATCH 2/3] libtraceevent: Update libtraceevent.pc if prefix is different Steven Rostedt
@ 2020-12-16  4:36 ` Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:36 UTC (permalink / raw)
  To: linux-trace-devel

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

Instead of rebuilding the build_install files every time the uninstall is
created, make it depend on the prefix, as if the prefix is the same, then
the uninstall should be the same.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index f795e05d22a7..f96232b99e40 100644
--- a/Makefile
+++ b/Makefile
@@ -319,7 +319,7 @@ define build_uninstall_script
 	$(Q)$(RM) -rf $(BUILD_OUTPUT)/tmp_build
 endef
 
-build_uninstall:
+build_uninstall: $(BUILD_PREFIX)
 	$(call build_uninstall_script,install,uninstall)
 
 $(BUILD_OUTPUT)/build_uninstall: build_uninstall
@@ -332,7 +332,6 @@ endef
 
 uninstall: $(BUILD_OUTPUT)/build_uninstall
 	@$(foreach file,$(shell cat $(BUILD_OUTPUT)/build_uninstall),$(call uninstall_file,$(file)))
-	$(Q)$(RM) $<
 
 PHONY += doc
 doc:
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-16  4:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 1/3] libtraceevent: Add a way to uninstall Steven Rostedt
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.