blob: 9832affd5d54b0400856f0cadfd57ad9b48aa1c6 [file] [log] [blame]
Googler9398cc32022-12-02 17:21:52 +08001# SPDX-License-Identifier: GPL-2.0-only
Googleraf606d22022-10-26 21:40:12 -07002
3ifeq ($(src-perf),)
4src-perf := $(srctree)/tools/perf
5endif
6
7ifeq ($(obj-perf),)
8obj-perf := $(OUTPUT)
9endif
10
11ifneq ($(obj-perf),)
12obj-perf := $(abspath $(obj-perf))/
13endif
14
15$(shell printf "" > $(OUTPUT).config-detected)
16detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
17detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
18
19CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
20
21include $(srctree)/tools/scripts/Makefile.arch
22
23$(call detected_var,SRCARCH)
24
25NO_PERF_REGS := 1
Googler9398cc32022-12-02 17:21:52 +080026NO_SYSCALL_TABLE := 1
Googleraf606d22022-10-26 21:40:12 -070027
28# Additional ARCH settings for ppc
29ifeq ($(SRCARCH),powerpc)
30 NO_PERF_REGS := 0
Googler9398cc32022-12-02 17:21:52 +080031 NO_SYSCALL_TABLE := 0
32 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated
Googleraf606d22022-10-26 21:40:12 -070033 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
34endif
35
36# Additional ARCH settings for x86
37ifeq ($(SRCARCH),x86)
38 $(call detected,CONFIG_X86)
39 ifeq (${IS_64_BIT}, 1)
Googler9398cc32022-12-02 17:21:52 +080040 NO_SYSCALL_TABLE := 0
41 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated
Googleraf606d22022-10-26 21:40:12 -070042 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
Googler9398cc32022-12-02 17:21:52 +080043 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
Googleraf606d22022-10-26 21:40:12 -070044 $(call detected,CONFIG_X86_64)
45 else
46 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
47 endif
48 NO_PERF_REGS := 0
49endif
50
51ifeq ($(SRCARCH),arm)
52 NO_PERF_REGS := 0
53 LIBUNWIND_LIBS = -lunwind -lunwind-arm
54endif
55
56ifeq ($(SRCARCH),arm64)
57 NO_PERF_REGS := 0
Googler9398cc32022-12-02 17:21:52 +080058 NO_SYSCALL_TABLE := 0
59 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
Googleraf606d22022-10-26 21:40:12 -070060 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
61endif
62
Googler9398cc32022-12-02 17:21:52 +080063ifeq ($(SRCARCH),riscv)
64 NO_PERF_REGS := 0
65endif
66
67ifeq ($(SRCARCH),csky)
68 NO_PERF_REGS := 0
69endif
70
71ifeq ($(ARCH),s390)
72 NO_PERF_REGS := 0
73 NO_SYSCALL_TABLE := 0
74 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
75endif
76
Googleraf606d22022-10-26 21:40:12 -070077ifeq ($(NO_PERF_REGS),0)
78 $(call detected,CONFIG_PERF_REGS)
79endif
80
Googler9398cc32022-12-02 17:21:52 +080081ifneq ($(NO_SYSCALL_TABLE),1)
82 CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT
83endif
84
Googleraf606d22022-10-26 21:40:12 -070085# So far there's only x86 and arm libdw unwind support merged in perf.
86# Disable it on all other architectures in case libdw unwind
87# support is detected in system. Add supported architectures
88# to the check.
Googler9398cc32022-12-02 17:21:52 +080089ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv))
Googleraf606d22022-10-26 21:40:12 -070090 NO_LIBDW_DWARF_UNWIND := 1
91endif
92
93ifeq ($(LIBUNWIND_LIBS),)
94 NO_LIBUNWIND := 1
95endif
96#
97# For linking with debug library, run like:
98#
99# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
100#
101
102libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
103define libunwind_arch_set_flags_code
104 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
105 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib
106endef
107
108ifdef LIBUNWIND_DIR
109 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
110 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
111 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64
112 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
113endif
114
115# Set per-feature check compilation flags
116FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
117FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
118FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
119FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
120
Googlerb48fa912023-03-17 12:40:29 +0530121FEATURE_CHECK_LDFLAGS-libunwind-arm = -lunwind -lunwind-arm
122FEATURE_CHECK_LDFLAGS-libunwind-aarch64 = -lunwind -lunwind-aarch64
123FEATURE_CHECK_LDFLAGS-libunwind-x86 = -lunwind -llzma -lunwind-x86
124FEATURE_CHECK_LDFLAGS-libunwind-x86_64 = -lunwind -llzma -lunwind-x86_64
Googler9398cc32022-12-02 17:21:52 +0800125
126FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
127
128ifdef CSINCLUDES
129 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
130endif
131OPENCSDLIBS := -lopencsd_c_api -lopencsd
132ifdef CSLIBS
133 LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
134endif
135FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)
136FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)
137
Googleraf606d22022-10-26 21:40:12 -0700138ifeq ($(NO_PERF_REGS),0)
139 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
140endif
141
142# for linking with debug library, run like:
143# make DEBUG=1 LIBDW_DIR=/opt/libdw/
144ifdef LIBDW_DIR
145 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
146 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
147endif
Googler9398cc32022-12-02 17:21:52 +0800148DWARFLIBS := -ldw
149ifeq ($(findstring -static,${LDFLAGS}),-static)
150 DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
151endif
Googleraf606d22022-10-26 21:40:12 -0700152FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
Googler9398cc32022-12-02 17:21:52 +0800153FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
Googleraf606d22022-10-26 21:40:12 -0700154
155# for linking with debug library, run like:
156# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
157ifdef LIBBABELTRACE_DIR
158 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
159 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
160endif
161FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
162FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
163
Googler9398cc32022-12-02 17:21:52 +0800164ifdef LIBZSTD_DIR
165 LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib
166 LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
167endif
168FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
169FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
170
Googleraf606d22022-10-26 21:40:12 -0700171FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
172# include ARCH specific config
173-include $(src-perf)/arch/$(SRCARCH)/Makefile
174
175ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
176 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
177endif
178
179include $(srctree)/tools/scripts/utilities.mak
180
181ifeq ($(call get-executable,$(FLEX)),)
182 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
183endif
184
185ifeq ($(call get-executable,$(BISON)),)
186 dummy := $(error Error: $(BISON) is missing on this system, please install it)
187endif
188
189# Treat warnings as errors unless directed not to
190ifneq ($(WERROR),0)
191 CFLAGS += -Werror
Googler9398cc32022-12-02 17:21:52 +0800192 CXXFLAGS += -Werror
Googleraf606d22022-10-26 21:40:12 -0700193endif
194
195ifndef DEBUG
196 DEBUG := 0
197endif
198
199ifeq ($(DEBUG),0)
Googler9398cc32022-12-02 17:21:52 +0800200ifeq ($(CC_NO_CLANG), 0)
201 CFLAGS += -O3
202else
Googleraf606d22022-10-26 21:40:12 -0700203 CFLAGS += -O6
204endif
Googler9398cc32022-12-02 17:21:52 +0800205endif
Googleraf606d22022-10-26 21:40:12 -0700206
207ifdef PARSER_DEBUG
208 PARSER_DEBUG_BISON := -t
209 PARSER_DEBUG_FLEX := -d
210 CFLAGS += -DPARSER_DEBUG
211 $(call detected_var,PARSER_DEBUG_BISON)
212 $(call detected_var,PARSER_DEBUG_FLEX)
213endif
214
215# Try different combinations to accommodate systems that only have
216# python[2][-config] in weird combinations but always preferring
217# python2 and python2-config as per pep-0394. If we catch a
218# python[-config] in version 3, the version check will kill it.
219PYTHON2 := $(if $(call get-executable,python2),python2,python)
220override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
221PYTHON2_CONFIG := \
222 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
223override PYTHON_CONFIG := \
224 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
225
Googler9398cc32022-12-02 17:21:52 +0800226grep-libs = $(filter -l%,$(1))
227strip-libs = $(filter-out -l%,$(1))
228
Googleraf606d22022-10-26 21:40:12 -0700229PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
230
Googler9398cc32022-12-02 17:21:52 +0800231# Python 3.8 changed the output of `python-config --ldflags` to not include the
232# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
233# libpython fails if that flag is not included in LDFLAGS
234ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
235 PYTHON_CONFIG_LDFLAGS := --ldflags --embed
236else
237 PYTHON_CONFIG_LDFLAGS := --ldflags
238endif
239
240ifdef PYTHON_CONFIG
241 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
242 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
243 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
244 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
245 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
246endif
Googleraf606d22022-10-26 21:40:12 -0700247
248FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
249FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
Googlerb48fa912023-03-17 12:40:29 +0530250FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
251FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
Googler9398cc32022-12-02 17:21:52 +0800252
253FEATURE_CHECK_LDFLAGS-libaio = -lrt
254
255FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
Googleraf606d22022-10-26 21:40:12 -0700256
Googleraf606d22022-10-26 21:40:12 -0700257CFLAGS += -fno-omit-frame-pointer
258CFLAGS += -ggdb3
259CFLAGS += -funwind-tables
260CFLAGS += -Wall
261CFLAGS += -Wextra
262CFLAGS += -std=gnu99
263
Googler9398cc32022-12-02 17:21:52 +0800264CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
265CXXFLAGS += -Wall
266CXXFLAGS += -fno-omit-frame-pointer
267CXXFLAGS += -ggdb3
268CXXFLAGS += -funwind-tables
269CXXFLAGS += -Wno-strict-aliasing
270
Googleraf606d22022-10-26 21:40:12 -0700271# Enforce a non-executable stack, as we may regress (again) in the future by
272# adding assembler files missing the .GNU-stack linker note.
273LDFLAGS += -Wl,-z,noexecstack
274
275EXTLIBS = -lpthread -lrt -lm -ldl
276
277ifeq ($(FEATURES_DUMP),)
278include $(srctree)/tools/build/Makefile.feature
279else
280include $(FEATURES_DUMP)
281endif
282
283ifeq ($(feature-stackprotector-all), 1)
284 CFLAGS += -fstack-protector-all
285endif
286
287ifeq ($(DEBUG),0)
288 ifeq ($(feature-fortify-source), 1)
289 CFLAGS += -D_FORTIFY_SOURCE=2
290 endif
291endif
292
Googler9398cc32022-12-02 17:21:52 +0800293INC_FLAGS += -I$(src-perf)/lib/include
294INC_FLAGS += -I$(src-perf)/util/include
295INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
296INC_FLAGS += -I$(srctree)/tools/include/
297INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
298INC_FLAGS += -I$(srctree)/tools/include/uapi
299INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
300INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
Googleraf606d22022-10-26 21:40:12 -0700301
302# $(obj-perf) for generated common-cmds.h
303# $(obj-perf)/util for generated bison/flex headers
304ifneq ($(OUTPUT),)
Googler9398cc32022-12-02 17:21:52 +0800305INC_FLAGS += -I$(obj-perf)/util
306INC_FLAGS += -I$(obj-perf)
Googleraf606d22022-10-26 21:40:12 -0700307endif
308
Googler9398cc32022-12-02 17:21:52 +0800309INC_FLAGS += -I$(src-perf)/util
310INC_FLAGS += -I$(src-perf)
311INC_FLAGS += -I$(srctree)/tools/lib/
312
313CFLAGS += $(INC_FLAGS)
314CXXFLAGS += $(INC_FLAGS)
Googleraf606d22022-10-26 21:40:12 -0700315
316CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
317
318ifeq ($(feature-sync-compare-and-swap), 1)
319 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
320endif
321
322ifeq ($(feature-pthread-attr-setaffinity-np), 1)
323 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
324endif
325
Googler9398cc32022-12-02 17:21:52 +0800326ifeq ($(feature-pthread-barrier), 1)
327 CFLAGS += -DHAVE_PTHREAD_BARRIER
328endif
329
Googleraf606d22022-10-26 21:40:12 -0700330ifndef NO_BIONIC
331 $(call feature_check,bionic)
332 ifeq ($(feature-bionic), 1)
333 BIONIC := 1
Googler9398cc32022-12-02 17:21:52 +0800334 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
335 CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
Googleraf606d22022-10-26 21:40:12 -0700336 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
337 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
338 endif
339endif
340
Googler9398cc32022-12-02 17:21:52 +0800341ifeq ($(feature-eventfd), 1)
342 CFLAGS += -DHAVE_EVENTFD
343endif
344
345ifeq ($(feature-get_current_dir_name), 1)
346 CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
347endif
348
349ifeq ($(feature-gettid), 1)
350 CFLAGS += -DHAVE_GETTID
351endif
352
Googleraf606d22022-10-26 21:40:12 -0700353ifdef NO_LIBELF
354 NO_DWARF := 1
355 NO_DEMANGLE := 1
356 NO_LIBUNWIND := 1
357 NO_LIBDW_DWARF_UNWIND := 1
358 NO_LIBBPF := 1
Googler9398cc32022-12-02 17:21:52 +0800359 NO_JVMTI := 1
Googleraf606d22022-10-26 21:40:12 -0700360else
361 ifeq ($(feature-libelf), 0)
362 ifeq ($(feature-glibc), 1)
363 LIBC_SUPPORT := 1
364 endif
365 ifeq ($(BIONIC),1)
366 LIBC_SUPPORT := 1
367 endif
368 ifeq ($(LIBC_SUPPORT),1)
Googler9398cc32022-12-02 17:21:52 +0800369 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);
Googleraf606d22022-10-26 21:40:12 -0700370
371 NO_LIBELF := 1
372 NO_DWARF := 1
373 NO_DEMANGLE := 1
374 NO_LIBUNWIND := 1
375 NO_LIBDW_DWARF_UNWIND := 1
376 NO_LIBBPF := 1
Googler9398cc32022-12-02 17:21:52 +0800377 NO_JVMTI := 1
Googleraf606d22022-10-26 21:40:12 -0700378 else
379 ifneq ($(filter s% -static%,$(LDFLAGS),),)
380 msg := $(error No static glibc found, please install glibc-static);
381 else
382 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
383 endif
384 endif
385 else
386 ifndef NO_LIBDW_DWARF_UNWIND
387 ifneq ($(feature-libdw-dwarf-unwind),1)
388 NO_LIBDW_DWARF_UNWIND := 1
389 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
390 endif
391 endif
392 ifneq ($(feature-dwarf), 1)
Googler9398cc32022-12-02 17:21:52 +0800393 ifndef NO_DWARF
394 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);
395 NO_DWARF := 1
396 endif
Googleraf606d22022-10-26 21:40:12 -0700397 else
398 ifneq ($(feature-dwarf_getlocations), 1)
399 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
400 else
Googler9398cc32022-12-02 17:21:52 +0800401 CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
Googleraf606d22022-10-26 21:40:12 -0700402 endif # dwarf_getlocations
403 endif # Dwarf support
404 endif # libelf support
405endif # NO_LIBELF
406
Googler9398cc32022-12-02 17:21:52 +0800407ifeq ($(feature-glibc), 1)
408 CFLAGS += -DHAVE_GLIBC_SUPPORT
409endif
410
411ifeq ($(feature-libaio), 1)
412 ifndef NO_AIO
413 CFLAGS += -DHAVE_AIO_SUPPORT
414 endif
415endif
416
Googleraf606d22022-10-26 21:40:12 -0700417ifdef NO_DWARF
418 NO_LIBDW_DWARF_UNWIND := 1
419endif
420
Googler9398cc32022-12-02 17:21:52 +0800421ifeq ($(feature-sched_getcpu), 1)
422 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
423endif
424
425ifeq ($(feature-setns), 1)
426 CFLAGS += -DHAVE_SETNS_SUPPORT
427 $(call detected,CONFIG_SETNS)
428endif
429
430ifdef CORESIGHT
431 $(call feature_check,libopencsd)
432 ifeq ($(feature-libopencsd), 1)
433 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
434 ifeq ($(feature-reallocarray), 0)
435 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
436 endif
437 LDFLAGS += $(LIBOPENCSD_LDFLAGS)
438 EXTLIBS += $(OPENCSDLIBS)
439 $(call detected,CONFIG_LIBOPENCSD)
440 ifdef CSTRACE_RAW
441 CFLAGS += -DCS_DEBUG_RAW
442 ifeq (${CSTRACE_RAW}, packed)
443 CFLAGS += -DCS_RAW_PACKED
444 endif
445 endif
446 endif
447endif
448
Googleraf606d22022-10-26 21:40:12 -0700449ifndef NO_LIBELF
450 CFLAGS += -DHAVE_LIBELF_SUPPORT
451 EXTLIBS += -lelf
452 $(call detected,CONFIG_LIBELF)
453
454 ifeq ($(feature-libelf-mmap), 1)
455 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
456 endif
457
458 ifeq ($(feature-libelf-getphdrnum), 1)
459 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
460 endif
461
462 ifeq ($(feature-libelf-gelf_getnote), 1)
463 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
464 else
465 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
466 endif
467
468 ifeq ($(feature-libelf-getshdrstrndx), 1)
469 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
470 endif
471
472 ifndef NO_DWARF
473 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
474 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
475 NO_DWARF := 1
476 else
477 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
478 LDFLAGS += $(LIBDW_LDFLAGS)
479 EXTLIBS += ${DWARFLIBS}
480 $(call detected,CONFIG_DWARF)
481 endif # PERF_HAVE_DWARF_REGS
482 endif # NO_DWARF
483
484 ifndef NO_LIBBPF
485 ifeq ($(feature-bpf), 1)
486 CFLAGS += -DHAVE_LIBBPF_SUPPORT
487 $(call detected,CONFIG_LIBBPF)
488 endif
489
490 ifndef NO_DWARF
491 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
492 CFLAGS += -DHAVE_BPF_PROLOGUE
493 $(call detected,CONFIG_BPF_PROLOGUE)
494 else
495 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
496 endif
497 else
498 msg := $(warning DWARF support is off, BPF prologue is disabled);
499 endif
500
501 endif # NO_LIBBPF
502endif # NO_LIBELF
503
504ifndef NO_SDT
505 ifneq ($(feature-sdt), 1)
506 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
507 NO_SDT := 1;
508 else
509 CFLAGS += -DHAVE_SDT_EVENT
510 $(call detected,CONFIG_SDT_EVENT)
511 endif
512endif
513
514ifdef PERF_HAVE_JITDUMP
515 ifndef NO_LIBELF
516 $(call detected,CONFIG_JITDUMP)
517 CFLAGS += -DHAVE_JITDUMP
518 endif
519endif
520
521ifeq ($(SRCARCH),powerpc)
522 ifndef NO_DWARF
523 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
524 endif
525endif
526
527ifndef NO_LIBUNWIND
528 have_libunwind :=
529
Googler9398cc32022-12-02 17:21:52 +0800530 $(call feature_check,libunwind-x86)
Googleraf606d22022-10-26 21:40:12 -0700531 ifeq ($(feature-libunwind-x86), 1)
532 $(call detected,CONFIG_LIBUNWIND_X86)
533 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
534 LDFLAGS += -lunwind-x86
535 EXTLIBS_LIBUNWIND += -lunwind-x86
536 have_libunwind = 1
537 endif
538
Googler9398cc32022-12-02 17:21:52 +0800539 $(call feature_check,libunwind-aarch64)
Googleraf606d22022-10-26 21:40:12 -0700540 ifeq ($(feature-libunwind-aarch64), 1)
541 $(call detected,CONFIG_LIBUNWIND_AARCH64)
542 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
543 LDFLAGS += -lunwind-aarch64
544 EXTLIBS_LIBUNWIND += -lunwind-aarch64
545 have_libunwind = 1
546 $(call feature_check,libunwind-debug-frame-aarch64)
547 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
548 msg := $(warning No debug_frame support found in libunwind-aarch64);
549 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
550 endif
551 endif
552
553 ifneq ($(feature-libunwind), 1)
554 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
555 NO_LOCAL_LIBUNWIND := 1
556 else
557 have_libunwind := 1
558 $(call detected,CONFIG_LOCAL_LIBUNWIND)
559 endif
560
561 ifneq ($(have_libunwind), 1)
562 NO_LIBUNWIND := 1
563 endif
564else
565 NO_LOCAL_LIBUNWIND := 1
566endif
567
568ifndef NO_LIBBPF
569 ifneq ($(feature-bpf), 1)
570 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
571 NO_LIBBPF := 1
572 endif
573endif
574
575dwarf-post-unwind := 1
576dwarf-post-unwind-text := BUG
577
578# setup DWARF post unwinder
579ifdef NO_LIBUNWIND
580 ifdef NO_LIBDW_DWARF_UNWIND
581 msg := $(warning Disabling post unwind, no support found.);
582 dwarf-post-unwind := 0
583 else
584 dwarf-post-unwind-text := libdw
585 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
586 endif
587else
588 dwarf-post-unwind-text := libunwind
589 $(call detected,CONFIG_LIBUNWIND)
590 # Enable libunwind support by default.
591 ifndef NO_LIBDW_DWARF_UNWIND
592 NO_LIBDW_DWARF_UNWIND := 1
593 endif
594endif
595
596ifeq ($(dwarf-post-unwind),1)
597 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
598 $(call detected,CONFIG_DWARF_UNWIND)
599else
600 NO_DWARF_UNWIND := 1
601endif
602
603ifndef NO_LOCAL_LIBUNWIND
604 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
605 $(call feature_check,libunwind-debug-frame)
606 ifneq ($(feature-libunwind-debug-frame), 1)
607 msg := $(warning No debug_frame support found in libunwind);
608 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
609 endif
610 else
611 # non-ARM has no dwarf_find_debug_frame() function:
612 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
613 endif
614 EXTLIBS += $(LIBUNWIND_LIBS)
615 LDFLAGS += $(LIBUNWIND_LIBS)
616endif
Googler9398cc32022-12-02 17:21:52 +0800617ifeq ($(findstring -static,${LDFLAGS}),-static)
618 # gcc -static links libgcc_eh which contans piece of libunwind
619 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
620endif
Googleraf606d22022-10-26 21:40:12 -0700621
622ifndef NO_LIBUNWIND
623 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
624 CFLAGS += $(LIBUNWIND_CFLAGS)
625 LDFLAGS += $(LIBUNWIND_LDFLAGS)
626 EXTLIBS += $(EXTLIBS_LIBUNWIND)
627endif
628
Googler9398cc32022-12-02 17:21:52 +0800629ifeq ($(NO_SYSCALL_TABLE),0)
630 $(call detected,CONFIG_TRACE)
631else
632 ifndef NO_LIBAUDIT
633 ifneq ($(feature-libaudit), 1)
634 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
635 NO_LIBAUDIT := 1
636 else
637 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
638 EXTLIBS += -laudit
639 $(call detected,CONFIG_TRACE)
640 endif
Googleraf606d22022-10-26 21:40:12 -0700641 endif
642endif
643
644ifndef NO_LIBCRYPTO
645 ifneq ($(feature-libcrypto), 1)
Googler9398cc32022-12-02 17:21:52 +0800646 msg := $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev);
Googleraf606d22022-10-26 21:40:12 -0700647 NO_LIBCRYPTO := 1
648 else
649 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
650 EXTLIBS += -lcrypto
651 $(call detected,CONFIG_CRYPTO)
652 endif
653endif
654
655ifdef NO_NEWT
656 NO_SLANG=1
657endif
658
659ifndef NO_SLANG
660 ifneq ($(feature-libslang), 1)
Googler9398cc32022-12-02 17:21:52 +0800661 ifneq ($(feature-libslang-include-subdir), 1)
662 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
663 NO_SLANG := 1
664 else
665 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR
666 endif
667 endif
668 ifndef NO_SLANG
Googleraf606d22022-10-26 21:40:12 -0700669 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
670 CFLAGS += -DHAVE_SLANG_SUPPORT
671 EXTLIBS += -lslang
672 $(call detected,CONFIG_SLANG)
673 endif
674endif
675
676ifndef NO_GTK2
677 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
678 ifneq ($(feature-gtk2), 1)
679 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
680 NO_GTK2 := 1
681 else
682 ifeq ($(feature-gtk2-infobar), 1)
683 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
684 endif
685 CFLAGS += -DHAVE_GTK2_SUPPORT
686 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
687 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
688 EXTLIBS += -ldl
689 endif
690endif
691
692ifdef NO_LIBPERL
693 CFLAGS += -DNO_LIBPERL
694else
695 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
696 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
697 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
Googler9398cc32022-12-02 17:21:52 +0800698 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
699 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
700 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
Googleraf606d22022-10-26 21:40:12 -0700701 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
702
703 ifneq ($(feature-libperl), 1)
704 CFLAGS += -DNO_LIBPERL
705 NO_LIBPERL := 1
706 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
707 else
708 LDFLAGS += $(PERL_EMBED_LDFLAGS)
709 EXTLIBS += $(PERL_EMBED_LIBADD)
Googler9398cc32022-12-02 17:21:52 +0800710 CFLAGS += -DHAVE_LIBPERL_SUPPORT
Googleraf606d22022-10-26 21:40:12 -0700711 $(call detected,CONFIG_LIBPERL)
712 endif
713endif
714
715ifeq ($(feature-timerfd), 1)
716 CFLAGS += -DHAVE_TIMERFD_SUPPORT
717else
718 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
719endif
720
721disable-python = $(eval $(disable-python_code))
722define disable-python_code
723 CFLAGS += -DNO_LIBPYTHON
724 $(warning $1)
725 NO_LIBPYTHON := 1
726endef
727
728ifdef NO_LIBPYTHON
729 $(call disable-python,Python support disabled by user)
730else
731
732 ifndef PYTHON
733 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
734 else
735 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
736
737 ifndef PYTHON_CONFIG
738 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
739 else
740
741 ifneq ($(feature-libpython), 1)
742 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
743 else
Googler9398cc32022-12-02 17:21:52 +0800744 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
745 EXTLIBS += $(PYTHON_EMBED_LIBADD)
746 LANG_BINDINGS += $(obj-perf)python/perf.so
747 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
748 $(call detected,CONFIG_LIBPYTHON)
Googleraf606d22022-10-26 21:40:12 -0700749 endif
750 endif
751 endif
752endif
753
754ifeq ($(feature-libbfd), 1)
Googler9398cc32022-12-02 17:21:52 +0800755 EXTLIBS += -lbfd -lopcodes
756else
757 # we are on a system that requires -liberty and (maybe) -lz
758 # to link against -lbfd; test each case individually here
Googleraf606d22022-10-26 21:40:12 -0700759
760 # call all detections now so we get correct
761 # status in VF output
Googler9398cc32022-12-02 17:21:52 +0800762 $(call feature_check,libbfd-liberty)
763 $(call feature_check,libbfd-liberty-z)
Googleraf606d22022-10-26 21:40:12 -0700764
Googler9398cc32022-12-02 17:21:52 +0800765 ifeq ($(feature-libbfd-liberty), 1)
766 EXTLIBS += -lbfd -lopcodes -liberty
767 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
Googleraf606d22022-10-26 21:40:12 -0700768 else
Googler9398cc32022-12-02 17:21:52 +0800769 ifeq ($(feature-libbfd-liberty-z), 1)
770 EXTLIBS += -lbfd -lopcodes -liberty -lz
771 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
Googleraf606d22022-10-26 21:40:12 -0700772 endif
773 endif
Googler9398cc32022-12-02 17:21:52 +0800774 $(call feature_check,disassembler-four-args)
Googleraf606d22022-10-26 21:40:12 -0700775endif
776
777ifdef NO_DEMANGLE
778 CFLAGS += -DNO_DEMANGLE
779else
780 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
781 EXTLIBS += -liberty
782 else
Googler9398cc32022-12-02 17:21:52 +0800783 ifeq ($(filter -liberty,$(EXTLIBS)),)
784 $(call feature_check,cplus-demangle)
785
786 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
787 # or any of 'bfd iberty z' trinity
788 ifeq ($(feature-cplus-demangle), 1)
789 EXTLIBS += -liberty
790 else
791 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
792 CFLAGS += -DNO_DEMANGLE
Googleraf606d22022-10-26 21:40:12 -0700793 endif
794 endif
795 endif
Googler9398cc32022-12-02 17:21:52 +0800796
797 ifneq ($(filter -liberty,$(EXTLIBS)),)
798 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
799 endif
Googleraf606d22022-10-26 21:40:12 -0700800endif
801
802ifneq ($(filter -lbfd,$(EXTLIBS)),)
803 CFLAGS += -DHAVE_LIBBFD_SUPPORT
804endif
805
806ifndef NO_ZLIB
807 ifeq ($(feature-zlib), 1)
808 CFLAGS += -DHAVE_ZLIB_SUPPORT
809 EXTLIBS += -lz
810 $(call detected,CONFIG_ZLIB)
811 else
812 NO_ZLIB := 1
813 endif
814endif
815
816ifndef NO_LZMA
817 ifeq ($(feature-lzma), 1)
818 CFLAGS += -DHAVE_LZMA_SUPPORT
819 EXTLIBS += -llzma
820 $(call detected,CONFIG_LZMA)
821 else
822 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
823 NO_LZMA := 1
824 endif
825endif
826
Googler9398cc32022-12-02 17:21:52 +0800827ifndef NO_LIBZSTD
828 ifeq ($(feature-libzstd), 1)
829 CFLAGS += -DHAVE_ZSTD_SUPPORT
830 CFLAGS += $(LIBZSTD_CFLAGS)
831 LDFLAGS += $(LIBZSTD_LDFLAGS)
832 EXTLIBS += -lzstd
833 $(call detected,CONFIG_ZSTD)
834 else
835 msg := $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR);
836 NO_LIBZSTD := 1
837 endif
838endif
839
840ifndef NO_LIBCAP
841 ifeq ($(feature-libcap), 1)
842 CFLAGS += -DHAVE_LIBCAP_SUPPORT
843 EXTLIBS += -lcap
844 $(call detected,CONFIG_LIBCAP)
845 else
846 msg := $(warning No libcap found, disables capability support, please install libcap-devel/libcap-dev);
847 NO_LIBCAP := 1
848 endif
849endif
850
Googleraf606d22022-10-26 21:40:12 -0700851ifndef NO_BACKTRACE
852 ifeq ($(feature-backtrace), 1)
853 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
854 endif
855endif
856
857ifndef NO_LIBNUMA
858 ifeq ($(feature-libnuma), 0)
859 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
860 NO_LIBNUMA := 1
861 else
862 ifeq ($(feature-numa_num_possible_cpus), 0)
863 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
864 NO_LIBNUMA := 1
865 else
866 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
867 EXTLIBS += -lnuma
868 $(call detected,CONFIG_NUMA)
869 endif
870 endif
871endif
872
873ifdef HAVE_KVM_STAT_SUPPORT
874 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
875endif
876
Googler9398cc32022-12-02 17:21:52 +0800877ifeq ($(feature-disassembler-four-args), 1)
878 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
879endif
880
Googleraf606d22022-10-26 21:40:12 -0700881ifeq (${IS_64_BIT}, 1)
882 ifndef NO_PERF_READ_VDSO32
883 $(call feature_check,compile-32)
884 ifeq ($(feature-compile-32), 1)
885 CFLAGS += -DHAVE_PERF_READ_VDSO32
886 else
887 NO_PERF_READ_VDSO32 := 1
888 endif
889 endif
890 ifneq ($(SRCARCH), x86)
891 NO_PERF_READ_VDSOX32 := 1
892 endif
893 ifndef NO_PERF_READ_VDSOX32
894 $(call feature_check,compile-x32)
895 ifeq ($(feature-compile-x32), 1)
896 CFLAGS += -DHAVE_PERF_READ_VDSOX32
897 else
898 NO_PERF_READ_VDSOX32 := 1
899 endif
900 endif
901else
902 NO_PERF_READ_VDSO32 := 1
903 NO_PERF_READ_VDSOX32 := 1
904endif
905
Googler9398cc32022-12-02 17:21:52 +0800906ifndef NO_LIBBABELTRACE
Googleraf606d22022-10-26 21:40:12 -0700907 $(call feature_check,libbabeltrace)
908 ifeq ($(feature-libbabeltrace), 1)
909 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
910 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
911 EXTLIBS += -lbabeltrace-ctf
912 $(call detected,CONFIG_LIBBABELTRACE)
913 else
914 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
915 endif
916endif
917
918ifndef NO_AUXTRACE
919 ifeq ($(SRCARCH),x86)
920 ifeq ($(feature-get_cpuid), 0)
921 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
922 NO_AUXTRACE := 1
923 endif
924 endif
925 ifndef NO_AUXTRACE
926 $(call detected,CONFIG_AUXTRACE)
927 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
928 endif
929endif
930
Googler9398cc32022-12-02 17:21:52 +0800931ifndef NO_JVMTI
932 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
933 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
934 else
935 ifneq (,$(wildcard /usr/sbin/alternatives))
936 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')
937 endif
938 endif
939 ifndef JDIR
940 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
941 NO_JVMTI := 1
942 endif
943endif
944
945ifndef NO_JVMTI
946 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
947 $(call feature_check,jvmti)
948 ifeq ($(feature-jvmti), 1)
949 $(call detected_var,JDIR)
950 ifndef NO_JVMTI_CMLR
951 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
952 $(call feature_check,jvmti-cmlr)
953 ifeq ($(feature-jvmti-cmlr), 1)
954 CFLAGS += -DHAVE_JVMTI_CMLR
955 endif
956 endif # NO_JVMTI_CMLR
957 else
958 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
959 NO_JVMTI := 1
960 endif
961endif
962
963USE_CXX = 0
964USE_CLANGLLVM = 0
965ifdef LIBCLANGLLVM
966 $(call feature_check,cxx)
967 ifneq ($(feature-cxx), 1)
968 msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
969 else
970 $(call feature_check,llvm)
971 $(call feature_check,llvm-version)
972 ifneq ($(feature-llvm), 1)
973 msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
974 else
975 $(call feature_check,clang)
976 ifneq ($(feature-clang), 1)
977 msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
978 else
979 CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
980 CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
981 $(call detected,CONFIG_CXX)
982 $(call detected,CONFIG_CLANGLLVM)
983 USE_CXX = 1
984 USE_LLVM = 1
985 USE_CLANG = 1
986 ifneq ($(feature-llvm-version),1)
987 msg := $(warning This version of LLVM is not tested. May cause build errors)
988 endif
989 endif
990 endif
991 endif
992endif
993
Googleraf606d22022-10-26 21:40:12 -0700994# Among the variables below, these:
995# perfexecdir
Googler9398cc32022-12-02 17:21:52 +0800996# perf_include_dir
997# perf_examples_dir
Googleraf606d22022-10-26 21:40:12 -0700998# template_dir
999# mandir
1000# infodir
1001# htmldir
1002# ETC_PERFCONFIG (but not sysconfdir)
1003# can be specified as a relative path some/where/else;
1004# this is interpreted as relative to $(prefix) and "perf" at
1005# runtime figures out where they are based on the path to the executable.
1006# This can help installing the suite in a relocatable way.
1007
1008# Make the path relative to DESTDIR, not to prefix
1009ifndef DESTDIR
1010prefix ?= $(HOME)
1011endif
1012bindir_relative = bin
1013bindir = $(abspath $(prefix)/$(bindir_relative))
1014mandir = share/man
1015infodir = share/info
1016perfexecdir = libexec/perf-core
Googler9398cc32022-12-02 17:21:52 +08001017perf_include_dir = lib/perf/include
1018perf_examples_dir = lib/perf/examples
Googleraf606d22022-10-26 21:40:12 -07001019sharedir = $(prefix)/share
1020template_dir = share/perf-core/templates
1021STRACE_GROUPS_DIR = share/perf-core/strace/groups
1022htmldir = share/doc/perf-doc
1023tipdir = share/doc/perf-tip
1024srcdir = $(srctree)/tools/perf
1025ifeq ($(prefix),/usr)
1026sysconfdir = /etc
1027ETC_PERFCONFIG = $(sysconfdir)/perfconfig
1028else
1029sysconfdir = $(prefix)/etc
1030ETC_PERFCONFIG = etc/perfconfig
1031endif
1032ifndef lib
1033ifeq ($(SRCARCH)$(IS_64_BIT), x861)
1034lib = lib64
1035else
1036lib = lib
1037endif
1038endif # lib
1039libdir = $(prefix)/$(lib)
1040
1041# Shell quote (do not use $(call) to accommodate ancient setups);
1042ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
1043STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
1044DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1045bindir_SQ = $(subst ','\'',$(bindir))
1046mandir_SQ = $(subst ','\'',$(mandir))
1047infodir_SQ = $(subst ','\'',$(infodir))
1048perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
Googler9398cc32022-12-02 17:21:52 +08001049perf_include_dir_SQ = $(subst ','\'',$(perf_include_dir))
1050perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))
Googleraf606d22022-10-26 21:40:12 -07001051template_dir_SQ = $(subst ','\'',$(template_dir))
1052htmldir_SQ = $(subst ','\'',$(htmldir))
1053tipdir_SQ = $(subst ','\'',$(tipdir))
1054prefix_SQ = $(subst ','\'',$(prefix))
1055sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
1056libdir_SQ = $(subst ','\'',$(libdir))
1057srcdir_SQ = $(subst ','\'',$(srcdir))
1058
1059ifneq ($(filter /%,$(firstword $(perfexecdir))),)
1060perfexec_instdir = $(perfexecdir)
Googler9398cc32022-12-02 17:21:52 +08001061perf_include_instdir = $(perf_include_dir)
1062perf_examples_instdir = $(perf_examples_dir)
Googleraf606d22022-10-26 21:40:12 -07001063STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
1064tip_instdir = $(tipdir)
1065else
1066perfexec_instdir = $(prefix)/$(perfexecdir)
Googler9398cc32022-12-02 17:21:52 +08001067perf_include_instdir = $(prefix)/$(perf_include_dir)
1068perf_examples_instdir = $(prefix)/$(perf_examples_dir)
Googleraf606d22022-10-26 21:40:12 -07001069STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
1070tip_instdir = $(prefix)/$(tipdir)
1071endif
1072perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Googler9398cc32022-12-02 17:21:52 +08001073perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))
1074perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))
Googleraf606d22022-10-26 21:40:12 -07001075STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
1076tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
1077
1078# If we install to $(HOME) we keep the traceevent default:
1079# $(HOME)/.traceevent/plugins
1080# Otherwise we install plugins into the global $(libdir).
1081ifdef DESTDIR
1082plugindir=$(libdir)/traceevent/plugins
1083plugindir_SQ= $(subst ','\'',$(plugindir))
1084endif
1085
1086print_var = $(eval $(print_var_code)) $(info $(MSG))
1087define print_var_code
1088 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
1089endef
1090
1091ifeq ($(VF),1)
Googler9398cc32022-12-02 17:21:52 +08001092 # Display EXTRA features which are detected manualy
1093 # from here with feature_check call and thus cannot
1094 # be partof global state output.
1095 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),))
Googleraf606d22022-10-26 21:40:12 -07001096 $(call print_var,prefix)
1097 $(call print_var,bindir)
1098 $(call print_var,libdir)
1099 $(call print_var,sysconfdir)
1100 $(call print_var,LIBUNWIND_DIR)
1101 $(call print_var,LIBDW_DIR)
Googler9398cc32022-12-02 17:21:52 +08001102 $(call print_var,JDIR)
Googleraf606d22022-10-26 21:40:12 -07001103
1104 ifeq ($(dwarf-post-unwind),1)
1105 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
1106 endif
1107 $(info )
1108endif
1109
1110$(call detected_var,bindir_SQ)
1111$(call detected_var,PYTHON_WORD)
1112ifneq ($(OUTPUT),)
1113$(call detected_var,OUTPUT)
1114endif
1115$(call detected_var,htmldir_SQ)
1116$(call detected_var,infodir_SQ)
1117$(call detected_var,mandir_SQ)
1118$(call detected_var,ETC_PERFCONFIG_SQ)
1119$(call detected_var,STRACE_GROUPS_DIR_SQ)
1120$(call detected_var,prefix_SQ)
1121$(call detected_var,perfexecdir_SQ)
Googler9398cc32022-12-02 17:21:52 +08001122$(call detected_var,perf_include_dir_SQ)
1123$(call detected_var,perf_examples_dir_SQ)
Googleraf606d22022-10-26 21:40:12 -07001124$(call detected_var,tipdir_SQ)
1125$(call detected_var,srcdir_SQ)
1126$(call detected_var,LIBDIR)
1127$(call detected_var,GTK_CFLAGS)
1128$(call detected_var,PERL_EMBED_CCOPTS)
1129$(call detected_var,PYTHON_EMBED_CCOPTS)