blob: cd568699157c26ea9672bef1bd4d6167640b0ba1 [file] [log] [blame]
Jiri Olsa8bd407b2013-03-15 16:28:49 +01001
Jiri Olsaa6cf5f32014-01-03 15:32:32 +01002ifeq ($(src-perf),)
3src-perf := $(srctree)/tools/perf
Jiri Olsa8bd407b2013-03-15 16:28:49 +01004endif
5
Jiri Olsaa6cf5f32014-01-03 15:32:32 +01006ifeq ($(obj-perf),)
7obj-perf := $(OUTPUT)
8endif
9
10ifneq ($(obj-perf),)
11obj-perf := $(abspath $(obj-perf))/
12endif
13
14LIB_INCLUDE := $(srctree)/tools/lib/
15CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
16
17include $(src-perf)/config/Makefile.arch
18
19NO_PERF_REGS := 1
20
21# Additional ARCH settings for x86
22ifeq ($(ARCH),x86)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020023 ifeq (${IS_X86_64}, 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +020024 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020025 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
Adrian Hunter8a0c4c22013-11-01 15:51:32 +020026 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
27 else
28 LIBUNWIND_LIBS = -lunwind -lunwind-x86
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020029 endif
30 NO_PERF_REGS := 0
Jiri Olsa8bd407b2013-03-15 16:28:49 +010031endif
Jean Pihet8ab596a2014-04-28 14:32:33 +020032
Will Deacon7495f372013-09-26 12:36:36 +010033ifeq ($(ARCH),arm)
34 NO_PERF_REGS := 0
35 LIBUNWIND_LIBS = -lunwind -lunwind-arm
36endif
Jiri Olsa8bd407b2013-03-15 16:28:49 +010037
Jean Pihet8ab596a2014-04-28 14:32:33 +020038ifeq ($(ARCH),arm64)
39 NO_PERF_REGS := 0
40 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
41endif
42
Jiri Olsa4dc549e2014-04-20 10:50:00 +020043# So far there's only x86 libdw unwind support merged in perf.
44# Disable it on all other architectures in case libdw unwind
45# support is detected in system. Add supported architectures
46# to the check.
47ifneq ($(ARCH),x86)
48 NO_LIBDW_DWARF_UNWIND := 1
49endif
50
Jean Pihet1448fef2013-12-10 13:24:04 +010051ifeq ($(LIBUNWIND_LIBS),)
52 NO_LIBUNWIND := 1
53else
54 #
55 # For linking with debug library, run like:
56 #
57 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
58 #
59 ifdef LIBUNWIND_DIR
60 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
61 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
62 endif
63 LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
64
65 # Set per-feature check compilation flags
66 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
67 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
68 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
69 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
Jean Pihet1448fef2013-12-10 13:24:04 +010070endif
71
Jiri Olsa8bd407b2013-03-15 16:28:49 +010072ifeq ($(NO_PERF_REGS),0)
Ingo Molnar89fe8082013-09-30 12:07:11 +020073 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
Jiri Olsa8bd407b2013-03-15 16:28:49 +010074endif
Jiri Olsaa32f4932013-03-25 00:32:01 +010075
Jiri Olsa45757892014-02-19 16:52:56 +010076ifndef NO_LIBELF
77 # for linking with debug library, run like:
78 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
79 ifdef LIBDW_DIR
80 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
81 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
Jiri Olsa45757892014-02-19 16:52:56 +010082 endif
Ramkumar Ramachandra2c529e42014-03-26 18:44:05 -040083 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
84 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
Jiri Olsa45757892014-02-19 16:52:56 +010085endif
86
Jiri Olsa7c537462013-05-24 14:35:23 +020087# include ARCH specific config
88-include $(src-perf)/arch/$(ARCH)/Makefile
89
Jiri Olsa7c537462013-05-24 14:35:23 +020090include $(src-perf)/config/utilities.mak
Jiri Olsaa32f4932013-03-25 00:32:01 +010091
92ifeq ($(call get-executable,$(FLEX)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020093 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +010094endif
95
96ifeq ($(call get-executable,$(BISON)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020097 dummy := $(error Error: $(BISON) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +010098endif
Jiri Olsa362493f2013-03-25 00:40:48 +010099
100# Treat warnings as errors unless directed not to
101ifneq ($(WERROR),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200102 CFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +0100103endif
104
Adrian Hunter74af3772013-10-22 10:34:05 +0300105ifndef DEBUG
106 DEBUG := 0
107endif
108
Ingo Molnarfcf92582013-10-10 08:05:25 +0200109ifeq ($(DEBUG),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200110 CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +0100111endif
112
113ifdef PARSER_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200114 PARSER_DEBUG_BISON := -t
115 PARSER_DEBUG_FLEX := -d
116 CFLAGS += -DPARSER_DEBUG
Jiri Olsa362493f2013-03-25 00:40:48 +0100117endif
118
Jiri Olsa2fe73742013-04-15 04:32:28 +0200119CFLAGS += -fno-omit-frame-pointer
120CFLAGS += -ggdb3
121CFLAGS += -funwind-tables
122CFLAGS += -Wall
123CFLAGS += -Wextra
124CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100125
David Ahern6d199122013-09-22 19:44:57 -0600126EXTLIBS = -lelf -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +0100127
Ingo Molnar1c2d1d82013-10-03 15:05:56 +0200128ifneq ($(OUTPUT),)
129 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
130 $(shell mkdir -p $(OUTPUT_FEATURES))
131endif
132
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200133feature_check = $(eval $(feature_check_code))
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200134define feature_check_code
Chunwei Chen56560ec2013-12-21 13:48:11 +0800135 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)
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200136endef
137
138feature_set = $(eval $(feature_set_code))
139define feature_set_code
140 feature-$(1) := 1
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200141endef
142
143#
144# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
145#
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200146
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200147#
148# Note that this is not a complete list of all feature tests, just
149# those that are typically built on a fully configured system.
150#
151# [ Feature tests not mentioned here have to be built explicitly in
152# the rule that uses them - an example for that is the 'bionic'
153# feature check. ]
154#
155CORE_FEATURE_TESTS = \
156 backtrace \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200157 dwarf \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200158 fortify-source \
159 glibc \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200160 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200161 gtk2-infobar \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200162 libaudit \
163 libbfd \
164 libelf \
165 libelf-getphdrnum \
166 libelf-mmap \
167 libnuma \
Ingo Molnar7181a672013-09-30 15:15:36 +0200168 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200169 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200170 libpython-version \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200171 libslang \
172 libunwind \
Ingo Molnar34ef2162013-09-30 16:46:49 +0200173 on-exit \
Ingo Molnarbb4c5502013-11-14 08:33:24 +0100174 stackprotector-all \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100175 timerfd \
176 libdw-dwarf-unwind
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200177
Jiri Olsa0695e572014-02-19 16:52:54 +0100178LIB_FEATURE_TESTS = \
179 dwarf \
180 glibc \
181 gtk2 \
182 libaudit \
183 libbfd \
184 libelf \
185 libnuma \
186 libperl \
187 libpython \
188 libslang \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100189 libunwind \
190 libdw-dwarf-unwind
Jiri Olsa0695e572014-02-19 16:52:54 +0100191
192VF_FEATURE_TESTS = \
193 backtrace \
194 fortify-source \
195 gtk2-infobar \
196 libelf-getphdrnum \
197 libelf-mmap \
198 libpython-version \
199 on-exit \
200 stackprotector-all \
201 timerfd \
202 libunwind-debug-frame \
203 bionic
204
Jiri Olsac4eb6c02014-01-07 13:47:18 +0100205# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
206# If in the future we need per-feature checks/flags for features not
207# mentioned in this list we need to refactor this ;-).
208set_test_all_flags = $(eval $(set_test_all_flags_code))
209define set_test_all_flags_code
210 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
211 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
212endef
213
214$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
215
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200216#
217# Special fast-path for the 'all features are available' case:
218#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200219$(call feature_check,all,$(MSG))
220
221#
222# Just in case the build freshly failed, make sure we print the
223# feature matrix:
224#
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200225ifeq ($(feature-all), 1)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200226 #
227 # test-all.c passed - just set all the core feature flags to 1:
228 #
229 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200230else
Chunwei Chen56560ec2013-12-21 13:48:11 +0800231 $(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)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200232 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200233endif
234
Ingo Molnar90ac5422013-09-30 13:48:44 +0200235ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200236 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100237endif
238
Ingo Molnarfcf92582013-10-10 08:05:25 +0200239ifeq ($(DEBUG),0)
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200240 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200241 CFLAGS += -D_FORTIFY_SOURCE=2
242 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100243endif
244
Jiri Olsa2fe73742013-04-15 04:32:28 +0200245CFLAGS += -I$(src-perf)/util/include
246CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
Namhyung Kim8a625c12014-01-09 23:00:52 +0900247CFLAGS += -I$(srctree)/tools/include/
Jiri Olsa2fe73742013-04-15 04:32:28 +0200248CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
249CFLAGS += -I$(srctree)/arch/$(ARCH)/include
250CFLAGS += -I$(srctree)/include/uapi
251CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200252
253# $(obj-perf) for generated common-cmds.h
254# $(obj-perf)/util for generated bison/flex headers
255ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200256CFLAGS += -I$(obj-perf)/util
257CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200258endif
259
Jiri Olsa2fe73742013-04-15 04:32:28 +0200260CFLAGS += -I$(src-perf)/util
261CFLAGS += -I$(src-perf)
Robert Richter4e319022013-06-11 17:29:18 +0200262CFLAGS += -I$(LIB_INCLUDE)
Jiri Olsa7c537462013-05-24 14:35:23 +0200263
Jiri Olsa2fe73742013-04-15 04:32:28 +0200264CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100265
Jiri Olsa4e22db42013-05-24 14:35:24 +0200266ifndef NO_BIONIC
David Ahern5febff02013-10-29 10:43:15 -0600267 $(call feature_check,bionic)
Ingo Molnar78e9d652013-09-30 14:11:46 +0200268 ifeq ($(feature-bionic), 1)
269 BIONIC := 1
270 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
271 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
272 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100273endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100274
275ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200276 NO_DWARF := 1
277 NO_DEMANGLE := 1
278 NO_LIBUNWIND := 1
Jiri Olsa5ea84152014-02-19 16:52:57 +0100279 NO_LIBDW_DWARF_UNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100280else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200281 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200282 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200283 LIBC_SUPPORT := 1
284 endif
285 ifeq ($(BIONIC),1)
286 LIBC_SUPPORT := 1
287 endif
288 ifeq ($(LIBC_SUPPORT),1)
289 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100290
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200291 NO_LIBELF := 1
292 NO_DWARF := 1
293 NO_DEMANGLE := 1
Arnaldo Carvalho de Melo94589552014-03-25 09:35:11 -0300294 NO_LIBUNWIND := 1
295 NO_LIBDW_DWARF_UNWIND := 1
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200296 else
297 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
298 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200299 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100300 ifndef NO_LIBDW_DWARF_UNWIND
301 ifneq ($(feature-libdw-dwarf-unwind),1)
302 NO_LIBDW_DWARF_UNWIND := 1
303 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
304 endif
305 endif
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200306 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200307 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);
308 NO_DWARF := 1
309 endif # Dwarf support
Ingo Molnar0648f832013-10-02 15:30:35 +0200310 endif # libelf support
Jiri Olsacf4cca12013-03-25 00:45:08 +0100311endif # NO_LIBELF
312
313ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200314 CFLAGS += -DHAVE_LIBELF_SUPPORT
Jiri Olsa779724f2013-03-25 00:48:14 +0100315
Ingo Molnar8869b172013-09-30 15:02:28 +0200316 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200317 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
318 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100319
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200320 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200321 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
322 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100323
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200324 # include ARCH specific config
325 -include $(src-perf)/arch/$(ARCH)/Makefile
326
327 ifndef NO_DWARF
328 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
329 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
330 NO_DWARF := 1
331 else
332 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
333 LDFLAGS += $(LIBDW_LDFLAGS)
334 EXTLIBS += -lelf -ldw
335 endif # PERF_HAVE_DWARF_REGS
336 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100337endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100338
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100339ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200340 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100341 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
Ingo Molnar308e1e72013-10-07 10:30:47 +0200342 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100343 endif
344endif
345
346dwarf-post-unwind := 1
347dwarf-post-unwind-text := BUG
348
349# setup DWARF post unwinder
350ifdef NO_LIBUNWIND
351 ifdef NO_LIBDW_DWARF_UNWIND
352 msg := $(warning Disabling post unwind, no support found.);
353 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900354 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100355 dwarf-post-unwind-text := libdw
356 endif
357else
358 dwarf-post-unwind-text := libunwind
359 # Enable libunwind support by default.
360 ifndef NO_LIBDW_DWARF_UNWIND
361 NO_LIBDW_DWARF_UNWIND := 1
362 endif
363endif
364
365ifeq ($(dwarf-post-unwind),1)
366 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
367else
368 NO_DWARF_UNWIND := 1
369endif
370
371ifndef NO_LIBUNWIND
Jean Pihet8ab596a2014-04-28 14:32:33 +0200372 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100373 $(call feature_check,libunwind-debug-frame)
374 ifneq ($(feature-libunwind-debug-frame), 1)
375 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900376 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
377 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100378 else
379 # non-ARM has no dwarf_find_debug_frame() function:
380 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
381 endif
382 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
383 EXTLIBS += $(LIBUNWIND_LIBS)
384 CFLAGS += $(LIBUNWIND_CFLAGS)
385 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200386endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100387
388ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200389 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200390 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
391 NO_LIBAUDIT := 1
392 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200393 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200394 EXTLIBS += -laudit
395 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100396endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100397
398ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200399 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100400endif
401
402ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200403 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200404 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
405 NO_SLANG := 1
406 else
407 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
408 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200409 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200410 EXTLIBS += -lslang
411 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100412endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100413
414ifndef NO_GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000415 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200416 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200417 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
418 NO_GTK2 := 1
419 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200420 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900421 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200422 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200423 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000424 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
425 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200426 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200427 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100428endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100429
430grep-libs = $(filter -l%,$(1))
431strip-libs = $(filter-out -l%,$(1))
432
433ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200434 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100435else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200436 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
437 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
438 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
439 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
440 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100441
Ingo Molnar7181a672013-09-30 15:15:36 +0200442 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200443 CFLAGS += -DNO_LIBPERL
444 NO_LIBPERL := 1
445 else
446 LDFLAGS += $(PERL_EMBED_LDFLAGS)
447 EXTLIBS += $(PERL_EMBED_LIBADD)
448 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100449endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100450
David Ahern87419c92013-10-29 10:43:16 -0600451ifeq ($(feature-timerfd), 1)
452 CFLAGS += -DHAVE_TIMERFD_SUPPORT
453else
454 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
455endif
456
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100457disable-python = $(eval $(disable-python_code))
458define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100459 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100460 $(if $(1),$(warning No $(1) was found))
461 $(warning Python support will not be built)
462 NO_LIBPYTHON := 1
463endef
464
465override PYTHON := \
466 $(call get-executable-or-default,PYTHON,python)
467
468ifndef PYTHON
469 $(call disable-python,python interpreter)
470else
471
472 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
473
474 ifdef NO_LIBPYTHON
475 $(call disable-python)
476 else
477
478 override PYTHON_CONFIG := \
479 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
480
481 ifndef PYTHON_CONFIG
482 $(call disable-python,python-config tool)
483 else
484
485 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
486
487 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
488 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
489 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
490 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
491 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
492
Ingo Molnar97341632013-09-30 15:18:37 +0200493 ifneq ($(feature-libpython), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100494 $(call disable-python,Python.h (for Python 2.x))
495 else
496
Ingo Molnar95d061c2013-09-30 15:40:04 +0200497 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100498 $(warning Python 3 is not yet supported; please set)
499 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
500 $(warning If you also have Python 2 installed, then)
501 $(warning try something like:)
502 $(warning $(and ,))
503 $(warning $(and ,) make PYTHON=python2)
504 $(warning $(and ,))
505 $(warning Otherwise, disable Python support entirely:)
506 $(warning $(and ,))
507 $(warning $(and ,) make NO_LIBPYTHON=1)
508 $(warning $(and ,))
509 $(error $(and ,))
510 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100511 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100512 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200513 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100514 endif
515 endif
516 endif
517 endif
518endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100519
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200520ifeq ($(feature-libbfd), 1)
Andi Kleen280e7c42014-01-11 11:42:51 -0800521 EXTLIBS += -lbfd -lz -liberty
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200522endif
523
Jiri Olsac3cf8362013-03-18 00:38:16 +0100524ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200525 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100526else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200527 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200528 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200529 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200530 else
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200531 ifneq ($(feature-libbfd), 1)
David Ahern5febff02013-10-29 10:43:15 -0600532 $(call feature_check,liberty)
Ingo Molnar1c476612013-10-02 15:15:09 +0200533 ifeq ($(feature-liberty), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200534 EXTLIBS += -lbfd -liberty
535 else
David Ahern5febff02013-10-29 10:43:15 -0600536 $(call feature_check,liberty-z)
Ingo Molnar1c476612013-10-02 15:15:09 +0200537 ifeq ($(feature-liberty-z), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200538 EXTLIBS += -lbfd -liberty -lz
539 else
David Ahern5febff02013-10-29 10:43:15 -0600540 $(call feature_check,cplus-demangle)
Ingo Molnar1c476612013-10-02 15:15:09 +0200541 ifeq ($(feature-cplus-demangle), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200542 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200543 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200544 else
545 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
546 CFLAGS += -DNO_DEMANGLE
547 endif
548 endif
549 endif
550 endif
551 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100552endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100553
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200554ifneq ($(filter -lbfd,$(EXTLIBS)),)
555 CFLAGS += -DHAVE_LIBBFD_SUPPORT
556endif
557
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100558ifndef NO_ON_EXIT
Ingo Molnar34ef2162013-09-30 16:46:49 +0200559 ifeq ($(feature-on-exit), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200560 CFLAGS += -DHAVE_ON_EXIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200561 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100562endif
563
564ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200565 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200566 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200567 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100568endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100569
570ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200571 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500572 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200573 NO_LIBNUMA := 1
574 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200575 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200576 EXTLIBS += -lnuma
577 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100578endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100579
580# Among the variables below, these:
581# perfexecdir
582# template_dir
583# mandir
584# infodir
585# htmldir
586# ETC_PERFCONFIG (but not sysconfdir)
587# can be specified as a relative path some/where/else;
588# this is interpreted as relative to $(prefix) and "perf" at
589# runtime figures out where they are based on the path to the executable.
590# This can help installing the suite in a relocatable way.
591
592# Make the path relative to DESTDIR, not to prefix
593ifndef DESTDIR
594prefix = $(HOME)
595endif
596bindir_relative = bin
597bindir = $(prefix)/$(bindir_relative)
598mandir = share/man
599infodir = share/info
600perfexecdir = libexec/perf-core
601sharedir = $(prefix)/share
602template_dir = share/perf-core/templates
603htmldir = share/doc/perf-doc
604ifeq ($(prefix),/usr)
605sysconfdir = /etc
606ETC_PERFCONFIG = $(sysconfdir)/perfconfig
607else
608sysconfdir = $(prefix)/etc
609ETC_PERFCONFIG = etc/perfconfig
610endif
Namhyung Kimfc672972013-09-13 15:27:43 +0900611ifeq ($(IS_X86_64),1)
612lib = lib64
613else
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100614lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900615endif
616libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100617
618# Shell quote (do not use $(call) to accommodate ancient setups);
619ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
620DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
621bindir_SQ = $(subst ','\'',$(bindir))
622mandir_SQ = $(subst ','\'',$(mandir))
623infodir_SQ = $(subst ','\'',$(infodir))
624perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
625template_dir_SQ = $(subst ','\'',$(template_dir))
626htmldir_SQ = $(subst ','\'',$(htmldir))
627prefix_SQ = $(subst ','\'',$(prefix))
628sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +0900629libdir_SQ = $(subst ','\'',$(libdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100630
631ifneq ($(filter /%,$(firstword $(perfexecdir))),)
632perfexec_instdir = $(perfexecdir)
633else
634perfexec_instdir = $(prefix)/$(perfexecdir)
635endif
636perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100637
638# If we install to $(HOME) we keep the traceevent default:
639# $(HOME)/.traceevent/plugins
640# Otherwise we install plugins into the global $(libdir).
641ifdef DESTDIR
642plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -0500643plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100644endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100645
646#
647# Print the result of the feature test:
648#
Jiri Olsa8d790762014-02-19 16:52:55 +0100649feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
Jiri Olsa0695e572014-02-19 16:52:54 +0100650
Jiri Olsa8d790762014-02-19 16:52:55 +0100651define feature_print_status_code
Jiri Olsa0695e572014-02-19 16:52:54 +0100652 ifeq ($(feature-$(1)), 1)
653 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
654 else
655 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
656 endif
657endef
658
Jiri Olsa8d790762014-02-19 16:52:55 +0100659feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
660define feature_print_var_code
661 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
662endef
663
664feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
665define feature_print_text_code
666 MSG = $(shell printf '...%30s: %s' $(1) $(2))
667endef
668
Jiri Olsa0695e572014-02-19 16:52:54 +0100669PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
670PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
671
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100672ifeq ($(dwarf-post-unwind),1)
673 PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
674endif
675
Jiri Olsa0695e572014-02-19 16:52:54 +0100676# The $(display_lib) controls the default detection message
677# output. It's set if:
678# - detected features differes from stored features from
679# last build (in PERF-FEATURES file)
680# - one of the $(LIB_FEATURE_TESTS) is not detected
681# - VF is enabled
682
683ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
684 $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
685 display_lib := 1
686endif
687
688feature_check = $(eval $(feature_check_code))
689define feature_check_code
690 ifneq ($(feature-$(1)), 1)
691 display_lib := 1
692 endif
693endef
694
695$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
696
697ifeq ($(VF),1)
698 display_lib := 1
699 display_vf := 1
700endif
701
702ifeq ($(display_lib),1)
703 $(info )
704 $(info Auto-detecting system features:)
Jiri Olsa8d790762014-02-19 16:52:55 +0100705 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100706
707 ifeq ($(dwarf-post-unwind),1)
708 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
709 endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100710endif
711
712ifeq ($(display_vf),1)
Jiri Olsa8d790762014-02-19 16:52:55 +0100713 $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
714 $(info )
715 $(call feature_print_var,prefix)
716 $(call feature_print_var,bindir)
717 $(call feature_print_var,libdir)
718 $(call feature_print_var,sysconfdir)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100719 $(call feature_print_var,LIBUNWIND_DIR)
720 $(call feature_print_var,LIBDW_DIR)
Jiri Olsa0695e572014-02-19 16:52:54 +0100721endif
722
723ifeq ($(display_lib),1)
724 $(info )
725endif