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 ifeq ($(CC_NO_CLANG), 1)
192 PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
194 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
197 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
198 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
199 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
200 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
202 CFLAGS += -fno-omit-frame-pointer
204 CFLAGS += -funwind-tables
209 CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
211 CXXFLAGS += -fno-omit-frame-pointer
213 CXXFLAGS += -funwind-tables
214 CXXFLAGS += -Wno-strict-aliasing
216 # Enforce a non-executable stack, as we may regress (again) in the future by
217 # adding assembler files missing the .GNU-stack linker note.
218 LDFLAGS += -Wl,-z,noexecstack
220 EXTLIBS = -lpthread -lrt -lm -ldl
222 ifeq ($(FEATURES_DUMP),)
223 include $(srctree)/tools/build/Makefile.feature
225 include $(FEATURES_DUMP)
228 ifeq ($(feature-stackprotector-all), 1)
229 CFLAGS += -fstack-protector-all
233 ifeq ($(feature-fortify-source), 1)
234 CFLAGS += -D_FORTIFY_SOURCE=2
238 INC_FLAGS += -I$(src-perf)/util/include
239 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
240 INC_FLAGS += -I$(srctree)/tools/include/uapi
241 INC_FLAGS += -I$(srctree)/tools/include/
242 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
243 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
244 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
246 # $(obj-perf) for generated common-cmds.h
247 # $(obj-perf)/util for generated bison/flex headers
249 INC_FLAGS += -I$(obj-perf)/util
250 INC_FLAGS += -I$(obj-perf)
253 INC_FLAGS += -I$(src-perf)/util
254 INC_FLAGS += -I$(src-perf)
255 INC_FLAGS += -I$(srctree)/tools/lib/
257 CFLAGS += $(INC_FLAGS)
258 CXXFLAGS += $(INC_FLAGS)
260 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
262 ifeq ($(feature-sync-compare-and-swap), 1)
263 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
266 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
267 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
271 $(call feature_check,bionic)
272 ifeq ($(feature-bionic), 1)
274 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
275 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
283 NO_LIBDW_DWARF_UNWIND := 1
287 ifeq ($(feature-libelf), 0)
288 ifeq ($(feature-glibc), 1)
294 ifeq ($(LIBC_SUPPORT),1)
295 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);
301 NO_LIBDW_DWARF_UNWIND := 1
305 ifneq ($(filter s% -static%,$(LDFLAGS),),)
306 msg := $(error No static glibc found, please install glibc-static);
308 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
312 ifndef NO_LIBDW_DWARF_UNWIND
313 ifneq ($(feature-libdw-dwarf-unwind),1)
314 NO_LIBDW_DWARF_UNWIND := 1
315 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
318 ifneq ($(feature-dwarf), 1)
320 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);
324 ifneq ($(feature-dwarf_getlocations), 1)
325 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
327 CFLAGS += -DHAVE_DWARF_GETLOCATIONS
328 endif # dwarf_getlocations
329 endif # Dwarf support
330 endif # libelf support
334 NO_LIBDW_DWARF_UNWIND := 1
337 ifeq ($(feature-sched_getcpu), 1)
338 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
341 ifeq ($(feature-setns), 1)
342 CFLAGS += -DHAVE_SETNS_SUPPORT
343 $(call detected,CONFIG_SETNS)
347 CFLAGS += -DHAVE_LIBELF_SUPPORT
349 $(call detected,CONFIG_LIBELF)
351 ifeq ($(feature-libelf-mmap), 1)
352 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
355 ifeq ($(feature-libelf-getphdrnum), 1)
356 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
359 ifeq ($(feature-libelf-gelf_getnote), 1)
360 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
362 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
365 ifeq ($(feature-libelf-getshdrstrndx), 1)
366 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
370 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
371 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
374 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
375 LDFLAGS += $(LIBDW_LDFLAGS)
376 EXTLIBS += ${DWARFLIBS}
377 $(call detected,CONFIG_DWARF)
378 endif # PERF_HAVE_DWARF_REGS
382 ifeq ($(feature-bpf), 1)
383 CFLAGS += -DHAVE_LIBBPF_SUPPORT
384 $(call detected,CONFIG_LIBBPF)
388 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
389 CFLAGS += -DHAVE_BPF_PROLOGUE
390 $(call detected,CONFIG_BPF_PROLOGUE)
392 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
395 msg := $(warning DWARF support is off, BPF prologue is disabled);
402 ifneq ($(feature-sdt), 1)
403 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
406 CFLAGS += -DHAVE_SDT_EVENT
407 $(call detected,CONFIG_SDT_EVENT)
411 ifdef PERF_HAVE_JITDUMP
413 $(call detected,CONFIG_JITDUMP)
414 CFLAGS += -DHAVE_JITDUMP
418 ifeq ($(SRCARCH),powerpc)
420 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
427 ifeq ($(feature-libunwind-x86), 1)
428 $(call detected,CONFIG_LIBUNWIND_X86)
429 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
430 LDFLAGS += -lunwind-x86
431 EXTLIBS_LIBUNWIND += -lunwind-x86
435 ifeq ($(feature-libunwind-aarch64), 1)
436 $(call detected,CONFIG_LIBUNWIND_AARCH64)
437 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
438 LDFLAGS += -lunwind-aarch64
439 EXTLIBS_LIBUNWIND += -lunwind-aarch64
441 $(call feature_check,libunwind-debug-frame-aarch64)
442 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
443 msg := $(warning No debug_frame support found in libunwind-aarch64);
444 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
448 ifneq ($(feature-libunwind), 1)
449 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
450 NO_LOCAL_LIBUNWIND := 1
453 $(call detected,CONFIG_LOCAL_LIBUNWIND)
456 ifneq ($(have_libunwind), 1)
460 NO_LOCAL_LIBUNWIND := 1
464 ifneq ($(feature-bpf), 1)
465 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
470 dwarf-post-unwind := 1
471 dwarf-post-unwind-text := BUG
473 # setup DWARF post unwinder
475 ifdef NO_LIBDW_DWARF_UNWIND
476 msg := $(warning Disabling post unwind, no support found.);
477 dwarf-post-unwind := 0
479 dwarf-post-unwind-text := libdw
480 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
483 dwarf-post-unwind-text := libunwind
484 $(call detected,CONFIG_LIBUNWIND)
485 # Enable libunwind support by default.
486 ifndef NO_LIBDW_DWARF_UNWIND
487 NO_LIBDW_DWARF_UNWIND := 1
491 ifeq ($(dwarf-post-unwind),1)
492 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
493 $(call detected,CONFIG_DWARF_UNWIND)
498 ifndef NO_LOCAL_LIBUNWIND
499 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
500 $(call feature_check,libunwind-debug-frame)
501 ifneq ($(feature-libunwind-debug-frame), 1)
502 msg := $(warning No debug_frame support found in libunwind);
503 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
506 # non-ARM has no dwarf_find_debug_frame() function:
507 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
509 EXTLIBS += $(LIBUNWIND_LIBS)
510 LDFLAGS += $(LIBUNWIND_LIBS)
512 ifeq ($(findstring -static,${LDFLAGS}),-static)
513 # gcc -static links libgcc_eh which contans piece of libunwind
514 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
518 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
519 CFLAGS += $(LIBUNWIND_CFLAGS)
520 LDFLAGS += $(LIBUNWIND_LDFLAGS)
521 EXTLIBS += $(EXTLIBS_LIBUNWIND)
525 ifneq ($(feature-libaudit), 1)
526 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
529 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
531 $(call detected,CONFIG_AUDIT)
536 ifneq ($(feature-libcrypto), 1)
537 msg := $(warning No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev);
540 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
542 $(call detected,CONFIG_CRYPTO)
551 ifneq ($(feature-libslang), 1)
552 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
555 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
556 CFLAGS += -I/usr/include/slang
557 CFLAGS += -DHAVE_SLANG_SUPPORT
559 $(call detected,CONFIG_SLANG)
564 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
565 ifneq ($(feature-gtk2), 1)
566 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
569 ifeq ($(feature-gtk2-infobar), 1)
570 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
572 CFLAGS += -DHAVE_GTK2_SUPPORT
573 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
574 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
581 CFLAGS += -DNO_LIBPERL
583 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
584 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
585 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
586 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
587 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
589 ifneq ($(feature-libperl), 1)
590 CFLAGS += -DNO_LIBPERL
592 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
594 LDFLAGS += $(PERL_EMBED_LDFLAGS)
595 EXTLIBS += $(PERL_EMBED_LIBADD)
596 $(call detected,CONFIG_LIBPERL)
600 ifeq ($(feature-timerfd), 1)
601 CFLAGS += -DHAVE_TIMERFD_SUPPORT
603 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
606 disable-python = $(eval $(disable-python_code))
607 define disable-python_code
608 CFLAGS += -DNO_LIBPYTHON
614 $(call disable-python,Python support disabled by user)
618 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
620 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
623 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
626 ifneq ($(feature-libpython), 1)
627 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
629 ifneq ($(feature-libpython-version), 1)
630 $(warning Python 3 is not yet supported; please set)
631 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
632 $(warning If you also have Python 2 installed, then)
633 $(warning try something like:)
635 $(warning $(and ,) make PYTHON=python2)
637 $(warning Otherwise, disable Python support entirely:)
639 $(warning $(and ,) make NO_LIBPYTHON=1)
643 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
644 EXTLIBS += $(PYTHON_EMBED_LIBADD)
645 LANG_BINDINGS += $(obj-perf)python/perf.so
646 $(call detected,CONFIG_LIBPYTHON)
653 ifeq ($(feature-libbfd), 1)
656 # call all detections now so we get correct
657 # status in VF output
658 $(call feature_check,liberty)
659 $(call feature_check,liberty-z)
660 $(call feature_check,cplus-demangle)
662 ifeq ($(feature-liberty), 1)
665 ifeq ($(feature-liberty-z), 1)
666 EXTLIBS += -liberty -lz
672 CFLAGS += -DNO_DEMANGLE
674 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
676 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
678 ifneq ($(feature-libbfd), 1)
679 ifneq ($(feature-liberty), 1)
680 ifneq ($(feature-liberty-z), 1)
681 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
682 # or any of 'bfd iberty z' trinity
683 ifeq ($(feature-cplus-demangle), 1)
685 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
687 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
688 CFLAGS += -DNO_DEMANGLE
696 ifneq ($(filter -lbfd,$(EXTLIBS)),)
697 CFLAGS += -DHAVE_LIBBFD_SUPPORT
701 ifeq ($(feature-zlib), 1)
702 CFLAGS += -DHAVE_ZLIB_SUPPORT
704 $(call detected,CONFIG_ZLIB)
711 ifeq ($(feature-lzma), 1)
712 CFLAGS += -DHAVE_LZMA_SUPPORT
714 $(call detected,CONFIG_LZMA)
716 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
722 ifeq ($(feature-backtrace), 1)
723 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
728 ifeq ($(feature-libnuma), 0)
729 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
732 ifeq ($(feature-numa_num_possible_cpus), 0)
733 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
736 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
738 $(call detected,CONFIG_NUMA)
743 ifdef HAVE_KVM_STAT_SUPPORT
744 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
747 ifeq (${IS_64_BIT}, 1)
748 ifndef NO_PERF_READ_VDSO32
749 $(call feature_check,compile-32)
750 ifeq ($(feature-compile-32), 1)
751 CFLAGS += -DHAVE_PERF_READ_VDSO32
753 NO_PERF_READ_VDSO32 := 1
756 ifneq ($(SRCARCH), x86)
757 NO_PERF_READ_VDSOX32 := 1
759 ifndef NO_PERF_READ_VDSOX32
760 $(call feature_check,compile-x32)
761 ifeq ($(feature-compile-x32), 1)
762 CFLAGS += -DHAVE_PERF_READ_VDSOX32
764 NO_PERF_READ_VDSOX32 := 1
768 NO_PERF_READ_VDSO32 := 1
769 NO_PERF_READ_VDSOX32 := 1
773 $(call feature_check,libbabeltrace)
774 ifeq ($(feature-libbabeltrace), 1)
775 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
776 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
777 EXTLIBS += -lbabeltrace-ctf
778 $(call detected,CONFIG_LIBBABELTRACE)
780 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
785 ifeq ($(SRCARCH),x86)
786 ifeq ($(feature-get_cpuid), 0)
787 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
792 $(call detected,CONFIG_AUXTRACE)
793 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
798 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
799 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
801 ifneq (,$(wildcard /usr/sbin/alternatives))
802 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
806 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
812 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
813 $(call feature_check,jvmti)
814 ifeq ($(feature-jvmti), 1)
815 $(call detected_var,JDIR)
817 $(warning No openjdk development package found, please install JDK package)
825 $(call feature_check,cxx)
826 ifneq ($(feature-cxx), 1)
827 msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
829 $(call feature_check,llvm)
830 $(call feature_check,llvm-version)
831 ifneq ($(feature-llvm), 1)
832 msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
834 $(call feature_check,clang)
835 ifneq ($(feature-clang), 1)
836 msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
838 CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
839 CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
840 $(call detected,CONFIG_CXX)
841 $(call detected,CONFIG_CLANGLLVM)
845 ifneq ($(feature-llvm-version),1)
846 msg := $(warning This version of LLVM is not tested. May cause build errors)
853 # Among the variables below, these:
859 # ETC_PERFCONFIG (but not sysconfdir)
860 # can be specified as a relative path some/where/else;
861 # this is interpreted as relative to $(prefix) and "perf" at
862 # runtime figures out where they are based on the path to the executable.
863 # This can help installing the suite in a relocatable way.
865 # Make the path relative to DESTDIR, not to prefix
869 bindir_relative = bin
870 bindir = $(abspath $(prefix)/$(bindir_relative))
873 perfexecdir = libexec/perf-core
874 sharedir = $(prefix)/share
875 template_dir = share/perf-core/templates
876 STRACE_GROUPS_DIR = share/perf-core/strace/groups
877 htmldir = share/doc/perf-doc
878 tipdir = share/doc/perf-tip
879 srcdir = $(srctree)/tools/perf
880 ifeq ($(prefix),/usr)
882 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
884 sysconfdir = $(prefix)/etc
885 ETC_PERFCONFIG = etc/perfconfig
888 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
894 libdir = $(prefix)/$(lib)
896 # Shell quote (do not use $(call) to accommodate ancient setups);
897 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
898 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
899 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
900 bindir_SQ = $(subst ','\'',$(bindir))
901 mandir_SQ = $(subst ','\'',$(mandir))
902 infodir_SQ = $(subst ','\'',$(infodir))
903 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
904 template_dir_SQ = $(subst ','\'',$(template_dir))
905 htmldir_SQ = $(subst ','\'',$(htmldir))
906 tipdir_SQ = $(subst ','\'',$(tipdir))
907 prefix_SQ = $(subst ','\'',$(prefix))
908 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
909 libdir_SQ = $(subst ','\'',$(libdir))
910 srcdir_SQ = $(subst ','\'',$(srcdir))
912 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
913 perfexec_instdir = $(perfexecdir)
914 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
915 tip_instdir = $(tipdir)
917 perfexec_instdir = $(prefix)/$(perfexecdir)
918 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
919 tip_instdir = $(prefix)/$(tipdir)
921 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
922 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
923 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
925 # If we install to $(HOME) we keep the traceevent default:
926 # $(HOME)/.traceevent/plugins
927 # Otherwise we install plugins into the global $(libdir).
929 plugindir=$(libdir)/traceevent/plugins
930 plugindir_SQ= $(subst ','\'',$(plugindir))
933 print_var = $(eval $(print_var_code)) $(info $(MSG))
934 define print_var_code
935 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
939 $(call print_var,prefix)
940 $(call print_var,bindir)
941 $(call print_var,libdir)
942 $(call print_var,sysconfdir)
943 $(call print_var,LIBUNWIND_DIR)
944 $(call print_var,LIBDW_DIR)
945 $(call print_var,JDIR)
947 ifeq ($(dwarf-post-unwind),1)
948 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
953 $(call detected_var,bindir_SQ)
954 $(call detected_var,PYTHON_WORD)
956 $(call detected_var,OUTPUT)
958 $(call detected_var,htmldir_SQ)
959 $(call detected_var,infodir_SQ)
960 $(call detected_var,mandir_SQ)
961 $(call detected_var,ETC_PERFCONFIG_SQ)
962 $(call detected_var,STRACE_GROUPS_DIR_SQ)
963 $(call detected_var,prefix_SQ)
964 $(call detected_var,perfexecdir_SQ)
965 $(call detected_var,tipdir_SQ)
966 $(call detected_var,srcdir_SQ)
967 $(call detected_var,LIBDIR)
968 $(call detected_var,GTK_CFLAGS)
969 $(call detected_var,PERL_EMBED_CCOPTS)
970 $(call detected_var,PYTHON_EMBED_CCOPTS)