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) $(EXTRA_WARNINGS)
21 include $(srctree)/tools/scripts/Makefile.arch
23 $(call detected_var,SRCARCH)
28 # Additional ARCH settings for ppc
29 ifeq ($(SRCARCH),powerpc)
32 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated
33 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
36 # Additional ARCH settings for x86
38 $(call detected,CONFIG_X86)
39 ifeq (${IS_64_BIT}, 1)
41 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated
42 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
43 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
44 $(call detected,CONFIG_X86_64)
46 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
53 LIBUNWIND_LIBS = -lunwind -lunwind-arm
56 ifeq ($(SRCARCH),arm64)
59 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
60 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
63 ifeq ($(SRCARCH),riscv)
67 ifeq ($(SRCARCH),csky)
74 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
77 ifeq ($(NO_PERF_REGS),0)
78 $(call detected,CONFIG_PERF_REGS)
81 ifneq ($(NO_SYSCALL_TABLE),1)
82 CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT
85 # So far there's only x86 and arm libdw unwind support merged in perf.
86 # Disable it on all other architectures in case libdw unwind
87 # support is detected in system. Add supported architectures
89 ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv))
90 NO_LIBDW_DWARF_UNWIND := 1
93 ifeq ($(LIBUNWIND_LIBS),)
97 # For linking with debug library, run like:
99 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
102 libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
103 define libunwind_arch_set_flags_code
104 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
105 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib
109 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
110 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
111 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64
112 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
115 # Set per-feature check compilation flags
116 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
117 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
118 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
119 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
121 FEATURE_CHECK_LDFLAGS-libunwind-arm = -lunwind -lunwind-arm
122 FEATURE_CHECK_LDFLAGS-libunwind-aarch64 = -lunwind -lunwind-aarch64
123 FEATURE_CHECK_LDFLAGS-libunwind-x86 = -lunwind -llzma -lunwind-x86
124 FEATURE_CHECK_LDFLAGS-libunwind-x86_64 = -lunwind -llzma -lunwind-x86_64
126 FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
129 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
131 OPENCSDLIBS := -lopencsd_c_api -lopencsd
133 LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
135 FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)
136 FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)
138 ifeq ($(NO_PERF_REGS),0)
139 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
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 -lebl -ldl -lz -llzma -lbz2
152 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
153 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
155 # for linking with debug library, run like:
156 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
157 ifdef LIBBABELTRACE_DIR
158 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
159 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
161 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
162 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
165 LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib
166 LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
168 FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
169 FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
171 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
172 # include ARCH specific config
173 -include $(src-perf)/arch/$(SRCARCH)/Makefile
175 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
176 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
179 include $(srctree)/tools/scripts/utilities.mak
181 ifeq ($(call get-executable,$(FLEX)),)
182 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
185 ifeq ($(call get-executable,$(BISON)),)
186 dummy := $(error Error: $(BISON) is missing on this system, please install it)
189 # Treat warnings as errors unless directed not to
200 ifeq ($(CC_NO_CLANG), 0)
208 PARSER_DEBUG_BISON := -t
209 PARSER_DEBUG_FLEX := -d
210 CFLAGS += -DPARSER_DEBUG
211 $(call detected_var,PARSER_DEBUG_BISON)
212 $(call detected_var,PARSER_DEBUG_FLEX)
215 # Try different combinations to accommodate systems that only have
216 # python[2][-config] in weird combinations but always preferring
217 # python2 and python2-config as per pep-0394. If we catch a
218 # python[-config] in version 3, the version check will kill it.
219 PYTHON2 := $(if $(call get-executable,python2),python2,python)
220 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
222 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
223 override PYTHON_CONFIG := \
224 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
226 grep-libs = $(filter -l%,$(1))
227 strip-libs = $(filter-out -l%,$(1))
229 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
232 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
233 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
234 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
235 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
236 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
239 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
240 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
241 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
242 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
244 FEATURE_CHECK_LDFLAGS-libaio = -lrt
246 FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
248 CFLAGS += -fno-omit-frame-pointer
250 CFLAGS += -funwind-tables
255 CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
257 CXXFLAGS += -fno-omit-frame-pointer
259 CXXFLAGS += -funwind-tables
260 CXXFLAGS += -Wno-strict-aliasing
262 # Enforce a non-executable stack, as we may regress (again) in the future by
263 # adding assembler files missing the .GNU-stack linker note.
264 LDFLAGS += -Wl,-z,noexecstack
266 EXTLIBS = -lpthread -lrt -lm -ldl
268 ifeq ($(FEATURES_DUMP),)
269 include $(srctree)/tools/build/Makefile.feature
271 include $(FEATURES_DUMP)
274 ifeq ($(feature-stackprotector-all), 1)
275 CFLAGS += -fstack-protector-all
279 ifeq ($(feature-fortify-source), 1)
280 CFLAGS += -D_FORTIFY_SOURCE=2
284 INC_FLAGS += -I$(src-perf)/util/include
285 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
286 INC_FLAGS += -I$(srctree)/tools/include/uapi
287 INC_FLAGS += -I$(srctree)/tools/include/
288 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
289 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
290 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
292 # $(obj-perf) for generated common-cmds.h
293 # $(obj-perf)/util for generated bison/flex headers
295 INC_FLAGS += -I$(obj-perf)/util
296 INC_FLAGS += -I$(obj-perf)
299 INC_FLAGS += -I$(src-perf)/util
300 INC_FLAGS += -I$(src-perf)
301 INC_FLAGS += -I$(srctree)/tools/lib/
303 CFLAGS += $(INC_FLAGS)
304 CXXFLAGS += $(INC_FLAGS)
306 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
308 ifeq ($(feature-sync-compare-and-swap), 1)
309 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
312 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
313 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
316 ifeq ($(feature-pthread-barrier), 1)
317 CFLAGS += -DHAVE_PTHREAD_BARRIER
321 $(call feature_check,bionic)
322 ifeq ($(feature-bionic), 1)
324 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
325 CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
326 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
327 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
331 ifeq ($(feature-eventfd), 1)
332 CFLAGS += -DHAVE_EVENTFD
335 ifeq ($(feature-get_current_dir_name), 1)
336 CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
339 ifeq ($(feature-gettid), 1)
340 CFLAGS += -DHAVE_GETTID
347 NO_LIBDW_DWARF_UNWIND := 1
351 ifeq ($(feature-libelf), 0)
352 ifeq ($(feature-glibc), 1)
358 ifeq ($(LIBC_SUPPORT),1)
359 msg := $(warning No libelf found. Disables 'probe' tool, jvmti and BPF support in 'perf record'. Please install libelf-dev, libelf-devel or elfutils-libelf-devel);
365 NO_LIBDW_DWARF_UNWIND := 1
369 ifneq ($(filter s% -static%,$(LDFLAGS),),)
370 msg := $(error No static glibc found, please install glibc-static);
372 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
376 ifndef NO_LIBDW_DWARF_UNWIND
377 ifneq ($(feature-libdw-dwarf-unwind),1)
378 NO_LIBDW_DWARF_UNWIND := 1
379 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
382 ifneq ($(feature-dwarf), 1)
384 msg := $(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);
388 ifneq ($(feature-dwarf_getlocations), 1)
389 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
391 CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
392 endif # dwarf_getlocations
393 endif # Dwarf support
394 endif # libelf support
397 ifeq ($(feature-glibc), 1)
398 CFLAGS += -DHAVE_GLIBC_SUPPORT
401 ifeq ($(feature-libaio), 1)
403 CFLAGS += -DHAVE_AIO_SUPPORT
408 NO_LIBDW_DWARF_UNWIND := 1
411 ifeq ($(feature-sched_getcpu), 1)
412 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
415 ifeq ($(feature-setns), 1)
416 CFLAGS += -DHAVE_SETNS_SUPPORT
417 $(call detected,CONFIG_SETNS)
421 $(call feature_check,libopencsd)
422 ifeq ($(feature-libopencsd), 1)
423 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
424 ifeq ($(feature-reallocarray), 0)
425 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
427 LDFLAGS += $(LIBOPENCSD_LDFLAGS)
428 EXTLIBS += $(OPENCSDLIBS)
429 $(call detected,CONFIG_LIBOPENCSD)
431 CFLAGS += -DCS_DEBUG_RAW
432 ifeq (${CSTRACE_RAW}, packed)
433 CFLAGS += -DCS_RAW_PACKED
440 CFLAGS += -DHAVE_LIBELF_SUPPORT
442 $(call detected,CONFIG_LIBELF)
444 ifeq ($(feature-libelf-mmap), 1)
445 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
448 ifeq ($(feature-libelf-getphdrnum), 1)
449 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
452 ifeq ($(feature-libelf-gelf_getnote), 1)
453 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
455 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
458 ifeq ($(feature-libelf-getshdrstrndx), 1)
459 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
463 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
464 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
467 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
468 LDFLAGS += $(LIBDW_LDFLAGS)
469 EXTLIBS += ${DWARFLIBS}
470 $(call detected,CONFIG_DWARF)
471 endif # PERF_HAVE_DWARF_REGS
475 ifeq ($(feature-bpf), 1)
476 CFLAGS += -DHAVE_LIBBPF_SUPPORT
477 $(call detected,CONFIG_LIBBPF)
481 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
482 CFLAGS += -DHAVE_BPF_PROLOGUE
483 $(call detected,CONFIG_BPF_PROLOGUE)
485 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
488 msg := $(warning DWARF support is off, BPF prologue is disabled);
495 ifneq ($(feature-sdt), 1)
496 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
499 CFLAGS += -DHAVE_SDT_EVENT
500 $(call detected,CONFIG_SDT_EVENT)
504 ifdef PERF_HAVE_JITDUMP
506 $(call detected,CONFIG_JITDUMP)
507 CFLAGS += -DHAVE_JITDUMP
511 ifeq ($(SRCARCH),powerpc)
513 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
520 $(call feature_check,libunwind-x86)
521 ifeq ($(feature-libunwind-x86), 1)
522 $(call detected,CONFIG_LIBUNWIND_X86)
523 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
524 LDFLAGS += -lunwind-x86
525 EXTLIBS_LIBUNWIND += -lunwind-x86
529 $(call feature_check,libunwind-aarch64)
530 ifeq ($(feature-libunwind-aarch64), 1)
531 $(call detected,CONFIG_LIBUNWIND_AARCH64)
532 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
533 LDFLAGS += -lunwind-aarch64
534 EXTLIBS_LIBUNWIND += -lunwind-aarch64
536 $(call feature_check,libunwind-debug-frame-aarch64)
537 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
538 msg := $(warning No debug_frame support found in libunwind-aarch64);
539 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
543 ifneq ($(feature-libunwind), 1)
544 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
545 NO_LOCAL_LIBUNWIND := 1
548 $(call detected,CONFIG_LOCAL_LIBUNWIND)
551 ifneq ($(have_libunwind), 1)
555 NO_LOCAL_LIBUNWIND := 1
559 ifneq ($(feature-bpf), 1)
560 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
565 dwarf-post-unwind := 1
566 dwarf-post-unwind-text := BUG
568 # setup DWARF post unwinder
570 ifdef NO_LIBDW_DWARF_UNWIND
571 msg := $(warning Disabling post unwind, no support found.);
572 dwarf-post-unwind := 0
574 dwarf-post-unwind-text := libdw
575 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
578 dwarf-post-unwind-text := libunwind
579 $(call detected,CONFIG_LIBUNWIND)
580 # Enable libunwind support by default.
581 ifndef NO_LIBDW_DWARF_UNWIND
582 NO_LIBDW_DWARF_UNWIND := 1
586 ifeq ($(dwarf-post-unwind),1)
587 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
588 $(call detected,CONFIG_DWARF_UNWIND)
593 ifndef NO_LOCAL_LIBUNWIND
594 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
595 $(call feature_check,libunwind-debug-frame)
596 ifneq ($(feature-libunwind-debug-frame), 1)
597 msg := $(warning No debug_frame support found in libunwind);
598 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
601 # non-ARM has no dwarf_find_debug_frame() function:
602 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
604 EXTLIBS += $(LIBUNWIND_LIBS)
605 LDFLAGS += $(LIBUNWIND_LIBS)
607 ifeq ($(findstring -static,${LDFLAGS}),-static)
608 # gcc -static links libgcc_eh which contans piece of libunwind
609 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
613 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
614 CFLAGS += $(LIBUNWIND_CFLAGS)
615 LDFLAGS += $(LIBUNWIND_LDFLAGS)
616 EXTLIBS += $(EXTLIBS_LIBUNWIND)
619 ifeq ($(NO_SYSCALL_TABLE),0)
620 $(call detected,CONFIG_TRACE)
623 ifneq ($(feature-libaudit), 1)
624 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
627 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
629 $(call detected,CONFIG_TRACE)
635 ifneq ($(feature-libcrypto), 1)
636 msg := $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev);
639 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
641 $(call detected,CONFIG_CRYPTO)
650 ifneq ($(feature-libslang), 1)
651 ifneq ($(feature-libslang-include-subdir), 1)
652 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
655 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR
659 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
660 CFLAGS += -DHAVE_SLANG_SUPPORT
662 $(call detected,CONFIG_SLANG)
667 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
668 ifneq ($(feature-gtk2), 1)
669 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
672 ifeq ($(feature-gtk2-infobar), 1)
673 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
675 CFLAGS += -DHAVE_GTK2_SUPPORT
676 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
677 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
683 CFLAGS += -DNO_LIBPERL
685 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
686 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
687 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
688 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
689 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
690 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
691 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
693 ifneq ($(feature-libperl), 1)
694 CFLAGS += -DNO_LIBPERL
696 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
698 LDFLAGS += $(PERL_EMBED_LDFLAGS)
699 EXTLIBS += $(PERL_EMBED_LIBADD)
700 CFLAGS += -DHAVE_LIBPERL_SUPPORT
701 $(call detected,CONFIG_LIBPERL)
705 ifeq ($(feature-timerfd), 1)
706 CFLAGS += -DHAVE_TIMERFD_SUPPORT
708 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
711 disable-python = $(eval $(disable-python_code))
712 define disable-python_code
713 CFLAGS += -DNO_LIBPYTHON
719 $(call disable-python,Python support disabled by user)
723 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
725 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
728 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
731 ifneq ($(feature-libpython), 1)
732 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
734 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
735 EXTLIBS += $(PYTHON_EMBED_LIBADD)
736 LANG_BINDINGS += $(obj-perf)python/perf.so
737 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
738 $(call detected,CONFIG_LIBPYTHON)
744 ifeq ($(feature-libbfd), 1)
745 EXTLIBS += -lbfd -lopcodes
747 # we are on a system that requires -liberty and (maybe) -lz
748 # to link against -lbfd; test each case individually here
750 # call all detections now so we get correct
751 # status in VF output
752 $(call feature_check,libbfd-liberty)
753 $(call feature_check,libbfd-liberty-z)
755 ifeq ($(feature-libbfd-liberty), 1)
756 EXTLIBS += -lbfd -lopcodes -liberty
757 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
759 ifeq ($(feature-libbfd-liberty-z), 1)
760 EXTLIBS += -lbfd -lopcodes -liberty -lz
761 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
764 $(call feature_check,disassembler-four-args)
768 CFLAGS += -DNO_DEMANGLE
770 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
773 ifeq ($(filter -liberty,$(EXTLIBS)),)
774 $(call feature_check,cplus-demangle)
776 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
777 # or any of 'bfd iberty z' trinity
778 ifeq ($(feature-cplus-demangle), 1)
781 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
782 CFLAGS += -DNO_DEMANGLE
787 ifneq ($(filter -liberty,$(EXTLIBS)),)
788 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
792 ifneq ($(filter -lbfd,$(EXTLIBS)),)
793 CFLAGS += -DHAVE_LIBBFD_SUPPORT
797 ifeq ($(feature-zlib), 1)
798 CFLAGS += -DHAVE_ZLIB_SUPPORT
800 $(call detected,CONFIG_ZLIB)
807 ifeq ($(feature-lzma), 1)
808 CFLAGS += -DHAVE_LZMA_SUPPORT
810 $(call detected,CONFIG_LZMA)
812 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
818 ifeq ($(feature-libzstd), 1)
819 CFLAGS += -DHAVE_ZSTD_SUPPORT
820 CFLAGS += $(LIBZSTD_CFLAGS)
821 LDFLAGS += $(LIBZSTD_LDFLAGS)
823 $(call detected,CONFIG_ZSTD)
825 msg := $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR);
831 ifeq ($(feature-backtrace), 1)
832 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
837 ifeq ($(feature-libnuma), 0)
838 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
841 ifeq ($(feature-numa_num_possible_cpus), 0)
842 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
845 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
847 $(call detected,CONFIG_NUMA)
852 ifdef HAVE_KVM_STAT_SUPPORT
853 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
856 ifeq ($(feature-disassembler-four-args), 1)
857 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
860 ifeq (${IS_64_BIT}, 1)
861 ifndef NO_PERF_READ_VDSO32
862 $(call feature_check,compile-32)
863 ifeq ($(feature-compile-32), 1)
864 CFLAGS += -DHAVE_PERF_READ_VDSO32
866 NO_PERF_READ_VDSO32 := 1
869 ifneq ($(SRCARCH), x86)
870 NO_PERF_READ_VDSOX32 := 1
872 ifndef NO_PERF_READ_VDSOX32
873 $(call feature_check,compile-x32)
874 ifeq ($(feature-compile-x32), 1)
875 CFLAGS += -DHAVE_PERF_READ_VDSOX32
877 NO_PERF_READ_VDSOX32 := 1
881 NO_PERF_READ_VDSO32 := 1
882 NO_PERF_READ_VDSOX32 := 1
885 ifndef NO_LIBBABELTRACE
886 $(call feature_check,libbabeltrace)
887 ifeq ($(feature-libbabeltrace), 1)
888 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
889 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
890 EXTLIBS += -lbabeltrace-ctf
891 $(call detected,CONFIG_LIBBABELTRACE)
893 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
898 ifeq ($(SRCARCH),x86)
899 ifeq ($(feature-get_cpuid), 0)
900 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
905 $(call detected,CONFIG_AUXTRACE)
906 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
911 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
912 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
914 ifneq (,$(wildcard /usr/sbin/alternatives))
915 JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
919 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
925 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
926 $(call feature_check,jvmti)
927 ifeq ($(feature-jvmti), 1)
928 $(call detected_var,JDIR)
930 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
931 $(call feature_check,jvmti-cmlr)
932 ifeq ($(feature-jvmti-cmlr), 1)
933 CFLAGS += -DHAVE_JVMTI_CMLR
935 endif # NO_JVMTI_CMLR
937 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
945 $(call feature_check,cxx)
946 ifneq ($(feature-cxx), 1)
947 msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
949 $(call feature_check,llvm)
950 $(call feature_check,llvm-version)
951 ifneq ($(feature-llvm), 1)
952 msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
954 $(call feature_check,clang)
955 ifneq ($(feature-clang), 1)
956 msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
958 CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
959 CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
960 $(call detected,CONFIG_CXX)
961 $(call detected,CONFIG_CLANGLLVM)
965 ifneq ($(feature-llvm-version),1)
966 msg := $(warning This version of LLVM is not tested. May cause build errors)
973 # Among the variables below, these:
981 # ETC_PERFCONFIG (but not sysconfdir)
982 # can be specified as a relative path some/where/else;
983 # this is interpreted as relative to $(prefix) and "perf" at
984 # runtime figures out where they are based on the path to the executable.
985 # This can help installing the suite in a relocatable way.
987 # Make the path relative to DESTDIR, not to prefix
991 bindir_relative = bin
992 bindir = $(abspath $(prefix)/$(bindir_relative))
995 perfexecdir = libexec/perf-core
996 perf_include_dir = lib/perf/include
997 perf_examples_dir = lib/perf/examples
998 sharedir = $(prefix)/share
999 template_dir = share/perf-core/templates
1000 STRACE_GROUPS_DIR = share/perf-core/strace/groups
1001 htmldir = share/doc/perf-doc
1002 tipdir = share/doc/perf-tip
1003 srcdir = $(srctree)/tools/perf
1004 ifeq ($(prefix),/usr)
1006 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
1008 sysconfdir = $(prefix)/etc
1009 ETC_PERFCONFIG = etc/perfconfig
1012 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
1018 libdir = $(prefix)/$(lib)
1020 # Shell quote (do not use $(call) to accommodate ancient setups);
1021 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
1022 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
1023 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1024 bindir_SQ = $(subst ','\'',$(bindir))
1025 mandir_SQ = $(subst ','\'',$(mandir))
1026 infodir_SQ = $(subst ','\'',$(infodir))
1027 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
1028 perf_include_dir_SQ = $(subst ','\'',$(perf_include_dir))
1029 perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))
1030 template_dir_SQ = $(subst ','\'',$(template_dir))
1031 htmldir_SQ = $(subst ','\'',$(htmldir))
1032 tipdir_SQ = $(subst ','\'',$(tipdir))
1033 prefix_SQ = $(subst ','\'',$(prefix))
1034 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
1035 libdir_SQ = $(subst ','\'',$(libdir))
1036 srcdir_SQ = $(subst ','\'',$(srcdir))
1038 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
1039 perfexec_instdir = $(perfexecdir)
1040 perf_include_instdir = $(perf_include_dir)
1041 perf_examples_instdir = $(perf_examples_dir)
1042 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
1043 tip_instdir = $(tipdir)
1045 perfexec_instdir = $(prefix)/$(perfexecdir)
1046 perf_include_instdir = $(prefix)/$(perf_include_dir)
1047 perf_examples_instdir = $(prefix)/$(perf_examples_dir)
1048 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
1049 tip_instdir = $(prefix)/$(tipdir)
1051 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
1052 perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))
1053 perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))
1054 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
1055 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
1057 # If we install to $(HOME) we keep the traceevent default:
1058 # $(HOME)/.traceevent/plugins
1059 # Otherwise we install plugins into the global $(libdir).
1061 plugindir=$(libdir)/traceevent/plugins
1062 plugindir_SQ= $(subst ','\'',$(plugindir))
1065 print_var = $(eval $(print_var_code)) $(info $(MSG))
1066 define print_var_code
1067 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
1071 # Display EXTRA features which are detected manualy
1072 # from here with feature_check call and thus cannot
1073 # be partof global state output.
1074 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),))
1075 $(call print_var,prefix)
1076 $(call print_var,bindir)
1077 $(call print_var,libdir)
1078 $(call print_var,sysconfdir)
1079 $(call print_var,LIBUNWIND_DIR)
1080 $(call print_var,LIBDW_DIR)
1081 $(call print_var,JDIR)
1083 ifeq ($(dwarf-post-unwind),1)
1084 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
1089 $(call detected_var,bindir_SQ)
1090 $(call detected_var,PYTHON_WORD)
1092 $(call detected_var,OUTPUT)
1094 $(call detected_var,htmldir_SQ)
1095 $(call detected_var,infodir_SQ)
1096 $(call detected_var,mandir_SQ)
1097 $(call detected_var,ETC_PERFCONFIG_SQ)
1098 $(call detected_var,STRACE_GROUPS_DIR_SQ)
1099 $(call detected_var,prefix_SQ)
1100 $(call detected_var,perfexecdir_SQ)
1101 $(call detected_var,perf_include_dir_SQ)
1102 $(call detected_var,perf_examples_dir_SQ)
1103 $(call detected_var,tipdir_SQ)
1104 $(call detected_var,srcdir_SQ)
1105 $(call detected_var,LIBDIR)
1106 $(call detected_var,GTK_CFLAGS)
1107 $(call detected_var,PERL_EMBED_CCOPTS)
1108 $(call detected_var,PYTHON_EMBED_CCOPTS)