blob: 2fd018529b95a22afc8eac6c27c9384b058f9ad8 [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
Jiri Olsafcfd6612014-12-31 17:37:00 +010014$(shell echo -n > .config-detected)
15detected = $(shell echo "$(1)=y" >> .config-detected)
16detected_var = $(shell echo "$(1)=$($(1))" >> .config-detected)
17
Jiri Olsaa6cf5f32014-01-03 15:32:32 +010018LIB_INCLUDE := $(srctree)/tools/lib/
19CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
20
21include $(src-perf)/config/Makefile.arch
22
Jiri Olsaf39e0422014-12-29 15:03:09 +010023$(call detected_var,ARCH)
24
Jiri Olsaa6cf5f32014-01-03 15:32:32 +010025NO_PERF_REGS := 1
26
27# Additional ARCH settings for x86
28ifeq ($(ARCH),x86)
Jiri Olsaf39e0422014-12-29 15:03:09 +010029 $(call detected,CONFIG_X86)
Namhyung Kimc6e5e9f2015-01-12 10:20:55 +080030 ifeq (${IS_64_BIT}, 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +020031 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020032 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
Adrian Hunter8a0c4c22013-11-01 15:51:32 +020033 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
Jiri Olsa72965b82014-12-29 13:52:36 +010034 $(call detected,CONFIG_X86_64)
Adrian Hunter8a0c4c22013-11-01 15:51:32 +020035 else
36 LIBUNWIND_LIBS = -lunwind -lunwind-x86
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020037 endif
38 NO_PERF_REGS := 0
Jiri Olsa8bd407b2013-03-15 16:28:49 +010039endif
Jean Pihet8ab596a2014-04-28 14:32:33 +020040
Will Deacon7495f372013-09-26 12:36:36 +010041ifeq ($(ARCH),arm)
42 NO_PERF_REGS := 0
43 LIBUNWIND_LIBS = -lunwind -lunwind-arm
44endif
Jiri Olsa8bd407b2013-03-15 16:28:49 +010045
Jean Pihet8ab596a2014-04-28 14:32:33 +020046ifeq ($(ARCH),arm64)
47 NO_PERF_REGS := 0
48 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
49endif
50
Jean Pihet90fa9de2014-05-16 10:41:11 +020051# So far there's only x86 and arm libdw unwind support merged in perf.
Jiri Olsa4dc549e2014-04-20 10:50:00 +020052# Disable it on all other architectures in case libdw unwind
53# support is detected in system. Add supported architectures
54# to the check.
Jean Pihet90fa9de2014-05-16 10:41:11 +020055ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
Jiri Olsa4dc549e2014-04-20 10:50:00 +020056 NO_LIBDW_DWARF_UNWIND := 1
57endif
58
Jean Pihet1448fef2013-12-10 13:24:04 +010059ifeq ($(LIBUNWIND_LIBS),)
60 NO_LIBUNWIND := 1
61else
62 #
63 # For linking with debug library, run like:
64 #
65 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
66 #
67 ifdef LIBUNWIND_DIR
68 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
69 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
70 endif
71 LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
72
73 # Set per-feature check compilation flags
74 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
75 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
76 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
77 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
Jean Pihet1448fef2013-12-10 13:24:04 +010078endif
79
Jiri Olsa8bd407b2013-03-15 16:28:49 +010080ifeq ($(NO_PERF_REGS),0)
Ingo Molnar89fe8082013-09-30 12:07:11 +020081 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
Jiri Olsa8bd407b2013-03-15 16:28:49 +010082endif
Jiri Olsaa32f4932013-03-25 00:32:01 +010083
Jiri Olsa45757892014-02-19 16:52:56 +010084ifndef NO_LIBELF
85 # for linking with debug library, run like:
86 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
87 ifdef LIBDW_DIR
88 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
89 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
Jiri Olsa45757892014-02-19 16:52:56 +010090 endif
Ramkumar Ramachandra2c529e42014-03-26 18:44:05 -040091 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
92 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
Jiri Olsa45757892014-02-19 16:52:56 +010093endif
94
Jiri Olsa7c537462013-05-24 14:35:23 +020095# include ARCH specific config
96-include $(src-perf)/arch/$(ARCH)/Makefile
97
Jiri Olsa7c537462013-05-24 14:35:23 +020098include $(src-perf)/config/utilities.mak
Jiri Olsaa32f4932013-03-25 00:32:01 +010099
100ifeq ($(call get-executable,$(FLEX)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200101 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100102endif
103
104ifeq ($(call get-executable,$(BISON)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200105 dummy := $(error Error: $(BISON) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100106endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100107
108# Treat warnings as errors unless directed not to
109ifneq ($(WERROR),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200110 CFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +0100111endif
112
Adrian Hunter74af3772013-10-22 10:34:05 +0300113ifndef DEBUG
114 DEBUG := 0
115endif
116
Ingo Molnarfcf92582013-10-10 08:05:25 +0200117ifeq ($(DEBUG),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200118 CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +0100119endif
120
121ifdef PARSER_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200122 PARSER_DEBUG_BISON := -t
123 PARSER_DEBUG_FLEX := -d
124 CFLAGS += -DPARSER_DEBUG
Jiri Olsa362493f2013-03-25 00:40:48 +0100125endif
126
Namhyung Kim56c7d792014-07-29 15:57:19 +0900127ifndef NO_LIBPYTHON
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200128 # Try different combinations to accommodate systems that only have
129 # python[2][-config] in weird combinations but always preferring
130 # python2 and python2-config as per pep-0394. If we catch a
131 # python[-config] in version 3, the version check will kill it.
132 PYTHON2 := $(if $(call get-executable,python2),python2,python)
133 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
134 PYTHON2_CONFIG := \
135 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
Namhyung Kim56c7d792014-07-29 15:57:19 +0900136 override PYTHON_CONFIG := \
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200137 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
Namhyung Kim56c7d792014-07-29 15:57:19 +0900138
139 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
140
141 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
142 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
143
144 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
145 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
146 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
147 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
148endif
149
Jiri Olsa2fe73742013-04-15 04:32:28 +0200150CFLAGS += -fno-omit-frame-pointer
151CFLAGS += -ggdb3
152CFLAGS += -funwind-tables
153CFLAGS += -Wall
154CFLAGS += -Wextra
155CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100156
Mathias Krause6392b4e2014-04-27 18:51:05 +0200157# Enforce a non-executable stack, as we may regress (again) in the future by
158# adding assembler files missing the .GNU-stack linker note.
159LDFLAGS += -Wl,-z,noexecstack
160
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900161EXTLIBS = -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +0100162
Ingo Molnar1c2d1d82013-10-03 15:05:56 +0200163ifneq ($(OUTPUT),)
164 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
165 $(shell mkdir -p $(OUTPUT_FEATURES))
166endif
167
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200168feature_check = $(eval $(feature_check_code))
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200169define feature_check_code
Chunwei Chen56560ec2013-12-21 13:48:11 +0800170 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 +0200171endef
172
173feature_set = $(eval $(feature_set_code))
174define feature_set_code
175 feature-$(1) := 1
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200176endef
177
178#
179# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
180#
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200181
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200182#
183# Note that this is not a complete list of all feature tests, just
184# those that are typically built on a fully configured system.
185#
186# [ Feature tests not mentioned here have to be built explicitly in
187# the rule that uses them - an example for that is the 'bionic'
188# feature check. ]
189#
190CORE_FEATURE_TESTS = \
191 backtrace \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200192 dwarf \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200193 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300194 sync-compare-and-swap \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200195 glibc \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200196 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200197 gtk2-infobar \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200198 libaudit \
199 libbfd \
200 libelf \
201 libelf-getphdrnum \
202 libelf-mmap \
203 libnuma \
Ingo Molnar7181a672013-09-30 15:15:36 +0200204 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200205 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200206 libpython-version \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200207 libslang \
208 libunwind \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530209 pthread-attr-setaffinity-np \
Ingo Molnarbb4c5502013-11-14 08:33:24 +0100210 stackprotector-all \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100211 timerfd \
Namhyung Kime92ce122014-10-31 16:51:38 +0900212 libdw-dwarf-unwind \
213 zlib
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200214
Jiri Olsa0695e572014-02-19 16:52:54 +0100215LIB_FEATURE_TESTS = \
216 dwarf \
217 glibc \
218 gtk2 \
219 libaudit \
220 libbfd \
221 libelf \
222 libnuma \
223 libperl \
224 libpython \
225 libslang \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100226 libunwind \
Namhyung Kime92ce122014-10-31 16:51:38 +0900227 libdw-dwarf-unwind \
228 zlib
Jiri Olsa0695e572014-02-19 16:52:54 +0100229
230VF_FEATURE_TESTS = \
231 backtrace \
232 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300233 sync-compare-and-swap \
Jiri Olsa0695e572014-02-19 16:52:54 +0100234 gtk2-infobar \
235 libelf-getphdrnum \
236 libelf-mmap \
237 libpython-version \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530238 pthread-attr-setaffinity-np \
Jiri Olsa0695e572014-02-19 16:52:54 +0100239 stackprotector-all \
240 timerfd \
241 libunwind-debug-frame \
Jiri Olsa2cf90402014-04-23 16:53:25 +0200242 bionic \
243 liberty \
244 liberty-z \
Adrian Huntere477f3f2014-10-23 18:16:03 -0300245 cplus-demangle \
246 compile-32 \
247 compile-x32
Jiri Olsa0695e572014-02-19 16:52:54 +0100248
Jiri Olsac4eb6c02014-01-07 13:47:18 +0100249# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
250# If in the future we need per-feature checks/flags for features not
251# mentioned in this list we need to refactor this ;-).
252set_test_all_flags = $(eval $(set_test_all_flags_code))
253define set_test_all_flags_code
254 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
255 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
256endef
257
258$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
259
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200260#
261# Special fast-path for the 'all features are available' case:
262#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200263$(call feature_check,all,$(MSG))
264
265#
266# Just in case the build freshly failed, make sure we print the
267# feature matrix:
268#
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200269ifeq ($(feature-all), 1)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200270 #
271 # test-all.c passed - just set all the core feature flags to 1:
272 #
273 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200274else
Chunwei Chen56560ec2013-12-21 13:48:11 +0800275 $(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 +0200276 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200277endif
278
Ingo Molnar90ac5422013-09-30 13:48:44 +0200279ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200280 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100281endif
282
Ingo Molnarfcf92582013-10-10 08:05:25 +0200283ifeq ($(DEBUG),0)
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200284 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200285 CFLAGS += -D_FORTIFY_SOURCE=2
286 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100287endif
288
Jiri Olsa2fe73742013-04-15 04:32:28 +0200289CFLAGS += -I$(src-perf)/util/include
290CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
Namhyung Kim8a625c12014-01-09 23:00:52 +0900291CFLAGS += -I$(srctree)/tools/include/
Jiri Olsa2fe73742013-04-15 04:32:28 +0200292CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
293CFLAGS += -I$(srctree)/arch/$(ARCH)/include
294CFLAGS += -I$(srctree)/include/uapi
295CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200296
297# $(obj-perf) for generated common-cmds.h
298# $(obj-perf)/util for generated bison/flex headers
299ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200300CFLAGS += -I$(obj-perf)/util
301CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200302endif
303
Jiri Olsa2fe73742013-04-15 04:32:28 +0200304CFLAGS += -I$(src-perf)/util
305CFLAGS += -I$(src-perf)
Robert Richter4e319022013-06-11 17:29:18 +0200306CFLAGS += -I$(LIB_INCLUDE)
Jiri Olsa7c537462013-05-24 14:35:23 +0200307
Jiri Olsa2fe73742013-04-15 04:32:28 +0200308CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100309
Adrian Hunterf6d31362014-07-14 13:02:53 +0300310ifeq ($(feature-sync-compare-and-swap), 1)
311 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
312endif
313
Vineet Gupta459a3df2015-01-13 19:13:24 +0530314ifeq ($(feature-pthread-attr-setaffinity-np), 1)
315 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
316endif
317
Jiri Olsa4e22db42013-05-24 14:35:24 +0200318ifndef NO_BIONIC
David Ahern5febff02013-10-29 10:43:15 -0600319 $(call feature_check,bionic)
Ingo Molnar78e9d652013-09-30 14:11:46 +0200320 ifeq ($(feature-bionic), 1)
321 BIONIC := 1
322 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
323 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
324 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100325endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100326
327ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200328 NO_DWARF := 1
329 NO_DEMANGLE := 1
330 NO_LIBUNWIND := 1
Jiri Olsa5ea84152014-02-19 16:52:57 +0100331 NO_LIBDW_DWARF_UNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100332else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200333 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200334 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200335 LIBC_SUPPORT := 1
336 endif
337 ifeq ($(BIONIC),1)
338 LIBC_SUPPORT := 1
339 endif
340 ifeq ($(LIBC_SUPPORT),1)
341 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100342
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200343 NO_LIBELF := 1
344 NO_DWARF := 1
345 NO_DEMANGLE := 1
Arnaldo Carvalho de Melo94589552014-03-25 09:35:11 -0300346 NO_LIBUNWIND := 1
347 NO_LIBDW_DWARF_UNWIND := 1
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200348 else
Arnaldo Carvalho de Melof9ca2d82014-06-05 12:46:04 -0300349 ifneq ($(filter s% -static%,$(LDFLAGS),),)
350 msg := $(error No static glibc found, please install glibc-static);
351 else
352 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
353 endif
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200354 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200355 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100356 ifndef NO_LIBDW_DWARF_UNWIND
357 ifneq ($(feature-libdw-dwarf-unwind),1)
358 NO_LIBDW_DWARF_UNWIND := 1
359 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
360 endif
361 endif
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200362 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200363 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);
364 NO_DWARF := 1
365 endif # Dwarf support
Ingo Molnar0648f832013-10-02 15:30:35 +0200366 endif # libelf support
Jiri Olsacf4cca12013-03-25 00:45:08 +0100367endif # NO_LIBELF
368
369ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200370 CFLAGS += -DHAVE_LIBELF_SUPPORT
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900371 EXTLIBS += -lelf
Jiri Olsa779724f2013-03-25 00:48:14 +0100372
Ingo Molnar8869b172013-09-30 15:02:28 +0200373 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200374 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
375 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100376
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200377 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200378 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
379 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100380
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200381 # include ARCH specific config
382 -include $(src-perf)/arch/$(ARCH)/Makefile
383
384 ifndef NO_DWARF
385 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
386 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
387 NO_DWARF := 1
388 else
389 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
390 LDFLAGS += $(LIBDW_LDFLAGS)
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900391 EXTLIBS += -ldw
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200392 endif # PERF_HAVE_DWARF_REGS
393 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100394endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100395
Anton Blanchard65ccb4f2014-08-25 18:25:06 +1000396ifeq ($(ARCH),powerpc)
397 ifndef NO_DWARF
398 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
399 endif
400endif
401
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100402ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200403 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100404 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
Ingo Molnar308e1e72013-10-07 10:30:47 +0200405 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100406 endif
407endif
408
409dwarf-post-unwind := 1
410dwarf-post-unwind-text := BUG
411
412# setup DWARF post unwinder
413ifdef NO_LIBUNWIND
414 ifdef NO_LIBDW_DWARF_UNWIND
415 msg := $(warning Disabling post unwind, no support found.);
416 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900417 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100418 dwarf-post-unwind-text := libdw
419 endif
420else
421 dwarf-post-unwind-text := libunwind
422 # Enable libunwind support by default.
423 ifndef NO_LIBDW_DWARF_UNWIND
424 NO_LIBDW_DWARF_UNWIND := 1
425 endif
426endif
427
428ifeq ($(dwarf-post-unwind),1)
429 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
Jiri Olsaf39e0422014-12-29 15:03:09 +0100430 $(call detected,CONFIG_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100431else
432 NO_DWARF_UNWIND := 1
433endif
434
435ifndef NO_LIBUNWIND
Jean Pihet8ab596a2014-04-28 14:32:33 +0200436 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100437 $(call feature_check,libunwind-debug-frame)
438 ifneq ($(feature-libunwind-debug-frame), 1)
439 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900440 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
441 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100442 else
443 # non-ARM has no dwarf_find_debug_frame() function:
444 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
445 endif
446 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
447 EXTLIBS += $(LIBUNWIND_LIBS)
448 CFLAGS += $(LIBUNWIND_CFLAGS)
449 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200450endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100451
452ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200453 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200454 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
455 NO_LIBAUDIT := 1
456 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200457 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200458 EXTLIBS += -laudit
459 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100460endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100461
462ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200463 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100464endif
465
466ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200467 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200468 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
469 NO_SLANG := 1
470 else
471 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
472 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200473 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200474 EXTLIBS += -lslang
475 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100476endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100477
478ifndef NO_GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000479 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200480 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200481 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
482 NO_GTK2 := 1
483 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200484 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900485 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200486 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200487 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000488 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
489 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200490 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200491 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100492endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100493
494grep-libs = $(filter -l%,$(1))
495strip-libs = $(filter-out -l%,$(1))
496
497ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200498 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100499else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200500 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
501 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
502 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
503 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
504 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100505
Ingo Molnar7181a672013-09-30 15:15:36 +0200506 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200507 CFLAGS += -DNO_LIBPERL
508 NO_LIBPERL := 1
Arnaldo Carvalho de Melo6a2f2542014-05-26 16:02:30 -0300509 msg := $(warning Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200510 else
511 LDFLAGS += $(PERL_EMBED_LDFLAGS)
512 EXTLIBS += $(PERL_EMBED_LIBADD)
513 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100514endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100515
David Ahern87419c92013-10-29 10:43:16 -0600516ifeq ($(feature-timerfd), 1)
517 CFLAGS += -DHAVE_TIMERFD_SUPPORT
518else
519 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
520endif
521
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100522disable-python = $(eval $(disable-python_code))
523define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100524 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100525 $(if $(1),$(warning No $(1) was found))
526 $(warning Python support will not be built)
527 NO_LIBPYTHON := 1
528endef
529
Namhyung Kim56c7d792014-07-29 15:57:19 +0900530ifdef NO_LIBPYTHON
531 $(call disable-python)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100532else
533
Namhyung Kim56c7d792014-07-29 15:57:19 +0900534 ifndef PYTHON
535 $(call disable-python,python interpreter)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100536 else
Namhyung Kim56c7d792014-07-29 15:57:19 +0900537 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100538
539 ifndef PYTHON_CONFIG
540 $(call disable-python,python-config tool)
541 else
542
543 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
544
545 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
546 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
547 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
548 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
549 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
550
Ingo Molnar97341632013-09-30 15:18:37 +0200551 ifneq ($(feature-libpython), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100552 $(call disable-python,Python.h (for Python 2.x))
553 else
554
Ingo Molnar95d061c2013-09-30 15:40:04 +0200555 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100556 $(warning Python 3 is not yet supported; please set)
557 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
558 $(warning If you also have Python 2 installed, then)
559 $(warning try something like:)
560 $(warning $(and ,))
561 $(warning $(and ,) make PYTHON=python2)
562 $(warning $(and ,))
563 $(warning Otherwise, disable Python support entirely:)
564 $(warning $(and ,))
565 $(warning $(and ,) make NO_LIBPYTHON=1)
566 $(warning $(and ,))
567 $(error $(and ,))
568 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100569 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100570 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200571 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100572 endif
573 endif
574 endif
575 endif
576endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100577
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200578ifeq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200579 EXTLIBS += -lbfd
580
581 # call all detections now so we get correct
582 # status in VF output
583 $(call feature_check,liberty)
584 $(call feature_check,liberty-z)
585 $(call feature_check,cplus-demangle)
586
587 ifeq ($(feature-liberty), 1)
588 EXTLIBS += -liberty
589 else
590 ifeq ($(feature-liberty-z), 1)
591 EXTLIBS += -liberty -lz
592 endif
593 endif
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200594endif
595
Jiri Olsac3cf8362013-03-18 00:38:16 +0100596ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200597 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100598else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200599 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200600 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200601 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200602 else
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200603 ifneq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200604 ifneq ($(feature-liberty), 1)
605 ifneq ($(feature-liberty-z), 1)
606 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
607 # or any of 'bfd iberty z' trinity
Ingo Molnar1c476612013-10-02 15:15:09 +0200608 ifeq ($(feature-cplus-demangle), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200609 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200610 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200611 else
612 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
613 CFLAGS += -DNO_DEMANGLE
614 endif
615 endif
616 endif
617 endif
618 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100619endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100620
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200621ifneq ($(filter -lbfd,$(EXTLIBS)),)
622 CFLAGS += -DHAVE_LIBBFD_SUPPORT
623endif
624
Namhyung Kime92ce122014-10-31 16:51:38 +0900625ifndef NO_ZLIB
626 ifeq ($(feature-zlib), 1)
627 CFLAGS += -DHAVE_ZLIB_SUPPORT
628 EXTLIBS += -lz
629 else
630 NO_ZLIB := 1
631 endif
632endif
633
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100634ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200635 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200636 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200637 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100638endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100639
640ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200641 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500642 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 +0200643 NO_LIBNUMA := 1
644 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200645 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200646 EXTLIBS += -lnuma
Jiri Olsa72965b82014-12-29 13:52:36 +0100647 $(call detected,CONFIG_NUMA)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200648 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100649endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100650
Alexander Yaryginda50ad62014-07-03 17:59:49 +0400651ifdef HAVE_KVM_STAT_SUPPORT
652 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
653endif
654
Adrian Huntere477f3f2014-10-23 18:16:03 -0300655ifeq (${IS_64_BIT}, 1)
656 ifndef NO_PERF_READ_VDSO32
657 $(call feature_check,compile-32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300658 ifeq ($(feature-compile-32), 1)
659 CFLAGS += -DHAVE_PERF_READ_VDSO32
660 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300661 NO_PERF_READ_VDSO32 := 1
662 endif
663 endif
664 ifneq (${IS_X86_64}, 1)
665 NO_PERF_READ_VDSOX32 := 1
666 endif
667 ifndef NO_PERF_READ_VDSOX32
668 $(call feature_check,compile-x32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300669 ifeq ($(feature-compile-x32), 1)
670 CFLAGS += -DHAVE_PERF_READ_VDSOX32
671 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300672 NO_PERF_READ_VDSOX32 := 1
673 endif
674 endif
675else
676 NO_PERF_READ_VDSO32 := 1
677 NO_PERF_READ_VDSOX32 := 1
678endif
679
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100680# Among the variables below, these:
681# perfexecdir
682# template_dir
683# mandir
684# infodir
685# htmldir
686# ETC_PERFCONFIG (but not sysconfdir)
687# can be specified as a relative path some/where/else;
688# this is interpreted as relative to $(prefix) and "perf" at
689# runtime figures out where they are based on the path to the executable.
690# This can help installing the suite in a relocatable way.
691
692# Make the path relative to DESTDIR, not to prefix
693ifndef DESTDIR
Jianyu Zhanfc9cabe2014-06-03 00:44:34 +0800694prefix ?= $(HOME)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100695endif
696bindir_relative = bin
697bindir = $(prefix)/$(bindir_relative)
698mandir = share/man
699infodir = share/info
700perfexecdir = libexec/perf-core
701sharedir = $(prefix)/share
702template_dir = share/perf-core/templates
703htmldir = share/doc/perf-doc
704ifeq ($(prefix),/usr)
705sysconfdir = /etc
706ETC_PERFCONFIG = $(sysconfdir)/perfconfig
707else
708sysconfdir = $(prefix)/etc
709ETC_PERFCONFIG = etc/perfconfig
710endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200711ifndef lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900712ifeq ($(IS_X86_64),1)
713lib = lib64
714else
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100715lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900716endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200717endif # lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900718libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100719
720# Shell quote (do not use $(call) to accommodate ancient setups);
721ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
722DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
723bindir_SQ = $(subst ','\'',$(bindir))
724mandir_SQ = $(subst ','\'',$(mandir))
725infodir_SQ = $(subst ','\'',$(infodir))
726perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
727template_dir_SQ = $(subst ','\'',$(template_dir))
728htmldir_SQ = $(subst ','\'',$(htmldir))
729prefix_SQ = $(subst ','\'',$(prefix))
730sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +0900731libdir_SQ = $(subst ','\'',$(libdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100732
733ifneq ($(filter /%,$(firstword $(perfexecdir))),)
734perfexec_instdir = $(perfexecdir)
735else
736perfexec_instdir = $(prefix)/$(perfexecdir)
737endif
738perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100739
740# If we install to $(HOME) we keep the traceevent default:
741# $(HOME)/.traceevent/plugins
742# Otherwise we install plugins into the global $(libdir).
743ifdef DESTDIR
744plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -0500745plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100746endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100747
748#
749# Print the result of the feature test:
750#
Jiri Olsa8d790762014-02-19 16:52:55 +0100751feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
Jiri Olsa0695e572014-02-19 16:52:54 +0100752
Jiri Olsa8d790762014-02-19 16:52:55 +0100753define feature_print_status_code
Jiri Olsa0695e572014-02-19 16:52:54 +0100754 ifeq ($(feature-$(1)), 1)
755 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
756 else
757 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
758 endif
759endef
760
Jiri Olsa8d790762014-02-19 16:52:55 +0100761feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
762define feature_print_var_code
763 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
764endef
765
766feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
767define feature_print_text_code
768 MSG = $(shell printf '...%30s: %s' $(1) $(2))
769endef
770
Jiri Olsa0695e572014-02-19 16:52:54 +0100771PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
772PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
773
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100774ifeq ($(dwarf-post-unwind),1)
775 PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
776endif
777
Jiri Olsa0695e572014-02-19 16:52:54 +0100778# The $(display_lib) controls the default detection message
779# output. It's set if:
780# - detected features differes from stored features from
781# last build (in PERF-FEATURES file)
782# - one of the $(LIB_FEATURE_TESTS) is not detected
783# - VF is enabled
784
785ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
786 $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
787 display_lib := 1
788endif
789
790feature_check = $(eval $(feature_check_code))
791define feature_check_code
792 ifneq ($(feature-$(1)), 1)
793 display_lib := 1
794 endif
795endef
796
797$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
798
799ifeq ($(VF),1)
800 display_lib := 1
801 display_vf := 1
802endif
803
804ifeq ($(display_lib),1)
805 $(info )
806 $(info Auto-detecting system features:)
Jiri Olsa8d790762014-02-19 16:52:55 +0100807 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100808
809 ifeq ($(dwarf-post-unwind),1)
810 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
811 endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100812endif
813
814ifeq ($(display_vf),1)
Jiri Olsa8d790762014-02-19 16:52:55 +0100815 $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
816 $(info )
817 $(call feature_print_var,prefix)
818 $(call feature_print_var,bindir)
819 $(call feature_print_var,libdir)
820 $(call feature_print_var,sysconfdir)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100821 $(call feature_print_var,LIBUNWIND_DIR)
822 $(call feature_print_var,LIBDW_DIR)
Jiri Olsa0695e572014-02-19 16:52:54 +0100823endif
824
825ifeq ($(display_lib),1)
826 $(info )
827endif
Jiri Olsaf39e0422014-12-29 15:03:09 +0100828
829$(call detected_var,bindir_SQ)
830$(call detected_var,PYTHON_WORD)
831ifneq ($(OUTPUT),)
832$(call detected_var,OUTPUT)
833endif