diff mbox series

libtracefs: Add minimum version for libtraceevent

Message ID 20210408135146.32a99951@gandalf.local.home (mailing list archive)
State Accepted
Commit 790962a61a16d252232b0713cbec83fa7e104198
Headers show
Series libtracefs: Add minimum version for libtraceevent | expand

Commit Message

Steven Rostedt April 8, 2021, 5:51 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

As libtracefs may in the future require new APIs from libtraceveent, add a
test to make sure that the required libtraceevent is installed on the
system.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 0eddb61..ff1a3a6 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,8 @@  export TFS_PATCHLEVEL
 export TFS_EXTRAVERSION
 export TRACEFS_VERSION
 
+LIBTRACEEVENT_MIN_VERSION = 1.1
+
 # taken from trace-cmd
 MAKEFLAGS += --no-print-directory
 
@@ -62,12 +64,14 @@  includedir_SQ = '$(subst ','\'',$(includedir))'
 pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) 		\
 			--variable pc_path pkg-config | tr ":" " "))
 
-LIBTRACEEVENT_INCLUDES = $(shell $(PKG_CONFIG) --cflags libtraceevent)
-LIBTRACEEVENT_LIBS = $(shell $(PKG_CONFIG) --libs libtraceevent)
+TEST_LIBTRACEEVENT = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEEVENT_MIN_VERSION) libtraceevent > /dev/null 2>&1 && echo y")
 
-ifneq ($(MAKECMDGOALS),clean)
- ifeq ("$(LIBTRACEEVENT_INCLUDES)","")
-   $(error libtraceevent.so not installed)
+ifeq ("$(TEST_LIBTRACEEVENT)", "y")
+LIBTRACEEVENT_INCLUDES = $(shell sh -c "$(PKG_CONFIG) --cflags libtraceevent")
+LIBTRACEEVENT_LIBS = $(shell sh -c "$(PKG_CONFIG) --libs libtraceevent")
+else
+ ifneq ($(MAKECMDGOALS),clean)
+   $(error libtraceevent.so minimum version of $(LIBTRACEEVENT_MIN_VERSION) not installed)
  endif
 endif