3 src-perf := $(srctree)/tools/perf
11 obj-perf := $(abspath $(obj-perf))/
14 $(shell echo -n > .config-detected)
15 detected = $(shell echo "$(1)=y" >> .config-detected)
16 detected_var = $(shell echo "$(1)=$($(1))" >> .config-detected)
18 LIB_INCLUDE := $(srctree)/tools/lib/
19 CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
21 include $(src-perf)/config/Makefile.arch
23 $(call detected_var,ARCH)
27 # Additional ARCH settings for x86
29 $(call detected,CONFIG_X86)
30 ifeq (${IS_64_BIT}, 1)
31 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
32 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
33 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
34 $(call detected,CONFIG_X86_64)
36 LIBUNWIND_LIBS = -lunwind -lunwind-x86
43 LIBUNWIND_LIBS = -lunwind -lunwind-arm
48 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
51 ifeq ($(NO_PERF_REGS),0)
52 $(call detected,CONFIG_PERF_REGS)
55 # So far there's only x86 and arm libdw unwind support merged in perf.
56 # Disable it on all other architectures in case libdw unwind
57 # support is detected in system. Add supported architectures
59 ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
60 NO_LIBDW_DWARF_UNWIND := 1
63 ifeq ($(LIBUNWIND_LIBS),)
67 # For linking with debug library, run like:
69 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
72 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
73 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
75 LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
77 # Set per-feature check compilation flags
78 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
79 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
80 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
81 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
84 ifeq ($(NO_PERF_REGS),0)
85 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
89 # for linking with debug library, run like:
90 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
92 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
93 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
95 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
96 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
99 ifndef NO_LIBBABELTRACE
100 # for linking with debug library, run like:
101 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
102 ifdef LIBBABELTRACE_DIR
103 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
104 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
106 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
107 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
110 # include ARCH specific config
111 -include $(src-perf)/arch/$(ARCH)/Makefile
113 include $(src-perf)/config/utilities.mak
115 ifeq ($(call get-executable,$(FLEX)),)
116 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
119 ifeq ($(call get-executable,$(BISON)),)
120 dummy := $(error Error: $(BISON) is missing on this system, please install it)
123 # Treat warnings as errors unless directed not to
137 PARSER_DEBUG_BISON := -t
138 PARSER_DEBUG_FLEX := -d
139 CFLAGS += -DPARSER_DEBUG
140 $(call detected_var,PARSER_DEBUG_BISON)
141 $(call detected_var,PARSER_DEBUG_FLEX)
145 # Try different combinations to accommodate systems that only have
146 # python[2][-config] in weird combinations but always preferring
147 # python2 and python2-config as per pep-0394. If we catch a
148 # python[-config] in version 3, the version check will kill it.
149 PYTHON2 := $(if $(call get-executable,python2),python2,python)
150 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
152 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
153 override PYTHON_CONFIG := \
154 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
156 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
158 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
159 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
161 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
162 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
163 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
164 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
167 CFLAGS += -fno-omit-frame-pointer
169 CFLAGS += -funwind-tables
174 # Enforce a non-executable stack, as we may regress (again) in the future by
175 # adding assembler files missing the .GNU-stack linker note.
176 LDFLAGS += -Wl,-z,noexecstack
178 EXTLIBS = -lpthread -lrt -lm -ldl
181 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
182 $(shell mkdir -p $(OUTPUT_FEATURES))
185 feature_check = $(eval $(feature_check_code))
186 define feature_check_code
187 feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
190 feature_set = $(eval $(feature_set_code))
191 define feature_set_code
196 # Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
200 # Note that this is not a complete list of all feature tests, just
201 # those that are typically built on a fully configured system.
203 # [ Feature tests not mentioned here have to be built explicitly in
204 # the rule that uses them - an example for that is the 'bionic'
207 CORE_FEATURE_TESTS = \
211 sync-compare-and-swap \
226 pthread-attr-setaffinity-np \
233 LIB_FEATURE_TESTS = \
252 sync-compare-and-swap \
257 pthread-attr-setaffinity-np \
260 libunwind-debug-frame \
268 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
269 # If in the future we need per-feature checks/flags for features not
270 # mentioned in this list we need to refactor this ;-).
271 set_test_all_flags = $(eval $(set_test_all_flags_code))
272 define set_test_all_flags_code
273 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
274 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
277 $(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
280 # Special fast-path for the 'all features are available' case:
282 $(call feature_check,all,$(MSG))
285 # Just in case the build freshly failed, make sure we print the
288 ifeq ($(feature-all), 1)
290 # test-all.c passed - just set all the core feature flags to 1:
292 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
294 $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(CORE_FEATURE_TESTS)) >/dev/null 2>&1)
295 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
298 ifeq ($(feature-stackprotector-all), 1)
299 CFLAGS += -fstack-protector-all
303 ifeq ($(feature-fortify-source), 1)
304 CFLAGS += -D_FORTIFY_SOURCE=2
308 CFLAGS += -I$(src-perf)/util/include
309 CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
310 CFLAGS += -I$(srctree)/tools/include/
311 CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
312 CFLAGS += -I$(srctree)/arch/$(ARCH)/include
313 CFLAGS += -I$(srctree)/include/uapi
314 CFLAGS += -I$(srctree)/include
316 # $(obj-perf) for generated common-cmds.h
317 # $(obj-perf)/util for generated bison/flex headers
319 CFLAGS += -I$(obj-perf)/util
320 CFLAGS += -I$(obj-perf)
323 CFLAGS += -I$(src-perf)/util
324 CFLAGS += -I$(src-perf)
325 CFLAGS += -I$(LIB_INCLUDE)
327 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
329 ifeq ($(feature-sync-compare-and-swap), 1)
330 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
333 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
334 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
338 $(call feature_check,bionic)
339 ifeq ($(feature-bionic), 1)
341 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
342 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
350 NO_LIBDW_DWARF_UNWIND := 1
352 ifeq ($(feature-libelf), 0)
353 ifeq ($(feature-glibc), 1)
359 ifeq ($(LIBC_SUPPORT),1)
360 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
366 NO_LIBDW_DWARF_UNWIND := 1
368 ifneq ($(filter s% -static%,$(LDFLAGS),),)
369 msg := $(error No static glibc found, please install glibc-static);
371 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
375 ifndef NO_LIBDW_DWARF_UNWIND
376 ifneq ($(feature-libdw-dwarf-unwind),1)
377 NO_LIBDW_DWARF_UNWIND := 1
378 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
381 ifneq ($(feature-dwarf), 1)
382 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);
384 endif # Dwarf support
385 endif # libelf support
389 CFLAGS += -DHAVE_LIBELF_SUPPORT
391 $(call detected,CONFIG_LIBELF)
393 ifeq ($(feature-libelf-mmap), 1)
394 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
397 ifeq ($(feature-libelf-getphdrnum), 1)
398 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
401 # include ARCH specific config
402 -include $(src-perf)/arch/$(ARCH)/Makefile
405 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
406 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
409 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
410 LDFLAGS += $(LIBDW_LDFLAGS)
412 $(call detected,CONFIG_DWARF)
413 endif # PERF_HAVE_DWARF_REGS
417 ifeq ($(ARCH),powerpc)
419 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
424 ifneq ($(feature-libunwind), 1)
425 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
430 dwarf-post-unwind := 1
431 dwarf-post-unwind-text := BUG
433 # setup DWARF post unwinder
435 ifdef NO_LIBDW_DWARF_UNWIND
436 msg := $(warning Disabling post unwind, no support found.);
437 dwarf-post-unwind := 0
439 dwarf-post-unwind-text := libdw
440 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
443 dwarf-post-unwind-text := libunwind
444 $(call detected,CONFIG_LIBUNWIND)
445 # Enable libunwind support by default.
446 ifndef NO_LIBDW_DWARF_UNWIND
447 NO_LIBDW_DWARF_UNWIND := 1
451 ifeq ($(dwarf-post-unwind),1)
452 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
453 $(call detected,CONFIG_DWARF_UNWIND)
459 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
460 $(call feature_check,libunwind-debug-frame)
461 ifneq ($(feature-libunwind-debug-frame), 1)
462 msg := $(warning No debug_frame support found in libunwind);
463 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
466 # non-ARM has no dwarf_find_debug_frame() function:
467 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
469 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
470 EXTLIBS += $(LIBUNWIND_LIBS)
471 CFLAGS += $(LIBUNWIND_CFLAGS)
472 LDFLAGS += $(LIBUNWIND_LDFLAGS)
476 ifneq ($(feature-libaudit), 1)
477 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
480 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
482 $(call detected,CONFIG_AUDIT)
491 ifneq ($(feature-libslang), 1)
492 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
495 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
496 CFLAGS += -I/usr/include/slang
497 CFLAGS += -DHAVE_SLANG_SUPPORT
499 $(call detected,CONFIG_SLANG)
504 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
505 ifneq ($(feature-gtk2), 1)
506 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
509 ifeq ($(feature-gtk2-infobar), 1)
510 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
512 CFLAGS += -DHAVE_GTK2_SUPPORT
513 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
514 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
519 grep-libs = $(filter -l%,$(1))
520 strip-libs = $(filter-out -l%,$(1))
523 CFLAGS += -DNO_LIBPERL
525 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
526 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
527 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
528 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
529 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
531 ifneq ($(feature-libperl), 1)
532 CFLAGS += -DNO_LIBPERL
534 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
536 LDFLAGS += $(PERL_EMBED_LDFLAGS)
537 EXTLIBS += $(PERL_EMBED_LIBADD)
538 $(call detected,CONFIG_LIBPERL)
542 ifeq ($(feature-timerfd), 1)
543 CFLAGS += -DHAVE_TIMERFD_SUPPORT
545 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
548 disable-python = $(eval $(disable-python_code))
549 define disable-python_code
550 CFLAGS += -DNO_LIBPYTHON
556 $(call disable-python,Python support disabled by user)
560 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
562 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
565 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
568 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
570 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
571 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
572 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
573 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
574 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
576 ifneq ($(feature-libpython), 1)
577 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
580 ifneq ($(feature-libpython-version), 1)
581 $(warning Python 3 is not yet supported; please set)
582 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
583 $(warning If you also have Python 2 installed, then)
584 $(warning try something like:)
586 $(warning $(and ,) make PYTHON=python2)
588 $(warning Otherwise, disable Python support entirely:)
590 $(warning $(and ,) make NO_LIBPYTHON=1)
594 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
595 EXTLIBS += $(PYTHON_EMBED_LIBADD)
596 LANG_BINDINGS += $(obj-perf)python/perf.so
597 $(call detected,CONFIG_LIBPYTHON)
604 ifeq ($(feature-libbfd), 1)
607 # call all detections now so we get correct
608 # status in VF output
609 $(call feature_check,liberty)
610 $(call feature_check,liberty-z)
611 $(call feature_check,cplus-demangle)
613 ifeq ($(feature-liberty), 1)
616 ifeq ($(feature-liberty-z), 1)
617 EXTLIBS += -liberty -lz
623 CFLAGS += -DNO_DEMANGLE
625 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
627 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
629 ifneq ($(feature-libbfd), 1)
630 ifneq ($(feature-liberty), 1)
631 ifneq ($(feature-liberty-z), 1)
632 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
633 # or any of 'bfd iberty z' trinity
634 ifeq ($(feature-cplus-demangle), 1)
636 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
638 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
639 CFLAGS += -DNO_DEMANGLE
647 ifneq ($(filter -lbfd,$(EXTLIBS)),)
648 CFLAGS += -DHAVE_LIBBFD_SUPPORT
652 ifeq ($(feature-zlib), 1)
653 CFLAGS += -DHAVE_ZLIB_SUPPORT
655 $(call detected,CONFIG_ZLIB)
662 ifeq ($(feature-backtrace), 1)
663 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
668 ifeq ($(feature-libnuma), 0)
669 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
672 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
674 $(call detected,CONFIG_NUMA)
678 ifdef HAVE_KVM_STAT_SUPPORT
679 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
682 ifeq (${IS_64_BIT}, 1)
683 ifndef NO_PERF_READ_VDSO32
684 $(call feature_check,compile-32)
685 ifeq ($(feature-compile-32), 1)
686 CFLAGS += -DHAVE_PERF_READ_VDSO32
688 NO_PERF_READ_VDSO32 := 1
691 ifneq (${IS_X86_64}, 1)
692 NO_PERF_READ_VDSOX32 := 1
694 ifndef NO_PERF_READ_VDSOX32
695 $(call feature_check,compile-x32)
696 ifeq ($(feature-compile-x32), 1)
697 CFLAGS += -DHAVE_PERF_READ_VDSOX32
699 NO_PERF_READ_VDSOX32 := 1
703 NO_PERF_READ_VDSO32 := 1
704 NO_PERF_READ_VDSOX32 := 1
707 ifndef NO_LIBBABELTRACE
708 ifeq ($(feature-libbabeltrace), 0)
709 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-devel/libbabeltrace-ctf-dev);
710 NO_LIBBABELTRACE := 1
712 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
713 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
714 EXTLIBS += -lbabeltrace-ctf
715 $(call detected,CONFIG_LIBBABELTRACE)
719 # Among the variables below, these:
725 # ETC_PERFCONFIG (but not sysconfdir)
726 # can be specified as a relative path some/where/else;
727 # this is interpreted as relative to $(prefix) and "perf" at
728 # runtime figures out where they are based on the path to the executable.
729 # This can help installing the suite in a relocatable way.
731 # Make the path relative to DESTDIR, not to prefix
735 bindir_relative = bin
736 bindir = $(prefix)/$(bindir_relative)
739 perfexecdir = libexec/perf-core
740 sharedir = $(prefix)/share
741 template_dir = share/perf-core/templates
742 htmldir = share/doc/perf-doc
743 ifeq ($(prefix),/usr)
745 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
747 sysconfdir = $(prefix)/etc
748 ETC_PERFCONFIG = etc/perfconfig
751 ifeq ($(IS_X86_64),1)
757 libdir = $(prefix)/$(lib)
759 # Shell quote (do not use $(call) to accommodate ancient setups);
760 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
761 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
762 bindir_SQ = $(subst ','\'',$(bindir))
763 mandir_SQ = $(subst ','\'',$(mandir))
764 infodir_SQ = $(subst ','\'',$(infodir))
765 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
766 template_dir_SQ = $(subst ','\'',$(template_dir))
767 htmldir_SQ = $(subst ','\'',$(htmldir))
768 prefix_SQ = $(subst ','\'',$(prefix))
769 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
770 libdir_SQ = $(subst ','\'',$(libdir))
772 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
773 perfexec_instdir = $(perfexecdir)
775 perfexec_instdir = $(prefix)/$(perfexecdir)
777 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
779 # If we install to $(HOME) we keep the traceevent default:
780 # $(HOME)/.traceevent/plugins
781 # Otherwise we install plugins into the global $(libdir).
783 plugindir=$(libdir)/traceevent/plugins
784 plugindir_SQ= $(subst ','\'',$(plugindir))
788 # Print the result of the feature test:
790 feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
792 define feature_print_status_code
793 ifeq ($(feature-$(1)), 1)
794 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
796 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
800 feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
801 define feature_print_var_code
802 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
805 feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
806 define feature_print_text_code
807 MSG = $(shell printf '...%30s: %s' $(1) $(2))
810 PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
811 PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
813 ifeq ($(dwarf-post-unwind),1)
814 PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
817 # The $(display_lib) controls the default detection message
818 # output. It's set if:
819 # - detected features differes from stored features from
820 # last build (in PERF-FEATURES file)
821 # - one of the $(LIB_FEATURE_TESTS) is not detected
824 ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
825 $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
829 feature_check = $(eval $(feature_check_code))
830 define feature_check_code
831 ifneq ($(feature-$(1)), 1)
836 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
843 ifeq ($(display_lib),1)
845 $(info Auto-detecting system features:)
846 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
848 ifeq ($(dwarf-post-unwind),1)
849 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
853 ifeq ($(display_vf),1)
854 $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
856 $(call feature_print_var,prefix)
857 $(call feature_print_var,bindir)
858 $(call feature_print_var,libdir)
859 $(call feature_print_var,sysconfdir)
860 $(call feature_print_var,LIBUNWIND_DIR)
861 $(call feature_print_var,LIBDW_DIR)
864 ifeq ($(display_lib),1)
868 $(call detected_var,bindir_SQ)
869 $(call detected_var,PYTHON_WORD)
871 $(call detected_var,OUTPUT)
873 $(call detected_var,htmldir_SQ)
874 $(call detected_var,infodir_SQ)
875 $(call detected_var,mandir_SQ)
876 $(call detected_var,ETC_PERFCONFIG_SQ)
877 $(call detected_var,prefix_SQ)
878 $(call detected_var,perfexecdir_SQ)
879 $(call detected_var,LIBDIR)
880 $(call detected_var,GTK_CFLAGS)
881 $(call detected_var,PERL_EMBED_CCOPTS)
882 $(call detected_var,PYTHON_EMBED_CCOPTS)