Skip to contentSkip to conversation

trace-cmd: Updates to the Makefile

PATCH New Steven Rostedt 1 participant 13 messages Dec 16, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

cover trace-cmd: Updates to the Makefile

Steven Rostedt (VMware) (12):
trace-cmd: Move do_make_pkgconfig_file to utils.mk
trace-cmd: Have etcdir always be at the root directory
trace-cmd: Remove unused variable LD_SO_CONF_DIR
trace-cmd: Use the LIBTRACE{EVENT,FS}_LIBS for building libtracecmd.so
libtracecmd: Update ld.so.conf.d/trace.conf if needed
libtracecmd: Make installing show a nice INSTALL output
libtracecmd: Build libtracecmd.pc when building the library
libtracecmd: Show building of libtracecmd.pc
libtracecmd: Install libtracecmd.pc when installing libs
trace-cmd: Add make uninstall
trace-cmd: Update libtracecmd.pc if prefix is different
trace-cmd: Keep build_install files around

----

 .gitignore             |  4 ++++
 Makefile               | 62 ++++++++++++++++++++++++++++++++++----------------
 lib/trace-cmd/Makefile | 39 +++++++++++++++++++++++++++----
 lib/trace-cmd/test.c   |  7 ++++++
 scripts/utils.mk       | 21 +++++++++++++++++
 5 files changed, 109 insertions(+), 24 deletions(-)
 create mode 100644 lib/trace-cmd/test.c
#1 lore raw

PATCH 1/12 trace-cmd: Move do_make_pkgconfig_file to utils.mk

From: "Steven Rostedt (VMware)" <[email protected]>

The macro do_make_pkgconfig_file should be in utils.mk and not in the top Makefile as utils.mk is where other similar macros are located.

---
 Makefile         | 8 --------
 scripts/utils.mk | 8 ++++++++
 2 files changed, 8 insertions(+), 8 deletions(-)
Makefile +0 -8
index ab91ae777b83..595c8443e572 100644
@@ -208,14 +208,6 @@ obj		:= $(objtree)
 PKG_CONFIG_SOURCE_FILE = libtracecmd.pc
 PKG_CONFIG_FILE := $(addprefix $(BUILD_OUTPUT)/,$(PKG_CONFIG_SOURCE_FILE))
 
-define do_make_pkgconfig_file
-	cp -f $(srctree)/${PKG_CONFIG_SOURCE_FILE}.template ${PKG_CONFIG_FILE};	\
-	sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; 		\
-	sed -i "s|LIB_VERSION|${LIBTRACECMD_VERSION}|g" ${PKG_CONFIG_FILE}; \
-	sed -i "s|LIB_DIR|$(libdir)|g" ${PKG_CONFIG_FILE}; \
-	sed -i "s|HEADER_DIR|$(includedir)/trace-cmd|g" ${PKG_CONFIG_FILE};
-endef
-
 kshark-dir	= $(src)/kernel-shark
 
 export prefix bindir src obj kshark-dir
scripts/utils.mk +8 -0
index 1d090d8ac001..98549af9a774 100644
@@ -142,3 +142,11 @@ define do_install_pkgconfig_file
 		(echo Failed to locate pkg-config directory) 1>&2;		\
 	fi
 endef
+
+define do_make_pkgconfig_file
+	cp -f $(srctree)/${PKG_CONFIG_SOURCE_FILE}.template ${PKG_CONFIG_FILE};	\
+	sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; 		\
+	sed -i "s|LIB_VERSION|${LIBTRACECMD_VERSION}|g" ${PKG_CONFIG_FILE}; \
+	sed -i "s|LIB_DIR|$(libdir)|g" ${PKG_CONFIG_FILE}; \
+	sed -i "s|HEADER_DIR|$(includedir)/trace-cmd|g" ${PKG_CONFIG_FILE};
+endef
Signature · 1 line
2.29.2
#2 lore raw

