3 src-perf := $(srctree)/tools/perf
11 obj-perf := $(abspath $(obj-perf))/
14 $(shell printf "" > $(OUTPUT).config-detected)
15 detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
16 detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
18 CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
20 include $(srctree)/tools/scripts/Makefile.arch
22 $(call detected_var,SRCARCH)
26 # Additional ARCH settings for ppc
27 ifeq ($(SRCARCH),powerpc)
29 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
32 # Additional ARCH settings for x86
34 $(call detected,CONFIG_X86)
35 ifeq (${IS_64_BIT}, 1)
36 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE -I$(OUTPUT)arch/x86/include/generated
37 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
38 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
39 $(call detected,CONFIG_X86_64)
41 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
48 LIBUNWIND_LIBS = -lunwind -lunwind-arm
51 ifeq ($(SRCARCH),arm64)
53 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
60 ifeq ($(NO_PERF_REGS),0)
61 $(call detected,CONFIG_PERF_REGS)
64 # So far there's only x86 and arm libdw unwind support merged in perf.
65 # Disable it on all other architectures in case libdw unwind
66 # support is detected in system. Add supported architectures
68 ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm powerpc s390))
69 NO_LIBDW_DWARF_UNWIND := 1
72 ifeq ($(LIBUNWIND_LIBS),)
76 # For linking with debug library, run like:
78 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
81 libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
82 define libunwind_arch_set_flags_code
83 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
84 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib
88 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
89 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
90 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64
91 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
94 # Set per-feature check compilation flags
95 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
96 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
97 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
98 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
100 ifeq ($(NO_PERF_REGS),0)
101 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
104 # for linking with debug library, run like:
105 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
107 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
108 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
111 ifeq ($(findstring -static,${LDFLAGS}),-static)
112 DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
114 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
115 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
117 # for linking with debug library, run like:
118 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
119 ifdef LIBBABELTRACE_DIR
120 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
121 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
123 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
124 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
126 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
127 # include ARCH specific config
128 -include $(src-perf)/arch/$(SRCARCH)/Makefile
130 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
131 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
134 include $(srctree)/tools/scripts/utilities.mak
136 ifeq ($(call get-executable,$(FLEX)),)
137 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
140 ifeq ($(call get-executable,$(BISON)),)
141 dummy := $(error Error: $(BISON) is missing on this system, please install it)
144 # Treat warnings as errors unless directed not to
155 ifeq ($(CC_NO_CLANG), 0)
163 PARSER_DEBUG_BISON := -t
164 PARSER_DEBUG_FLEX := -d
165 CFLAGS += -DPARSER_DEBUG
166 $(call detected_var,PARSER_DEBUG_BISON)
167 $(call detected_var,PARSER_DEBUG_FLEX)
170 # Try different combinations to accommodate systems that only have
171 # python[2][-config] in weird combinations but always preferring
172 # python2 and python2-config as per pep-0394. If we catch a
173 # python[-config] in version 3, the version check will kill it.
174 PYTHON2 := $(if $(call get-executable,python2),python2,python)
175 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
177 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
178 override PYTHON_CONFIG := \
179 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
181 grep-libs = $(filter -l%,$(1))
182 strip-libs = $(filter-out -l%,$(1))
184 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
187 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
188 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
189 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
190 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
191 PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
192 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
195 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
196 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
197 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
198 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
200 CFLAGS += -fno-omit-frame-pointer
202 CFLAGS += -funwind-tables
207 CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
209 CXXFLAGS += -fno-omit-frame-pointer
211 CXXFLAGS += -funwind-tables
212 CXXFLAGS += -Wno-strict-aliasing
214 # Enforce a non-executable stack, as we may regress (again) in the future by
215 # adding assembler files missing the .GNU-stack linker note.
216 LDFLAGS += -Wl,-z,noexecstack
218 EXTLIBS = -lpthread -lrt -lm -ldl
220 ifeq ($(FEATURES_DUMP),)
221 include $(srctree)/tools/build/Makefile.feature
223 include $(FEATURES_DUMP)
226 ifeq ($(feature-stackprotector-all), 1)
227 CFLAGS += -fstack-protector-all
231 ifeq ($(feature-fortify-source), 1)
232 CFLAGS += -D_FORTIFY_SOURCE=2
236 INC_FLAGS += -I$(src-perf)/util/include
237 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
238 INC_FLAGS += -I$(srctree)/tools/include/uapi
239 INC_FLAGS += -I$(srctree)/tools/include/
240 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
241 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
242 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
244 # $(obj-perf) for generated common-cmds.h
245 # $(obj-perf)/util for generated bison/flex headers
247 INC_FLAGS += -I$(obj-perf)/util
248 INC_FLAGS += -I$(obj-perf)
251 INC_FLAGS += -I$(src-perf)/util
252 INC_FLAGS += -I$(src-perf)
253 INC_FLAGS += -I$(srctree)/tools/lib/
255 CFLAGS += $(INC_FLAGS)
256 CXXFLAGS += $(INC_FLAGS)
258 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
260 ifeq ($(feature-sync-compare-and-swap), 1)
261 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
264 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
265 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
269 $(call feature_check,bionic)
270 ifeq ($(feature-bionic), 1)
272 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
273 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
281 NO_LIBDW_DWARF_UNWIND := 1
285 ifeq ($(feature-libelf), 0)
286 ifeq ($(feature-glibc), 1)
292 ifeq ($(LIBC_SUPPORT),1)
293 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);
299 NO_LIBDW_DWARF_UNWIND := 1
303 ifneq ($(filter s% -static%,$(LDFLAGS),),)
304 msg := $(error No static glibc found, please install glibc-static);
306 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
310 ifndef NO_LIBDW_DWARF_UNWIND
311 ifneq ($(feature-libdw-dwarf-unwind),1)
312 NO_LIBDW_DWARF_UNWIND := 1
313 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
316 ifneq ($(feature-dwarf), 1)
318 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);
322 ifneq ($(feature-dwarf_getlocations), 1)
323 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
325 CFLAGS += -DHAVE_DWARF_GETLOCATIONS
326 endif # dwarf_getlocations
327 endif # Dwarf support
328 endif # libelf support
332 NO_LIBDW_DWARF_UNWIND := 1
335 ifeq ($(feature-sched_getcpu), 1)
336 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
339 ifeq ($(feature-setns), 1)
340 CFLAGS += -DHAVE_SETNS_SUPPORT
341 $(call detected,CONFIG_SETNS)
345 CFLAGS += -DHAVE_LIBELF_SUPPORT
347 $(call detected,CONFIG_LIBELF)
349 ifeq ($(feature-libelf-mmap), 1)
350 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
353 ifeq ($(feature-libelf-getphdrnum), 1)
354 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
357 ifeq ($(feature-libelf-gelf_getnote), 1)
358 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
360 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
363 ifeq ($(feature-libelf-getshdrstrndx), 1)
364 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
368 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
369 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
372 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
373 LDFLAGS += $(LIBDW_LDFLAGS)
374 EXTLIBS += ${DWARFLIBS}
375 $(call detected,CONFIG_DWARF)
376 endif # PERF_HAVE_DWARF_REGS
380 ifeq ($(feature-bpf), 1)
381 CFLAGS += -DHAVE_LIBBPF_SUPPORT
382 $(call detected,CONFIG_LIBBPF)
386 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
387 CFLAGS += -DHAVE_BPF_PROLOGUE
388 $(call detected,CONFIG_BPF_PROLOGUE)
390 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
393 msg := $(warning DWARF support is off, BPF prologue is disabled);
400 ifneq ($(feature-sdt), 1)
401 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
404 CFLAGS += -DHAVE_SDT_EVENT
405 $(call detected,CONFIG_SDT_EVENT)
409 ifdef PERF_HAVE_JITDUMP
411 $(call detected,CONFIG_JITDUMP)
412 CFLAGS += -DHAVE_JITDUMP
416 ifeq ($(SRCARCH),powerpc)
418 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
425 ifeq ($(feature-libunwind-x86), 1)
426 $(call detected,CONFIG_LIBUNWIND_X86)
427 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
428 LDFLAGS += -lunwind-x86
429 EXTLIBS_LIBUNWIND += -lunwind-x86
433 ifeq ($(feature-libunwind-aarch64), 1)
434 $(call detected,CONFIG_LIBUNWIND_AARCH64)
435 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
436 LDFLAGS += -lunwind-aarch64
437 EXTLIBS_LIBUNWIND += -lunwind-aarch64
439 $(call feature_check,libunwind-debug-frame-aarch64)
440 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
441 msg := $(warning No debug_frame support found in libunwind-aarch64);
442 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
446 ifneq ($(feature-libunwind), 1)
447 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
448 NO_LOCAL_LIBUNWIND := 1
451 $(call detected,CONFIG_LOCAL_LIBUNWIND)
454 ifneq ($(have_libunwind), 1)
458 NO_LOCAL_LIBUNWIND := 1
462 ifneq ($(feature-bpf), 1)
463 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
468 dwarf-post-unwind := 1
469 dwarf-post-unwind-text := BUG
471 # setup DWARF post unwinder
473 ifdef NO_LIBDW_DWARF_UNWIND
474 msg := $(warning Disabling post unwind, no support found.);
475 dwarf-post-unwind := 0
477 dwarf-post-unwind-text := libdw
478 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
481 dwarf-post-unwind-text := libunwind
482 $(call detected,CONFIG_LIBUNWIND)
483 # Enable libunwind support by default.
484 ifndef NO_LIBDW_DWARF_UNWIND
485 NO_LIBDW_DWARF_UNWIND := 1
489 ifeq ($(dwarf-post-unwind),1)
490 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
491 $(call detected,CONFIG_DWARF_UNWIND)
496 ifndef NO_LOCAL_LIBUNWIND
497 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
498 $(call feature_check,libunwind-debug-frame)
499 ifneq ($(feature-libunwind-debug-frame), 1)
500 msg := $(warning No debug_frame support found in libunwind);
501 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
504 # non-ARM has no dwarf_find_debug_frame() function:
505 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
507 EXTLIBS += $(LIBUNWIND_LIBS)
508 LDFLAGS += $(LIBUNWIND_LIBS)
510 ifeq ($(findstring -static,${LDFLAGS}),-static)
511 # gcc -static links libgcc_eh which contans piece of libunwind
512 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
516 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
517 CFLAGS += $(LIBUNWIND_CFLAGS)
518 LDFLAGS += $(LIBUNWIND_LDFLAGS)
519 EXTLIBS += $(EXTLIBS_LIBUNWIND)
523 ifneq ($(feature-libaudit), 1)
524 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
527 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
529 $(call detected,CONFIG_AUDIT)
534 ifneq ($(feature-libcrypto), 1)
535 msg := $(warning No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev);
538 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
540 $(call detected,CONFIG_CRYPTO)
549 ifneq ($(feature-libslang), 1)
550 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
553 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
554 CFLAGS += -I/usr/include/slang
555 CFLAGS += -DHAVE_SLANG_SUPPORT
557 $(call detected,CONFIG_SLANG)
562 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
563 ifneq ($(feature-gtk2), 1)
564 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
567 ifeq ($(feature-gtk2-infobar), 1)
568 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
570 CFLAGS += -DHAVE_GTK2_SUPPORT
571 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
572 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
578 CFLAGS += -DNO_LIBPERL
580 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
581 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
582 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
583 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
584 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
585 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
586 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
588 ifneq ($(feature-libperl), 1)
589 CFLAGS += -DNO_LIBPERL
591 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
593 LDFLAGS += $(PERL_EMBED_LDFLAGS)
594 EXTLIBS += $(PERL_EMBED_LIBADD)
595 $(call detected,CONFIG_LIBPERL)
599 ifeq ($(feature-timerfd), 1)
600 CFLAGS += -DHAVE_TIMERFD_SUPPORT
602 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
605 disable-python = $(eval $(disable-python_code))
606 define disable-python_code
607 CFLAGS += -DNO_LIBPYTHON
613 $(call disable-python,Python support disabled by user)
617 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
619 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
622 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
625 ifneq ($(feature-libpython), 1)
626 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
628 ifneq ($(feature-libpython-version), 1)
629 $(warning Python 3 is not yet supported; please set)
630 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
631 $(warning If you also have Python 2 installed, then)
632 $(warning try something like:)
634 $(warning $(and ,) make PYTHON=python2)
636 $(warning Otherwise, disable Python support entirely:)
638 $(warning $(and ,) make NO_LIBPYTHON=1)
642 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
643 EXTLIBS += $(PYTHON_EMBED_LIBADD)
644 LANG_BINDINGS += $(obj-perf)python/perf.so
645 $(call detected,CONFIG_LIBPYTHON)
652 ifeq ($(feature-libbfd), 1)
655 # call all detections now so we get correct
656 # status in VF output
657 $(call feature_check,liberty)
658 $(call feature_check,liberty-z)
659 $(call feature_check,cplus-demangle)
661 ifeq ($(feature-liberty), 1)
664 ifeq ($(feature-liberty-z), 1)
665 EXTLIBS += -liberty -lz
671 CFLAGS += -DNO_DEMANGLE
673 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
675 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
677 ifneq ($(feature-libbfd), 1)
678 ifneq ($(feature-liberty), 1)
679 ifneq ($(feature-liberty-z), 1)
680 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
681 # or any of 'bfd iberty z' trinity
682 ifeq ($(feature-cplus-demangle), 1)
684 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
686 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
687 CFLAGS += -DNO_DEMANGLE
695 ifneq ($(filter -lbfd,$(EXTLIBS)),)
696 CFLAGS += -DHAVE_LIBBFD_SUPPORT
700 ifeq ($(feature-zlib), 1)
701 CFLAGS += -DHAVE_ZLIB_SUPPORT
703 $(call detected,CONFIG_ZLIB)
710 ifeq ($(feature-lzma), 1)
711 CFLAGS += -DHAVE_LZMA_SUPPORT
713 $(call detected,CONFIG_LZMA)
715 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
721 ifeq ($(feature-backtrace), 1)
722 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
727 ifeq ($(feature-libnuma), 0)
728 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
731 ifeq ($(feature-numa_num_possible_cpus), 0)
732 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
735 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
737 $(call detected,CONFIG_NUMA)
742 ifdef HAVE_KVM_STAT_SUPPORT
743 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
746 ifeq (${IS_64_BIT}, 1)
747 ifndef NO_PERF_READ_VDSO32
748 $(call feature_check,compile-32)
749 ifeq ($(feature-compile-32), 1)
750 CFLAGS += -DHAVE_PERF_READ_VDSO32
752 NO_PERF_READ_VDSO32 := 1
755 ifneq ($(SRCARCH), x86)
756 NO_PERF_READ_VDSOX32 := 1
758 ifndef NO_PERF_READ_VDSOX32
759 $(call feature_check,compile-x32)
760 ifeq ($(feature-compile-x32), 1)
761 CFLAGS += -DHAVE_PERF_READ_VDSOX32
763 NO_PERF_READ_VDSOX32 := 1
767 NO_PERF_READ_VDSO32 := 1
768 NO_PERF_READ_VDSOX32 := 1
772 $(call feature_check,libbabeltrace)
773 ifeq ($(feature-libbabeltrace), 1)
774 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
775 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
776 EXTLIBS += -lbabeltrace-ctf
777 $(call detected,CONFIG_LIBBABELTRACE)
779 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
784 ifeq ($(SRCARCH),x86)
785 ifeq ($(feature-get_cpuid), 0)
786 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
791 $(call detected,CONFIG_AUXTRACE)
792 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
797 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
798 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
800 ifneq (,$(wildcard /usr/sbin/alternatives))
801 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
805 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
811 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
812 $(call feature_check,jvmti)
813 ifeq ($(feature-jvmti), 1)
814 $(call detected_var,JDIR)
816 $(warning No openjdk development package found, please install JDK package)
824 $(call feature_check,cxx)
825 ifneq ($(feature-cxx), 1)
826 msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
828 $(call feature_check,llvm)
829 $(call feature_check,llvm-version)
830 ifneq ($(feature-llvm), 1)
831 msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
833 $(call feature_check,clang)
834 ifneq ($(feature-clang), 1)
835 msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
837 CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
838 CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
839 $(call detected,CONFIG_CXX)
840 $(call detected,CONFIG_CLANGLLVM)
844 ifneq ($(feature-llvm-version),1)
845 msg := $(warning This version of LLVM is not tested. May cause build errors)
852 # Among the variables below, these:
858 # ETC_PERFCONFIG (but not sysconfdir)
859 # can be specified as a relative path some/where/else;
860 # this is interpreted as relative to $(prefix) and "perf" at
861 # runtime figures out where they are based on the path to the executable.
862 # This can help installing the suite in a relocatable way.
864 # Make the path relative to DESTDIR, not to prefix
868 bindir_relative = bin
869 bindir = $(abspath $(prefix)/$(bindir_relative))
872 perfexecdir = libexec/perf-core
873 sharedir = $(prefix)/share
874 template_dir = share/perf-core/templates
875 STRACE_GROUPS_DIR = share/perf-core/strace/groups
876 htmldir = share/doc/perf-doc
877 tipdir = share/doc/perf-tip
878 srcdir = $(srctree)/tools/perf
879 ifeq ($(prefix),/usr)
881 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
883 sysconfdir = $(prefix)/etc
884 ETC_PERFCONFIG = etc/perfconfig
887 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
893 libdir = $(prefix)/$(lib)
895 # Shell quote (do not use $(call) to accommodate ancient setups);
896 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
897 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
898 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
899 bindir_SQ = $(subst ','\'',$(bindir))
900 mandir_SQ = $(subst ','\'',$(mandir))
901 infodir_SQ = $(subst ','\'',$(infodir))
902 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
903 template_dir_SQ = $(subst ','\'',$(template_dir))
904 htmldir_SQ = $(subst ','\'',$(htmldir))
905 tipdir_SQ = $(subst ','\'',$(tipdir))
906 prefix_SQ = $(subst ','\'',$(prefix))
907 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
908 libdir_SQ = $(subst ','\'',$(libdir))
909 srcdir_SQ = $(subst ','\'',$(srcdir))
911 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
912 perfexec_instdir = $(perfexecdir)
913 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
914 tip_instdir = $(tipdir)
916 perfexec_instdir = $(prefix)/$(perfexecdir)
917 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
918 tip_instdir = $(prefix)/$(tipdir)
920 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
921 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
922 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
924 # If we install to $(HOME) we keep the traceevent default:
925 # $(HOME)/.traceevent/plugins
926 # Otherwise we install plugins into the global $(libdir).
928 plugindir=$(libdir)/traceevent/plugins
929 plugindir_SQ= $(subst ','\'',$(plugindir))
932 print_var = $(eval $(print_var_code)) $(info $(MSG))
933 define print_var_code
934 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
938 $(call print_var,prefix)
939 $(call print_var,bindir)
940 $(call print_var,libdir)
941 $(call print_var,sysconfdir)
942 $(call print_var,LIBUNWIND_DIR)
943 $(call print_var,LIBDW_DIR)
944 $(call print_var,JDIR)
946 ifeq ($(dwarf-post-unwind),1)
947 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
952 $(call detected_var,bindir_SQ)
953 $(call detected_var,PYTHON_WORD)
955 $(call detected_var,OUTPUT)
957 $(call detected_var,htmldir_SQ)
958 $(call detected_var,infodir_SQ)
959 $(call detected_var,mandir_SQ)
960 $(call detected_var,ETC_PERFCONFIG_SQ)
961 $(call detected_var,STRACE_GROUPS_DIR_SQ)
962 $(call detected_var,prefix_SQ)
963 $(call detected_var,perfexecdir_SQ)
964 $(call detected_var,tipdir_SQ)
965 $(call detected_var,srcdir_SQ)
966 $(call detected_var,LIBDIR)
967 $(call detected_var,GTK_CFLAGS)
968 $(call detected_var,PERL_EMBED_CCOPTS)
969 $(call detected_var,PYTHON_EMBED_CCOPTS)