Skip to content

Commit 8f61e98

Browse files
amadionamhyung
authored andcommitted
tools: Make pkg-config dependency checks usable by other tools
Other tools, in tools/verification and tools/tracing, make use of libtraceevent and libtracefs as dependencies. This allows setting up the feature check flags for them as well. Signed-off-by: Guilherme Amadio <[email protected]> Tested-by: Thorsten Leemhuis <[email protected]> Tested-by: Leo Yan <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 37ac347 commit 8f61e98

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

tools/build/Makefile.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ FEATURE_DISPLAY ?= \
149149
#
150150
FEATURE_GROUP_MEMBERS-libbfd = libbfd-liberty libbfd-liberty-z
151151

152+
#
153+
# Declare list of feature dependency packages that provide pkg-config files.
154+
#
155+
FEATURE_PKG_CONFIG ?= \
156+
libtraceevent \
157+
libtracefs
158+
159+
feature_pkg_config = $(eval $(feature_pkg_config_code))
160+
define feature_pkg_config_code
161+
FEATURE_CHECK_CFLAGS-$(1) := $(shell $(PKG_CONFIG) --cflags $(1) 2>/dev/null)
162+
FEATURE_CHECK_LDFLAGS-$(1) := $(shell $(PKG_CONFIG) --libs $(1) 2>/dev/null)
163+
endef
164+
165+
# Set FEATURE_CHECK_(C|LD)FLAGS-$(package) for packages using pkg-config.
166+
ifneq ($(PKG_CONFIG),)
167+
$(foreach package,$(FEATURE_PKG_CONFIG),$(call feature_pkg_config,$(package)))
168+
endif
169+
152170
# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
153171
# If in the future we need per-feature checks/flags for features not
154172
# mentioned in this list we need to refactor this ;-).

tools/perf/Makefile.config

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,15 @@ endif
182182
FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
183183
FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
184184

185+
# for linking with debug library, run like:
186+
# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
187+
185188
ifneq ($(NO_LIBTRACEEVENT),1)
186189
ifeq ($(call get-executable,$(PKG_CONFIG)),)
187190
$(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)
188191
endif
189192
endif
190193

191-
# for linking with debug library, run like:
192-
# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
193-
FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null)
194-
FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent 2>/dev/null)
195-
196-
FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs 2>/dev/null)
197-
FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs 2>/dev/null)
198-
199194
FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
200195
# include ARCH specific config
201196
-include $(src-perf)/arch/$(SRCARCH)/Makefile

0 commit comments

Comments
 (0)