aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/config/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/config/Makefile')
-rw-r--r--tools/perf/config/Makefile358
1 files changed, 225 insertions, 133 deletions
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 5f6f9b3271bb..c516d6ba6716 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -23,7 +23,7 @@ ifeq ($(ARCH),x86_64)
23 endif 23 endif
24 ifeq (${IS_X86_64}, 1) 24 ifeq (${IS_X86_64}, 1)
25 RAW_ARCH := x86_64 25 RAW_ARCH := x86_64
26 CFLAGS += -DARCH_X86_64 26 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
27 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 27 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
28 endif 28 endif
29 NO_PERF_REGS := 0 29 NO_PERF_REGS := 0
@@ -31,7 +31,7 @@ ifeq ($(ARCH),x86_64)
31endif 31endif
32 32
33ifeq ($(NO_PERF_REGS),0) 33ifeq ($(NO_PERF_REGS),0)
34 CFLAGS += -DHAVE_PERF_REGS 34 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
35endif 35endif
36 36
37ifeq ($(src-perf),) 37ifeq ($(src-perf),)
@@ -51,7 +51,6 @@ LIB_INCLUDE := $(srctree)/tools/lib/
51# include ARCH specific config 51# include ARCH specific config
52-include $(src-perf)/arch/$(ARCH)/Makefile 52-include $(src-perf)/arch/$(ARCH)/Makefile
53 53
54include $(src-perf)/config/feature-tests.mak
55include $(src-perf)/config/utilities.mak 54include $(src-perf)/config/utilities.mak
56 55
57ifeq ($(call get-executable,$(FLEX)),) 56ifeq ($(call get-executable,$(FLEX)),)
@@ -67,10 +66,7 @@ ifneq ($(WERROR),0)
67 CFLAGS += -Werror 66 CFLAGS += -Werror
68endif 67endif
69 68
70ifeq ("$(origin DEBUG)", "command line") 69ifeq ($(DEBUG),0)
71 PERF_DEBUG = $(DEBUG)
72endif
73ifndef PERF_DEBUG
74 CFLAGS += -O6 70 CFLAGS += -O6
75endif 71endif
76 72
@@ -89,20 +85,125 @@ CFLAGS += -std=gnu99
89 85
90EXTLIBS = -lelf -lpthread -lrt -lm -ldl 86EXTLIBS = -lelf -lpthread -lrt -lm -ldl
91 87
92ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) 88ifneq ($(OUTPUT),)
93 CFLAGS += -fstack-protector-all 89 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
90 $(shell mkdir -p $(OUTPUT_FEATURES))
94endif 91endif
95 92
96ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) 93feature_check = $(eval $(feature_check_code))
97 CFLAGS += -Wstack-protector 94define feature_check_code
95 feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
96endef
97
98feature_set = $(eval $(feature_set_code))
99define feature_set_code
100 feature-$(1) := 1
101endef
102
103#
104# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
105#
106
107#
108# Note that this is not a complete list of all feature tests, just
109# those that are typically built on a fully configured system.
110#
111# [ Feature tests not mentioned here have to be built explicitly in
112# the rule that uses them - an example for that is the 'bionic'
113# feature check. ]
114#
115CORE_FEATURE_TESTS = \
116 backtrace \
117 dwarf \
118 fortify-source \
119 glibc \
120 gtk2 \
121 gtk2-infobar \
122 libaudit \
123 libbfd \
124 libelf \
125 libelf-getphdrnum \
126 libelf-mmap \
127 libnuma \
128 libperl \
129 libpython \
130 libpython-version \
131 libslang \
132 libunwind \
133 on-exit \
134 stackprotector \
135 stackprotector-all
136
137#
138# So here we detect whether test-all was rebuilt, to be able
139# to skip the print-out of the long features list if the file
140# existed before and after it was built:
141#
142ifeq ($(wildcard $(OUTPUT)config/feature-checks/test-all),)
143 test-all-failed := 1
144else
145 test-all-failed := 0
146endif
147
148#
149# Special fast-path for the 'all features are available' case:
150#
151$(call feature_check,all,$(MSG))
152
153#
154# Just in case the build freshly failed, make sure we print the
155# feature matrix:
156#
157ifeq ($(feature-all), 0)
158 test-all-failed := 1
98endif 159endif
99 160
100ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) 161ifeq ($(test-all-failed),1)
101 CFLAGS += -Wvolatile-register-var 162 $(info )
163 $(info Auto-detecting system features:)
102endif 164endif
103 165
104ifndef PERF_DEBUG 166ifeq ($(feature-all), 1)
105 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) 167 #
168 # test-all.c passed - just set all the core feature flags to 1:
169 #
170 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
171else
172 $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
173 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
174endif
175
176#
177# Print the result of the feature test:
178#
179feature_print = $(eval $(feature_print_code)) $(info $(MSG))
180
181define feature_print_code
182 ifeq ($(feature-$(1)), 1)
183 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
184 else
185 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
186 endif
187endef
188
189#
190# Only print out our features if we rebuilt the testcases or if a test failed:
191#
192ifeq ($(test-all-failed), 1)
193 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_print,$(feat)))
194 $(info )
195endif
196
197ifeq ($(feature-stackprotector-all), 1)
198 CFLAGS += -fstack-protector-all
199endif
200
201ifeq ($(feature-stackprotector), 1)
202 CFLAGS += -Wstack-protector
203endif
204
205ifeq ($(DEBUG),0)
206 ifeq ($(feature-fortify-source), 1)
106 CFLAGS += -D_FORTIFY_SOURCE=2 207 CFLAGS += -D_FORTIFY_SOURCE=2
107 endif 208 endif
108endif 209endif
@@ -128,84 +229,74 @@ CFLAGS += -I$(LIB_INCLUDE)
128CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 229CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
129 230
130ifndef NO_BIONIC 231ifndef NO_BIONIC
131ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) 232 $(feature_check,bionic)
132 BIONIC := 1 233 ifeq ($(feature-bionic), 1)
133 EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) 234 BIONIC := 1
134 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) 235 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
236 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
237 endif
135endif 238endif
136endif # NO_BIONIC
137 239
138ifdef NO_LIBELF 240ifdef NO_LIBELF
139 NO_DWARF := 1 241 NO_DWARF := 1
140 NO_DEMANGLE := 1 242 NO_DEMANGLE := 1
141 NO_LIBUNWIND := 1 243 NO_LIBUNWIND := 1
142else 244else
143FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) 245 ifeq ($(feature-libelf), 0)
144ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) 246 ifeq ($(feature-glibc), 1)
145 FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS) 247 LIBC_SUPPORT := 1
146 ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) 248 endif
147 LIBC_SUPPORT := 1 249 ifeq ($(BIONIC),1)
148 endif 250 LIBC_SUPPORT := 1
149 ifeq ($(BIONIC),1) 251 endif
150 LIBC_SUPPORT := 1 252 ifeq ($(LIBC_SUPPORT),1)
151 endif 253 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
152 ifeq ($(LIBC_SUPPORT),1)
153 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
154 254
155 NO_LIBELF := 1 255 NO_LIBELF := 1
156 NO_DWARF := 1 256 NO_DWARF := 1
157 NO_DEMANGLE := 1 257 NO_DEMANGLE := 1
258 else
259 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
260 endif
158 else 261 else
159 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); 262 # for linking with debug library, run like:
160 endif 263 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
161else 264 ifdef LIBDW_DIR
162 # for linking with debug library, run like: 265 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
163 # make DEBUG=1 LIBDW_DIR=/opt/libdw/ 266 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
164 ifdef LIBDW_DIR 267 endif
165 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
166 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
167 endif
168 268
169 FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lz -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) 269 ifneq ($(feature-dwarf), 1)
170 ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) 270 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);
171 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); 271 NO_DWARF := 1
172 NO_DWARF := 1 272 endif # Dwarf support
173 endif # Dwarf support 273 endif # libelf support
174endif # SOURCE_LIBELF
175endif # NO_LIBELF 274endif # NO_LIBELF
176 275
177ifndef NO_LIBELF 276ifndef NO_LIBELF
178CFLAGS += -DLIBELF_SUPPORT 277 CFLAGS += -DHAVE_LIBELF_SUPPORT
179FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
180ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y)
181 CFLAGS += -DLIBELF_MMAP
182endif
183ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM),y)
184 CFLAGS += -DHAVE_ELF_GETPHDRNUM
185endif
186 278
187# include ARCH specific config 279 ifeq ($(feature-libelf-mmap), 1)
188-include $(src-perf)/arch/$(ARCH)/Makefile 280 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
281 endif
189 282
190ifndef NO_DWARF 283 ifeq ($(feature-libelf-getphdrnum), 1)
191ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) 284 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
192 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); 285 endif
193 NO_DWARF := 1
194else
195 CFLAGS += -DDWARF_SUPPORT $(LIBDW_CFLAGS)
196 LDFLAGS += $(LIBDW_LDFLAGS)
197 EXTLIBS += -lelf -ldw
198endif # PERF_HAVE_DWARF_REGS
199endif # NO_DWARF
200 286
201endif # NO_LIBELF 287 # include ARCH specific config
288 -include $(src-perf)/arch/$(ARCH)/Makefile
202 289
203ifndef NO_LIBELF 290 ifndef NO_DWARF
204CFLAGS += -DLIBELF_SUPPORT 291 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
205FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) 292 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
206ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) 293 NO_DWARF := 1
207 CFLAGS += -DLIBELF_MMAP 294 else
208endif # try-cc 295 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
296 LDFLAGS += $(LIBDW_LDFLAGS)
297 EXTLIBS += -lelf -ldw
298 endif # PERF_HAVE_DWARF_REGS
299 endif # NO_DWARF
209endif # NO_LIBELF 300endif # NO_LIBELF
210 301
211# There's only x86 (both 32 and 64) support for CFI unwind so far 302# There's only x86 (both 32 and 64) support for CFI unwind so far
@@ -214,34 +305,35 @@ ifneq ($(ARCH),x86)
214endif 305endif
215 306
216ifndef NO_LIBUNWIND 307ifndef NO_LIBUNWIND
217# for linking with debug library, run like: 308 #
218# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ 309 # For linking with debug library, run like:
219ifdef LIBUNWIND_DIR 310 #
220 LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include 311 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
221 LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib 312 #
222endif 313 ifdef LIBUNWIND_DIR
314 LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
315 LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
316 endif
223 317
224FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) 318 ifneq ($(feature-libunwind), 1)
225ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) 319 msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99);
226 msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); 320 NO_LIBUNWIND := 1
227 NO_LIBUNWIND := 1 321 endif
228endif # Libunwind support 322endif
229endif # NO_LIBUNWIND
230 323
231ifndef NO_LIBUNWIND 324ifndef NO_LIBUNWIND
232 CFLAGS += -DLIBUNWIND_SUPPORT 325 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
233 EXTLIBS += $(LIBUNWIND_LIBS) 326 EXTLIBS += $(LIBUNWIND_LIBS)
234 CFLAGS += $(LIBUNWIND_CFLAGS) 327 CFLAGS += $(LIBUNWIND_CFLAGS)
235 LDFLAGS += $(LIBUNWIND_LDFLAGS) 328 LDFLAGS += $(LIBUNWIND_LDFLAGS)
236endif # NO_LIBUNWIND 329endif
237 330
238ifndef NO_LIBAUDIT 331ifndef NO_LIBAUDIT
239 FLAGS_LIBAUDIT = $(CFLAGS) $(LDFLAGS) -laudit 332 ifneq ($(feature-libaudit), 1)
240 ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y)
241 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); 333 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
242 NO_LIBAUDIT := 1 334 NO_LIBAUDIT := 1
243 else 335 else
244 CFLAGS += -DLIBAUDIT_SUPPORT 336 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
245 EXTLIBS += -laudit 337 EXTLIBS += -laudit
246 endif 338 endif
247endif 339endif
@@ -251,30 +343,30 @@ ifdef NO_NEWT
251endif 343endif
252 344
253ifndef NO_SLANG 345ifndef NO_SLANG
254 FLAGS_SLANG=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang 346 ifneq ($(feature-libslang), 1)
255 ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y)
256 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); 347 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
257 NO_SLANG := 1 348 NO_SLANG := 1
258 else 349 else
259 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h 350 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
260 CFLAGS += -I/usr/include/slang 351 CFLAGS += -I/usr/include/slang
261 CFLAGS += -DSLANG_SUPPORT 352 CFLAGS += -DHAVE_SLANG_SUPPORT
262 EXTLIBS += -lslang 353 EXTLIBS += -lslang
263 endif 354 endif
264endif 355endif
265 356
266ifndef NO_GTK2 357ifndef NO_GTK2
267 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) 358 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
268 ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y) 359 ifneq ($(feature-gtk2), 1)
269 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); 360 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
270 NO_GTK2 := 1 361 NO_GTK2 := 1
271 else 362 else
272 ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y) 363 ifeq ($(feature-gtk2-infobar), 1)
273 CFLAGS += -DHAVE_GTK_INFO_BAR 364 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
274 endif 365 endif
275 CFLAGS += -DGTK2_SUPPORT 366 CFLAGS += -DHAVE_GTK2_SUPPORT
276 CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) 367 GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
277 EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null) 368 GTK_LIBS := $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
369 EXTLIBS += -ldl
278 endif 370 endif
279endif 371endif
280 372
@@ -290,7 +382,7 @@ else
290 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` 382 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
291 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) 383 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
292 384
293 ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y) 385 ifneq ($(feature-libperl), 1)
294 CFLAGS += -DNO_LIBPERL 386 CFLAGS += -DNO_LIBPERL
295 NO_LIBPERL := 1 387 NO_LIBPERL := 1
296 else 388 else
@@ -335,11 +427,11 @@ else
335 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) 427 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
336 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) 428 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
337 429
338 ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y) 430 ifneq ($(feature-libpython), 1)
339 $(call disable-python,Python.h (for Python 2.x)) 431 $(call disable-python,Python.h (for Python 2.x))
340 else 432 else
341 433
342 ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y) 434 ifneq ($(feature-libpython-version), 1)
343 $(warning Python 3 is not yet supported; please set) 435 $(warning Python 3 is not yet supported; please set)
344 $(warning PYTHON and/or PYTHON_CONFIG appropriately.) 436 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
345 $(warning If you also have Python 2 installed, then) 437 $(warning If you also have Python 2 installed, then)
@@ -362,33 +454,30 @@ else
362 endif 454 endif
363endif 455endif
364 456
457ifeq ($(feature-libbfd), 1)
458 EXTLIBS += -lbfd
459endif
460
365ifdef NO_DEMANGLE 461ifdef NO_DEMANGLE
366 CFLAGS += -DNO_DEMANGLE 462 CFLAGS += -DNO_DEMANGLE
367else 463else
368 ifdef HAVE_CPLUS_DEMANGLE 464 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
369 EXTLIBS += -liberty 465 EXTLIBS += -liberty
370 CFLAGS += -DHAVE_CPLUS_DEMANGLE 466 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
371 else 467 else
372 FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd 468 ifneq ($(feature-libbfd), 1)
373 has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd) 469 $(feature_check,liberty)
374 ifeq ($(has_bfd),y) 470 ifeq ($(feature-liberty), 1)
375 EXTLIBS += -lbfd
376 else
377 FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
378 has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty)
379 ifeq ($(has_bfd_iberty),y)
380 EXTLIBS += -lbfd -liberty 471 EXTLIBS += -lbfd -liberty
381 else 472 else
382 FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz 473 $(feature_check,liberty-z)
383 has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz) 474 ifeq ($(feature-liberty-z), 1)
384 ifeq ($(has_bfd_iberty_z),y)
385 EXTLIBS += -lbfd -liberty -lz 475 EXTLIBS += -lbfd -liberty -lz
386 else 476 else
387 FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -liberty 477 $(feature_check,cplus-demangle)
388 has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle) 478 ifeq ($(feature-cplus-demangle), 1)
389 ifeq ($(has_cplus_demangle),y)
390 EXTLIBS += -liberty 479 EXTLIBS += -liberty
391 CFLAGS += -DHAVE_CPLUS_DEMANGLE 480 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
392 else 481 else
393 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) 482 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
394 CFLAGS += -DNO_DEMANGLE 483 CFLAGS += -DNO_DEMANGLE
@@ -399,31 +488,28 @@ else
399 endif 488 endif
400endif 489endif
401 490
402ifndef NO_STRLCPY 491ifneq ($(filter -lbfd,$(EXTLIBS)),)
403 ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y) 492 CFLAGS += -DHAVE_LIBBFD_SUPPORT
404 CFLAGS += -DHAVE_STRLCPY
405 endif
406endif 493endif
407 494
408ifndef NO_ON_EXIT 495ifndef NO_ON_EXIT
409 ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y) 496 ifeq ($(feature-on-exit), 1)
410 CFLAGS += -DHAVE_ON_EXIT 497 CFLAGS += -DHAVE_ON_EXIT_SUPPORT
411 endif 498 endif
412endif 499endif
413 500
414ifndef NO_BACKTRACE 501ifndef NO_BACKTRACE
415 ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y) 502 ifeq ($(feature-backtrace), 1)
416 CFLAGS += -DBACKTRACE_SUPPORT 503 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
417 endif 504 endif
418endif 505endif
419 506
420ifndef NO_LIBNUMA 507ifndef NO_LIBNUMA
421 FLAGS_LIBNUMA = $(CFLAGS) $(LDFLAGS) -lnuma 508 ifeq ($(feature-libnuma), 0)
422 ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y)
423 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev); 509 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
424 NO_LIBNUMA := 1 510 NO_LIBNUMA := 1
425 else 511 else
426 CFLAGS += -DLIBNUMA_SUPPORT 512 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
427 EXTLIBS += -lnuma 513 EXTLIBS += -lnuma
428 endif 514 endif
429endif 515endif
@@ -459,7 +545,12 @@ else
459sysconfdir = $(prefix)/etc 545sysconfdir = $(prefix)/etc
460ETC_PERFCONFIG = etc/perfconfig 546ETC_PERFCONFIG = etc/perfconfig
461endif 547endif
548ifeq ($(IS_X86_64),1)
549lib = lib64
550else
462lib = lib 551lib = lib
552endif
553libdir = $(prefix)/$(lib)
463 554
464# Shell quote (do not use $(call) to accommodate ancient setups); 555# Shell quote (do not use $(call) to accommodate ancient setups);
465ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) 556ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
@@ -472,6 +563,7 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
472htmldir_SQ = $(subst ','\'',$(htmldir)) 563htmldir_SQ = $(subst ','\'',$(htmldir))
473prefix_SQ = $(subst ','\'',$(prefix)) 564prefix_SQ = $(subst ','\'',$(prefix))
474sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) 565sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
566libdir_SQ = $(subst ','\'',$(libdir))
475 567
476ifneq ($(filter /%,$(firstword $(perfexecdir))),) 568ifneq ($(filter /%,$(firstword $(perfexecdir))),)
477perfexec_instdir = $(perfexecdir) 569perfexec_instdir = $(perfexecdir)