PATCH 2/12 trace-cmd: Have etcdir always be at the root directory

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

There's a test if prefix == /usr/local and if so, then etcdir is set to "/etc", otherwise it is set to $(prefix)/etc, which is not correct.

Always have etcdir = "/etc".

---
 Makefile | 4 ----
 1 file changed, 4 deletions(-)
Makefile +0 -4
index 595c8443e572..f8252ba83352 100644
@@ -72,11 +72,7 @@ includedir_SQ = '$(subst ','\'',$(includedir))'
 pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) 		\
 			--variable pc_path pkg-config | tr ":" " "))
 
-ifeq ($(prefix),/usr/local)
 etcdir ?= /etc
-else
-etcdir ?= $(prefix)/etc
-endif
 etcdir_SQ = '$(subst ','\'',$(etcdir))'
 
 export man_dir man_dir_SQ html_install html_install_SQ INSTALL
Signature · 1 line
2.29.2
#3 lore raw

PATCH 3/12 trace-cmd: Remove unused variable LD_SO_CONF_DIR

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

The LD_SO_CONF_DIR variable in the Makefile is not used anywhere. Remove it.

---
 Makefile | 1 -
 1 file changed, 1 deletion(-)
Makefile +0 -1
index f8252ba83352..e956a2e6e8b6 100644
@@ -114,7 +114,6 @@ HELP_DIR_SQ = '$(subst ','\'',$(HELP_DIR))'
 #' emacs highlighting gets confused by the above escaped quote.
 
 BASH_COMPLETE_DIR ?= $(etcdir)/bash_completion.d
-LD_SO_CONF_DIR ?= $(etcdir)/ld.so.conf.d
 
 export PLUGIN_DIR_TRACEEVENT
 export PLUGIN_DIR_TRACECMD
Signature · 1 line
2.29.2
#4 lore raw

PATCH 4/12 trace-cmd: Use the LIBTRACE{EVENT,FS}_LIBS for building libtracecmd.so

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

Currently the path of the libtraceevent library is hardcoded when building libtracecmd.so, and libtracefs is not even specified. In order to use libtracecmd.so without needing to add -ltraceevent or -ltracefs, use the defined LIBTRACEVENT_LIBS and LIBTRACEFS_LIBS for the LIBS macro to build libtracecmd.so.

---
 lib/trace-cmd/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/trace-cmd/Makefile +1 -1
index 838a59ddf332..75e4fea4e3e0 100644
@@ -38,7 +38,7 @@ $(DEPS): | $(bdir)
 $(LIBTRACECMD_STATIC): $(OBJS)
 	$(Q)$(call do_build_static_lib)
 
-LIBS = -L$(obj)/lib/traceevent -ltraceevent
+LIBS = $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS)
 
 $(LIBTRACECMD_SHARED_VERSION): $(LIBTRACECMD_SHARED)
 	@ln -sf $(<F) $@
Signature · 1 line
2.29.2
#5 lore raw

PATCH 5/12 libtracecmd: Update ld.so.conf.d/trace.conf if needed

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

If DESTDIR is not defined (building for the current machine) check if after installing libtracecmd, if it is in the ld.so path by building a test program and running it, and making sure that the dynamic linker works, and if not, then update /etc/ld.so.conf.d/trace.conf to include the path to libtracecmd.so.

---
 Makefile               |  6 +++++-
 lib/trace-cmd/Makefile | 26 ++++++++++++++++++++++++++
 lib/trace-cmd/test.c   |  7 +++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 lib/trace-cmd/test.c
Makefile +5 -1
index e956a2e6e8b6..101820733862 100644
@@ -37,6 +37,10 @@ endef
 $(call allow-override,CC,$(CROSS_COMPILE)gcc)
 $(call allow-override,AR,$(CROSS_COMPILE)ar)
 $(call allow-override,PKG_CONFIG,pkg-config)
