perf unwind: Don't mix LIBUNWIND_LIBS into LIBUNWIND_LDFLAGS
[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   ifneq ($(feature-libunwind), 1)
357     msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
358     NO_LIBUNWIND := 1
359   endif
360 endif
361
362 ifndef NO_LIBBPF
363   ifneq ($(feature-bpf), 1)
364     msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
365     NO_LIBBPF := 1
366   endif
367 endif
368
369 dwarf-post-unwind := 1
370 dwarf-post-unwind-text := BUG
371
372 # setup DWARF post unwinder
373 ifdef NO_LIBUNWIND
374   ifdef NO_LIBDW_DWARF_UNWIND
375     msg := $(warning Disabling post unwind, no support found.);
376     dwarf-post-unwind := 0
377   else
378     dwarf-post-unwind-text := libdw
379     $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
380   endif
381 else
382   dwarf-post-unwind-text := libunwind
383   $(call detected,CONFIG_LIBUNWIND)
384   # Enable libunwind support by default.
385   ifndef NO_LIBDW_DWARF_UNWIND
386     NO_LIBDW_DWARF_UNWIND := 1
387   endif
388 endif
389
390 ifeq ($(dwarf-post-unwind),1)
391   CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
392   $(call detected,CONFIG_DWARF_UNWIND)
393 else
394   NO_DWARF_UNWIND := 1
395 endif
396
397 ifndef NO_LIBUNWIND
398   ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
399     $(call feature_check,libunwind-debug-frame)
400     ifneq ($(feature-libunwind-debug-frame), 1)
401       msg := $(warning No debug_frame support found in libunwind);
402       CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
403     endif
404   else
405     # non-ARM has no dwarf_find_debug_frame() function:
406     CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
407   endif
408   CFLAGS  += -DHAVE_LIBUNWIND_SUPPORT
409   EXTLIBS += $(LIBUNWIND_LIBS)
410   CFLAGS  += $(LIBUNWIND_CFLAGS)
411   LDFLAGS += $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
412 endif
413
414 ifndef NO_LIBAUDIT
415   ifneq ($(feature-libaudit), 1)
416     msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
417     NO_LIBAUDIT := 1
418   else
419     CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
420     EXTLIBS += -laudit
421     $(call detected,CONFIG_AUDIT)
422   endif
423 endif
424
425 ifndef NO_LIBCRYPTO
426   ifneq ($(feature-libcrypto), 1)
427     msg := $(warning No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev);
428     NO_LIBCRYPTO := 1
429   else
430     CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
431     EXTLIBS += -lcrypto
432     $(call detected,CONFIG_CRYPTO)
433   endif
434 endif
435
436 ifdef NO_NEWT
437   NO_SLANG=1
438 endif
439
440 ifndef NO_SLANG
441   ifneq ($(feature-libslang), 1)
442     msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
443     NO_SLANG := 1
444   else
445     # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
446     CFLAGS += -I/usr/include/slang
447     CFLAGS += -DHAVE_SLANG_SUPPORT
448     EXTLIBS += -lslang
449     $(call detected,CONFIG_SLANG)
450   endif
451 endif
452
453 ifndef NO_GTK2
454   FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
455   ifneq ($(feature-gtk2), 1)
456     msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
457     NO_GTK2 := 1
458   else
459     ifeq ($(feature-gtk2-infobar), 1)
460       GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
461     endif
462     CFLAGS += -DHAVE_GTK2_SUPPORT
463     GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
464     GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
465     EXTLIBS += -ldl
466   endif
467 endif
468
469 grep-libs  = $(filter -l%,$(1))
470 strip-libs = $(filter-out -l%,$(1))
471
472 ifdef NO_LIBPERL
473   CFLAGS += -DNO_LIBPERL
474 else
475   PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
476   PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
477   PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
478   PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
479   FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
480
481   ifneq ($(feature-libperl), 1)
482     CFLAGS += -DNO_LIBPERL
483     NO_LIBPERL := 1
484     msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
485   else
486     LDFLAGS += $(PERL_EMBED_LDFLAGS)
487     EXTLIBS += $(PERL_EMBED_LIBADD)
488     $(call detected,CONFIG_LIBPERL)
489   endif
490 endif
491
492 ifeq ($(feature-timerfd), 1)
493   CFLAGS += -DHAVE_TIMERFD_SUPPORT
494 else
495   msg := $(warning No timerfd support. Disables 'perf kvm stat live');
496 endif
497
498 disable-python = $(eval $(disable-python_code))
499 define disable-python_code
500   CFLAGS += -DNO_LIBPYTHON
501   $(warning $1)
502   NO_LIBPYTHON := 1
503 endef
504
505 ifdef NO_LIBPYTHON
506   $(call disable-python,Python support disabled by user)
507 else
508
509   ifndef PYTHON
510     $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
511   else
512     PYTHON_WORD := $(call shell-wordify,$(PYTHON))
513
514     ifndef PYTHON_CONFIG
515       $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
516     else
517
518       PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
519
520       PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
521       PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
522       PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
523       PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
524       FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
525
526       ifneq ($(feature-libpython), 1)
527         $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
528       else
529
530         ifneq ($(feature-libpython-version), 1)
531           $(warning Python 3 is not yet supported; please set)
532           $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
533           $(warning If you also have Python 2 installed, then)
534           $(warning try something like:)
535           $(warning $(and ,))
536           $(warning $(and ,)  make PYTHON=python2)
537           $(warning $(and ,))
538           $(warning Otherwise, disable Python support entirely:)
539           $(warning $(and ,))
540           $(warning $(and ,)  make NO_LIBPYTHON=1)
541           $(warning $(and ,))
542           $(error   $(and ,))
543         else
544           LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
545           EXTLIBS += $(PYTHON_EMBED_LIBADD)
546           LANG_BINDINGS += $(obj-perf)python/perf.so
547           $(call detected,CONFIG_LIBPYTHON)
548         endif
549       endif
550     endif
551   endif
552 endif
553
554 ifeq ($(feature-libbfd), 1)
555   EXTLIBS += -lbfd
556
557   # call all detections now so we get correct
558   # status in VF output
559   $(call feature_check,liberty)
560   $(call feature_check,liberty-z)
561   $(call feature_check,cplus-demangle)
562
563   ifeq ($(feature-liberty), 1)
564     EXTLIBS += -liberty
565   else
566     ifeq ($(feature-liberty-z), 1)
567       EXTLIBS += -liberty -lz
568     endif
569   endif
570 endif
571
572 ifdef NO_DEMANGLE
573   CFLAGS += -DNO_DEMANGLE
574 else
575   ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
576     EXTLIBS += -liberty
577     CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
578   else
579     ifneq ($(feature-libbfd), 1)
580       ifneq ($(feature-liberty), 1)
581         ifneq ($(feature-liberty-z), 1)
582           # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
583           # or any of 'bfd iberty z' trinity
584           ifeq ($(feature-cplus-demangle), 1)
585             EXTLIBS += -liberty
586             CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
587           else
588             msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
589             CFLAGS += -DNO_DEMANGLE
590           endif
591         endif
592       endif
593     endif
594   endif
595 endif
596
597 ifneq ($(filter -lbfd,$(EXTLIBS)),)
598   CFLAGS += -DHAVE_LIBBFD_SUPPORT
599 endif
600
601 ifndef NO_ZLIB
602   ifeq ($(feature-zlib), 1)
603     CFLAGS += -DHAVE_ZLIB_SUPPORT
604     EXTLIBS += -lz
605     $(call detected,CONFIG_ZLIB)
606   else
607     NO_ZLIB := 1
608   endif
609 endif
610
611 ifndef NO_LZMA
612   ifeq ($(feature-lzma), 1)
613     CFLAGS += -DHAVE_LZMA_SUPPORT
614     EXTLIBS += -llzma
615     $(call detected,CONFIG_LZMA)
616   else
617     msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
618     NO_LZMA := 1
619   endif
620 endif
621
622 ifndef NO_BACKTRACE
623   ifeq ($(feature-backtrace), 1)
624     CFLAGS += -DHAVE_BACKTRACE_SUPPORT
625   endif
626 endif
627
628 ifndef NO_LIBNUMA
629   ifeq ($(feature-libnuma), 0)
630     msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
631     NO_LIBNUMA := 1
632   else
633     ifeq ($(feature-numa_num_possible_cpus), 0)
634       msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
635       NO_LIBNUMA := 1
636     else
637       CFLAGS += -DHAVE_LIBNUMA_SUPPORT
638       EXTLIBS += -lnuma
639       $(call detected,CONFIG_NUMA)
640     endif
641   endif
642 endif
643
644 ifdef HAVE_KVM_STAT_SUPPORT
645     CFLAGS += -DHAVE_KVM_STAT_SUPPORT
646 endif
647
648 ifeq (${IS_64_BIT}, 1)
649   ifndef NO_PERF_READ_VDSO32
650     $(call feature_check,compile-32)
651     ifeq ($(feature-compile-32), 1)
652       CFLAGS += -DHAVE_PERF_READ_VDSO32
653     else
654       NO_PERF_READ_VDSO32 := 1
655     endif
656   endif
657   ifneq ($(ARCH), x86)
658     NO_PERF_READ_VDSOX32 := 1
659   endif
660   ifndef NO_PERF_READ_VDSOX32
661     $(call feature_check,compile-x32)
662     ifeq ($(feature-compile-x32), 1)
663       CFLAGS += -DHAVE_PERF_READ_VDSOX32
664     else
665       NO_PERF_READ_VDSOX32 := 1
666     endif
667   endif
668 else
669   NO_PERF_READ_VDSO32 := 1
670   NO_PERF_READ_VDSOX32 := 1
671 endif
672
673 ifdef LIBBABELTRACE
674   $(call feature_check,libbabeltrace)
675   ifeq ($(feature-libbabeltrace), 1)
676     CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
677     LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
678     EXTLIBS += -lbabeltrace-ctf
679     $(call detected,CONFIG_LIBBABELTRACE)
680   else
681     msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
682   endif
683 endif
684
685 ifndef NO_AUXTRACE
686   ifeq ($(feature-get_cpuid), 0)
687     msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
688     NO_AUXTRACE := 1
689   else
690     $(call detected,CONFIG_AUXTRACE)
691     CFLAGS += -DHAVE_AUXTRACE_SUPPORT
692   endif
693 endif
694
695 # Among the variables below, these:
696 #   perfexecdir
697 #   template_dir
698 #   mandir
699 #   infodir
700 #   htmldir
701 #   ETC_PERFCONFIG (but not sysconfdir)
702 # can be specified as a relative path some/where/else;
703 # this is interpreted as relative to $(prefix) and "perf" at
704 # runtime figures out where they are based on the path to the executable.
705 # This can help installing the suite in a relocatable way.
706
707 # Make the path relative to DESTDIR, not to prefix
708 ifndef DESTDIR
709 prefix ?= $(HOME)
710 endif
711 bindir_relative = bin
712 bindir = $(abspath $(prefix)/$(bindir_relative))
713 mandir = share/man
714 infodir = share/info
715 perfexecdir = libexec/perf-core
716 sharedir = $(prefix)/share
717 template_dir = share/perf-core/templates
718 STRACE_GROUPS_DIR = share/perf-core/strace/groups
719 htmldir = share/doc/perf-doc
720 tipdir = share/doc/perf-tip
721 srcdir = $(srctree)/tools/perf
722 ifeq ($(prefix),/usr)
723 sysconfdir = /etc
724 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
725 else
726 sysconfdir = $(prefix)/etc
727 ETC_PERFCONFIG = etc/perfconfig
728 endif
729 ifndef lib
730 ifeq ($(ARCH)$(IS_64_BIT), x861)
731 lib = lib64
732 else
733 lib = lib
734 endif
735 endif # lib
736 libdir = $(prefix)/$(lib)
737
738 # Shell quote (do not use $(call) to accommodate ancient setups);
739 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
740 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
741 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
742 bindir_SQ = $(subst ','\'',$(bindir))
743 mandir_SQ = $(subst ','\'',$(mandir))
744 infodir_SQ = $(subst ','\'',$(infodir))
745 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
746 template_dir_SQ = $(subst ','\'',$(template_dir))
747 htmldir_SQ = $(subst ','\'',$(htmldir))
748 tipdir_SQ = $(subst ','\'',$(tipdir))
749 prefix_SQ = $(subst ','\'',$(prefix))
750 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
751 libdir_SQ = $(subst ','\'',$(libdir))
752 srcdir_SQ = $(subst ','\'',$(srcdir))
753
754 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
755 perfexec_instdir = $(perfexecdir)
756 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
757 tip_instdir = $(tipdir)
758 else
759 perfexec_instdir = $(prefix)/$(perfexecdir)
760 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
761 tip_instdir = $(prefix)/$(tipdir)
762 endif
763 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
764 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
765 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
766
767 # If we install to $(HOME) we keep the traceevent default:
768 # $(HOME)/.traceevent/plugins
769 # Otherwise we install plugins into the global $(libdir).
770 ifdef DESTDIR
771 plugindir=$(libdir)/traceevent/plugins
772 plugindir_SQ= $(subst ','\'',$(plugindir))
773 endif
774
775 print_var = $(eval $(print_var_code)) $(info $(MSG))
776 define print_var_code
777     MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
778 endef
779
780 ifeq ($(VF),1)
781   $(call print_var,prefix)
782   $(call print_var,bindir)
783   $(call print_var,libdir)
784   $(call print_var,sysconfdir)
785   $(call print_var,LIBUNWIND_DIR)
786   $(call print_var,LIBDW_DIR)
787
788   ifeq ($(dwarf-post-unwind),1)
789     $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
790   endif
791   $(info )
792 endif
793
794 $(call detected_var,bindir_SQ)
795 $(call detected_var,PYTHON_WORD)
796 ifneq ($(OUTPUT),)
797 $(call detected_var,OUTPUT)
798 endif
799 $(call detected_var,htmldir_SQ)
800 $(call detected_var,infodir_SQ)
801 $(call detected_var,mandir_SQ)
802 $(call detected_var,ETC_PERFCONFIG_SQ)
803 $(call detected_var,STRACE_GROUPS_DIR_SQ)
804 $(call detected_var,prefix_SQ)
805 $(call detected_var,perfexecdir_SQ)
806 $(call detected_var,tipdir_SQ)
807 $(call detected_var,srcdir_SQ)
808 $(call detected_var,LIBDIR)
809 $(call detected_var,GTK_CFLAGS)
810 $(call detected_var,PERL_EMBED_CCOPTS)
811 $(call detected_var,PYTHON_EMBED_CCOPTS)