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 riscv))
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
87 CFLAGS += -I$(OUTPUT)arch/riscv/include/generated
90 # So far there's only x86 and arm libdw unwind support merged in perf.
91 # Disable it on all other architectures in case libdw unwind
92 # support is detected in system. Add supported architectures
94 ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv loongarch))
95 NO_LIBDW_DWARF_UNWIND := 1
98 ifneq ($(LIBUNWIND),1)
102 ifeq ($(LIBUNWIND_LIBS),)
106 # For linking with debug library, run like:
108 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
111 libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
112 define libunwind_arch_set_flags_code
113 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
114 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib
118 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
119 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
120 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 loongarch
121 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
124 # Set per-feature check compilation flags
125 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
126 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
127 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
128 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
130 FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm
131 FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
132 FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
133 FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
135 FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
138 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
140 OPENCSDLIBS := -lopencsd_c_api -lopencsd
141 ifeq ($(findstring -static,${LDFLAGS}),-static)
142 OPENCSDLIBS += -lstdc++
145 LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
147 FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)
148 FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)
150 # for linking with debug library, run like:
151 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
153 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
154 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
157 ifeq ($(findstring -static,${LDFLAGS}),-static)
158 DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd
160 LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
161 LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
162 LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
164 # Elfutils merged libebl.a into libdw.a starting from version 0.177,
165 # Link libebl.a only if libdw is older than this version.
166 ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
170 # Must put -ldl after -lebl for dependency
173 FEATURE_CHECK_CFLAGS-libdw := $(LIBDW_CFLAGS)
174 FEATURE_CHECK_LDFLAGS-libdw := $(LIBDW_LDFLAGS) $(DWARFLIBS)
176 # for linking with debug library, run like:
177 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
178 ifdef LIBBABELTRACE_DIR
179 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
180 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
182 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
183 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
185 # for linking with debug library, run like:
186 # make DEBUG=1 LIBCAPSTONE_DIR=/opt/capstone/
187 ifdef LIBCAPSTONE_DIR
188 LIBCAPSTONE_CFLAGS := -I$(LIBCAPSTONE_DIR)/include
189 LIBCAPSTONE_LDFLAGS := -L$(LIBCAPSTONE_DIR)/
191 FEATURE_CHECK_CFLAGS-libcapstone := $(LIBCAPSTONE_CFLAGS)
192 FEATURE_CHECK_LDFLAGS-libcapstone := $(LIBCAPSTONE_LDFLAGS) -lcapstone
195 LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib
196 LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
198 FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
199 FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
201 # for linking with debug library, run like:
202 # make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
204 ifneq ($(NO_LIBTRACEEVENT),1)
205 ifeq ($(call get-executable,$(PKG_CONFIG)),)
206 $(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)
210 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
211 # include ARCH specific config
212 -include $(src-perf)/arch/$(SRCARCH)/Makefile
214 include $(srctree)/tools/scripts/utilities.mak
216 ifeq ($(call get-executable,$(FLEX)),)
217 $(error Error: $(FLEX) is missing on this system, please install it)
220 ifeq ($(call get-executable,$(BISON)),)
221 $(error Error: $(BISON) is missing on this system, please install it)
225 ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1)
226 BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)=
230 # Treat warnings as errors unless directed not to
232 CORE_CFLAGS += -Werror
234 HOSTCFLAGS += -Werror
242 CORE_CFLAGS += -DNDEBUG=1
250 PARSER_DEBUG_BISON := -t
251 PARSER_DEBUG_FLEX := -d
252 CFLAGS += -DPARSER_DEBUG
253 $(call detected_var,PARSER_DEBUG_BISON)
254 $(call detected_var,PARSER_DEBUG_FLEX)
262 # Try different combinations to accommodate systems that only have
263 # python[2][3]-config in weird combinations in the following order of
264 # priority from lowest to highest:
265 # * python2-config as per pep-0394.
268 # * $(PYTHON)-config (If PYTHON is user supplied but PYTHON_CONFIG isn't)
270 PYTHON_AUTO := python-config
271 PYTHON_AUTO := $(if $(call get-executable,python2-config),python2-config,$(PYTHON_AUTO))
272 PYTHON_AUTO := $(if $(call get-executable,python-config),python-config,$(PYTHON_AUTO))
273 PYTHON_AUTO := $(if $(call get-executable,python3-config),python3-config,$(PYTHON_AUTO))
275 # If PYTHON is defined but PYTHON_CONFIG isn't, then take $(PYTHON)-config as if it was the user
276 # supplied value for PYTHON_CONFIG. Because it's "user supplied", error out if it doesn't exist.
279 PYTHON_CONFIG_AUTO := $(call get-executable,$(PYTHON)-config)
280 PYTHON_CONFIG := $(if $(PYTHON_CONFIG_AUTO),$(PYTHON_CONFIG_AUTO),\
281 $(call $(error $(PYTHON)-config not found)))
285 # Select either auto detected python and python-config or use user supplied values if they are
286 # defined. get-executable-or-default fails with an error if the first argument is supplied but
288 override PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO))
289 override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_CONFIG)))
291 grep-libs = $(filter -l%,$(1))
292 strip-libs = $(filter-out -l%,$(1))
294 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
296 # Python 3.8 changed the output of `python-config --ldflags` to not include the
297 # '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
298 # libpython fails if that flag is not included in LDFLAGS
299 ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
300 PYTHON_CONFIG_LDFLAGS := --ldflags --embed
302 PYTHON_CONFIG_LDFLAGS := --ldflags
306 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
307 # Update the python flags for cross compilation
309 PYTHON_NATIVE := $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/\(-L.*\/\)\(.*-linux-gnu\).*/\2/')
310 PYTHON_EMBED_LDOPTS := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EMBED_LDOPTS))
312 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
313 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
314 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
315 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
316 ifeq ($(CC_NO_CLANG), 0)
317 PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS))
321 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
322 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
324 FEATURE_CHECK_LDFLAGS-libaio = -lrt
326 FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
327 FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl
329 CORE_CFLAGS += -fno-omit-frame-pointer
331 CORE_CFLAGS += -Wextra
332 CORE_CFLAGS += -std=gnu11
334 CXXFLAGS += -std=gnu++17 -fno-exceptions -fno-rtti
337 CXXFLAGS += -fno-omit-frame-pointer
340 HOSTCFLAGS += -Wextra
342 # Enforce a non-executable stack, as we may regress (again) in the future by
343 # adding assembler files missing the .GNU-stack linker note.
344 LDFLAGS += -Wl,-z,noexecstack
346 EXTLIBS = -lpthread -lrt -lm -ldl
349 CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
350 EXTLIBS += -ltcmalloc
353 ifeq ($(FEATURES_DUMP),)
354 # We will display at the end of this Makefile.config, using $(call feature_display_entries)
355 # As we may retry some feature detection here, see the disassembler-four-args case, for instance
356 FEATURE_DISPLAY_DEFERRED := 1
357 include $(srctree)/tools/build/Makefile.feature
359 include $(FEATURES_DUMP)
362 ifeq ($(feature-stackprotector-all), 1)
363 CORE_CFLAGS += -fstack-protector-all
367 ifeq ($(feature-fortify-source), 1)
368 CORE_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
372 INC_FLAGS += -I$(src-perf)/util/include
373 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
374 INC_FLAGS += -I$(srctree)/tools/include/
375 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
376 INC_FLAGS += -I$(srctree)/tools/include/uapi
377 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
378 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
380 # $(obj-perf) for generated common-cmds.h
381 # $(obj-perf)/util for generated bison/flex headers
383 INC_FLAGS += -I$(obj-perf)/util
384 INC_FLAGS += -I$(obj-perf)
387 INC_FLAGS += -I$(src-perf)/util
388 INC_FLAGS += -I$(src-perf)
390 CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
392 CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)
393 CXXFLAGS += $(INC_FLAGS)
395 LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)
397 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
398 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
401 ifeq ($(feature-pthread-barrier), 1)
402 CFLAGS += -DHAVE_PTHREAD_BARRIER
406 $(call feature_check,bionic)
407 ifeq ($(feature-bionic), 1)
409 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
410 CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
411 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
412 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
416 ifeq ($(feature-eventfd), 1)
417 CFLAGS += -DHAVE_EVENTFD_SUPPORT
420 ifeq ($(feature-get_current_dir_name), 1)
421 CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
424 ifeq ($(feature-gettid), 1)
425 CFLAGS += -DHAVE_GETTID
428 ifeq ($(feature-file-handle), 1)
429 CFLAGS += -DHAVE_FILE_HANDLE
435 NO_LIBDW_DWARF_UNWIND := 1
439 ifeq ($(feature-libelf), 0)
440 ifeq ($(feature-glibc), 1)
446 ifeq ($(LIBC_SUPPORT),1)
447 $(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.)
449 ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)
450 ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)
451 $(error No libasan found, please install libasan)
455 ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),)
456 ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0)
457 $(error No libubsan found, please install libubsan)
461 ifneq ($(filter s% -static%,$(LDFLAGS),),)
462 $(error No static glibc found, please install glibc-static)
464 $(error No gnu/libc-version.h found, please install glibc-dev[el])
468 ifneq ($(feature-libdw), 1)
470 $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.157, disables dwarf support. Please install new elfutils-devel/libdw-dev)
473 endif # Dwarf support
474 endif # libelf support
477 ifeq ($(feature-libaio), 1)
479 CFLAGS += -DHAVE_AIO_SUPPORT
484 NO_LIBDW_DWARF_UNWIND := 1
487 ifeq ($(feature-scandirat), 1)
488 # Ignore having scandirat with memory sanitizer that lacks an interceptor.
489 ifeq ($(filter s% -fsanitize=memory%,$(EXTRA_CFLAGS),),)
490 CFLAGS += -DHAVE_SCANDIRAT_SUPPORT
494 ifeq ($(feature-sched_getcpu), 1)
495 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
498 ifeq ($(feature-setns), 1)
499 CFLAGS += -DHAVE_SETNS_SUPPORT
500 $(call detected,CONFIG_SETNS)
504 $(call feature_check,libopencsd)
505 ifeq ($(feature-libopencsd), 1)
506 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
507 ifeq ($(feature-reallocarray), 0)
508 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
510 LDFLAGS += $(LIBOPENCSD_LDFLAGS)
511 EXTLIBS += $(OPENCSDLIBS)
512 $(call detected,CONFIG_LIBOPENCSD)
514 CFLAGS += -DCS_DEBUG_RAW
515 ifeq (${CSTRACE_RAW}, packed)
516 CFLAGS += -DCS_RAW_PACKED
520 $(error Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1)
525 ifeq ($(feature-zlib), 1)
526 CFLAGS += -DHAVE_ZLIB_SUPPORT
528 $(call detected,CONFIG_ZLIB)
535 CFLAGS += -DHAVE_LIBELF_SUPPORT
537 $(call detected,CONFIG_LIBELF)
539 ifeq ($(feature-libelf-getphdrnum), 1)
540 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
543 ifeq ($(feature-libelf-gelf_getnote), 1)
544 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
546 $(warning gelf_getnote() not found on libelf, SDT support disabled)
549 ifeq ($(feature-libelf-getshdrstrndx), 1)
550 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
553 ifndef NO_LIBDEBUGINFOD
554 $(call feature_check,libdebuginfod)
555 ifeq ($(feature-libdebuginfod), 1)
556 CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT
557 EXTLIBS += -ldebuginfod
562 CFLAGS += -DHAVE_LIBDW_SUPPORT $(LIBDW_CFLAGS)
563 LDFLAGS += $(LIBDW_LDFLAGS)
564 EXTLIBS += ${DWARFLIBS}
565 $(call detected,CONFIG_LIBDW)
569 ifeq ($(feature-bpf), 1)
570 # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status
571 $(call feature_check,libbpf)
574 ifeq ($(feature-libbpf), 1)
576 CFLAGS += -DHAVE_LIBBPF_SUPPORT
577 $(call detected,CONFIG_LIBBPF)
578 $(call detected,CONFIG_LIBBPF_DYNAMIC)
580 $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel)
584 $(warning Warning: Statically building libbpf not possible as zlib is missing)
587 # Libbpf will be built as a static library from tools/lib/bpf.
589 $(call detected,CONFIG_LIBBPF)
590 CFLAGS += -DHAVE_LIBBPF_SUPPORT
598 ifneq ($(feature-sdt), 1)
599 $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev)
602 CFLAGS += -DHAVE_SDT_EVENT
603 $(call detected,CONFIG_SDT_EVENT)
607 ifdef PERF_HAVE_JITDUMP
609 $(call detected,CONFIG_JITDUMP)
610 CFLAGS += -DHAVE_JITDUMP
614 ifeq ($(SRCARCH),powerpc)
616 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
623 $(call feature_check,libunwind-x86)
624 ifeq ($(feature-libunwind-x86), 1)
625 $(call detected,CONFIG_LIBUNWIND_X86)
626 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
627 LDFLAGS += -lunwind-x86
628 EXTLIBS_LIBUNWIND += -lunwind-x86
632 $(call feature_check,libunwind-aarch64)
633 ifeq ($(feature-libunwind-aarch64), 1)
634 $(call detected,CONFIG_LIBUNWIND_AARCH64)
635 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
636 LDFLAGS += -lunwind-aarch64
637 EXTLIBS_LIBUNWIND += -lunwind-aarch64
639 $(call feature_check,libunwind-debug-frame-aarch64)
640 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
641 $(warning No debug_frame support found in libunwind-aarch64)
642 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
646 ifneq ($(feature-libunwind), 1)
647 $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR)
648 NO_LOCAL_LIBUNWIND := 1
651 $(call detected,CONFIG_LOCAL_LIBUNWIND)
654 ifneq ($(have_libunwind), 1)
658 NO_LOCAL_LIBUNWIND := 1
662 ifneq ($(feature-bpf), 1)
663 $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
668 ifndef BUILD_BPF_SKEL
669 # BPF skeletons control a large number of perf features, by default
674 ifeq ($(BUILD_BPF_SKEL),1)
675 ifeq ($(filter -DHAVE_LIBELF_SUPPORT, $(CFLAGS)),)
676 $(warning Warning: Disabled BPF skeletons as libelf is required by bpftool)
678 else ifeq ($(filter -DHAVE_ZLIB_SUPPORT, $(CFLAGS)),)
679 $(warning Warning: Disabled BPF skeletons as zlib is required by bpftool)
681 else ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),)
682 $(warning Warning: Disabled BPF skeletons as libbpf is required)
684 else ifeq ($(call get-executable,$(CLANG)),)
685 $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) is missing)
688 CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')
689 ifeq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1)
690 $(warning Warning: Disabled BPF skeletons as reliable BTF generation needs at least $(CLANG) version 12.0.1)
694 ifeq ($(BUILD_BPF_SKEL),1)
695 $(call feature_check,clang-bpf-co-re)
696 ifeq ($(feature-clang-bpf-co-re), 0)
697 $(warning Warning: Disabled BPF skeletons as clang is too old)
701 ifeq ($(BUILD_BPF_SKEL),1)
702 $(call detected,CONFIG_PERF_BPF_SKEL)
703 CFLAGS += -DHAVE_BPF_SKEL
708 VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h
711 dwarf-post-unwind := 1
712 dwarf-post-unwind-text := BUG
714 # setup DWARF post unwinder
716 ifdef NO_LIBDW_DWARF_UNWIND
717 $(warning Disabling post unwind, no support found.)
718 dwarf-post-unwind := 0
720 dwarf-post-unwind-text := libdw
721 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
724 dwarf-post-unwind-text := libunwind
725 $(call detected,CONFIG_LIBUNWIND)
726 # Enable libunwind support by default.
727 ifndef NO_LIBDW_DWARF_UNWIND
728 NO_LIBDW_DWARF_UNWIND := 1
732 ifeq ($(dwarf-post-unwind),1)
733 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
734 $(call detected,CONFIG_DWARF_UNWIND)
737 ifndef NO_LOCAL_LIBUNWIND
738 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
739 $(call feature_check,libunwind-debug-frame)
740 ifneq ($(feature-libunwind-debug-frame), 1)
741 $(warning No debug_frame support found in libunwind)
742 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
745 # non-ARM has no dwarf_find_debug_frame() function:
746 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
748 EXTLIBS += $(LIBUNWIND_LIBS)
749 LDFLAGS += $(LIBUNWIND_LIBS)
751 ifeq ($(findstring -static,${LDFLAGS}),-static)
752 # gcc -static links libgcc_eh which contans piece of libunwind
753 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
757 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
758 CFLAGS += $(LIBUNWIND_CFLAGS)
759 LDFLAGS += $(LIBUNWIND_LDFLAGS)
760 EXTLIBS += $(EXTLIBS_LIBUNWIND)
763 ifneq ($(NO_LIBTRACEEVENT),1)
764 ifeq ($(NO_SYSCALL_TABLE),0)
765 $(call detected,CONFIG_TRACE)
768 $(call feature_check,libaudit)
769 ifneq ($(feature-libaudit), 1)
770 $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev)
773 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
775 $(call detected,CONFIG_TRACE)
782 ifneq ($(feature-libcrypto), 1)
783 $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev)
786 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
788 $(call detected,CONFIG_CRYPTO)
793 ifneq ($(feature-libslang), 1)
794 ifneq ($(feature-libslang-include-subdir), 1)
795 $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev)
798 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR
802 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
803 CFLAGS += -DHAVE_SLANG_SUPPORT
805 $(call detected,CONFIG_SLANG)
810 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
811 $(call feature_check,gtk2)
812 ifneq ($(feature-gtk2), 1)
813 $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev)
816 $(call feature_check,gtk2-infobar)
817 ifeq ($(feature-gtk2-infobar), 1)
818 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
820 CFLAGS += -DHAVE_GTK2_SUPPORT
821 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
822 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
828 CFLAGS += -DNO_LIBPERL
830 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
831 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
832 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
833 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
834 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
835 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
836 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
837 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
839 ifneq ($(feature-libperl), 1)
840 CFLAGS += -DNO_LIBPERL
842 $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev)
844 LDFLAGS += $(PERL_EMBED_LDFLAGS)
845 EXTLIBS += $(PERL_EMBED_LIBADD)
846 CFLAGS += -DHAVE_LIBPERL_SUPPORT
847 ifeq ($(CC_NO_CLANG), 0)
848 CFLAGS += -Wno-compound-token-split-by-macro
850 $(call detected,CONFIG_LIBPERL)
854 ifeq ($(feature-timerfd), 1)
855 CFLAGS += -DHAVE_TIMERFD_SUPPORT
857 $(warning No timerfd support. Disables 'perf kvm stat live')
860 disable-python = $(eval $(disable-python_code))
861 define disable-python_code
862 CFLAGS += -DNO_LIBPYTHON
867 PYTHON_EXTENSION_SUFFIX := '.so'
869 $(call disable-python,Python support disabled by user)
873 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
875 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
878 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
881 ifneq ($(feature-libpython), 1)
882 $(call disable-python,No 'Python.h' was found: disables Python support - please install python-devel/python-dev)
884 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
885 EXTLIBS += $(PYTHON_EMBED_LIBADD)
886 PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no")
887 ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes)
888 PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
890 PYTHON_EXTENSION_SUFFIX := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EXTENSION_SUFFIX))
892 LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX)
894 $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent)
896 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
897 $(call detected,CONFIG_LIBPYTHON)
898 ifeq ($(filter -fPIC,$(CFLAGS)),)
899 # Building a shared library requires position independent code.
908 ifneq ($(NO_JEVENTS),1)
909 ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),)
913 ifneq ($(NO_JEVENTS),1)
916 $(error ERROR: No python interpreter needed for jevents generation. Install python or build with NO_JEVENTS=1.)
918 # jevents.py uses f-strings present in Python 3.6 released in Dec. 2016.
919 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)
920 ifneq ($(JEVENTS_PYTHON_GOOD), 1)
921 $(error ERROR: Python interpreter needed for jevents generation too old (older than 3.6). Install a newer python or build with NO_JEVENTS=1.)
926 ifdef BUILD_NONDISTRO
927 ifeq ($(feature-libbfd), 1)
928 EXTLIBS += -lbfd -lopcodes
930 # we are on a system that requires -liberty and (maybe) -lz
931 # to link against -lbfd; test each case individually here
933 # call all detections now so we get correct
934 # status in VF output
935 $(call feature_check,libbfd-liberty)
936 $(call feature_check,libbfd-liberty-z)
938 ifeq ($(feature-libbfd-liberty), 1)
939 EXTLIBS += -lbfd -lopcodes -liberty
940 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
941 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl
943 ifeq ($(feature-libbfd-liberty-z), 1)
944 EXTLIBS += -lbfd -lopcodes -liberty -lz
945 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
946 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl
949 $(call feature_check,disassembler-four-args)
950 $(call feature_check,disassembler-init-styled)
953 CFLAGS += -DHAVE_LIBBFD_SUPPORT
954 CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
955 ifeq ($(feature-libbfd-buildid), 1)
956 CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
958 $(warning Old version of libbfd/binutils things like PE executable profiling will not be available)
963 $(call feature_check,llvm-perf)
964 ifeq ($(feature-llvm-perf), 1)
965 CFLAGS += -DHAVE_LIBLLVM_SUPPORT
966 CFLAGS += $(shell $(LLVM_CONFIG) --cflags)
967 CXXFLAGS += -DHAVE_LIBLLVM_SUPPORT
968 CXXFLAGS += $(shell $(LLVM_CONFIG) --cxxflags)
969 LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)
970 EXTLIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)
972 $(call detected,CONFIG_LIBLLVM)
974 $(warning No libllvm 13+ found, slower source file resolution, please install llvm-devel/llvm-dev)
980 $(call feature_check,cxa-demangle)
981 ifeq ($(feature-cxa-demangle), 1)
983 CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
984 CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
985 $(call detected,CONFIG_CXX_DEMANGLE)
987 ifdef BUILD_NONDISTRO
988 ifeq ($(filter -liberty,$(EXTLIBS)),)
989 $(call feature_check,cplus-demangle)
990 ifeq ($(feature-cplus-demangle), 1)
994 ifneq ($(filter -liberty,$(EXTLIBS)),)
995 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
996 CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
1002 ifeq ($(feature-lzma), 1)
1003 CFLAGS += -DHAVE_LZMA_SUPPORT
1005 $(call detected,CONFIG_LZMA)
1007 $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev)
1013 ifeq ($(feature-libzstd), 1)
1014 CFLAGS += -DHAVE_ZSTD_SUPPORT
1015 CFLAGS += $(LIBZSTD_CFLAGS)
1016 LDFLAGS += $(LIBZSTD_LDFLAGS)
1018 $(call detected,CONFIG_ZSTD)
1020 $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR)
1026 ifeq ($(feature-backtrace), 1)
1027 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
1032 ifeq ($(feature-libnuma), 0)
1033 $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev)
1036 ifeq ($(feature-numa_num_possible_cpus), 0)
1037 $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8)
1040 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
1042 $(call detected,CONFIG_NUMA)
1047 ifdef HAVE_KVM_STAT_SUPPORT
1048 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
1051 ifeq ($(feature-disassembler-four-args), 1)
1052 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
1055 ifeq ($(feature-disassembler-init-styled), 1)
1056 CFLAGS += -DDISASM_INIT_STYLED
1059 ifeq (${IS_64_BIT}, 1)
1060 ifndef NO_PERF_READ_VDSO32
1061 $(call feature_check,compile-32)
1062 ifeq ($(feature-compile-32), 1)
1063 CFLAGS += -DHAVE_PERF_READ_VDSO32
1065 NO_PERF_READ_VDSO32 := 1
1068 ifneq ($(SRCARCH), x86)
1069 NO_PERF_READ_VDSOX32 := 1
1071 ifndef NO_PERF_READ_VDSOX32
1072 $(call feature_check,compile-x32)
1073 ifeq ($(feature-compile-x32), 1)
1074 CFLAGS += -DHAVE_PERF_READ_VDSOX32
1076 NO_PERF_READ_VDSOX32 := 1
1080 NO_PERF_READ_VDSO32 := 1
1081 NO_PERF_READ_VDSOX32 := 1
1084 ifndef NO_LIBBABELTRACE
1085 $(call feature_check,libbabeltrace)
1086 ifeq ($(feature-libbabeltrace), 1)
1087 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
1088 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
1089 EXTLIBS += -lbabeltrace-ctf
1090 $(call detected,CONFIG_LIBBABELTRACE)
1092 $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev)
1097 $(call feature_check,libcapstone)
1098 ifeq ($(feature-libcapstone), 1)
1099 CFLAGS += -DHAVE_LIBCAPSTONE_SUPPORT $(LIBCAPSTONE_CFLAGS)
1100 LDFLAGS += $(LICAPSTONE_LDFLAGS)
1101 EXTLIBS += -lcapstone
1102 $(call detected,CONFIG_LIBCAPSTONE)
1104 msg := $(warning No libcapstone found, disables disasm engine support for 'perf script', please install libcapstone-dev/capstone-devel);
1109 ifeq ($(SRCARCH),x86)
1110 ifeq ($(feature-get_cpuid), 0)
1111 $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc)
1116 $(call detected,CONFIG_AUXTRACE)
1117 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
1118 ifeq ($(feature-reallocarray), 0)
1119 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
1125 $(call detected,CONFIG_EXTRA_TESTS)
1126 CFLAGS += -DHAVE_EXTRA_TESTS
1130 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
1131 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
1133 ifneq (,$(wildcard /usr/sbin/alternatives))
1134 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')
1138 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
1144 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
1145 $(call feature_check,jvmti)
1146 ifeq ($(feature-jvmti), 1)
1147 $(call detected_var,JDIR)
1148 ifndef NO_JVMTI_CMLR
1149 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
1150 $(call feature_check,jvmti-cmlr)
1151 ifeq ($(feature-jvmti-cmlr), 1)
1152 CFLAGS += -DHAVE_JVMTI_CMLR
1154 endif # NO_JVMTI_CMLR
1156 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
1162 $(call feature_check,libpfm4)
1163 ifeq ($(feature-libpfm4), 1)
1164 CFLAGS += -DHAVE_LIBPFM
1166 ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1
1167 $(call detected,CONFIG_LIBPFM4)
1169 $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev)
1173 # libtraceevent is a recommended dependency picked up from the system.
1174 ifneq ($(NO_LIBTRACEEVENT),1)
1175 $(call feature_check,libtraceevent)
1176 ifeq ($(feature-libtraceevent), 1)
1177 CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent)
1178 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent)
1179 EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent)
1180 LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent).0.0
1181 LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1182 LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1183 LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1184 LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3))
1185 CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)
1186 $(call detected,CONFIG_LIBTRACEEVENT)
1188 $(error ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel and/or set LIBTRACEEVENT_DIR or build with NO_LIBTRACEEVENT=1)
1191 $(call feature_check,libtracefs)
1192 ifeq ($(feature-libtracefs), 1)
1193 CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs)
1194 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)
1195 EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtracefs)
1196 LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs).0.0
1197 LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION)))
1198 LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION)))
1199 LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION)))
1200 LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3))
1201 CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP)
1203 $(warning libtracefs is missing. Please install libtracefs-dev/libtracefs-devel)
1207 # Among the variables below, these:
1209 # libbpf_include_dir
1215 # ETC_PERFCONFIG (but not sysconfdir)
1216 # can be specified as a relative path some/where/else;
1217 # this is interpreted as relative to $(prefix) and "perf" at
1218 # runtime figures out where they are based on the path to the executable.
1219 # This can help installing the suite in a relocatable way.
1221 # Make the path relative to DESTDIR, not to prefix
1225 bindir_relative = bin
1226 bindir = $(abspath $(prefix)/$(bindir_relative))
1227 includedir_relative = include
1228 includedir = $(abspath $(prefix)/$(includedir_relative))
1230 infodir = share/info
1231 perfexecdir = libexec/perf-core
1232 # FIXME: system's libbpf header directory, where we expect to find bpf/bpf_helpers.h, for instance
1233 libbpf_include_dir = /usr/include
1234 perf_examples_dir = lib/perf/examples
1235 sharedir = $(prefix)/share
1236 template_dir = share/perf-core/templates
1237 STRACE_GROUPS_DIR = share/perf-core/strace/groups
1238 htmldir = share/doc/perf-doc
1239 tipdir = share/doc/perf-tip
1240 srcdir = $(srctree)/tools/perf
1241 ifeq ($(prefix),/usr)
1243 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
1245 sysconfdir = $(prefix)/etc
1246 ETC_PERFCONFIG = etc/perfconfig
1249 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
1255 libdir = $(prefix)/$(lib)
1257 # Shell quote (do not use $(call) to accommodate ancient setups);
1258 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
1259 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
1260 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1261 bindir_SQ = $(subst ','\'',$(bindir))
1262 includedir_SQ = $(subst ','\'',$(includedir))
1263 mandir_SQ = $(subst ','\'',$(mandir))
1264 infodir_SQ = $(subst ','\'',$(infodir))
1265 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
1266 libbpf_include_dir_SQ = $(subst ','\'',$(libbpf_include_dir))
1267 perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))
1268 template_dir_SQ = $(subst ','\'',$(template_dir))
1269 htmldir_SQ = $(subst ','\'',$(htmldir))
1270 tipdir_SQ = $(subst ','\'',$(tipdir))
1271 prefix_SQ = $(subst ','\'',$(prefix))
1272 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
1273 libdir_SQ = $(subst ','\'',$(libdir))
1274 srcdir_SQ = $(subst ','\'',$(srcdir))
1276 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
1277 perfexec_instdir = $(perfexecdir)
1278 perf_include_instdir = $(libbpf_include_dir)
1279 perf_examples_instdir = $(perf_examples_dir)
1280 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
1281 tip_instdir = $(tipdir)
1283 perfexec_instdir = $(prefix)/$(perfexecdir)
1284 perf_include_instdir = $(prefix)/$(libbpf_include_dir)
1285 perf_examples_instdir = $(prefix)/$(perf_examples_dir)
1286 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
1287 tip_instdir = $(prefix)/$(tipdir)
1289 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
1290 perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))
1291 perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))
1292 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
1293 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
1295 export perfexec_instdir_SQ
1297 print_var = $(eval $(print_var_code)) $(info $(MSG))
1298 define print_var_code
1299 MSG = $(shell printf '...%40s: %s' $(1) $($(1)))
1302 ifeq ($(feature_display),1)
1303 $(call feature_display_entries)
1307 # Display EXTRA features which are detected manualy
1308 # from here with feature_check call and thus cannot
1309 # be partof global state output.
1310 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),) $(info $(MSG)))
1311 $(call print_var,prefix)
1312 $(call print_var,bindir)
1313 $(call print_var,libdir)
1314 $(call print_var,sysconfdir)
1315 $(call print_var,LIBUNWIND_DIR)
1316 $(call print_var,LIBDW_DIR)
1317 $(call print_var,JDIR)
1319 ifeq ($(dwarf-post-unwind),1)
1320 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG))
1326 $(call detected_var,bindir_SQ)
1327 $(call detected_var,PYTHON_WORD)
1329 $(call detected_var,OUTPUT)
1331 $(call detected_var,htmldir_SQ)
1332 $(call detected_var,infodir_SQ)
1333 $(call detected_var,mandir_SQ)
1334 $(call detected_var,ETC_PERFCONFIG_SQ)
1335 $(call detected_var,STRACE_GROUPS_DIR_SQ)
1336 $(call detected_var,prefix_SQ)
1337 $(call detected_var,perfexecdir_SQ)
1338 $(call detected_var,libbpf_include_dir_SQ)
1339 $(call detected_var,perf_examples_dir_SQ)
1340 $(call detected_var,tipdir_SQ)
1341 $(call detected_var,srcdir_SQ)
1342 $(call detected_var,LIBDIR)
1343 $(call detected_var,GTK_CFLAGS)
1344 $(call detected_var,PERL_EMBED_CCOPTS)
1345 $(call detected_var,PYTHON_EMBED_CCOPTS)
1346 ifneq ($(BISON_FILE_PREFIX_MAP),)
1347 $(call detected_var,BISON_FILE_PREFIX_MAP)
1350 # re-generate FEATURE-DUMP as we may have called feature_check, found out
1351 # extra libraries to add to LDFLAGS of some other test and then redo those
1352 # tests, see the block about libbfd, disassembler-four-args, for instance.
1353 $(shell rm -f $(FEATURE_DUMP_FILENAME))
1354 $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))