Skip to contentSkip to conversation

trace-cmd: Add LOCAL_LIBS variable to force building the local libraries

PATCH New Steven Rostedt 1 participant 1 message Dec 21, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd: Add LOCAL_LIBS variable to force building the local libraries

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

In the process of changing the API for libtracefs before it becomes live, add LOCAL_LIBS make command line variable to allow overriding the check if libtracevent and libtracefs exist. If LOCAL_LIBS=1 is set on the make command line, then the local versions of the libraries are built.

This is mostly for debug purposes, so it does not need to be documented.

---
 Makefile | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Makefile +10 -2
index 7aef50b3..eb833f67 100644
@@ -232,7 +232,15 @@ LIBTRACEFS=libtracefs
 LIBTRACEFS_DIR = $(obj)/lib/tracefs
 LIBTRACEFS_STATIC = $(LIBTRACEFS_DIR)/libtracefs.a
 
-ifeq ($(shell sh -c "$(PKG_CONFIG) --cflags $(LIBTRACEEVENT) > /dev/null 2>&1 && echo y"), y)
+# In the special case (debugging), that the local versions of the
+# libraries need to be built, adding "LOCAL_LIBS=1" to the make
+# command line will skip the check if they are installed.
+ifneq ("$(origin LOCAL_LIBS)", "command line")
+TEST_LIBTRACEEVENT = $(shell sh -c "$(PKG_CONFIG) --cflags $(LIBTRACEEVENT) > /dev/null 2>&1 && echo y")
+TEST_LIBTRACEFS = $(shell sh -c "$(PKG_CONFIG) --cflags $(LIBTRACEFS) > /dev/null 2>&1 && echo y")
+endif
+
+ifeq ("$(TEST_LIBTRACEEVENT)", "y")
 LIBTRACEEVENT_CFLAGS = $(shell sh -c "$(PKG_CONFIG) --cflags $(LIBTRACEEVENT)")
 LIBTRACEEVENT_LDLAGS = $(shell sh -c "$(PKG_CONFIG) --libs $(LIBTRACEEVENT)")
 else
@@ -243,7 +251,7 @@ endif
 
 export LIBTRACEEVENT_CFLAGS LIBTRACEEVENT_LDLAGS
 
-ifeq ($(shell sh -c "$(PKG_CONFIG) --cflags $(LIBTRACEFS) > /dev/null 2>&1 && echo y"), y)
+ifeq ("$(TEST_LIBTRACEFS)", "y")
 LIBTRACEFS_CFLAGS = $(shell sh -c "$(PKG_CONFIG) --cflags $(LIBTRACEFS)")
 LIBTRACEFS_LDLAGS = $(shell sh -c "$(PKG_CONFIG) --libs $(LIBTRACEFS)")
 else
Signature · 1 line
2.25.4