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