perf kcore_copy: Do not check /proc/modules is unchanged
[platform/kernel/linux-rpi.git] / tools / perf / Makefile.config
1 # SPDX-License-Identifier: GPL-2.0-only
2
3 ifeq ($(src-perf),)
4 src-perf := $(srctree)/tools/perf
5 endif
6
7 ifeq ($(obj-perf),)
8 obj-perf := $(OUTPUT)
9 endif
10
11 ifneq ($(obj-perf),)
12 obj-perf := $(abspath $(obj-perf))/
13 endif
14
15 $(shell printf "" > $(OUTPUT).config-detected)
16 detected     = $(shell echo "$(1)=y"       >> $(OUTPUT).config-detected)
17 detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
18
19 CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
20
21 include $(srctree)/tools/scripts/Makefile.arch
22
23 $(call detected_var,SRCARCH)
24
25 NO_PERF_REGS := 1
26
27 ifneq ($(NO_SYSCALL_TABLE),1)
28   NO_SYSCALL_TABLE := 1
29
30   ifeq ($(SRCARCH),x86)
31     ifeq (${IS_64_BIT}, 1)
32       NO_SYSCALL_TABLE := 0
33     endif
34   else
35     ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390 mips))
36       NO_SYSCALL_TABLE := 0
37     endif
38   endif
39
40   ifneq ($(NO_SYSCALL_TABLE),1)
41     CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT
42   endif
43 endif
44
45 # Additional ARCH settings for ppc
46 ifeq ($(SRCARCH),powerpc)
47   NO_PERF_REGS := 0
48   CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated
49   LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
50 endif
51
52 # Additional ARCH settings for x86
53 ifeq ($(SRCARCH),x86)
54   $(call detected,CONFIG_X86)
55   ifeq (${IS_64_BIT}, 1)
56     CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated
57     ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
58     LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
59     $(call detected,CONFIG_X86_64)
60   else
61     LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
62   endif
63   NO_PERF_REGS := 0
64 endif
65
66 ifeq ($(SRCARCH),arm)
67   NO_PERF_REGS := 0
68   LIBUNWIND_LIBS = -lunwind -lunwind-arm
69 endif
70
71 ifeq ($(SRCARCH),arm64)
72   NO_PERF_REGS := 0
73   CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
74   LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
75 endif
76
77 ifeq ($(SRCARCH),riscv)
78   NO_PERF_REGS := 0
79 endif
80
81 ifeq ($(SRCARCH),csky)
82   NO_PERF_REGS := 0
83 endif
84
85 ifeq ($(ARCH),s390)
86   NO_PERF_REGS := 0
87   CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
88 endif
89
90 ifeq ($(ARCH),mips)
91   NO_PERF_REGS := 0
92   CFLAGS += -I$(OUTPUT)arch/mips/include/generated
93   LIBUNWIND_LIBS = -lunwind -lunwind-mips
94 endif
95
96 ifeq ($(NO_PERF_REGS),0)
97   $(call detected,CONFIG_PERF_REGS)
98 endif
99
100 # So far there's only x86 and arm libdw unwind support merged in perf.
101 # Disable it on all other architectures in case libdw unwind
102 # support is detected in system. Add supported architectures
103 # to the check.
104 ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv))
105   NO_LIBDW_DWARF_UNWIND := 1
106 endif
107
108 ifeq ($(LIBUNWIND_LIBS),)
109   NO_LIBUNWIND := 1
110 endif
111 #
112 # For linking with debug library, run like:
113 #
114 #   make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
115 #
116
117 libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
118 define libunwind_arch_set_flags_code
119   FEATURE_CHECK_CFLAGS-libunwind-$(1)  = -I$(LIBUNWIND_DIR)/include
120   FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib
121 endef
122
123 ifdef LIBUNWIND_DIR
124   LIBUNWIND_CFLAGS  = -I$(LIBUNWIND_DIR)/include
125   LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
126   LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64
127   $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
128 endif
129
130 # Set per-feature check compilation flags
131 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
132 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
133 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
134 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
135
136 FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm
137 FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
138 FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
139 FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
140
141 FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
142
143 ifdef CSINCLUDES
144   LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
145 endif
146 OPENCSDLIBS := -lopencsd_c_api
147 ifeq ($(findstring -static,${LDFLAGS}),-static)
148   OPENCSDLIBS += -lopencsd -lstdc++
149 endif
150 ifdef CSLIBS
151   LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
152 endif
153 FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)
154 FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)
155
156 ifeq ($(NO_PERF_REGS),0)
157   CFLAGS += -DHAVE_PERF_REGS_SUPPORT
158 endif
159
160 # for linking with debug library, run like:
161 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
162 ifdef LIBDW_DIR
163   LIBDW_CFLAGS  := -I$(LIBDW_DIR)/include
164   LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
165 endif
166 DWARFLIBS := -ldw
167 ifeq ($(findstring -static,${LDFLAGS}),-static)
168   DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
169 endif
170 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
171 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
172
173 # for linking with debug library, run like:
174 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
175 ifdef LIBBABELTRACE_DIR
176   LIBBABELTRACE_CFLAGS  := -I$(LIBBABELTRACE_DIR)/include
177   LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
178 endif
179 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
180 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
181
182 ifdef LIBZSTD_DIR
183   LIBZSTD_CFLAGS  := -I$(LIBZSTD_DIR)/lib
184   LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
185 endif
186 FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
187 FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
188
189 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
190 # include ARCH specific config
191 -include $(src-perf)/arch/$(SRCARCH)/Makefile
192
193 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
194   CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
195 endif
196
197 include $(srctree)/tools/scripts/utilities.mak
198
199 ifeq ($(call get-executable,$(FLEX)),)
200   dummy := $(error Error: $(FLEX) is missing on this system, please install it)
201 endif
202
203 ifeq ($(call get-executable,$(BISON)),)
204   dummy := $(error Error: $(BISON) is missing on this system, please install it)
205 endif
206
207 ifneq ($(OUTPUT),)
208   ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1)
209     BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)=
210   endif
211 endif
212
213 # Treat warnings as errors unless directed not to
214 ifneq ($(WERROR),0)
215   CORE_CFLAGS += -Werror
216   CXXFLAGS += -Werror
217 endif
218
219 ifndef DEBUG
220   DEBUG := 0
221 endif
222
223 ifeq ($(DEBUG),0)
224 ifeq ($(CC_NO_CLANG), 0)
225   CORE_CFLAGS += -O3
226 else
227   CORE_CFLAGS += -O6
228 endif
229 endif
230
231 ifdef PARSER_DEBUG
232   PARSER_DEBUG_BISON := -t
233   PARSER_DEBUG_FLEX  := -d
234   CFLAGS             += -DPARSER_DEBUG
235   $(call detected_var,PARSER_DEBUG_BISON)
236   $(call detected_var,PARSER_DEBUG_FLEX)
237 endif
238
239 # Try different combinations to accommodate systems that only have
240 # python[2][3]-config in weird combinations in the following order of
241 # priority from lowest to highest:
242 #   * python3-config
243 #   * python-config
244 #   * python2-config as per pep-0394.
245 #   * $(PYTHON)-config (If PYTHON is user supplied but PYTHON_CONFIG isn't)
246 #
247 PYTHON_AUTO := python-config
248 PYTHON_AUTO := $(if $(call get-executable,python3-config),python3-config,$(PYTHON_AUTO))
249 PYTHON_AUTO := $(if $(call get-executable,python-config),python-config,$(PYTHON_AUTO))
250 PYTHON_AUTO := $(if $(call get-executable,python2-config),python2-config,$(PYTHON_AUTO))
251
252 # If PYTHON is defined but PYTHON_CONFIG isn't, then take $(PYTHON)-config as if it was the user
253 # supplied value for PYTHON_CONFIG. Because it's "user supplied", error out if it doesn't exist.
254 ifdef PYTHON
255   ifndef PYTHON_CONFIG
256     PYTHON_CONFIG_AUTO := $(call get-executable,$(PYTHON)-config)
257     PYTHON_CONFIG := $(if $(PYTHON_CONFIG_AUTO),$(PYTHON_CONFIG_AUTO),\
258                           $(call $(error $(PYTHON)-config not found)))
259   endif
260 endif
261
262 # Select either auto detected python and python-config or use user supplied values if they are
263 # defined. get-executable-or-default fails with an error if the first argument is supplied but
264 # doesn't exist.
265 override PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO))
266 override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_CONFIG)))
267
268 grep-libs  = $(filter -l%,$(1))
269 strip-libs  = $(filter-out -l%,$(1))
270
271 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
272
273 # Python 3.8 changed the output of `python-config --ldflags` to not include the
274 # '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
275 # libpython fails if that flag is not included in LDFLAGS
276 ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
277   PYTHON_CONFIG_LDFLAGS := --ldflags --embed
278 else
279   PYTHON_CONFIG_LDFLAGS := --ldflags
280 endif
281
282 ifdef PYTHON_CONFIG
283   PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
284   PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
285   PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
286   PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
287   FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
288   ifeq ($(CC_NO_CLANG), 0)
289     PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS))
290   endif
291 endif
292
293 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
294 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
295
296 FEATURE_CHECK_LDFLAGS-libaio = -lrt
297
298 FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
299
300 CORE_CFLAGS += -fno-omit-frame-pointer
301 CORE_CFLAGS += -ggdb3
302 CORE_CFLAGS += -funwind-tables
303 CORE_CFLAGS += -Wall
304 CORE_CFLAGS += -Wextra
305 CORE_CFLAGS += -std=gnu99
306
307 CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
308 CXXFLAGS += -Wall
309 CXXFLAGS += -fno-omit-frame-pointer
310 CXXFLAGS += -ggdb3
311 CXXFLAGS += -funwind-tables
312 CXXFLAGS += -Wno-strict-aliasing
313
314 # Enforce a non-executable stack, as we may regress (again) in the future by
315 # adding assembler files missing the .GNU-stack linker note.
316 LDFLAGS += -Wl,-z,noexecstack
317
318 EXTLIBS = -lpthread -lrt -lm -ldl
319
320 ifneq ($(TCMALLOC),)
321   CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
322   EXTLIBS += -ltcmalloc
323 endif
324
325 ifeq ($(FEATURES_DUMP),)
326 # We will display at the end of this Makefile.config, using $(call feature_display_entries)
327 # As we may retry some feature detection here, see the disassembler-four-args case, for instance
328   FEATURE_DISPLAY_DEFERRED := 1
329 include $(srctree)/tools/build/Makefile.feature
330 else
331 include $(FEATURES_DUMP)
332 endif
333
334 ifeq ($(feature-stackprotector-all), 1)
335   CORE_CFLAGS += -fstack-protector-all
336 endif
337
338 ifeq ($(DEBUG),0)
339   ifeq ($(feature-fortify-source), 1)
340     CORE_CFLAGS += -D_FORTIFY_SOURCE=2
341   endif
342 endif
343
344 INC_FLAGS += -I$(srctree)/tools/lib/perf/include
345 INC_FLAGS += -I$(src-perf)/util/include
346 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
347 INC_FLAGS += -I$(srctree)/tools/include/
348 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
349 INC_FLAGS += -I$(srctree)/tools/include/uapi
350 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
351 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
352
353 # $(obj-perf)      for generated common-cmds.h
354 # $(obj-perf)/util for generated bison/flex headers
355 ifneq ($(OUTPUT),)
356 INC_FLAGS += -I$(obj-perf)/util
357 INC_FLAGS += -I$(obj-perf)
358 endif
359
360 INC_FLAGS += -I$(src-perf)/util
361 INC_FLAGS += -I$(src-perf)
362 INC_FLAGS += -I$(srctree)/tools/lib/
363
364 CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
365
366 CFLAGS   += $(CORE_CFLAGS) $(INC_FLAGS)
367 CXXFLAGS += $(INC_FLAGS)
368
369 LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)
370
371 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
372   CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
373 endif
374
375 ifeq ($(feature-pthread-barrier), 1)
376   CFLAGS += -DHAVE_PTHREAD_BARRIER
377 endif
378
379 ifndef NO_BIONIC
380   $(call feature_check,bionic)
381   ifeq ($(feature-bionic), 1)
382     BIONIC := 1
383     CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
384     CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
385     EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
386     EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
387   endif
388 endif
389
390 ifeq ($(feature-eventfd), 1)
391   CFLAGS += -DHAVE_EVENTFD_SUPPORT
392 endif
393
394 ifeq ($(feature-get_current_dir_name), 1)
395   CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
396 endif
397
398 ifeq ($(feature-gettid), 1)
399   CFLAGS += -DHAVE_GETTID
400 endif
401
402 ifeq ($(feature-file-handle), 1)
403   CFLAGS += -DHAVE_FILE_HANDLE
404 endif
405
406 ifdef NO_LIBELF
407   NO_DWARF := 1
408   NO_DEMANGLE := 1
409   NO_LIBUNWIND := 1
410   NO_LIBDW_DWARF_UNWIND := 1
411   NO_LIBBPF := 1
412   NO_JVMTI := 1
413 else
414   ifeq ($(feature-libelf), 0)
415     ifeq ($(feature-glibc), 1)
416       LIBC_SUPPORT := 1
417     endif
418     ifeq ($(BIONIC),1)
419       LIBC_SUPPORT := 1
420     endif
421     ifeq ($(LIBC_SUPPORT),1)
422       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);
423
424       NO_LIBELF := 1
425       NO_DWARF := 1
426       NO_DEMANGLE := 1
427       NO_LIBUNWIND := 1
428       NO_LIBDW_DWARF_UNWIND := 1
429       NO_LIBBPF := 1
430       NO_JVMTI := 1
431     else
432       ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)
433         ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)
434           msg := $(error No libasan found, please install libasan);
435         endif
436       endif
437
438       ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),)
439         ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0)
440           msg := $(error No libubsan found, please install libubsan);
441         endif
442       endif
443
444       ifneq ($(filter s% -static%,$(LDFLAGS),),)
445         msg := $(error No static glibc found, please install glibc-static);
446       else
447         msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
448       endif
449     endif
450   else
451     ifndef NO_LIBDW_DWARF_UNWIND
452       ifneq ($(feature-libdw-dwarf-unwind),1)
453         NO_LIBDW_DWARF_UNWIND := 1
454         msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
455       endif
456     endif
457     ifneq ($(feature-dwarf), 1)
458       ifndef NO_DWARF
459         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);
460         NO_DWARF := 1
461       endif
462     else
463       ifneq ($(feature-dwarf_getlocations), 1)
464         msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
465       else
466         CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
467       endif # dwarf_getlocations
468     endif # Dwarf support
469   endif # libelf support
470 endif # NO_LIBELF
471
472 ifeq ($(feature-glibc), 1)
473   CFLAGS += -DHAVE_GLIBC_SUPPORT
474 endif
475
476 ifeq ($(feature-libaio), 1)
477   ifndef NO_AIO
478     CFLAGS += -DHAVE_AIO_SUPPORT
479   endif
480 endif
481
482 ifdef NO_DWARF
483   NO_LIBDW_DWARF_UNWIND := 1
484 endif
485
486 ifeq ($(feature-sched_getcpu), 1)
487   CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
488 endif
489
490 ifeq ($(feature-setns), 1)
491   CFLAGS += -DHAVE_SETNS_SUPPORT
492   $(call detected,CONFIG_SETNS)
493 endif
494
495 ifdef CORESIGHT
496   $(call feature_check,libopencsd)
497   ifeq ($(feature-libopencsd), 1)
498     CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
499     ifeq ($(feature-reallocarray), 0)
500       CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
501     endif
502     LDFLAGS += $(LIBOPENCSD_LDFLAGS)
503     EXTLIBS += $(OPENCSDLIBS)
504     $(call detected,CONFIG_LIBOPENCSD)
505     ifdef CSTRACE_RAW
506       CFLAGS += -DCS_DEBUG_RAW
507       ifeq (${CSTRACE_RAW}, packed)
508         CFLAGS += -DCS_RAW_PACKED
509       endif
510     endif
511   else
512     dummy := $(error Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1)
513   endif
514 endif
515
516 ifndef NO_LIBELF
517   CFLAGS += -DHAVE_LIBELF_SUPPORT
518   EXTLIBS += -lelf
519   $(call detected,CONFIG_LIBELF)
520
521   ifeq ($(feature-libelf-getphdrnum), 1)
522     CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
523   endif
524
525   ifeq ($(feature-libelf-gelf_getnote), 1)
526     CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
527   else
528     msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
529   endif
530
531   ifeq ($(feature-libelf-getshdrstrndx), 1)
532     CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
533   endif
534
535   ifndef NO_LIBDEBUGINFOD
536     $(call feature_check,libdebuginfod)
537     ifeq ($(feature-libdebuginfod), 1)
538       CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT
539       EXTLIBS += -ldebuginfod
540     endif
541   endif
542
543   ifndef NO_DWARF
544     ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
545       msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
546       NO_DWARF := 1
547     else
548       CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
549       LDFLAGS += $(LIBDW_LDFLAGS)
550       EXTLIBS += ${DWARFLIBS}
551       $(call detected,CONFIG_DWARF)
552     endif # PERF_HAVE_DWARF_REGS
553   endif # NO_DWARF
554
555   ifndef NO_LIBBPF
556     ifeq ($(feature-bpf), 1)
557       CFLAGS += -DHAVE_LIBBPF_SUPPORT
558       $(call detected,CONFIG_LIBBPF)
559
560       # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status
561       $(call feature_check,libbpf)
562       ifdef LIBBPF_DYNAMIC
563         ifeq ($(feature-libbpf), 1)
564           EXTLIBS += -lbpf
565           $(call detected,CONFIG_LIBBPF_DYNAMIC)
566
567           $(call feature_check,libbpf-btf__load_from_kernel_by_id)
568           ifeq ($(feature-libbpf-btf__load_from_kernel_by_id), 1)
569             CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
570           endif
571         else
572           dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
573         endif
574       else
575         CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
576       endif
577     endif
578
579     ifndef NO_DWARF
580       ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
581         CFLAGS += -DHAVE_BPF_PROLOGUE
582         $(call detected,CONFIG_BPF_PROLOGUE)
583       else
584         msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
585       endif
586     else
587       msg := $(warning DWARF support is off, BPF prologue is disabled);
588     endif
589
590   endif # NO_LIBBPF
591 endif # NO_LIBELF
592
593 ifndef NO_SDT
594   ifneq ($(feature-sdt), 1)
595     msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
596     NO_SDT := 1;
597   else
598     CFLAGS += -DHAVE_SDT_EVENT
599     $(call detected,CONFIG_SDT_EVENT)
600   endif
601 endif
602
603 ifdef PERF_HAVE_JITDUMP
604   ifndef NO_LIBELF
605     $(call detected,CONFIG_JITDUMP)
606     CFLAGS += -DHAVE_JITDUMP
607   endif
608 endif
609
610 ifeq ($(SRCARCH),powerpc)
611   ifndef NO_DWARF
612     CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
613   endif
614 endif
615
616 ifndef NO_LIBUNWIND
617   have_libunwind :=
618
619   $(call feature_check,libunwind-x86)
620   ifeq ($(feature-libunwind-x86), 1)
621     $(call detected,CONFIG_LIBUNWIND_X86)
622     CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
623     LDFLAGS += -lunwind-x86
624     EXTLIBS_LIBUNWIND += -lunwind-x86
625     have_libunwind = 1
626   endif
627
628   $(call feature_check,libunwind-aarch64)
629   ifeq ($(feature-libunwind-aarch64), 1)
630     $(call detected,CONFIG_LIBUNWIND_AARCH64)
631     CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
632     LDFLAGS += -lunwind-aarch64
633     EXTLIBS_LIBUNWIND += -lunwind-aarch64
634     have_libunwind = 1
635     $(call feature_check,libunwind-debug-frame-aarch64)
636     ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
637       msg := $(warning No debug_frame support found in libunwind-aarch64);
638       CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
639     endif
640   endif
641
642   ifneq ($(feature-libunwind), 1)
643     msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
644     NO_LOCAL_LIBUNWIND := 1
645   else
646     have_libunwind := 1
647     $(call detected,CONFIG_LOCAL_LIBUNWIND)
648   endif
649
650   ifneq ($(have_libunwind), 1)
651     NO_LIBUNWIND := 1
652   endif
653 else
654   NO_LOCAL_LIBUNWIND := 1
655 endif
656
657 ifndef NO_LIBBPF
658   ifneq ($(feature-bpf), 1)
659     msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
660     NO_LIBBPF := 1
661   endif
662 endif
663
664 ifdef BUILD_BPF_SKEL
665   $(call feature_check,clang-bpf-co-re)
666   ifeq ($(feature-clang-bpf-co-re), 0)
667     dummy := $(error Error: clang too old/not installed. Please install recent clang to build with BUILD_BPF_SKEL)
668   endif
669   $(call detected,CONFIG_PERF_BPF_SKEL)
670   CFLAGS += -DHAVE_BPF_SKEL
671 endif
672
673 dwarf-post-unwind := 1
674 dwarf-post-unwind-text := BUG
675
676 # setup DWARF post unwinder
677 ifdef NO_LIBUNWIND
678   ifdef NO_LIBDW_DWARF_UNWIND
679     msg := $(warning Disabling post unwind, no support found.);
680     dwarf-post-unwind := 0
681   else
682     dwarf-post-unwind-text := libdw
683     $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
684   endif
685 else
686   dwarf-post-unwind-text := libunwind
687   $(call detected,CONFIG_LIBUNWIND)
688   # Enable libunwind support by default.
689   ifndef NO_LIBDW_DWARF_UNWIND
690     NO_LIBDW_DWARF_UNWIND := 1
691   endif
692 endif
693
694 ifeq ($(dwarf-post-unwind),1)
695   CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
696   $(call detected,CONFIG_DWARF_UNWIND)
697 else
698   NO_DWARF_UNWIND := 1
699 endif
700
701 ifndef NO_LOCAL_LIBUNWIND
702   ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
703     $(call feature_check,libunwind-debug-frame)
704     ifneq ($(feature-libunwind-debug-frame), 1)
705       msg := $(warning No debug_frame support found in libunwind);
706       CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
707     endif
708   else
709     # non-ARM has no dwarf_find_debug_frame() function:
710     CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
711   endif
712   EXTLIBS += $(LIBUNWIND_LIBS)
713   LDFLAGS += $(LIBUNWIND_LIBS)
714 endif
715 ifeq ($(findstring -static,${LDFLAGS}),-static)
716   # gcc -static links libgcc_eh which contans piece of libunwind
717   LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
718 endif
719
720 ifndef NO_LIBUNWIND
721   CFLAGS  += -DHAVE_LIBUNWIND_SUPPORT
722   CFLAGS  += $(LIBUNWIND_CFLAGS)
723   LDFLAGS += $(LIBUNWIND_LDFLAGS)
724   EXTLIBS += $(EXTLIBS_LIBUNWIND)
725 endif
726
727 ifeq ($(NO_SYSCALL_TABLE),0)
728   $(call detected,CONFIG_TRACE)
729 else
730   ifndef NO_LIBAUDIT
731     $(call feature_check,libaudit)
732     ifneq ($(feature-libaudit), 1)
733       msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
734       NO_LIBAUDIT := 1
735     else
736       CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
737       EXTLIBS += -laudit
738       $(call detected,CONFIG_TRACE)
739     endif
740   endif
741 endif
742
743 ifndef NO_LIBCRYPTO
744   ifneq ($(feature-libcrypto), 1)
745     msg := $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev);
746     NO_LIBCRYPTO := 1
747   else
748     CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
749     EXTLIBS += -lcrypto
750     $(call detected,CONFIG_CRYPTO)
751   endif
752 endif
753
754 ifdef NO_NEWT
755   NO_SLANG=1
756 endif
757
758 ifndef NO_SLANG
759   ifneq ($(feature-libslang), 1)
760     ifneq ($(feature-libslang-include-subdir), 1)
761       msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
762       NO_SLANG := 1
763     else
764       CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR
765     endif
766   endif
767   ifndef NO_SLANG
768     # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
769     CFLAGS += -DHAVE_SLANG_SUPPORT
770     EXTLIBS += -lslang
771     $(call detected,CONFIG_SLANG)
772   endif
773 endif
774
775 ifdef GTK2
776   FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
777   $(call feature_check,gtk2)
778   ifneq ($(feature-gtk2), 1)
779     msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
780     NO_GTK2 := 1
781   else
782     $(call feature_check,gtk2-infobar)
783     ifeq ($(feature-gtk2-infobar), 1)
784       GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
785     endif
786     CFLAGS += -DHAVE_GTK2_SUPPORT
787     GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
788     GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
789     EXTLIBS += -ldl
790   endif
791 endif
792
793 ifdef NO_LIBPERL
794   CFLAGS += -DNO_LIBPERL
795 else
796   PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
797   PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
798   PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
799   PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
800   PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
801   PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
802   PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
803   FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
804
805   ifneq ($(feature-libperl), 1)
806     CFLAGS += -DNO_LIBPERL
807     NO_LIBPERL := 1
808     msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
809   else
810     LDFLAGS += $(PERL_EMBED_LDFLAGS)
811     EXTLIBS += $(PERL_EMBED_LIBADD)
812     CFLAGS += -DHAVE_LIBPERL_SUPPORT
813     ifeq ($(CC_NO_CLANG), 0)
814       CFLAGS += -Wno-compound-token-split-by-macro
815     endif
816     $(call detected,CONFIG_LIBPERL)
817   endif
818 endif
819
820 ifeq ($(feature-timerfd), 1)
821   CFLAGS += -DHAVE_TIMERFD_SUPPORT
822 else
823   msg := $(warning No timerfd support. Disables 'perf kvm stat live');
824 endif
825
826 disable-python = $(eval $(disable-python_code))
827 define disable-python_code
828   CFLAGS += -DNO_LIBPYTHON
829   $(warning $1)
830   NO_LIBPYTHON := 1
831 endef
832
833 ifdef NO_LIBPYTHON
834   $(call disable-python,Python support disabled by user)
835 else
836
837   ifndef PYTHON
838     $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
839   else
840     PYTHON_WORD := $(call shell-wordify,$(PYTHON))
841
842     ifndef PYTHON_CONFIG
843       $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
844     else
845
846       ifneq ($(feature-libpython), 1)
847         $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
848       else
849          LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
850          EXTLIBS += $(PYTHON_EMBED_LIBADD)
851          LANG_BINDINGS += $(obj-perf)python/perf.so
852          CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
853          $(call detected,CONFIG_LIBPYTHON)
854       endif
855     endif
856   endif
857 endif
858
859
860 ifndef NO_LIBBFD
861   ifeq ($(feature-libbfd), 1)
862     EXTLIBS += -lbfd -lopcodes
863   else
864     # we are on a system that requires -liberty and (maybe) -lz
865     # to link against -lbfd; test each case individually here
866
867     # call all detections now so we get correct
868     # status in VF output
869     $(call feature_check,libbfd-liberty)
870     $(call feature_check,libbfd-liberty-z)
871
872     ifeq ($(feature-libbfd-liberty), 1)
873       EXTLIBS += -lbfd -lopcodes -liberty
874       FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
875     else
876       ifeq ($(feature-libbfd-liberty-z), 1)
877         EXTLIBS += -lbfd -lopcodes -liberty -lz
878         FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
879       endif
880     endif
881     $(call feature_check,disassembler-four-args)
882   endif
883
884   ifeq ($(feature-libbfd-buildid), 1)
885     CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
886   else
887     msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available);
888   endif
889 endif
890
891 ifdef NO_DEMANGLE
892   CFLAGS += -DNO_DEMANGLE
893 else
894   ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
895     EXTLIBS += -liberty
896   else
897     ifeq ($(filter -liberty,$(EXTLIBS)),)
898       $(call feature_check,cplus-demangle)
899
900       # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
901       # or any of 'bfd iberty z' trinity
902       ifeq ($(feature-cplus-demangle), 1)
903         EXTLIBS += -liberty
904       else
905         msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
906         CFLAGS += -DNO_DEMANGLE
907       endif
908     endif
909   endif
910
911   ifneq ($(filter -liberty,$(EXTLIBS)),)
912     CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
913   endif
914 endif
915
916 ifneq ($(filter -lbfd,$(EXTLIBS)),)
917   CFLAGS += -DHAVE_LIBBFD_SUPPORT
918 endif
919
920 ifndef NO_ZLIB
921   ifeq ($(feature-zlib), 1)
922     CFLAGS += -DHAVE_ZLIB_SUPPORT
923     EXTLIBS += -lz
924     $(call detected,CONFIG_ZLIB)
925   else
926     NO_ZLIB := 1
927   endif
928 endif
929
930 ifndef NO_LZMA
931   ifeq ($(feature-lzma), 1)
932     CFLAGS += -DHAVE_LZMA_SUPPORT
933     EXTLIBS += -llzma
934     $(call detected,CONFIG_LZMA)
935   else
936     msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
937     NO_LZMA := 1
938   endif
939 endif
940
941 ifndef NO_LIBZSTD
942   ifeq ($(feature-libzstd), 1)
943     CFLAGS += -DHAVE_ZSTD_SUPPORT
944     CFLAGS += $(LIBZSTD_CFLAGS)
945     LDFLAGS += $(LIBZSTD_LDFLAGS)
946     EXTLIBS += -lzstd
947     $(call detected,CONFIG_ZSTD)
948   else
949     msg := $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR);
950     NO_LIBZSTD := 1
951   endif
952 endif
953
954 ifndef NO_LIBCAP
955   ifeq ($(feature-libcap), 1)
956     CFLAGS += -DHAVE_LIBCAP_SUPPORT
957     EXTLIBS += -lcap
958     $(call detected,CONFIG_LIBCAP)
959   else
960     msg := $(warning No libcap found, disables capability support, please install libcap-devel/libcap-dev);
961     NO_LIBCAP := 1
962   endif
963 endif
964
965 ifndef NO_BACKTRACE
966   ifeq ($(feature-backtrace), 1)
967     CFLAGS += -DHAVE_BACKTRACE_SUPPORT
968   endif
969 endif
970
971 ifndef NO_LIBNUMA
972   ifeq ($(feature-libnuma), 0)
973     msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
974     NO_LIBNUMA := 1
975   else
976     ifeq ($(feature-numa_num_possible_cpus), 0)
977       msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
978       NO_LIBNUMA := 1
979     else
980       CFLAGS += -DHAVE_LIBNUMA_SUPPORT
981       EXTLIBS += -lnuma
982       $(call detected,CONFIG_NUMA)
983     endif
984   endif
985 endif
986
987 ifdef HAVE_KVM_STAT_SUPPORT
988     CFLAGS += -DHAVE_KVM_STAT_SUPPORT
989 endif
990
991 ifeq ($(feature-disassembler-four-args), 1)
992     CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
993 endif
994
995 ifeq (${IS_64_BIT}, 1)
996   ifndef NO_PERF_READ_VDSO32
997     $(call feature_check,compile-32)
998     ifeq ($(feature-compile-32), 1)
999       CFLAGS += -DHAVE_PERF_READ_VDSO32
1000     else
1001       NO_PERF_READ_VDSO32 := 1
1002     endif
1003   endif
1004   ifneq ($(SRCARCH), x86)
1005     NO_PERF_READ_VDSOX32 := 1
1006   endif
1007   ifndef NO_PERF_READ_VDSOX32
1008     $(call feature_check,compile-x32)
1009     ifeq ($(feature-compile-x32), 1)
1010       CFLAGS += -DHAVE_PERF_READ_VDSOX32
1011     else
1012       NO_PERF_READ_VDSOX32 := 1
1013     endif
1014   endif
1015 else
1016   NO_PERF_READ_VDSO32 := 1
1017   NO_PERF_READ_VDSOX32 := 1
1018 endif
1019
1020 ifndef NO_LIBBABELTRACE
1021   $(call feature_check,libbabeltrace)
1022   ifeq ($(feature-libbabeltrace), 1)
1023     CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
1024     LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
1025     EXTLIBS += -lbabeltrace-ctf
1026     $(call detected,CONFIG_LIBBABELTRACE)
1027   else
1028     msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
1029   endif
1030 endif
1031
1032 ifndef NO_AUXTRACE
1033   ifeq ($(SRCARCH),x86)
1034     ifeq ($(feature-get_cpuid), 0)
1035       msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
1036       NO_AUXTRACE := 1
1037     endif
1038   endif
1039   ifndef NO_AUXTRACE
1040     $(call detected,CONFIG_AUXTRACE)
1041     CFLAGS += -DHAVE_AUXTRACE_SUPPORT
1042   endif
1043 endif
1044
1045 ifndef NO_JVMTI
1046   ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
1047     JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
1048   else
1049     ifneq (,$(wildcard /usr/sbin/alternatives))
1050       JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g')
1051     endif
1052   endif
1053   ifndef JDIR
1054     $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
1055     NO_JVMTI := 1
1056   endif
1057 endif
1058
1059 ifndef NO_JVMTI
1060   FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
1061   $(call feature_check,jvmti)
1062   ifeq ($(feature-jvmti), 1)
1063     $(call detected_var,JDIR)
1064     ifndef NO_JVMTI_CMLR
1065       FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
1066       $(call feature_check,jvmti-cmlr)
1067       ifeq ($(feature-jvmti-cmlr), 1)
1068         CFLAGS += -DHAVE_JVMTI_CMLR
1069       endif
1070     endif # NO_JVMTI_CMLR
1071   else
1072     $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
1073     NO_JVMTI := 1
1074   endif
1075 endif
1076
1077 USE_CXX = 0
1078 USE_CLANGLLVM = 0
1079 ifdef LIBCLANGLLVM
1080   $(call feature_check,cxx)
1081   ifneq ($(feature-cxx), 1)
1082     msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
1083   else
1084     $(call feature_check,llvm)
1085     $(call feature_check,llvm-version)
1086     ifneq ($(feature-llvm), 1)
1087       msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
1088     else
1089       $(call feature_check,clang)
1090       ifneq ($(feature-clang), 1)
1091         msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
1092       else
1093         CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
1094         CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
1095         $(call detected,CONFIG_CXX)
1096         $(call detected,CONFIG_CLANGLLVM)
1097         USE_CXX = 1
1098         USE_LLVM = 1
1099         USE_CLANG = 1
1100         ifneq ($(feature-llvm-version),1)
1101           msg := $(warning This version of LLVM is not tested. May cause build errors)
1102         endif
1103       endif
1104     endif
1105   endif
1106 endif
1107
1108 ifdef LIBPFM4
1109   $(call feature_check,libpfm4)
1110   ifeq ($(feature-libpfm4), 1)
1111     CFLAGS += -DHAVE_LIBPFM
1112     EXTLIBS += -lpfm
1113     ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1
1114     $(call detected,CONFIG_LIBPFM4)
1115   else
1116     msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev);
1117     NO_LIBPFM4 := 1
1118   endif
1119 endif
1120
1121 ifdef LIBTRACEEVENT_DYNAMIC
1122   $(call feature_check,libtraceevent)
1123   ifeq ($(feature-libtraceevent), 1)
1124     EXTLIBS += -ltraceevent
1125   else
1126     dummy := $(error Error: No libtraceevent devel library found, please install libtraceevent-devel);
1127   endif
1128 endif
1129
1130 # Among the variables below, these:
1131 #   perfexecdir
1132 #   perf_include_dir
1133 #   perf_examples_dir
1134 #   template_dir
1135 #   mandir
1136 #   infodir
1137 #   htmldir
1138 #   ETC_PERFCONFIG (but not sysconfdir)
1139 # can be specified as a relative path some/where/else;
1140 # this is interpreted as relative to $(prefix) and "perf" at
1141 # runtime figures out where they are based on the path to the executable.
1142 # This can help installing the suite in a relocatable way.
1143
1144 # Make the path relative to DESTDIR, not to prefix
1145 ifndef DESTDIR
1146 prefix ?= $(HOME)
1147 endif
1148 bindir_relative = bin
1149 bindir = $(abspath $(prefix)/$(bindir_relative))
1150 includedir_relative = include
1151 includedir = $(abspath $(prefix)/$(includedir_relative))
1152 mandir = share/man
1153 infodir = share/info
1154 perfexecdir = libexec/perf-core
1155 perf_include_dir = lib/perf/include
1156 perf_examples_dir = lib/perf/examples
1157 sharedir = $(prefix)/share
1158 template_dir = share/perf-core/templates
1159 STRACE_GROUPS_DIR = share/perf-core/strace/groups
1160 htmldir = share/doc/perf-doc
1161 tipdir = share/doc/perf-tip
1162 srcdir = $(srctree)/tools/perf
1163 ifeq ($(prefix),/usr)
1164 sysconfdir = /etc
1165 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
1166 else
1167 sysconfdir = $(prefix)/etc
1168 ETC_PERFCONFIG = etc/perfconfig
1169 endif
1170 ifndef lib
1171 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
1172 lib = lib64
1173 else
1174 lib = lib
1175 endif
1176 endif # lib
1177 libdir = $(prefix)/$(lib)
1178
1179 # Shell quote (do not use $(call) to accommodate ancient setups);
1180 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
1181 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
1182 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1183 bindir_SQ = $(subst ','\'',$(bindir))
1184 includedir_SQ = $(subst ','\'',$(includedir))
1185 mandir_SQ = $(subst ','\'',$(mandir))
1186 infodir_SQ = $(subst ','\'',$(infodir))
1187 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
1188 perf_include_dir_SQ = $(subst ','\'',$(perf_include_dir))
1189 perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))
1190 template_dir_SQ = $(subst ','\'',$(template_dir))
1191 htmldir_SQ = $(subst ','\'',$(htmldir))
1192 tipdir_SQ = $(subst ','\'',$(tipdir))
1193 prefix_SQ = $(subst ','\'',$(prefix))
1194 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
1195 libdir_SQ = $(subst ','\'',$(libdir))
1196 srcdir_SQ = $(subst ','\'',$(srcdir))
1197
1198 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
1199 perfexec_instdir = $(perfexecdir)
1200 perf_include_instdir = $(perf_include_dir)
1201 perf_examples_instdir = $(perf_examples_dir)
1202 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
1203 tip_instdir = $(tipdir)
1204 else
1205 perfexec_instdir = $(prefix)/$(perfexecdir)
1206 perf_include_instdir = $(prefix)/$(perf_include_dir)
1207 perf_examples_instdir = $(prefix)/$(perf_examples_dir)
1208 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
1209 tip_instdir = $(prefix)/$(tipdir)
1210 endif
1211 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
1212 perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))
1213 perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))
1214 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
1215 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
1216
1217 # If we install to $(HOME) we keep the traceevent default:
1218 # $(HOME)/.traceevent/plugins
1219 # Otherwise we install plugins into the global $(libdir).
1220 ifdef DESTDIR
1221 plugindir=$(libdir)/traceevent/plugins
1222 plugindir_SQ= $(subst ','\'',$(plugindir))
1223 endif
1224
1225 print_var = $(eval $(print_var_code)) $(info $(MSG))
1226 define print_var_code
1227     MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
1228 endef
1229
1230 ifeq ($(VF),1)
1231   # Display EXTRA features which are detected manualy
1232   # from here with feature_check call and thus cannot
1233   # be partof global state output.
1234   $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),))
1235   $(call print_var,prefix)
1236   $(call print_var,bindir)
1237   $(call print_var,libdir)
1238   $(call print_var,sysconfdir)
1239   $(call print_var,LIBUNWIND_DIR)
1240   $(call print_var,LIBDW_DIR)
1241   $(call print_var,JDIR)
1242
1243   ifeq ($(dwarf-post-unwind),1)
1244     $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
1245   endif
1246   $(info )
1247 endif
1248
1249 $(call detected_var,bindir_SQ)
1250 $(call detected_var,PYTHON_WORD)
1251 ifneq ($(OUTPUT),)
1252 $(call detected_var,OUTPUT)
1253 endif
1254 $(call detected_var,htmldir_SQ)
1255 $(call detected_var,infodir_SQ)
1256 $(call detected_var,mandir_SQ)
1257 $(call detected_var,ETC_PERFCONFIG_SQ)
1258 $(call detected_var,STRACE_GROUPS_DIR_SQ)
1259 $(call detected_var,prefix_SQ)
1260 $(call detected_var,perfexecdir_SQ)
1261 $(call detected_var,perf_include_dir_SQ)
1262 $(call detected_var,perf_examples_dir_SQ)
1263 $(call detected_var,tipdir_SQ)
1264 $(call detected_var,srcdir_SQ)
1265 $(call detected_var,LIBDIR)
1266 $(call detected_var,GTK_CFLAGS)
1267 $(call detected_var,PERL_EMBED_CCOPTS)
1268 $(call detected_var,PYTHON_EMBED_CCOPTS)
1269 ifneq ($(BISON_FILE_PREFIX_MAP),)
1270 $(call detected_var,BISON_FILE_PREFIX_MAP)
1271 endif
1272
1273 # re-generate FEATURE-DUMP as we may have called feature_check, found out
1274 # extra libraries to add to LDFLAGS of some other test and then redo those
1275 # tests, see the block about libbfd, disassembler-four-args, for instance.
1276 $(shell rm -f $(FEATURE_DUMP_FILENAME))
1277 $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))
1278
1279 ifeq ($(feature_display),1)
1280   $(call feature_display_entries)
1281 endif