blob: e7f83b15fcbfe7dc1560d1e97f37f63119305a89 [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#
Jiri Olsaee9c80a2015-03-01 20:32:42 +0100206FEATURE_TESTS = \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200207 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 Olsa07efbf52015-03-01 20:44:18 +0100231FEATURE_DISPLAY = \
Jiri Olsa0695e572014-02-19 16:52:54 +0100232 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
Jiri Olsaee9c80a2015-03-01 20:32:42 +0100246# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
Jiri Olsac4eb6c02014-01-07 13:47:18 +0100247# 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
Jiri Olsaee9c80a2015-03-01 20:32:42 +0100255$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
Jiri Olsac4eb6c02014-01-07 13:47:18 +0100256
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 #
Jiri Olsaee9c80a2015-03-01 20:32:42 +0100270 $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200271else
Jiri Olsaee9c80a2015-03-01 20:32:42 +0100272 $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
273 $(foreach feat,$(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)
Jiri Olsa9444e872015-03-01 20:11:24 +0100303CFLAGS += -I$(srctree)/tools/lib/
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 Olsa709e6792014-12-29 23:52:25 +0100369 $(call detected,CONFIG_LIBELF)
Jiri Olsa779724f2013-03-25 00:48:14 +0100370
Ingo Molnar8869b172013-09-30 15:02:28 +0200371 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200372 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
373 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100374
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200375 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200376 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
377 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100378
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200379 # include ARCH specific config
380 -include $(src-perf)/arch/$(ARCH)/Makefile
381
382 ifndef NO_DWARF
383 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
384 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
385 NO_DWARF := 1
386 else
387 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
388 LDFLAGS += $(LIBDW_LDFLAGS)
Namhyung Kim5e2d4d02014-11-07 14:20:06 +0900389 EXTLIBS += -ldw
Jiri Olsa8379fce2014-12-30 00:06:25 +0100390 $(call detected,CONFIG_DWARF)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200391 endif # PERF_HAVE_DWARF_REGS
392 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100393endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100394
Anton Blanchard65ccb4f2014-08-25 18:25:06 +1000395ifeq ($(ARCH),powerpc)
396 ifndef NO_DWARF
397 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
398 endif
399endif
400
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100401ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200402 ifneq ($(feature-libunwind), 1)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100403 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
Ingo Molnar308e1e72013-10-07 10:30:47 +0200404 NO_LIBUNWIND := 1
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100405 endif
406endif
407
408dwarf-post-unwind := 1
409dwarf-post-unwind-text := BUG
410
411# setup DWARF post unwinder
412ifdef NO_LIBUNWIND
413 ifdef NO_LIBDW_DWARF_UNWIND
414 msg := $(warning Disabling post unwind, no support found.);
415 dwarf-post-unwind := 0
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900416 else
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100417 dwarf-post-unwind-text := libdw
Jiri Olsab2e45c32014-12-30 00:11:11 +0100418 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100419 endif
420else
421 dwarf-post-unwind-text := libunwind
Jiri Olsab2e45c32014-12-30 00:11:11 +0100422 $(call detected,CONFIG_LIBUNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100423 # Enable libunwind support by default.
424 ifndef NO_LIBDW_DWARF_UNWIND
425 NO_LIBDW_DWARF_UNWIND := 1
426 endif
427endif
428
429ifeq ($(dwarf-post-unwind),1)
430 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
Jiri Olsaf39e0422014-12-29 15:03:09 +0100431 $(call detected,CONFIG_DWARF_UNWIND)
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100432else
433 NO_DWARF_UNWIND := 1
434endif
435
436ifndef NO_LIBUNWIND
Jean Pihet8ab596a2014-04-28 14:32:33 +0200437 ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100438 $(call feature_check,libunwind-debug-frame)
439 ifneq ($(feature-libunwind-debug-frame), 1)
440 msg := $(warning No debug_frame support found in libunwind);
Linus Torvaldsf47671e2013-11-14 08:51:29 +0900441 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
442 endif
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100443 else
444 # non-ARM has no dwarf_find_debug_frame() function:
445 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
446 endif
447 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
448 EXTLIBS += $(LIBUNWIND_LIBS)
449 CFLAGS += $(LIBUNWIND_CFLAGS)
450 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200451endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100452
453ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200454 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200455 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
456 NO_LIBAUDIT := 1
457 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200458 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200459 EXTLIBS += -laudit
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100460 $(call detected,CONFIG_AUDIT)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200461 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100462endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100463
464ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200465 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100466endif
467
468ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200469 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200470 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
471 NO_SLANG := 1
472 else
473 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
474 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200475 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200476 EXTLIBS += -lslang
Jiri Olsacf15c742014-12-30 00:27:52 +0100477 $(call detected,CONFIG_SLANG)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200478 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100479endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100480
481ifndef NO_GTK2
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000482 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200483 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200484 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
485 NO_GTK2 := 1
486 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200487 ifeq ($(feature-gtk2-infobar), 1)
Namhyung Kimfc672972013-09-13 15:27:43 +0900488 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200489 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200490 CFLAGS += -DHAVE_GTK2_SUPPORT
Mark Rutlanda8a5cd82014-01-15 10:44:08 +0000491 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
492 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
Jiri Olsae2137082013-09-26 20:55:54 +0200493 EXTLIBS += -ldl
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200494 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100495endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100496
497grep-libs = $(filter -l%,$(1))
498strip-libs = $(filter-out -l%,$(1))
499
500ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200501 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100502else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200503 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
504 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
505 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
506 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
507 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100508
Ingo Molnar7181a672013-09-30 15:15:36 +0200509 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200510 CFLAGS += -DNO_LIBPERL
511 NO_LIBPERL := 1
Ingo Molnara954e682015-02-28 09:39:09 +0100512 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200513 else
514 LDFLAGS += $(PERL_EMBED_LDFLAGS)
515 EXTLIBS += $(PERL_EMBED_LIBADD)
Jiri Olsac7355f82014-12-30 13:11:32 +0100516 $(call detected,CONFIG_LIBPERL)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200517 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100518endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100519
David Ahern87419c92013-10-29 10:43:16 -0600520ifeq ($(feature-timerfd), 1)
521 CFLAGS += -DHAVE_TIMERFD_SUPPORT
522else
523 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
524endif
525
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100526disable-python = $(eval $(disable-python_code))
527define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100528 CFLAGS += -DNO_LIBPYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100529 $(warning $1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100530 NO_LIBPYTHON := 1
531endef
532
Namhyung Kim56c7d792014-07-29 15:57:19 +0900533ifdef NO_LIBPYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100534 $(call disable-python,Python support disabled by user)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100535else
536
Namhyung Kim56c7d792014-07-29 15:57:19 +0900537 ifndef PYTHON
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100538 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100539 else
Namhyung Kim56c7d792014-07-29 15:57:19 +0900540 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100541
542 ifndef PYTHON_CONFIG
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100543 $(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 +0100544 else
545
546 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
547
548 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
549 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
550 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
551 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
552 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
553
Ingo Molnar97341632013-09-30 15:18:37 +0200554 ifneq ($(feature-libpython), 1)
Ingo Molnar6c5aa232015-02-28 09:33:45 +0100555 $(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 +0100556 else
557
Ingo Molnar95d061c2013-09-30 15:40:04 +0200558 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100559 $(warning Python 3 is not yet supported; please set)
560 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
561 $(warning If you also have Python 2 installed, then)
562 $(warning try something like:)
563 $(warning $(and ,))
564 $(warning $(and ,) make PYTHON=python2)
565 $(warning $(and ,))
566 $(warning Otherwise, disable Python support entirely:)
567 $(warning $(and ,))
568 $(warning $(and ,) make NO_LIBPYTHON=1)
569 $(warning $(and ,))
570 $(error $(and ,))
571 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100572 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100573 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200574 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsac7355f82014-12-30 13:11:32 +0100575 $(call detected,CONFIG_LIBPYTHON)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100576 endif
577 endif
578 endif
579 endif
580endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100581
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200582ifeq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200583 EXTLIBS += -lbfd
584
585 # call all detections now so we get correct
586 # status in VF output
587 $(call feature_check,liberty)
588 $(call feature_check,liberty-z)
589 $(call feature_check,cplus-demangle)
590
591 ifeq ($(feature-liberty), 1)
592 EXTLIBS += -liberty
593 else
594 ifeq ($(feature-liberty-z), 1)
595 EXTLIBS += -liberty -lz
596 endif
597 endif
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200598endif
599
Jiri Olsac3cf8362013-03-18 00:38:16 +0100600ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200601 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100602else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200603 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200604 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200605 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200606 else
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200607 ifneq ($(feature-libbfd), 1)
Jiri Olsa2cf90402014-04-23 16:53:25 +0200608 ifneq ($(feature-liberty), 1)
609 ifneq ($(feature-liberty-z), 1)
610 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
611 # or any of 'bfd iberty z' trinity
Ingo Molnar1c476612013-10-02 15:15:09 +0200612 ifeq ($(feature-cplus-demangle), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200613 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200614 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200615 else
Ingo Molnar0189d7c2015-02-28 09:46:42 +0100616 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 +0200617 CFLAGS += -DNO_DEMANGLE
618 endif
619 endif
620 endif
621 endif
622 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100623endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100624
Jiri Olsa3e6a1472013-10-10 22:24:00 +0200625ifneq ($(filter -lbfd,$(EXTLIBS)),)
626 CFLAGS += -DHAVE_LIBBFD_SUPPORT
627endif
628
Namhyung Kime92ce122014-10-31 16:51:38 +0900629ifndef NO_ZLIB
630 ifeq ($(feature-zlib), 1)
631 CFLAGS += -DHAVE_ZLIB_SUPPORT
632 EXTLIBS += -lz
Jiri Olsa1571b692014-12-30 13:31:12 +0100633 $(call detected,CONFIG_ZLIB)
Namhyung Kime92ce122014-10-31 16:51:38 +0900634 else
635 NO_ZLIB := 1
636 endif
637endif
638
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100639ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200640 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200641 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200642 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100643endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100644
645ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200646 ifeq ($(feature-libnuma), 0)
Dongsheng Yang6305edf2013-12-02 10:26:48 -0500647 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200648 NO_LIBNUMA := 1
649 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200650 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200651 EXTLIBS += -lnuma
Jiri Olsa72965b82014-12-29 13:52:36 +0100652 $(call detected,CONFIG_NUMA)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200653 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100654endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100655
Alexander Yaryginda50ad62014-07-03 17:59:49 +0400656ifdef HAVE_KVM_STAT_SUPPORT
657 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
658endif
659
Adrian Huntere477f3f2014-10-23 18:16:03 -0300660ifeq (${IS_64_BIT}, 1)
661 ifndef NO_PERF_READ_VDSO32
662 $(call feature_check,compile-32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300663 ifeq ($(feature-compile-32), 1)
664 CFLAGS += -DHAVE_PERF_READ_VDSO32
665 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300666 NO_PERF_READ_VDSO32 := 1
667 endif
668 endif
H.J. Lu76aea772015-03-17 15:27:48 -0700669 ifneq ($(ARCH), x86)
Adrian Huntere477f3f2014-10-23 18:16:03 -0300670 NO_PERF_READ_VDSOX32 := 1
671 endif
672 ifndef NO_PERF_READ_VDSOX32
673 $(call feature_check,compile-x32)
Adrian Hunter46b1fa82014-10-23 13:45:24 +0300674 ifeq ($(feature-compile-x32), 1)
675 CFLAGS += -DHAVE_PERF_READ_VDSOX32
676 else
Adrian Huntere477f3f2014-10-23 18:16:03 -0300677 NO_PERF_READ_VDSOX32 := 1
678 endif
679 endif
680else
681 NO_PERF_READ_VDSO32 := 1
682 NO_PERF_READ_VDSOX32 := 1
683endif
684
Jiri Olsa53d0a572015-02-20 23:16:58 +0100685ifndef NO_LIBBABELTRACE
Jiri Olsa97e7a512015-03-11 09:00:41 +0100686 $(call feature_check,libbabeltrace)
687 ifeq ($(feature-libbabeltrace), 1)
Jiri Olsa53d0a572015-02-20 23:16:58 +0100688 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
689 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
690 EXTLIBS += -lbabeltrace-ctf
Jiri Olsaedbe9812015-02-20 23:17:00 +0100691 $(call detected,CONFIG_LIBBABELTRACE)
Jiri Olsa97e7a512015-03-11 09:00:41 +0100692 else
693 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
694 NO_LIBBABELTRACE := 1
Jiri Olsa53d0a572015-02-20 23:16:58 +0100695 endif
696endif
697
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100698# Among the variables below, these:
699# perfexecdir
700# template_dir
701# mandir
702# infodir
703# htmldir
704# ETC_PERFCONFIG (but not sysconfdir)
705# can be specified as a relative path some/where/else;
706# this is interpreted as relative to $(prefix) and "perf" at
707# runtime figures out where they are based on the path to the executable.
708# This can help installing the suite in a relocatable way.
709
710# Make the path relative to DESTDIR, not to prefix
711ifndef DESTDIR
Jianyu Zhanfc9cabe2014-06-03 00:44:34 +0800712prefix ?= $(HOME)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100713endif
714bindir_relative = bin
715bindir = $(prefix)/$(bindir_relative)
716mandir = share/man
717infodir = share/info
718perfexecdir = libexec/perf-core
719sharedir = $(prefix)/share
720template_dir = share/perf-core/templates
721htmldir = share/doc/perf-doc
722ifeq ($(prefix),/usr)
723sysconfdir = /etc
724ETC_PERFCONFIG = $(sysconfdir)/perfconfig
725else
726sysconfdir = $(prefix)/etc
727ETC_PERFCONFIG = etc/perfconfig
728endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200729ifndef lib
H.J. Lu76aea772015-03-17 15:27:48 -0700730ifeq ($(ARCH)$(IS_64_BIT), x861)
Namhyung Kimfc672972013-09-13 15:27:43 +0900731lib = lib64
732else
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100733lib = lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900734endif
Jiri Olsa6997af722014-08-25 16:55:52 +0200735endif # lib
Namhyung Kimfc672972013-09-13 15:27:43 +0900736libdir = $(prefix)/$(lib)
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100737
738# Shell quote (do not use $(call) to accommodate ancient setups);
739ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
740DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
741bindir_SQ = $(subst ','\'',$(bindir))
742mandir_SQ = $(subst ','\'',$(mandir))
743infodir_SQ = $(subst ','\'',$(infodir))
744perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
745template_dir_SQ = $(subst ','\'',$(template_dir))
746htmldir_SQ = $(subst ','\'',$(htmldir))
747prefix_SQ = $(subst ','\'',$(prefix))
748sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
Namhyung Kimfc672972013-09-13 15:27:43 +0900749libdir_SQ = $(subst ','\'',$(libdir))
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100750
751ifneq ($(filter /%,$(firstword $(perfexecdir))),)
752perfexec_instdir = $(perfexecdir)
753else
754perfexec_instdir = $(prefix)/$(perfexecdir)
755endif
756perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100757
758# If we install to $(HOME) we keep the traceevent default:
759# $(HOME)/.traceevent/plugins
760# Otherwise we install plugins into the global $(libdir).
761ifdef DESTDIR
762plugindir=$(libdir)/traceevent/plugins
Josh Boyerb935a582014-01-22 10:01:48 -0500763plugindir_SQ= $(subst ','\'',$(plugindir))
Jiri Olsa3d7c0142013-12-03 14:09:21 +0100764endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100765
766#
767# Print the result of the feature test:
768#
Jiri Olsa8d790762014-02-19 16:52:55 +0100769feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
Jiri Olsa0695e572014-02-19 16:52:54 +0100770
Jiri Olsa8d790762014-02-19 16:52:55 +0100771define feature_print_status_code
Jiri Olsa0695e572014-02-19 16:52:54 +0100772 ifeq ($(feature-$(1)), 1)
773 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
774 else
775 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
776 endif
777endef
778
Jiri Olsa4b20d682015-03-02 13:30:30 +0100779print_var = $(eval $(print_var_code)) $(info $(MSG))
780define print_var_code
Jiri Olsa8d790762014-02-19 16:52:55 +0100781 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
782endef
783
784feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
785define feature_print_text_code
786 MSG = $(shell printf '...%30s: %s' $(1) $(2))
787endef
788
Jiri Olsa4ae61202015-03-01 20:50:47 +0100789FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
790FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
Jiri Olsa0695e572014-02-19 16:52:54 +0100791
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100792ifeq ($(dwarf-post-unwind),1)
Jiri Olsa4ae61202015-03-01 20:50:47 +0100793 FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100794endif
795
Jiri Olsa48e383e2015-03-01 20:46:28 +0100796# The $(feature_display) controls the default detection message
Jiri Olsa0695e572014-02-19 16:52:54 +0100797# output. It's set if:
798# - detected features differes from stored features from
Jiri Olsa4ae61202015-03-01 20:50:47 +0100799# last build (in FEATURE-DUMP file)
Jiri Olsa07efbf52015-03-01 20:44:18 +0100800# - one of the $(FEATURE_DISPLAY) is not detected
Jiri Olsa0695e572014-02-19 16:52:54 +0100801# - VF is enabled
802
Jiri Olsa4ae61202015-03-01 20:50:47 +0100803ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
804 $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
Jiri Olsa48e383e2015-03-01 20:46:28 +0100805 feature_display := 1
Jiri Olsa0695e572014-02-19 16:52:54 +0100806endif
807
808feature_check = $(eval $(feature_check_code))
809define feature_check_code
810 ifneq ($(feature-$(1)), 1)
Jiri Olsa48e383e2015-03-01 20:46:28 +0100811 feature_display := 1
Jiri Olsa0695e572014-02-19 16:52:54 +0100812 endif
813endef
814
Jiri Olsa07efbf52015-03-01 20:44:18 +0100815$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
Jiri Olsa0695e572014-02-19 16:52:54 +0100816
817ifeq ($(VF),1)
Jiri Olsa48e383e2015-03-01 20:46:28 +0100818 feature_display := 1
Jiri Olsaa15599a2015-03-01 20:58:24 +0100819 feature_verbose := 1
Jiri Olsa0695e572014-02-19 16:52:54 +0100820endif
821
Jiri Olsa48e383e2015-03-01 20:46:28 +0100822ifeq ($(feature_display),1)
Jiri Olsa0695e572014-02-19 16:52:54 +0100823 $(info )
824 $(info Auto-detecting system features:)
Jiri Olsa07efbf52015-03-01 20:44:18 +0100825 $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
Jiri Olsa0a4f2b62014-02-19 16:52:58 +0100826
827 ifeq ($(dwarf-post-unwind),1)
828 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
829 endif
Jiri Olsa4b20d682015-03-02 13:30:30 +0100830
831 ifneq ($(feature_verbose),1)
832 $(info )
833 endif
Jiri Olsa0695e572014-02-19 16:52:54 +0100834endif
835
Jiri Olsaa15599a2015-03-01 20:58:24 +0100836ifeq ($(feature_verbose),1)
Jiri Olsa07efbf52015-03-01 20:44:18 +0100837 TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
838 $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
Jiri Olsa8d790762014-02-19 16:52:55 +0100839 $(info )
Jiri Olsa4b20d682015-03-02 13:30:30 +0100840 $(call print_var,prefix)
841 $(call print_var,bindir)
842 $(call print_var,libdir)
843 $(call print_var,sysconfdir)
844 $(call print_var,LIBUNWIND_DIR)
845 $(call print_var,LIBDW_DIR)
Jiri Olsa0695e572014-02-19 16:52:54 +0100846 $(info )
847endif
Jiri Olsaf39e0422014-12-29 15:03:09 +0100848
849$(call detected_var,bindir_SQ)
850$(call detected_var,PYTHON_WORD)
851ifneq ($(OUTPUT),)
852$(call detected_var,OUTPUT)
853endif
Jiri Olsa285ab8b2014-12-29 15:13:44 +0100854$(call detected_var,htmldir_SQ)
855$(call detected_var,infodir_SQ)
856$(call detected_var,mandir_SQ)
Jiri Olsa9352aab2014-12-29 17:42:46 +0100857$(call detected_var,ETC_PERFCONFIG_SQ)
858$(call detected_var,prefix_SQ)
859$(call detected_var,perfexecdir_SQ)
Jiri Olsa3b939a62014-12-30 00:16:01 +0100860$(call detected_var,LIBDIR)
Jiri Olsa88aeea02014-12-30 00:34:23 +0100861$(call detected_var,GTK_CFLAGS)
Jiri Olsac7355f82014-12-30 13:11:32 +0100862$(call detected_var,PERL_EMBED_CCOPTS)
863$(call detected_var,PYTHON_EMBED_CCOPTS)