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