Commit 0f0e1f44 authored by Guilherme Amadio's avatar Guilherme Amadio Committed by Namhyung Kim

perf build: Use pkg-config for feature check for libtrace{event,fs}

Needed to add required include directories for the feature detection
to succeed. The header tracefs.h is installed either into the include
directory /usr/include/tracefs/tracefs.h when using the Makefile, or
into /usr/include/libtracefs/tracefs.h when using meson to build
libtracefs. The header tracefs.h uses #include <event-parse.h> from
libtraceevent, so pkg-config needs to pick the correct include directory
for libtracefs and add the one for libtraceevent to succeed.

Note that in baa2ca59 the variable
LIBTRACEEVENT_DIR was introduced, and now the method to compile against
non-standard locations requires PKG_CONFIG_PATH to be set instead, which
works for both libtraceevent and libtracefs.
Signed-off-by: default avatarGuilherme Amadio <amadio@gentoo.org>
Reviewed-by: default avatarLeo Yan <leo.yan@arm.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240606153625.2255470-2-amadio@gentoo.org
parent 5518063f
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <tracefs/tracefs.h> #include <tracefs.h>
int main(void) int main(void)
{ {
......
...@@ -183,14 +183,12 @@ FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS) ...@@ -183,14 +183,12 @@ FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS) FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
# for linking with debug library, run like: # for linking with debug library, run like:
# make DEBUG=1 LIBTRACEEVENT_DIR=/opt/libtraceevent/ # make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
TRACEEVENTLIBS := -ltraceevent FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent)
ifdef LIBTRACEEVENT_DIR FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent)
LIBTRACEEVENT_CFLAGS := -I$(LIBTRACEEVENT_DIR)/include
LIBTRACEEVENT_LDFLAGS := -L$(LIBTRACEEVENT_DIR)/lib FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
endif FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
FEATURE_CHECK_CFLAGS-libtraceevent := $(LIBTRACEEVENT_CFLAGS)
FEATURE_CHECK_LDFLAGS-libtraceevent := $(LIBTRACEEVENT_LDFLAGS) $(TRACEEVENTLIBS)
FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
# include ARCH specific config # include ARCH specific config
...@@ -1178,10 +1176,10 @@ endif ...@@ -1178,10 +1176,10 @@ endif
ifneq ($(NO_LIBTRACEEVENT),1) ifneq ($(NO_LIBTRACEEVENT),1)
$(call feature_check,libtraceevent) $(call feature_check,libtraceevent)
ifeq ($(feature-libtraceevent), 1) ifeq ($(feature-libtraceevent), 1)
CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS) CFLAGS += -DHAVE_LIBTRACEEVENT
LDFLAGS += $(LIBTRACEEVENT_LDFLAGS) LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent)
EXTLIBS += ${TRACEEVENTLIBS} EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent)
LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent) LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION))) LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION))) LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION))) LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
...@@ -1194,7 +1192,9 @@ ifneq ($(NO_LIBTRACEEVENT),1) ...@@ -1194,7 +1192,9 @@ ifneq ($(NO_LIBTRACEEVENT),1)
$(call feature_check,libtracefs) $(call feature_check,libtracefs)
ifeq ($(feature-libtracefs), 1) ifeq ($(feature-libtracefs), 1)
EXTLIBS += -ltracefs CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs)
LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)
EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtracefs)
LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs) LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs)
LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION))) LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION)))
LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION))) LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION)))
...@@ -1315,7 +1315,6 @@ ifeq ($(VF),1) ...@@ -1315,7 +1315,6 @@ ifeq ($(VF),1)
$(call print_var,LIBUNWIND_DIR) $(call print_var,LIBUNWIND_DIR)
$(call print_var,LIBDW_DIR) $(call print_var,LIBDW_DIR)
$(call print_var,JDIR) $(call print_var,JDIR)
$(call print_var,LIBTRACEEVENT_DIR)
ifeq ($(dwarf-post-unwind),1) ifeq ($(dwarf-post-unwind),1)
$(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG)) $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment