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