1# SPDX-License-Identifier: GPL-2.0-only 2 3include $(srctree)/tools/scripts/utilities.mak 4 5STOP_ERROR := 6 7LIBTRACEEVENT_MIN_VERSION = 1.5 8LIBTRACEFS_MIN_VERSION = 1.6 9 10ifndef ($(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 14endif 15 16define 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)")) 20endef 21 22$(call feature_check,libtraceevent) 23ifeq ($(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) 33else 34 STOP_ERROR := 1 35 $(info libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel) 36endif 37 38$(call feature_check,libtracefs) 39ifeq ($(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) 49else 50 STOP_ERROR := 1 51 $(info libtracefs is missing. Please install libtracefs-dev/libtracefs-devel) 52endif 53 54$(call feature_check,libcpupower) 55ifeq ($(feature-libcpupower), 1) 56 $(call detected,CONFIG_LIBCPUPOWER) 57 CFLAGS += -DHAVE_LIBCPUPOWER_SUPPORT 58 EXTLIBS += -lcpupower 59else 60 $(info libcpupower is missing, building without --deepest-idle-state support.) 61 $(info Please install libcpupower-dev/kernel-tools-libs-devel) 62endif 63 64ifndef BUILD_BPF_SKEL 65 # BPF skeletons are used to implement improved sample collection, enable 66 # them by default. 67 BUILD_BPF_SKEL := 1 68endif 69 70ifeq ($(BUILD_BPF_SKEL),0) 71 $(info BPF skeleton support disabled, building without BPF skeleton support.) 72endif 73 74$(call feature_check,libbpf) 75ifeq ($(feature-libbpf), 1) 76 $(call detected,CONFIG_LIBBPF) 77else 78 $(info libbpf is missing, building without BPF skeleton support.) 79 $(info Please install libbpf-dev/libbpf-devel) 80 BUILD_BPF_SKEL := 0 81endif 82 83$(call feature_check,clang-bpf-co-re) 84ifeq ($(feature-clang-bpf-co-re), 1) 85 $(call detected,CONFIG_CLANG_BPF_CO_RE) 86else 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 90endif 91 92$(call feature_check,bpftool-skeletons) 93ifeq ($(feature-bpftool-skeletons), 1) 94 $(call detected,CONFIG_BPFTOOL_SKELETONS) 95else 96 $(info bpftool is missing or not supporting skeletons, building without BPF skeleton support.) 97 $(info Please install bpftool) 98 BUILD_BPF_SKEL := 0 99endif 100 101ifeq ($(BUILD_BPF_SKEL),1) 102 CFLAGS += -DHAVE_BPF_SKEL 103 EXTLIBS += -lbpf 104endif 105 106ifeq ($(STOP_ERROR),1) 107 $(error Please, check the errors above.) 108endif 109