blob: 3e90fcab709dc270fd3c38cbec049de187baadef [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
23NO_PERF_REGS := 1
24
25# Additional ARCH settings for x86
26ifeq ($(ARCH),x86)
Namhyung Kimc6e5e9f2015-01-12 10:20:55 +080027 ifeq (${IS_64_BIT}, 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +020028 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020029 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
Adrian Hunter8a0c4c22013-11-01 15:51:32 +020030 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
Jiri Olsa72965b82014-12-29 13:52:36 +010031 $(call detected,CONFIG_X86_64)
Adrian Hunter8a0c4c22013-11-01 15:51:32 +020032 else
33 LIBUNWIND_LIBS = -lunwind -lunwind-x86
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020034 endif
35 NO_PERF_REGS := 0
Jiri Olsa8bd407b2013-03-15 16:28:49 +010036endif
Jean Pihet8ab596a2014-04-28 14:32:33 +020037
Will Deacon7495f372013-09-26 12:36:36 +010038ifeq ($(ARCH),arm)
39 NO_PERF_REGS := 0
40 LIBUNWIND_LIBS = -lunwind -lunwind-arm
41endif
Jiri Olsa8bd407b2013-03-15 16:28:49 +010042
Jean Pihet8ab596a2014-04-28 14:32:33 +020043ifeq ($(ARCH),arm64)
44 NO_PERF_REGS := 0
45 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
46endif
47
Jean Pihet90fa9de2014-05-16 10:41:11 +020048# So far there's only x86 and arm libdw unwind support merged in perf.
Jiri Olsa4dc549e2014-04-20 10:50:00 +020049# Disable it on all other architectures in case libdw unwind
50# support is detected in system. Add supported architectures
51# to the check.
Jean Pihet90fa9de2014-05-16 10:41:11 +020052ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
Jiri Olsa4dc549e2014-04-20 10:50:00 +020053 NO_LIBDW_DWARF_UNWIND := 1
54endif
55
Jean Pihet1448fef2013-12-10 13:24:04 +010056ifeq ($(LIBUNWIND_LIBS),)
57 NO_LIBUNWIND := 1
58else
59 #
60 # For linking with debug library, run like:
61 #
62 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
63 #
64 ifdef LIBUNWIND_DIR
65 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
66 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
67 endif
68 LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
69
70 # Set per-feature check compilation flags
71 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
72 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
73 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
74 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
Jean Pihet1448fef2013-12-10 13:24:04 +010075endif
76
Jiri Olsa8bd407b2013-03-15 16:28:49 +010077ifeq ($(NO_PERF_REGS),0)
Ingo Molnar89fe8082013-09-30 12:07:11 +020078 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
Jiri Olsa8bd407b2013-03-15 16:28:49 +010079endif
Jiri Olsaa32f4932013-03-25 00:32:01 +010080
Jiri Olsa45757892014-02-19 16:52:56 +010081ifndef NO_LIBELF
82 # for linking with debug library, run like:
83 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
84 ifdef LIBDW_DIR
85 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
86 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
Jiri Olsa45757892014-02-19 16:52:56 +010087 endif
Ramkumar Ramachandra2c529e42014-03-26 18:44:05 -040088 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
89 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
Jiri Olsa45757892014-02-19 16:52:56 +010090endif
91
Jiri Olsa7c537462013-05-24 14:35:23 +020092# include ARCH specific config
93-include $(src-perf)/arch/$(ARCH)/Makefile
94
Jiri Olsa7c537462013-05-24 14:35:23 +020095include $(src-perf)/config/utilities.mak
Jiri Olsaa32f4932013-03-25 00:32:01 +010096
97ifeq ($(call get-executable,$(FLEX)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020098 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +010099endif
100
101ifeq ($(call get-executable,$(BISON)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200102 dummy := $(error Error: $(BISON) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100103endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100104
105# Treat warnings as errors unless directed not to
106ifneq ($(WERROR),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200107 CFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +0100108endif
109
Adrian Hunter74af3772013-10-22 10:34:05 +0300110ifndef DEBUG
111 DEBUG := 0
112endif
113
Ingo Molnarfcf92582013-10-10 08:05:25 +0200114ifeq ($(DEBUG),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200115 CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +0100116endif
117
118ifdef PARSER_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200119 PARSER_DEBUG_BISON := -t
120 PARSER_DEBUG_FLEX := -d
121 CFLAGS += -DPARSER_DEBUG
Jiri Olsa362493f2013-03-25 00:40:48 +0100122endif
123
Namhyung Kim56c7d792014-07-29 15:57:19 +0900124ifndef NO_LIBPYTHON
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200125 # Try different combinations to accommodate systems that only have
126 # python[2][-config] in weird combinations but always preferring
127 # python2 and python2-config as per pep-0394. If we catch a
128 # python[-config] in version 3, the version check will kill it.
129 PYTHON2 := $(if $(call get-executable,python2),python2,python)
130 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
131 PYTHON2_CONFIG := \
132 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
Namhyung Kim56c7d792014-07-29 15:57:19 +0900133 override PYTHON_CONFIG := \
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200134 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
Namhyung Kim56c7d792014-07-29 15:57:19 +0900135
136 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
137
138 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
139 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
140
141 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
142 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
143 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
144 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
145endif
146
Jiri Olsa2fe73742013-04-15 04:32:28 +0200147CFLAGS += -fno-omit-frame-pointer
148CFLAGS += -ggdb3
149CFLAGS += -funwind-tables
150CFLAGS += -Wall
151CFLAGS += -Wextra
152CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100153
Mathias Krause6392b4e2014-04-27 18:51:05 +0200154# Enforce a non-executable stack, as we may regress (again) in the future by
155# adding assembler files missing the .GNU-stack linker note.
156LDFLAGS += -Wl,-z,noexecstack
157
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900158EXTLIBS = -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +0100159
Ingo Molnar1c2d1d82013-10-03 15:05:56 +0200160ifneq ($(OUTPUT),)
161 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
162 $(shell mkdir -p $(OUTPUT_FEATURES))
163endif
164
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200165feature_check = $(eval $(feature_check_code))
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200166define feature_check_code
Chunwei Chen56560ec2013-12-21 13:48:11 +0800167 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 +0200168endef
169
170feature_set = $(eval $(feature_set_code))
171define feature_set_code
172 feature-$(1) := 1
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200173endef
174
175#
176# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
177#
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200178
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200179#
180# Note that this is not a complete list of all feature tests, just
181# those that are typically built on a fully configured system.
182#
183# [ Feature tests not mentioned here have to be built explicitly in
184# the rule that uses them - an example for that is the 'bionic'
185# feature check. ]
186#
187CORE_FEATURE_TESTS = \
188 backtrace \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200189 dwarf \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200190 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300191 sync-compare-and-swap \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200192 glibc \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200193 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200194 gtk2-infobar \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200195 libaudit \
196 libbfd \
197 libelf \
198 libelf-getphdrnum \
199 libelf-mmap \
200 libnuma \
Ingo Molnar7181a672013-09-30 15:15:36 +0200201 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200202 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200203 libpython-version \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200204 libslang \
205 libunwind \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530206 pthread-attr-setaffinity-np \
Ingo Molnarbb4c5502013-11-14 08:33:24 +0100207 stackprotector-all \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100208 timerfd \
Namhyung Kime92ce122014-10-31 16:51:38 +0900209 libdw-dwarf-unwind \
210 zlib
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200211
Jiri Olsa0695e572014-02-19 16:52:54 +0100212LIB_FEATURE_TESTS = \
213 dwarf \
214 glibc \
215 gtk2 \
216 libaudit \
217 libbfd \
218 libelf \
219 libnuma \
220 libperl \
221 libpython \
222 libslang \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100223 libunwind \
Namhyung Kime92ce122014-10-31 16:51:38 +0900224 libdw-dwarf-unwind \
225 zlib
Jiri Olsa0695e572014-02-19 16:52:54 +0100226
227VF_FEATURE_TESTS = \
228 backtrace \
229 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300230 sync-compare-and-swap \
Jiri Olsa0695e572014-02-19 16:52:54 +0100231 gtk2-infobar \
232 libelf-getphdrnum \
233 libelf-mmap \
234 libpython-version \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530235 pthread-attr-setaffinity-np \
Jiri Olsa0695e572014-02-19 16:52:54 +0100236 stackprotector-all \
237 timerfd \
238 libunwind-debug-frame \
Jiri Olsa2cf90402014-04-23 16:53:25 +0200239 bionic \
240 liberty \
241 liberty-z \
Adrian Huntere477f3f2014-10-23 18:16:03 -0300242 cplus-demangle \
243 compile-32 \
244 compile-x32
Jiri Olsa0695e572014-02-19 16:52:54 +0100245
Jiri Olsac4eb6c02014-01-07 13:47:18 +0100246# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
247# If in the future we need per-feature checks/flags for features not
248# mentioned in this list we need to refactor this ;-).
249set_test_all_flags = $(eval $(set_test_all_flags_code))
250define set_test_all_flags_code
251 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
252 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
253endef
254
255$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
256
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200257#
258# Special fast-path for the 'all features are available' case:
259#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200260$(call feature_check,all,$(MSG))
261
262#
263# Just in case the build freshly failed, make sure we print the
264# feature matrix:
265#
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200266ifeq ($(feature-all), 1)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200267 #
268 # test-all.c passed - just set all the core feature flags to 1:
269 #
270 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200271else
Chunwei Chen56560ec2013-12-21 13:48:11 +0800272 $(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 +0200273 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200274endif
275
Ingo Molnar90ac5422013-09-30 13:48:44 +0200276ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200277 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100278endif
279
Ingo Molnarfcf92582013-10-10 08:05:25 +0200280ifeq ($(DEBUG),0)
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200281 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200282 CFLAGS += -D_FORTIFY_SOURCE=2
283 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100284endif
285
Jiri Olsa2fe73742013-04-15 04:32:28 +0200286CFLAGS += -I$(src-perf)/util/include
287CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
Namhyung Kim8a625c12014-01-09 23:00:52 +0900288CFLAGS += -I$(srctree)/tools/include/
Jiri Olsa2fe73742013-04-15 04:32:28 +0200289CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
290CFLAGS += -I$(srctree)/arch/$(ARCH)/include
291CFLAGS += -I$(srctree)/include/uapi
292CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200293
294# $(obj-perf) for generated common-cmds.h
295# $(obj-perf)/util for generated bison/flex headers
296ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200297CFLAGS += -I$(obj-perf)/util
298CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200299endif
300
Jiri Olsa2fe73742013-04-15 04:32:28 +0200301CFLAGS += -I$(src-perf)/util
302CFLAGS += -I$(src-perf)
Robert Richter4e319022013-06-11 17:29:18 +0200303CFLAGS += -I$(LIB_INCLUDE)
Jiri Olsa7c537462013-05-24 14:35:23 +0200304
Jiri Olsa2fe73742013-04-15 04:32:28 +0200305CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100306
Adrian Hunterf6d31362014-07-14 13:02:53 +0300307ifeq ($(feature-sync-compare-and-swap), 1)
308 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
309endif
310
Vineet Gupta459a3df2015-01-13 19:13:24 +0530311ifeq ($(feature-pthread-attr-setaffinity-np), 1)
312 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
313endif
314
Jiri Olsa4e22db42013-05-24 14:35:24 +0200315ifndef NO_BIONIC
David Ahern5febff02013-10-29 10:43:15 -0600316 $(call feature_check,bionic)
Ingo Molnar78e9d652013-09-30 14:11:46 +0200317 ifeq ($(feature-bionic), 1)
318 BIONIC := 1
319 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
320 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
321 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100322endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100323
324ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200325 NO_DWARF := 1
326 NO_DEMANGLE := 1
327 NO_LIBUNWIND := 1
Jiri Olsa5ea84152014-02-19 16:52:57 +0100328 NO_LIBDW_DWARF_UNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100329else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200330 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200331 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200332 LIBC_SUPPORT := 1
333 endif
334 ifeq ($(BIONIC),1)
335 LIBC_SUPPORT := 1
336 endif
337 ifeq ($(LIBC_SUPPORT),1)
338 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100339
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200340 NO_LIBELF := 1
341 NO_DWARF := 1
342 NO_DEMANGLE := 1
Arnaldo Carvalho de Melo94589552014-03-25 09:35:11 -0300343 NO_LIBUNWIND := 1
344 NO_LIBDW_DWARF_UNWIND := 1
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200345 else
Arnaldo Carvalho de Melof9ca2d82014-06-05 12:46:04 -0300346 ifneq ($(filter s% -static%,$(LDFLAGS),),)
347 msg := $(error No static glibc found, please install glibc-static);
348 else
349 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
350 endif
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200351 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200352 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100353 ifndef NO_LIBDW_DWARF_UNWIND
354 ifneq ($(feature-libdw-dwarf-unwind),1)
355 NO_LIBDW_DWARF_UNWIND := 1
356 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
357 endif
358 endif
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200359 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200360 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);
361 NO_DWARF := 1
362 endif # Dwarf support
Ingo Molnar0648f832013-10-02 15:30:35 +0200363 endif # libelf support
Jiri Olsacf4cca12013-03-25 00:45:08 +0100364endif # NO_LIBELF
365
366ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200367 CFLAGS += -DHAVE_LIBELF_SUPPORT
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900368 EXTLIBS += -lelf
Jiri Olsa779724f2013-03-25 00:48:14 +0100369
Ingo Molnar8869b172013-09-30 15:02:28 +0200370 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200371 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
372 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100373
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200374 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200375 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
376 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100377
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200378 # include ARCH specific config
379 -include $(src-perf)/arch/$(ARCH)/Makefile
380
381 ifndef NO_DWARF
382 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
383 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
384 NO_DWARF := 1
385 else
386 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
387 LDFLAGS += $(LIBDW_LDFLAGS)
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900388 EXTLIBS += -ldw
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200389 endif # PERF_HAVE_DWARF_REGS
390 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100391endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100392
Anton Blanchard65ccb4f2014-08-25 18:25:06 +1000393ifeq ($(ARCH),powerpc)
394 ifndef NO_DWARF
395 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
396 endif
397endif
398
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100399ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200400 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100401 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
Ingo Molnar308e1e72013-10-07 10:30:47 +0200402 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100403 endif
404endif
405
406dwarf-post-unwind := 1
407dwarf-post-unwind-text := BUG
408
409# setup DWARF post unwinder
410ifdef NO_LIBUNWIND
411 ifdef NO_LIBDW_DWARF_UNWIND
412 msg := $(warning Disabling post unwind, no support found.);
413 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900414 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100415 dwarf-post-unwind-text := libdw
416 endif
417else
418 dwarf-post-unwind-text := libunwind
419 # Enable libunwind support by default.
420 ifndef NO_LIBDW_DWARF_UNWIND
421 NO_LIBDW_DWARF_UNWIND := 1
422 endif
423endif
424
425ifeq ($(dwarf-post-unwind),1)
426 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
427else
428 NO_DWARF_UNWIND := 1
429endif
430
431ifndef NO_LIBUNWIND
Jean Pihet8ab596a2014-04-28 14:32:33 +0200432 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100433 $(call feature_check,libunwind-debug-frame)
434 ifneq ($(feature-libunwind-debug-frame), 1)
435 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900436 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
437 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100438 else
439 # non-ARM has no dwarf_find_debug_frame() function:
440 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
441 endif
442 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
443 EXTLIBS += $(LIBUNWIND_LIBS)
444 CFLAGS += $(LIBUNWIND_CFLAGS)
445 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200446endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100447
448ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200449 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200450 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
451 NO_LIBAUDIT := 1
452 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200453 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200454 EXTLIBS += -laudit
455 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100456endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100457
458ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200459 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100460endif
461
462ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200463 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200464 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
465 NO_SLANG := 1
466 else
467 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
468 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200469 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200470 EXTLIBS += -lslang
471 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100472endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100473
474ifndef NO_GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000475 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200476 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200477 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
478 NO_GTK2 := 1
479 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200480 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900481 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200482 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200483 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000484 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
485 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200486 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200487 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100488endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100489
490grep-libs = $(filter -l%,$(1))
491strip-libs = $(filter-out -l%,$(1))
492
493ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200494 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100495else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200496 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
497 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
498 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
499 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
500 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100501
Ingo Molnar7181a672013-09-30 15:15:36 +0200502 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200503 CFLAGS += -DNO_LIBPERL
504 NO_LIBPERL := 1
Arnaldo Carvalho de Melo6a2f2542014-05-26 16:02:30 -0300505 msg := $(warning Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200506 else
507 LDFLAGS += $(PERL_EMBED_LDFLAGS)
508 EXTLIBS += $(PERL_EMBED_LIBADD)
509 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100510endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100511
David Ahern87419c92013-10-29 10:43:16 -0600512ifeq ($(feature-timerfd), 1)
513 CFLAGS += -DHAVE_TIMERFD_SUPPORT
514else
515 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
516endif
517
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100518disable-python = $(eval $(disable-python_code))
519define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100520 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100521 $(if $(1),$(warning No $(1) was found))
522 $(warning Python support will not be built)
523 NO_LIBPYTHON := 1
524endef
525
Namhyung Kim56c7d792014-07-29 15:57:19 +0900526ifdef NO_LIBPYTHON
527 $(call disable-python)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100528else
529
Namhyung Kim56c7d792014-07-29 15:57:19 +0900530 ifndef PYTHON
531 $(call disable-python,python interpreter)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100532 else
Namhyung Kim56c7d792014-07-29 15:57:19 +0900533 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100534
535 ifndef PYTHON_CONFIG
536 $(call disable-python,python-config tool)
537 else
538
539 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
540
541 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
542 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
543 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
544 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
545 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
546
Ingo Molnar97341632013-09-30 15:18:37 +0200547 ifneq ($(feature-libpython), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100548 $(call disable-python,Python.h (for Python 2.x))
549 else
550
Ingo Molnar95d061c2013-09-30 15:40:04 +0200551 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100552 $(warning Python 3 is not yet supported; please set)
553 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
554 $(warning If you also have Python 2 installed, then)
555 $(warning try something like:)
556 $(warning $(and ,))
557 $(warning $(and ,) make PYTHON=python2)
558 $(warning $(and ,))
559 $(warning Otherwise, disable Python support entirely:)
560 $(warning $(and ,))
561 $(warning $(and ,) make NO_LIBPYTHON=1)
562 $(warning $(and ,))
563 $(error $(and ,))
564 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100565 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100566 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200567 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100568 endif
569 endif
570 endif
571 endif
572endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100573
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200574ifeq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200575 EXTLIBS += -lbfd
576
577 # call all detections now so we get correct
578 # status in VF output
579 $(call feature_check,liberty)
580 $(call feature_check,liberty-z)
581 $(call feature_check,cplus-demangle)
582
583 ifeq ($(feature-liberty), 1)
584 EXTLIBS += -liberty
585 else
586 ifeq ($(feature-liberty-z), 1)
587 EXTLIBS += -liberty -lz
588 endif
589 endif
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200590endif
591
Jiri Olsac3cf8362013-03-18 00:38:16 +0100592ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200593 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100594else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200595 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200596 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200597 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200598 else
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200599 ifneq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200600 ifneq ($(feature-liberty), 1)
601 ifneq ($(feature-liberty-z), 1)
602 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
603 # or any of 'bfd iberty z' trinity
Ingo Molnar1c476612013-10-02 15:15:09 +0200604 ifeq ($(feature-cplus-demangle), 1)
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
608 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
609 CFLAGS += -DNO_DEMANGLE
610 endif
611 endif
612 endif
613 endif
614 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100615endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100616
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200617ifneq ($(filter -lbfd,$(EXTLIBS)),)
618 CFLAGS += -DHAVE_LIBBFD_SUPPORT
619endif
620
Namhyung Kime92ce122014-10-31 16:51:38 +0900621ifndef NO_ZLIB
622 ifeq ($(feature-zlib), 1)
623 CFLAGS += -DHAVE_ZLIB_SUPPORT
624 EXTLIBS += -lz
625 else
626 NO_ZLIB := 1
627 endif
628endif
629
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100630ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200631 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200632 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200633 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100634endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100635
636ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200637 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500638 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 +0200639 NO_LIBNUMA := 1
640 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200641 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200642 EXTLIBS += -lnuma
Jiri Olsa72965b82014-12-29 13:52:36 +0100643 $(call detected,CONFIG_NUMA)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200644 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100645endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100646
Alexander Yaryginda50ad62014-07-03 17:59:49 +0400647ifdef HAVE_KVM_STAT_SUPPORT
648 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
649endif
650
Adrian Huntere477f3f2014-10-23 18:16:03 -0300651ifeq (${IS_64_BIT}, 1)
652 ifndef NO_PERF_READ_VDSO32
653 $(call feature_check,compile-32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300654 ifeq ($(feature-compile-32), 1)
655 CFLAGS += -DHAVE_PERF_READ_VDSO32
656 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300657 NO_PERF_READ_VDSO32 := 1
658 endif
659 endif
660 ifneq (${IS_X86_64}, 1)
661 NO_PERF_READ_VDSOX32 := 1
662 endif
663 ifndef NO_PERF_READ_VDSOX32
664 $(call feature_check,compile-x32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300665 ifeq ($(feature-compile-x32), 1)
666 CFLAGS += -DHAVE_PERF_READ_VDSOX32
667 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300668 NO_PERF_READ_VDSOX32 := 1
669 endif
670 endif
671else
672 NO_PERF_READ_VDSO32 := 1
673 NO_PERF_READ_VDSOX32 := 1
674endif
675
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100676# Among the variables below, these:
677# perfexecdir
678# template_dir
679# mandir
680# infodir
681# htmldir
682# ETC_PERFCONFIG (but not sysconfdir)
683# can be specified as a relative path some/where/else;
684# this is interpreted as relative to $(prefix) and "perf" at
685# runtime figures out where they are based on the path to the executable.
686# This can help installing the suite in a relocatable way.
687
688# Make the path relative to DESTDIR, not to prefix
689ifndef DESTDIR
Jianyu Zhanfc9cabe2014-06-03 00:44:34 +0800690prefix ?= $(HOME)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100691endif
692bindir_relative = bin
693bindir = $(prefix)/$(bindir_relative)
694mandir = share/man
695infodir = share/info
696perfexecdir = libexec/perf-core
697sharedir = $(prefix)/share
698template_dir = share/perf-core/templates
699htmldir = share/doc/perf-doc
700ifeq ($(prefix),/usr)
701sysconfdir = /etc
702ETC_PERFCONFIG = $(sysconfdir)/perfconfig
703else
704sysconfdir = $(prefix)/etc
705ETC_PERFCONFIG = etc/perfconfig
706endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200707ifndef lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900708ifeq ($(IS_X86_64),1)
709lib = lib64
710else
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100711lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900712endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200713endif # lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900714libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100715
716# Shell quote (do not use $(call) to accommodate ancient setups);
717ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
718DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
719bindir_SQ = $(subst ','\'',$(bindir))
720mandir_SQ = $(subst ','\'',$(mandir))
721infodir_SQ = $(subst ','\'',$(infodir))
722perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
723template_dir_SQ = $(subst ','\'',$(template_dir))
724htmldir_SQ = $(subst ','\'',$(htmldir))
725prefix_SQ = $(subst ','\'',$(prefix))
726sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +0900727libdir_SQ = $(subst ','\'',$(libdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100728
729ifneq ($(filter /%,$(firstword $(perfexecdir))),)
730perfexec_instdir = $(perfexecdir)
731else
732perfexec_instdir = $(prefix)/$(perfexecdir)
733endif
734perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100735
736# If we install to $(HOME) we keep the traceevent default:
737# $(HOME)/.traceevent/plugins
738# Otherwise we install plugins into the global $(libdir).
739ifdef DESTDIR
740plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -0500741plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100742endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100743
744#
745# Print the result of the feature test:
746#
Jiri Olsa8d790762014-02-19 16:52:55 +0100747feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
Jiri Olsa0695e572014-02-19 16:52:54 +0100748
Jiri Olsa8d790762014-02-19 16:52:55 +0100749define feature_print_status_code
Jiri Olsa0695e572014-02-19 16:52:54 +0100750 ifeq ($(feature-$(1)), 1)
751 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
752 else
753 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
754 endif
755endef
756
Jiri Olsa8d790762014-02-19 16:52:55 +0100757feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
758define feature_print_var_code
759 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
760endef
761
762feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
763define feature_print_text_code
764 MSG = $(shell printf '...%30s: %s' $(1) $(2))
765endef
766
Jiri Olsa0695e572014-02-19 16:52:54 +0100767PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
768PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
769
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100770ifeq ($(dwarf-post-unwind),1)
771 PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
772endif
773
Jiri Olsa0695e572014-02-19 16:52:54 +0100774# The $(display_lib) controls the default detection message
775# output. It's set if:
776# - detected features differes from stored features from
777# last build (in PERF-FEATURES file)
778# - one of the $(LIB_FEATURE_TESTS) is not detected
779# - VF is enabled
780
781ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
782 $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
783 display_lib := 1
784endif
785
786feature_check = $(eval $(feature_check_code))
787define feature_check_code
788 ifneq ($(feature-$(1)), 1)
789 display_lib := 1
790 endif
791endef
792
793$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
794
795ifeq ($(VF),1)
796 display_lib := 1
797 display_vf := 1
798endif
799
800ifeq ($(display_lib),1)
801 $(info )
802 $(info Auto-detecting system features:)
Jiri Olsa8d790762014-02-19 16:52:55 +0100803 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100804
805 ifeq ($(dwarf-post-unwind),1)
806 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
807 endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100808endif
809
810ifeq ($(display_vf),1)
Jiri Olsa8d790762014-02-19 16:52:55 +0100811 $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
812 $(info )
813 $(call feature_print_var,prefix)
814 $(call feature_print_var,bindir)
815 $(call feature_print_var,libdir)
816 $(call feature_print_var,sysconfdir)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100817 $(call feature_print_var,LIBUNWIND_DIR)
818 $(call feature_print_var,LIBDW_DIR)
Jiri Olsa0695e572014-02-19 16:52:54 +0100819endif
820
821ifeq ($(display_lib),1)
822 $(info )
823endif