1 # SPDX-License-Identifier: GPL-2.0-only
4 src-perf := $(srctree)/tools/perf
12 obj-perf := $(abspath $(obj-perf))/
15 $(shell printf "" > $(OUTPUT).config-detected)
16 detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
17 detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
19 CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
20 HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
22 # Enabled Wthread-safety analysis for clang builds.
23 ifeq ($(CC_NO_CLANG), 0)
24 CFLAGS += -Wthread-safety
27 include $(srctree)/tools/scripts/Makefile.arch
29 $(call detected_var,SRCARCH)
31 ifneq ($(NO_SYSCALL_TABLE),1)
34 ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch))
38 ifneq ($(NO_SYSCALL_TABLE),1)
39 CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT
43 # Additional ARCH settings for ppc
44 ifeq ($(SRCARCH),powerpc)
45 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated
46 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
49 # Additional ARCH settings for x86
51 $(call detected,CONFIG_X86)
52 CFLAGS += -I$(OUTPUT)arch/x86/include/generated
53 ifeq (${IS_64_BIT}, 1)
54 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
55 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
56 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
57 $(call detected,CONFIG_X86_64)
59 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
64 LIBUNWIND_LIBS = -lunwind -lunwind-arm
67 ifeq ($(SRCARCH),arm64)
68 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
69 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
72 ifeq ($(SRCARCH),loongarch)
73 CFLAGS += -I$(OUTPUT)arch/loongarch/include/generated
74 LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64
78 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
82 CFLAGS += -I$(OUTPUT)arch/mips/include/generated
83 LIBUNWIND_LIBS = -lunwind -lunwind-mips
86 # So far there's only x86 and arm libdw unwind support merged in perf.
87 # Disable it on all other architectures in case libdw unwind
88 # support is detected in system. Add supported architectures
90 ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv loongarch))
91 NO_LIBDW_DWARF_UNWIND := 1
94 ifeq ($(LIBUNWIND_LIBS),)
98 # For linking with debug library, run like:
100 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
103 libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
104 define libunwind_arch_set_flags_code
105 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
106 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib
110 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
111 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
112 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 loongarch
113 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
116 # Set per-feature check compilation flags
117 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
118 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
119 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
120 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
122 FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm
123 FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
124 FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
125 FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
127 FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
130 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
132 OPENCSDLIBS := -lopencsd_c_api -lopencsd
133 ifeq ($(findstring -static,${LDFLAGS}),-static)
134 OPENCSDLIBS += -lstdc++
137 LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
139 FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)
140 FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)
142 # for linking with debug library, run like:
143 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
145 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
146 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
149 ifeq ($(findstring -static,${LDFLAGS}),-static)
150 DWARFLIBS += -lelf -ldl -lz -llzma -lbz2 -lzstd
152 LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
153 LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
154 LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
156 # Elfutils merged libebl.a into libdw.a starting from version 0.177,
157 # Link libebl.a only if libdw is older than this version.
158 ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
162 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
163 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
165 # for linking with debug library, run like:
166 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
167 ifdef LIBBABELTRACE_DIR
168 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
169 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
171 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
172 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
174 # for linking with debug library, run like:
175 # make DEBUG=1 LIBCAPSTONE_DIR=/opt/capstone/
176 ifdef LIBCAPSTONE_DIR
177 LIBCAPSTONE_CFLAGS := -I$(LIBCAPSTONE_DIR)/include
178 LIBCAPSTONE_LDFLAGS := -L$(LIBCAPSTONE_DIR)/
180 FEATURE_CHECK_CFLAGS-libcapstone := $(LIBCAPSTONE_CFLAGS)
181 FEATURE_CHECK_LDFLAGS-libcapstone := $(LIBCAPSTONE_LDFLAGS) -lcapstone
184 LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib
185 LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
187 FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
188 FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
190 # for linking with debug library, run like:
191 # make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
193 ifneq ($(NO_LIBTRACEEVENT),1)
194 ifeq ($(call get-executable,$(PKG_CONFIG)),)
195 $(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)
199 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
200 # include ARCH specific config
201 -include $(src-perf)/arch/$(SRCARCH)/Makefile
203 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
204 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
207 include $(srctree)/tools/scripts/utilities.mak
209 ifeq ($(call get-executable,$(FLEX)),)
210 $(error Error: $(FLEX) is missing on this system, please install it)
213 ifeq ($(call get-executable,$(BISON)),)
214 $(error Error: $(BISON) is missing on this system, please install it)
218 ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1)
219 BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)=
223 # Treat warnings as errors unless directed not to
225 CORE_CFLAGS += -Werror
227 HOSTCFLAGS += -Werror
235 CORE_CFLAGS += -DNDEBUG=1
243 PARSER_DEBUG_BISON := -t
244 PARSER_DEBUG_FLEX := -d
245 CFLAGS += -DPARSER_DEBUG
246 $(call detected_var,PARSER_DEBUG_BISON)
247 $(call detected_var,PARSER_DEBUG_FLEX)
255 # Try different combinations to accommodate systems that only have
256 # python[2][3]-config in weird combinations in the following order of
257 # priority from lowest to highest:
258 # * python2-config as per pep-0394.
261 # * $(PYTHON)-config (If PYTHON is user supplied but PYTHON_CONFIG isn't)
263 PYTHON_AUTO := python-config
264 PYTHON_AUTO := $(if $(call get-executable,python2-config),python2-config,$(PYTHON_AUTO))
265 PYTHON_AUTO := $(if $(call get-executable,python-config),python-config,$(PYTHON_AUTO))
266 PYTHON_AUTO := $(if $(call get-executable,python3-config),python3-config,$(PYTHON_AUTO))
268 # If PYTHON is defined but PYTHON_CONFIG isn't, then take $(PYTHON)-config as if it was the user
269 # supplied value for PYTHON_CONFIG. Because it's "user supplied", error out if it doesn't exist.
272 PYTHON_CONFIG_AUTO := $(call get-executable,$(PYTHON)-config)
273 PYTHON_CONFIG := $(if $(PYTHON_CONFIG_AUTO),$(PYTHON_CONFIG_AUTO),\
274 $(call $(error $(PYTHON)-config not found)))
278 # Select either auto detected python and python-config or use user supplied values if they are
279 # defined. get-executable-or-default fails with an error if the first argument is supplied but
281 override PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO))
282 override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_CONFIG)))
284 grep-libs = $(filter -l%,$(1))
285 strip-libs = $(filter-out -l%,$(1))
287 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
289 # Python 3.8 changed the output of `python-config --ldflags` to not include the
290 # '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
291 # libpython fails if that flag is not included in LDFLAGS
292 ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
293 PYTHON_CONFIG_LDFLAGS := --ldflags --embed
295 PYTHON_CONFIG_LDFLAGS := --ldflags
299 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
300 # Update the python flags for cross compilation
302 PYTHON_NATIVE := $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/\(-L.*\/\)\(.*-linux-gnu\).*/\2/')
303 PYTHON_EMBED_LDOPTS := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EMBED_LDOPTS))
305 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
306 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
307 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
308 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
309 ifeq ($(CC_NO_CLANG), 0)
310 PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS))
314 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
315 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
317 FEATURE_CHECK_LDFLAGS-libaio = -lrt
319 FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
320 FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl
322 CORE_CFLAGS += -fno-omit-frame-pointer
324 CORE_CFLAGS += -Wextra
325 CORE_CFLAGS += -std=gnu11
327 CXXFLAGS += -std=gnu++17 -fno-exceptions -fno-rtti
330 CXXFLAGS += -fno-omit-frame-pointer
333 HOSTCFLAGS += -Wextra
335 # Enforce a non-executable stack, as we may regress (again) in the future by
336 # adding assembler files missing the .GNU-stack linker note.
337 LDFLAGS += -Wl,-z,noexecstack
339 EXTLIBS = -lpthread -lrt -lm -ldl
342 CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
343 EXTLIBS += -ltcmalloc
346 ifeq ($(FEATURES_DUMP),)
347 # We will display at the end of this Makefile.config, using $(call feature_display_entries)
348 # As we may retry some feature detection here, see the disassembler-four-args case, for instance
349 FEATURE_DISPLAY_DEFERRED := 1
350 include $(srctree)/tools/build/Makefile.feature
352 include $(FEATURES_DUMP)
355 ifeq ($(feature-stackprotector-all), 1)
356 CORE_CFLAGS += -fstack-protector-all
360 ifeq ($(feature-fortify-source), 1)
361 CORE_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
365 INC_FLAGS += -I$(src-perf)/util/include
366 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
367 INC_FLAGS += -I$(srctree)/tools/include/
368 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
369 INC_FLAGS += -I$(srctree)/tools/include/uapi
370 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
371 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
373 # $(obj-perf) for generated common-cmds.h
374 # $(obj-perf)/util for generated bison/flex headers
376 INC_FLAGS += -I$(obj-perf)/util
377 INC_FLAGS += -I$(obj-perf)
380 INC_FLAGS += -I$(src-perf)/util
381 INC_FLAGS += -I$(src-perf)
383 CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
385 CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)
386 CXXFLAGS += $(INC_FLAGS)
388 LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)
390 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
391 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
394 ifeq ($(feature-pthread-barrier), 1)
395 CFLAGS += -DHAVE_PTHREAD_BARRIER
399 $(call feature_check,bionic)
400 ifeq ($(feature-bionic), 1)
402 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
403 CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
404 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
405 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
409 ifeq ($(feature-eventfd), 1)
410 CFLAGS += -DHAVE_EVENTFD_SUPPORT
413 ifeq ($(feature-get_current_dir_name), 1)
414 CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
417 ifeq ($(feature-gettid), 1)
418 CFLAGS += -DHAVE_GETTID
421 ifeq ($(feature-file-handle), 1)
422 CFLAGS += -DHAVE_FILE_HANDLE
428 NO_LIBDW_DWARF_UNWIND := 1
432 ifeq ($(feature-libelf), 0)
433 ifeq ($(feature-glibc), 1)
439 ifeq ($(LIBC_SUPPORT),1)
440 $(error ERROR: No libelf found. Disables 'probe' tool, jvmti and BPF support. Please install libelf-dev, libelf-devel, elfutils-libelf-devel or build with NO_LIBELF=1.)
442 ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)
443 ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)
444 $(error No libasan found, please install libasan)
448 ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),)
449 ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0)
450 $(error No libubsan found, please install libubsan)
454 ifneq ($(filter s% -static%,$(LDFLAGS),),)
455 $(error No static glibc found, please install glibc-static)
457 $(error No gnu/libc-version.h found, please install glibc-dev[el])
461 ifndef NO_LIBDW_DWARF_UNWIND
462 ifneq ($(feature-libdw-dwarf-unwind),1)
463 NO_LIBDW_DWARF_UNWIND := 1
464 $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR)
467 ifneq ($(feature-dwarf), 1)
469 $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev)
473 ifneq ($(feature-dwarf_getlocations), 1)
474 $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157)
476 CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
477 endif # dwarf_getlocations
478 ifneq ($(feature-dwarf_getcfi), 1)
479 $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.142)
481 CFLAGS += -DHAVE_DWARF_CFI_SUPPORT
483 endif # Dwarf support
484 endif # libelf support
487 ifeq ($(feature-libaio), 1)
489 CFLAGS += -DHAVE_AIO_SUPPORT
494 NO_LIBDW_DWARF_UNWIND := 1
497 ifeq ($(feature-scandirat), 1)
498 # Ignore having scandirat with memory sanitizer that lacks an interceptor.
499 ifeq ($(filter s% -fsanitize=memory%,$(EXTRA_CFLAGS),),)
500 CFLAGS += -DHAVE_SCANDIRAT_SUPPORT
504 ifeq ($(feature-sched_getcpu), 1)
505 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
508 ifeq ($(feature-setns), 1)
509 CFLAGS += -DHAVE_SETNS_SUPPORT
510 $(call detected,CONFIG_SETNS)
514 $(call feature_check,libopencsd)
515 ifeq ($(feature-libopencsd), 1)
516 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
517 ifeq ($(feature-reallocarray), 0)
518 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
520 LDFLAGS += $(LIBOPENCSD_LDFLAGS)
521 EXTLIBS += $(OPENCSDLIBS)
522 $(call detected,CONFIG_LIBOPENCSD)
524 CFLAGS += -DCS_DEBUG_RAW
525 ifeq (${CSTRACE_RAW}, packed)
526 CFLAGS += -DCS_RAW_PACKED
530 $(error Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1)
535 ifeq ($(feature-zlib), 1)
536 CFLAGS += -DHAVE_ZLIB_SUPPORT
538 $(call detected,CONFIG_ZLIB)
545 CFLAGS += -DHAVE_LIBELF_SUPPORT
547 $(call detected,CONFIG_LIBELF)
549 ifeq ($(feature-libelf-getphdrnum), 1)
550 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
553 ifeq ($(feature-libelf-gelf_getnote), 1)
554 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
556 $(warning gelf_getnote() not found on libelf, SDT support disabled)
559 ifeq ($(feature-libelf-getshdrstrndx), 1)
560 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
563 ifndef NO_LIBDEBUGINFOD
564 $(call feature_check,libdebuginfod)
565 ifeq ($(feature-libdebuginfod), 1)
566 CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT
567 EXTLIBS += -ldebuginfod
572 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
573 $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled)
576 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
577 LDFLAGS += $(LIBDW_LDFLAGS)
578 EXTLIBS += ${DWARFLIBS}
579 $(call detected,CONFIG_DWARF)
580 endif # PERF_HAVE_DWARF_REGS
584 ifeq ($(feature-bpf), 1)
585 # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status
586 $(call feature_check,libbpf)
589 ifeq ($(feature-libbpf), 1)
591 CFLAGS += -DHAVE_LIBBPF_SUPPORT
592 $(call detected,CONFIG_LIBBPF)
593 $(call detected,CONFIG_LIBBPF_DYNAMIC)
595 $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel)
599 $(warning Warning: Statically building libbpf not possible as zlib is missing)
602 # Libbpf will be built as a static library from tools/lib/bpf.
604 $(call detected,CONFIG_LIBBPF)
605 CFLAGS += -DHAVE_LIBBPF_SUPPORT
613 ifneq ($(feature-sdt), 1)
614 $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev)
617 CFLAGS += -DHAVE_SDT_EVENT
618 $(call detected,CONFIG_SDT_EVENT)
622 ifdef PERF_HAVE_JITDUMP
624 $(call detected,CONFIG_JITDUMP)
625 CFLAGS += -DHAVE_JITDUMP
629 ifeq ($(SRCARCH),powerpc)
631 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
638 $(call feature_check,libunwind-x86)
639 ifeq ($(feature-libunwind-x86), 1)
640 $(call detected,CONFIG_LIBUNWIND_X86)
641 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
642 LDFLAGS += -lunwind-x86
643 EXTLIBS_LIBUNWIND += -lunwind-x86
647 $(call feature_check,libunwind-aarch64)
648 ifeq ($(feature-libunwind-aarch64), 1)
649 $(call detected,CONFIG_LIBUNWIND_AARCH64)
650 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
651 LDFLAGS += -lunwind-aarch64
652 EXTLIBS_LIBUNWIND += -lunwind-aarch64
654 $(call feature_check,libunwind-debug-frame-aarch64)
655 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
656 $(warning No debug_frame support found in libunwind-aarch64)
657 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
661 ifneq ($(feature-libunwind), 1)
662 $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR)
663 NO_LOCAL_LIBUNWIND := 1
666 $(call detected,CONFIG_LOCAL_LIBUNWIND)
669 ifneq ($(have_libunwind), 1)
673 NO_LOCAL_LIBUNWIND := 1
677 ifneq ($(feature-bpf), 1)
678 $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
683 ifndef BUILD_BPF_SKEL
684 # BPF skeletons control a large number of perf features, by default
689 ifeq ($(BUILD_BPF_SKEL),1)
690 ifeq ($(filter -DHAVE_LIBELF_SUPPORT, $(CFLAGS)),)
691 $(warning Warning: Disabled BPF skeletons as libelf is required by bpftool)
693 else ifeq ($(filter -DHAVE_ZLIB_SUPPORT, $(CFLAGS)),)
694 $(warning Warning: Disabled BPF skeletons as zlib is required by bpftool)
696 else ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),)
697 $(warning Warning: Disabled BPF skeletons as libbpf is required)
699 else ifeq ($(call get-executable,$(CLANG)),)
700 $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) is missing)
703 CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')
704 ifeq ($(call version-lt3,$(CLANG_VERSION),16.0.6),1)
705 $(warning Warning: Disabled BPF skeletons as at least $(CLANG) version 16.0.6 is reported to be a working setup with the current of BPF based perf features)
709 ifeq ($(BUILD_BPF_SKEL),1)
710 $(call feature_check,clang-bpf-co-re)
711 ifeq ($(feature-clang-bpf-co-re), 0)
712 $(warning Warning: Disabled BPF skeletons as clang is too old)
716 ifeq ($(BUILD_BPF_SKEL),1)
717 $(call detected,CONFIG_PERF_BPF_SKEL)
718 CFLAGS += -DHAVE_BPF_SKEL
723 VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h
726 dwarf-post-unwind := 1
727 dwarf-post-unwind-text := BUG
729 # setup DWARF post unwinder
731 ifdef NO_LIBDW_DWARF_UNWIND
732 $(warning Disabling post unwind, no support found.)
733 dwarf-post-unwind := 0
735 dwarf-post-unwind-text := libdw
736 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
739 dwarf-post-unwind-text := libunwind
740 $(call detected,CONFIG_LIBUNWIND)
741 # Enable libunwind support by default.
742 ifndef NO_LIBDW_DWARF_UNWIND
743 NO_LIBDW_DWARF_UNWIND := 1
747 ifeq ($(dwarf-post-unwind),1)
748 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
749 $(call detected,CONFIG_DWARF_UNWIND)
754 ifndef NO_LOCAL_LIBUNWIND
755 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
756 $(call feature_check,libunwind-debug-frame)
757 ifneq ($(feature-libunwind-debug-frame), 1)
758 $(warning No debug_frame support found in libunwind)
759 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
762 # non-ARM has no dwarf_find_debug_frame() function:
763 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
765 EXTLIBS += $(LIBUNWIND_LIBS)
766 LDFLAGS += $(LIBUNWIND_LIBS)
768 ifeq ($(findstring -static,${LDFLAGS}),-static)
769 # gcc -static links libgcc_eh which contans piece of libunwind
770 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
774 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
775 CFLAGS += $(LIBUNWIND_CFLAGS)
776 LDFLAGS += $(LIBUNWIND_LDFLAGS)
777 EXTLIBS += $(EXTLIBS_LIBUNWIND)
780 ifneq ($(NO_LIBTRACEEVENT),1)
781 ifeq ($(NO_SYSCALL_TABLE),0)
782 $(call detected,CONFIG_TRACE)
785 $(call feature_check,libaudit)
786 ifneq ($(feature-libaudit), 1)
787 $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev)
790 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
792 $(call detected,CONFIG_TRACE)
799 ifneq ($(feature-libcrypto), 1)
800 $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev)
803 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
805 $(call detected,CONFIG_CRYPTO)
810 ifneq ($(feature-libslang), 1)
811 ifneq ($(feature-libslang-include-subdir), 1)
812 $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev)
815 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR
819 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
820 CFLAGS += -DHAVE_SLANG_SUPPORT
822 $(call detected,CONFIG_SLANG)
827 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
828 $(call feature_check,gtk2)
829 ifneq ($(feature-gtk2), 1)
830 $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev)
833 $(call feature_check,gtk2-infobar)
834 ifeq ($(feature-gtk2-infobar), 1)
835 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
837 CFLAGS += -DHAVE_GTK2_SUPPORT
838 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
839 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
845 CFLAGS += -DNO_LIBPERL
847 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
848 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
849 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
850 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
851 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
852 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
853 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
854 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
856 ifneq ($(feature-libperl), 1)
857 CFLAGS += -DNO_LIBPERL
859 $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev)
861 LDFLAGS += $(PERL_EMBED_LDFLAGS)
862 EXTLIBS += $(PERL_EMBED_LIBADD)
863 CFLAGS += -DHAVE_LIBPERL_SUPPORT
864 ifeq ($(CC_NO_CLANG), 0)
865 CFLAGS += -Wno-compound-token-split-by-macro
867 $(call detected,CONFIG_LIBPERL)
871 ifeq ($(feature-timerfd), 1)
872 CFLAGS += -DHAVE_TIMERFD_SUPPORT
874 $(warning No timerfd support. Disables 'perf kvm stat live')
877 disable-python = $(eval $(disable-python_code))
878 define disable-python_code
879 CFLAGS += -DNO_LIBPYTHON
884 PYTHON_EXTENSION_SUFFIX := '.so'
886 $(call disable-python,Python support disabled by user)
890 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
892 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
895 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
898 ifneq ($(feature-libpython), 1)
899 $(call disable-python,No 'Python.h' was found: disables Python support - please install python-devel/python-dev)
901 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
902 EXTLIBS += $(PYTHON_EMBED_LIBADD)
903 PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no")
904 ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes)
905 PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
907 PYTHON_EXTENSION_SUFFIX := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EXTENSION_SUFFIX))
909 LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX)
911 $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent)
913 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
914 $(call detected,CONFIG_LIBPYTHON)
915 ifeq ($(filter -fPIC,$(CFLAGS)),)
916 # Building a shared library requires position independent code.
925 ifneq ($(NO_JEVENTS),1)
926 ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),)
930 ifneq ($(NO_JEVENTS),1)
933 $(error ERROR: No python interpreter needed for jevents generation. Install python or build with NO_JEVENTS=1.)
935 # jevents.py uses f-strings present in Python 3.6 released in Dec. 2016.
936 JEVENTS_PYTHON_GOOD := $(shell $(PYTHON) -c 'import sys;print("1" if(sys.version_info.major >= 3 and sys.version_info.minor >= 6) else "0")' 2> /dev/null)
937 ifneq ($(JEVENTS_PYTHON_GOOD), 1)
938 $(error ERROR: Python interpreter needed for jevents generation too old (older than 3.6). Install a newer python or build with NO_JEVENTS=1.)
943 ifdef BUILD_NONDISTRO
944 ifeq ($(feature-libbfd), 1)
945 EXTLIBS += -lbfd -lopcodes
947 # we are on a system that requires -liberty and (maybe) -lz
948 # to link against -lbfd; test each case individually here
950 # call all detections now so we get correct
951 # status in VF output
952 $(call feature_check,libbfd-liberty)
953 $(call feature_check,libbfd-liberty-z)
955 ifeq ($(feature-libbfd-liberty), 1)
956 EXTLIBS += -lbfd -lopcodes -liberty
957 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
958 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl
960 ifeq ($(feature-libbfd-liberty-z), 1)
961 EXTLIBS += -lbfd -lopcodes -liberty -lz
962 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
963 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl
966 $(call feature_check,disassembler-four-args)
967 $(call feature_check,disassembler-init-styled)
970 CFLAGS += -DHAVE_LIBBFD_SUPPORT
971 CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
972 ifeq ($(feature-libbfd-buildid), 1)
973 CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
975 $(warning Old version of libbfd/binutils things like PE executable profiling will not be available)
980 $(call feature_check,llvm-perf)
981 ifeq ($(feature-llvm-perf), 1)
982 CFLAGS += -DHAVE_LIBLLVM_SUPPORT
983 CFLAGS += $(shell $(LLVM_CONFIG) --cflags)
984 CXXFLAGS += -DHAVE_LIBLLVM_SUPPORT
985 CXXFLAGS += $(shell $(LLVM_CONFIG) --cxxflags)
986 LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)
987 EXTLIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)
989 $(call detected,CONFIG_LIBLLVM)
991 $(warning No libllvm 13+ found, slower source file resolution, please install llvm-devel/llvm-dev)
997 $(call feature_check,cxa-demangle)
998 ifeq ($(feature-cxa-demangle), 1)
1000 CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
1001 CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
1002 $(call detected,CONFIG_CXX_DEMANGLE)
1004 ifdef BUILD_NONDISTRO
1005 ifeq ($(filter -liberty,$(EXTLIBS)),)
1006 $(call feature_check,cplus-demangle)
1007 ifeq ($(feature-cplus-demangle), 1)
1011 ifneq ($(filter -liberty,$(EXTLIBS)),)
1012 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
1013 CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
1019 ifeq ($(feature-lzma), 1)
1020 CFLAGS += -DHAVE_LZMA_SUPPORT
1022 $(call detected,CONFIG_LZMA)
1024 $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev)
1030 ifeq ($(feature-libzstd), 1)
1031 CFLAGS += -DHAVE_ZSTD_SUPPORT
1032 CFLAGS += $(LIBZSTD_CFLAGS)
1033 LDFLAGS += $(LIBZSTD_LDFLAGS)
1035 $(call detected,CONFIG_ZSTD)
1037 $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR)
1043 ifeq ($(feature-backtrace), 1)
1044 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
1049 ifeq ($(feature-libnuma), 0)
1050 $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev)
1053 ifeq ($(feature-numa_num_possible_cpus), 0)
1054 $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8)
1057 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
1059 $(call detected,CONFIG_NUMA)
1064 ifdef HAVE_KVM_STAT_SUPPORT
1065 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
1068 ifeq ($(feature-disassembler-four-args), 1)
1069 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
1072 ifeq ($(feature-disassembler-init-styled), 1)
1073 CFLAGS += -DDISASM_INIT_STYLED
1076 ifeq (${IS_64_BIT}, 1)
1077 ifndef NO_PERF_READ_VDSO32
1078 $(call feature_check,compile-32)
1079 ifeq ($(feature-compile-32), 1)
1080 CFLAGS += -DHAVE_PERF_READ_VDSO32
1082 NO_PERF_READ_VDSO32 := 1
1085 ifneq ($(SRCARCH), x86)
1086 NO_PERF_READ_VDSOX32 := 1
1088 ifndef NO_PERF_READ_VDSOX32
1089 $(call feature_check,compile-x32)
1090 ifeq ($(feature-compile-x32), 1)
1091 CFLAGS += -DHAVE_PERF_READ_VDSOX32
1093 NO_PERF_READ_VDSOX32 := 1
1097 NO_PERF_READ_VDSO32 := 1
1098 NO_PERF_READ_VDSOX32 := 1
1101 ifndef NO_LIBBABELTRACE
1102 $(call feature_check,libbabeltrace)
1103 ifeq ($(feature-libbabeltrace), 1)
1104 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
1105 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
1106 EXTLIBS += -lbabeltrace-ctf
1107 $(call detected,CONFIG_LIBBABELTRACE)
1109 $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev)
1114 $(call feature_check,libcapstone)
1115 ifeq ($(feature-libcapstone), 1)
1116 CFLAGS += -DHAVE_LIBCAPSTONE_SUPPORT $(LIBCAPSTONE_CFLAGS)
1117 LDFLAGS += $(LICAPSTONE_LDFLAGS)
1118 EXTLIBS += -lcapstone
1119 $(call detected,CONFIG_LIBCAPSTONE)
1121 msg := $(warning No libcapstone found, disables disasm engine support for 'perf script', please install libcapstone-dev/capstone-devel);
1126 ifeq ($(SRCARCH),x86)
1127 ifeq ($(feature-get_cpuid), 0)
1128 $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc)
1133 $(call detected,CONFIG_AUXTRACE)
1134 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
1135 ifeq ($(feature-reallocarray), 0)
1136 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
1142 $(call detected,CONFIG_EXTRA_TESTS)
1143 CFLAGS += -DHAVE_EXTRA_TESTS
1147 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
1148 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
1150 ifneq (,$(wildcard /usr/sbin/alternatives))
1151 JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g')
1155 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
1161 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
1162 $(call feature_check,jvmti)
1163 ifeq ($(feature-jvmti), 1)
1164 $(call detected_var,JDIR)
1165 ifndef NO_JVMTI_CMLR
1166 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
1167 $(call feature_check,jvmti-cmlr)
1168 ifeq ($(feature-jvmti-cmlr), 1)
1169 CFLAGS += -DHAVE_JVMTI_CMLR
1171 endif # NO_JVMTI_CMLR
1173 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
1179 $(call feature_check,libpfm4)
1180 ifeq ($(feature-libpfm4), 1)
1181 CFLAGS += -DHAVE_LIBPFM
1183 ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1
1184 $(call detected,CONFIG_LIBPFM4)
1186 $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev)
1190 # libtraceevent is a recommended dependency picked up from the system.
1191 ifneq ($(NO_LIBTRACEEVENT),1)
1192 $(call feature_check,libtraceevent)
1193 ifeq ($(feature-libtraceevent), 1)
1194 CFLAGS += -DHAVE_LIBTRACEEVENT
1195 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent)
1196 EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent)
1197 LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent).0.0
1198 LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1199 LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1200 LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1201 LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3))
1202 CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)
1203 $(call detected,CONFIG_LIBTRACEEVENT)
1205 $(error ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel and/or set LIBTRACEEVENT_DIR or build with NO_LIBTRACEEVENT=1)
1208 $(call feature_check,libtracefs)
1209 ifeq ($(feature-libtracefs), 1)
1210 CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs)
1211 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)
1212 EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtracefs)
1213 LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs).0.0
1214 LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION)))
1215 LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION)))
1216 LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION)))
1217 LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3))
1218 CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP)
1220 $(warning libtracefs is missing. Please install libtracefs-dev/libtracefs-devel)
1224 # Among the variables below, these:
1226 # libbpf_include_dir
1232 # ETC_PERFCONFIG (but not sysconfdir)
1233 # can be specified as a relative path some/where/else;
1234 # this is interpreted as relative to $(prefix) and "perf" at
1235 # runtime figures out where they are based on the path to the executable.
1236 # This can help installing the suite in a relocatable way.
1238 # Make the path relative to DESTDIR, not to prefix
1242 bindir_relative = bin
1243 bindir = $(abspath $(prefix)/$(bindir_relative))
1244 includedir_relative = include
1245 includedir = $(abspath $(prefix)/$(includedir_relative))
1247 infodir = share/info
1248 perfexecdir = libexec/perf-core
1249 # FIXME: system's libbpf header directory, where we expect to find bpf/bpf_helpers.h, for instance
1250 libbpf_include_dir = /usr/include
1251 perf_examples_dir = lib/perf/examples
1252 sharedir = $(prefix)/share
1253 template_dir = share/perf-core/templates
1254 STRACE_GROUPS_DIR = share/perf-core/strace/groups
1255 htmldir = share/doc/perf-doc
1256 tipdir = share/doc/perf-tip
1257 srcdir = $(srctree)/tools/perf
1258 ifeq ($(prefix),/usr)
1260 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
1262 sysconfdir = $(prefix)/etc
1263 ETC_PERFCONFIG = etc/perfconfig
1266 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
1272 libdir = $(prefix)/$(lib)
1274 # Shell quote (do not use $(call) to accommodate ancient setups);
1275 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
1276 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
1277 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1278 bindir_SQ = $(subst ','\'',$(bindir))
1279 includedir_SQ = $(subst ','\'',$(includedir))
1280 mandir_SQ = $(subst ','\'',$(mandir))
1281 infodir_SQ = $(subst ','\'',$(infodir))
1282 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
1283 libbpf_include_dir_SQ = $(subst ','\'',$(libbpf_include_dir))
1284 perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))
1285 template_dir_SQ = $(subst ','\'',$(template_dir))
1286 htmldir_SQ = $(subst ','\'',$(htmldir))
1287 tipdir_SQ = $(subst ','\'',$(tipdir))
1288 prefix_SQ = $(subst ','\'',$(prefix))
1289 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
1290 libdir_SQ = $(subst ','\'',$(libdir))
1291 srcdir_SQ = $(subst ','\'',$(srcdir))
1293 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
1294 perfexec_instdir = $(perfexecdir)
1295 perf_include_instdir = $(libbpf_include_dir)
1296 perf_examples_instdir = $(perf_examples_dir)
1297 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
1298 tip_instdir = $(tipdir)
1300 perfexec_instdir = $(prefix)/$(perfexecdir)
1301 perf_include_instdir = $(prefix)/$(libbpf_include_dir)
1302 perf_examples_instdir = $(prefix)/$(perf_examples_dir)
1303 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
1304 tip_instdir = $(prefix)/$(tipdir)
1306 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
1307 perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))
1308 perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))
1309 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
1310 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
1312 export perfexec_instdir_SQ
1314 print_var = $(eval $(print_var_code)) $(info $(MSG))
1315 define print_var_code
1316 MSG = $(shell printf '...%40s: %s' $(1) $($(1)))
1319 ifeq ($(feature_display),1)
1320 $(call feature_display_entries)
1324 # Display EXTRA features which are detected manualy
1325 # from here with feature_check call and thus cannot
1326 # be partof global state output.
1327 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),) $(info $(MSG)))
1328 $(call print_var,prefix)
1329 $(call print_var,bindir)
1330 $(call print_var,libdir)
1331 $(call print_var,sysconfdir)
1332 $(call print_var,LIBUNWIND_DIR)
1333 $(call print_var,LIBDW_DIR)
1334 $(call print_var,JDIR)
1336 ifeq ($(dwarf-post-unwind),1)
1337 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG))
1343 $(call detected_var,bindir_SQ)
1344 $(call detected_var,PYTHON_WORD)
1346 $(call detected_var,OUTPUT)
1348 $(call detected_var,htmldir_SQ)
1349 $(call detected_var,infodir_SQ)
1350 $(call detected_var,mandir_SQ)
1351 $(call detected_var,ETC_PERFCONFIG_SQ)
1352 $(call detected_var,STRACE_GROUPS_DIR_SQ)
1353 $(call detected_var,prefix_SQ)
1354 $(call detected_var,perfexecdir_SQ)
1355 $(call detected_var,libbpf_include_dir_SQ)
1356 $(call detected_var,perf_examples_dir_SQ)
1357 $(call detected_var,tipdir_SQ)
1358 $(call detected_var,srcdir_SQ)
1359 $(call detected_var,LIBDIR)
1360 $(call detected_var,GTK_CFLAGS)
1361 $(call detected_var,PERL_EMBED_CCOPTS)
1362 $(call detected_var,PYTHON_EMBED_CCOPTS)
1363 ifneq ($(BISON_FILE_PREFIX_MAP),)
1364 $(call detected_var,BISON_FILE_PREFIX_MAP)
1367 # re-generate FEATURE-DUMP as we may have called feature_check, found out
1368 # extra libraries to add to LDFLAGS of some other test and then redo those
1369 # tests, see the block about libbfd, disassembler-four-args, for instance.
1370 $(shell rm -f $(FEATURE_DUMP_FILENAME))
1371 $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))