blob: 5f553989d8a136d9d28d9c1bb6ea9981a6e68c19 [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 Olsa9352aab2014-12-29 17:42:46 +0100125 $(call detected_var,PARSER_DEBUG_BISON)
126 $(call detected_var,PARSER_DEBUG_FLEX)
Jiri Olsa362493f2013-03-25 00:40:48 +0100127endif
128
Namhyung Kim56c7d792014-07-29 15:57:19 +0900129ifndef NO_LIBPYTHON
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200130 # Try different combinations to accommodate systems that only have
131 # python[2][-config] in weird combinations but always preferring
132 # python2 and python2-config as per pep-0394. If we catch a
133 # python[-config] in version 3, the version check will kill it.
134 PYTHON2 := $(if $(call get-executable,python2),python2,python)
135 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
136 PYTHON2_CONFIG := \
137 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
Namhyung Kim56c7d792014-07-29 15:57:19 +0900138 override PYTHON_CONFIG := \
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200139 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
Namhyung Kim56c7d792014-07-29 15:57:19 +0900140
141 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
142
143 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
144 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
145
146 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
147 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
148 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
149 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
150endif
151
Jiri Olsa2fe73742013-04-15 04:32:28 +0200152CFLAGS += -fno-omit-frame-pointer
153CFLAGS += -ggdb3
154CFLAGS += -funwind-tables
155CFLAGS += -Wall
156CFLAGS += -Wextra
157CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100158
Mathias Krause6392b4e2014-04-27 18:51:05 +0200159# Enforce a non-executable stack, as we may regress (again) in the future by
160# adding assembler files missing the .GNU-stack linker note.
161LDFLAGS += -Wl,-z,noexecstack
162
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900163EXTLIBS = -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +0100164
Ingo Molnar1c2d1d82013-10-03 15:05:56 +0200165ifneq ($(OUTPUT),)
166 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
167 $(shell mkdir -p $(OUTPUT_FEATURES))
168endif
169
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200170feature_check = $(eval $(feature_check_code))
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200171define feature_check_code
Chunwei Chen56560ec2013-12-21 13:48:11 +0800172 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 +0200173endef
174
175feature_set = $(eval $(feature_set_code))
176define feature_set_code
177 feature-$(1) := 1
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200178endef
179
180#
181# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
182#
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200183
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200184#
185# Note that this is not a complete list of all feature tests, just
186# those that are typically built on a fully configured system.
187#
188# [ Feature tests not mentioned here have to be built explicitly in
189# the rule that uses them - an example for that is the 'bionic'
190# feature check. ]
191#
192CORE_FEATURE_TESTS = \
193 backtrace \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200194 dwarf \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200195 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300196 sync-compare-and-swap \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200197 glibc \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200198 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200199 gtk2-infobar \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200200 libaudit \
201 libbfd \
202 libelf \
203 libelf-getphdrnum \
204 libelf-mmap \
205 libnuma \
Ingo Molnar7181a672013-09-30 15:15:36 +0200206 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200207 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200208 libpython-version \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200209 libslang \
210 libunwind \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530211 pthread-attr-setaffinity-np \
Ingo Molnarbb4c5502013-11-14 08:33:24 +0100212 stackprotector-all \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100213 timerfd \
Namhyung Kime92ce122014-10-31 16:51:38 +0900214 libdw-dwarf-unwind \
215 zlib
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200216
Jiri Olsa0695e572014-02-19 16:52:54 +0100217LIB_FEATURE_TESTS = \
218 dwarf \
219 glibc \
220 gtk2 \
221 libaudit \
222 libbfd \
223 libelf \
224 libnuma \
225 libperl \
226 libpython \
227 libslang \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100228 libunwind \
Namhyung Kime92ce122014-10-31 16:51:38 +0900229 libdw-dwarf-unwind \
230 zlib
Jiri Olsa0695e572014-02-19 16:52:54 +0100231
232VF_FEATURE_TESTS = \
233 backtrace \
234 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300235 sync-compare-and-swap \
Jiri Olsa0695e572014-02-19 16:52:54 +0100236 gtk2-infobar \
237 libelf-getphdrnum \
238 libelf-mmap \
239 libpython-version \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530240 pthread-attr-setaffinity-np \
Jiri Olsa0695e572014-02-19 16:52:54 +0100241 stackprotector-all \
242 timerfd \
243 libunwind-debug-frame \
Jiri Olsa2cf90402014-04-23 16:53:25 +0200244 bionic \
245 liberty \
246 liberty-z \
Adrian Huntere477f3f2014-10-23 18:16:03 -0300247 cplus-demangle \
248 compile-32 \
249 compile-x32
Jiri Olsa0695e572014-02-19 16:52:54 +0100250
Jiri Olsac4eb6c02014-01-07 13:47:18 +0100251# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
252# If in the future we need per-feature checks/flags for features not
253# mentioned in this list we need to refactor this ;-).
254set_test_all_flags = $(eval $(set_test_all_flags_code))
255define set_test_all_flags_code
256 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
257 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
258endef
259
260$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
261
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200262#
263# Special fast-path for the 'all features are available' case:
264#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200265$(call feature_check,all,$(MSG))
266
267#
268# Just in case the build freshly failed, make sure we print the
269# feature matrix:
270#
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200271ifeq ($(feature-all), 1)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200272 #
273 # test-all.c passed - just set all the core feature flags to 1:
274 #
275 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200276else
Chunwei Chen56560ec2013-12-21 13:48:11 +0800277 $(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 +0200278 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200279endif
280
Ingo Molnar90ac5422013-09-30 13:48:44 +0200281ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200282 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100283endif
284
Ingo Molnarfcf92582013-10-10 08:05:25 +0200285ifeq ($(DEBUG),0)
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200286 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200287 CFLAGS += -D_FORTIFY_SOURCE=2
288 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100289endif
290
Jiri Olsa2fe73742013-04-15 04:32:28 +0200291CFLAGS += -I$(src-perf)/util/include
292CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
Namhyung Kim8a625c12014-01-09 23:00:52 +0900293CFLAGS += -I$(srctree)/tools/include/
Jiri Olsa2fe73742013-04-15 04:32:28 +0200294CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
295CFLAGS += -I$(srctree)/arch/$(ARCH)/include
296CFLAGS += -I$(srctree)/include/uapi
297CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200298
299# $(obj-perf) for generated common-cmds.h
300# $(obj-perf)/util for generated bison/flex headers
301ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200302CFLAGS += -I$(obj-perf)/util
303CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200304endif
305
Jiri Olsa2fe73742013-04-15 04:32:28 +0200306CFLAGS += -I$(src-perf)/util
307CFLAGS += -I$(src-perf)
Robert Richter4e319022013-06-11 17:29:18 +0200308CFLAGS += -I$(LIB_INCLUDE)
Jiri Olsa7c537462013-05-24 14:35:23 +0200309
Jiri Olsa2fe73742013-04-15 04:32:28 +0200310CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100311
Adrian Hunterf6d31362014-07-14 13:02:53 +0300312ifeq ($(feature-sync-compare-and-swap), 1)
313 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
314endif
315
Vineet Gupta459a3df2015-01-13 19:13:24 +0530316ifeq ($(feature-pthread-attr-setaffinity-np), 1)
317 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
318endif
319
Jiri Olsa4e22db42013-05-24 14:35:24 +0200320ifndef NO_BIONIC
David Ahern5febff02013-10-29 10:43:15 -0600321 $(call feature_check,bionic)
Ingo Molnar78e9d652013-09-30 14:11:46 +0200322 ifeq ($(feature-bionic), 1)
323 BIONIC := 1
324 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
325 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
326 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100327endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100328
329ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200330 NO_DWARF := 1
331 NO_DEMANGLE := 1
332 NO_LIBUNWIND := 1
Jiri Olsa5ea84152014-02-19 16:52:57 +0100333 NO_LIBDW_DWARF_UNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100334else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200335 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200336 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200337 LIBC_SUPPORT := 1
338 endif
339 ifeq ($(BIONIC),1)
340 LIBC_SUPPORT := 1
341 endif
342 ifeq ($(LIBC_SUPPORT),1)
343 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100344
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200345 NO_LIBELF := 1
346 NO_DWARF := 1
347 NO_DEMANGLE := 1
Arnaldo Carvalho de Melo94589552014-03-25 09:35:11 -0300348 NO_LIBUNWIND := 1
349 NO_LIBDW_DWARF_UNWIND := 1
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200350 else
Arnaldo Carvalho de Melof9ca2d82014-06-05 12:46:04 -0300351 ifneq ($(filter s% -static%,$(LDFLAGS),),)
352 msg := $(error No static glibc found, please install glibc-static);
353 else
354 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
355 endif
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200356 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200357 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100358 ifndef NO_LIBDW_DWARF_UNWIND
359 ifneq ($(feature-libdw-dwarf-unwind),1)
360 NO_LIBDW_DWARF_UNWIND := 1
361 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
362 endif
363 endif
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200364 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200365 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);
366 NO_DWARF := 1
367 endif # Dwarf support
Ingo Molnar0648f832013-10-02 15:30:35 +0200368 endif # libelf support
Jiri Olsacf4cca12013-03-25 00:45:08 +0100369endif # NO_LIBELF
370
371ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200372 CFLAGS += -DHAVE_LIBELF_SUPPORT
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900373 EXTLIBS += -lelf
Jiri Olsa709e6792014-12-29 23:52:25 +0100374 $(call detected,CONFIG_LIBELF)
Jiri Olsa779724f2013-03-25 00:48:14 +0100375
Ingo Molnar8869b172013-09-30 15:02:28 +0200376 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200377 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
378 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100379
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200380 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200381 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
382 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100383
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200384 # include ARCH specific config
385 -include $(src-perf)/arch/$(ARCH)/Makefile
386
387 ifndef NO_DWARF
388 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
389 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
390 NO_DWARF := 1
391 else
392 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
393 LDFLAGS += $(LIBDW_LDFLAGS)
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900394 EXTLIBS += -ldw
Jiri Olsa8379fce2014-12-30 00:06:25 +0100395 $(call detected,CONFIG_DWARF)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200396 endif # PERF_HAVE_DWARF_REGS
397 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100398endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100399
Anton Blanchard65ccb4f2014-08-25 18:25:06 +1000400ifeq ($(ARCH),powerpc)
401 ifndef NO_DWARF
402 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
403 endif
404endif
405
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100406ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200407 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100408 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
Ingo Molnar308e1e72013-10-07 10:30:47 +0200409 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100410 endif
411endif
412
413dwarf-post-unwind := 1
414dwarf-post-unwind-text := BUG
415
416# setup DWARF post unwinder
417ifdef NO_LIBUNWIND
418 ifdef NO_LIBDW_DWARF_UNWIND
419 msg := $(warning Disabling post unwind, no support found.);
420 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900421 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100422 dwarf-post-unwind-text := libdw
423 endif
424else
425 dwarf-post-unwind-text := libunwind
426 # Enable libunwind support by default.
427 ifndef NO_LIBDW_DWARF_UNWIND
428 NO_LIBDW_DWARF_UNWIND := 1
429 endif
430endif
431
432ifeq ($(dwarf-post-unwind),1)
433 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
Jiri Olsaf39e0422014-12-29 15:03:09 +0100434 $(call detected,CONFIG_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100435else
436 NO_DWARF_UNWIND := 1
437endif
438
439ifndef NO_LIBUNWIND
Jean Pihet8ab596a2014-04-28 14:32:33 +0200440 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100441 $(call feature_check,libunwind-debug-frame)
442 ifneq ($(feature-libunwind-debug-frame), 1)
443 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900444 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
445 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100446 else
447 # non-ARM has no dwarf_find_debug_frame() function:
448 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
449 endif
450 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
451 EXTLIBS += $(LIBUNWIND_LIBS)
452 CFLAGS += $(LIBUNWIND_CFLAGS)
453 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200454endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100455
456ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200457 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200458 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
459 NO_LIBAUDIT := 1
460 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200461 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200462 EXTLIBS += -laudit
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100463 $(call detected,CONFIG_AUDIT)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200464 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100465endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100466
467ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200468 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100469endif
470
471ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200472 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200473 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
474 NO_SLANG := 1
475 else
476 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
477 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200478 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200479 EXTLIBS += -lslang
480 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100481endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100482
483ifndef NO_GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000484 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200485 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200486 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
487 NO_GTK2 := 1
488 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200489 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900490 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200491 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200492 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000493 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
494 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200495 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200496 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100497endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100498
499grep-libs = $(filter -l%,$(1))
500strip-libs = $(filter-out -l%,$(1))
501
502ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200503 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100504else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200505 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
506 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
507 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
508 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
509 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100510
Ingo Molnar7181a672013-09-30 15:15:36 +0200511 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200512 CFLAGS += -DNO_LIBPERL
513 NO_LIBPERL := 1
Arnaldo Carvalho de Melo6a2f2542014-05-26 16:02:30 -0300514 msg := $(warning Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200515 else
516 LDFLAGS += $(PERL_EMBED_LDFLAGS)
517 EXTLIBS += $(PERL_EMBED_LIBADD)
518 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100519endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100520
David Ahern87419c92013-10-29 10:43:16 -0600521ifeq ($(feature-timerfd), 1)
522 CFLAGS += -DHAVE_TIMERFD_SUPPORT
523else
524 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
525endif
526
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100527disable-python = $(eval $(disable-python_code))
528define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100529 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100530 $(if $(1),$(warning No $(1) was found))
531 $(warning Python support will not be built)
532 NO_LIBPYTHON := 1
533endef
534
Namhyung Kim56c7d792014-07-29 15:57:19 +0900535ifdef NO_LIBPYTHON
536 $(call disable-python)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100537else
538
Namhyung Kim56c7d792014-07-29 15:57:19 +0900539 ifndef PYTHON
540 $(call disable-python,python interpreter)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100541 else
Namhyung Kim56c7d792014-07-29 15:57:19 +0900542 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100543
544 ifndef PYTHON_CONFIG
545 $(call disable-python,python-config tool)
546 else
547
548 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
549
550 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
551 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
552 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
553 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
554 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
555
Ingo Molnar97341632013-09-30 15:18:37 +0200556 ifneq ($(feature-libpython), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100557 $(call disable-python,Python.h (for Python 2.x))
558 else
559
Ingo Molnar95d061c2013-09-30 15:40:04 +0200560 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100561 $(warning Python 3 is not yet supported; please set)
562 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
563 $(warning If you also have Python 2 installed, then)
564 $(warning try something like:)
565 $(warning $(and ,))
566 $(warning $(and ,) make PYTHON=python2)
567 $(warning $(and ,))
568 $(warning Otherwise, disable Python support entirely:)
569 $(warning $(and ,))
570 $(warning $(and ,) make NO_LIBPYTHON=1)
571 $(warning $(and ,))
572 $(error $(and ,))
573 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100574 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100575 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200576 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100577 endif
578 endif
579 endif
580 endif
581endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100582
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200583ifeq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200584 EXTLIBS += -lbfd
585
586 # call all detections now so we get correct
587 # status in VF output
588 $(call feature_check,liberty)
589 $(call feature_check,liberty-z)
590 $(call feature_check,cplus-demangle)
591
592 ifeq ($(feature-liberty), 1)
593 EXTLIBS += -liberty
594 else
595 ifeq ($(feature-liberty-z), 1)
596 EXTLIBS += -liberty -lz
597 endif
598 endif
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200599endif
600
Jiri Olsac3cf8362013-03-18 00:38:16 +0100601ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200602 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100603else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200604 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200605 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200606 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200607 else
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200608 ifneq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200609 ifneq ($(feature-liberty), 1)
610 ifneq ($(feature-liberty-z), 1)
611 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
612 # or any of 'bfd iberty z' trinity
Ingo Molnar1c476612013-10-02 15:15:09 +0200613 ifeq ($(feature-cplus-demangle), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200614 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200615 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200616 else
617 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
618 CFLAGS += -DNO_DEMANGLE
619 endif
620 endif
621 endif
622 endif
623 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100624endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100625
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200626ifneq ($(filter -lbfd,$(EXTLIBS)),)
627 CFLAGS += -DHAVE_LIBBFD_SUPPORT
628endif
629
Namhyung Kime92ce122014-10-31 16:51:38 +0900630ifndef NO_ZLIB
631 ifeq ($(feature-zlib), 1)
632 CFLAGS += -DHAVE_ZLIB_SUPPORT
633 EXTLIBS += -lz
634 else
635 NO_ZLIB := 1
636 endif
637endif
638
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100639ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200640 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200641 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200642 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100643endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100644
645ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200646 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500647 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 +0200648 NO_LIBNUMA := 1
649 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200650 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200651 EXTLIBS += -lnuma
Jiri Olsa72965b82014-12-29 13:52:36 +0100652 $(call detected,CONFIG_NUMA)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200653 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100654endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100655
Alexander Yaryginda50ad62014-07-03 17:59:49 +0400656ifdef HAVE_KVM_STAT_SUPPORT
657 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
658endif
659
Adrian Huntere477f3f2014-10-23 18:16:03 -0300660ifeq (${IS_64_BIT}, 1)
661 ifndef NO_PERF_READ_VDSO32
662 $(call feature_check,compile-32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300663 ifeq ($(feature-compile-32), 1)
664 CFLAGS += -DHAVE_PERF_READ_VDSO32
665 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300666 NO_PERF_READ_VDSO32 := 1
667 endif
668 endif
669 ifneq (${IS_X86_64}, 1)
670 NO_PERF_READ_VDSOX32 := 1
671 endif
672 ifndef NO_PERF_READ_VDSOX32
673 $(call feature_check,compile-x32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300674 ifeq ($(feature-compile-x32), 1)
675 CFLAGS += -DHAVE_PERF_READ_VDSOX32
676 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300677 NO_PERF_READ_VDSOX32 := 1
678 endif
679 endif
680else
681 NO_PERF_READ_VDSO32 := 1
682 NO_PERF_READ_VDSOX32 := 1
683endif
684
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100685# Among the variables below, these:
686# perfexecdir
687# template_dir
688# mandir
689# infodir
690# htmldir
691# ETC_PERFCONFIG (but not sysconfdir)
692# can be specified as a relative path some/where/else;
693# this is interpreted as relative to $(prefix) and "perf" at
694# runtime figures out where they are based on the path to the executable.
695# This can help installing the suite in a relocatable way.
696
697# Make the path relative to DESTDIR, not to prefix
698ifndef DESTDIR
Jianyu Zhanfc9cabe2014-06-03 00:44:34 +0800699prefix ?= $(HOME)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100700endif
701bindir_relative = bin
702bindir = $(prefix)/$(bindir_relative)
703mandir = share/man
704infodir = share/info
705perfexecdir = libexec/perf-core
706sharedir = $(prefix)/share
707template_dir = share/perf-core/templates
708htmldir = share/doc/perf-doc
709ifeq ($(prefix),/usr)
710sysconfdir = /etc
711ETC_PERFCONFIG = $(sysconfdir)/perfconfig
712else
713sysconfdir = $(prefix)/etc
714ETC_PERFCONFIG = etc/perfconfig
715endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200716ifndef lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900717ifeq ($(IS_X86_64),1)
718lib = lib64
719else
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100720lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900721endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200722endif # lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900723libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100724
725# Shell quote (do not use $(call) to accommodate ancient setups);
726ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
727DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
728bindir_SQ = $(subst ','\'',$(bindir))
729mandir_SQ = $(subst ','\'',$(mandir))
730infodir_SQ = $(subst ','\'',$(infodir))
731perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
732template_dir_SQ = $(subst ','\'',$(template_dir))
733htmldir_SQ = $(subst ','\'',$(htmldir))
734prefix_SQ = $(subst ','\'',$(prefix))
735sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +0900736libdir_SQ = $(subst ','\'',$(libdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100737
738ifneq ($(filter /%,$(firstword $(perfexecdir))),)
739perfexec_instdir = $(perfexecdir)
740else
741perfexec_instdir = $(prefix)/$(perfexecdir)
742endif
743perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100744
745# If we install to $(HOME) we keep the traceevent default:
746# $(HOME)/.traceevent/plugins
747# Otherwise we install plugins into the global $(libdir).
748ifdef DESTDIR
749plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -0500750plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100751endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100752
753#
754# Print the result of the feature test:
755#
Jiri Olsa8d790762014-02-19 16:52:55 +0100756feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
Jiri Olsa0695e572014-02-19 16:52:54 +0100757
Jiri Olsa8d790762014-02-19 16:52:55 +0100758define feature_print_status_code
Jiri Olsa0695e572014-02-19 16:52:54 +0100759 ifeq ($(feature-$(1)), 1)
760 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
761 else
762 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
763 endif
764endef
765
Jiri Olsa8d790762014-02-19 16:52:55 +0100766feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
767define feature_print_var_code
768 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
769endef
770
771feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
772define feature_print_text_code
773 MSG = $(shell printf '...%30s: %s' $(1) $(2))
774endef
775
Jiri Olsa0695e572014-02-19 16:52:54 +0100776PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
777PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
778
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100779ifeq ($(dwarf-post-unwind),1)
780 PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
781endif
782
Jiri Olsa0695e572014-02-19 16:52:54 +0100783# The $(display_lib) controls the default detection message
784# output. It's set if:
785# - detected features differes from stored features from
786# last build (in PERF-FEATURES file)
787# - one of the $(LIB_FEATURE_TESTS) is not detected
788# - VF is enabled
789
790ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
791 $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
792 display_lib := 1
793endif
794
795feature_check = $(eval $(feature_check_code))
796define feature_check_code
797 ifneq ($(feature-$(1)), 1)
798 display_lib := 1
799 endif
800endef
801
802$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
803
804ifeq ($(VF),1)
805 display_lib := 1
806 display_vf := 1
807endif
808
809ifeq ($(display_lib),1)
810 $(info )
811 $(info Auto-detecting system features:)
Jiri Olsa8d790762014-02-19 16:52:55 +0100812 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100813
814 ifeq ($(dwarf-post-unwind),1)
815 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
816 endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100817endif
818
819ifeq ($(display_vf),1)
Jiri Olsa8d790762014-02-19 16:52:55 +0100820 $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
821 $(info )
822 $(call feature_print_var,prefix)
823 $(call feature_print_var,bindir)
824 $(call feature_print_var,libdir)
825 $(call feature_print_var,sysconfdir)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100826 $(call feature_print_var,LIBUNWIND_DIR)
827 $(call feature_print_var,LIBDW_DIR)
Jiri Olsa0695e572014-02-19 16:52:54 +0100828endif
829
830ifeq ($(display_lib),1)
831 $(info )
832endif
Jiri Olsaf39e0422014-12-29 15:03:09 +0100833
834$(call detected_var,bindir_SQ)
835$(call detected_var,PYTHON_WORD)
836ifneq ($(OUTPUT),)
837$(call detected_var,OUTPUT)
838endif
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100839$(call detected_var,htmldir_SQ)
840$(call detected_var,infodir_SQ)
841$(call detected_var,mandir_SQ)
Jiri Olsa9352aab2014-12-29 17:42:46 +0100842$(call detected_var,ETC_PERFCONFIG_SQ)
843$(call detected_var,prefix_SQ)
844$(call detected_var,perfexecdir_SQ)