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