blob: 5b89bb7b2d7d032541609e5a998fed6f4c3b7e24 [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 Olsa779724f2013-03-25 00:48:14 +0100374
Ingo Molnar8869b172013-09-30 15:02:28 +0200375 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200376 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
377 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100378
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200379 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200380 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
381 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100382
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200383 # include ARCH specific config
384 -include $(src-perf)/arch/$(ARCH)/Makefile
385
386 ifndef NO_DWARF
387 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
388 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
389 NO_DWARF := 1
390 else
391 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
392 LDFLAGS += $(LIBDW_LDFLAGS)
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900393 EXTLIBS += -ldw
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200394 endif # PERF_HAVE_DWARF_REGS
395 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100396endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100397
Anton Blanchard65ccb4f2014-08-25 18:25:06 +1000398ifeq ($(ARCH),powerpc)
399 ifndef NO_DWARF
400 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
401 endif
402endif
403
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100404ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200405 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100406 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
Ingo Molnar308e1e72013-10-07 10:30:47 +0200407 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100408 endif
409endif
410
411dwarf-post-unwind := 1
412dwarf-post-unwind-text := BUG
413
414# setup DWARF post unwinder
415ifdef NO_LIBUNWIND
416 ifdef NO_LIBDW_DWARF_UNWIND
417 msg := $(warning Disabling post unwind, no support found.);
418 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900419 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100420 dwarf-post-unwind-text := libdw
421 endif
422else
423 dwarf-post-unwind-text := libunwind
424 # Enable libunwind support by default.
425 ifndef NO_LIBDW_DWARF_UNWIND
426 NO_LIBDW_DWARF_UNWIND := 1
427 endif
428endif
429
430ifeq ($(dwarf-post-unwind),1)
431 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
Jiri Olsaf39e0422014-12-29 15:03:09 +0100432 $(call detected,CONFIG_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100433else
434 NO_DWARF_UNWIND := 1
435endif
436
437ifndef NO_LIBUNWIND
Jean Pihet8ab596a2014-04-28 14:32:33 +0200438 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100439 $(call feature_check,libunwind-debug-frame)
440 ifneq ($(feature-libunwind-debug-frame), 1)
441 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900442 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
443 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100444 else
445 # non-ARM has no dwarf_find_debug_frame() function:
446 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
447 endif
448 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
449 EXTLIBS += $(LIBUNWIND_LIBS)
450 CFLAGS += $(LIBUNWIND_CFLAGS)
451 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200452endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100453
454ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200455 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200456 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
457 NO_LIBAUDIT := 1
458 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200459 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200460 EXTLIBS += -laudit
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100461 $(call detected,CONFIG_AUDIT)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200462 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100463endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100464
465ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200466 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100467endif
468
469ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200470 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200471 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
472 NO_SLANG := 1
473 else
474 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
475 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200476 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200477 EXTLIBS += -lslang
478 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100479endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100480
481ifndef NO_GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000482 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200483 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200484 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
485 NO_GTK2 := 1
486 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200487 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900488 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200489 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200490 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000491 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
492 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200493 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200494 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100495endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100496
497grep-libs = $(filter -l%,$(1))
498strip-libs = $(filter-out -l%,$(1))
499
500ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200501 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100502else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200503 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
504 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
505 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
506 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
507 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100508
Ingo Molnar7181a672013-09-30 15:15:36 +0200509 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200510 CFLAGS += -DNO_LIBPERL
511 NO_LIBPERL := 1
Arnaldo Carvalho de Melo6a2f2542014-05-26 16:02:30 -0300512 msg := $(warning Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200513 else
514 LDFLAGS += $(PERL_EMBED_LDFLAGS)
515 EXTLIBS += $(PERL_EMBED_LIBADD)
516 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100517endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100518
David Ahern87419c92013-10-29 10:43:16 -0600519ifeq ($(feature-timerfd), 1)
520 CFLAGS += -DHAVE_TIMERFD_SUPPORT
521else
522 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
523endif
524
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100525disable-python = $(eval $(disable-python_code))
526define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100527 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100528 $(if $(1),$(warning No $(1) was found))
529 $(warning Python support will not be built)
530 NO_LIBPYTHON := 1
531endef
532
Namhyung Kim56c7d792014-07-29 15:57:19 +0900533ifdef NO_LIBPYTHON
534 $(call disable-python)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100535else
536
Namhyung Kim56c7d792014-07-29 15:57:19 +0900537 ifndef PYTHON
538 $(call disable-python,python interpreter)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100539 else
Namhyung Kim56c7d792014-07-29 15:57:19 +0900540 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100541
542 ifndef PYTHON_CONFIG
543 $(call disable-python,python-config tool)
544 else
545
546 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
547
548 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
549 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
550 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
551 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
552 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
553
Ingo Molnar97341632013-09-30 15:18:37 +0200554 ifneq ($(feature-libpython), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100555 $(call disable-python,Python.h (for Python 2.x))
556 else
557
Ingo Molnar95d061c2013-09-30 15:40:04 +0200558 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100559 $(warning Python 3 is not yet supported; please set)
560 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
561 $(warning If you also have Python 2 installed, then)
562 $(warning try something like:)
563 $(warning $(and ,))
564 $(warning $(and ,) make PYTHON=python2)
565 $(warning $(and ,))
566 $(warning Otherwise, disable Python support entirely:)
567 $(warning $(and ,))
568 $(warning $(and ,) make NO_LIBPYTHON=1)
569 $(warning $(and ,))
570 $(error $(and ,))
571 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100572 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100573 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200574 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100575 endif
576 endif
577 endif
578 endif
579endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100580
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200581ifeq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200582 EXTLIBS += -lbfd
583
584 # call all detections now so we get correct
585 # status in VF output
586 $(call feature_check,liberty)
587 $(call feature_check,liberty-z)
588 $(call feature_check,cplus-demangle)
589
590 ifeq ($(feature-liberty), 1)
591 EXTLIBS += -liberty
592 else
593 ifeq ($(feature-liberty-z), 1)
594 EXTLIBS += -liberty -lz
595 endif
596 endif
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200597endif
598
Jiri Olsac3cf8362013-03-18 00:38:16 +0100599ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200600 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100601else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200602 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200603 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200604 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200605 else
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200606 ifneq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200607 ifneq ($(feature-liberty), 1)
608 ifneq ($(feature-liberty-z), 1)
609 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
610 # or any of 'bfd iberty z' trinity
Ingo Molnar1c476612013-10-02 15:15:09 +0200611 ifeq ($(feature-cplus-demangle), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200612 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200613 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200614 else
615 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
616 CFLAGS += -DNO_DEMANGLE
617 endif
618 endif
619 endif
620 endif
621 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100622endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100623
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200624ifneq ($(filter -lbfd,$(EXTLIBS)),)
625 CFLAGS += -DHAVE_LIBBFD_SUPPORT
626endif
627
Namhyung Kime92ce122014-10-31 16:51:38 +0900628ifndef NO_ZLIB
629 ifeq ($(feature-zlib), 1)
630 CFLAGS += -DHAVE_ZLIB_SUPPORT
631 EXTLIBS += -lz
632 else
633 NO_ZLIB := 1
634 endif
635endif
636
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100637ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200638 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200639 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200640 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100641endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100642
643ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200644 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500645 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 +0200646 NO_LIBNUMA := 1
647 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200648 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200649 EXTLIBS += -lnuma
Jiri Olsa72965b82014-12-29 13:52:36 +0100650 $(call detected,CONFIG_NUMA)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200651 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100652endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100653
Alexander Yaryginda50ad62014-07-03 17:59:49 +0400654ifdef HAVE_KVM_STAT_SUPPORT
655 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
656endif
657
Adrian Huntere477f3f2014-10-23 18:16:03 -0300658ifeq (${IS_64_BIT}, 1)
659 ifndef NO_PERF_READ_VDSO32
660 $(call feature_check,compile-32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300661 ifeq ($(feature-compile-32), 1)
662 CFLAGS += -DHAVE_PERF_READ_VDSO32
663 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300664 NO_PERF_READ_VDSO32 := 1
665 endif
666 endif
667 ifneq (${IS_X86_64}, 1)
668 NO_PERF_READ_VDSOX32 := 1
669 endif
670 ifndef NO_PERF_READ_VDSOX32
671 $(call feature_check,compile-x32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300672 ifeq ($(feature-compile-x32), 1)
673 CFLAGS += -DHAVE_PERF_READ_VDSOX32
674 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300675 NO_PERF_READ_VDSOX32 := 1
676 endif
677 endif
678else
679 NO_PERF_READ_VDSO32 := 1
680 NO_PERF_READ_VDSOX32 := 1
681endif
682
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100683# Among the variables below, these:
684# perfexecdir
685# template_dir
686# mandir
687# infodir
688# htmldir
689# ETC_PERFCONFIG (but not sysconfdir)
690# can be specified as a relative path some/where/else;
691# this is interpreted as relative to $(prefix) and "perf" at
692# runtime figures out where they are based on the path to the executable.
693# This can help installing the suite in a relocatable way.
694
695# Make the path relative to DESTDIR, not to prefix
696ifndef DESTDIR
Jianyu Zhanfc9cabe2014-06-03 00:44:34 +0800697prefix ?= $(HOME)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100698endif
699bindir_relative = bin
700bindir = $(prefix)/$(bindir_relative)
701mandir = share/man
702infodir = share/info
703perfexecdir = libexec/perf-core
704sharedir = $(prefix)/share
705template_dir = share/perf-core/templates
706htmldir = share/doc/perf-doc
707ifeq ($(prefix),/usr)
708sysconfdir = /etc
709ETC_PERFCONFIG = $(sysconfdir)/perfconfig
710else
711sysconfdir = $(prefix)/etc
712ETC_PERFCONFIG = etc/perfconfig
713endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200714ifndef lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900715ifeq ($(IS_X86_64),1)
716lib = lib64
717else
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100718lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900719endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200720endif # lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900721libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100722
723# Shell quote (do not use $(call) to accommodate ancient setups);
724ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
725DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
726bindir_SQ = $(subst ','\'',$(bindir))
727mandir_SQ = $(subst ','\'',$(mandir))
728infodir_SQ = $(subst ','\'',$(infodir))
729perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
730template_dir_SQ = $(subst ','\'',$(template_dir))
731htmldir_SQ = $(subst ','\'',$(htmldir))
732prefix_SQ = $(subst ','\'',$(prefix))
733sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +0900734libdir_SQ = $(subst ','\'',$(libdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100735
736ifneq ($(filter /%,$(firstword $(perfexecdir))),)
737perfexec_instdir = $(perfexecdir)
738else
739perfexec_instdir = $(prefix)/$(perfexecdir)
740endif
741perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100742
743# If we install to $(HOME) we keep the traceevent default:
744# $(HOME)/.traceevent/plugins
745# Otherwise we install plugins into the global $(libdir).
746ifdef DESTDIR
747plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -0500748plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100749endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100750
751#
752# Print the result of the feature test:
753#
Jiri Olsa8d790762014-02-19 16:52:55 +0100754feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
Jiri Olsa0695e572014-02-19 16:52:54 +0100755
Jiri Olsa8d790762014-02-19 16:52:55 +0100756define feature_print_status_code
Jiri Olsa0695e572014-02-19 16:52:54 +0100757 ifeq ($(feature-$(1)), 1)
758 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
759 else
760 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
761 endif
762endef
763
Jiri Olsa8d790762014-02-19 16:52:55 +0100764feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
765define feature_print_var_code
766 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
767endef
768
769feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
770define feature_print_text_code
771 MSG = $(shell printf '...%30s: %s' $(1) $(2))
772endef
773
Jiri Olsa0695e572014-02-19 16:52:54 +0100774PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
775PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
776
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100777ifeq ($(dwarf-post-unwind),1)
778 PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
779endif
780
Jiri Olsa0695e572014-02-19 16:52:54 +0100781# The $(display_lib) controls the default detection message
782# output. It's set if:
783# - detected features differes from stored features from
784# last build (in PERF-FEATURES file)
785# - one of the $(LIB_FEATURE_TESTS) is not detected
786# - VF is enabled
787
788ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
789 $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
790 display_lib := 1
791endif
792
793feature_check = $(eval $(feature_check_code))
794define feature_check_code
795 ifneq ($(feature-$(1)), 1)
796 display_lib := 1
797 endif
798endef
799
800$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
801
802ifeq ($(VF),1)
803 display_lib := 1
804 display_vf := 1
805endif
806
807ifeq ($(display_lib),1)
808 $(info )
809 $(info Auto-detecting system features:)
Jiri Olsa8d790762014-02-19 16:52:55 +0100810 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100811
812 ifeq ($(dwarf-post-unwind),1)
813 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
814 endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100815endif
816
817ifeq ($(display_vf),1)
Jiri Olsa8d790762014-02-19 16:52:55 +0100818 $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
819 $(info )
820 $(call feature_print_var,prefix)
821 $(call feature_print_var,bindir)
822 $(call feature_print_var,libdir)
823 $(call feature_print_var,sysconfdir)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100824 $(call feature_print_var,LIBUNWIND_DIR)
825 $(call feature_print_var,LIBDW_DIR)
Jiri Olsa0695e572014-02-19 16:52:54 +0100826endif
827
828ifeq ($(display_lib),1)
829 $(info )
830endif
Jiri Olsaf39e0422014-12-29 15:03:09 +0100831
832$(call detected_var,bindir_SQ)
833$(call detected_var,PYTHON_WORD)
834ifneq ($(OUTPUT),)
835$(call detected_var,OUTPUT)
836endif
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100837$(call detected_var,htmldir_SQ)
838$(call detected_var,infodir_SQ)
839$(call detected_var,mandir_SQ)
Jiri Olsa9352aab2014-12-29 17:42:46 +0100840$(call detected_var,ETC_PERFCONFIG_SQ)
841$(call detected_var,prefix_SQ)
842$(call detected_var,perfexecdir_SQ)