blob: d44c64d6446510e53f65b30bfeccb502cdb75c4f [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
Jiri Olsa3bc33742014-12-30 13:30:04 +010051ifeq ($(NO_PERF_REGS),0)
52 $(call detected,CONFIG_PERF_REGS)
53endif
54
Jean Pihet90fa9de2014-05-16 10:41:11 +020055# So far there's only x86 and arm libdw unwind support merged in perf.
Jiri Olsa4dc549e2014-04-20 10:50:00 +020056# Disable it on all other architectures in case libdw unwind
57# support is detected in system. Add supported architectures
58# to the check.
Jean Pihet90fa9de2014-05-16 10:41:11 +020059ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
Jiri Olsa4dc549e2014-04-20 10:50:00 +020060 NO_LIBDW_DWARF_UNWIND := 1
61endif
62
Jean Pihet1448fef2013-12-10 13:24:04 +010063ifeq ($(LIBUNWIND_LIBS),)
64 NO_LIBUNWIND := 1
65else
66 #
67 # For linking with debug library, run like:
68 #
69 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
70 #
71 ifdef LIBUNWIND_DIR
72 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
73 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
74 endif
75 LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
76
77 # Set per-feature check compilation flags
78 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
79 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
80 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
81 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
Jean Pihet1448fef2013-12-10 13:24:04 +010082endif
83
Jiri Olsa8bd407b2013-03-15 16:28:49 +010084ifeq ($(NO_PERF_REGS),0)
Ingo Molnar89fe8082013-09-30 12:07:11 +020085 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
Jiri Olsa8bd407b2013-03-15 16:28:49 +010086endif
Jiri Olsaa32f4932013-03-25 00:32:01 +010087
Jiri Olsa45757892014-02-19 16:52:56 +010088ifndef NO_LIBELF
89 # for linking with debug library, run like:
90 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
91 ifdef LIBDW_DIR
92 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
93 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
Jiri Olsa45757892014-02-19 16:52:56 +010094 endif
Ramkumar Ramachandra2c529e42014-03-26 18:44:05 -040095 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
96 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
Jiri Olsa45757892014-02-19 16:52:56 +010097endif
98
Jiri Olsa53d0a572015-02-20 23:16:58 +010099ifndef NO_LIBBABELTRACE
100 # for linking with debug library, run like:
101 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
102 ifdef LIBBABELTRACE_DIR
103 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
104 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
105 endif
106 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
107 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
108endif
109
Jiri Olsa7c537462013-05-24 14:35:23 +0200110# include ARCH specific config
111-include $(src-perf)/arch/$(ARCH)/Makefile
112
Jiri Olsa7c537462013-05-24 14:35:23 +0200113include $(src-perf)/config/utilities.mak
Jiri Olsaa32f4932013-03-25 00:32:01 +0100114
115ifeq ($(call get-executable,$(FLEX)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200116 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100117endif
118
119ifeq ($(call get-executable,$(BISON)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200120 dummy := $(error Error: $(BISON) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100121endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100122
123# Treat warnings as errors unless directed not to
124ifneq ($(WERROR),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200125 CFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +0100126endif
127
Adrian Hunter74af3772013-10-22 10:34:05 +0300128ifndef DEBUG
129 DEBUG := 0
130endif
131
Ingo Molnarfcf92582013-10-10 08:05:25 +0200132ifeq ($(DEBUG),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200133 CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +0100134endif
135
136ifdef PARSER_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200137 PARSER_DEBUG_BISON := -t
138 PARSER_DEBUG_FLEX := -d
139 CFLAGS += -DPARSER_DEBUG
Jiri Olsa9352aab2014-12-29 17:42:46 +0100140 $(call detected_var,PARSER_DEBUG_BISON)
141 $(call detected_var,PARSER_DEBUG_FLEX)
Jiri Olsa362493f2013-03-25 00:40:48 +0100142endif
143
Namhyung Kim56c7d792014-07-29 15:57:19 +0900144ifndef NO_LIBPYTHON
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200145 # Try different combinations to accommodate systems that only have
146 # python[2][-config] in weird combinations but always preferring
147 # python2 and python2-config as per pep-0394. If we catch a
148 # python[-config] in version 3, the version check will kill it.
149 PYTHON2 := $(if $(call get-executable,python2),python2,python)
150 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
151 PYTHON2_CONFIG := \
152 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
Namhyung Kim56c7d792014-07-29 15:57:19 +0900153 override PYTHON_CONFIG := \
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200154 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
Namhyung Kim56c7d792014-07-29 15:57:19 +0900155
156 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
157
158 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
159 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
160
161 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
162 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
163 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
164 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
165endif
166
Jiri Olsa2fe73742013-04-15 04:32:28 +0200167CFLAGS += -fno-omit-frame-pointer
168CFLAGS += -ggdb3
169CFLAGS += -funwind-tables
170CFLAGS += -Wall
171CFLAGS += -Wextra
172CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100173
Mathias Krause6392b4e2014-04-27 18:51:05 +0200174# Enforce a non-executable stack, as we may regress (again) in the future by
175# adding assembler files missing the .GNU-stack linker note.
176LDFLAGS += -Wl,-z,noexecstack
177
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900178EXTLIBS = -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +0100179
Ingo Molnar1c2d1d82013-10-03 15:05:56 +0200180ifneq ($(OUTPUT),)
181 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
182 $(shell mkdir -p $(OUTPUT_FEATURES))
183endif
184
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200185feature_check = $(eval $(feature_check_code))
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200186define feature_check_code
Chunwei Chen56560ec2013-12-21 13:48:11 +0800187 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 +0200188endef
189
190feature_set = $(eval $(feature_set_code))
191define feature_set_code
192 feature-$(1) := 1
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200193endef
194
195#
196# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
197#
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200198
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200199#
200# Note that this is not a complete list of all feature tests, just
201# those that are typically built on a fully configured system.
202#
203# [ Feature tests not mentioned here have to be built explicitly in
204# the rule that uses them - an example for that is the 'bionic'
205# feature check. ]
206#
207CORE_FEATURE_TESTS = \
208 backtrace \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200209 dwarf \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200210 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300211 sync-compare-and-swap \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200212 glibc \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200213 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200214 gtk2-infobar \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200215 libaudit \
216 libbfd \
217 libelf \
218 libelf-getphdrnum \
219 libelf-mmap \
220 libnuma \
Ingo Molnar7181a672013-09-30 15:15:36 +0200221 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200222 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200223 libpython-version \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200224 libslang \
225 libunwind \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530226 pthread-attr-setaffinity-np \
Ingo Molnarbb4c5502013-11-14 08:33:24 +0100227 stackprotector-all \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100228 timerfd \
Namhyung Kime92ce122014-10-31 16:51:38 +0900229 libdw-dwarf-unwind \
Jiri Olsa53d0a572015-02-20 23:16:58 +0100230 libbabeltrace \
Namhyung Kime92ce122014-10-31 16:51:38 +0900231 zlib
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200232
Jiri Olsa0695e572014-02-19 16:52:54 +0100233LIB_FEATURE_TESTS = \
234 dwarf \
235 glibc \
236 gtk2 \
237 libaudit \
238 libbfd \
239 libelf \
240 libnuma \
241 libperl \
242 libpython \
243 libslang \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100244 libunwind \
Namhyung Kime92ce122014-10-31 16:51:38 +0900245 libdw-dwarf-unwind \
Jiri Olsa53d0a572015-02-20 23:16:58 +0100246 libbabeltrace \
Namhyung Kime92ce122014-10-31 16:51:38 +0900247 zlib
Jiri Olsa0695e572014-02-19 16:52:54 +0100248
249VF_FEATURE_TESTS = \
250 backtrace \
251 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300252 sync-compare-and-swap \
Jiri Olsa0695e572014-02-19 16:52:54 +0100253 gtk2-infobar \
254 libelf-getphdrnum \
255 libelf-mmap \
256 libpython-version \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530257 pthread-attr-setaffinity-np \
Jiri Olsa0695e572014-02-19 16:52:54 +0100258 stackprotector-all \
259 timerfd \
260 libunwind-debug-frame \
Jiri Olsa2cf90402014-04-23 16:53:25 +0200261 bionic \
262 liberty \
263 liberty-z \
Adrian Huntere477f3f2014-10-23 18:16:03 -0300264 cplus-demangle \
265 compile-32 \
266 compile-x32
Jiri Olsa0695e572014-02-19 16:52:54 +0100267
Jiri Olsac4eb6c02014-01-07 13:47:18 +0100268# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
269# If in the future we need per-feature checks/flags for features not
270# mentioned in this list we need to refactor this ;-).
271set_test_all_flags = $(eval $(set_test_all_flags_code))
272define set_test_all_flags_code
273 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
274 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
275endef
276
277$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
278
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200279#
280# Special fast-path for the 'all features are available' case:
281#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200282$(call feature_check,all,$(MSG))
283
284#
285# Just in case the build freshly failed, make sure we print the
286# feature matrix:
287#
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200288ifeq ($(feature-all), 1)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200289 #
290 # test-all.c passed - just set all the core feature flags to 1:
291 #
292 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200293else
Chunwei Chen56560ec2013-12-21 13:48:11 +0800294 $(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 +0200295 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200296endif
297
Ingo Molnar90ac5422013-09-30 13:48:44 +0200298ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200299 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100300endif
301
Ingo Molnarfcf92582013-10-10 08:05:25 +0200302ifeq ($(DEBUG),0)
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200303 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200304 CFLAGS += -D_FORTIFY_SOURCE=2
305 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100306endif
307
Jiri Olsa2fe73742013-04-15 04:32:28 +0200308CFLAGS += -I$(src-perf)/util/include
309CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
Namhyung Kim8a625c12014-01-09 23:00:52 +0900310CFLAGS += -I$(srctree)/tools/include/
Jiri Olsa2fe73742013-04-15 04:32:28 +0200311CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
312CFLAGS += -I$(srctree)/arch/$(ARCH)/include
313CFLAGS += -I$(srctree)/include/uapi
314CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200315
316# $(obj-perf) for generated common-cmds.h
317# $(obj-perf)/util for generated bison/flex headers
318ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200319CFLAGS += -I$(obj-perf)/util
320CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200321endif
322
Jiri Olsa2fe73742013-04-15 04:32:28 +0200323CFLAGS += -I$(src-perf)/util
324CFLAGS += -I$(src-perf)
Robert Richter4e319022013-06-11 17:29:18 +0200325CFLAGS += -I$(LIB_INCLUDE)
Jiri Olsa7c537462013-05-24 14:35:23 +0200326
Jiri Olsa2fe73742013-04-15 04:32:28 +0200327CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100328
Adrian Hunterf6d31362014-07-14 13:02:53 +0300329ifeq ($(feature-sync-compare-and-swap), 1)
330 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
331endif
332
Vineet Gupta459a3df2015-01-13 19:13:24 +0530333ifeq ($(feature-pthread-attr-setaffinity-np), 1)
334 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
335endif
336
Jiri Olsa4e22db42013-05-24 14:35:24 +0200337ifndef NO_BIONIC
David Ahern5febff02013-10-29 10:43:15 -0600338 $(call feature_check,bionic)
Ingo Molnar78e9d652013-09-30 14:11:46 +0200339 ifeq ($(feature-bionic), 1)
340 BIONIC := 1
341 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
342 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
343 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100344endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100345
346ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200347 NO_DWARF := 1
348 NO_DEMANGLE := 1
349 NO_LIBUNWIND := 1
Jiri Olsa5ea84152014-02-19 16:52:57 +0100350 NO_LIBDW_DWARF_UNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100351else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200352 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200353 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200354 LIBC_SUPPORT := 1
355 endif
356 ifeq ($(BIONIC),1)
357 LIBC_SUPPORT := 1
358 endif
359 ifeq ($(LIBC_SUPPORT),1)
360 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100361
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200362 NO_LIBELF := 1
363 NO_DWARF := 1
364 NO_DEMANGLE := 1
Arnaldo Carvalho de Melo94589552014-03-25 09:35:11 -0300365 NO_LIBUNWIND := 1
366 NO_LIBDW_DWARF_UNWIND := 1
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200367 else
Arnaldo Carvalho de Melof9ca2d82014-06-05 12:46:04 -0300368 ifneq ($(filter s% -static%,$(LDFLAGS),),)
369 msg := $(error No static glibc found, please install glibc-static);
370 else
371 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
372 endif
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200373 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200374 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100375 ifndef NO_LIBDW_DWARF_UNWIND
376 ifneq ($(feature-libdw-dwarf-unwind),1)
377 NO_LIBDW_DWARF_UNWIND := 1
378 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
379 endif
380 endif
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200381 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200382 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);
383 NO_DWARF := 1
384 endif # Dwarf support
Ingo Molnar0648f832013-10-02 15:30:35 +0200385 endif # libelf support
Jiri Olsacf4cca12013-03-25 00:45:08 +0100386endif # NO_LIBELF
387
388ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200389 CFLAGS += -DHAVE_LIBELF_SUPPORT
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900390 EXTLIBS += -lelf
Jiri Olsa709e6792014-12-29 23:52:25 +0100391 $(call detected,CONFIG_LIBELF)
Jiri Olsa779724f2013-03-25 00:48:14 +0100392
Ingo Molnar8869b172013-09-30 15:02:28 +0200393 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200394 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
395 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100396
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200397 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200398 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
399 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100400
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200401 # include ARCH specific config
402 -include $(src-perf)/arch/$(ARCH)/Makefile
403
404 ifndef NO_DWARF
405 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
406 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
407 NO_DWARF := 1
408 else
409 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
410 LDFLAGS += $(LIBDW_LDFLAGS)
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900411 EXTLIBS += -ldw
Jiri Olsa8379fce2014-12-30 00:06:25 +0100412 $(call detected,CONFIG_DWARF)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200413 endif # PERF_HAVE_DWARF_REGS
414 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100415endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100416
Anton Blanchard65ccb4f2014-08-25 18:25:06 +1000417ifeq ($(ARCH),powerpc)
418 ifndef NO_DWARF
419 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
420 endif
421endif
422
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100423ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200424 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100425 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
Ingo Molnar308e1e72013-10-07 10:30:47 +0200426 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100427 endif
428endif
429
430dwarf-post-unwind := 1
431dwarf-post-unwind-text := BUG
432
433# setup DWARF post unwinder
434ifdef NO_LIBUNWIND
435 ifdef NO_LIBDW_DWARF_UNWIND
436 msg := $(warning Disabling post unwind, no support found.);
437 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900438 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100439 dwarf-post-unwind-text := libdw
Jiri Olsab2e45c32014-12-30 00:11:11 +0100440 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100441 endif
442else
443 dwarf-post-unwind-text := libunwind
Jiri Olsab2e45c32014-12-30 00:11:11 +0100444 $(call detected,CONFIG_LIBUNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100445 # Enable libunwind support by default.
446 ifndef NO_LIBDW_DWARF_UNWIND
447 NO_LIBDW_DWARF_UNWIND := 1
448 endif
449endif
450
451ifeq ($(dwarf-post-unwind),1)
452 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
Jiri Olsaf39e0422014-12-29 15:03:09 +0100453 $(call detected,CONFIG_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100454else
455 NO_DWARF_UNWIND := 1
456endif
457
458ifndef NO_LIBUNWIND
Jean Pihet8ab596a2014-04-28 14:32:33 +0200459 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100460 $(call feature_check,libunwind-debug-frame)
461 ifneq ($(feature-libunwind-debug-frame), 1)
462 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900463 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
464 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100465 else
466 # non-ARM has no dwarf_find_debug_frame() function:
467 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
468 endif
469 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
470 EXTLIBS += $(LIBUNWIND_LIBS)
471 CFLAGS += $(LIBUNWIND_CFLAGS)
472 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200473endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100474
475ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200476 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200477 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
478 NO_LIBAUDIT := 1
479 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200480 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200481 EXTLIBS += -laudit
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100482 $(call detected,CONFIG_AUDIT)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200483 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100484endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100485
486ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200487 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100488endif
489
490ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200491 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200492 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
493 NO_SLANG := 1
494 else
495 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
496 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200497 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200498 EXTLIBS += -lslang
Jiri Olsacf15c742014-12-30 00:27:52 +0100499 $(call detected,CONFIG_SLANG)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200500 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100501endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100502
503ifndef NO_GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000504 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200505 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200506 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
507 NO_GTK2 := 1
508 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200509 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900510 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200511 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200512 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000513 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
514 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200515 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200516 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100517endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100518
519grep-libs = $(filter -l%,$(1))
520strip-libs = $(filter-out -l%,$(1))
521
522ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200523 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100524else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200525 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
526 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
527 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
528 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
529 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100530
Ingo Molnar7181a672013-09-30 15:15:36 +0200531 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200532 CFLAGS += -DNO_LIBPERL
533 NO_LIBPERL := 1
Ingo Molnara954e682015-02-28 09:39:09 +0100534 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200535 else
536 LDFLAGS += $(PERL_EMBED_LDFLAGS)
537 EXTLIBS += $(PERL_EMBED_LIBADD)
Jiri Olsac7355f82014-12-30 13:11:32 +0100538 $(call detected,CONFIG_LIBPERL)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200539 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100540endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100541
David Ahern87419c92013-10-29 10:43:16 -0600542ifeq ($(feature-timerfd), 1)
543 CFLAGS += -DHAVE_TIMERFD_SUPPORT
544else
545 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
546endif
547
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100548disable-python = $(eval $(disable-python_code))
549define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100550 CFLAGS += -DNO_LIBPYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100551 $(warning $1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100552 NO_LIBPYTHON := 1
553endef
554
Namhyung Kim56c7d792014-07-29 15:57:19 +0900555ifdef NO_LIBPYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100556 $(call disable-python,Python support disabled by user)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100557else
558
Namhyung Kim56c7d792014-07-29 15:57:19 +0900559 ifndef PYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100560 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100561 else
Namhyung Kim56c7d792014-07-29 15:57:19 +0900562 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100563
564 ifndef PYTHON_CONFIG
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100565 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100566 else
567
568 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
569
570 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
571 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
572 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
573 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
574 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
575
Ingo Molnar97341632013-09-30 15:18:37 +0200576 ifneq ($(feature-libpython), 1)
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100577 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100578 else
579
Ingo Molnar95d061c2013-09-30 15:40:04 +0200580 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100581 $(warning Python 3 is not yet supported; please set)
582 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
583 $(warning If you also have Python 2 installed, then)
584 $(warning try something like:)
585 $(warning $(and ,))
586 $(warning $(and ,) make PYTHON=python2)
587 $(warning $(and ,))
588 $(warning Otherwise, disable Python support entirely:)
589 $(warning $(and ,))
590 $(warning $(and ,) make NO_LIBPYTHON=1)
591 $(warning $(and ,))
592 $(error $(and ,))
593 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100594 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100595 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200596 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsac7355f82014-12-30 13:11:32 +0100597 $(call detected,CONFIG_LIBPYTHON)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100598 endif
599 endif
600 endif
601 endif
602endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100603
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200604ifeq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200605 EXTLIBS += -lbfd
606
607 # call all detections now so we get correct
608 # status in VF output
609 $(call feature_check,liberty)
610 $(call feature_check,liberty-z)
611 $(call feature_check,cplus-demangle)
612
613 ifeq ($(feature-liberty), 1)
614 EXTLIBS += -liberty
615 else
616 ifeq ($(feature-liberty-z), 1)
617 EXTLIBS += -liberty -lz
618 endif
619 endif
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200620endif
621
Jiri Olsac3cf8362013-03-18 00:38:16 +0100622ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200623 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100624else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200625 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200626 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200627 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200628 else
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200629 ifneq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200630 ifneq ($(feature-liberty), 1)
631 ifneq ($(feature-liberty-z), 1)
632 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
633 # or any of 'bfd iberty z' trinity
Ingo Molnar1c476612013-10-02 15:15:09 +0200634 ifeq ($(feature-cplus-demangle), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200635 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200636 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200637 else
Ingo Molnar0189d7c2015-02-28 09:46:42 +0100638 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200639 CFLAGS += -DNO_DEMANGLE
640 endif
641 endif
642 endif
643 endif
644 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100645endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100646
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200647ifneq ($(filter -lbfd,$(EXTLIBS)),)
648 CFLAGS += -DHAVE_LIBBFD_SUPPORT
649endif
650
Namhyung Kime92ce122014-10-31 16:51:38 +0900651ifndef NO_ZLIB
652 ifeq ($(feature-zlib), 1)
653 CFLAGS += -DHAVE_ZLIB_SUPPORT
654 EXTLIBS += -lz
Jiri Olsa1571b692014-12-30 13:31:12 +0100655 $(call detected,CONFIG_ZLIB)
Namhyung Kime92ce122014-10-31 16:51:38 +0900656 else
657 NO_ZLIB := 1
658 endif
659endif
660
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100661ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200662 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200663 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200664 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100665endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100666
667ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200668 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500669 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 +0200670 NO_LIBNUMA := 1
671 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200672 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200673 EXTLIBS += -lnuma
Jiri Olsa72965b82014-12-29 13:52:36 +0100674 $(call detected,CONFIG_NUMA)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200675 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100676endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100677
Alexander Yaryginda50ad62014-07-03 17:59:49 +0400678ifdef HAVE_KVM_STAT_SUPPORT
679 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
680endif
681
Adrian Huntere477f3f2014-10-23 18:16:03 -0300682ifeq (${IS_64_BIT}, 1)
683 ifndef NO_PERF_READ_VDSO32
684 $(call feature_check,compile-32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300685 ifeq ($(feature-compile-32), 1)
686 CFLAGS += -DHAVE_PERF_READ_VDSO32
687 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300688 NO_PERF_READ_VDSO32 := 1
689 endif
690 endif
691 ifneq (${IS_X86_64}, 1)
692 NO_PERF_READ_VDSOX32 := 1
693 endif
694 ifndef NO_PERF_READ_VDSOX32
695 $(call feature_check,compile-x32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300696 ifeq ($(feature-compile-x32), 1)
697 CFLAGS += -DHAVE_PERF_READ_VDSOX32
698 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300699 NO_PERF_READ_VDSOX32 := 1
700 endif
701 endif
702else
703 NO_PERF_READ_VDSO32 := 1
704 NO_PERF_READ_VDSOX32 := 1
705endif
706
Jiri Olsa53d0a572015-02-20 23:16:58 +0100707ifndef NO_LIBBABELTRACE
708 ifeq ($(feature-libbabeltrace), 0)
Ingo Molnarde5349f2015-02-28 10:18:49 +0100709 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
Jiri Olsa53d0a572015-02-20 23:16:58 +0100710 NO_LIBBABELTRACE := 1
711 else
712 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
713 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
714 EXTLIBS += -lbabeltrace-ctf
Jiri Olsaedbe9812015-02-20 23:17:00 +0100715 $(call detected,CONFIG_LIBBABELTRACE)
Jiri Olsa53d0a572015-02-20 23:16:58 +0100716 endif
717endif
718
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100719# Among the variables below, these:
720# perfexecdir
721# template_dir
722# mandir
723# infodir
724# htmldir
725# ETC_PERFCONFIG (but not sysconfdir)
726# can be specified as a relative path some/where/else;
727# this is interpreted as relative to $(prefix) and "perf" at
728# runtime figures out where they are based on the path to the executable.
729# This can help installing the suite in a relocatable way.
730
731# Make the path relative to DESTDIR, not to prefix
732ifndef DESTDIR
Jianyu Zhanfc9cabe2014-06-03 00:44:34 +0800733prefix ?= $(HOME)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100734endif
735bindir_relative = bin
736bindir = $(prefix)/$(bindir_relative)
737mandir = share/man
738infodir = share/info
739perfexecdir = libexec/perf-core
740sharedir = $(prefix)/share
741template_dir = share/perf-core/templates
742htmldir = share/doc/perf-doc
743ifeq ($(prefix),/usr)
744sysconfdir = /etc
745ETC_PERFCONFIG = $(sysconfdir)/perfconfig
746else
747sysconfdir = $(prefix)/etc
748ETC_PERFCONFIG = etc/perfconfig
749endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200750ifndef lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900751ifeq ($(IS_X86_64),1)
752lib = lib64
753else
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100754lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900755endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200756endif # lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900757libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100758
759# Shell quote (do not use $(call) to accommodate ancient setups);
760ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
761DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
762bindir_SQ = $(subst ','\'',$(bindir))
763mandir_SQ = $(subst ','\'',$(mandir))
764infodir_SQ = $(subst ','\'',$(infodir))
765perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
766template_dir_SQ = $(subst ','\'',$(template_dir))
767htmldir_SQ = $(subst ','\'',$(htmldir))
768prefix_SQ = $(subst ','\'',$(prefix))
769sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +0900770libdir_SQ = $(subst ','\'',$(libdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100771
772ifneq ($(filter /%,$(firstword $(perfexecdir))),)
773perfexec_instdir = $(perfexecdir)
774else
775perfexec_instdir = $(prefix)/$(perfexecdir)
776endif
777perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100778
779# If we install to $(HOME) we keep the traceevent default:
780# $(HOME)/.traceevent/plugins
781# Otherwise we install plugins into the global $(libdir).
782ifdef DESTDIR
783plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -0500784plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100785endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100786
787#
788# Print the result of the feature test:
789#
Jiri Olsa8d790762014-02-19 16:52:55 +0100790feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
Jiri Olsa0695e572014-02-19 16:52:54 +0100791
Jiri Olsa8d790762014-02-19 16:52:55 +0100792define feature_print_status_code
Jiri Olsa0695e572014-02-19 16:52:54 +0100793 ifeq ($(feature-$(1)), 1)
794 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
795 else
796 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
797 endif
798endef
799
Jiri Olsa8d790762014-02-19 16:52:55 +0100800feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
801define feature_print_var_code
802 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
803endef
804
805feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
806define feature_print_text_code
807 MSG = $(shell printf '...%30s: %s' $(1) $(2))
808endef
809
Jiri Olsa0695e572014-02-19 16:52:54 +0100810PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
811PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
812
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100813ifeq ($(dwarf-post-unwind),1)
814 PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
815endif
816
Jiri Olsa0695e572014-02-19 16:52:54 +0100817# The $(display_lib) controls the default detection message
818# output. It's set if:
819# - detected features differes from stored features from
820# last build (in PERF-FEATURES file)
821# - one of the $(LIB_FEATURE_TESTS) is not detected
822# - VF is enabled
823
824ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
825 $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
826 display_lib := 1
827endif
828
829feature_check = $(eval $(feature_check_code))
830define feature_check_code
831 ifneq ($(feature-$(1)), 1)
832 display_lib := 1
833 endif
834endef
835
836$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
837
838ifeq ($(VF),1)
839 display_lib := 1
840 display_vf := 1
841endif
842
843ifeq ($(display_lib),1)
844 $(info )
845 $(info Auto-detecting system features:)
Jiri Olsa8d790762014-02-19 16:52:55 +0100846 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100847
848 ifeq ($(dwarf-post-unwind),1)
849 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
850 endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100851endif
852
853ifeq ($(display_vf),1)
Jiri Olsa8d790762014-02-19 16:52:55 +0100854 $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
855 $(info )
856 $(call feature_print_var,prefix)
857 $(call feature_print_var,bindir)
858 $(call feature_print_var,libdir)
859 $(call feature_print_var,sysconfdir)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100860 $(call feature_print_var,LIBUNWIND_DIR)
861 $(call feature_print_var,LIBDW_DIR)
Jiri Olsa0695e572014-02-19 16:52:54 +0100862endif
863
864ifeq ($(display_lib),1)
865 $(info )
866endif
Jiri Olsaf39e0422014-12-29 15:03:09 +0100867
868$(call detected_var,bindir_SQ)
869$(call detected_var,PYTHON_WORD)
870ifneq ($(OUTPUT),)
871$(call detected_var,OUTPUT)
872endif
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100873$(call detected_var,htmldir_SQ)
874$(call detected_var,infodir_SQ)
875$(call detected_var,mandir_SQ)
Jiri Olsa9352aab2014-12-29 17:42:46 +0100876$(call detected_var,ETC_PERFCONFIG_SQ)
877$(call detected_var,prefix_SQ)
878$(call detected_var,perfexecdir_SQ)
Jiri Olsa3b939a62014-12-30 00:16:01 +0100879$(call detected_var,LIBDIR)
Jiri Olsa88aeea02014-12-30 00:34:23 +0100880$(call detected_var,GTK_CFLAGS)
Jiri Olsac7355f82014-12-30 13:11:32 +0100881$(call detected_var,PERL_EMBED_CCOPTS)
882$(call detected_var,PYTHON_EMBED_CCOPTS)