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