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