All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] trace-cmd: Updates to the Makefile
@ 2020-12-16  4:41 Steven Rostedt
  2020-12-16  4:41 ` [PATCH 01/12] trace-cmd: Move do_make_pkgconfig_file to utils.mk Steven Rostedt
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel


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

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

* [PATCH 01/12] trace-cmd: Move do_make_pkgconfig_file to utils.mk
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:41 ` [PATCH 02/12] trace-cmd: Have etcdir always be at the root directory Steven Rostedt
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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.

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

diff --git a/Makefile b/Makefile
index ab91ae777b83..595c8443e572 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/scripts/utils.mk b/scripts/utils.mk
index 1d090d8ac001..98549af9a774 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -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
-- 
2.29.2



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

* [PATCH 02/12] trace-cmd: Have etcdir always be at the root directory
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
  2020-12-16  4:41 ` [PATCH 01/12] trace-cmd: Move do_make_pkgconfig_file to utils.mk Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:41 ` [PATCH 03/12] trace-cmd: Remove unused variable LD_SO_CONF_DIR Steven Rostedt
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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".

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

diff --git a/Makefile b/Makefile
index 595c8443e572..f8252ba83352 100644
--- a/Makefile
+++ b/Makefile
@@ -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
-- 
2.29.2



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

* [PATCH 03/12] trace-cmd: Remove unused variable LD_SO_CONF_DIR
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
  2020-12-16  4:41 ` [PATCH 01/12] trace-cmd: Move do_make_pkgconfig_file to utils.mk Steven Rostedt
  2020-12-16  4:41 ` [PATCH 02/12] trace-cmd: Have etcdir always be at the root directory Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:41 ` [PATCH 04/12] trace-cmd: Use the LIBTRACE{EVENT,FS}_LIBS for building libtracecmd.so Steven Rostedt
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile b/Makefile
index f8252ba83352..e956a2e6e8b6 100644
--- a/Makefile
+++ b/Makefile
@@ -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
-- 
2.29.2



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

* [PATCH 04/12] trace-cmd: Use the LIBTRACE{EVENT,FS}_LIBS for building libtracecmd.so
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (2 preceding siblings ...)
  2020-12-16  4:41 ` [PATCH 03/12] trace-cmd: Remove unused variable LD_SO_CONF_DIR Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:41 ` [PATCH 05/12] libtracecmd: Update ld.so.conf.d/trace.conf if needed Steven Rostedt
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/trace-cmd/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/trace-cmd/Makefile b/lib/trace-cmd/Makefile
index 838a59ddf332..75e4fea4e3e0 100644
--- a/lib/trace-cmd/Makefile
+++ b/lib/trace-cmd/Makefile
@@ -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) $@
-- 
2.29.2



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

* [PATCH 05/12] libtracecmd: Update ld.so.conf.d/trace.conf if needed
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (3 preceding siblings ...)
  2020-12-16  4:41 ` [PATCH 04/12] trace-cmd: Use the LIBTRACE{EVENT,FS}_LIBS for building libtracecmd.so Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:41 ` [PATCH 06/12] libtracecmd: Make installing show a nice INSTALL output Steven Rostedt
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 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

diff --git a/Makefile b/Makefile
index e956a2e6e8b6..101820733862 100644
--- a/Makefile
+++ b/Makefile
@@ -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))
diff --git a/lib/trace-cmd/Makefile b/lib/trace-cmd/Makefile
index 75e4fea4e3e0..a26b989a2c82 100644
--- a/lib/trace-cmd/Makefile
+++ b/lib/trace-cmd/Makefile
@@ -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))
 
diff --git a/lib/trace-cmd/test.c b/lib/trace-cmd/test.c
new file mode 100644
index 000000000000..5622d79c86c5
--- /dev/null
+++ b/lib/trace-cmd/test.c
@@ -0,0 +1,7 @@
+#include <trace-cmd/trace-cmd.h>
+
+int main()
+{
+	tracecmd_open_head("trace.dat");
+	return 0;
+}
-- 
2.29.2



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

* [PATCH 06/12] libtracecmd: Make installing show a nice INSTALL output
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (4 preceding siblings ...)
  2020-12-16  4:41 ` [PATCH 05/12] libtracecmd: Update ld.so.conf.d/trace.conf if needed Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:41 ` [PATCH 07/12] libtracecmd: Build libtracecmd.pc when building the library Steven Rostedt
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/trace-cmd/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/trace-cmd/Makefile b/lib/trace-cmd/Makefile
index a26b989a2c82..3b8087f66db5 100644
--- a/lib/trace-cmd/Makefile
+++ b/lib/trace-cmd/Makefile
@@ -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)
 
-- 
2.29.2



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

* [PATCH 07/12] libtracecmd: Build libtracecmd.pc when building the library
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (5 preceding siblings ...)
  2020-12-16  4:41 ` [PATCH 06/12] libtracecmd: Make installing show a nice INSTALL output Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:41 ` [PATCH 08/12] libtracecmd: Show building of libtracecmd.pc Steven Rostedt
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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

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

diff --git a/Makefile b/Makefile
index 101820733862..038276b67464 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
-- 
2.29.2



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

* [PATCH 08/12] libtracecmd: Show building of libtracecmd.pc
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (6 preceding siblings ...)
  2020-12-16  4:41 ` [PATCH 07/12] libtracecmd: Build libtracecmd.pc when building the library Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:41 ` [PATCH 09/12] libtracecmd: Install libtracecmd.pc when installing libs Steven Rostedt
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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

And also add it to the .gitignore file.

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

diff --git a/.gitignore b/.gitignore
index ca6c9cb68f6f..1e8c1d4f5734 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@ cscope*
 traceevent_plugin_dir
 trace_python_dir
 tracecmd_plugin_dir
+libtracecmd.pc
diff --git a/scripts/utils.mk b/scripts/utils.mk
index 98549af9a774..e166c6ae3f9d 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -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}; \
-- 
2.29.2



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

* [PATCH 09/12] libtracecmd: Install libtracecmd.pc when installing libs
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (7 preceding siblings ...)
  2020-12-16  4:41 ` [PATCH 08/12] libtracecmd: Show building of libtracecmd.pc Steven Rostedt
