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