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