@ 2020-12-16  4:41 ` Steven Rostedt
  2020-12-16  4:42 ` [PATCH 10/12] trace-cmd: Add make uninstall Steven Rostedt
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:41 UTC (permalink / raw)
  To: linux-trace-devel

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

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.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile               | 8 +++-----
 lib/trace-cmd/Makefile | 5 ++++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 038276b67464..c1192da4f049 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
diff --git a/lib/trace-cmd/Makefile b/lib/trace-cmd/Makefile
index 3b8087f66db5..ec6ab29923db 100644
--- a/lib/trace-cmd/Makefile
+++ b/lib/trace-cmd/Makefile
@@ -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)
-- 
2.29.2



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

* [PATCH 10/12] trace-cmd: Add make uninstall
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (8 preceding siblings ...)
  2020-12-16  4:41 ` [PATCH 09/12] libtracecmd: Install libtracecmd.pc when installing libs Steven Rostedt
@ 2020-12-16  4:42 ` Steven Rostedt
  2020-12-16  4:42 ` [PATCH 11/12] trace-cmd: Update libtracecmd.pc if prefix is different Steven Rostedt
  2020-12-16  4:42 ` [PATCH 12/12] trace-cmd: Keep build_install files around Steven Rostedt
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:42 UTC (permalink / raw)
  To: linux-trace-devel

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         | 30 ++++++++++++++++++++++++++++++
 scripts/utils.mk |  2 ++
 2 files changed, 32 insertions(+)

diff --git a/Makefile b/Makefile
index c1192da4f049..ddceab3f45e7 100644
--- a/Makefile
+++ b/Makefile
@@ -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 #####
 
