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