diff mbox series

[4/5] libtracefs: Update libtracefs.pc if prefix is different

Message ID 20201216043921.836601434@goodmis.org (mailing list archive)
State Accepted
Commit 05c94eb230a17a0bd3edd87677f1217519a3bb80
Headers show
Series libtracefs: Makefile fixes, add uninstall and fix dependency of libtracefs.pc | expand

Commit Message

Steven Rostedt Dec. 16, 2020, 4:38 a.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

If a build is done with different DESTDIR and the prefix is changed, the
the libtracefs.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 libtracefs.pc.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile         |  7 ++++++-
 scripts/utils.mk | 10 ++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 653fdc448f45..204a4e5e6e1f 100644
--- a/Makefile
+++ b/Makefile
@@ -197,7 +197,12 @@  define do_make_pkgconfig_file
 	sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE};
 endef
 
-$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template
+BUILD_PREFIX := $(BUILD_OUTPUT)/build_prefix
+
+$(BUILD_PREFIX): force
+	$(Q)$(call build_prefix,$(prefix))
+
+$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template $(BUILD_PREFIX)
 	$(Q) $(call do_make_pkgconfig_file,$(prefix))
 
 tags:	force
diff --git a/scripts/utils.mk b/scripts/utils.mk
index 74b138eefed6..0d3c3194f6c5 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -113,6 +113,16 @@  define update_dir
 	fi);
 endef
 
+define build_prefix
+	(echo $1 > $@.tmp;	\
+	if [ -r $@ ] && cmp -s $@ $@.tmp; then				\
+		rm -f $@.tmp;						\
+	else								\
+		$(print_update)						\
+		mv -f $@.tmp $@;					\
+	fi);
+endef
+
 define do_install_mkdir
 	if [ ! -d '$(DESTDIR_SQ)$1' ]; then		\
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1';	\