Commit | Line | Data |
---|---|---|
8bd407b9 JO |
1 | uname_M := $(shell uname -m 2>/dev/null || echo not) |
2 | ||
3 | ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ | |
8e1b3f68 JO |
4 | -e s/arm.*/arm/ -e s/sa110/arm/ \ |
5 | -e s/s390x/s390/ -e s/parisc64/parisc/ \ | |
6 | -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ | |
7 | -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) | |
8bd407b9 | 8 | NO_PERF_REGS := 1 |
9c12cf95 | 9 | CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) |
8bd407b9 JO |
10 | |
11 | # Additional ARCH settings for x86 | |
12 | ifeq ($(ARCH),i386) | |
8e1b3f68 JO |
13 | override ARCH := x86 |
14 | NO_PERF_REGS := 0 | |
15 | LIBUNWIND_LIBS = -lunwind -lunwind-x86 | |
8bd407b9 JO |
16 | endif |
17 | ||
18 | ifeq ($(ARCH),x86_64) | |
8e1b3f68 JO |
19 | override ARCH := x86 |
20 | IS_X86_64 := 0 | |
21 | ifeq (, $(findstring m32,$(CFLAGS))) | |
22 | IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1) | |
23 | endif | |
24 | ifeq (${IS_X86_64}, 1) | |
25 | RAW_ARCH := x86_64 | |
89fe808a | 26 | CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT |
8e1b3f68 JO |
27 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S |
28 | endif | |
29 | NO_PERF_REGS := 0 | |
30 | LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 | |
8bd407b9 JO |
31 | endif |
32 | ||
33 | ifeq ($(NO_PERF_REGS),0) | |
89fe808a | 34 | CFLAGS += -DHAVE_PERF_REGS_SUPPORT |
8bd407b9 | 35 | endif |
a32f4936 | 36 | |
7c53746e JO |
37 | ifeq ($(src-perf),) |
38 | src-perf := $(srctree)/tools/perf | |
39 | endif | |
40 | ||
41 | ifeq ($(obj-perf),) | |
107de372 | 42 | obj-perf := $(OUTPUT) |
7c53746e JO |
43 | endif |
44 | ||
45 | ifneq ($(obj-perf),) | |
46 | obj-perf := $(abspath $(obj-perf))/ | |
47 | endif | |
48 | ||
4e319027 RR |
49 | LIB_INCLUDE := $(srctree)/tools/lib/ |
50 | ||
7c53746e JO |
51 | # include ARCH specific config |
52 | -include $(src-perf)/arch/$(ARCH)/Makefile | |
53 | ||
54 | include $(src-perf)/config/feature-tests.mak | |
55 | include $(src-perf)/config/utilities.mak | |
a32f4936 JO |
56 | |
57 | ifeq ($(call get-executable,$(FLEX)),) | |
8e1b3f68 | 58 | dummy := $(error Error: $(FLEX) is missing on this system, please install it) |
a32f4936 JO |
59 | endif |
60 | ||
61 | ifeq ($(call get-executable,$(BISON)),) | |
8e1b3f68 | 62 | dummy := $(error Error: $(BISON) is missing on this system, please install it) |
a32f4936 | 63 | endif |
362493f0 JO |
64 | |
65 | # Treat warnings as errors unless directed not to | |
66 | ifneq ($(WERROR),0) | |
8e1b3f68 | 67 | CFLAGS += -Werror |
362493f0 JO |
68 | endif |
69 | ||
70 | ifeq ("$(origin DEBUG)", "command line") | |
8e1b3f68 | 71 | PERF_DEBUG = $(DEBUG) |
362493f0 JO |
72 | endif |
73 | ifndef PERF_DEBUG | |
8e1b3f68 | 74 | CFLAGS += -O6 |
362493f0 JO |
75 | endif |
76 | ||
77 | ifdef PARSER_DEBUG | |
8e1b3f68 JO |
78 | PARSER_DEBUG_BISON := -t |
79 | PARSER_DEBUG_FLEX := -d | |
80 | CFLAGS += -DPARSER_DEBUG | |
362493f0 JO |
81 | endif |
82 | ||
2fe73746 JO |
83 | CFLAGS += -fno-omit-frame-pointer |
84 | CFLAGS += -ggdb3 | |
85 | CFLAGS += -funwind-tables | |
86 | CFLAGS += -Wall | |
87 | CFLAGS += -Wextra | |
88 | CFLAGS += -std=gnu99 | |
9c12cf95 | 89 | |
6d19912c | 90 | EXTLIBS = -lelf -lpthread -lrt -lm -ldl |
362493f0 | 91 | |
baa9c30e | 92 | feature_check = $(eval $(feature_check_code)) |
b6aa9979 | 93 | define feature_check_code |
baa9c30e IM |
94 | feature-$(1) := $(shell $(MAKE) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) |
95 | endef | |
96 | ||
97 | feature_set = $(eval $(feature_set_code)) | |
98 | define feature_set_code | |
99 | feature-$(1) := 1 | |
b6aa9979 IM |
100 | endef |
101 | ||
102 | # | |
103 | # Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: | |
104 | # | |
baa9c30e IM |
105 | $(info ) |
106 | $(info Auto-detecting system features:) | |
b6aa9979 | 107 | |
3ae069cf IM |
108 | FEATURE_TESTS = \ |
109 | hello \ | |
90ac5422 | 110 | stackprotector-all \ |
430be5ab | 111 | stackprotector \ |
c2510445 | 112 | volatile-register-var \ |
1ea6f99e | 113 | fortify-source \ |
78e9d655 | 114 | bionic \ |
8f7f8005 | 115 | libelf \ |
e12762cf | 116 | glibc \ |
8295d4e2 | 117 | dwarf \ |
8869b17e | 118 | libelf-mmap \ |
b7bcef6f | 119 | libelf-getphdrnum \ |
058f952d | 120 | libunwind \ |
d795a658 | 121 | libaudit \ |
b9498b50 | 122 | libslang \ |
7ef9e055 | 123 | gtk2 \ |
c7a79e96 | 124 | gtk2-infobar \ |
7181a671 | 125 | libperl \ |
9734163b | 126 | libpython \ |
95d061c8 | 127 | libpython-version \ |
3b7646e4 | 128 | libbfd \ |
34ef2162 | 129 | on-exit \ |
4cc9117a | 130 | backtrace \ |
3ae069cf | 131 | libnuma |
b6aa9979 | 132 | |
baa9c30e IM |
133 | # |
134 | # Special fast-path for the 'all features are available' case: | |
135 | # | |
136 | $(call feature_check,all) | |
137 | ||
138 | ifeq ($(feature-all), 1) | |
139 | $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat))) | |
140 | else | |
141 | $(shell $(MAKE) -i -j -C config/feature-checks >/dev/null 2>&1) | |
142 | $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat))) | |
143 | endif | |
144 | ||
145 | feature_print = $(eval $(feature_print_code)) | |
146 | ||
147 | # | |
148 | # Print the result of the feature test: | |
149 | # | |
150 | define feature_print_code | |
151 | ifeq ($(feature-$(1)), 1) | |
152 | MSG := $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1)) | |
153 | else | |
154 | MSG := $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1)) | |
155 | endif | |
156 | $(info $(MSG)) | |
157 | endef | |
158 | ||
159 | $(foreach feat,$(FEATURE_TESTS) DUMMY,$(call feature_print,$(feat))) | |
160 | ||
161 | # newline at the end of the feature printouts: | |
162 | $(info ) | |
b6aa9979 | 163 | |
90ac5422 | 164 | ifeq ($(feature-stackprotector-all), 1) |
8e1b3f68 | 165 | CFLAGS += -fstack-protector-all |
362493f0 JO |
166 | endif |
167 | ||
430be5ab | 168 | ifeq ($(feature-stackprotector), 1) |
8e1b3f68 | 169 | CFLAGS += -Wstack-protector |
362493f0 JO |
170 | endif |
171 | ||
c2510445 | 172 | ifeq ($(feature-volatile-register-var), 1) |
8e1b3f68 | 173 | CFLAGS += -Wvolatile-register-var |
362493f0 JO |
174 | endif |
175 | ||
176 | ifndef PERF_DEBUG | |
1ea6f99e | 177 | ifeq ($(feature-fortify-source), 1) |
8e1b3f68 JO |
178 | CFLAGS += -D_FORTIFY_SOURCE=2 |
179 | endif | |
362493f0 JO |
180 | endif |
181 | ||
2fe73746 JO |
182 | CFLAGS += -I$(src-perf)/util/include |
183 | CFLAGS += -I$(src-perf)/arch/$(ARCH)/include | |
184 | CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi | |
185 | CFLAGS += -I$(srctree)/arch/$(ARCH)/include | |
186 | CFLAGS += -I$(srctree)/include/uapi | |
187 | CFLAGS += -I$(srctree)/include | |
7c53746e JO |
188 | |
189 | # $(obj-perf) for generated common-cmds.h | |
190 | # $(obj-perf)/util for generated bison/flex headers | |
191 | ifneq ($(OUTPUT),) | |
2fe73746 JO |
192 | CFLAGS += -I$(obj-perf)/util |
193 | CFLAGS += -I$(obj-perf) | |
7c53746e JO |
194 | endif |
195 | ||
2fe73746 JO |
196 | CFLAGS += -I$(src-perf)/util |
197 | CFLAGS += -I$(src-perf) | |
4e319027 | 198 | CFLAGS += -I$(LIB_INCLUDE) |
7c53746e | 199 | |
2fe73746 | 200 | CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE |
362493f0 | 201 | |
4e22db46 | 202 | ifndef NO_BIONIC |
78e9d655 IM |
203 | $(feature_check,bionic) |
204 | ifeq ($(feature-bionic), 1) | |
205 | BIONIC := 1 | |
206 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) | |
207 | EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) | |
208 | endif | |
362493f0 | 209 | endif |
cf4cca10 JO |
210 | |
211 | ifdef NO_LIBELF | |
8e1b3f68 JO |
212 | NO_DWARF := 1 |
213 | NO_DEMANGLE := 1 | |
214 | NO_LIBUNWIND := 1 | |
cf4cca10 | 215 | else |
8f7f8005 | 216 | ifeq ($(feature-libelf), 0) |
e12762cf | 217 | ifeq ($(feature-glibc), 1) |
50eed7a7 IM |
218 | LIBC_SUPPORT := 1 |
219 | endif | |
220 | ifeq ($(BIONIC),1) | |
221 | LIBC_SUPPORT := 1 | |
222 | endif | |
223 | ifeq ($(LIBC_SUPPORT),1) | |
224 | msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); | |
225 | ||
226 | NO_LIBELF := 1 | |
227 | NO_DWARF := 1 | |
228 | NO_DEMANGLE := 1 | |
229 | else | |
230 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); | |
231 | endif | |
8e1b3f68 | 232 | else |
50eed7a7 IM |
233 | # for linking with debug library, run like: |
234 | # make DEBUG=1 LIBDW_DIR=/opt/libdw/ | |
235 | ifdef LIBDW_DIR | |
236 | LIBDW_CFLAGS := -I$(LIBDW_DIR)/include | |
237 | LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib | |
238 | endif | |
239 | ||
8295d4e2 | 240 | ifneq ($(feature-dwarf), 1) |
50eed7a7 IM |
241 | 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); |
242 | NO_DWARF := 1 | |
243 | endif # Dwarf support | |
244 | endif # SOURCE_LIBELF | |
cf4cca10 JO |
245 | endif # NO_LIBELF |
246 | ||
247 | ifndef NO_LIBELF | |
fb3d333b IM |
248 | CFLAGS += -DHAVE_LIBELF_SUPPORT |
249 | FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) | |
779724fd | 250 | |
8869b17e | 251 | ifeq ($(feature-libelf-mmap), 1) |
fb3d333b IM |
252 | CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT |
253 | endif | |
779724fd | 254 | |
b7bcef6f | 255 | ifeq ($(feature-libelf-getphdrnum), 1) |
fb3d333b IM |
256 | CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT |
257 | endif | |
258 | ||
259 | # include ARCH specific config | |
260 | -include $(src-perf)/arch/$(ARCH)/Makefile | |
779724fd | 261 | |
fb3d333b IM |
262 | ifndef NO_DWARF |
263 | ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) | |
264 | msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); | |
265 | NO_DWARF := 1 | |
266 | else | |
267 | CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) | |
268 | LDFLAGS += $(LIBDW_LDFLAGS) | |
269 | EXTLIBS += -lelf -ldw | |
270 | endif # PERF_HAVE_DWARF_REGS | |
271 | endif # NO_DWARF | |
cf4cca10 | 272 | endif # NO_LIBELF |
0e433feb | 273 | |
1e9f7aad | 274 | ifndef NO_LIBELF |
fb3d333b | 275 | CFLAGS += -DHAVE_LIBELF_SUPPORT |
8869b17e | 276 | ifeq ($(feature-libelf-mmap), 1) |
fb3d333b | 277 | CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT |
b7bcef6f | 278 | endif |
1e9f7aad JO |
279 | endif # NO_LIBELF |
280 | ||
0e433feb JO |
281 | # There's only x86 (both 32 and 64) support for CFI unwind so far |
282 | ifneq ($(ARCH),x86) | |
8e1b3f68 | 283 | NO_LIBUNWIND := 1 |
0e433feb JO |
284 | endif |
285 | ||
286 | ifndef NO_LIBUNWIND | |
058f952d IM |
287 | # |
288 | # For linking with debug library, run like: | |
289 | # | |
290 | # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ | |
291 | # | |
308e1e70 IM |
292 | ifdef LIBUNWIND_DIR |
293 | LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include | |
294 | LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib | |
295 | endif | |
0e433feb | 296 | |
058f952d | 297 | ifneq ($(feature-libunwind), 1) |
308e1e70 IM |
298 | msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); |
299 | NO_LIBUNWIND := 1 | |
300 | endif | |
301 | endif | |
0e433feb JO |
302 | |
303 | ifndef NO_LIBUNWIND | |
89fe808a | 304 | CFLAGS += -DHAVE_LIBUNWIND_SUPPORT |
8e1b3f68 JO |
305 | EXTLIBS += $(LIBUNWIND_LIBS) |
306 | CFLAGS += $(LIBUNWIND_CFLAGS) | |
307 | LDFLAGS += $(LIBUNWIND_LDFLAGS) | |
058f952d | 308 | endif |
a8279525 JO |
309 | |
310 | ifndef NO_LIBAUDIT | |
d795a658 | 311 | ifneq ($(feature-libaudit), 1) |
8e1b3f68 JO |
312 | msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); |
313 | NO_LIBAUDIT := 1 | |
314 | else | |
89fe808a | 315 | CFLAGS += -DHAVE_LIBAUDIT_SUPPORT |
8e1b3f68 JO |
316 | EXTLIBS += -laudit |
317 | endif | |
a8279525 | 318 | endif |
4a8f888a JO |
319 | |
320 | ifdef NO_NEWT | |
8e1b3f68 | 321 | NO_SLANG=1 |
4a8f888a JO |
322 | endif |
323 | ||
324 | ifndef NO_SLANG | |
b9498b50 | 325 | ifneq ($(feature-libslang), 1) |
8e1b3f68 JO |
326 | msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); |
327 | NO_SLANG := 1 | |
328 | else | |
329 | # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h | |
330 | CFLAGS += -I/usr/include/slang | |
89fe808a | 331 | CFLAGS += -DHAVE_SLANG_SUPPORT |
8e1b3f68 JO |
332 | EXTLIBS += -lslang |
333 | endif | |
4a8f888a | 334 | endif |
58cabf6a JO |
335 | |
336 | ifndef NO_GTK2 | |
8e1b3f68 | 337 | FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) |
7ef9e055 | 338 | ifneq ($(feature-gtk2), 1) |
8e1b3f68 JO |
339 | msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); |
340 | NO_GTK2 := 1 | |
341 | else | |
c7a79e96 | 342 | ifeq ($(feature-gtk2-infobar), 1) |
89fe808a | 343 | CFLAGS += -DHAVE_GTK_INFO_BAR_SUPPORT |
8e1b3f68 | 344 | endif |
89fe808a | 345 | CFLAGS += -DHAVE_GTK2_SUPPORT |
8e1b3f68 JO |
346 | CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) |
347 | EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null) | |
348 | endif | |
58cabf6a | 349 | endif |
3082cb33 JO |
350 | |
351 | grep-libs = $(filter -l%,$(1)) | |
352 | strip-libs = $(filter-out -l%,$(1)) | |
353 | ||
354 | ifdef NO_LIBPERL | |
8e1b3f68 | 355 | CFLAGS += -DNO_LIBPERL |
3082cb33 | 356 | else |
8e1b3f68 JO |
357 | PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) |
358 | PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) | |
359 | PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) | |
360 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` | |
361 | FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) | |
362 | ||
7181a671 | 363 | ifneq ($(feature-libperl), 1) |
8e1b3f68 JO |
364 | CFLAGS += -DNO_LIBPERL |
365 | NO_LIBPERL := 1 | |
366 | else | |
367 | LDFLAGS += $(PERL_EMBED_LDFLAGS) | |
368 | EXTLIBS += $(PERL_EMBED_LIBADD) | |
369 | endif | |
3082cb33 | 370 | endif |
6e533cf1 JO |
371 | |
372 | disable-python = $(eval $(disable-python_code)) | |
373 | define disable-python_code | |
9c12cf95 | 374 | CFLAGS += -DNO_LIBPYTHON |
6e533cf1 JO |
375 | $(if $(1),$(warning No $(1) was found)) |
376 | $(warning Python support will not be built) | |
377 | NO_LIBPYTHON := 1 | |
378 | endef | |
379 | ||
380 | override PYTHON := \ | |
381 | $(call get-executable-or-default,PYTHON,python) | |
382 | ||
383 | ifndef PYTHON | |
384 | $(call disable-python,python interpreter) | |
385 | else | |
386 | ||
387 | PYTHON_WORD := $(call shell-wordify,$(PYTHON)) | |
388 | ||
389 | ifdef NO_LIBPYTHON | |
390 | $(call disable-python) | |
391 | else | |
392 | ||
393 | override PYTHON_CONFIG := \ | |
394 | $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config) | |
395 | ||
396 | ifndef PYTHON_CONFIG | |
397 | $(call disable-python,python-config tool) | |
398 | else | |
399 | ||
400 | PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) | |
401 | ||
402 | PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) | |
403 | PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) | |
404 | PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) | |
405 | PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) | |
406 | FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) | |
407 | ||
9734163b | 408 | ifneq ($(feature-libpython), 1) |
6e533cf1 JO |
409 | $(call disable-python,Python.h (for Python 2.x)) |
410 | else | |
411 | ||
95d061c8 | 412 | ifneq ($(feature-libpython-version), 1) |
6e533cf1 JO |
413 | $(warning Python 3 is not yet supported; please set) |
414 | $(warning PYTHON and/or PYTHON_CONFIG appropriately.) | |
415 | $(warning If you also have Python 2 installed, then) | |
416 | $(warning try something like:) | |
417 | $(warning $(and ,)) | |
418 | $(warning $(and ,) make PYTHON=python2) | |
419 | $(warning $(and ,)) | |
420 | $(warning Otherwise, disable Python support entirely:) | |
421 | $(warning $(and ,)) | |
422 | $(warning $(and ,) make NO_LIBPYTHON=1) | |
423 | $(warning $(and ,)) | |
424 | $(error $(and ,)) | |
425 | else | |
1e9f7aad | 426 | LDFLAGS += $(PYTHON_EMBED_LDFLAGS) |
6e533cf1 | 427 | EXTLIBS += $(PYTHON_EMBED_LIBADD) |
7c53746e | 428 | LANG_BINDINGS += $(obj-perf)python/perf.so |
6e533cf1 JO |
429 | endif |
430 | endif | |
431 | endif | |
432 | endif | |
433 | endif | |
c3cf8368 JO |
434 | |
435 | ifdef NO_DEMANGLE | |
8e1b3f68 | 436 | CFLAGS += -DNO_DEMANGLE |
c3cf8368 | 437 | else |
89fe808a | 438 | ifdef HAVE_CPLUS_DEMANGLE_SUPPORT |
8e1b3f68 | 439 | EXTLIBS += -liberty |
89fe808a | 440 | CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT |
8e1b3f68 JO |
441 | else |
442 | FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd | |
3b7646e4 | 443 | ifeq ($(feature-libbfd), 1) |
8e1b3f68 JO |
444 | EXTLIBS += -lbfd |
445 | else | |
446 | FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty | |
447 | has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty) | |
448 | ifeq ($(has_bfd_iberty),y) | |
449 | EXTLIBS += -lbfd -liberty | |
450 | else | |
451 | FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz | |
452 | has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz) | |
453 | ifeq ($(has_bfd_iberty_z),y) | |
454 | EXTLIBS += -lbfd -liberty -lz | |
455 | else | |
456 | FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -liberty | |
457 | has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle) | |
458 | ifeq ($(has_cplus_demangle),y) | |
459 | EXTLIBS += -liberty | |
89fe808a | 460 | CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT |
8e1b3f68 JO |
461 | else |
462 | msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) | |
463 | CFLAGS += -DNO_DEMANGLE | |
464 | endif | |
465 | endif | |
466 | endif | |
467 | endif | |
468 | endif | |
c3cf8368 | 469 | endif |
a1c7c9e7 | 470 | |
a1c7c9e7 | 471 | ifndef NO_ON_EXIT |
34ef2162 | 472 | ifeq ($(feature-on-exit), 1) |
89fe808a | 473 | CFLAGS += -DHAVE_ON_EXIT_SUPPORT |
8e1b3f68 | 474 | endif |
a1c7c9e7 JO |
475 | endif |
476 | ||
477 | ifndef NO_BACKTRACE | |
4cc9117a | 478 | ifeq ($(feature-backtrace), 1) |
89fe808a | 479 | CFLAGS += -DHAVE_BACKTRACE_SUPPORT |
8e1b3f68 | 480 | endif |
a1c7c9e7 | 481 | endif |
58a0abd7 JO |
482 | |
483 | ifndef NO_LIBNUMA | |
3ae069cf | 484 | ifeq ($(feature-libnuma), 0) |
8e1b3f68 JO |
485 | msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev); |
486 | NO_LIBNUMA := 1 | |
487 | else | |
89fe808a | 488 | CFLAGS += -DHAVE_LIBNUMA_SUPPORT |
8e1b3f68 JO |
489 | EXTLIBS += -lnuma |
490 | endif | |
58a0abd7 | 491 | endif |
cd1c39f2 JO |
492 | |
493 | # Among the variables below, these: | |
494 | # perfexecdir | |
495 | # template_dir | |
496 | # mandir | |
497 | # infodir | |
498 | # htmldir | |
499 | # ETC_PERFCONFIG (but not sysconfdir) | |
500 | # can be specified as a relative path some/where/else; | |
501 | # this is interpreted as relative to $(prefix) and "perf" at | |
502 | # runtime figures out where they are based on the path to the executable. | |
503 | # This can help installing the suite in a relocatable way. | |
504 | ||
505 | # Make the path relative to DESTDIR, not to prefix | |
506 | ifndef DESTDIR | |
507 | prefix = $(HOME) | |
508 | endif | |
509 | bindir_relative = bin | |
510 | bindir = $(prefix)/$(bindir_relative) | |
511 | mandir = share/man | |
512 | infodir = share/info | |
513 | perfexecdir = libexec/perf-core | |
514 | sharedir = $(prefix)/share | |
515 | template_dir = share/perf-core/templates | |
516 | htmldir = share/doc/perf-doc | |
517 | ifeq ($(prefix),/usr) | |
518 | sysconfdir = /etc | |
519 | ETC_PERFCONFIG = $(sysconfdir)/perfconfig | |
520 | else | |
521 | sysconfdir = $(prefix)/etc | |
522 | ETC_PERFCONFIG = etc/perfconfig | |
523 | endif | |
524 | lib = lib | |
525 | ||
526 | # Shell quote (do not use $(call) to accommodate ancient setups); | |
527 | ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) | |
528 | DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) | |
529 | bindir_SQ = $(subst ','\'',$(bindir)) | |
530 | mandir_SQ = $(subst ','\'',$(mandir)) | |
531 | infodir_SQ = $(subst ','\'',$(infodir)) | |
532 | perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) | |
533 | template_dir_SQ = $(subst ','\'',$(template_dir)) | |
534 | htmldir_SQ = $(subst ','\'',$(htmldir)) | |
535 | prefix_SQ = $(subst ','\'',$(prefix)) | |
536 | sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) | |
537 | ||
538 | ifneq ($(filter /%,$(firstword $(perfexecdir))),) | |
539 | perfexec_instdir = $(perfexecdir) | |
540 | else | |
541 | perfexec_instdir = $(prefix)/$(perfexecdir) | |
542 | endif | |
543 | perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) |