]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - tools/perf/Makefile.config
xen-netback: fix input validation in xenvif_set_hash_mapping()
[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 PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
192 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
193 endif
194
195 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
196 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
197 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
198 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
199
200 CFLAGS += -fno-omit-frame-pointer
201 CFLAGS += -ggdb3
202 CFLAGS += -funwind-tables
203 CFLAGS += -Wall
204 CFLAGS += -Wextra
205 CFLAGS += -std=gnu99
206
207 CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
208 CXXFLAGS += -Wall
209 CXXFLAGS += -fno-omit-frame-pointer
210 CXXFLAGS += -ggdb3
211 CXXFLAGS += -funwind-tables
212 CXXFLAGS += -Wno-strict-aliasing
213
214 # Enforce a non-executable stack, as we may regress (again) in the future by
215 # adding assembler files missing the .GNU-stack linker note.
216 LDFLAGS += -Wl,-z,noexecstack
217
218 EXTLIBS = -lpthread -lrt -lm -ldl
219
220 ifeq ($(FEATURES_DUMP),)
221 include $(srctree)/tools/build/Makefile.feature
222 else
223 include $(FEATURES_DUMP)
224 endif
225
226 ifeq ($(feature-stackprotector-all), 1)
227 CFLAGS += -fstack-protector-all
228 endif
229
230 ifeq ($(DEBUG),0)
231 ifeq ($(feature-fortify-source), 1)
232 CFLAGS += -D_FORTIFY_SOURCE=2
233 endif
234 endif
235
236 INC_FLAGS += -I$(src-perf)/util/include
237 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
238 INC_FLAGS += -I$(srctree)/tools/include/uapi
239 INC_FLAGS += -I$(srctree)/tools/include/
240 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
241 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
242 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
243
244 # $(obj-perf) for generated common-cmds.h
245 # $(obj-perf)/util for generated bison/flex headers
246 ifneq ($(OUTPUT),)
247 INC_FLAGS += -I$(obj-perf)/util
248 INC_FLAGS += -I$(obj-perf)
249 endif
250
251 INC_FLAGS += -I$(src-perf)/util
252 INC_FLAGS += -I$(src-perf)
253 INC_FLAGS += -I$(srctree)/tools/lib/
254
255 CFLAGS += $(INC_FLAGS)
256 CXXFLAGS += $(INC_FLAGS)
257
258 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
259
260 ifeq ($(feature-sync-compare-and-swap), 1)
261 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
262 endif
263
264 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
265 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
266 endif
267
268 ifndef NO_BIONIC
269 $(call feature_check,bionic)
270 ifeq ($(feature-bionic), 1)
271 BIONIC := 1
272 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
273 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
274 endif
275 endif
276
277 ifdef NO_LIBELF
278 NO_DWARF := 1
279 NO_DEMANGLE := 1
280 NO_LIBUNWIND := 1
281 NO_LIBDW_DWARF_UNWIND := 1
282 NO_LIBBPF := 1
283 NO_JVMTI := 1
284 else
285 ifeq ($(feature-libelf), 0)
286 ifeq ($(feature-glibc), 1)
287 LIBC_SUPPORT := 1
288 endif
289 ifeq ($(BIONIC),1)
290 LIBC_SUPPORT := 1
291 endif
292 ifeq ($(LIBC_SUPPORT),1)
293 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);
294
295 NO_LIBELF := 1
296 NO_DWARF := 1
297 NO_DEMANGLE := 1
298 NO_LIBUNWIND := 1
299 NO_LIBDW_DWARF_UNWIND := 1
300 NO_LIBBPF := 1
301 NO_JVMTI := 1
302 else
303 ifneq ($(filter s% -static%,$(LDFLAGS),),)
304 msg := $(error No static glibc found, please install glibc-static);
305 else
306 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
307 endif
308 endif
309 else
310 ifndef NO_LIBDW_DWARF_UNWIND
311 ifneq ($(feature-libdw-dwarf-unwind),1)
312 NO_LIBDW_DWARF_UNWIND := 1
313 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
314 endif
315 endif
316 ifneq ($(feature-dwarf), 1)
317 ifndef NO_DWARF
318 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);
319 NO_DWARF := 1
320 endif
321 else
322 ifneq ($(feature-dwarf_getlocations), 1)
323 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
324 else
325 CFLAGS += -DHAVE_DWARF_GETLOCATIONS
326 endif # dwarf_getlocations
327 endif # Dwarf support
328 endif # libelf support
329 endif # NO_LIBELF
330
331 ifdef NO_DWARF
332 NO_LIBDW_DWARF_UNWIND := 1
333 endif
334
335 ifeq ($(feature-sched_getcpu), 1)
336 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
337 endif
338
339 ifeq ($(feature-setns), 1)
340 CFLAGS += -DHAVE_SETNS_SUPPORT
341 $(call detected,CONFIG_SETNS)
342 endif
343
344 ifndef NO_LIBELF
345 CFLAGS += -DHAVE_LIBELF_SUPPORT
346 EXTLIBS += -lelf
347 $(call detected,CONFIG_LIBELF)
348
349 ifeq ($(feature-libelf-mmap), 1)
350 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
351 endif
352
353 ifeq ($(feature-libelf-getphdrnum), 1)
354 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
355 endif
356
357 ifeq ($(feature-libelf-gelf_getnote), 1)
358 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
359 else
360 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
361 endif
362
363 ifeq ($(feature-libelf-getshdrstrndx), 1)
364 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
365 endif
366
367 ifndef NO_DWARF
368 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
369 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
370 NO_DWARF := 1
371 else
372 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
373 LDFLAGS += $(LIBDW_LDFLAGS)
374 EXTLIBS += ${DWARFLIBS}
375 $(call detected,CONFIG_DWARF)
376 endif # PERF_HAVE_DWARF_REGS
377 endif # NO_DWARF
378
379 ifndef NO_LIBBPF
380 ifeq ($(feature-bpf), 1)
381 CFLAGS += -DHAVE_LIBBPF_SUPPORT
382 $(call detected,CONFIG_LIBBPF)
383 endif
384
385 ifndef NO_DWARF
386 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
387 CFLAGS += -DHAVE_BPF_PROLOGUE
388 $(call detected,CONFIG_BPF_PROLOGUE)
389 else
390 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
391 endif
392 else
393 msg := $(warning DWARF support is off, BPF prologue is disabled);
394 endif
395
396 endif # NO_LIBBPF
397 endif # NO_LIBELF
398
399 ifndef NO_SDT
400 ifneq ($(feature-sdt), 1)
401 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
402 NO_SDT := 1;
403 else
404 CFLAGS += -DHAVE_SDT_EVENT
405 $(call detected,CONFIG_SDT_EVENT)
406 endif
407 endif
408
409 ifdef PERF_HAVE_JITDUMP
410 ifndef NO_LIBELF
411 $(call detected,CONFIG_JITDUMP)
412 CFLAGS += -DHAVE_JITDUMP
413 endif
414 endif
415
416 ifeq ($(SRCARCH),powerpc)
417 ifndef NO_DWARF
418 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
419 endif
420 endif
421
422 ifndef NO_LIBUNWIND
423 have_libunwind :=
424
425 ifeq ($(feature-libunwind-x86), 1)
426 $(call detected,CONFIG_LIBUNWIND_X86)
427 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
428 LDFLAGS += -lunwind-x86
429 EXTLIBS_LIBUNWIND += -lunwind-x86
430 have_libunwind = 1
431 endif
432
433 ifeq ($(feature-libunwind-aarch64), 1)
434 $(call detected,CONFIG_LIBUNWIND_AARCH64)
435 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
436 LDFLAGS += -lunwind-aarch64
437 EXTLIBS_LIBUNWIND += -lunwind-aarch64
438 have_libunwind = 1
439 $(call feature_check,libunwind-debug-frame-aarch64)
440 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
441 msg := $(warning No debug_frame support found in libunwind-aarch64);
442 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
443 endif
444 endif
445
446 ifneq ($(feature-libunwind), 1)
447 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
448 NO_LOCAL_LIBUNWIND := 1
449 else
450 have_libunwind := 1
451 $(call detected,CONFIG_LOCAL_LIBUNWIND)
452 endif
453
454 ifneq ($(have_libunwind), 1)
455 NO_LIBUNWIND := 1
456 endif
457 else
458 NO_LOCAL_LIBUNWIND := 1
459 endif
460
461 ifndef NO_LIBBPF
462 ifneq ($(feature-bpf), 1)
463 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
464 NO_LIBBPF := 1
465 endif
466 endif
467
468 dwarf-post-unwind := 1
469 dwarf-post-unwind-text := BUG
470
471 # setup DWARF post unwinder
472 ifdef NO_LIBUNWIND
473 ifdef NO_LIBDW_DWARF_UNWIND
474 msg := $(warning Disabling post unwind, no support found.);
475 dwarf-post-unwind := 0
476 else
477 dwarf-post-unwind-text := libdw
478 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
479 endif
480 else
481 dwarf-post-unwind-text := libunwind
482 $(call detected,CONFIG_LIBUNWIND)
483 # Enable libunwind support by default.
484 ifndef NO_LIBDW_DWARF_UNWIND
485 NO_LIBDW_DWARF_UNWIND := 1
486 endif
487 endif
488
489 ifeq ($(dwarf-post-unwind),1)
490 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
491 $(call detected,CONFIG_DWARF_UNWIND)
492 else
493 NO_DWARF_UNWIND := 1
494 endif
495
496 ifndef NO_LOCAL_LIBUNWIND
497 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
498 $(call feature_check,libunwind-debug-frame)
499 ifneq ($(feature-libunwind-debug-frame), 1)
500 msg := $(warning No debug_frame support found in libunwind);
501 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
502 endif
503 else
504 # non-ARM has no dwarf_find_debug_frame() function:
505 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
506 endif
507 EXTLIBS += $(LIBUNWIND_LIBS)
508 LDFLAGS += $(LIBUNWIND_LIBS)
509 endif
510 ifeq ($(findstring -static,${LDFLAGS}),-static)
511 # gcc -static links libgcc_eh which contans piece of libunwind
512 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
513 endif
514
515 ifndef NO_LIBUNWIND
516 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
517 CFLAGS += $(LIBUNWIND_CFLAGS)
518 LDFLAGS += $(LIBUNWIND_LDFLAGS)
519 EXTLIBS += $(EXTLIBS_LIBUNWIND)
520 endif
521
522 ifndef NO_LIBAUDIT
523 ifneq ($(feature-libaudit), 1)
524 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
525 NO_LIBAUDIT := 1
526 else
527 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
528 EXTLIBS += -laudit
529 $(call detected,CONFIG_AUDIT)
530 endif
531 endif
532
533 ifndef NO_LIBCRYPTO
534 ifneq ($(feature-libcrypto), 1)
535 msg := $(warning No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev);
536 NO_LIBCRYPTO := 1
537 else
538 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
539 EXTLIBS += -lcrypto
540 $(call detected,CONFIG_CRYPTO)
541 endif
542 endif
543
544 ifdef NO_NEWT
545 NO_SLANG=1
546 endif
547
548 ifndef NO_SLANG
549 ifneq ($(feature-libslang), 1)
550 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
551 NO_SLANG := 1
552 else
553 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
554 CFLAGS += -I/usr/include/slang
555 CFLAGS += -DHAVE_SLANG_SUPPORT
556 EXTLIBS += -lslang
557 $(call detected,CONFIG_SLANG)
558 endif
559 endif
560
561 ifndef NO_GTK2
562 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
563 ifneq ($(feature-gtk2), 1)
564 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
565 NO_GTK2 := 1
566 else
567 ifeq ($(feature-gtk2-infobar), 1)
568 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
569 endif
570 CFLAGS += -DHAVE_GTK2_SUPPORT
571 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
572 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
573 EXTLIBS += -ldl
574 endif
575 endif
576
577 ifdef NO_LIBPERL
578 CFLAGS += -DNO_LIBPERL
579 else
580 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
581 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
582 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
583 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
584 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
585 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
586 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
587
588 ifneq ($(feature-libperl), 1)
589 CFLAGS += -DNO_LIBPERL
590 NO_LIBPERL := 1
591 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
592 else
593 LDFLAGS += $(PERL_EMBED_LDFLAGS)
594 EXTLIBS += $(PERL_EMBED_LIBADD)
595 $(call detected,CONFIG_LIBPERL)
596 endif
597 endif
598
599 ifeq ($(feature-timerfd), 1)
600 CFLAGS += -DHAVE_TIMERFD_SUPPORT
601 else
602 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
603 endif
604
605 disable-python = $(eval $(disable-python_code))
606 define disable-python_code
607 CFLAGS += -DNO_LIBPYTHON
608 $(warning $1)
609 NO_LIBPYTHON := 1
610 endef
611
612 ifdef NO_LIBPYTHON
613 $(call disable-python,Python support disabled by user)
614 else
615
616 ifndef PYTHON
617 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
618 else
619 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
620
621 ifndef PYTHON_CONFIG
622 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
623 else
624
625 ifneq ($(feature-libpython), 1)
626 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
627 else
628 ifneq ($(feature-libpython-version), 1)
629 $(warning Python 3 is not yet supported; please set)
630 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
631 $(warning If you also have Python 2 installed, then)
632 $(warning try something like:)
633 $(warning $(and ,))
634 $(warning $(and ,) make PYTHON=python2)
635 $(warning $(and ,))
636 $(warning Otherwise, disable Python support entirely:)
637 $(warning $(and ,))
638 $(warning $(and ,) make NO_LIBPYTHON=1)
639 $(warning $(and ,))
640 $(error $(and ,))
641 else
642 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
643 EXTLIBS += $(PYTHON_EMBED_LIBADD)
644 LANG_BINDINGS += $(obj-perf)python/perf.so
645 $(call detected,CONFIG_LIBPYTHON)
646 endif
647 endif
648 endif
649 endif
650 endif
651
652 ifdef HAVE_NO_LIBBFD
653 feature-libbfd := 0
654 endif
655
656 ifeq ($(feature-libbfd), 1)
657 EXTLIBS += -lbfd
658
659 # call all detections now so we get correct
660 # status in VF output
661 $(call feature_check,liberty)
662 $(call feature_check,liberty-z)
663 $(call feature_check,cplus-demangle)
664
665 ifeq ($(feature-liberty), 1)
666 EXTLIBS += -liberty
667 else
668 ifeq ($(feature-liberty-z), 1)
669 EXTLIBS += -liberty -lz
670 endif
671 endif
672 endif
673
674 ifdef NO_DEMANGLE
675 CFLAGS += -DNO_DEMANGLE
676 else
677 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
678 EXTLIBS += -liberty
679 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
680 else
681 ifneq ($(feature-libbfd), 1)
682 ifneq ($(feature-liberty), 1)
683 ifneq ($(feature-liberty-z), 1)
684 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
685 # or any of 'bfd iberty z' trinity
686 ifeq ($(feature-cplus-demangle), 1)
687 EXTLIBS += -liberty
688 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
689 else
690 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
691 CFLAGS += -DNO_DEMANGLE
692 endif
693 endif
694 endif
695 endif
696 endif
697 endif
698
699 ifneq ($(filter -lbfd,$(EXTLIBS)),)
700 CFLAGS += -DHAVE_LIBBFD_SUPPORT
701 endif
702
703 ifndef NO_ZLIB
704 ifeq ($(feature-zlib), 1)
705 CFLAGS += -DHAVE_ZLIB_SUPPORT
706 EXTLIBS += -lz
707 $(call detected,CONFIG_ZLIB)
708 else
709 NO_ZLIB := 1
710 endif
711 endif
712
713 ifndef NO_LZMA
714 ifeq ($(feature-lzma), 1)
715 CFLAGS += -DHAVE_LZMA_SUPPORT
716 EXTLIBS += -llzma
717 $(call detected,CONFIG_LZMA)
718 else
719 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
720 NO_LZMA := 1
721 endif
722 endif
723
724 ifndef NO_BACKTRACE
725 ifeq ($(feature-backtrace), 1)
726 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
727 endif
728 endif
729
730 ifndef NO_LIBNUMA
731 ifeq ($(feature-libnuma), 0)
732 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
733 NO_LIBNUMA := 1
734 else
735 ifeq ($(feature-numa_num_possible_cpus), 0)
736 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
737 NO_LIBNUMA := 1
738 else
739 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
740 EXTLIBS += -lnuma
741 $(call detected,CONFIG_NUMA)
742 endif
743 endif
744 endif
745
746 ifdef HAVE_KVM_STAT_SUPPORT
747 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
748 endif
749
750 ifeq (${IS_64_BIT}, 1)
751 ifndef NO_PERF_READ_VDSO32
752 $(call feature_check,compile-32)
753 ifeq ($(feature-compile-32), 1)
754 CFLAGS += -DHAVE_PERF_READ_VDSO32
755 else
756 NO_PERF_READ_VDSO32 := 1
757 endif
758 endif
759 ifneq ($(SRCARCH), x86)
760 NO_PERF_READ_VDSOX32 := 1
761 endif
762 ifndef NO_PERF_READ_VDSOX32
763 $(call feature_check,compile-x32)
764 ifeq ($(feature-compile-x32), 1)
765 CFLAGS += -DHAVE_PERF_READ_VDSOX32
766 else
767 NO_PERF_READ_VDSOX32 := 1
768 endif
769 endif
770 else
771 NO_PERF_READ_VDSO32 := 1
772 NO_PERF_READ_VDSOX32 := 1
773 endif
774
775 ifdef LIBBABELTRACE
776 $(call feature_check,libbabeltrace)
777 ifeq ($(feature-libbabeltrace), 1)
778 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
779 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
780 EXTLIBS += -lbabeltrace-ctf
781 $(call detected,CONFIG_LIBBABELTRACE)
782 else
783 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
784 endif
785 endif
786
787 ifndef NO_AUXTRACE
788 ifeq ($(SRCARCH),x86)
789 ifeq ($(feature-get_cpuid), 0)
790 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
791 NO_AUXTRACE := 1
792 endif
793 endif
794 ifndef NO_AUXTRACE
795 $(call detected,CONFIG_AUXTRACE)
796 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
797 endif
798 endif
799
800 ifndef NO_JVMTI
801 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
802 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
803 else
804 ifneq (,$(wildcard /usr/sbin/alternatives))
805 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
806 endif
807 endif
808 ifndef JDIR
809 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
810 NO_JVMTI := 1
811 endif
812 endif
813
814 ifndef NO_JVMTI
815 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
816 $(call feature_check,jvmti)
817 ifeq ($(feature-jvmti), 1)
818 $(call detected_var,JDIR)
819 else
820 $(warning No openjdk development package found, please install JDK package)
821 NO_JVMTI := 1
822 endif
823 endif
824
825 USE_CXX = 0
826 USE_CLANGLLVM = 0
827 ifdef LIBCLANGLLVM
828 $(call feature_check,cxx)
829 ifneq ($(feature-cxx), 1)
830 msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
831 else
832 $(call feature_check,llvm)
833 $(call feature_check,llvm-version)
834 ifneq ($(feature-llvm), 1)
835 msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
836 else
837 $(call feature_check,clang)
838 ifneq ($(feature-clang), 1)
839 msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
840 else
841 CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
842 CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
843 $(call detected,CONFIG_CXX)
844 $(call detected,CONFIG_CLANGLLVM)
845 USE_CXX = 1
846 USE_LLVM = 1
847 USE_CLANG = 1
848 ifneq ($(feature-llvm-version),1)
849 msg := $(warning This version of LLVM is not tested. May cause build errors)
850 endif
851 endif
852 endif
853 endif
854 endif
855
856 # Among the variables below, these:
857 # perfexecdir
858 # template_dir
859 # mandir
860 # infodir
861 # htmldir
862 # ETC_PERFCONFIG (but not sysconfdir)
863 # can be specified as a relative path some/where/else;
864 # this is interpreted as relative to $(prefix) and "perf" at
865 # runtime figures out where they are based on the path to the executable.
866 # This can help installing the suite in a relocatable way.
867
868 # Make the path relative to DESTDIR, not to prefix
869 ifndef DESTDIR
870 prefix ?= $(HOME)
871 endif
872 bindir_relative = bin
873 bindir = $(abspath $(prefix)/$(bindir_relative))
874 mandir = share/man
875 infodir = share/info
876 perfexecdir = libexec/perf-core
877 sharedir = $(prefix)/share
878 template_dir = share/perf-core/templates
879 STRACE_GROUPS_DIR = share/perf-core/strace/groups
880 htmldir = share/doc/perf-doc
881 tipdir = share/doc/perf-tip
882 srcdir = $(srctree)/tools/perf
883 ifeq ($(prefix),/usr)
884 sysconfdir = /etc
885 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
886 else
887 sysconfdir = $(prefix)/etc
888 ETC_PERFCONFIG = etc/perfconfig
889 endif
890 ifndef lib
891 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
892 lib = lib64
893 else
894 lib = lib
895 endif
896 endif # lib
897 libdir = $(prefix)/$(lib)
898
899 # Shell quote (do not use $(call) to accommodate ancient setups);
900 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
901 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
902 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
903 bindir_SQ = $(subst ','\'',$(bindir))
904 mandir_SQ = $(subst ','\'',$(mandir))
905 infodir_SQ = $(subst ','\'',$(infodir))
906 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
907 template_dir_SQ = $(subst ','\'',$(template_dir))
908 htmldir_SQ = $(subst ','\'',$(htmldir))
909 tipdir_SQ = $(subst ','\'',$(tipdir))
910 prefix_SQ = $(subst ','\'',$(prefix))
911 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
912 libdir_SQ = $(subst ','\'',$(libdir))
913 srcdir_SQ = $(subst ','\'',$(srcdir))
914
915 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
916 perfexec_instdir = $(perfexecdir)
917 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
918 tip_instdir = $(tipdir)
919 else
920 perfexec_instdir = $(prefix)/$(perfexecdir)
921 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
922 tip_instdir = $(prefix)/$(tipdir)
923 endif
924 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
925 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
926 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
927
928 # If we install to $(HOME) we keep the traceevent default:
929 # $(HOME)/.traceevent/plugins
930 # Otherwise we install plugins into the global $(libdir).
931 ifdef DESTDIR
932 plugindir=$(libdir)/traceevent/plugins
933 plugindir_SQ= $(subst ','\'',$(plugindir))
934 endif
935
936 print_var = $(eval $(print_var_code)) $(info $(MSG))
937 define print_var_code
938 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
939 endef
940
941 ifeq ($(VF),1)
942 $(call print_var,prefix)
943 $(call print_var,bindir)
944 $(call print_var,libdir)
945 $(call print_var,sysconfdir)
946 $(call print_var,LIBUNWIND_DIR)
947 $(call print_var,LIBDW_DIR)
948 $(call print_var,JDIR)
949
950 ifeq ($(dwarf-post-unwind),1)
951 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
952 endif
953 $(info )
954 endif
955
956 $(call detected_var,bindir_SQ)
957 $(call detected_var,PYTHON_WORD)
958 ifneq ($(OUTPUT),)
959 $(call detected_var,OUTPUT)
960 endif
961 $(call detected_var,htmldir_SQ)
962 $(call detected_var,infodir_SQ)
963 $(call detected_var,mandir_SQ)
964 $(call detected_var,ETC_PERFCONFIG_SQ)
965 $(call detected_var,STRACE_GROUPS_DIR_SQ)
966 $(call detected_var,prefix_SQ)
967 $(call detected_var,perfexecdir_SQ)
968 $(call detected_var,tipdir_SQ)
969 $(call detected_var,srcdir_SQ)
970 $(call detected_var,LIBDIR)
971 $(call detected_var,GTK_CFLAGS)
972 $(call detected_var,PERL_EMBED_CCOPTS)
973 $(call detected_var,PYTHON_EMBED_CCOPTS)