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