+$(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
+$(call allow-override,LDCONFIG,ldconfig)
+
+export LD_SO_CONF_PATH LDCONFIG
 
 EXT = -std=gnu99
 INSTALL = install
@@ -76,7 +80,7 @@ etcdir ?= /etc
 etcdir_SQ = '$(subst ','\'',$(etcdir))'
 
 export man_dir man_dir_SQ html_install html_install_SQ INSTALL
-export img_install img_install_SQ libdir_SQ includedir_SQ
+export img_install img_install_SQ libdir libdir_SQ includedir_SQ
 export DESTDIR DESTDIR_SQ
 
 ifeq ($(prefix),$(HOME))
lib/trace-cmd/Makefile +26 -0
index 75e4fea4e3e0..a26b989a2c82 100644
@@ -3,6 +3,7 @@
 include $(src)/scripts/utils.mk
 
 bdir:=$(obj)/lib/trace-cmd
+ldir:=$(src)/lib/trace-cmd
 
 DEFAULT_TARGET = $(LIBTRACECMD_STATIC)
 
@@ -59,11 +60,36 @@ $(DEPS): $(bdir)/.%.d: %.c
 
 $(OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
+ifeq ("$(DESTDIR)", "")
+# If DESTDIR is not defined, then test if after installing the library
+# and running ldconfig, if the library is visible by ld.so.
+# If not, add the path to /etc/ld.so.conf.d/trace.conf and run ldconfig again.
+define install_ld_config
+	$(LDCONFIG); \
+	if ! grep "^$(libdir)$$" $(LD_SO_CONF_PATH)/* &> /dev/null ; then \
+		$(CC) -o $(bdir)/test $(ldir)/test.c -I $(includedir_SQ) \
+			-L $(libdir_SQ) -ltracecmd > /dev/null; \
+		if ! $(bdir)/test &> /dev/null; then \
+			$(call print_install,trace.conf,$(LD_SO_CONF_PATH)) \
+			echo $(libdir_SQ) >> $(LD_SO_CONF_PATH)/trace.conf; \
+			$(LDCONFIG); \
+		fi; \
+		$(RM) $(bdir)/test; \
+	fi
+endef
+else
+# If installing to a location for another machine or package, do not bother
+# with running ldconfig.
+define install_ld_config
+endef
+endif # DESTDIR = ""
+
 install_libs:
 	$(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ))
 	cp -fpR $(LIBTRACECMD_SHARED_VERSION) $(DESTDIR)$(libdir_SQ)
 	cp -fpR $(LIBTRACECMD_SHARED_SO) $(DESTDIR)$(libdir_SQ)
 	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)/trace-cmd)
+	$(Q)$(call install_ld_config)
 
 dep_includes := $(wildcard $(DEPS))
 
lib/trace-cmd/test.c new file +7 -0
new file mode 100644
index 000000000000..5622d79c86c5
@@ -0,0 +1,7 @@
+#include <trace-cmd/trace-cmd.h>
+
+int main()
+{
+	tracecmd_open_head("trace.dat");
+	return 0;
+}
Signature · 1 line
2.29.2
#6 lore raw

PATCH 6/12 libtracecmd: Make installing show a nice INSTALL output

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

Currently, when doing "make install_libs" the output looks like:

INSTALL /tmp/build/lib/trace-cmd/libtracecmd.so.0.0.1 to /usr/local/lib64
cp -fpR /tmp/build/lib/trace-cmd/libtracecmd.so.0 '/usr/local/lib64' cp -fpR /tmp/build/lib/trace-cmd/libtracecmd.so '/usr/local/lib64'
INSTALL /work/git/trace-cmd.git/include/trace-cmd/trace-cmd.h to /usr/local/include/trace-cmd

Have it look like:

  INSTALL         /tmp/build/lib/trace-cmd/libtracecmd.so.0.0.1	to	/usr/local/lib64
  INSTALL         /tmp/build/lib/trace-cmd/libtracecmd.so.0	to	/usr/local/lib64
  INSTALL         /tmp/build/lib/trace-cmd/libtracecmd.so	to	/usr/local/lib64
  INSTALL         /work/git/trace-cmd.git/include/trace-cmd/trace-cmd.h	to	/usr/local/include/trace-cmd
---
 lib/trace-cmd/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/trace-cmd/Makefile +4 -2
index a26b989a2c82..3b8087f66db5 100644
@@ -86,8 +86,10 @@ endif # DESTDIR = ""
 
 install_libs:
 	$(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ))
-	cp -fpR $(LIBTRACECMD_SHARED_VERSION) $(DESTDIR)$(libdir_SQ)
-	cp -fpR $(LIBTRACECMD_SHARED_SO) $(DESTDIR)$(libdir_SQ)
+	$(Q)$(call print_install,$(LIBTRACECMD_SHARED_VERSION),$(DESTDIR)$(libdir_SQ))
+	$(Q)cp -fpR $(LIBTRACECMD_SHARED_VERSION) $(DESTDIR)$(libdir_SQ)
+	$(Q)$(call print_install,$(LIBTRACECMD_SHARED_SO),$(DESTDIR)$(libdir_SQ))
+	$(Q)cp -fpR $(LIBTRACECMD_SHARED_SO) $(DESTDIR)$(libdir_SQ)
 	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)/trace-cmd)
 	$(Q)$(call install_ld_config)
 
Signature · 1 line
2.29.2
#7 lore raw

PATCH 7/12 libtracecmd: Build libtracecmd.pc when building the library

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

Instead of creating libtracecmd.pc when installing, which will likely leave the file owned by root, create it when building the library.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 101820733862..038276b67464 100644
@@ -376,7 +376,7 @@ libtracecmd.a: $(LIBTRACECMD_STATIC)
 libtracecmd.so: $(LIBTRACECMD_SHARED)
 libtracefs.a: $(LIBTRACEFS_STATIC)
 
-libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD)
+libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD) $(PKG_CONFIG_FILE)
 
 test: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD) $(LIBTRACECMD_STATIC)
 ifneq ($(CUNIT_INSTALLED),1)
Signature · 1 line
2.29.2
#8 lore raw

PATCH 8/12 libtracecmd: Show building of libtracecmd.pc

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

Add printing a nice message "BUILD libtracecmd.pc" when it is being created.

And also add it to the .gitignore file.

---
 .gitignore       | 1 +
 scripts/utils.mk | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
.gitignore +1 -0
index ca6c9cb68f6f..1e8c1d4f5734 100644
@@ -23,3 +23,4 @@ cscope*
 traceevent_plugin_dir
 trace_python_dir
 tracecmd_plugin_dir
+libtracecmd.pc
scripts/utils.mk +2 -1
index 98549af9a774..e166c6ae3f9d 100644
@@ -144,7 +144,8 @@ define do_install_pkgconfig_file
 endef
 
 define do_make_pkgconfig_file
-	cp -f $(srctree)/${PKG_CONFIG_SOURCE_FILE}.template ${PKG_CONFIG_FILE};	\
+	$(print_app_build)
+	$(Q)cp -f $(srctree)/${PKG_CONFIG_SOURCE_FILE}.template ${PKG_CONFIG_FILE};	\
 	sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; 		\
 	sed -i "s|LIB_VERSION|${LIBTRACECMD_VERSION}|g" ${PKG_CONFIG_FILE}; \
 	sed -i "s|LIB_DIR|$(libdir)|g" ${PKG_CONFIG_FILE}; \
Signature · 1 line
2.29.2
#9 lore raw

PATCH 9/12 libtracecmd: Install libtracecmd.pc when installing libs

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

Instead of installing libtracecmd.pc when doing the install of the executable, install it durin "make install_libs". Also do some clean ups around the building and installin gof libtracecmd.pc.

---
 Makefile               | 8 +++-----
 lib/trace-cmd/Makefile | 5 ++++-
 2 files changed, 7 insertions(+), 6 deletions(-)
Makefile +3 -5
index 038276b67464..c1192da4f049 100644
@@ -207,6 +207,8 @@ obj		:= $(objtree)
 PKG_CONFIG_SOURCE_FILE = libtracecmd.pc
 PKG_CONFIG_FILE := $(addprefix $(BUILD_OUTPUT)/,$(PKG_CONFIG_SOURCE_FILE))
 
+export pkgconfig_dir PKG_CONFIG_FILE
+
 kshark-dir	= $(src)/kernel-shark
 
 export prefix bindir src obj kshark-dir
@@ -439,7 +441,7 @@ install_python: force
 install_bash_completion: force
 	$(Q)$(call do_install_data,$(src)/tracecmd/trace-cmd.bash,$(BASH_COMPLETE_DIR))
 
-install_cmd: all_cmd install_plugins install_python install_bash_completion install_pkgconfig
+install_cmd: all_cmd install_plugins install_python install_bash_completion
 	$(Q)$(call do_install,$(obj)/tracecmd/trace-cmd,$(bindir_SQ))
 
 install: install_cmd
@@ -468,10 +470,6 @@ install_doc:
 install_doc_gui:
 	$(MAKE) -C $(kshark-dir)/Documentation install
 
-install_pkgconfig: $(PKG_CONFIG_FILE)
-	$(Q)$(call , $(PKG_CONFIG_FILE)) \
-		$(call do_install_pkgconfig_file,$(prefix))
-
 clean:
 	$(RM) *.o *~ *.a *.so .*.d
 	$(RM) tags TAGS cscope* $(PKG_CONFIG_SOURCE_FILE)
lib/trace-cmd/Makefile +4 -1
index 3b8087f66db5..ec6ab29923db 100644
@@ -84,7 +84,10 @@ define install_ld_config
 endef
 endif # DESTDIR = ""
 
-install_libs:
+install_pkgconfig: $(PKG_CONFIG_FILE)
+	$(Q)$(call do_install_pkgconfig_file,$(prefix))
+
+install_libs: install_pkgconfig
 	$(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ))
 	$(Q)$(call print_install,$(LIBTRACECMD_SHARED_VERSION),$(DESTDIR)$(libdir_SQ))
 	$(Q)cp -fpR $(LIBTRACECMD_SHARED_VERSION) $(DESTDIR)$(libdir_SQ)
Signature · 1 line
2.29.2
#10 lore raw

PATCH 10/12 trace-cmd: Add make uninstall

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

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.

---
 Makefile         | 30 ++++++++++++++++++++++++++++++
 scripts/utils.mk |  2 ++
 2 files changed, 32 insertions(+)
Makefile +30 -0
index c1192da4f049..ddceab3f45e7 100644
@@ -484,6 +484,36 @@ clean:
 	if [ -f $(kshark-dir)/build/Makefile ]; then $(MAKE) -C $(kshark-dir)/build clean; fi
 	cd $(kshark-dir)/build; ./cmake_clean.sh
 
+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
+
+build_libs_uninstall:
+	$(call build_uninstall_script,install_libs,libs_uninstall)
+
+$(BUILD_OUTPUT)/build_libs_uninstall: build_libs_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) $<
+
+uninstall_libs: $(BUILD_OUTPUT)/build_libs_uninstall
+	@$(foreach file,$(shell cat $(BUILD_OUTPUT)/build_libs_uninstall),$(call uninstall_file,$(file)))
+	$(Q)$(RM) $<
 
 ##### PYTHON STUFF #####
 
scripts/utils.mk +2 -0
index e166c6ae3f9d..c8ef44b3776a 100644
@@ -30,6 +30,7 @@ ifeq ($(findstring 1,$(SILENT)$(VERBOSE)),1)
   print_plugin_obj_compile =
   print_plugin_build =
   print_install =
+  print_uninstall =
   print_update =
 else
   print_compile =		echo '  $(GUI)COMPILE            '$(GOBJ);
@@ -41,6 +42,7 @@ else
   print_static_lib_build =	echo '  $(GUI)BUILD STATIC LIB   '$(GOBJ);
   print_install =		echo '  $(GUI)INSTALL     '$(GSPACE)$1'	to	$(DESTDIR_SQ)$2';
   print_update =		echo '  $(GUI)UPDATE             '$(GOBJ);
+  print_uninstall =		echo '  $(GUI)UNINSTALLING $(DESTDIR_SQ)$1';
 endif
 
 do_fpic_compile =					\
Signature · 1 line
2.29.2
#11 lore raw

PATCH 11/12 trace-cmd: Update libtracecmd.pc if prefix is different

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

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

---
 .gitignore       |  1 +
 Makefile         |  7 ++++++-
 scripts/utils.mk | 10 ++++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)
.gitignore +1 -0
index 1e8c1d4f5734..9ce25c8e031e 100644
@@ -24,3 +24,4 @@ traceevent_plugin_dir
 trace_python_dir
 tracecmd_plugin_dir
 libtracecmd.pc
+build_prefix
Makefile +6 -1
index ddceab3f45e7..396a6795bad1 100644
@@ -343,7 +343,12 @@ CMAKE_COMMAND = /usr/bin/cmake
 # Build with "BUILD_TYPE=Release" to remove cmake debug info
 BUILD_TYPE ?= RelWithDebInfo
 
-$(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))
 
 $(kshark-dir)/build/Makefile: $(kshark-dir)/CMakeLists.txt
scripts/utils.mk +10 -0
index c8ef44b3776a..c06888795ddf 100644
@@ -121,6 +121,16 @@ define update_dir
 	fi);
 endef
 
+define build_prefix
+	(echo $1 > [email protected];	\
+	if [ -r $@ ] && cmp -s $@ [email protected]; then				\
+		rm -f [email protected];						\
+	else								\
+		$(print_update)						\
+		mv -f [email protected] $@;					\
+	fi);
+endef
+
 define do_install
 	$(print_install)				\
 	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
Signature · 1 line
2.29.2
#12 lore raw

PATCH 12/12 trace-cmd: Keep build_install files around

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

Instead of rebuilding the build_install and build_libs_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.

---
 .gitignore | 2 ++
 Makefile   | 6 ++----
 2 files changed, 4 insertions(+), 4 deletions(-)
.gitignore +2 -0
index 9ce25c8e031e..af9bf6c09a24 100644
@@ -25,3 +25,5 @@ trace_python_dir
 tracecmd_plugin_dir
 libtracecmd.pc
 build_prefix
+build_install
+build_libs_install
Makefile +2 -4
index 396a6795bad1..662d24ba288f 100644
@@ -496,12 +496,12 @@ 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
 
-build_libs_uninstall:
+build_libs_uninstall: $(BUILD_PREFIX)
 	$(call build_uninstall_script,install_libs,libs_uninstall)
 
 $(BUILD_OUTPUT)/build_libs_uninstall: build_libs_uninstall
@@ -514,11 +514,9 @@ endef
 
 uninstall: $(BUILD_OUTPUT)/build_uninstall
 	@$(foreach file,$(shell cat $(BUILD_OUTPUT)/build_uninstall),$(call uninstall_file,$(file)))
-	$(Q)$(RM) $<
 
 uninstall_libs: $(BUILD_OUTPUT)/build_libs_uninstall
 	@$(foreach file,$(shell cat $(BUILD_OUTPUT)/build_libs_uninstall),$(call uninstall_file,$(file)))
-	$(Q)$(RM) $<
 
 ##### PYTHON STUFF #####
 
Signature · 1 line
2.29.2