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