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