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