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