diff mbox series

[5/6] libtracefs: Use pkg-config to find libtraceevent

Message ID 20201208215504.983661503@goodmis.org (mailing list archive)
State Accepted
Commit 803798baf5485f7201b9a433a4d41f6ac82fca07
Headers show
Series libtracefs: Clean up of the source directory | expand

Commit Message

Steven Rostedt Dec. 8, 2020, 9:54 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

As libtracefs is dependent on libtraceevent, use the proper pkg-config
method to find where libtraceevent is installed.

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

Patch

diff --git a/Makefile b/Makefile
index f6b6a9ede5c0..be57682d37c9 100644
--- a/Makefile
+++ b/Makefile
@@ -62,6 +62,13 @@  pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) 		\
 PKG_CONFIG_SOURCE_FILE = libtracefs.pc
 PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE))
 
+LIBTRACEEVENT_INCLUDES = $(shell $(PKG_CONFIG) --cflags libtraceevent)
+LIBTRACEEVENT_LIBS = $(shell $(PKG_CONFIG) --libs libtraceevent)
+
+ifeq ("$(LIBTRACEEVENT_INCLUDES)","")
+$(error libtraceevent.so not installed)
+endif
+
 ifeq ($(prefix),/usr/local)
 etcdir ?= /etc
 else
@@ -128,7 +135,7 @@  export prefix bindir src obj bdir
 LIBTRACEFS_STATIC = $(bdir)/libtracefs.a
 LIBTRACEFS_SHARED = $(bdir)/libtracefs.so.$(TRACEFS_VERSION)
 
-TRACE_LIBS = -L$(bdir) -ltracefs
+TRACE_LIBS = $(LIBTRACEEVENT_LIBS)
 
 export LIBS TRACE_LIBS
 export LIBTRACEFS_STATIC LIBTRACEFS_SHARED
@@ -155,7 +162,7 @@  export CFLAGS
 export INCLUDES
 
 # Required CFLAGS
-override CFLAGS += -D_GNU_SOURCE
+override CFLAGS += -D_GNU_SOURCE $(LIBTRACEEVENT_INCLUDES)
 
 # Append required CFLAGS
 override CFLAGS += $(INCLUDES)