| 1 |
# SPDX-License-Identifier: GPL-2.0-only |
| 2 |
|
| 3 |
include $(srctree)/tools/scripts/utilities.mak |
| 4 |
|
| 5 |
STOP_ERROR := |
| 6 |
|
| 7 |
LIBTRACEEVENT_MIN_VERSION = 1.5 |
| 8 |
LIBTRACEFS_MIN_VERSION = 1.6 |
| 9 |
|
| 10 |
ifndef ($(NO_LIBTRACEEVENT),1) |
| 11 |
ifeq ($(call get-executable,$(PKG_CONFIG)),) |
| 12 |
$(error Error: $(PKG_CONFIG) needed by libtraceevent/libtracefs is missing on this system, please install it) |
| 13 |
endif |
| 14 |
endif |
| 15 |
|
| 16 |
define lib_setup |
| 17 |
$(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)")) |
| 18 |
$(eval LDFLAGS += $(shell sh -c "$(PKG_CONFIG) --libs-only-L lib$(1)")) |
| 19 |
$(eval EXTLIBS += $(shell sh -c "$(PKG_CONFIG) --libs-only-l lib$(1)")) |
| 20 |
endef |
| 21 |
|
| 22 |
$(call feature_check,libtraceevent) |
| 23 |
ifeq ($(feature-libtraceevent), 1) |
| 24 |
$(call detected,CONFIG_LIBTRACEEVENT) |
| 25 |
|
| 26 |
TEST = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEEVENT_MIN_VERSION) libtraceevent > /dev/null 2>&1 && echo y || echo n") |
| 27 |
ifeq ($(TEST),n) |
| 28 |
$(info libtraceevent version is too low, it must be at least $(LIBTRACEEVENT_MIN_VERSION)) |
| 29 |
STOP_ERROR := 1 |
| 30 |
endif |
| 31 |
|
| 32 |
$(call lib_setup,traceevent) |
| 33 |
else |
| 34 |
STOP_ERROR := 1 |
| 35 |
$(info libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel) |
| 36 |
endif |
| 37 |
|
| 38 |
$(call feature_check,libtracefs) |
| 39 |
ifeq ($(feature-libtracefs), 1) |
| 40 |
$(call detected,CONFIG_LIBTRACEFS) |
| 41 |
|
| 42 |
TEST = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEFS_MIN_VERSION) libtracefs > /dev/null 2>&1 && echo y || echo n") |
| 43 |
ifeq ($(TEST),n) |
| 44 |
$(info libtracefs version is too low, it must be at least $(LIBTRACEFS_MIN_VERSION)) |
| 45 |
STOP_ERROR := 1 |
| 46 |
endif |
| 47 |
|
| 48 |
$(call lib_setup,tracefs) |
| 49 |
else |
| 50 |
STOP_ERROR := 1 |
| 51 |
$(info libtracefs is missing. Please install libtracefs-dev/libtracefs-devel) |
| 52 |
endif |
| 53 |
|
| 54 |
$(call feature_check,libcpupower) |
| 55 |
ifeq ($(feature-libcpupower), 1) |
| 56 |
$(call detected,CONFIG_LIBCPUPOWER) |
| 57 |
CFLAGS += -DHAVE_LIBCPUPOWER_SUPPORT |
| 58 |
EXTLIBS += -lcpupower |
| 59 |
else |
| 60 |
$(info libcpupower is missing, building without --deepest-idle-state support.) |
| 61 |
$(info Please install libcpupower-dev/kernel-tools-libs-devel) |
| 62 |
endif |
| 63 |
|
| 64 |
ifndef BUILD_BPF_SKEL |
| 65 |
# BPF skeletons are used to implement improved sample collection, enable |
| 66 |
# them by default. |
| 67 |
BUILD_BPF_SKEL := 1 |
| 68 |
endif |
| 69 |
|
| 70 |
ifeq ($(BUILD_BPF_SKEL),0) |
| 71 |
$(info BPF skeleton support disabled, building without BPF skeleton support.) |
| 72 |
endif |
| 73 |
|
| 74 |
$(call feature_check,libbpf) |
| 75 |
ifeq ($(feature-libbpf), 1) |
| 76 |
$(call detected,CONFIG_LIBBPF) |
| 77 |
else |
| 78 |
$(info libbpf is missing, building without BPF skeleton support.) |
| 79 |
$(info Please install libbpf-dev/libbpf-devel) |
| 80 |
BUILD_BPF_SKEL := 0 |
| 81 |
endif |
| 82 |
|
| 83 |
$(call feature_check,clang-bpf-co-re) |
| 84 |
ifeq ($(feature-clang-bpf-co-re), 1) |
| 85 |
$(call detected,CONFIG_CLANG_BPF_CO_RE) |
| 86 |
else |
| 87 |
$(info clang is missing or does not support BPF CO-RE, building without BPF skeleton support.) |
| 88 |
$(info Please install clang) |
| 89 |
BUILD_BPF_SKEL := 0 |
| 90 |
endif |
| 91 |
|
| 92 |
$(call feature_check,bpftool-skeletons) |
| 93 |
ifeq ($(feature-bpftool-skeletons), 1) |
| 94 |
$(call detected,CONFIG_BPFTOOL_SKELETONS) |
| 95 |
else |
| 96 |
$(info bpftool is missing or not supporting skeletons, building without BPF skeleton support.) |
| 97 |
$(info Please install bpftool) |
| 98 |
BUILD_BPF_SKEL := 0 |
| 99 |
endif |
| 100 |
|
| 101 |
ifeq ($(BUILD_BPF_SKEL),1) |
| 102 |
CFLAGS += -DHAVE_BPF_SKEL |
| 103 |
EXTLIBS += -lbpf |
| 104 |
endif |
| 105 |
|
| 106 |
ifeq ($(STOP_ERROR),1) |
| 107 |
$(error Please, check the errors above.) |
| 108 |
endif |