| 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 | $(call feature_check,libcheck) |
| 65 | ifeq ($(feature-libcheck), 1) |
| 66 | $(call detected,CONFIG_LIBCHECK) |
| 67 | else |
| 68 | $(info libcheck is missing, building without unit tests support.) |
| 69 | $(info Please install check-devel/check) |
| 70 | endif |
| 71 | |
| 72 | ifndef BUILD_BPF_SKEL |
| 73 | # BPF skeletons are used to implement improved sample collection, enable |
| 74 | # them by default. |
| 75 | BUILD_BPF_SKEL := 1 |
| 76 | endif |
| 77 | |
| 78 | ifeq ($(BUILD_BPF_SKEL),0) |
| 79 | $(info BPF skeleton support disabled, building without BPF skeleton support.) |
| 80 | endif |
| 81 | |
| 82 | $(call feature_check,libbpf) |
| 83 | ifeq ($(feature-libbpf), 1) |
| 84 | $(call detected,CONFIG_LIBBPF) |
| 85 | else |
| 86 | $(info libbpf is missing, building without BPF skeleton support.) |
| 87 | $(info Please install libbpf-dev/libbpf-devel) |
| 88 | BUILD_BPF_SKEL := 0 |
| 89 | endif |
| 90 | |
| 91 | $(call feature_check,clang-bpf-co-re) |
| 92 | ifeq ($(feature-clang-bpf-co-re), 1) |
| 93 | $(call detected,CONFIG_CLANG_BPF_CO_RE) |
| 94 | else |
| 95 | $(info clang is missing or does not support BPF CO-RE, building without BPF skeleton support.) |
| 96 | $(info Please install clang) |
| 97 | BUILD_BPF_SKEL := 0 |
| 98 | endif |
| 99 | |
| 100 | $(call feature_check,bpftool-skeletons) |
| 101 | ifeq ($(feature-bpftool-skeletons), 1) |
| 102 | $(call detected,CONFIG_BPFTOOL_SKELETONS) |
| 103 | else |
| 104 | $(info bpftool is missing or not supporting skeletons, building without BPF skeleton support.) |
| 105 | $(info Please install bpftool) |
| 106 | BUILD_BPF_SKEL := 0 |
| 107 | endif |
| 108 | |
| 109 | ifeq ($(BUILD_BPF_SKEL),1) |
| 110 | CFLAGS += -DHAVE_BPF_SKEL |
| 111 | EXTLIBS += -lbpf |
| 112 | endif |
| 113 | |
| 114 | ifeq ($(STOP_ERROR),1) |
| 115 | $(error Please, check the errors above.) |
| 116 | endif |