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