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