]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - tools/perf/Makefile.config
ed65e82f034efe0e76cef718fdb8a9bd07511edb
[mirror_ubuntu-bionic-kernel.git] / tools / perf / Makefile.config
1
2 ifeq ($(src-perf),)
3 src-perf := $(srctree)/tools/perf
4 endif
5
6 ifeq ($(obj-perf),)
7 obj-perf := $(OUTPUT)
8 endif
9
10 ifneq ($(obj-perf),)
11 obj-perf := $(abspath $(obj-perf))/
12 endif
13
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)
17
18 CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
19
20 include $(srctree)/tools/scripts/Makefile.arch
21
22 $(call detected_var,SRCARCH)
23
24 NO_PERF_REGS := 1
25
26 # Additional ARCH settings for ppc
27 ifeq ($(SRCARCH),powerpc)
28 NO_PERF_REGS := 0
29 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
30 endif
31
32 # Additional ARCH settings for x86
33 ifeq ($(SRCARCH),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)
40 else
41 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
42 endif
43 NO_PERF_REGS := 0
44 endif
45
46 ifeq ($(SRCARCH),arm)
47 NO_PERF_REGS := 0
48 LIBUNWIND_LIBS = -lunwind -lunwind-arm
49 endif
50
51 ifeq ($(SRCARCH),arm64)
52 NO_PERF_REGS := 0
53 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
54 endif
55
56 ifeq ($(ARCH),s390)
57 NO_PERF_REGS := 0
58 endif
59
60 ifeq ($(NO_PERF_REGS),0)
61 $(call detected,CONFIG_PERF_REGS)
62 endif
63
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
67 # to the check.
68 ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm powerpc s390))
69 NO_LIBDW_DWARF_UNWIND := 1
70 endif
71
72 ifeq ($(LIBUNWIND_LIBS),)
73 NO_LIBUNWIND := 1
74 endif
75 #
76 # For linking with debug library, run like:
77 #
78 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
79 #
80
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
85 endef
86
87 ifdef LIBUNWIND_DIR
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)))
92 endif
93
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)
99
100 ifeq ($(NO_PERF_REGS),0)
101 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
102 endif
103
104 # for linking with debug library, run like:
105 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
106 ifdef LIBDW_DIR
107 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
108 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
109 endif
110 DWARFLIBS := -ldw
111 ifeq ($(findstring -static,${LDFLAGS}),-static)
112 DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
113 endif
114 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
115 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
116
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
122 endif
123 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
124 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
125
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
129
130 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
131 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
132 endif
133
134 include $(srctree)/tools/scripts/utilities.mak
135
136 ifeq ($(call get-executable,$(FLEX)),)
137 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
138 endif
139
140 ifeq ($(call get-executable,$(BISON)),)
141 dummy := $(error Error: $(BISON) is missing on this system, please install it)
142 endif
143
144 # Treat warnings as errors unless directed not to
145 ifneq ($(WERROR),0)
146 CFLAGS += -Werror
147 CXXFLAGS += -Werror
148 endif
149
150 ifndef DEBUG
151 DEBUG := 0
152 endif
153
154 ifeq ($(DEBUG),0)
155 ifeq ($(CC_NO_CLANG), 0)
156 CFLAGS += -O3
157 else
158 CFLAGS += -O6
159 endif
160 endif
161
162 ifdef PARSER_DEBUG
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)
168 endif
169
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))
176 PYTHON2_CONFIG := \
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))
180
181 grep-libs = $(filter -l%,$(1))
182 strip-libs = $(filter-out -l%,$(1))
183
184 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
185
186 ifdef 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))
193 endif
194 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
195 endif
196
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)
201
202 CFLAGS += -fno-omit-frame-pointer
203 CFLAGS += -ggdb3
204 CFLAGS += -funwind-tables
205 CFLAGS += -Wall
206 CFLAGS += -Wextra
207 CFLAGS += -std=gnu99
208
209 CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
210 CXXFLAGS += -Wall
211 CXXFLAGS += -fno-omit-frame-pointer
212 CXXFLAGS += -ggdb3
213 CXXFLAGS += -funwind-tables
214 CXXFLAGS += -Wno-strict-aliasing
215
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
219
220 EXTLIBS = -lpthread -lrt -lm -ldl
221
222 ifeq ($(FEATURES_DUMP),)
223 include $(srctree)/tools/build/Makefile.feature
224 else
225 include $(FEATURES_DUMP)
226 endif
227
228 ifeq ($(feature-stackprotector-all), 1)
229 CFLAGS += -fstack-protector-all
230 endif
231
232 ifeq ($(DEBUG),0)
233 ifeq ($(feature-fortify-source), 1)
234 CFLAGS += -D_FORTIFY_SOURCE=2
235 endif
236 endif
237
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)/
245
246 # $(obj-perf) for generated common-cmds.h
247 # $(obj-perf)/util for generated bison/flex headers
248 ifneq ($(OUTPUT),)
249 INC_FLAGS += -I$(obj-perf)/util
250 INC_FLAGS += -I$(obj-perf)
251 endif
252
253 INC_FLAGS += -I$(src-perf)/util
254 INC_FLAGS += -I$(src-perf)
255 INC_FLAGS += -I$(srctree)/tools/lib/
256
257 CFLAGS += $(INC_FLAGS)
258 CXXFLAGS += $(INC_FLAGS)
259
260 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
261
262 ifeq ($(feature-sync-compare-and-swap), 1)
263 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
264 endif
265
266 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
267 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
268 endif
269
270 ifndef NO_BIONIC
271 $(call feature_check,bionic)
272 ifeq ($(feature-bionic), 1)
273 BIONIC := 1
274 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
275 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
276 endif
277 endif
278
279 ifdef NO_LIBELF
280 NO_DWARF := 1
281 NO_DEMANGLE := 1
282 NO_LIBUNWIND := 1
283 NO_LIBDW_DWARF_UNWIND := 1
284 NO_LIBBPF := 1
285 NO_JVMTI := 1
286 else
287 ifeq ($(feature-libelf), 0)
288 ifeq ($(feature-glibc), 1)
289 LIBC_SUPPORT := 1
290 endif
291 ifeq ($(BIONIC),1)
292 LIBC_SUPPORT := 1
293 endif
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);
296
297 NO_LIBELF := 1
298 NO_DWARF := 1
299 NO_DEMANGLE := 1
300 NO_LIBUNWIND := 1
301 NO_LIBDW_DWARF_UNWIND := 1
302 NO_LIBBPF := 1
303 NO_JVMTI := 1
304 else
305 ifneq ($(filter s% -static%,$(LDFLAGS),),)
306 msg := $(error No static glibc found, please install glibc-static);
307 else
308 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
309 endif
310 endif
311 else
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);
316 endif
317 endif
318 ifneq ($(feature-dwarf), 1)
319 ifndef NO_DWARF
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);
321 NO_DWARF := 1
322 endif
323 else
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);
326 else
327 CFLAGS += -DHAVE_DWARF_GETLOCATIONS
328 endif # dwarf_getlocations
329 endif # Dwarf support
330 endif # libelf support
331 endif # NO_LIBELF
332
333 ifdef NO_DWARF
334 NO_LIBDW_DWARF_UNWIND := 1
335 endif
336
337 ifeq ($(feature-sched_getcpu), 1)
338 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
339 endif
340
341 ifeq ($(feature-setns), 1)
342 CFLAGS += -DHAVE_SETNS_SUPPORT
343 $(call detected,CONFIG_SETNS)
344 endif
345
346 ifndef NO_LIBELF
347 CFLAGS += -DHAVE_LIBELF_SUPPORT
348 EXTLIBS += -lelf
349 $(call detected,CONFIG_LIBELF)
350
351 ifeq ($(feature-libelf-mmap), 1)
352 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
353 endif
354
355 ifeq ($(feature-libelf-getphdrnum), 1)
356 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
357 endif
358
359 ifeq ($(feature-libelf-gelf_getnote), 1)
360 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
361 else
362 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
363 endif
364
365 ifeq ($(feature-libelf-getshdrstrndx), 1)
366 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
367 endif
368
369 ifndef NO_DWARF
370 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
371 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
372 NO_DWARF := 1
373 else
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
379 endif # NO_DWARF
380
381 ifndef NO_LIBBPF
382 ifeq ($(feature-bpf), 1)
383 CFLAGS += -DHAVE_LIBBPF_SUPPORT
384 $(call detected,CONFIG_LIBBPF)
385 endif
386
387 ifndef NO_DWARF
388 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
389 CFLAGS += -DHAVE_BPF_PROLOGUE
390 $(call detected,CONFIG_BPF_PROLOGUE)
391 else
392 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
393 endif
394 else
395 msg := $(warning DWARF support is off, BPF prologue is disabled);
396 endif
397
398 endif # NO_LIBBPF
399 endif # NO_LIBELF
400
401 ifndef NO_SDT
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);
404 NO_SDT := 1;
405 else
406 CFLAGS += -DHAVE_SDT_EVENT
407 $(call detected,CONFIG_SDT_EVENT)
408 endif
409 endif
410
411 ifdef PERF_HAVE_JITDUMP
412 ifndef NO_LIBELF
413 $(call detected,CONFIG_JITDUMP)
414 CFLAGS += -DHAVE_JITDUMP
415 endif
416 endif
417
418 ifeq ($(SRCARCH),powerpc)
419 ifndef NO_DWARF
420 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
421 endif
422 endif
423
424 ifndef NO_LIBUNWIND
425 have_libunwind :=
426
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
432 have_libunwind = 1
433 endif
434
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
440 have_libunwind = 1
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
445 endif
446 endif
447
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
451 else
452 have_libunwind := 1
453 $(call detected,CONFIG_LOCAL_LIBUNWIND)
454 endif
455
456 ifneq ($(have_libunwind), 1)
457 NO_LIBUNWIND := 1
458 endif
459 else
460 NO_LOCAL_LIBUNWIND := 1
461 endif
462
463 ifndef NO_LIBBPF
464 ifneq ($(feature-bpf), 1)
465 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
466 NO_LIBBPF := 1
467 endif
468 endif
469
470 dwarf-post-unwind := 1
471 dwarf-post-unwind-text := BUG
472
473 # setup DWARF post unwinder
474 ifdef NO_LIBUNWIND
475 ifdef NO_LIBDW_DWARF_UNWIND
476 msg := $(warning Disabling post unwind, no support found.);
477 dwarf-post-unwind := 0
478 else
479 dwarf-post-unwind-text := libdw
480 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
481 endif
482 else
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
488 endif
489 endif
490
491 ifeq ($(dwarf-post-unwind),1)
492 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
493 $(call detected,CONFIG_DWARF_UNWIND)
494 else
495 NO_DWARF_UNWIND := 1
496 endif
497
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
504 endif
505 else
506 # non-ARM has no dwarf_find_debug_frame() function:
507 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
508 endif
509 EXTLIBS += $(LIBUNWIND_LIBS)
510 LDFLAGS += $(LIBUNWIND_LIBS)
511 endif
512 ifeq ($(findstring -static,${LDFLAGS}),-static)
513 # gcc -static links libgcc_eh which contans piece of libunwind
514 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
515 endif
516
517 ifndef NO_LIBUNWIND
518 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
519 CFLAGS += $(LIBUNWIND_CFLAGS)
520 LDFLAGS += $(LIBUNWIND_LDFLAGS)
521 EXTLIBS += $(EXTLIBS_LIBUNWIND)
522 endif
523
524 ifndef NO_LIBAUDIT
525 ifneq ($(feature-libaudit), 1)
526 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
527 NO_LIBAUDIT := 1
528 else
529 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
530 EXTLIBS += -laudit
531 $(call detected,CONFIG_AUDIT)
532 endif
533 endif
534
535 ifndef NO_LIBCRYPTO
536 ifneq ($(feature-libcrypto), 1)
537 msg := $(warning No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev);
538 NO_LIBCRYPTO := 1
539 else
540 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
541 EXTLIBS += -lcrypto
542 $(call detected,CONFIG_CRYPTO)
543 endif
544 endif
545
546 ifdef NO_NEWT
547 NO_SLANG=1
548 endif
549
550 ifndef NO_SLANG
551 ifneq ($(feature-libslang), 1)
552 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
553 NO_SLANG := 1
554 else
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
558 EXTLIBS += -lslang
559 $(call detected,CONFIG_SLANG)
560 endif
561 endif
562
563 ifndef NO_GTK2
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);
567 NO_GTK2 := 1
568 else
569 ifeq ($(feature-gtk2-infobar), 1)
570 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
571 endif
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)
575 EXTLIBS += -ldl
576 endif
577 endif
578
579
580 ifdef NO_LIBPERL
581 CFLAGS += -DNO_LIBPERL
582 else
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)
588
589 ifneq ($(feature-libperl), 1)
590 CFLAGS += -DNO_LIBPERL
591 NO_LIBPERL := 1
592 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
593 else
594 LDFLAGS += $(PERL_EMBED_LDFLAGS)
595 EXTLIBS += $(PERL_EMBED_LIBADD)
596 $(call detected,CONFIG_LIBPERL)
597 endif
598 endif
599
600 ifeq ($(feature-timerfd), 1)
601 CFLAGS += -DHAVE_TIMERFD_SUPPORT
602 else
603 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
604 endif
605
606 disable-python = $(eval $(disable-python_code))
607 define disable-python_code
608 CFLAGS += -DNO_LIBPYTHON
609 $(warning $1)
610 NO_LIBPYTHON := 1
611 endef
612
613 ifdef NO_LIBPYTHON
614 $(call disable-python,Python support disabled by user)
615 else
616
617 ifndef PYTHON
618 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
619 else
620 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
621
622 ifndef PYTHON_CONFIG
623 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
624 else
625
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)
628 else
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:)
634 $(warning $(and ,))
635 $(warning $(and ,) make PYTHON=python2)
636 $(warning $(and ,))
637 $(warning Otherwise, disable Python support entirely:)
638 $(warning $(and ,))
639 $(warning $(and ,) make NO_LIBPYTHON=1)
640 $(warning $(and ,))
641 $(error $(and ,))
642 else
643 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
644 EXTLIBS += $(PYTHON_EMBED_LIBADD)
645 LANG_BINDINGS += $(obj-perf)python/perf.so
646 $(call detected,CONFIG_LIBPYTHON)
647 endif
648 endif
649 endif
650 endif
651 endif
652
653 ifeq ($(feature-libbfd), 1)
654 EXTLIBS += -lbfd
655
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)
661
662 ifeq ($(feature-liberty), 1)
663 EXTLIBS += -liberty
664 else
665 ifeq ($(feature-liberty-z), 1)
666 EXTLIBS += -liberty -lz
667 endif
668 endif
669 endif
670
671 ifdef NO_DEMANGLE
672 CFLAGS += -DNO_DEMANGLE
673 else
674 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
675 EXTLIBS += -liberty
676 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
677 else
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)
684 EXTLIBS += -liberty
685 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
686 else
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
689 endif
690 endif
691 endif
692 endif
693 endif
694 endif
695
696 ifneq ($(filter -lbfd,$(EXTLIBS)),)
697 CFLAGS += -DHAVE_LIBBFD_SUPPORT
698 endif
699
700 ifndef NO_ZLIB
701 ifeq ($(feature-zlib), 1)
702 CFLAGS += -DHAVE_ZLIB_SUPPORT
703 EXTLIBS += -lz
704 $(call detected,CONFIG_ZLIB)
705 else
706 NO_ZLIB := 1
707 endif
708 endif
709
710 ifndef NO_LZMA
711 ifeq ($(feature-lzma), 1)
712 CFLAGS += -DHAVE_LZMA_SUPPORT
713 EXTLIBS += -llzma
714 $(call detected,CONFIG_LZMA)
715 else
716 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
717 NO_LZMA := 1
718 endif
719 endif
720
721 ifndef NO_BACKTRACE
722 ifeq ($(feature-backtrace), 1)
723 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
724 endif
725 endif
726
727 ifndef NO_LIBNUMA
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);
730 NO_LIBNUMA := 1
731 else
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);
734 NO_LIBNUMA := 1
735 else
736 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
737 EXTLIBS += -lnuma
738 $(call detected,CONFIG_NUMA)
739 endif
740 endif
741 endif
742
743 ifdef HAVE_KVM_STAT_SUPPORT
744 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
745 endif
746
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
752 else
753 NO_PERF_READ_VDSO32 := 1
754 endif
755 endif
756 ifneq ($(SRCARCH), x86)
757 NO_PERF_READ_VDSOX32 := 1
758 endif
759 ifndef NO_PERF_READ_VDSOX32
760 $(call feature_check,compile-x32)
761 ifeq ($(feature-compile-x32), 1)
762 CFLAGS += -DHAVE_PERF_READ_VDSOX32
763 else
764 NO_PERF_READ_VDSOX32 := 1
765 endif
766 endif
767 else
768 NO_PERF_READ_VDSO32 := 1
769 NO_PERF_READ_VDSOX32 := 1
770 endif
771
772 ifdef LIBBABELTRACE
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)
779 else
780 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
781 endif
782 endif
783
784 ifndef NO_AUXTRACE
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);
788 NO_AUXTRACE := 1
789 endif
790 endif
791 ifndef NO_AUXTRACE
792 $(call detected,CONFIG_AUXTRACE)
793 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
794 endif
795 endif
796
797 ifndef NO_JVMTI
798 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
799 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
800 else
801 ifneq (,$(wildcard /usr/sbin/alternatives))
802 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
803 endif
804 endif
805 ifndef JDIR
806 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
807 NO_JVMTI := 1
808 endif
809 endif
810
811 ifndef NO_JVMTI
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)
816 else
817 $(warning No openjdk development package found, please install JDK package)
818 NO_JVMTI := 1
819 endif
820 endif
821
822 USE_CXX = 0
823 USE_CLANGLLVM = 0
824 ifdef LIBCLANGLLVM
825 $(call feature_check,cxx)
826 ifneq ($(feature-cxx), 1)
827 msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
828 else
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))
833 else
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))
837 else
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)
842 USE_CXX = 1
843 USE_LLVM = 1
844 USE_CLANG = 1
845 ifneq ($(feature-llvm-version),1)
846 msg := $(warning This version of LLVM is not tested. May cause build errors)
847 endif
848 endif
849 endif
850 endif
851 endif
852
853 # Among the variables below, these:
854 # perfexecdir
855 # template_dir
856 # mandir
857 # infodir
858 # htmldir
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.
864
865 # Make the path relative to DESTDIR, not to prefix
866 ifndef DESTDIR
867 prefix ?= $(HOME)
868 endif
869 bindir_relative = bin
870 bindir = $(abspath $(prefix)/$(bindir_relative))
871 mandir = share/man
872 infodir = share/info
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)
881 sysconfdir = /etc
882 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
883 else
884 sysconfdir = $(prefix)/etc
885 ETC_PERFCONFIG = etc/perfconfig
886 endif
887 ifndef lib
888 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
889 lib = lib64
890 else
891 lib = lib
892 endif
893 endif # lib
894 libdir = $(prefix)/$(lib)
895
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))
911
912 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
913 perfexec_instdir = $(perfexecdir)
914 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
915 tip_instdir = $(tipdir)
916 else
917 perfexec_instdir = $(prefix)/$(perfexecdir)
918 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
919 tip_instdir = $(prefix)/$(tipdir)
920 endif
921 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
922 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
923 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
924
925 # If we install to $(HOME) we keep the traceevent default:
926 # $(HOME)/.traceevent/plugins
927 # Otherwise we install plugins into the global $(libdir).
928 ifdef DESTDIR
929 plugindir=$(libdir)/traceevent/plugins
930 plugindir_SQ= $(subst ','\'',$(plugindir))
931 endif
932
933 print_var = $(eval $(print_var_code)) $(info $(MSG))
934 define print_var_code
935 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
936 endef
937
938 ifeq ($(VF),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)
946
947 ifeq ($(dwarf-post-unwind),1)
948 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
949 endif
950 $(info )
951 endif
952
953 $(call detected_var,bindir_SQ)
954 $(call detected_var,PYTHON_WORD)
955 ifneq ($(OUTPUT),)
956 $(call detected_var,OUTPUT)
957 endif
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)