Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux/fpc-iii.git] / tools / perf / config / Makefile
blobf7d7f5a1cad538e44be9400b520ca32315eed999
2 ifeq ($(src-perf),)
3 src-perf := $(srctree)/tools/perf
4 endif
6 ifeq ($(obj-perf),)
7 obj-perf := $(OUTPUT)
8 endif
10 ifneq ($(obj-perf),)
11 obj-perf := $(abspath $(obj-perf))/
12 endif
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,ARCH)
24 NO_PERF_REGS := 1
26 # Additional ARCH settings for x86
27 ifeq ($(ARCH),x86)
28 $(call detected,CONFIG_X86)
29 ifeq (${IS_64_BIT}, 1)
30 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
31 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
32 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
33 $(call detected,CONFIG_X86_64)
34 else
35 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
36 endif
37 NO_PERF_REGS := 0
38 endif
40 ifeq ($(ARCH),arm)
41 NO_PERF_REGS := 0
42 LIBUNWIND_LIBS = -lunwind -lunwind-arm
43 endif
45 ifeq ($(ARCH),arm64)
46 NO_PERF_REGS := 0
47 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
48 endif
50 ifeq ($(NO_PERF_REGS),0)
51 $(call detected,CONFIG_PERF_REGS)
52 endif
54 # So far there's only x86 and arm libdw unwind support merged in perf.
55 # Disable it on all other architectures in case libdw unwind
56 # support is detected in system. Add supported architectures
57 # to the check.
58 ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
59 NO_LIBDW_DWARF_UNWIND := 1
60 endif
62 ifeq ($(LIBUNWIND_LIBS),)
63 NO_LIBUNWIND := 1
64 endif
66 # For linking with debug library, run like:
68 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
70 ifdef LIBUNWIND_DIR
71 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
72 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
73 endif
74 LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
76 # Set per-feature check compilation flags
77 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
78 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
79 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
80 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
82 ifeq ($(NO_PERF_REGS),0)
83 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
84 endif
86 # for linking with debug library, run like:
87 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
88 ifdef LIBDW_DIR
89 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
90 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
91 endif
92 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
93 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
95 # for linking with debug library, run like:
96 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
97 ifdef LIBBABELTRACE_DIR
98 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
99 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
100 endif
101 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
102 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
104 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(ARCH)/include/uapi -I$(srctree)/include/uapi
105 # include ARCH specific config
106 -include $(src-perf)/arch/$(ARCH)/Makefile
108 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
109 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
110 endif
112 include $(srctree)/tools/scripts/utilities.mak
114 ifeq ($(call get-executable,$(FLEX)),)
115 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
116 endif
118 ifeq ($(call get-executable,$(BISON)),)
119 dummy := $(error Error: $(BISON) is missing on this system, please install it)
120 endif
122 # Treat warnings as errors unless directed not to
123 ifneq ($(WERROR),0)
124 CFLAGS += -Werror
125 endif
127 ifndef DEBUG
128 DEBUG := 0
129 endif
131 ifeq ($(DEBUG),0)
132 CFLAGS += -O6
133 endif
135 ifdef PARSER_DEBUG
136 PARSER_DEBUG_BISON := -t
137 PARSER_DEBUG_FLEX := -d
138 CFLAGS += -DPARSER_DEBUG
139 $(call detected_var,PARSER_DEBUG_BISON)
140 $(call detected_var,PARSER_DEBUG_FLEX)
141 endif
143 # Try different combinations to accommodate systems that only have
144 # python[2][-config] in weird combinations but always preferring
145 # python2 and python2-config as per pep-0394. If we catch a
146 # python[-config] in version 3, the version check will kill it.
147 PYTHON2 := $(if $(call get-executable,python2),python2,python)
148 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
149 PYTHON2_CONFIG := \
150 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
151 override PYTHON_CONFIG := \
152 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
154 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
156 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
157 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
159 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
160 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
161 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
162 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
164 CFLAGS += -fno-omit-frame-pointer
165 CFLAGS += -ggdb3
166 CFLAGS += -funwind-tables
167 CFLAGS += -Wall
168 CFLAGS += -Wextra
169 CFLAGS += -std=gnu99
171 # Enforce a non-executable stack, as we may regress (again) in the future by
172 # adding assembler files missing the .GNU-stack linker note.
173 LDFLAGS += -Wl,-z,noexecstack
175 EXTLIBS = -lpthread -lrt -lm -ldl
177 ifeq ($(FEATURES_DUMP),)
178 include $(srctree)/tools/build/Makefile.feature
179 else
180 include $(FEATURES_DUMP)
181 endif
183 ifeq ($(feature-stackprotector-all), 1)
184 CFLAGS += -fstack-protector-all
185 endif
187 ifeq ($(DEBUG),0)
188 ifeq ($(feature-fortify-source), 1)
189 CFLAGS += -D_FORTIFY_SOURCE=2
190 endif
191 endif
193 CFLAGS += -I$(src-perf)/util/include
194 CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
195 CFLAGS += -I$(srctree)/tools/include/
196 CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
197 CFLAGS += -I$(srctree)/arch/$(ARCH)/include
198 CFLAGS += -I$(srctree)/include/uapi
199 CFLAGS += -I$(srctree)/include
201 # $(obj-perf) for generated common-cmds.h
202 # $(obj-perf)/util for generated bison/flex headers
203 ifneq ($(OUTPUT),)
204 CFLAGS += -I$(obj-perf)/util
205 CFLAGS += -I$(obj-perf)
206 endif
208 CFLAGS += -I$(src-perf)/util
209 CFLAGS += -I$(src-perf)
210 CFLAGS += -I$(srctree)/tools/lib/
212 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
214 ifeq ($(feature-sync-compare-and-swap), 1)
215 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
216 endif
218 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
219 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
220 endif
222 ifndef NO_BIONIC
223 $(call feature_check,bionic)
224 ifeq ($(feature-bionic), 1)
225 BIONIC := 1
226 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
227 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
228 endif
229 endif
231 ifdef NO_LIBELF
232 NO_DWARF := 1
233 NO_DEMANGLE := 1
234 NO_LIBUNWIND := 1
235 NO_LIBDW_DWARF_UNWIND := 1
236 NO_LIBBPF := 1
237 else
238 ifeq ($(feature-libelf), 0)
239 ifeq ($(feature-glibc), 1)
240 LIBC_SUPPORT := 1
241 endif
242 ifeq ($(BIONIC),1)
243 LIBC_SUPPORT := 1
244 endif
245 ifeq ($(LIBC_SUPPORT),1)
246 msg := $(warning No libelf found, disables 'probe' tool and BPF support in 'perf record', please install elfutils-libelf-devel/libelf-dev);
248 NO_LIBELF := 1
249 NO_DWARF := 1
250 NO_DEMANGLE := 1
251 NO_LIBUNWIND := 1
252 NO_LIBDW_DWARF_UNWIND := 1
253 NO_LIBBPF := 1
254 else
255 ifneq ($(filter s% -static%,$(LDFLAGS),),)
256 msg := $(error No static glibc found, please install glibc-static);
257 else
258 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
259 endif
260 endif
261 else
262 ifndef NO_LIBDW_DWARF_UNWIND
263 ifneq ($(feature-libdw-dwarf-unwind),1)
264 NO_LIBDW_DWARF_UNWIND := 1
265 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
266 endif
267 endif
268 ifneq ($(feature-dwarf), 1)
269 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);
270 NO_DWARF := 1
271 endif # Dwarf support
272 endif # libelf support
273 endif # NO_LIBELF
275 ifdef NO_DWARF
276 NO_LIBDW_DWARF_UNWIND := 1
277 endif
279 ifndef NO_LIBELF
280 CFLAGS += -DHAVE_LIBELF_SUPPORT
281 EXTLIBS += -lelf
282 $(call detected,CONFIG_LIBELF)
284 ifeq ($(feature-libelf-mmap), 1)
285 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
286 endif
288 ifeq ($(feature-libelf-getphdrnum), 1)
289 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
290 endif
292 # include ARCH specific config
293 -include $(src-perf)/arch/$(ARCH)/Makefile
295 ifndef NO_DWARF
296 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
297 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
298 NO_DWARF := 1
299 else
300 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
301 LDFLAGS += $(LIBDW_LDFLAGS)
302 DWARFLIBS := -ldw
303 ifeq ($(findstring -static,${LDFLAGS}),-static)
304 DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
305 endif
306 EXTLIBS += ${DWARFLIBS}
307 $(call detected,CONFIG_DWARF)
308 endif # PERF_HAVE_DWARF_REGS
309 endif # NO_DWARF
311 ifndef NO_LIBBPF
312 ifeq ($(feature-bpf), 1)
313 CFLAGS += -DHAVE_LIBBPF_SUPPORT
314 $(call detected,CONFIG_LIBBPF)
315 endif
317 ifndef NO_DWARF
318 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
319 CFLAGS += -DHAVE_BPF_PROLOGUE
320 $(call detected,CONFIG_BPF_PROLOGUE)
321 else
322 msg := $(warning BPF prologue is not supported by architecture $(ARCH), missing regs_query_register_offset());
323 endif
324 else
325 msg := $(warning DWARF support is off, BPF prologue is disabled);
326 endif
328 endif # NO_LIBBPF
329 endif # NO_LIBELF
331 ifdef PERF_HAVE_JITDUMP
332 ifndef NO_DWARF
333 $(call detected,CONFIG_JITDUMP)
334 CFLAGS += -DHAVE_JITDUMP
335 endif
336 endif
338 ifeq ($(ARCH),powerpc)
339 ifndef NO_DWARF
340 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
341 endif
342 endif
344 ifndef NO_LIBUNWIND
345 ifneq ($(feature-libunwind), 1)
346 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
347 NO_LIBUNWIND := 1
348 endif
349 endif
351 ifndef NO_LIBBPF
352 ifneq ($(feature-bpf), 1)
353 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
354 NO_LIBBPF := 1
355 endif
356 endif
358 dwarf-post-unwind := 1
359 dwarf-post-unwind-text := BUG
361 # setup DWARF post unwinder
362 ifdef NO_LIBUNWIND
363 ifdef NO_LIBDW_DWARF_UNWIND
364 msg := $(warning Disabling post unwind, no support found.);
365 dwarf-post-unwind := 0
366 else
367 dwarf-post-unwind-text := libdw
368 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
369 endif
370 else
371 dwarf-post-unwind-text := libunwind
372 $(call detected,CONFIG_LIBUNWIND)
373 # Enable libunwind support by default.
374 ifndef NO_LIBDW_DWARF_UNWIND
375 NO_LIBDW_DWARF_UNWIND := 1
376 endif
377 endif
379 ifeq ($(dwarf-post-unwind),1)
380 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
381 $(call detected,CONFIG_DWARF_UNWIND)
382 else
383 NO_DWARF_UNWIND := 1
384 endif
386 ifndef NO_LIBUNWIND
387 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
388 $(call feature_check,libunwind-debug-frame)
389 ifneq ($(feature-libunwind-debug-frame), 1)
390 msg := $(warning No debug_frame support found in libunwind);
391 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
392 endif
393 else
394 # non-ARM has no dwarf_find_debug_frame() function:
395 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
396 endif
397 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
398 EXTLIBS += $(LIBUNWIND_LIBS)
399 CFLAGS += $(LIBUNWIND_CFLAGS)
400 LDFLAGS += $(LIBUNWIND_LDFLAGS)
401 endif
403 ifndef NO_LIBAUDIT
404 ifneq ($(feature-libaudit), 1)
405 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
406 NO_LIBAUDIT := 1
407 else
408 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
409 EXTLIBS += -laudit
410 $(call detected,CONFIG_AUDIT)
411 endif
412 endif
414 ifndef NO_LIBCRYPTO
415 ifneq ($(feature-libcrypto), 1)
416 msg := $(warning No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev);
417 NO_LIBCRYPTO := 1
418 else
419 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
420 EXTLIBS += -lcrypto
421 $(call detected,CONFIG_CRYPTO)
422 endif
423 endif
425 ifdef NO_NEWT
426 NO_SLANG=1
427 endif
429 ifndef NO_SLANG
430 ifneq ($(feature-libslang), 1)
431 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
432 NO_SLANG := 1
433 else
434 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
435 CFLAGS += -I/usr/include/slang
436 CFLAGS += -DHAVE_SLANG_SUPPORT
437 EXTLIBS += -lslang
438 $(call detected,CONFIG_SLANG)
439 endif
440 endif
442 ifndef NO_GTK2
443 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
444 ifneq ($(feature-gtk2), 1)
445 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
446 NO_GTK2 := 1
447 else
448 ifeq ($(feature-gtk2-infobar), 1)
449 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
450 endif
451 CFLAGS += -DHAVE_GTK2_SUPPORT
452 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
453 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
454 EXTLIBS += -ldl
455 endif
456 endif
458 grep-libs = $(filter -l%,$(1))
459 strip-libs = $(filter-out -l%,$(1))
461 ifdef NO_LIBPERL
462 CFLAGS += -DNO_LIBPERL
463 else
464 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
465 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
466 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
467 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
468 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
470 ifneq ($(feature-libperl), 1)
471 CFLAGS += -DNO_LIBPERL
472 NO_LIBPERL := 1
473 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
474 else
475 LDFLAGS += $(PERL_EMBED_LDFLAGS)
476 EXTLIBS += $(PERL_EMBED_LIBADD)
477 $(call detected,CONFIG_LIBPERL)
478 endif
479 endif
481 ifeq ($(feature-timerfd), 1)
482 CFLAGS += -DHAVE_TIMERFD_SUPPORT
483 else
484 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
485 endif
487 disable-python = $(eval $(disable-python_code))
488 define disable-python_code
489 CFLAGS += -DNO_LIBPYTHON
490 $(warning $1)
491 NO_LIBPYTHON := 1
492 endef
494 ifdef NO_LIBPYTHON
495 $(call disable-python,Python support disabled by user)
496 else
498 ifndef PYTHON
499 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
500 else
501 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
503 ifndef PYTHON_CONFIG
504 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
505 else
507 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
509 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
510 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
511 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
512 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
513 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
515 ifneq ($(feature-libpython), 1)
516 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
517 else
519 ifneq ($(feature-libpython-version), 1)
520 $(warning Python 3 is not yet supported; please set)
521 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
522 $(warning If you also have Python 2 installed, then)
523 $(warning try something like:)
524 $(warning $(and ,))
525 $(warning $(and ,) make PYTHON=python2)
526 $(warning $(and ,))
527 $(warning Otherwise, disable Python support entirely:)
528 $(warning $(and ,))
529 $(warning $(and ,) make NO_LIBPYTHON=1)
530 $(warning $(and ,))
531 $(error $(and ,))
532 else
533 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
534 EXTLIBS += $(PYTHON_EMBED_LIBADD)
535 LANG_BINDINGS += $(obj-perf)python/perf.so
536 $(call detected,CONFIG_LIBPYTHON)
537 endif
538 endif
539 endif
540 endif
541 endif
543 ifeq ($(feature-libbfd), 1)
544 EXTLIBS += -lbfd
546 # call all detections now so we get correct
547 # status in VF output
548 $(call feature_check,liberty)
549 $(call feature_check,liberty-z)
550 $(call feature_check,cplus-demangle)
552 ifeq ($(feature-liberty), 1)
553 EXTLIBS += -liberty
554 else
555 ifeq ($(feature-liberty-z), 1)
556 EXTLIBS += -liberty -lz
557 endif
558 endif
559 endif
561 ifdef NO_DEMANGLE
562 CFLAGS += -DNO_DEMANGLE
563 else
564 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
565 EXTLIBS += -liberty
566 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
567 else
568 ifneq ($(feature-libbfd), 1)
569 ifneq ($(feature-liberty), 1)
570 ifneq ($(feature-liberty-z), 1)
571 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
572 # or any of 'bfd iberty z' trinity
573 ifeq ($(feature-cplus-demangle), 1)
574 EXTLIBS += -liberty
575 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
576 else
577 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
578 CFLAGS += -DNO_DEMANGLE
579 endif
580 endif
581 endif
582 endif
583 endif
584 endif
586 ifneq ($(filter -lbfd,$(EXTLIBS)),)
587 CFLAGS += -DHAVE_LIBBFD_SUPPORT
588 endif
590 ifndef NO_ZLIB
591 ifeq ($(feature-zlib), 1)
592 CFLAGS += -DHAVE_ZLIB_SUPPORT
593 EXTLIBS += -lz
594 $(call detected,CONFIG_ZLIB)
595 else
596 NO_ZLIB := 1
597 endif
598 endif
600 ifndef NO_LZMA
601 ifeq ($(feature-lzma), 1)
602 CFLAGS += -DHAVE_LZMA_SUPPORT
603 EXTLIBS += -llzma
604 $(call detected,CONFIG_LZMA)
605 else
606 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
607 NO_LZMA := 1
608 endif
609 endif
611 ifndef NO_BACKTRACE
612 ifeq ($(feature-backtrace), 1)
613 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
614 endif
615 endif
617 ifndef NO_LIBNUMA
618 ifeq ($(feature-libnuma), 0)
619 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
620 NO_LIBNUMA := 1
621 else
622 ifeq ($(feature-numa_num_possible_cpus), 0)
623 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
624 NO_LIBNUMA := 1
625 else
626 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
627 EXTLIBS += -lnuma
628 $(call detected,CONFIG_NUMA)
629 endif
630 endif
631 endif
633 ifdef HAVE_KVM_STAT_SUPPORT
634 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
635 endif
637 ifeq (${IS_64_BIT}, 1)
638 ifndef NO_PERF_READ_VDSO32
639 $(call feature_check,compile-32)
640 ifeq ($(feature-compile-32), 1)
641 CFLAGS += -DHAVE_PERF_READ_VDSO32
642 else
643 NO_PERF_READ_VDSO32 := 1
644 endif
645 endif
646 ifneq ($(ARCH), x86)
647 NO_PERF_READ_VDSOX32 := 1
648 endif
649 ifndef NO_PERF_READ_VDSOX32
650 $(call feature_check,compile-x32)
651 ifeq ($(feature-compile-x32), 1)
652 CFLAGS += -DHAVE_PERF_READ_VDSOX32
653 else
654 NO_PERF_READ_VDSOX32 := 1
655 endif
656 endif
657 else
658 NO_PERF_READ_VDSO32 := 1
659 NO_PERF_READ_VDSOX32 := 1
660 endif
662 ifdef LIBBABELTRACE
663 $(call feature_check,libbabeltrace)
664 ifeq ($(feature-libbabeltrace), 1)
665 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
666 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
667 EXTLIBS += -lbabeltrace-ctf
668 $(call detected,CONFIG_LIBBABELTRACE)
669 else
670 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
671 endif
672 endif
674 ifndef NO_AUXTRACE
675 ifeq ($(feature-get_cpuid), 0)
676 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
677 NO_AUXTRACE := 1
678 else
679 $(call detected,CONFIG_AUXTRACE)
680 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
681 endif
682 endif
684 # Among the variables below, these:
685 # perfexecdir
686 # template_dir
687 # mandir
688 # infodir
689 # htmldir
690 # ETC_PERFCONFIG (but not sysconfdir)
691 # can be specified as a relative path some/where/else;
692 # this is interpreted as relative to $(prefix) and "perf" at
693 # runtime figures out where they are based on the path to the executable.
694 # This can help installing the suite in a relocatable way.
696 # Make the path relative to DESTDIR, not to prefix
697 ifndef DESTDIR
698 prefix ?= $(HOME)
699 endif
700 bindir_relative = bin
701 bindir = $(abspath $(prefix)/$(bindir_relative))
702 mandir = share/man
703 infodir = share/info
704 perfexecdir = libexec/perf-core
705 sharedir = $(prefix)/share
706 template_dir = share/perf-core/templates
707 STRACE_GROUPS_DIR = share/perf-core/strace/groups
708 htmldir = share/doc/perf-doc
709 tipdir = share/doc/perf-tip
710 srcdir = $(srctree)/tools/perf
711 ifeq ($(prefix),/usr)
712 sysconfdir = /etc
713 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
714 else
715 sysconfdir = $(prefix)/etc
716 ETC_PERFCONFIG = etc/perfconfig
717 endif
718 ifndef lib
719 ifeq ($(ARCH)$(IS_64_BIT), x861)
720 lib = lib64
721 else
722 lib = lib
723 endif
724 endif # lib
725 libdir = $(prefix)/$(lib)
727 # Shell quote (do not use $(call) to accommodate ancient setups);
728 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
729 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
730 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
731 bindir_SQ = $(subst ','\'',$(bindir))
732 mandir_SQ = $(subst ','\'',$(mandir))
733 infodir_SQ = $(subst ','\'',$(infodir))
734 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
735 template_dir_SQ = $(subst ','\'',$(template_dir))
736 htmldir_SQ = $(subst ','\'',$(htmldir))
737 tipdir_SQ = $(subst ','\'',$(tipdir))
738 prefix_SQ = $(subst ','\'',$(prefix))
739 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
740 libdir_SQ = $(subst ','\'',$(libdir))
741 srcdir_SQ = $(subst ','\'',$(srcdir))
743 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
744 perfexec_instdir = $(perfexecdir)
745 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
746 tip_instdir = $(tipdir)
747 else
748 perfexec_instdir = $(prefix)/$(perfexecdir)
749 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
750 tip_instdir = $(prefix)/$(tipdir)
751 endif
752 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
753 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
754 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
756 # If we install to $(HOME) we keep the traceevent default:
757 # $(HOME)/.traceevent/plugins
758 # Otherwise we install plugins into the global $(libdir).
759 ifdef DESTDIR
760 plugindir=$(libdir)/traceevent/plugins
761 plugindir_SQ= $(subst ','\'',$(plugindir))
762 endif
764 print_var = $(eval $(print_var_code)) $(info $(MSG))
765 define print_var_code
766 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
767 endef
769 ifeq ($(VF),1)
770 $(call print_var,prefix)
771 $(call print_var,bindir)
772 $(call print_var,libdir)
773 $(call print_var,sysconfdir)
774 $(call print_var,LIBUNWIND_DIR)
775 $(call print_var,LIBDW_DIR)
777 ifeq ($(dwarf-post-unwind),1)
778 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
779 endif
780 $(info )
781 endif
783 $(call detected_var,bindir_SQ)
784 $(call detected_var,PYTHON_WORD)
785 ifneq ($(OUTPUT),)
786 $(call detected_var,OUTPUT)
787 endif
788 $(call detected_var,htmldir_SQ)
789 $(call detected_var,infodir_SQ)
790 $(call detected_var,mandir_SQ)
791 $(call detected_var,ETC_PERFCONFIG_SQ)
792 $(call detected_var,STRACE_GROUPS_DIR_SQ)
793 $(call detected_var,prefix_SQ)
794 $(call detected_var,perfexecdir_SQ)
795 $(call detected_var,tipdir_SQ)
796 $(call detected_var,srcdir_SQ)
797 $(call detected_var,LIBDIR)
798 $(call detected_var,GTK_CFLAGS)
799 $(call detected_var,PERL_EMBED_CCOPTS)
800 $(call detected_var,PYTHON_EMBED_CCOPTS)