blob: 467106bc5faba3b63524329e47114688e8b3856f [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 +010018CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
19
20include $(src-perf)/config/Makefile.arch
21
Jiri Olsaf39e0422014-12-29 15:03:09 +010022$(call detected_var,ARCH)
23
Jiri Olsaa6cf5f32014-01-03 15:32:32 +010024NO_PERF_REGS := 1
25
26# Additional ARCH settings for x86
27ifeq ($(ARCH),x86)
Jiri Olsaf39e0422014-12-29 15:03:09 +010028 $(call detected,CONFIG_X86)
Namhyung Kimc6e5e9f2015-01-12 10:20:55 +080029 ifeq (${IS_64_BIT}, 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +020030 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020031 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
Adrian Hunter8a0c4c22013-11-01 15:51:32 +020032 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
Jiri Olsa72965b82014-12-29 13:52:36 +010033 $(call detected,CONFIG_X86_64)
Adrian Hunter8a0c4c22013-11-01 15:51:32 +020034 else
35 LIBUNWIND_LIBS = -lunwind -lunwind-x86
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020036 endif
37 NO_PERF_REGS := 0
Jiri Olsa8bd407b2013-03-15 16:28:49 +010038endif
Jean Pihet8ab596a2014-04-28 14:32:33 +020039
Will Deacon7495f372013-09-26 12:36:36 +010040ifeq ($(ARCH),arm)
41 NO_PERF_REGS := 0
42 LIBUNWIND_LIBS = -lunwind -lunwind-arm
43endif
Jiri Olsa8bd407b2013-03-15 16:28:49 +010044
Jean Pihet8ab596a2014-04-28 14:32:33 +020045ifeq ($(ARCH),arm64)
46 NO_PERF_REGS := 0
47 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
48endif
49
Jiri Olsa3bc33742014-12-30 13:30:04 +010050ifeq ($(NO_PERF_REGS),0)
51 $(call detected,CONFIG_PERF_REGS)
52endif
53
Jean Pihet90fa9de2014-05-16 10:41:11 +020054# So far there's only x86 and arm libdw unwind support merged in perf.
Jiri Olsa4dc549e2014-04-20 10:50:00 +020055# Disable it on all other architectures in case libdw unwind
56# support is detected in system. Add supported architectures
57# to the check.
Jean Pihet90fa9de2014-05-16 10:41:11 +020058ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
Jiri Olsa4dc549e2014-04-20 10:50:00 +020059 NO_LIBDW_DWARF_UNWIND := 1
60endif
61
Jean Pihet1448fef2013-12-10 13:24:04 +010062ifeq ($(LIBUNWIND_LIBS),)
63 NO_LIBUNWIND := 1
64else
65 #
66 # For linking with debug library, run like:
67 #
68 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
69 #
70 ifdef LIBUNWIND_DIR
71 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
72 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
73 endif
74 LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
75
76 # Set per-feature check compilation flags
77 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
78 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
79 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
80 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
Jean Pihet1448fef2013-12-10 13:24:04 +010081endif
82
Jiri Olsa8bd407b2013-03-15 16:28:49 +010083ifeq ($(NO_PERF_REGS),0)
Ingo Molnar89fe8082013-09-30 12:07:11 +020084 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
Jiri Olsa8bd407b2013-03-15 16:28:49 +010085endif
Jiri Olsaa32f4932013-03-25 00:32:01 +010086
Jiri Olsa45757892014-02-19 16:52:56 +010087ifndef NO_LIBELF
88 # for linking with debug library, run like:
89 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
90 ifdef LIBDW_DIR
91 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
92 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
Jiri Olsa45757892014-02-19 16:52:56 +010093 endif
Ramkumar Ramachandra2c529e42014-03-26 18:44:05 -040094 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
95 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
Jiri Olsa45757892014-02-19 16:52:56 +010096endif
97
Jiri Olsa53d0a572015-02-20 23:16:58 +010098ifndef NO_LIBBABELTRACE
99 # for linking with debug library, run like:
100 # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/
101 ifdef LIBBABELTRACE_DIR
102 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
103 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
104 endif
105 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
106 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
107endif
108
Jiri Olsa7c537462013-05-24 14:35:23 +0200109# include ARCH specific config
110-include $(src-perf)/arch/$(ARCH)/Makefile
111
Jiri Olsa7c537462013-05-24 14:35:23 +0200112include $(src-perf)/config/utilities.mak
Jiri Olsaa32f4932013-03-25 00:32:01 +0100113
114ifeq ($(call get-executable,$(FLEX)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200115 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100116endif
117
118ifeq ($(call get-executable,$(BISON)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200119 dummy := $(error Error: $(BISON) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +0100120endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100121
122# Treat warnings as errors unless directed not to
123ifneq ($(WERROR),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200124 CFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +0100125endif
126
Adrian Hunter74af3772013-10-22 10:34:05 +0300127ifndef DEBUG
128 DEBUG := 0
129endif
130
Ingo Molnarfcf92582013-10-10 08:05:25 +0200131ifeq ($(DEBUG),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200132 CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +0100133endif
134
135ifdef PARSER_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200136 PARSER_DEBUG_BISON := -t
137 PARSER_DEBUG_FLEX := -d
138 CFLAGS += -DPARSER_DEBUG
Jiri Olsa9352aab2014-12-29 17:42:46 +0100139 $(call detected_var,PARSER_DEBUG_BISON)
140 $(call detected_var,PARSER_DEBUG_FLEX)
Jiri Olsa362493f2013-03-25 00:40:48 +0100141endif
142
Namhyung Kim56c7d792014-07-29 15:57:19 +0900143ifndef NO_LIBPYTHON
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200144 # Try different combinations to accommodate systems that only have
145 # python[2][-config] in weird combinations but always preferring
146 # python2 and python2-config as per pep-0394. If we catch a
147 # python[-config] in version 3, the version check will kill it.
148 PYTHON2 := $(if $(call get-executable,python2),python2,python)
149 override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
150 PYTHON2_CONFIG := \
151 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
Namhyung Kim56c7d792014-07-29 15:57:19 +0900152 override PYTHON_CONFIG := \
Thomas Ilsched6a947f2014-08-04 15:03:15 +0200153 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
Namhyung Kim56c7d792014-07-29 15:57:19 +0900154
155 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
156
157 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
158 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
159
160 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
161 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
162 FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
163 FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
164endif
165
Jiri Olsa2fe73742013-04-15 04:32:28 +0200166CFLAGS += -fno-omit-frame-pointer
167CFLAGS += -ggdb3
168CFLAGS += -funwind-tables
169CFLAGS += -Wall
170CFLAGS += -Wextra
171CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100172
Mathias Krause6392b4e2014-04-27 18:51:05 +0200173# Enforce a non-executable stack, as we may regress (again) in the future by
174# adding assembler files missing the .GNU-stack linker note.
175LDFLAGS += -Wl,-z,noexecstack
176
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900177EXTLIBS = -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +0100178
Ingo Molnar1c2d1d82013-10-03 15:05:56 +0200179ifneq ($(OUTPUT),)
180 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
181 $(shell mkdir -p $(OUTPUT_FEATURES))
182endif
183
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200184feature_check = $(eval $(feature_check_code))
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200185define feature_check_code
Jiri Olsa806f0722015-03-11 09:01:26 +0100186 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 +0200187endef
188
189feature_set = $(eval $(feature_set_code))
190define feature_set_code
191 feature-$(1) := 1
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200192endef
193
194#
195# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
196#
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200197
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200198#
199# Note that this is not a complete list of all feature tests, just
200# those that are typically built on a fully configured system.
201#
202# [ Feature tests not mentioned here have to be built explicitly in
203# the rule that uses them - an example for that is the 'bionic'
204# feature check. ]
205#
206CORE_FEATURE_TESTS = \
207 backtrace \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200208 dwarf \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200209 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300210 sync-compare-and-swap \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200211 glibc \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200212 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200213 gtk2-infobar \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200214 libaudit \
215 libbfd \
216 libelf \
217 libelf-getphdrnum \
218 libelf-mmap \
219 libnuma \
Ingo Molnar7181a672013-09-30 15:15:36 +0200220 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200221 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200222 libpython-version \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200223 libslang \
224 libunwind \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530225 pthread-attr-setaffinity-np \
Ingo Molnarbb4c5502013-11-14 08:33:24 +0100226 stackprotector-all \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100227 timerfd \
Namhyung Kime92ce122014-10-31 16:51:38 +0900228 libdw-dwarf-unwind \
229 zlib
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200230
Jiri Olsa0695e572014-02-19 16:52:54 +0100231LIB_FEATURE_TESTS = \
232 dwarf \
233 glibc \
234 gtk2 \
235 libaudit \
236 libbfd \
237 libelf \
238 libnuma \
239 libperl \
240 libpython \
241 libslang \
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100242 libunwind \
Namhyung Kime92ce122014-10-31 16:51:38 +0900243 libdw-dwarf-unwind \
244 zlib
Jiri Olsa0695e572014-02-19 16:52:54 +0100245
246VF_FEATURE_TESTS = \
247 backtrace \
248 fortify-source \
Adrian Hunterf6d31362014-07-14 13:02:53 +0300249 sync-compare-and-swap \
Jiri Olsa0695e572014-02-19 16:52:54 +0100250 gtk2-infobar \
251 libelf-getphdrnum \
252 libelf-mmap \
253 libpython-version \
Vineet Gupta459a3df2015-01-13 19:13:24 +0530254 pthread-attr-setaffinity-np \
Jiri Olsa0695e572014-02-19 16:52:54 +0100255 stackprotector-all \
256 timerfd \
257 libunwind-debug-frame \
Jiri Olsa2cf90402014-04-23 16:53:25 +0200258 bionic \
259 liberty \
260 liberty-z \
Adrian Huntere477f3f2014-10-23 18:16:03 -0300261 cplus-demangle \
262 compile-32 \
263 compile-x32
Jiri Olsa0695e572014-02-19 16:52:54 +0100264
Jiri Olsac4eb6c02014-01-07 13:47:18 +0100265# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
266# If in the future we need per-feature checks/flags for features not
267# mentioned in this list we need to refactor this ;-).
268set_test_all_flags = $(eval $(set_test_all_flags_code))
269define set_test_all_flags_code
270 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
271 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
272endef
273
274$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
275
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200276#
277# Special fast-path for the 'all features are available' case:
278#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200279$(call feature_check,all,$(MSG))
280
281#
282# Just in case the build freshly failed, make sure we print the
283# feature matrix:
284#
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200285ifeq ($(feature-all), 1)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200286 #
287 # test-all.c passed - just set all the core feature flags to 1:
288 #
289 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200290else
Chunwei Chen56560ec2013-12-21 13:48:11 +0800291 $(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 +0200292 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200293endif
294
Ingo Molnar90ac5422013-09-30 13:48:44 +0200295ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200296 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100297endif
298
Ingo Molnarfcf92582013-10-10 08:05:25 +0200299ifeq ($(DEBUG),0)
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200300 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200301 CFLAGS += -D_FORTIFY_SOURCE=2
302 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100303endif
304
Jiri Olsa2fe73742013-04-15 04:32:28 +0200305CFLAGS += -I$(src-perf)/util/include
306CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
Namhyung Kim8a625c12014-01-09 23:00:52 +0900307CFLAGS += -I$(srctree)/tools/include/
Jiri Olsa2fe73742013-04-15 04:32:28 +0200308CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
309CFLAGS += -I$(srctree)/arch/$(ARCH)/include
310CFLAGS += -I$(srctree)/include/uapi
311CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200312
313# $(obj-perf) for generated common-cmds.h
314# $(obj-perf)/util for generated bison/flex headers
315ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200316CFLAGS += -I$(obj-perf)/util
317CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200318endif
319
Jiri Olsa2fe73742013-04-15 04:32:28 +0200320CFLAGS += -I$(src-perf)/util
321CFLAGS += -I$(src-perf)
Jiri Olsa9444e872015-03-01 20:11:24 +0100322CFLAGS += -I$(srctree)/tools/lib/
Jiri Olsa7c537462013-05-24 14:35:23 +0200323
Jiri Olsa2fe73742013-04-15 04:32:28 +0200324CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100325
Adrian Hunterf6d31362014-07-14 13:02:53 +0300326ifeq ($(feature-sync-compare-and-swap), 1)
327 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
328endif
329
Vineet Gupta459a3df2015-01-13 19:13:24 +0530330ifeq ($(feature-pthread-attr-setaffinity-np), 1)
331 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
332endif
333
Jiri Olsa4e22db42013-05-24 14:35:24 +0200334ifndef NO_BIONIC
David Ahern5febff02013-10-29 10:43:15 -0600335 $(call feature_check,bionic)
Ingo Molnar78e9d652013-09-30 14:11:46 +0200336 ifeq ($(feature-bionic), 1)
337 BIONIC := 1
338 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
339 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
340 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100341endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100342
343ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200344 NO_DWARF := 1
345 NO_DEMANGLE := 1
346 NO_LIBUNWIND := 1
Jiri Olsa5ea84152014-02-19 16:52:57 +0100347 NO_LIBDW_DWARF_UNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100348else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200349 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200350 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200351 LIBC_SUPPORT := 1
352 endif
353 ifeq ($(BIONIC),1)
354 LIBC_SUPPORT := 1
355 endif
356 ifeq ($(LIBC_SUPPORT),1)
357 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100358
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200359 NO_LIBELF := 1
360 NO_DWARF := 1
361 NO_DEMANGLE := 1
Arnaldo Carvalho de Melo94589552014-03-25 09:35:11 -0300362 NO_LIBUNWIND := 1
363 NO_LIBDW_DWARF_UNWIND := 1
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200364 else
Arnaldo Carvalho de Melof9ca2d82014-06-05 12:46:04 -0300365 ifneq ($(filter s% -static%,$(LDFLAGS),),)
366 msg := $(error No static glibc found, please install glibc-static);
367 else
368 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
369 endif
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200370 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200371 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100372 ifndef NO_LIBDW_DWARF_UNWIND
373 ifneq ($(feature-libdw-dwarf-unwind),1)
374 NO_LIBDW_DWARF_UNWIND := 1
375 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
376 endif
377 endif
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200378 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200379 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);
380 NO_DWARF := 1
381 endif # Dwarf support
Ingo Molnar0648f832013-10-02 15:30:35 +0200382 endif # libelf support
Jiri Olsacf4cca12013-03-25 00:45:08 +0100383endif # NO_LIBELF
384
385ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200386 CFLAGS += -DHAVE_LIBELF_SUPPORT
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900387 EXTLIBS += -lelf
Jiri Olsa709e6792014-12-29 23:52:25 +0100388 $(call detected,CONFIG_LIBELF)
Jiri Olsa779724f2013-03-25 00:48:14 +0100389
Ingo Molnar8869b172013-09-30 15:02:28 +0200390 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200391 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
392 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100393
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200394 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200395 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
396 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100397
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200398 # include ARCH specific config
399 -include $(src-perf)/arch/$(ARCH)/Makefile
400
401 ifndef NO_DWARF
402 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
403 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
404 NO_DWARF := 1
405 else
406 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
407 LDFLAGS += $(LIBDW_LDFLAGS)
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900408 EXTLIBS += -ldw
Jiri Olsa8379fce2014-12-30 00:06:25 +0100409 $(call detected,CONFIG_DWARF)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200410 endif # PERF_HAVE_DWARF_REGS
411 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100412endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100413
Anton Blanchard65ccb4f2014-08-25 18:25:06 +1000414ifeq ($(ARCH),powerpc)
415 ifndef NO_DWARF
416 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
417 endif
418endif
419
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100420ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200421 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100422 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
Ingo Molnar308e1e72013-10-07 10:30:47 +0200423 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100424 endif
425endif
426
427dwarf-post-unwind := 1
428dwarf-post-unwind-text := BUG
429
430# setup DWARF post unwinder
431ifdef NO_LIBUNWIND
432 ifdef NO_LIBDW_DWARF_UNWIND
433 msg := $(warning Disabling post unwind, no support found.);
434 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900435 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100436 dwarf-post-unwind-text := libdw
Jiri Olsab2e45c32014-12-30 00:11:11 +0100437 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100438 endif
439else
440 dwarf-post-unwind-text := libunwind
Jiri Olsab2e45c32014-12-30 00:11:11 +0100441 $(call detected,CONFIG_LIBUNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100442 # Enable libunwind support by default.
443 ifndef NO_LIBDW_DWARF_UNWIND
444 NO_LIBDW_DWARF_UNWIND := 1
445 endif
446endif
447
448ifeq ($(dwarf-post-unwind),1)
449 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
Jiri Olsaf39e0422014-12-29 15:03:09 +0100450 $(call detected,CONFIG_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100451else
452 NO_DWARF_UNWIND := 1
453endif
454
455ifndef NO_LIBUNWIND
Jean Pihet8ab596a2014-04-28 14:32:33 +0200456 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100457 $(call feature_check,libunwind-debug-frame)
458 ifneq ($(feature-libunwind-debug-frame), 1)
459 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900460 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
461 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100462 else
463 # non-ARM has no dwarf_find_debug_frame() function:
464 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
465 endif
466 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
467 EXTLIBS += $(LIBUNWIND_LIBS)
468 CFLAGS += $(LIBUNWIND_CFLAGS)
469 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200470endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100471
472ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200473 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200474 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
475 NO_LIBAUDIT := 1
476 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200477 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200478 EXTLIBS += -laudit
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100479 $(call detected,CONFIG_AUDIT)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200480 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100481endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100482
483ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200484 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100485endif
486
487ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200488 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200489 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
490 NO_SLANG := 1
491 else
492 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
493 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200494 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200495 EXTLIBS += -lslang
Jiri Olsacf15c742014-12-30 00:27:52 +0100496 $(call detected,CONFIG_SLANG)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200497 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100498endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100499
500ifndef NO_GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000501 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200502 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200503 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
504 NO_GTK2 := 1
505 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200506 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900507 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200508 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200509 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000510 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
511 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200512 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200513 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100514endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100515
516grep-libs = $(filter -l%,$(1))
517strip-libs = $(filter-out -l%,$(1))
518
519ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200520 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100521else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200522 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
523 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
524 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
525 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
526 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100527
Ingo Molnar7181a672013-09-30 15:15:36 +0200528 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200529 CFLAGS += -DNO_LIBPERL
530 NO_LIBPERL := 1
Ingo Molnara954e682015-02-28 09:39:09 +0100531 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200532 else
533 LDFLAGS += $(PERL_EMBED_LDFLAGS)
534 EXTLIBS += $(PERL_EMBED_LIBADD)
Jiri Olsac7355f82014-12-30 13:11:32 +0100535 $(call detected,CONFIG_LIBPERL)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200536 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100537endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100538
David Ahern87419c92013-10-29 10:43:16 -0600539ifeq ($(feature-timerfd), 1)
540 CFLAGS += -DHAVE_TIMERFD_SUPPORT
541else
542 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
543endif
544
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100545disable-python = $(eval $(disable-python_code))
546define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100547 CFLAGS += -DNO_LIBPYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100548 $(warning $1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100549 NO_LIBPYTHON := 1
550endef
551
Namhyung Kim56c7d792014-07-29 15:57:19 +0900552ifdef NO_LIBPYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100553 $(call disable-python,Python support disabled by user)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100554else
555
Namhyung Kim56c7d792014-07-29 15:57:19 +0900556 ifndef PYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100557 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100558 else
Namhyung Kim56c7d792014-07-29 15:57:19 +0900559 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100560
561 ifndef PYTHON_CONFIG
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100562 $(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 +0100563 else
564
565 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
566
567 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
568 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
569 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
570 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
571 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
572
Ingo Molnar97341632013-09-30 15:18:37 +0200573 ifneq ($(feature-libpython), 1)
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100574 $(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 +0100575 else
576
Ingo Molnar95d061c2013-09-30 15:40:04 +0200577 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100578 $(warning Python 3 is not yet supported; please set)
579 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
580 $(warning If you also have Python 2 installed, then)
581 $(warning try something like:)
582 $(warning $(and ,))
583 $(warning $(and ,) make PYTHON=python2)
584 $(warning $(and ,))
585 $(warning Otherwise, disable Python support entirely:)
586 $(warning $(and ,))
587 $(warning $(and ,) make NO_LIBPYTHON=1)
588 $(warning $(and ,))
589 $(error $(and ,))
590 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100591 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100592 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200593 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsac7355f82014-12-30 13:11:32 +0100594 $(call detected,CONFIG_LIBPYTHON)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100595 endif
596 endif
597 endif
598 endif
599endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100600
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200601ifeq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200602 EXTLIBS += -lbfd
603
604 # call all detections now so we get correct
605 # status in VF output
606 $(call feature_check,liberty)
607 $(call feature_check,liberty-z)
608 $(call feature_check,cplus-demangle)
609
610 ifeq ($(feature-liberty), 1)
611 EXTLIBS += -liberty
612 else
613 ifeq ($(feature-liberty-z), 1)
614 EXTLIBS += -liberty -lz
615 endif
616 endif
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200617endif
618
Jiri Olsac3cf8362013-03-18 00:38:16 +0100619ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200620 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100621else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200622 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200623 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200624 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200625 else
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200626 ifneq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200627 ifneq ($(feature-liberty), 1)
628 ifneq ($(feature-liberty-z), 1)
629 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
630 # or any of 'bfd iberty z' trinity
Ingo Molnar1c476612013-10-02 15:15:09 +0200631 ifeq ($(feature-cplus-demangle), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200632 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200633 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200634 else
Ingo Molnar0189d7c2015-02-28 09:46:42 +0100635 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 +0200636 CFLAGS += -DNO_DEMANGLE
637 endif
638 endif
639 endif
640 endif
641 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100642endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100643
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200644ifneq ($(filter -lbfd,$(EXTLIBS)),)
645 CFLAGS += -DHAVE_LIBBFD_SUPPORT
646endif
647
Namhyung Kime92ce122014-10-31 16:51:38 +0900648ifndef NO_ZLIB
649 ifeq ($(feature-zlib), 1)
650 CFLAGS += -DHAVE_ZLIB_SUPPORT
651 EXTLIBS += -lz
Jiri Olsa1571b692014-12-30 13:31:12 +0100652 $(call detected,CONFIG_ZLIB)
Namhyung Kime92ce122014-10-31 16:51:38 +0900653 else
654 NO_ZLIB := 1
655 endif
656endif
657
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100658ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200659 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200660 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200661 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100662endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100663
664ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200665 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500666 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 +0200667 NO_LIBNUMA := 1
668 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200669 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200670 EXTLIBS += -lnuma
Jiri Olsa72965b82014-12-29 13:52:36 +0100671 $(call detected,CONFIG_NUMA)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200672 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100673endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100674
Alexander Yaryginda50ad62014-07-03 17:59:49 +0400675ifdef HAVE_KVM_STAT_SUPPORT
676 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
677endif
678
Adrian Huntere477f3f2014-10-23 18:16:03 -0300679ifeq (${IS_64_BIT}, 1)
680 ifndef NO_PERF_READ_VDSO32
681 $(call feature_check,compile-32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300682 ifeq ($(feature-compile-32), 1)
683 CFLAGS += -DHAVE_PERF_READ_VDSO32
684 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300685 NO_PERF_READ_VDSO32 := 1
686 endif
687 endif
688 ifneq (${IS_X86_64}, 1)
689 NO_PERF_READ_VDSOX32 := 1
690 endif
691 ifndef NO_PERF_READ_VDSOX32
692 $(call feature_check,compile-x32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300693 ifeq ($(feature-compile-x32), 1)
694 CFLAGS += -DHAVE_PERF_READ_VDSOX32
695 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300696 NO_PERF_READ_VDSOX32 := 1
697 endif
698 endif
699else
700 NO_PERF_READ_VDSO32 := 1
701 NO_PERF_READ_VDSOX32 := 1
702endif
703
Jiri Olsa53d0a572015-02-20 23:16:58 +0100704ifndef NO_LIBBABELTRACE
Jiri Olsa97e7a512015-03-11 09:00:41 +0100705 $(call feature_check,libbabeltrace)
706 ifeq ($(feature-libbabeltrace), 1)
Jiri Olsa53d0a572015-02-20 23:16:58 +0100707 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
708 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
709 EXTLIBS += -lbabeltrace-ctf
Jiri Olsaedbe9812015-02-20 23:17:00 +0100710 $(call detected,CONFIG_LIBBABELTRACE)
Jiri Olsa97e7a512015-03-11 09:00:41 +0100711 else
712 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
713 NO_LIBBABELTRACE := 1
Jiri Olsa53d0a572015-02-20 23:16:58 +0100714 endif
715endif
716
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100717# Among the variables below, these:
718# perfexecdir
719# template_dir
720# mandir
721# infodir
722# htmldir
723# ETC_PERFCONFIG (but not sysconfdir)
724# can be specified as a relative path some/where/else;
725# this is interpreted as relative to $(prefix) and "perf" at
726# runtime figures out where they are based on the path to the executable.
727# This can help installing the suite in a relocatable way.
728
729# Make the path relative to DESTDIR, not to prefix
730ifndef DESTDIR
Jianyu Zhanfc9cabe2014-06-03 00:44:34 +0800731prefix ?= $(HOME)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100732endif
733bindir_relative = bin
734bindir = $(prefix)/$(bindir_relative)
735mandir = share/man
736infodir = share/info
737perfexecdir = libexec/perf-core
738sharedir = $(prefix)/share
739template_dir = share/perf-core/templates
740htmldir = share/doc/perf-doc
741ifeq ($(prefix),/usr)
742sysconfdir = /etc
743ETC_PERFCONFIG = $(sysconfdir)/perfconfig
744else
745sysconfdir = $(prefix)/etc
746ETC_PERFCONFIG = etc/perfconfig
747endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200748ifndef lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900749ifeq ($(IS_X86_64),1)
750lib = lib64
751else
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100752lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900753endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200754endif # lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900755libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100756
757# Shell quote (do not use $(call) to accommodate ancient setups);
758ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
759DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
760bindir_SQ = $(subst ','\'',$(bindir))
761mandir_SQ = $(subst ','\'',$(mandir))
762infodir_SQ = $(subst ','\'',$(infodir))
763perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
764template_dir_SQ = $(subst ','\'',$(template_dir))
765htmldir_SQ = $(subst ','\'',$(htmldir))
766prefix_SQ = $(subst ','\'',$(prefix))
767sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +0900768libdir_SQ = $(subst ','\'',$(libdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100769
770ifneq ($(filter /%,$(firstword $(perfexecdir))),)
771perfexec_instdir = $(perfexecdir)
772else
773perfexec_instdir = $(prefix)/$(perfexecdir)
774endif
775perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100776
777# If we install to $(HOME) we keep the traceevent default:
778# $(HOME)/.traceevent/plugins
779# Otherwise we install plugins into the global $(libdir).
780ifdef DESTDIR
781plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -0500782plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100783endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100784
785#
786# Print the result of the feature test:
787#
Jiri Olsa8d790762014-02-19 16:52:55 +0100788feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
Jiri Olsa0695e572014-02-19 16:52:54 +0100789
Jiri Olsa8d790762014-02-19 16:52:55 +0100790define feature_print_status_code
Jiri Olsa0695e572014-02-19 16:52:54 +0100791 ifeq ($(feature-$(1)), 1)
792 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
793 else
794 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
795 endif
796endef
797
Jiri Olsa8d790762014-02-19 16:52:55 +0100798feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
799define feature_print_var_code
800 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
801endef
802
803feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
804define feature_print_text_code
805 MSG = $(shell printf '...%30s: %s' $(1) $(2))
806endef
807
Jiri Olsa0695e572014-02-19 16:52:54 +0100808PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
809PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
810
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100811ifeq ($(dwarf-post-unwind),1)
812 PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
813endif
814
Jiri Olsa0695e572014-02-19 16:52:54 +0100815# The $(display_lib) controls the default detection message
816# output. It's set if:
817# - detected features differes from stored features from
818# last build (in PERF-FEATURES file)
819# - one of the $(LIB_FEATURE_TESTS) is not detected
820# - VF is enabled
821
822ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
823 $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
824 display_lib := 1
825endif
826
827feature_check = $(eval $(feature_check_code))
828define feature_check_code
829 ifneq ($(feature-$(1)), 1)
830 display_lib := 1
831 endif
832endef
833
834$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
835
836ifeq ($(VF),1)
837 display_lib := 1
838 display_vf := 1
839endif
840
841ifeq ($(display_lib),1)
842 $(info )
843 $(info Auto-detecting system features:)
Jiri Olsa8d790762014-02-19 16:52:55 +0100844 $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100845
846 ifeq ($(dwarf-post-unwind),1)
847 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
848 endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100849endif
850
851ifeq ($(display_vf),1)
Jiri Olsa8d790762014-02-19 16:52:55 +0100852 $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
853 $(info )
854 $(call feature_print_var,prefix)
855 $(call feature_print_var,bindir)
856 $(call feature_print_var,libdir)
857 $(call feature_print_var,sysconfdir)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100858 $(call feature_print_var,LIBUNWIND_DIR)
859 $(call feature_print_var,LIBDW_DIR)
Jiri Olsa0695e572014-02-19 16:52:54 +0100860endif
861
862ifeq ($(display_lib),1)
863 $(info )
864endif
Jiri Olsaf39e0422014-12-29 15:03:09 +0100865
866$(call detected_var,bindir_SQ)
867$(call detected_var,PYTHON_WORD)
868ifneq ($(OUTPUT),)
869$(call detected_var,OUTPUT)
870endif
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100871$(call detected_var,htmldir_SQ)
872$(call detected_var,infodir_SQ)
873$(call detected_var,mandir_SQ)
Jiri Olsa9352aab2014-12-29 17:42:46 +0100874$(call detected_var,ETC_PERFCONFIG_SQ)
875$(call detected_var,prefix_SQ)
876$(call detected_var,perfexecdir_SQ)
Jiri Olsa3b939a62014-12-30 00:16:01 +0100877$(call detected_var,LIBDIR)
Jiri Olsa88aeea02014-12-30 00:34:23 +0100878$(call detected_var,GTK_CFLAGS)
Jiri Olsac7355f82014-12-30 13:11:32 +0100879$(call detected_var,PERL_EMBED_CCOPTS)
880$(call detected_var,PYTHON_EMBED_CCOPTS)