blob: 446180401e267f27cc35852572b77131e3353fe5 [file] [log] [blame]
Thomas Gleixnerec8f24b2019-05-19 13:07:45 +01001# SPDX-License-Identifier: GPL-2.0-only
Jiri Olsa8bd407b2013-03-15 16:28:49 +01002
Jiri Olsaa6cf5f32014-01-03 15:32:32 +01003ifeq ($(src-perf),)
4src-perf := $(srctree)/tools/perf
Jiri Olsa8bd407b2013-03-15 16:28:49 +01005endif
6
Jiri Olsaa6cf5f32014-01-03 15:32:32 +01007ifeq ($(obj-perf),)
8obj-perf := $(OUTPUT)
9endif
10
11ifneq ($(obj-perf),)
12obj-perf := $(abspath $(obj-perf))/
13endif
14
Sergei Trofimovich52c0a182015-07-19 10:30:05 +010015$(shell printf "" > $(OUTPUT).config-detected)
Aaro Koskinen642273792015-07-01 14:54:42 +030016detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
17detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
Jiri Olsafcfd6612014-12-31 17:37:00 +010018
Vasily Gorbikab0a40e2020-10-09 14:25:23 +020019CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
Jiri Olsaa6cf5f32014-01-03 15:32:32 +010020
Wang Nan935e6bd2016-01-11 13:47:58 +000021include $(srctree)/tools/scripts/Makefile.arch
Jiri Olsaa6cf5f32014-01-03 15:32:32 +010022
Jiada Wang7a759cd2017-04-09 20:02:37 -070023$(call detected_var,SRCARCH)
Jiri Olsaf39e0422014-12-29 15:03:09 +010024
Jiri Olsaa6cf5f32014-01-03 15:32:32 +010025NO_PERF_REGS := 1
Arnaldo Carvalho de Melo9b90d972020-05-28 11:47:24 -030026
Arnaldo Carvalho de Melo9b90d972020-05-28 11:47:24 -030027ifneq ($(NO_SYSCALL_TABLE),1)
Arnaldo Carvalho de Melo43de3862020-05-28 12:03:40 -030028 NO_SYSCALL_TABLE := 1
29
30 ifeq ($(SRCARCH),x86)
31 ifeq (${IS_64_BIT}, 1)
32 NO_SYSCALL_TABLE := 0
33 endif
34 else
Tiezhu Yangd9fd5a72021-02-04 11:35:24 +080035 ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390 mips))
Arnaldo Carvalho de Melo43de3862020-05-28 12:03:40 -030036 NO_SYSCALL_TABLE := 0
37 endif
38 endif
39
40 ifneq ($(NO_SYSCALL_TABLE),1)
41 CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT
42 endif
Arnaldo Carvalho de Melo9b90d972020-05-28 11:47:24 -030043endif
44
Anju Tdc642e82016-02-20 10:32:47 +053045# Additional ARCH settings for ppc
Jiada Wang7a759cd2017-04-09 20:02:37 -070046ifeq ($(SRCARCH),powerpc)
Anju Tdc642e82016-02-20 10:32:47 +053047 NO_PERF_REGS := 0
Ravi Bangoria4281da22018-01-29 14:04:17 +053048 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated
Chandan Kumarc4522462016-04-28 15:01:09 +053049 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
Anju Tdc642e82016-02-20 10:32:47 +053050endif
51
Jiri Olsaa6cf5f32014-01-03 15:32:32 +010052# Additional ARCH settings for x86
Jiada Wang7a759cd2017-04-09 20:02:37 -070053ifeq ($(SRCARCH),x86)
Jiri Olsaf39e0422014-12-29 15:03:09 +010054 $(call detected,CONFIG_X86)
Namhyung Kimc6e5e9f2015-01-12 10:20:55 +080055 ifeq (${IS_64_BIT}, 1)
Hendrik Brueckner901bb022017-12-07 09:27:59 +010056 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020057 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
Konstantin Khlebnikov60913e02017-08-20 14:39:32 +030058 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
Jiri Olsa72965b82014-12-29 13:52:36 +010059 $(call detected,CONFIG_X86_64)
Adrian Hunter8a0c4c22013-11-01 15:51:32 +020060 else
Adrian Hunter05b41772015-05-19 16:05:43 +030061 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020062 endif
63 NO_PERF_REGS := 0
Jiri Olsa8bd407b2013-03-15 16:28:49 +010064endif
Jean Pihet8ab596a2014-04-28 14:32:33 +020065
Jiada Wang7a759cd2017-04-09 20:02:37 -070066ifeq ($(SRCARCH),arm)
Will Deacon7495f372013-09-26 12:36:36 +010067 NO_PERF_REGS := 0
68 LIBUNWIND_LIBS = -lunwind -lunwind-arm
69endif
Jiri Olsa8bd407b2013-03-15 16:28:49 +010070
Jiada Wang7a759cd2017-04-09 20:02:37 -070071ifeq ($(SRCARCH),arm64)
Jean Pihet8ab596a2014-04-28 14:32:33 +020072 NO_PERF_REGS := 0
Kim Phillipsa7f660d2018-07-06 16:34:54 -050073 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
Jean Pihet8ab596a2014-04-28 14:32:33 +020074 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
75endif
76
Mao Han51bc6202019-09-05 11:46:36 +080077ifeq ($(SRCARCH),riscv)
78 NO_PERF_REGS := 0
79endif
80
Mao Han32134862019-04-15 17:17:30 +080081ifeq ($(SRCARCH),csky)
82 NO_PERF_REGS := 0
83endif
84
Heiko Carstensf704ef42016-01-19 11:23:38 +010085ifeq ($(ARCH),s390)
86 NO_PERF_REGS := 0
Hendrik Bruecknera9a3f1d2017-12-13 17:46:54 -030087 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
Heiko Carstensf704ef42016-01-19 11:23:38 +010088endif
89
Tiezhu Yangb5f184f2021-02-04 11:35:23 +080090ifeq ($(ARCH),mips)
91 NO_PERF_REGS := 0
Tiezhu Yangd9fd5a72021-02-04 11:35:24 +080092 CFLAGS += -I$(OUTPUT)arch/mips/include/generated
Tiezhu Yangb5f184f2021-02-04 11:35:23 +080093 LIBUNWIND_LIBS = -lunwind -lunwind-mips
94endif
95
Jiri Olsa3bc33742014-12-30 13:30:04 +010096ifeq ($(NO_PERF_REGS),0)
97 $(call detected,CONFIG_PERF_REGS)
98endif
99
Jean Pihet90fa9de2014-05-16 10:41:11 +0200100# So far there's only x86 and arm libdw unwind support merged in perf.
Jiri Olsa4dc549e2014-04-20 10:50:00 +0200101# Disable it on all other architectures in case libdw unwind
102# support is detected in system. Add supported architectures
103# to the check.
Mao Han51bc6202019-09-05 11:46:36 +0800104ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv))
Jiri Olsa4dc549e2014-04-20 10:50:00 +0200105 NO_LIBDW_DWARF_UNWIND := 1
106endif
107
Jean Pihet1448fef2013-12-10 13:24:04 +0100108ifeq ($(LIBUNWIND_LIBS),)
109 NO_LIBUNWIND := 1
Jean Pihet1448fef2013-12-10 13:24:04 +0100110endif
Wang Nan5a155bb2016-01-29 05:57:30 +0000111#
112# For linking with debug library, run like:
113#
114# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
115#
He Kuang195106b2016-06-03 03:33:10 +0000116
117libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
118define 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
121endef
122
Wang Nan5a155bb2016-01-29 05:57:30 +0000123ifdef LIBUNWIND_DIR
124 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
125 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
He Kuang195106b2016-06-03 03:33:10 +0000126 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)))
Wang Nan5a155bb2016-01-29 05:57:30 +0000128endif
Wang Nan5a155bb2016-01-29 05:57:30 +0000129
130# Set per-feature check compilation flags
131FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
He Kuang403cacb2016-06-03 03:33:14 +0000132FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
Wang Nan5a155bb2016-01-29 05:57:30 +0000133FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
He Kuang403cacb2016-06-03 03:33:14 +0000134FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
Jean Pihet1448fef2013-12-10 13:24:04 +0100135
Li Huafeicdf32b42021-08-23 21:43:40 +0800136FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm
137FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
138FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
139FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
Arnaldo Carvalho de Melo5c4d7c82019-02-12 16:34:32 -0300140
Arnaldo Carvalho de Melo271402a2019-02-12 16:19:45 -0300141FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
142
Mathieu Poirieraa6292f2018-01-17 10:52:10 -0700143ifdef CSINCLUDES
144 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
145endif
146OPENCSDLIBS := -lopencsd_c_api -lopencsd
147ifdef CSLIBS
148 LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
149endif
150FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)
151FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)
152
Jiri Olsa8bd407b2013-03-15 16:28:49 +0100153ifeq ($(NO_PERF_REGS),0)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200154 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
Jiri Olsa8bd407b2013-03-15 16:28:49 +0100155endif
Jiri Olsaa32f4932013-03-25 00:32:01 +0100156
Wang Nan5a155bb2016-01-29 05:57:30 +0000157# for linking with debug library, run like:
158# make DEBUG=1 LIBDW_DIR=/opt/libdw/
159ifdef LIBDW_DIR
160 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
161 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
Jiri Olsa45757892014-02-19 16:52:56 +0100162endif
Konstantin Khlebnikovba335df2017-08-20 14:39:27 +0300163DWARFLIBS := -ldw
164ifeq ($(findstring -static,${LDFLAGS}),-static)
165 DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
166endif
Wang Nan5a155bb2016-01-29 05:57:30 +0000167FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
Konstantin Khlebnikovba335df2017-08-20 14:39:27 +0300168FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
Jiri Olsa45757892014-02-19 16:52:56 +0100169
Wang Nan5a155bb2016-01-29 05:57:30 +0000170# for linking with debug library, run like:
171# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
172ifdef LIBBABELTRACE_DIR
173 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
174 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
Jiri Olsa53d0a572015-02-20 23:16:58 +0100175endif
Wang Nan5a155bb2016-01-29 05:57:30 +0000176FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
177FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
Jiri Olsa53d0a572015-02-20 23:16:58 +0100178
Alexey Budankov3b1c5d92019-03-18 20:39:49 +0300179ifdef LIBZSTD_DIR
180 LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib
181 LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
182endif
183FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
184FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
185
Jiada Wang7a759cd2017-04-09 20:02:37 -0700186FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
Jiri Olsa7c537462013-05-24 14:35:23 +0200187# include ARCH specific config
Jiada Wang7a759cd2017-04-09 20:02:37 -0700188-include $(src-perf)/arch/$(SRCARCH)/Makefile
Jiri Olsa7c537462013-05-24 14:35:23 +0200189
Wang Nan63ab0242015-09-14 23:02:49 -0300190ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
191 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
192endif
193
Arnaldo Carvalho de Meloca70c242016-03-18 13:57:20 -0300194include $(srctree)/tools/scripts/utilities.mak
Jiri Olsaa32f4932013-03-25 00:32:01 +0100195
196ifeq ($(call get-executable,$(FLEX)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200197 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100198endif
199
200ifeq ($(call get-executable,$(BISON)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200201 dummy := $(error Error: $(BISON) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100202endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100203
Denys Zagorui67936722021-05-24 04:15:14 -0700204ifneq ($(OUTPUT),)
205 ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1)
206 BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)=
207 endif
208endif
209
Jiri Olsa362493f2013-03-25 00:40:48 +0100210# Treat warnings as errors unless directed not to
211ifneq ($(WERROR),0)
Jiri Olsa55542112019-10-11 14:21:55 +0200212 CORE_CFLAGS += -Werror
Wang Nand58ac0b2016-11-26 07:03:33 +0000213 CXXFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +0100214endif
215
Adrian Hunter74af3772013-10-22 10:34:05 +0300216ifndef DEBUG
217 DEBUG := 0
218endif
219
Ingo Molnarfcf92582013-10-10 08:05:25 +0200220ifeq ($(DEBUG),0)
David Carrillo-Cisneros38660582017-08-27 00:54:40 -0700221ifeq ($(CC_NO_CLANG), 0)
Jiri Olsa55542112019-10-11 14:21:55 +0200222 CORE_CFLAGS += -O3
Arnaldo Carvalho de Melo49b3cd32017-02-14 10:55:27 -0300223else
Jiri Olsa55542112019-10-11 14:21:55 +0200224 CORE_CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +0100225endif
Arnaldo Carvalho de Melo49b3cd32017-02-14 10:55:27 -0300226endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100227
228ifdef PARSER_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200229 PARSER_DEBUG_BISON := -t
230 PARSER_DEBUG_FLEX := -d
231 CFLAGS += -DPARSER_DEBUG
Jiri Olsa9352aab2014-12-29 17:42:46 +0100232 $(call detected_var,PARSER_DEBUG_BISON)
233 $(call detected_var,PARSER_DEBUG_FLEX)
Jiri Olsa362493f2013-03-25 00:40:48 +0100234endif
235
Wang Nan5a155bb2016-01-29 05:57:30 +0000236# Try different combinations to accommodate systems that only have
237# python[2][-config] in weird combinations but always preferring
James Clark79373082020-10-05 09:06:45 +0100238# python2 and python2-config as per pep-0394. If python2 or python
239# aren't found, then python3 is used.
240PYTHON_AUTO := python
241PYTHON_AUTO := $(if $(call get-executable,python3),python3,$(PYTHON_AUTO))
242PYTHON_AUTO := $(if $(call get-executable,python),python,$(PYTHON_AUTO))
243PYTHON_AUTO := $(if $(call get-executable,python2),python2,$(PYTHON_AUTO))
244override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON_AUTO))
245PYTHON_AUTO_CONFIG := \
Wang Nan5a155bb2016-01-29 05:57:30 +0000246 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
247override PYTHON_CONFIG := \
James Clark79373082020-10-05 09:06:45 +0100248 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO_CONFIG))
Namhyung Kim56c7d792014-07-29 15:57:19 +0900249
David Carrillo-Cisneros7be6b312017-04-11 23:49:13 -0700250grep-libs = $(filter -l%,$(1))
251strip-libs = $(filter-out -l%,$(1))
252
Wang Nan5a155bb2016-01-29 05:57:30 +0000253PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
Namhyung Kim56c7d792014-07-29 15:57:19 +0900254
Sam Luntb9c9ce42020-01-31 12:11:23 -0600255# Python 3.8 changed the output of `python-config --ldflags` to not include the
256# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
257# libpython fails if that flag is not included in LDFLAGS
258ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
259 PYTHON_CONFIG_LDFLAGS := --ldflags --embed
260else
261 PYTHON_CONFIG_LDFLAGS := --ldflags
262endif
263
David Carrillo-Cisneros7be6b312017-04-11 23:49:13 -0700264ifdef PYTHON_CONFIG
Sam Luntb9c9ce42020-01-31 12:11:23 -0600265 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
David Carrillo-Cisneros7be6b312017-04-11 23:49:13 -0700266 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
267 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
Jeremy Cline32aa9282018-07-10 11:46:12 -0400268 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
David Carrillo-Cisneros7be6b312017-04-11 23:49:13 -0700269 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
Arnaldo Carvalho de Melo8bd8c652017-02-15 21:31:40 -0300270endif
271
Wang Nan5a155bb2016-01-29 05:57:30 +0000272FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
273FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
274FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
275FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
Namhyung Kim56c7d792014-07-29 15:57:19 +0900276
Arnaldo Carvalho de Meloaa8f9c52019-02-12 11:20:56 -0300277FEATURE_CHECK_LDFLAGS-libaio = -lrt
278
Arnaldo Carvalho de Meloc6384172019-05-01 16:27:00 -0400279FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
Song Liu8a1b1712019-03-11 22:30:48 -0700280
Jiri Olsa55542112019-10-11 14:21:55 +0200281CORE_CFLAGS += -fno-omit-frame-pointer
282CORE_CFLAGS += -ggdb3
283CORE_CFLAGS += -funwind-tables
284CORE_CFLAGS += -Wall
285CORE_CFLAGS += -Wextra
286CORE_CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100287
Wang Nand58ac0b2016-11-26 07:03:33 +0000288CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
289CXXFLAGS += -Wall
290CXXFLAGS += -fno-omit-frame-pointer
291CXXFLAGS += -ggdb3
292CXXFLAGS += -funwind-tables
293CXXFLAGS += -Wno-strict-aliasing
294
Mathias Krause6392b4e2014-04-27 18:51:05 +0200295# Enforce a non-executable stack, as we may regress (again) in the future by
296# adding assembler files missing the .GNU-stack linker note.
297LDFLAGS += -Wl,-z,noexecstack
298
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900299EXTLIBS = -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +0100300
Jiri Olsabb91a072019-10-13 17:14:25 +0200301ifneq ($(TCMALLOC),)
302 CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
303 EXTLIBS += -ltcmalloc
304endif
305
Jiri Olsa96b9e702016-01-15 04:00:18 +0000306ifeq ($(FEATURES_DUMP),)
Arnaldo Carvalho de Meloc6e3bf42021-04-26 15:47:39 -0300307# We will display at the end of this Makefile.config, using $(call feature_display_entries)
308# As we may retry some feature detection here, see the disassembler-four-args case, for instance
309 FEATURE_DISPLAY_DEFERRED := 1
Jiri Olsae6c76d62015-03-01 21:19:44 +0100310include $(srctree)/tools/build/Makefile.feature
Jiri Olsa96b9e702016-01-15 04:00:18 +0000311else
312include $(FEATURES_DUMP)
313endif
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200314
Ingo Molnar90ac5422013-09-30 13:48:44 +0200315ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa55542112019-10-11 14:21:55 +0200316 CORE_CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100317endif
318
Ingo Molnarfcf92582013-10-10 08:05:25 +0200319ifeq ($(DEBUG),0)
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200320 ifeq ($(feature-fortify-source), 1)
Jiri Olsa55542112019-10-11 14:21:55 +0200321 CORE_CFLAGS += -D_FORTIFY_SOURCE=2
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200322 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100323endif
324
Jiri Olsa3ce311a2019-12-06 22:06:11 +0100325INC_FLAGS += -I$(srctree)/tools/lib/perf/include
Wang Nane67d52d2016-11-26 07:03:37 +0000326INC_FLAGS += -I$(src-perf)/util/include
Jiada Wang7a759cd2017-04-09 20:02:37 -0700327INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
Wang Nane67d52d2016-11-26 07:03:37 +0000328INC_FLAGS += -I$(srctree)/tools/include/
Jiada Wang7a759cd2017-04-09 20:02:37 -0700329INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
Arnaldo Carvalho de Melo146dc302019-08-19 11:11:30 -0300330INC_FLAGS += -I$(srctree)/tools/include/uapi
Jiada Wang7a759cd2017-04-09 20:02:37 -0700331INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
332INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
Jiri Olsa7c537462013-05-24 14:35:23 +0200333
334# $(obj-perf) for generated common-cmds.h
335# $(obj-perf)/util for generated bison/flex headers
336ifneq ($(OUTPUT),)
Wang Nane67d52d2016-11-26 07:03:37 +0000337INC_FLAGS += -I$(obj-perf)/util
338INC_FLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200339endif
340
Wang Nane67d52d2016-11-26 07:03:37 +0000341INC_FLAGS += -I$(src-perf)/util
342INC_FLAGS += -I$(src-perf)
343INC_FLAGS += -I$(srctree)/tools/lib/
344
Jiri Olsa55542112019-10-11 14:21:55 +0200345CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
346
347CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)
Wang Nane67d52d2016-11-26 07:03:37 +0000348CXXFLAGS += $(INC_FLAGS)
Jiri Olsa7c537462013-05-24 14:35:23 +0200349
Jiri Olsa55542112019-10-11 14:21:55 +0200350LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)
Jiri Olsa362493f2013-03-25 00:40:48 +0100351
Vineet Gupta459a3df2015-01-13 19:13:24 +0530352ifeq ($(feature-pthread-attr-setaffinity-np), 1)
353 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
354endif
355
Arnaldo Carvalho de Melo25ab5ab2017-12-05 10:14:42 -0300356ifeq ($(feature-pthread-barrier), 1)
357 CFLAGS += -DHAVE_PTHREAD_BARRIER
358endif
359
Jiri Olsa4e22db42013-05-24 14:35:24 +0200360ifndef NO_BIONIC
David Ahern5febff02013-10-29 10:43:15 -0600361 $(call feature_check,bionic)
Ingo Molnar78e9d652013-09-30 14:11:46 +0200362 ifeq ($(feature-bionic), 1)
363 BIONIC := 1
Arnaldo Carvalho de Melo748fe082018-12-11 15:48:47 -0300364 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
Arnaldo Carvalho de Melod7a8c4a2018-12-11 16:31:19 -0300365 CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
Ingo Molnar78e9d652013-09-30 14:11:46 +0200366 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
367 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
368 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100369endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100370
Arnaldo Carvalho de Melo11c6cbe2018-11-21 17:42:00 -0300371ifeq ($(feature-eventfd), 1)
Arnaldo Carvalho de Meloba35fe92020-05-20 12:21:07 -0300372 CFLAGS += -DHAVE_EVENTFD_SUPPORT
Arnaldo Carvalho de Melo11c6cbe2018-11-21 17:42:00 -0300373endif
374
Arnaldo Carvalho de Melo8feb8ef2018-11-19 16:56:22 -0300375ifeq ($(feature-get_current_dir_name), 1)
376 CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
377endif
378
Arnaldo Carvalho de Melo4541a8b2019-06-13 12:04:19 -0300379ifeq ($(feature-gettid), 1)
380 CFLAGS += -DHAVE_GETTID
381endif
382
Namhyung Kim49f550e2020-04-02 10:52:49 +0900383ifeq ($(feature-file-handle), 1)
384 CFLAGS += -DHAVE_FILE_HANDLE
385endif
386
Jiri Olsacf4cca12013-03-25 00:45:08 +0100387ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200388 NO_DWARF := 1
389 NO_DEMANGLE := 1
390 NO_LIBUNWIND := 1
Jiri Olsa5ea84152014-02-19 16:52:57 +0100391 NO_LIBDW_DWARF_UNWIND := 1
Wang Naned63f34c2015-10-14 12:41:12 +0000392 NO_LIBBPF := 1
David Carrillo-Cisnerose5e992a2017-04-12 10:07:45 -0700393 NO_JVMTI := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100394else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200395 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200396 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200397 LIBC_SUPPORT := 1
398 endif
399 ifeq ($(BIONIC),1)
400 LIBC_SUPPORT := 1
401 endif
402 ifeq ($(LIBC_SUPPORT),1)
David Carrillo-Cisnerose5e992a2017-04-12 10:07:45 -0700403 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);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100404
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200405 NO_LIBELF := 1
406 NO_DWARF := 1
407 NO_DEMANGLE := 1
Arnaldo Carvalho de Melo94589552014-03-25 09:35:11 -0300408 NO_LIBUNWIND := 1
409 NO_LIBDW_DWARF_UNWIND := 1
Wang Naned63f34c2015-10-14 12:41:12 +0000410 NO_LIBBPF := 1
David Carrillo-Cisnerose5e992a2017-04-12 10:07:45 -0700411 NO_JVMTI := 1
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200412 else
Tiezhu Yang6a1515c2020-06-18 10:06:01 +0800413 ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)
414 ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)
415 msg := $(error No libasan found, please install libasan);
416 endif
417 endif
418
419 ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),)
420 ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0)
421 msg := $(error No libubsan found, please install libubsan);
422 endif
423 endif
424
Arnaldo Carvalho de Melof9ca2d82014-06-05 12:46:04 -0300425 ifneq ($(filter s% -static%,$(LDFLAGS),),)
426 msg := $(error No static glibc found, please install glibc-static);
427 else
428 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
429 endif
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200430 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200431 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100432 ifndef NO_LIBDW_DWARF_UNWIND
433 ifneq ($(feature-libdw-dwarf-unwind),1)
434 NO_LIBDW_DWARF_UNWIND := 1
435 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
436 endif
437 endif
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200438 ifneq ($(feature-dwarf), 1)
David Carrillo-Cisneros2484c4c2017-01-12 13:01:59 -0800439 ifndef NO_DWARF
440 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);
441 NO_DWARF := 1
442 endif
Arnaldo Carvalho de Melobd0419e2016-04-05 11:33:41 -0300443 else
444 ifneq ($(feature-dwarf_getlocations), 1)
445 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
446 else
Jin Yaoa36ebe42018-03-30 17:27:13 +0800447 CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
Arnaldo Carvalho de Melobd0419e2016-04-05 11:33:41 -0300448 endif # dwarf_getlocations
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200449 endif # Dwarf support
Ingo Molnar0648f832013-10-02 15:30:35 +0200450 endif # libelf support
Jiri Olsacf4cca12013-03-25 00:45:08 +0100451endif # NO_LIBELF
452
Jin Yao8e2c2412018-03-30 17:27:12 +0800453ifeq ($(feature-glibc), 1)
454 CFLAGS += -DHAVE_GLIBC_SUPPORT
455endif
456
Alexey Budankov2a07d812018-11-06 12:03:35 +0300457ifeq ($(feature-libaio), 1)
458 ifndef NO_AIO
459 CFLAGS += -DHAVE_AIO_SUPPORT
460 endif
461endif
462
Naveen N. Rao76d40842015-04-29 16:45:31 +0530463ifdef NO_DWARF
464 NO_LIBDW_DWARF_UNWIND := 1
465endif
466
Arnaldo Carvalho de Melo120010c2017-03-02 12:55:49 -0300467ifeq ($(feature-sched_getcpu), 1)
468 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
469endif
470
Arnaldo Carvalho de Melo86bcdb52017-07-18 17:15:29 -0300471ifeq ($(feature-setns), 1)
472 CFLAGS += -DHAVE_SETNS_SUPPORT
473 $(call detected,CONFIG_SETNS)
474endif
475
Arnaldo Carvalho de Melo1c3b28f2019-02-12 14:37:15 -0300476ifdef CORESIGHT
477 $(call feature_check,libopencsd)
Mathieu Poirieraa6292f2018-01-17 10:52:10 -0700478 ifeq ($(feature-libopencsd), 1)
479 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
Mathieu Poirierc152d4d2019-05-24 11:35:05 -0600480 ifeq ($(feature-reallocarray), 0)
481 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
482 endif
Mathieu Poirieraa6292f2018-01-17 10:52:10 -0700483 LDFLAGS += $(LIBOPENCSD_LDFLAGS)
484 EXTLIBS += $(OPENCSDLIBS)
485 $(call detected,CONFIG_LIBOPENCSD)
486 ifdef CSTRACE_RAW
487 CFLAGS += -DCS_DEBUG_RAW
488 ifeq (${CSTRACE_RAW}, packed)
489 CFLAGS += -DCS_RAW_PACKED
490 endif
491 endif
Leo Yan71f7f892021-09-02 16:18:00 +0800492 else
493 dummy := $(error Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1)
Mathieu Poirieraa6292f2018-01-17 10:52:10 -0700494 endif
495endif
496
Jiri Olsacf4cca12013-03-25 00:45:08 +0100497ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200498 CFLAGS += -DHAVE_LIBELF_SUPPORT
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900499 EXTLIBS += -lelf
Jiri Olsa709e6792014-12-29 23:52:25 +0100500 $(call detected,CONFIG_LIBELF)
Jiri Olsa779724f2013-03-25 00:48:14 +0100501
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200502 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200503 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
504 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100505
Arnaldo Carvalho de Melo1c1a3a42016-07-12 12:19:09 -0300506 ifeq ($(feature-libelf-gelf_getnote), 1)
507 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
508 else
509 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
510 endif
511
Arnaldo Carvalho de Melo2492c462016-07-04 19:35:47 -0300512 ifeq ($(feature-libelf-getshdrstrndx), 1)
513 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
514 endif
515
Frank Ch. Eiglerc7a14fd2020-08-13 10:22:04 +0200516 ifndef NO_LIBDEBUGINFOD
517 $(call feature_check,libdebuginfod)
518 ifeq ($(feature-libdebuginfod), 1)
519 CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT
520 EXTLIBS += -ldebuginfod
521 endif
522 endif
523
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200524 ifndef NO_DWARF
525 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
Jiada Wang7a759cd2017-04-09 20:02:37 -0700526 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200527 NO_DWARF := 1
528 else
529 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
530 LDFLAGS += $(LIBDW_LDFLAGS)
Andi Kleen7aec51c2015-08-12 15:48:37 -0700531 EXTLIBS += ${DWARFLIBS}
Jiri Olsa8379fce2014-12-30 00:06:25 +0100532 $(call detected,CONFIG_DWARF)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200533 endif # PERF_HAVE_DWARF_REGS
534 endif # NO_DWARF
Wang Naned63f34c2015-10-14 12:41:12 +0000535
536 ifndef NO_LIBBPF
537 ifeq ($(feature-bpf), 1)
538 CFLAGS += -DHAVE_LIBBPF_SUPPORT
539 $(call detected,CONFIG_LIBBPF)
Jiri Olsa7b65e202019-11-26 13:12:53 +0100540
541 # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status
542 $(call feature_check,libbpf)
543 ifdef LIBBPF_DYNAMIC
544 ifeq ($(feature-libbpf), 1)
545 EXTLIBS += -lbpf
Jiri Olsaad1237c2021-05-08 22:50:20 +0200546 $(call detected,CONFIG_LIBBPF_DYNAMIC)
Jiri Olsa7b65e202019-11-26 13:12:53 +0100547 else
548 dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
549 endif
550 endif
Wang Naned63f34c2015-10-14 12:41:12 +0000551 endif
Wang Nan1c0ed632015-11-16 12:10:10 +0000552
553 ifndef NO_DWARF
554 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
555 CFLAGS += -DHAVE_BPF_PROLOGUE
556 $(call detected,CONFIG_BPF_PROLOGUE)
557 else
Jiada Wang7a759cd2017-04-09 20:02:37 -0700558 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
Wang Nan1c0ed632015-11-16 12:10:10 +0000559 endif
560 else
561 msg := $(warning DWARF support is off, BPF prologue is disabled);
562 endif
563
Wang Naned63f34c2015-10-14 12:41:12 +0000564 endif # NO_LIBBPF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100565endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100566
Masami Hiramatsue26e63b2016-07-12 19:05:56 +0900567ifndef NO_SDT
568 ifneq ($(feature-sdt), 1)
569 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
570 NO_SDT := 1;
571 else
572 CFLAGS += -DHAVE_SDT_EVENT
573 $(call detected,CONFIG_SDT_EVENT)
574 endif
575endif
576
Jiri Olsae12b2022016-03-10 17:41:13 +0100577ifdef PERF_HAVE_JITDUMP
Maciej Debski621cb4e2016-10-13 03:59:36 -0700578 ifndef NO_LIBELF
Jiri Olsae12b2022016-03-10 17:41:13 +0100579 $(call detected,CONFIG_JITDUMP)
580 CFLAGS += -DHAVE_JITDUMP
581 endif
582endif
583
Jiada Wang7a759cd2017-04-09 20:02:37 -0700584ifeq ($(SRCARCH),powerpc)
Anton Blanchard65ccb4f2014-08-25 18:25:06 +1000585 ifndef NO_DWARF
586 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
587 endif
588endif
589
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100590ifndef NO_LIBUNWIND
He Kuang9d8e14d2016-06-03 03:33:15 +0000591 have_libunwind :=
He Kuang52ffe0f2016-06-03 03:33:22 +0000592
Arnaldo Carvalho de Melo5c4d7c82019-02-12 16:34:32 -0300593 $(call feature_check,libunwind-x86)
He Kuang52ffe0f2016-06-03 03:33:22 +0000594 ifeq ($(feature-libunwind-x86), 1)
595 $(call detected,CONFIG_LIBUNWIND_X86)
596 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
597 LDFLAGS += -lunwind-x86
He Kuang906a8272016-06-15 11:03:56 +0000598 EXTLIBS_LIBUNWIND += -lunwind-x86
He Kuang52ffe0f2016-06-03 03:33:22 +0000599 have_libunwind = 1
600 endif
601
Arnaldo Carvalho de Melo5c4d7c82019-02-12 16:34:32 -0300602 $(call feature_check,libunwind-aarch64)
He Kuang057fbfb2016-06-03 03:33:23 +0000603 ifeq ($(feature-libunwind-aarch64), 1)
604 $(call detected,CONFIG_LIBUNWIND_AARCH64)
605 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
606 LDFLAGS += -lunwind-aarch64
He Kuang906a8272016-06-15 11:03:56 +0000607 EXTLIBS_LIBUNWIND += -lunwind-aarch64
He Kuang057fbfb2016-06-03 03:33:23 +0000608 have_libunwind = 1
609 $(call feature_check,libunwind-debug-frame-aarch64)
610 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
611 msg := $(warning No debug_frame support found in libunwind-aarch64);
612 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
613 endif
614 endif
615
Ingo Molnar058f9522013-09-30 14:45:44 +0200616 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100617 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
He Kuang9d8e14d2016-06-03 03:33:15 +0000618 NO_LOCAL_LIBUNWIND := 1
619 else
620 have_libunwind := 1
621 $(call detected,CONFIG_LOCAL_LIBUNWIND)
622 endif
623
624 ifneq ($(have_libunwind), 1)
Ingo Molnar308e1e72013-10-07 10:30:47 +0200625 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100626 endif
He Kuang9d8e14d2016-06-03 03:33:15 +0000627else
628 NO_LOCAL_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100629endif
630
Wang Naned63f34c2015-10-14 12:41:12 +0000631ifndef NO_LIBBPF
632 ifneq ($(feature-bpf), 1)
633 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
634 NO_LIBBPF := 1
635 endif
636endif
637
Song Liufbcdaa12020-12-29 13:42:13 -0800638ifdef BUILD_BPF_SKEL
639 $(call feature_check,clang-bpf-co-re)
640 ifeq ($(feature-clang-bpf-co-re), 0)
Song Liuefb0b232021-05-09 23:49:17 -0700641 dummy := $(error Error: clang too old/not installed. Please install recent clang to build with BUILD_BPF_SKEL)
Song Liufbcdaa12020-12-29 13:42:13 -0800642 endif
643 $(call detected,CONFIG_PERF_BPF_SKEL)
644 CFLAGS += -DHAVE_BPF_SKEL
645endif
646
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100647dwarf-post-unwind := 1
648dwarf-post-unwind-text := BUG
649
650# setup DWARF post unwinder
651ifdef NO_LIBUNWIND
652 ifdef NO_LIBDW_DWARF_UNWIND
653 msg := $(warning Disabling post unwind, no support found.);
654 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900655 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100656 dwarf-post-unwind-text := libdw
Jiri Olsab2e45c32014-12-30 00:11:11 +0100657 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100658 endif
659else
660 dwarf-post-unwind-text := libunwind
Jiri Olsab2e45c32014-12-30 00:11:11 +0100661 $(call detected,CONFIG_LIBUNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100662 # Enable libunwind support by default.
663 ifndef NO_LIBDW_DWARF_UNWIND
664 NO_LIBDW_DWARF_UNWIND := 1
665 endif
666endif
667
668ifeq ($(dwarf-post-unwind),1)
669 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
Jiri Olsaf39e0422014-12-29 15:03:09 +0100670 $(call detected,CONFIG_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100671else
672 NO_DWARF_UNWIND := 1
673endif
674
He Kuang9d8e14d2016-06-03 03:33:15 +0000675ifndef NO_LOCAL_LIBUNWIND
Jiada Wang7a759cd2017-04-09 20:02:37 -0700676 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100677 $(call feature_check,libunwind-debug-frame)
678 ifneq ($(feature-libunwind-debug-frame), 1)
679 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900680 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
681 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100682 else
683 # non-ARM has no dwarf_find_debug_frame() function:
684 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
685 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100686 EXTLIBS += $(LIBUNWIND_LIBS)
He Kuang9d8e14d2016-06-03 03:33:15 +0000687 LDFLAGS += $(LIBUNWIND_LIBS)
688endif
Konstantin Khlebnikov60913e02017-08-20 14:39:32 +0300689ifeq ($(findstring -static,${LDFLAGS}),-static)
690 # gcc -static links libgcc_eh which contans piece of libunwind
691 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
692endif
He Kuang9d8e14d2016-06-03 03:33:15 +0000693
694ifndef NO_LIBUNWIND
695 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100696 CFLAGS += $(LIBUNWIND_CFLAGS)
697 LDFLAGS += $(LIBUNWIND_LDFLAGS)
He Kuang906a8272016-06-15 11:03:56 +0000698 EXTLIBS += $(EXTLIBS_LIBUNWIND)
Ingo Molnar058f9522013-09-30 14:45:44 +0200699endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100700
Hendrik Bruecknerb3fa3892018-01-19 09:56:17 +0100701ifeq ($(NO_SYSCALL_TABLE),0)
702 $(call detected,CONFIG_TRACE)
703else
704 ifndef NO_LIBAUDIT
Arnaldo Carvalho de Meloa88f70d2020-05-29 11:11:59 -0300705 $(call feature_check,libaudit)
Hendrik Bruecknerb3fa3892018-01-19 09:56:17 +0100706 ifneq ($(feature-libaudit), 1)
707 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
708 NO_LIBAUDIT := 1
709 else
710 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
711 EXTLIBS += -laudit
712 $(call detected,CONFIG_TRACE)
713 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200714 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100715endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100716
Stephane Eranian8ee46462015-11-30 10:02:21 +0100717ifndef NO_LIBCRYPTO
718 ifneq ($(feature-libcrypto), 1)
Arnaldo Carvalho de Melo54fceb02018-11-29 20:41:54 -0300719 msg := $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev);
Stephane Eranian8ee46462015-11-30 10:02:21 +0100720 NO_LIBCRYPTO := 1
721 else
722 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
723 EXTLIBS += -lcrypto
724 $(call detected,CONFIG_CRYPTO)
725 endif
726endif
727
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100728ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200729 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100730endif
731
732ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200733 ifneq ($(feature-libslang), 1)
Arnaldo Carvalho de Melo78d6ccc2019-06-18 17:48:12 -0300734 ifneq ($(feature-libslang-include-subdir), 1)
735 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
736 NO_SLANG := 1
737 else
738 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR
739 endif
740 endif
741 ifndef NO_SLANG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200742 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
Ingo Molnar89fe8082013-09-30 12:07:11 +0200743 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200744 EXTLIBS += -lslang
Jiri Olsacf15c742014-12-30 00:27:52 +0100745 $(call detected,CONFIG_SLANG)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200746 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100747endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100748
Arnaldo Carvalho de Melo4751bdd2020-09-04 17:11:59 -0300749ifdef GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000750 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Arnaldo Carvalho de Melo4751bdd2020-09-04 17:11:59 -0300751 $(call feature_check,gtk2)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200752 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200753 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
754 NO_GTK2 := 1
755 else
Arnaldo Carvalho de Melo4751bdd2020-09-04 17:11:59 -0300756 $(call feature_check,gtk2-infobar)
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200757 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900758 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200759 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200760 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000761 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
762 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200763 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200764 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100765endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100766
Jiri Olsa3082cb32013-03-18 00:19:44 +0100767ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200768 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100769else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200770 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
771 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
772 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
Jiri Olsa86f5fe02017-11-08 11:27:37 +0100773 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
Jiri Olsac6707fd2017-12-04 12:23:08 -0300774 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
Justin M. Forbesb773ea62020-10-28 13:59:00 -0300775 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
Jiri Olsac6707fd2017-12-04 12:23:08 -0300776 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200777 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100778
Ingo Molnar7181a672013-09-30 15:15:36 +0200779 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200780 CFLAGS += -DNO_LIBPERL
781 NO_LIBPERL := 1
Ingo Molnara954e682015-02-28 09:39:09 +0100782 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200783 else
784 LDFLAGS += $(PERL_EMBED_LDFLAGS)
785 EXTLIBS += $(PERL_EMBED_LIBADD)
Jin Yao8e2c2412018-03-30 17:27:12 +0800786 CFLAGS += -DHAVE_LIBPERL_SUPPORT
Jiri Olsac7355f82014-12-30 13:11:32 +0100787 $(call detected,CONFIG_LIBPERL)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200788 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100789endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100790
David Ahern87419c92013-10-29 10:43:16 -0600791ifeq ($(feature-timerfd), 1)
792 CFLAGS += -DHAVE_TIMERFD_SUPPORT
793else
794 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
795endif
796
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100797disable-python = $(eval $(disable-python_code))
798define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100799 CFLAGS += -DNO_LIBPYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100800 $(warning $1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100801 NO_LIBPYTHON := 1
802endef
803
Namhyung Kim56c7d792014-07-29 15:57:19 +0900804ifdef NO_LIBPYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100805 $(call disable-python,Python support disabled by user)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100806else
807
Namhyung Kim56c7d792014-07-29 15:57:19 +0900808 ifndef PYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100809 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100810 else
Namhyung Kim56c7d792014-07-29 15:57:19 +0900811 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100812
813 ifndef PYTHON_CONFIG
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100814 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100815 else
816
Ingo Molnar97341632013-09-30 15:18:37 +0200817 ifneq ($(feature-libpython), 1)
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100818 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100819 else
Jaroslav Å karvada66dfdff2018-01-19 21:56:41 +0100820 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
821 EXTLIBS += $(PYTHON_EMBED_LIBADD)
822 LANG_BINDINGS += $(obj-perf)python/perf.so
Jin Yao8e2c2412018-03-30 17:27:12 +0800823 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
Jaroslav Å karvada66dfdff2018-01-19 21:56:41 +0100824 $(call detected,CONFIG_LIBPYTHON)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100825 endif
826 endif
827 endif
828endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100829
Jiri Olsa2cf90402014-04-23 16:53:25 +0200830
Ian Rogers0d1c50a2021-09-10 15:57:56 -0700831ifndef NO_LIBBFD
832 ifeq ($(feature-libbfd), 1)
833 EXTLIBS += -lbfd -lopcodes
Jiri Olsa2cf90402014-04-23 16:53:25 +0200834 else
Ian Rogers0d1c50a2021-09-10 15:57:56 -0700835 # we are on a system that requires -liberty and (maybe) -lz
836 # to link against -lbfd; test each case individually here
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200837
Ian Rogers0d1c50a2021-09-10 15:57:56 -0700838 # call all detections now so we get correct
839 # status in VF output
840 $(call feature_check,libbfd-liberty)
841 $(call feature_check,libbfd-liberty-z)
842
843 ifeq ($(feature-libbfd-liberty), 1)
844 EXTLIBS += -lbfd -lopcodes -liberty
845 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
846 else
847 ifeq ($(feature-libbfd-liberty-z), 1)
848 EXTLIBS += -lbfd -lopcodes -liberty -lz
849 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
850 endif
851 endif
852 $(call feature_check,disassembler-four-args)
853 endif
854
855 ifeq ($(feature-libbfd-buildid), 1)
856 CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
857 else
858 msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available);
859 endif
Arnaldo Carvalho de Meloe71e19a2020-09-03 13:44:39 -0300860endif
861
Jiri Olsac3cf8362013-03-18 00:38:16 +0100862ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200863 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100864else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200865 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200866 EXTLIBS += -liberty
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200867 else
Stanislav Fomichev14541b12018-11-15 16:32:01 -0800868 ifeq ($(filter -liberty,$(EXTLIBS)),)
869 $(call feature_check,cplus-demangle)
870
871 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
872 # or any of 'bfd iberty z' trinity
873 ifeq ($(feature-cplus-demangle), 1)
874 EXTLIBS += -liberty
875 else
876 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
877 CFLAGS += -DNO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200878 endif
879 endif
880 endif
Stanislav Fomichev14541b12018-11-15 16:32:01 -0800881
882 ifneq ($(filter -liberty,$(EXTLIBS)),)
883 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
884 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100885endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100886
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200887ifneq ($(filter -lbfd,$(EXTLIBS)),)
888 CFLAGS += -DHAVE_LIBBFD_SUPPORT
889endif
890
Namhyung Kime92ce122014-10-31 16:51:38 +0900891ifndef NO_ZLIB
892 ifeq ($(feature-zlib), 1)
893 CFLAGS += -DHAVE_ZLIB_SUPPORT
894 EXTLIBS += -lz
Jiri Olsa1571b692014-12-30 13:31:12 +0100895 $(call detected,CONFIG_ZLIB)
Namhyung Kime92ce122014-10-31 16:51:38 +0900896 else
897 NO_ZLIB := 1
898 endif
899endif
900
Jiri Olsa80a32e5b2015-01-29 13:29:39 +0100901ifndef NO_LZMA
902 ifeq ($(feature-lzma), 1)
903 CFLAGS += -DHAVE_LZMA_SUPPORT
904 EXTLIBS += -llzma
905 $(call detected,CONFIG_LZMA)
906 else
907 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
908 NO_LZMA := 1
909 endif
910endif
911
Alexey Budankov3b1c5d92019-03-18 20:39:49 +0300912ifndef NO_LIBZSTD
913 ifeq ($(feature-libzstd), 1)
914 CFLAGS += -DHAVE_ZSTD_SUPPORT
915 CFLAGS += $(LIBZSTD_CFLAGS)
916 LDFLAGS += $(LIBZSTD_LDFLAGS)
917 EXTLIBS += -lzstd
918 $(call detected,CONFIG_ZSTD)
919 else
920 msg := $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR);
921 NO_LIBZSTD := 1
922 endif
923endif
924
Igor Lubashev74d5f3d2019-08-07 10:44:14 -0400925ifndef NO_LIBCAP
926 ifeq ($(feature-libcap), 1)
927 CFLAGS += -DHAVE_LIBCAP_SUPPORT
928 EXTLIBS += -lcap
929 $(call detected,CONFIG_LIBCAP)
930 else
931 msg := $(warning No libcap found, disables capability support, please install libcap-devel/libcap-dev);
932 NO_LIBCAP := 1
933 endif
934endif
935
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100936ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200937 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200938 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200939 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100940endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100941
942ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200943 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500944 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200945 NO_LIBNUMA := 1
946 else
Arnaldo Carvalho de Melof8ac8602015-09-17 12:20:28 -0300947 ifeq ($(feature-numa_num_possible_cpus), 0)
948 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
949 NO_LIBNUMA := 1
950 else
951 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
952 EXTLIBS += -lnuma
953 $(call detected,CONFIG_NUMA)
954 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200955 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100956endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100957
Alexander Yaryginda50ad62014-07-03 17:59:49 +0400958ifdef HAVE_KVM_STAT_SUPPORT
959 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
960endif
961
Song Liu8a1b1712019-03-11 22:30:48 -0700962ifeq ($(feature-disassembler-four-args), 1)
963 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
964endif
965
Adrian Huntere477f3f2014-10-23 18:16:03 -0300966ifeq (${IS_64_BIT}, 1)
967 ifndef NO_PERF_READ_VDSO32
968 $(call feature_check,compile-32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300969 ifeq ($(feature-compile-32), 1)
970 CFLAGS += -DHAVE_PERF_READ_VDSO32
971 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300972 NO_PERF_READ_VDSO32 := 1
973 endif
974 endif
Jiada Wang7a759cd2017-04-09 20:02:37 -0700975 ifneq ($(SRCARCH), x86)
Adrian Huntere477f3f2014-10-23 18:16:03 -0300976 NO_PERF_READ_VDSOX32 := 1
977 endif
978 ifndef NO_PERF_READ_VDSOX32
979 $(call feature_check,compile-x32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300980 ifeq ($(feature-compile-x32), 1)
981 CFLAGS += -DHAVE_PERF_READ_VDSOX32
982 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300983 NO_PERF_READ_VDSOX32 := 1
984 endif
985 endif
986else
987 NO_PERF_READ_VDSO32 := 1
988 NO_PERF_READ_VDSOX32 := 1
989endif
990
Jiri Olsa24787af2018-01-07 17:03:45 +0100991ifndef NO_LIBBABELTRACE
Jiri Olsa97e7a512015-03-11 09:00:41 +0100992 $(call feature_check,libbabeltrace)
993 ifeq ($(feature-libbabeltrace), 1)
Jiri Olsa53d0a572015-02-20 23:16:58 +0100994 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
995 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
996 EXTLIBS += -lbabeltrace-ctf
Jiri Olsaedbe9812015-02-20 23:17:00 +0100997 $(call detected,CONFIG_LIBBABELTRACE)
Jiri Olsa97e7a512015-03-11 09:00:41 +0100998 else
999 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
Jiri Olsa53d0a572015-02-20 23:16:58 +01001000 endif
1001endif
1002
Adrian Huntere31f0d02015-04-30 17:37:27 +03001003ifndef NO_AUXTRACE
Jiada Wang7a759cd2017-04-09 20:02:37 -07001004 ifeq ($(SRCARCH),x86)
Mathieu Poirier08d52042016-09-16 09:49:58 -06001005 ifeq ($(feature-get_cpuid), 0)
1006 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
1007 NO_AUXTRACE := 1
1008 endif
1009 endif
1010 ifndef NO_AUXTRACE
Arnaldo Carvalho de Melob0063db2015-09-17 12:54:30 -03001011 $(call detected,CONFIG_AUXTRACE)
1012 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
1013 endif
Adrian Huntere31f0d02015-04-30 17:37:27 +03001014endif
1015
Jiri Olsad4dfdf02016-11-02 14:35:49 +01001016ifndef NO_JVMTI
1017 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
1018 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
1019 else
1020 ifneq (,$(wildcard /usr/sbin/alternatives))
Thomas Richter815c1562019-09-09 13:41:16 +02001021 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')
Jiri Olsad4dfdf02016-11-02 14:35:49 +01001022 endif
1023 endif
1024 ifndef JDIR
1025 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
1026 NO_JVMTI := 1
1027 endif
1028endif
1029
1030ifndef NO_JVMTI
1031 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
1032 $(call feature_check,jvmti)
1033 ifeq ($(feature-jvmti), 1)
1034 $(call detected_var,JDIR)
Jiri Olsadd1d0042018-11-21 16:43:41 +01001035 ifndef NO_JVMTI_CMLR
1036 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
1037 $(call feature_check,jvmti-cmlr)
1038 ifeq ($(feature-jvmti-cmlr), 1)
1039 CFLAGS += -DHAVE_JVMTI_CMLR
1040 endif
1041 endif # NO_JVMTI_CMLR
Jiri Olsad4dfdf02016-11-02 14:35:49 +01001042 else
Arnaldo Carvalho de Meloe14b7332018-04-11 12:08:53 -03001043 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
Jiri Olsad4dfdf02016-11-02 14:35:49 +01001044 NO_JVMTI := 1
1045 endif
1046endif
1047
Wang Nand58ac0b2016-11-26 07:03:33 +00001048USE_CXX = 0
1049USE_CLANGLLVM = 0
1050ifdef LIBCLANGLLVM
1051 $(call feature_check,cxx)
1052 ifneq ($(feature-cxx), 1)
1053 msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
1054 else
1055 $(call feature_check,llvm)
Wang Nana940cad2016-12-06 07:22:30 +00001056 $(call feature_check,llvm-version)
Wang Nand58ac0b2016-11-26 07:03:33 +00001057 ifneq ($(feature-llvm), 1)
Wang Nana940cad2016-12-06 07:22:30 +00001058 msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
Wang Nand58ac0b2016-11-26 07:03:33 +00001059 else
1060 $(call feature_check,clang)
1061 ifneq ($(feature-clang), 1)
Wang Nana940cad2016-12-06 07:22:30 +00001062 msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
Wang Nand58ac0b2016-11-26 07:03:33 +00001063 else
1064 CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
1065 CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
1066 $(call detected,CONFIG_CXX)
1067 $(call detected,CONFIG_CLANGLLVM)
1068 USE_CXX = 1
1069 USE_LLVM = 1
1070 USE_CLANG = 1
Wang Nana940cad2016-12-06 07:22:30 +00001071 ifneq ($(feature-llvm-version),1)
1072 msg := $(warning This version of LLVM is not tested. May cause build errors)
1073 endif
Wang Nand58ac0b2016-11-26 07:03:33 +00001074 endif
1075 endif
1076 endif
1077endif
1078
Stephane Eranian70943492020-05-05 11:29:43 -07001079ifdef LIBPFM4
1080 $(call feature_check,libpfm4)
1081 ifeq ($(feature-libpfm4), 1)
1082 CFLAGS += -DHAVE_LIBPFM
1083 EXTLIBS += -lpfm
1084 ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1
1085 $(call detected,CONFIG_LIBPFM4)
1086 else
1087 msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev);
1088 NO_LIBPFM4 := 1
1089 endif
1090endif
1091
Michael Petlan56d32d42021-04-28 11:20:23 +02001092ifdef LIBTRACEEVENT_DYNAMIC
1093 $(call feature_check,libtraceevent)
1094 ifeq ($(feature-libtraceevent), 1)
1095 EXTLIBS += -ltraceevent
1096 else
1097 dummy := $(error Error: No libtraceevent devel library found, please install libtraceevent-devel);
1098 endif
1099endif
1100
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001101# Among the variables below, these:
1102# perfexecdir
Arnaldo Carvalho de Melo1b16fff2018-05-04 10:37:27 -03001103# perf_include_dir
Arnaldo Carvalho de Melo8f12a2f2018-05-04 11:56:15 -03001104# perf_examples_dir
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001105# template_dir
1106# mandir
1107# infodir
1108# htmldir
1109# ETC_PERFCONFIG (but not sysconfdir)
1110# can be specified as a relative path some/where/else;
1111# this is interpreted as relative to $(prefix) and "perf" at
1112# runtime figures out where they are based on the path to the executable.
1113# This can help installing the suite in a relocatable way.
1114
1115# Make the path relative to DESTDIR, not to prefix
1116ifndef DESTDIR
Jianyu Zhanfc9cabe2014-06-03 00:44:34 +08001117prefix ?= $(HOME)
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001118endif
1119bindir_relative = bin
Pawel Moll0927bee2015-07-28 15:10:13 +01001120bindir = $(abspath $(prefix)/$(bindir_relative))
Adrian Hunter0beb2182021-06-27 16:18:13 +03001121includedir_relative = include
1122includedir = $(abspath $(prefix)/$(includedir_relative))
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001123mandir = share/man
1124infodir = share/info
1125perfexecdir = libexec/perf-core
Thomas Richter83868bf2018-07-31 09:32:54 +02001126perf_include_dir = lib/perf/include
1127perf_examples_dir = lib/perf/examples
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001128sharedir = $(prefix)/share
1129template_dir = share/perf-core/templates
Arnaldo Carvalho de Melo005438a82015-07-20 12:02:09 -03001130STRACE_GROUPS_DIR = share/perf-core/strace/groups
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001131htmldir = share/doc/perf-doc
Namhyung Kim14cbfbe2016-01-07 20:41:53 +09001132tipdir = share/doc/perf-tip
Namhyung Kim84cfac72016-01-09 19:16:28 +09001133srcdir = $(srctree)/tools/perf
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001134ifeq ($(prefix),/usr)
1135sysconfdir = /etc
1136ETC_PERFCONFIG = $(sysconfdir)/perfconfig
1137else
1138sysconfdir = $(prefix)/etc
1139ETC_PERFCONFIG = etc/perfconfig
1140endif
Jiri Olsa6997af722014-08-25 16:55:52 +02001141ifndef lib
Jiada Wang7a759cd2017-04-09 20:02:37 -07001142ifeq ($(SRCARCH)$(IS_64_BIT), x861)
Namhyung Kimfc672972013-09-13 15:27:43 +09001143lib = lib64
1144else
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001145lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +09001146endif
Jiri Olsa6997af722014-08-25 16:55:52 +02001147endif # lib
Namhyung Kimfc672972013-09-13 15:27:43 +09001148libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001149
1150# Shell quote (do not use $(call) to accommodate ancient setups);
1151ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
Arnaldo Carvalho de Melo005438a82015-07-20 12:02:09 -03001152STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001153DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1154bindir_SQ = $(subst ','\'',$(bindir))
Adrian Hunter0beb2182021-06-27 16:18:13 +03001155includedir_SQ = $(subst ','\'',$(includedir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001156mandir_SQ = $(subst ','\'',$(mandir))
1157infodir_SQ = $(subst ','\'',$(infodir))
1158perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
Arnaldo Carvalho de Melo1b16fff2018-05-04 10:37:27 -03001159perf_include_dir_SQ = $(subst ','\'',$(perf_include_dir))
Arnaldo Carvalho de Melo8f12a2f2018-05-04 11:56:15 -03001160perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001161template_dir_SQ = $(subst ','\'',$(template_dir))
1162htmldir_SQ = $(subst ','\'',$(htmldir))
Namhyung Kim14cbfbe2016-01-07 20:41:53 +09001163tipdir_SQ = $(subst ','\'',$(tipdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001164prefix_SQ = $(subst ','\'',$(prefix))
1165sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +09001166libdir_SQ = $(subst ','\'',$(libdir))
Namhyung Kim84cfac72016-01-09 19:16:28 +09001167srcdir_SQ = $(subst ','\'',$(srcdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001168
1169ifneq ($(filter /%,$(firstword $(perfexecdir))),)
1170perfexec_instdir = $(perfexecdir)
Arnaldo Carvalho de Melo1b16fff2018-05-04 10:37:27 -03001171perf_include_instdir = $(perf_include_dir)
Arnaldo Carvalho de Melo8f12a2f2018-05-04 11:56:15 -03001172perf_examples_instdir = $(perf_examples_dir)
Arnaldo Carvalho de Melo005438a82015-07-20 12:02:09 -03001173STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
Namhyung Kim14cbfbe2016-01-07 20:41:53 +09001174tip_instdir = $(tipdir)
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001175else
1176perfexec_instdir = $(prefix)/$(perfexecdir)
Arnaldo Carvalho de Melo1b16fff2018-05-04 10:37:27 -03001177perf_include_instdir = $(prefix)/$(perf_include_dir)
Arnaldo Carvalho de Melo8f12a2f2018-05-04 11:56:15 -03001178perf_examples_instdir = $(prefix)/$(perf_examples_dir)
Arnaldo Carvalho de Melo005438a82015-07-20 12:02:09 -03001179STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
Namhyung Kim14cbfbe2016-01-07 20:41:53 +09001180tip_instdir = $(prefix)/$(tipdir)
Jiri Olsacd1c39f2013-03-18 00:56:01 +01001181endif
1182perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Arnaldo Carvalho de Melo1b16fff2018-05-04 10:37:27 -03001183perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))
Arnaldo Carvalho de Melo8f12a2f2018-05-04 11:56:15 -03001184perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))
Arnaldo Carvalho de Melo005438a82015-07-20 12:02:09 -03001185STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
Namhyung Kim14cbfbe2016-01-07 20:41:53 +09001186tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +01001187
1188# If we install to $(HOME) we keep the traceevent default:
1189# $(HOME)/.traceevent/plugins
1190# Otherwise we install plugins into the global $(libdir).
1191ifdef DESTDIR
1192plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -05001193plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +01001194endif
Jiri Olsa0695e572014-02-19 16:52:54 +01001195
Jiri Olsa4b20d682015-03-02 13:30:30 +01001196print_var = $(eval $(print_var_code)) $(info $(MSG))
1197define print_var_code
Jiri Olsa8d790762014-02-19 16:52:55 +01001198 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
1199endef
1200
Jiri Olsa0695e572014-02-19 16:52:54 +01001201ifeq ($(VF),1)
Jiri Olsa99402e02018-01-09 10:26:46 +01001202 # Display EXTRA features which are detected manualy
1203 # from here with feature_check call and thus cannot
1204 # be partof global state output.
1205 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),))
Jiri Olsa4b20d682015-03-02 13:30:30 +01001206 $(call print_var,prefix)
1207 $(call print_var,bindir)
1208 $(call print_var,libdir)
1209 $(call print_var,sysconfdir)
1210 $(call print_var,LIBUNWIND_DIR)
1211 $(call print_var,LIBDW_DIR)
Jiri Olsad4dfdf02016-11-02 14:35:49 +01001212 $(call print_var,JDIR)
Jiri Olsa76ee2ff2015-12-23 18:58:31 +01001213
1214 ifeq ($(dwarf-post-unwind),1)
1215 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
1216 endif
Jiri Olsa0695e572014-02-19 16:52:54 +01001217 $(info )
1218endif
Jiri Olsaf39e0422014-12-29 15:03:09 +01001219
1220$(call detected_var,bindir_SQ)
1221$(call detected_var,PYTHON_WORD)
1222ifneq ($(OUTPUT),)
1223$(call detected_var,OUTPUT)
1224endif
Jiri Olsa285ab8b2014-12-29 15:13:44 +01001225$(call detected_var,htmldir_SQ)
1226$(call detected_var,infodir_SQ)
1227$(call detected_var,mandir_SQ)
Jiri Olsa9352aab2014-12-29 17:42:46 +01001228$(call detected_var,ETC_PERFCONFIG_SQ)
Arnaldo Carvalho de Melo005438a82015-07-20 12:02:09 -03001229$(call detected_var,STRACE_GROUPS_DIR_SQ)
Jiri Olsa9352aab2014-12-29 17:42:46 +01001230$(call detected_var,prefix_SQ)
1231$(call detected_var,perfexecdir_SQ)
Arnaldo Carvalho de Melo1b16fff2018-05-04 10:37:27 -03001232$(call detected_var,perf_include_dir_SQ)
Arnaldo Carvalho de Melo8f12a2f2018-05-04 11:56:15 -03001233$(call detected_var,perf_examples_dir_SQ)
Namhyung Kim14cbfbe2016-01-07 20:41:53 +09001234$(call detected_var,tipdir_SQ)
Namhyung Kim84cfac72016-01-09 19:16:28 +09001235$(call detected_var,srcdir_SQ)
Jiri Olsa3b939a62014-12-30 00:16:01 +01001236$(call detected_var,LIBDIR)
Jiri Olsa88aeea02014-12-30 00:34:23 +01001237$(call detected_var,GTK_CFLAGS)
Jiri Olsac7355f82014-12-30 13:11:32 +01001238$(call detected_var,PERL_EMBED_CCOPTS)
1239$(call detected_var,PYTHON_EMBED_CCOPTS)
Denys Zagorui67936722021-05-24 04:15:14 -07001240ifneq ($(BISON_FILE_PREFIX_MAP),)
1241$(call detected_var,BISON_FILE_PREFIX_MAP)
1242endif
Jiri Olsafbed59f2021-04-26 15:27:32 -03001243
1244# re-generate FEATURE-DUMP as we may have called feature_check, found out
1245# extra libraries to add to LDFLAGS of some other test and then redo those
1246# tests, see the block about libbfd, disassembler-four-args, for instance.
1247$(shell rm -f $(FEATURE_DUMP_FILENAME))
1248$(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))
Arnaldo Carvalho de Meloc6e3bf42021-04-26 15:47:39 -03001249
1250ifeq ($(feature_display),1)
1251 $(call feature_display_entries)
1252endif