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