]>
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 | ||
52c0a18b | 14 | $(shell printf "" > $(OUTPUT).config-detected) |
64227379 AK |
15 | detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) |
16 | detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) | |
fcfd6611 | 17 | |
a6cf5f39 JO |
18 | CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) |
19 | ||
20 | include $(src-perf)/config/Makefile.arch | |
21 | ||
f39e042a JO |
22 | $(call detected_var,ARCH) |
23 | ||
a6cf5f39 JO |
24 | NO_PERF_REGS := 1 |
25 | ||
26 | # Additional ARCH settings for x86 | |
27 | ifeq ($(ARCH),x86) | |
f39e042a | 28 | $(call detected,CONFIG_X86) |
c6e5e9fb | 29 | ifeq (${IS_64_BIT}, 1) |
89fe808a | 30 | CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT |
8e1b3f68 | 31 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S |
8a0c4c28 | 32 | LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 |
72965b87 | 33 | $(call detected,CONFIG_X86_64) |
8a0c4c28 | 34 | else |
05b41775 | 35 | LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind |
8e1b3f68 JO |
36 | endif |
37 | NO_PERF_REGS := 0 | |
8bd407b9 | 38 | endif |
8ab596af | 39 | |
7495f374 WD |
40 | ifeq ($(ARCH),arm) |
41 | NO_PERF_REGS := 0 | |
42 | LIBUNWIND_LIBS = -lunwind -lunwind-arm | |
43 | endif | |
8bd407b9 | 44 | |
8ab596af JP |
45 | ifeq ($(ARCH),arm64) |
46 | NO_PERF_REGS := 0 | |
47 | LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 | |
48 | endif | |
49 | ||
3bc3374c JO |
50 | ifeq ($(NO_PERF_REGS),0) |
51 | $(call detected,CONFIG_PERF_REGS) | |
52 | endif | |
53 | ||
90fa9deb | 54 | # So far there's only x86 and arm libdw unwind support merged in perf. |
4dc549e5 JO |
55 | # Disable it on all other architectures in case libdw unwind |
56 | # support is detected in system. Add supported architectures | |
57 | # to the check. | |
90fa9deb | 58 | ifneq ($(ARCH),$(filter $(ARCH),x86 arm)) |
4dc549e5 JO |
59 | NO_LIBDW_DWARF_UNWIND := 1 |
60 | endif | |
61 | ||
1448fef4 JP |
62 | ifeq ($(LIBUNWIND_LIBS),) |
63 | NO_LIBUNWIND := 1 | |
64 | else | |
65 | # | |
66 | # For linking with debug library, run like: | |
67 | # | |
68 | # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ | |
69 | # | |
70 | ifdef LIBUNWIND_DIR | |
71 | LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include | |
72 | LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib | |
73 | endif | |
74 | LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS) | |
75 | ||
76 | # Set per-feature check compilation flags | |
77 | FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) | |
78 | FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) | |
79 | FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) | |
80 | FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) | |
1448fef4 JP |
81 | endif |
82 | ||
8bd407b9 | 83 | ifeq ($(NO_PERF_REGS),0) |
89fe808a | 84 | CFLAGS += -DHAVE_PERF_REGS_SUPPORT |
8bd407b9 | 85 | endif |
a32f4936 | 86 | |
45757895 JO |
87 | ifndef NO_LIBELF |
88 | # for linking with debug library, run like: | |
89 | # make DEBUG=1 LIBDW_DIR=/opt/libdw/ | |
90 | ifdef LIBDW_DIR | |
91 | LIBDW_CFLAGS := -I$(LIBDW_DIR)/include | |
92 | LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib | |
45757895 | 93 | endif |
2c529e4e RR |
94 | FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) |
95 | FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw | |
45757895 JO |
96 | endif |
97 | ||
6ab2b762 | 98 | ifdef LIBBABELTRACE |
53d0a573 JO |
99 | # for linking with debug library, run like: |
100 | # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ | |
101 | ifdef LIBBABELTRACE_DIR | |
102 | LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include | |
103 | LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib | |
104 | endif | |
105 | FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS) | |
106 | FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf | |
107 | endif | |
108 | ||
7c53746e JO |
109 | # include ARCH specific config |
110 | -include $(src-perf)/arch/$(ARCH)/Makefile | |
111 | ||
63ab024a WN |
112 | ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET |
113 | CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET | |
114 | endif | |
115 | ||
7c53746e | 116 | include $(src-perf)/config/utilities.mak |
a32f4936 JO |
117 | |
118 | ifeq ($(call get-executable,$(FLEX)),) | |
8e1b3f68 | 119 | dummy := $(error Error: $(FLEX) is missing on this system, please install it) |
a32f4936 JO |
120 | endif |
121 | ||
122 | ifeq ($(call get-executable,$(BISON)),) | |
8e1b3f68 | 123 | dummy := $(error Error: $(BISON) is missing on this system, please install it) |
a32f4936 | 124 | endif |
362493f0 JO |
125 | |
126 | # Treat warnings as errors unless directed not to | |
127 | ifneq ($(WERROR),0) | |
8e1b3f68 | 128 | CFLAGS += -Werror |
362493f0 JO |
129 | endif |
130 | ||
74af377b AH |
131 | ifndef DEBUG |
132 | DEBUG := 0 | |
133 | endif | |
134 | ||
fcf92585 | 135 | ifeq ($(DEBUG),0) |
8e1b3f68 | 136 | CFLAGS += -O6 |
e8b7ea43 ML |
137 | else |
138 | CFLAGS += $(call cc-option,-Og,-O0) | |
362493f0 JO |
139 | endif |
140 | ||
141 | ifdef PARSER_DEBUG | |
8e1b3f68 JO |
142 | PARSER_DEBUG_BISON := -t |
143 | PARSER_DEBUG_FLEX := -d | |
144 | CFLAGS += -DPARSER_DEBUG | |
9352aaba JO |
145 | $(call detected_var,PARSER_DEBUG_BISON) |
146 | $(call detected_var,PARSER_DEBUG_FLEX) | |
362493f0 JO |
147 | endif |
148 | ||
56c7d79e | 149 | ifndef NO_LIBPYTHON |
d6a947fb TI |
150 | # Try different combinations to accommodate systems that only have |
151 | # python[2][-config] in weird combinations but always preferring | |
152 | # python2 and python2-config as per pep-0394. If we catch a | |
153 | # python[-config] in version 3, the version check will kill it. | |
154 | PYTHON2 := $(if $(call get-executable,python2),python2,python) | |
155 | override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2)) | |
156 | PYTHON2_CONFIG := \ | |
157 | $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config) | |
56c7d79e | 158 | override PYTHON_CONFIG := \ |
d6a947fb | 159 | $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG)) |
56c7d79e NK |
160 | |
161 | PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) | |
162 | ||
163 | PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) | |
164 | PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) | |
165 | ||
166 | FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS) | |
167 | FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) | |
168 | FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS) | |
169 | FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS) | |
170 | endif | |
171 | ||
2fe73746 JO |
172 | CFLAGS += -fno-omit-frame-pointer |
173 | CFLAGS += -ggdb3 | |
174 | CFLAGS += -funwind-tables | |
175 | CFLAGS += -Wall | |
176 | CFLAGS += -Wextra | |
177 | CFLAGS += -std=gnu99 | |
9c12cf95 | 178 | |
6392b4eb MK |
179 | # Enforce a non-executable stack, as we may regress (again) in the future by |
180 | # adding assembler files missing the .GNU-stack linker note. | |
181 | LDFLAGS += -Wl,-z,noexecstack | |
182 | ||
5e2d4d0e | 183 | EXTLIBS = -lpthread -lrt -lm -ldl |
362493f0 | 184 | |
e6c76d62 | 185 | include $(srctree)/tools/build/Makefile.feature |
baa9c30e | 186 | |
90ac5422 | 187 | ifeq ($(feature-stackprotector-all), 1) |
8e1b3f68 | 188 | CFLAGS += -fstack-protector-all |
362493f0 JO |
189 | endif |
190 | ||
fcf92585 | 191 | ifeq ($(DEBUG),0) |
1ea6f99e | 192 | ifeq ($(feature-fortify-source), 1) |
8e1b3f68 JO |
193 | CFLAGS += -D_FORTIFY_SOURCE=2 |
194 | endif | |
362493f0 JO |
195 | endif |
196 | ||
2fe73746 JO |
197 | CFLAGS += -I$(src-perf)/util/include |
198 | CFLAGS += -I$(src-perf)/arch/$(ARCH)/include | |
8a625c1f | 199 | CFLAGS += -I$(srctree)/tools/include/ |
2fe73746 JO |
200 | CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi |
201 | CFLAGS += -I$(srctree)/arch/$(ARCH)/include | |
202 | CFLAGS += -I$(srctree)/include/uapi | |
203 | CFLAGS += -I$(srctree)/include | |
7c53746e JO |
204 | |
205 | # $(obj-perf) for generated common-cmds.h | |
206 | # $(obj-perf)/util for generated bison/flex headers | |
207 | ifneq ($(OUTPUT),) | |
2fe73746 JO |
208 | CFLAGS += -I$(obj-perf)/util |
209 | CFLAGS += -I$(obj-perf) | |
7c53746e JO |
210 | endif |
211 | ||
2fe73746 JO |
212 | CFLAGS += -I$(src-perf)/util |
213 | CFLAGS += -I$(src-perf) | |
9444e874 | 214 | CFLAGS += -I$(srctree)/tools/lib/ |
7c53746e | 215 | |
2fe73746 | 216 | CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE |
362493f0 | 217 | |
f6d31369 AH |
218 | ifeq ($(feature-sync-compare-and-swap), 1) |
219 | CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT | |
220 | endif | |
221 | ||
459a3df7 VG |
222 | ifeq ($(feature-pthread-attr-setaffinity-np), 1) |
223 | CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP | |
224 | endif | |
225 | ||
4e22db46 | 226 | ifndef NO_BIONIC |
5febff00 | 227 | $(call feature_check,bionic) |
78e9d655 IM |
228 | ifeq ($(feature-bionic), 1) |
229 | BIONIC := 1 | |
230 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) | |
231 | EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) | |
232 | endif | |
362493f0 | 233 | endif |
cf4cca10 JO |
234 | |
235 | ifdef NO_LIBELF | |
8e1b3f68 JO |
236 | NO_DWARF := 1 |
237 | NO_DEMANGLE := 1 | |
238 | NO_LIBUNWIND := 1 | |
5ea84154 | 239 | NO_LIBDW_DWARF_UNWIND := 1 |
cf4cca10 | 240 | else |
8f7f8005 | 241 | ifeq ($(feature-libelf), 0) |
e12762cf | 242 | ifeq ($(feature-glibc), 1) |
50eed7a7 IM |
243 | LIBC_SUPPORT := 1 |
244 | endif | |
245 | ifeq ($(BIONIC),1) | |
246 | LIBC_SUPPORT := 1 | |
247 | endif | |
248 | ifeq ($(LIBC_SUPPORT),1) | |
249 | msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); | |
250 | ||
251 | NO_LIBELF := 1 | |
252 | NO_DWARF := 1 | |
253 | NO_DEMANGLE := 1 | |
94589557 ACM |
254 | NO_LIBUNWIND := 1 |
255 | NO_LIBDW_DWARF_UNWIND := 1 | |
50eed7a7 | 256 | else |
f9ca2d89 ACM |
257 | ifneq ($(filter s% -static%,$(LDFLAGS),),) |
258 | msg := $(error No static glibc found, please install glibc-static); | |
259 | else | |
260 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]); | |
261 | endif | |
50eed7a7 | 262 | endif |
8e1b3f68 | 263 | else |
0a4f2b6a JO |
264 | ifndef NO_LIBDW_DWARF_UNWIND |
265 | ifneq ($(feature-libdw-dwarf-unwind),1) | |
266 | NO_LIBDW_DWARF_UNWIND := 1 | |
267 | msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR); | |
268 | endif | |
269 | endif | |
8295d4e2 | 270 | ifneq ($(feature-dwarf), 1) |
50eed7a7 IM |
271 | 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); |
272 | NO_DWARF := 1 | |
273 | endif # Dwarf support | |
0648f839 | 274 | endif # libelf support |
cf4cca10 JO |
275 | endif # NO_LIBELF |
276 | ||
76d40849 NR |
277 | ifdef NO_DWARF |
278 | NO_LIBDW_DWARF_UNWIND := 1 | |
279 | endif | |
280 | ||
cf4cca10 | 281 | ifndef NO_LIBELF |
fb3d333b | 282 | CFLAGS += -DHAVE_LIBELF_SUPPORT |
5e2d4d0e | 283 | EXTLIBS += -lelf |
709e6791 | 284 | $(call detected,CONFIG_LIBELF) |
779724fd | 285 | |
8869b17e | 286 | ifeq ($(feature-libelf-mmap), 1) |
fb3d333b IM |
287 | CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT |
288 | endif | |
779724fd | 289 | |
b7bcef6f | 290 | ifeq ($(feature-libelf-getphdrnum), 1) |
fb3d333b IM |
291 | CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT |
292 | endif | |
293 | ||
294 | # include ARCH specific config | |
295 | -include $(src-perf)/arch/$(ARCH)/Makefile | |
779724fd | 296 | |
fb3d333b IM |
297 | ifndef NO_DWARF |
298 | ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) | |
299 | msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); | |
300 | NO_DWARF := 1 | |
301 | else | |
302 | CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) | |
303 | LDFLAGS += $(LIBDW_LDFLAGS) | |
7aec51cb AK |
304 | DWARFLIBS := -ldw |
305 | ifeq ($(findstring -static,${LDFLAGS}),-static) | |
306 | DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 | |
307 | endif | |
308 | EXTLIBS += ${DWARFLIBS} | |
8379fce4 | 309 | $(call detected,CONFIG_DWARF) |
fb3d333b IM |
310 | endif # PERF_HAVE_DWARF_REGS |
311 | endif # NO_DWARF | |
cf4cca10 | 312 | endif # NO_LIBELF |
0e433feb | 313 | |
65ccb4fa AB |
314 | ifeq ($(ARCH),powerpc) |
315 | ifndef NO_DWARF | |
316 | CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX | |
317 | endif | |
318 | endif | |
319 | ||
0e433feb | 320 | ifndef NO_LIBUNWIND |
058f952d | 321 | ifneq ($(feature-libunwind), 1) |
0a4f2b6a | 322 | msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR); |
308e1e70 | 323 | NO_LIBUNWIND := 1 |
0a4f2b6a JO |
324 | endif |
325 | endif | |
326 | ||
327 | dwarf-post-unwind := 1 | |
328 | dwarf-post-unwind-text := BUG | |
329 | ||
330 | # setup DWARF post unwinder | |
331 | ifdef NO_LIBUNWIND | |
332 | ifdef NO_LIBDW_DWARF_UNWIND | |
333 | msg := $(warning Disabling post unwind, no support found.); | |
334 | dwarf-post-unwind := 0 | |
f47671e2 | 335 | else |
0a4f2b6a | 336 | dwarf-post-unwind-text := libdw |
b2e45c32 | 337 | $(call detected,CONFIG_LIBDW_DWARF_UNWIND) |
0a4f2b6a JO |
338 | endif |
339 | else | |
340 | dwarf-post-unwind-text := libunwind | |
b2e45c32 | 341 | $(call detected,CONFIG_LIBUNWIND) |
0a4f2b6a JO |
342 | # Enable libunwind support by default. |
343 | ifndef NO_LIBDW_DWARF_UNWIND | |
344 | NO_LIBDW_DWARF_UNWIND := 1 | |
345 | endif | |
346 | endif | |
347 | ||
348 | ifeq ($(dwarf-post-unwind),1) | |
349 | CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT | |
f39e042a | 350 | $(call detected,CONFIG_DWARF_UNWIND) |
0a4f2b6a JO |
351 | else |
352 | NO_DWARF_UNWIND := 1 | |
353 | endif | |
354 | ||
355 | ifndef NO_LIBUNWIND | |
8ab596af | 356 | ifeq ($(ARCH),$(filter $(ARCH),arm arm64)) |
0a4f2b6a JO |
357 | $(call feature_check,libunwind-debug-frame) |
358 | ifneq ($(feature-libunwind-debug-frame), 1) | |
359 | msg := $(warning No debug_frame support found in libunwind); | |
f47671e2 LT |
360 | CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME |
361 | endif | |
0a4f2b6a JO |
362 | else |
363 | # non-ARM has no dwarf_find_debug_frame() function: | |
364 | CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME | |
365 | endif | |
366 | CFLAGS += -DHAVE_LIBUNWIND_SUPPORT | |
367 | EXTLIBS += $(LIBUNWIND_LIBS) | |
368 | CFLAGS += $(LIBUNWIND_CFLAGS) | |
369 | LDFLAGS += $(LIBUNWIND_LDFLAGS) | |
058f952d | 370 | endif |
a8279525 JO |
371 | |
372 | ifndef NO_LIBAUDIT | |
d795a658 | 373 | ifneq ($(feature-libaudit), 1) |
8e1b3f68 JO |
374 | msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); |
375 | NO_LIBAUDIT := 1 | |
376 | else | |
89fe808a | 377 | CFLAGS += -DHAVE_LIBAUDIT_SUPPORT |
8e1b3f68 | 378 | EXTLIBS += -laudit |
285ab8bf | 379 | $(call detected,CONFIG_AUDIT) |
8e1b3f68 | 380 | endif |
a8279525 | 381 | endif |
4a8f888a JO |
382 | |
383 | ifdef NO_NEWT | |
8e1b3f68 | 384 | NO_SLANG=1 |
4a8f888a JO |
385 | endif |
386 | ||
387 | ifndef NO_SLANG | |
b9498b50 | 388 | ifneq ($(feature-libslang), 1) |
8e1b3f68 JO |
389 | msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); |
390 | NO_SLANG := 1 | |
391 | else | |
392 | # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h | |
393 | CFLAGS += -I/usr/include/slang | |
89fe808a | 394 | CFLAGS += -DHAVE_SLANG_SUPPORT |
8e1b3f68 | 395 | EXTLIBS += -lslang |
cf15c74c | 396 | $(call detected,CONFIG_SLANG) |
8e1b3f68 | 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 | |
a954e684 | 431 | msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev); |
8e1b3f68 JO |
432 | else |
433 | LDFLAGS += $(PERL_EMBED_LDFLAGS) | |
434 | EXTLIBS += $(PERL_EMBED_LIBADD) | |
c7355f84 | 435 | $(call detected,CONFIG_LIBPERL) |
8e1b3f68 | 436 | endif |
3082cb33 | 437 | endif |
6e533cf1 | 438 | |
87419c9a DA |
439 | ifeq ($(feature-timerfd), 1) |
440 | CFLAGS += -DHAVE_TIMERFD_SUPPORT | |
441 | else | |
442 | msg := $(warning No timerfd support. Disables 'perf kvm stat live'); | |
443 | endif | |
444 | ||
6e533cf1 JO |
445 | disable-python = $(eval $(disable-python_code)) |
446 | define disable-python_code | |
9c12cf95 | 447 | CFLAGS += -DNO_LIBPYTHON |
6c5aa237 | 448 | $(warning $1) |
6e533cf1 JO |
449 | NO_LIBPYTHON := 1 |
450 | endef | |
451 | ||
56c7d79e | 452 | ifdef NO_LIBPYTHON |
6c5aa237 | 453 | $(call disable-python,Python support disabled by user) |
6e533cf1 JO |
454 | else |
455 | ||
56c7d79e | 456 | ifndef PYTHON |
6c5aa237 | 457 | $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev) |
6e533cf1 | 458 | else |
56c7d79e | 459 | PYTHON_WORD := $(call shell-wordify,$(PYTHON)) |
6e533cf1 JO |
460 | |
461 | ifndef PYTHON_CONFIG | |
6c5aa237 | 462 | $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev) |
6e533cf1 JO |
463 | else |
464 | ||
465 | PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) | |
466 | ||
467 | PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) | |
468 | PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) | |
469 | PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) | |
470 | PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) | |
471 | FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) | |
472 | ||
9734163b | 473 | ifneq ($(feature-libpython), 1) |
6c5aa237 | 474 | $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev) |
6e533cf1 JO |
475 | else |
476 | ||
95d061c8 | 477 | ifneq ($(feature-libpython-version), 1) |
6e533cf1 JO |
478 | $(warning Python 3 is not yet supported; please set) |
479 | $(warning PYTHON and/or PYTHON_CONFIG appropriately.) | |
480 | $(warning If you also have Python 2 installed, then) | |
481 | $(warning try something like:) | |
482 | $(warning $(and ,)) | |
483 | $(warning $(and ,) make PYTHON=python2) | |
484 | $(warning $(and ,)) | |
485 | $(warning Otherwise, disable Python support entirely:) | |
486 | $(warning $(and ,)) | |
487 | $(warning $(and ,) make NO_LIBPYTHON=1) | |
488 | $(warning $(and ,)) | |
489 | $(error $(and ,)) | |
490 | else | |
1e9f7aad | 491 | LDFLAGS += $(PYTHON_EMBED_LDFLAGS) |
6e533cf1 | 492 | EXTLIBS += $(PYTHON_EMBED_LIBADD) |
7c53746e | 493 | LANG_BINDINGS += $(obj-perf)python/perf.so |
c7355f84 | 494 | $(call detected,CONFIG_LIBPYTHON) |
6e533cf1 JO |
495 | endif |
496 | endif | |
497 | endif | |
498 | endif | |
499 | endif | |
c3cf8368 | 500 | |
3e6a147d | 501 | ifeq ($(feature-libbfd), 1) |
2cf90407 JO |
502 | EXTLIBS += -lbfd |
503 | ||
504 | # call all detections now so we get correct | |
505 | # status in VF output | |
506 | $(call feature_check,liberty) | |
507 | $(call feature_check,liberty-z) | |
508 | $(call feature_check,cplus-demangle) | |
509 | ||
510 | ifeq ($(feature-liberty), 1) | |
511 | EXTLIBS += -liberty | |
512 | else | |
513 | ifeq ($(feature-liberty-z), 1) | |
514 | EXTLIBS += -liberty -lz | |
515 | endif | |
516 | endif | |
3e6a147d JO |
517 | endif |
518 | ||
c3cf8368 | 519 | ifdef NO_DEMANGLE |
8e1b3f68 | 520 | CFLAGS += -DNO_DEMANGLE |
c3cf8368 | 521 | else |
89fe808a | 522 | ifdef HAVE_CPLUS_DEMANGLE_SUPPORT |
8e1b3f68 | 523 | EXTLIBS += -liberty |
89fe808a | 524 | CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT |
8e1b3f68 | 525 | else |
3e6a147d | 526 | ifneq ($(feature-libbfd), 1) |
2cf90407 JO |
527 | ifneq ($(feature-liberty), 1) |
528 | ifneq ($(feature-liberty-z), 1) | |
529 | # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT | |
530 | # or any of 'bfd iberty z' trinity | |
1c47661a | 531 | ifeq ($(feature-cplus-demangle), 1) |
8e1b3f68 | 532 | EXTLIBS += -liberty |
89fe808a | 533 | CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT |
8e1b3f68 | 534 | else |
0189d7c4 | 535 | msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling) |
8e1b3f68 JO |
536 | CFLAGS += -DNO_DEMANGLE |
537 | endif | |
538 | endif | |
539 | endif | |
540 | endif | |
541 | endif | |
c3cf8368 | 542 | endif |
a1c7c9e7 | 543 | |
3e6a147d JO |
544 | ifneq ($(filter -lbfd,$(EXTLIBS)),) |
545 | CFLAGS += -DHAVE_LIBBFD_SUPPORT | |
546 | endif | |
547 | ||
e92ce12e NK |
548 | ifndef NO_ZLIB |
549 | ifeq ($(feature-zlib), 1) | |
550 | CFLAGS += -DHAVE_ZLIB_SUPPORT | |
551 | EXTLIBS += -lz | |
1571b695 | 552 | $(call detected,CONFIG_ZLIB) |
e92ce12e NK |
553 | else |
554 | NO_ZLIB := 1 | |
555 | endif | |
556 | endif | |
557 | ||
80a32e5b JO |
558 | ifndef NO_LZMA |
559 | ifeq ($(feature-lzma), 1) | |
560 | CFLAGS += -DHAVE_LZMA_SUPPORT | |
561 | EXTLIBS += -llzma | |
562 | $(call detected,CONFIG_LZMA) | |
563 | else | |
564 | msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev); | |
565 | NO_LZMA := 1 | |
566 | endif | |
567 | endif | |
568 | ||
a1c7c9e7 | 569 | ifndef NO_BACKTRACE |
4cc9117a | 570 | ifeq ($(feature-backtrace), 1) |
89fe808a | 571 | CFLAGS += -DHAVE_BACKTRACE_SUPPORT |
8e1b3f68 | 572 | endif |
a1c7c9e7 | 573 | endif |
58a0abd7 JO |
574 | |
575 | ifndef NO_LIBNUMA | |
3ae069cf | 576 | ifeq ($(feature-libnuma), 0) |
6305edfc | 577 | msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev); |
8e1b3f68 JO |
578 | NO_LIBNUMA := 1 |
579 | else | |
f8ac8606 ACM |
580 | ifeq ($(feature-numa_num_possible_cpus), 0) |
581 | msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8); | |
582 | NO_LIBNUMA := 1 | |
583 | else | |
584 | CFLAGS += -DHAVE_LIBNUMA_SUPPORT | |
585 | EXTLIBS += -lnuma | |
586 | $(call detected,CONFIG_NUMA) | |
587 | endif | |
8e1b3f68 | 588 | endif |
58a0abd7 | 589 | endif |
cd1c39f2 | 590 | |
da50ad69 AY |
591 | ifdef HAVE_KVM_STAT_SUPPORT |
592 | CFLAGS += -DHAVE_KVM_STAT_SUPPORT | |
593 | endif | |
594 | ||
e477f3f0 AH |
595 | ifeq (${IS_64_BIT}, 1) |
596 | ifndef NO_PERF_READ_VDSO32 | |
597 | $(call feature_check,compile-32) | |
46b1fa85 AH |
598 | ifeq ($(feature-compile-32), 1) |
599 | CFLAGS += -DHAVE_PERF_READ_VDSO32 | |
600 | else | |
e477f3f0 AH |
601 | NO_PERF_READ_VDSO32 := 1 |
602 | endif | |
603 | endif | |
76aea773 | 604 | ifneq ($(ARCH), x86) |
e477f3f0 AH |
605 | NO_PERF_READ_VDSOX32 := 1 |
606 | endif | |
607 | ifndef NO_PERF_READ_VDSOX32 | |
608 | $(call feature_check,compile-x32) | |
46b1fa85 AH |
609 | ifeq ($(feature-compile-x32), 1) |
610 | CFLAGS += -DHAVE_PERF_READ_VDSOX32 | |
611 | else | |
e477f3f0 AH |
612 | NO_PERF_READ_VDSOX32 := 1 |
613 | endif | |
614 | endif | |
615 | else | |
616 | NO_PERF_READ_VDSO32 := 1 | |
617 | NO_PERF_READ_VDSOX32 := 1 | |
618 | endif | |
619 | ||
6ab2b762 | 620 | ifdef LIBBABELTRACE |
97e7a515 JO |
621 | $(call feature_check,libbabeltrace) |
622 | ifeq ($(feature-libbabeltrace), 1) | |
53d0a573 JO |
623 | CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS) |
624 | LDFLAGS += $(LIBBABELTRACE_LDFLAGS) | |
625 | EXTLIBS += -lbabeltrace-ctf | |
edbe9817 | 626 | $(call detected,CONFIG_LIBBABELTRACE) |
97e7a515 JO |
627 | else |
628 | msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev); | |
53d0a573 JO |
629 | endif |
630 | endif | |
631 | ||
e31f0d01 | 632 | ifndef NO_AUXTRACE |
b0063dbf ACM |
633 | ifeq ($(feature-get_cpuid), 0) |
634 | msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); | |
635 | NO_AUXTRACE := 1 | |
636 | else | |
637 | $(call detected,CONFIG_AUXTRACE) | |
638 | CFLAGS += -DHAVE_AUXTRACE_SUPPORT | |
639 | endif | |
e31f0d01 AH |
640 | endif |
641 | ||
cd1c39f2 JO |
642 | # Among the variables below, these: |
643 | # perfexecdir | |
644 | # template_dir | |
645 | # mandir | |
646 | # infodir | |
647 | # htmldir | |
648 | # ETC_PERFCONFIG (but not sysconfdir) | |
649 | # can be specified as a relative path some/where/else; | |
650 | # this is interpreted as relative to $(prefix) and "perf" at | |
651 | # runtime figures out where they are based on the path to the executable. | |
652 | # This can help installing the suite in a relocatable way. | |
653 | ||
654 | # Make the path relative to DESTDIR, not to prefix | |
655 | ifndef DESTDIR | |
fc9cabea | 656 | prefix ?= $(HOME) |
cd1c39f2 JO |
657 | endif |
658 | bindir_relative = bin | |
0927beec | 659 | bindir = $(abspath $(prefix)/$(bindir_relative)) |
cd1c39f2 JO |
660 | mandir = share/man |
661 | infodir = share/info | |
662 | perfexecdir = libexec/perf-core | |
663 | sharedir = $(prefix)/share | |
664 | template_dir = share/perf-core/templates | |
005438a8 | 665 | STRACE_GROUPS_DIR = share/perf-core/strace/groups |
cd1c39f2 JO |
666 | htmldir = share/doc/perf-doc |
667 | ifeq ($(prefix),/usr) | |
668 | sysconfdir = /etc | |
669 | ETC_PERFCONFIG = $(sysconfdir)/perfconfig | |
670 | else | |
671 | sysconfdir = $(prefix)/etc | |
672 | ETC_PERFCONFIG = etc/perfconfig | |
673 | endif | |
6997af72 | 674 | ifndef lib |
76aea773 | 675 | ifeq ($(ARCH)$(IS_64_BIT), x861) |
fc67297b NK |
676 | lib = lib64 |
677 | else | |
cd1c39f2 | 678 | lib = lib |
fc67297b | 679 | endif |
6997af72 | 680 | endif # lib |
fc67297b | 681 | libdir = $(prefix)/$(lib) |
cd1c39f2 JO |
682 | |
683 | # Shell quote (do not use $(call) to accommodate ancient setups); | |
684 | ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) | |
005438a8 | 685 | STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR)) |
cd1c39f2 JO |
686 | DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) |
687 | bindir_SQ = $(subst ','\'',$(bindir)) | |
688 | mandir_SQ = $(subst ','\'',$(mandir)) | |
689 | infodir_SQ = $(subst ','\'',$(infodir)) | |
690 | perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) | |
691 | template_dir_SQ = $(subst ','\'',$(template_dir)) | |
692 | htmldir_SQ = $(subst ','\'',$(htmldir)) | |
693 | prefix_SQ = $(subst ','\'',$(prefix)) | |
694 | sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) | |
fc67297b | 695 | libdir_SQ = $(subst ','\'',$(libdir)) |
cd1c39f2 JO |
696 | |
697 | ifneq ($(filter /%,$(firstword $(perfexecdir))),) | |
698 | perfexec_instdir = $(perfexecdir) | |
005438a8 | 699 | STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR) |
cd1c39f2 JO |
700 | else |
701 | perfexec_instdir = $(prefix)/$(perfexecdir) | |
005438a8 | 702 | STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR) |
cd1c39f2 JO |
703 | endif |
704 | perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) | |
005438a8 | 705 | STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR)) |
3d7c0144 JO |
706 | |
707 | # If we install to $(HOME) we keep the traceevent default: | |
708 | # $(HOME)/.traceevent/plugins | |
709 | # Otherwise we install plugins into the global $(libdir). | |
710 | ifdef DESTDIR | |
711 | plugindir=$(libdir)/traceevent/plugins | |
b935a58d | 712 | plugindir_SQ= $(subst ','\'',$(plugindir)) |
3d7c0144 | 713 | endif |
0695e57b | 714 | |
4b20d684 JO |
715 | print_var = $(eval $(print_var_code)) $(info $(MSG)) |
716 | define print_var_code | |
8d79076a JO |
717 | MSG = $(shell printf '...%30s: %s' $(1) $($(1))) |
718 | endef | |
719 | ||
0695e57b | 720 | ifeq ($(VF),1) |
4b20d684 JO |
721 | $(call print_var,prefix) |
722 | $(call print_var,bindir) | |
723 | $(call print_var,libdir) | |
724 | $(call print_var,sysconfdir) | |
725 | $(call print_var,LIBUNWIND_DIR) | |
726 | $(call print_var,LIBDW_DIR) | |
0695e57b JO |
727 | $(info ) |
728 | endif | |
f39e042a JO |
729 | |
730 | $(call detected_var,bindir_SQ) | |
731 | $(call detected_var,PYTHON_WORD) | |
732 | ifneq ($(OUTPUT),) | |
733 | $(call detected_var,OUTPUT) | |
734 | endif | |
285ab8bf JO |
735 | $(call detected_var,htmldir_SQ) |
736 | $(call detected_var,infodir_SQ) | |
737 | $(call detected_var,mandir_SQ) | |
9352aaba | 738 | $(call detected_var,ETC_PERFCONFIG_SQ) |
005438a8 | 739 | $(call detected_var,STRACE_GROUPS_DIR_SQ) |
9352aaba JO |
740 | $(call detected_var,prefix_SQ) |
741 | $(call detected_var,perfexecdir_SQ) | |
3b939a63 | 742 | $(call detected_var,LIBDIR) |
88aeea06 | 743 | $(call detected_var,GTK_CFLAGS) |
c7355f84 JO |
744 | $(call detected_var,PERL_EMBED_CCOPTS) |
745 | $(call detected_var,PYTHON_EMBED_CCOPTS) |