diff --git a/scripts/utils.mk b/scripts/utils.mk
index e166c6ae3f9d..c8ef44b3776a 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -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 =					\
-- 
2.29.2



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

* [PATCH 11/12] trace-cmd: Update libtracecmd.pc if prefix is different
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (9 preceding siblings ...)
  2020-12-16  4:42 ` [PATCH 10/12] trace-cmd: Add make uninstall Steven Rostedt
@ 2020-12-16  4:42 ` Steven Rostedt
  2020-12-16  4:42 ` [PATCH 12/12] trace-cmd: Keep build_install files around Steven Rostedt
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:42 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 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.

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

diff --git a/.gitignore b/.gitignore
index 1e8c1d4f5734..9ce25c8e031e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,4 @@ traceevent_plugin_dir
 trace_python_dir
 tracecmd_plugin_dir
 libtracecmd.pc
+build_prefix
diff --git a/Makefile b/Makefile
index ddceab3f45e7..396a6795bad1 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/scripts/utils.mk b/scripts/utils.mk
index c8ef44b3776a..c06888795ddf 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -121,6 +121,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
 	$(print_install)				\
 	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
-- 
2.29.2



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

* [PATCH 12/12] trace-cmd: Keep build_install files around
  2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
                   ` (10 preceding siblings ...)
  2020-12-16  4:42 ` [PATCH 11/12] trace-cmd: Update libtracecmd.pc if prefix is different Steven Rostedt
@ 2020-12-16  4:42 ` Steven Rostedt
  11 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-12-16  4:42 UTC (permalink / raw)
  To: linux-trace-devel

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

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.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 .gitignore | 2 ++
 Makefile   | 6 ++----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 9ce25c8e031e..af9bf6c09a24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,5 @@ trace_python_dir
 tracecmd_plugin_dir
 libtracecmd.pc
 build_prefix
+build_install
+build_libs_install
diff --git a/Makefile b/Makefile
index 396a6795bad1..662d24ba288f 100644
--- a/Makefile
+++ b/Makefile
@@ -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 #####
 
-- 
2.29.2



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

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

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16  4:41 [PATCH 00/12] trace-cmd: Updates to the Makefile Steven Rostedt
2020-12-16  4:41 ` [PATCH 01/12] trace-cmd: Move do_make_pkgconfig_file to utils.mk Steven Rostedt
2020-12-16  4:41 ` [PATCH 02/12] trace-cmd: Have etcdir always be at the root directory Steven Rostedt
2020-12-16  4:41 ` [PATCH 03/12] trace-cmd: Remove unused variable LD_SO_CONF_DIR Steven Rostedt
2020-12-16  4:41 ` [PATCH 04/12] trace-cmd: Use the LIBTRACE{EVENT,FS}_LIBS for building libtracecmd.so Steven Rostedt
2020-12-16  4:41 ` [PATCH 05/12] libtracecmd: Update ld.so.conf.d/trace.conf if needed Steven Rostedt
2020-12-16  4:41 ` [PATCH 06/12] libtracecmd: Make installing show a nice INSTALL output Steven Rostedt
2020-12-16  4:41 ` [PATCH 07/12] libtracecmd: Build libtracecmd.pc when building the library Steven Rostedt
2020-12-16  4:41 ` [PATCH 08/12] libtracecmd: Show building of libtracecmd.pc Steven Rostedt
2020-12-16  4:41 ` [PATCH 09/12] libtracecmd: Install libtracecmd.pc when installing libs Steven Rostedt
2020-12-16  4:42 ` [PATCH 10/12] trace-cmd: Add make uninstall Steven Rostedt
2020-12-16  4:42 ` [PATCH 11/12] trace-cmd: Update libtracecmd.pc if prefix is different Steven Rostedt
2020-12-16  4:42 ` [PATCH 12/12] trace-cmd: Keep build_install files 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.