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