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