blob: e80ffe8262b0d1246c77f99e872313a83efde789 [file] [log] [blame]
Jiri Olsa8bd407b2013-03-15 16:28:49 +01001uname_M := $(shell uname -m 2>/dev/null || echo not)
2
3ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
Jiri Olsa8e1b3f62013-04-15 04:06:58 +02004 -e s/arm.*/arm/ -e s/sa110/arm/ \
5 -e s/s390x/s390/ -e s/parisc64/parisc/ \
6 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
7 -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ )
Jiri Olsa8bd407b2013-03-15 16:28:49 +01008NO_PERF_REGS := 1
Jiri Olsa9c12cf92013-03-21 11:30:54 +01009CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
Jiri Olsa8bd407b2013-03-15 16:28:49 +010010
11# Additional ARCH settings for x86
12ifeq ($(ARCH),i386)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020013 override ARCH := x86
14 NO_PERF_REGS := 0
15 LIBUNWIND_LIBS = -lunwind -lunwind-x86
Jiri Olsa8bd407b2013-03-15 16:28:49 +010016endif
17
18ifeq ($(ARCH),x86_64)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020019 override ARCH := x86
20 IS_X86_64 := 0
21 ifeq (, $(findstring m32,$(CFLAGS)))
22 IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1)
23 endif
24 ifeq (${IS_X86_64}, 1)
25 RAW_ARCH := x86_64
Ingo Molnar89fe8082013-09-30 12:07:11 +020026 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020027 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
28 endif
29 NO_PERF_REGS := 0
30 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
Jiri Olsa8bd407b2013-03-15 16:28:49 +010031endif
32
33ifeq ($(NO_PERF_REGS),0)
Ingo Molnar89fe8082013-09-30 12:07:11 +020034 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
Jiri Olsa8bd407b2013-03-15 16:28:49 +010035endif
Jiri Olsaa32f4932013-03-25 00:32:01 +010036
Jiri Olsa7c537462013-05-24 14:35:23 +020037ifeq ($(src-perf),)
38src-perf := $(srctree)/tools/perf
39endif
40
41ifeq ($(obj-perf),)
Robert Richter107de372013-06-11 17:22:38 +020042obj-perf := $(OUTPUT)
Jiri Olsa7c537462013-05-24 14:35:23 +020043endif
44
45ifneq ($(obj-perf),)
46obj-perf := $(abspath $(obj-perf))/
47endif
48
Robert Richter4e319022013-06-11 17:29:18 +020049LIB_INCLUDE := $(srctree)/tools/lib/
50
Jiri Olsa7c537462013-05-24 14:35:23 +020051# include ARCH specific config
52-include $(src-perf)/arch/$(ARCH)/Makefile
53
Jiri Olsa7c537462013-05-24 14:35:23 +020054include $(src-perf)/config/utilities.mak
Jiri Olsaa32f4932013-03-25 00:32:01 +010055
56ifeq ($(call get-executable,$(FLEX)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020057 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +010058endif
59
60ifeq ($(call get-executable,$(BISON)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020061 dummy := $(error Error: $(BISON) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +010062endif
Jiri Olsa362493f2013-03-25 00:40:48 +010063
64# Treat warnings as errors unless directed not to
65ifneq ($(WERROR),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020066 CFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +010067endif
68
69ifeq ("$(origin DEBUG)", "command line")
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020070 PERF_DEBUG = $(DEBUG)
Jiri Olsa362493f2013-03-25 00:40:48 +010071endif
72ifndef PERF_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020073 CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +010074endif
75
76ifdef PARSER_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020077 PARSER_DEBUG_BISON := -t
78 PARSER_DEBUG_FLEX := -d
79 CFLAGS += -DPARSER_DEBUG
Jiri Olsa362493f2013-03-25 00:40:48 +010080endif
81
Jiri Olsa2fe73742013-04-15 04:32:28 +020082CFLAGS += -fno-omit-frame-pointer
83CFLAGS += -ggdb3
84CFLAGS += -funwind-tables
85CFLAGS += -Wall
86CFLAGS += -Wextra
87CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +010088
David Ahern6d199122013-09-22 19:44:57 -060089EXTLIBS = -lelf -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +010090
Ingo Molnarbaa9c302013-10-01 14:14:31 +020091feature_check = $(eval $(feature_check_code))
Ingo Molnarb6aa9972013-09-30 10:08:24 +020092define feature_check_code
Ingo Molnarbaa9c302013-10-01 14:14:31 +020093 feature-$(1) := $(shell $(MAKE) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
94endef
95
96feature_set = $(eval $(feature_set_code))
97define feature_set_code
98 feature-$(1) := 1
Ingo Molnarb6aa9972013-09-30 10:08:24 +020099endef
100
101#
102# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
103#
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200104
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200105#
106# Note that this is not a complete list of all feature tests, just
107# those that are typically built on a fully configured system.
108#
109# [ Feature tests not mentioned here have to be built explicitly in
110# the rule that uses them - an example for that is the 'bionic'
111# feature check. ]
112#
113CORE_FEATURE_TESTS = \
114 backtrace \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200115 dwarf \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200116 fortify-source \
117 glibc \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200118 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200119 gtk2-infobar \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200120 libaudit \
121 libbfd \
122 libelf \
123 libelf-getphdrnum \
124 libelf-mmap \
125 libnuma \
Ingo Molnar7181a672013-09-30 15:15:36 +0200126 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200127 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200128 libpython-version \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200129 libslang \
130 libunwind \
Ingo Molnar34ef2162013-09-30 16:46:49 +0200131 on-exit \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200132 stackprotector \
133 stackprotector-all \
134 volatile-register-var
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200135
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200136#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200137# So here we detect whether test-all was rebuilt, to be able
138# to skip the print-out of the long features list if the file
139# existed before and after it was built:
140#
141ifeq ($(wildcard config/feature-checks/test-all),)
142 test-all-failed := 1
143else
144 test-all-failed := 0
145endif
146
147#
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200148# Special fast-path for the 'all features are available' case:
149#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200150$(call feature_check,all,$(MSG))
151
152#
153# Just in case the build freshly failed, make sure we print the
154# feature matrix:
155#
156ifeq ($(feature-all), 0)
157 test-all-failed := 1
158endif
159
160ifeq ($(test-all-failed),1)
161 $(info )
162 $(info Auto-detecting system features:)
163endif
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200164
165ifeq ($(feature-all), 1)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200166 #
167 # test-all.c passed - just set all the core feature flags to 1:
168 #
169 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200170else
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200171 $(shell $(MAKE) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
172 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200173endif
174
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200175#
176# Print the result of the feature test:
177#
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200178feature_print = $(eval $(feature_print_code))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200179define feature_print_code
180 ifeq ($(feature-$(1)), 1)
Ingo Molnar73a725f2013-10-02 11:58:30 +0200181 MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200182 else
Ingo Molnar73a725f2013-10-02 11:58:30 +0200183 MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200184 endif
185 $(info $(MSG))
186endef
187
Ingo Molnarb3b64a12013-10-02 10:01:42 +0200188#
189# Only print out our features if we rebuilt the testcases or if a test failed:
190#
191ifeq ($(test-all-failed), 1)
192 $(foreach feat,$(CORE_FEATURE_TESTS) DUMMY,$(call feature_print,$(feat)))
193 $(info )
194endif
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200195
Ingo Molnar90ac5422013-09-30 13:48:44 +0200196ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200197 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100198endif
199
Ingo Molnar430be5a2013-10-07 09:47:00 +0200200ifeq ($(feature-stackprotector), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200201 CFLAGS += -Wstack-protector
Jiri Olsa362493f2013-03-25 00:40:48 +0100202endif
203
Ingo Molnarc2510442013-09-30 13:58:12 +0200204ifeq ($(feature-volatile-register-var), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200205 CFLAGS += -Wvolatile-register-var
Jiri Olsa362493f2013-03-25 00:40:48 +0100206endif
207
208ifndef PERF_DEBUG
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200209 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200210 CFLAGS += -D_FORTIFY_SOURCE=2
211 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100212endif
213
Jiri Olsa2fe73742013-04-15 04:32:28 +0200214CFLAGS += -I$(src-perf)/util/include
215CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
216CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
217CFLAGS += -I$(srctree)/arch/$(ARCH)/include
218CFLAGS += -I$(srctree)/include/uapi
219CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200220
221# $(obj-perf) for generated common-cmds.h
222# $(obj-perf)/util for generated bison/flex headers
223ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200224CFLAGS += -I$(obj-perf)/util
225CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200226endif
227
Jiri Olsa2fe73742013-04-15 04:32:28 +0200228CFLAGS += -I$(src-perf)/util
229CFLAGS += -I$(src-perf)
Robert Richter4e319022013-06-11 17:29:18 +0200230CFLAGS += -I$(LIB_INCLUDE)
Jiri Olsa7c537462013-05-24 14:35:23 +0200231
Jiri Olsa2fe73742013-04-15 04:32:28 +0200232CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100233
Jiri Olsa4e22db42013-05-24 14:35:24 +0200234ifndef NO_BIONIC
Ingo Molnar78e9d652013-09-30 14:11:46 +0200235 $(feature_check,bionic)
236 ifeq ($(feature-bionic), 1)
237 BIONIC := 1
238 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
239 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
240 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100241endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100242
243ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200244 NO_DWARF := 1
245 NO_DEMANGLE := 1
246 NO_LIBUNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100247else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200248 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200249 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200250 LIBC_SUPPORT := 1
251 endif
252 ifeq ($(BIONIC),1)
253 LIBC_SUPPORT := 1
254 endif
255 ifeq ($(LIBC_SUPPORT),1)
256 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100257
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200258 NO_LIBELF := 1
259 NO_DWARF := 1
260 NO_DEMANGLE := 1
261 else
262 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
263 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200264 else
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200265 # for linking with debug library, run like:
266 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
267 ifdef LIBDW_DIR
268 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
269 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
270 endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100271
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200272 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200273 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);
274 NO_DWARF := 1
275 endif # Dwarf support
Ingo Molnar0648f832013-10-02 15:30:35 +0200276 endif # libelf support
Jiri Olsacf4cca12013-03-25 00:45:08 +0100277endif # NO_LIBELF
278
279ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200280 CFLAGS += -DHAVE_LIBELF_SUPPORT
281 FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
Jiri Olsa779724f2013-03-25 00:48:14 +0100282
Ingo Molnar8869b172013-09-30 15:02:28 +0200283 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200284 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
285 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100286
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200287 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200288 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
289 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100290
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200291 # include ARCH specific config
292 -include $(src-perf)/arch/$(ARCH)/Makefile
293
294 ifndef NO_DWARF
295 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
296 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
297 NO_DWARF := 1
298 else
299 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
300 LDFLAGS += $(LIBDW_LDFLAGS)
301 EXTLIBS += -lelf -ldw
302 endif # PERF_HAVE_DWARF_REGS
303 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100304endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100305
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100306ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200307 CFLAGS += -DHAVE_LIBELF_SUPPORT
Ingo Molnar8869b172013-09-30 15:02:28 +0200308 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200309 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200310 endif
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100311endif # NO_LIBELF
312
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100313# There's only x86 (both 32 and 64) support for CFI unwind so far
314ifneq ($(ARCH),x86)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200315 NO_LIBUNWIND := 1
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100316endif
317
318ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200319 #
320 # For linking with debug library, run like:
321 #
322 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
323 #
Ingo Molnar308e1e72013-10-07 10:30:47 +0200324 ifdef LIBUNWIND_DIR
325 LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
326 LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
327 endif
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100328
Ingo Molnar058f9522013-09-30 14:45:44 +0200329 ifneq ($(feature-libunwind), 1)
Ingo Molnar308e1e72013-10-07 10:30:47 +0200330 msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99);
331 NO_LIBUNWIND := 1
332 endif
333endif
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100334
335ifndef NO_LIBUNWIND
Ingo Molnar89fe8082013-09-30 12:07:11 +0200336 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200337 EXTLIBS += $(LIBUNWIND_LIBS)
338 CFLAGS += $(LIBUNWIND_CFLAGS)
339 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200340endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100341
342ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200343 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200344 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
345 NO_LIBAUDIT := 1
346 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200347 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200348 EXTLIBS += -laudit
349 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100350endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100351
352ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200353 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100354endif
355
356ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200357 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200358 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
359 NO_SLANG := 1
360 else
361 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
362 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200363 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200364 EXTLIBS += -lslang
365 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100366endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100367
368ifndef NO_GTK2
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200369 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200370 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200371 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
372 NO_GTK2 := 1
373 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200374 ifeq ($(feature-gtk2-infobar), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200375 CFLAGS += -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200376 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200377 CFLAGS += -DHAVE_GTK2_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200378 CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
379 EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
380 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100381endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100382
383grep-libs = $(filter -l%,$(1))
384strip-libs = $(filter-out -l%,$(1))
385
386ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200387 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100388else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200389 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
390 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
391 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
392 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
393 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100394
Ingo Molnar7181a672013-09-30 15:15:36 +0200395 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200396 CFLAGS += -DNO_LIBPERL
397 NO_LIBPERL := 1
398 else
399 LDFLAGS += $(PERL_EMBED_LDFLAGS)
400 EXTLIBS += $(PERL_EMBED_LIBADD)
401 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100402endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100403
404disable-python = $(eval $(disable-python_code))
405define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100406 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100407 $(if $(1),$(warning No $(1) was found))
408 $(warning Python support will not be built)
409 NO_LIBPYTHON := 1
410endef
411
412override PYTHON := \
413 $(call get-executable-or-default,PYTHON,python)
414
415ifndef PYTHON
416 $(call disable-python,python interpreter)
417else
418
419 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
420
421 ifdef NO_LIBPYTHON
422 $(call disable-python)
423 else
424
425 override PYTHON_CONFIG := \
426 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
427
428 ifndef PYTHON_CONFIG
429 $(call disable-python,python-config tool)
430 else
431
432 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
433
434 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
435 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
436 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
437 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
438 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
439
Ingo Molnar97341632013-09-30 15:18:37 +0200440 ifneq ($(feature-libpython), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100441 $(call disable-python,Python.h (for Python 2.x))
442 else
443
Ingo Molnar95d061c2013-09-30 15:40:04 +0200444 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100445 $(warning Python 3 is not yet supported; please set)
446 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
447 $(warning If you also have Python 2 installed, then)
448 $(warning try something like:)
449 $(warning $(and ,))
450 $(warning $(and ,) make PYTHON=python2)
451 $(warning $(and ,))
452 $(warning Otherwise, disable Python support entirely:)
453 $(warning $(and ,))
454 $(warning $(and ,) make NO_LIBPYTHON=1)
455 $(warning $(and ,))
456 $(error $(and ,))
457 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100458 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100459 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200460 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100461 endif
462 endif
463 endif
464 endif
465endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100466
467ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200468 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100469else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200470 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200471 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200472 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200473 else
Ingo Molnar3b7646e2013-09-30 15:53:31 +0200474 ifeq ($(feature-libbfd), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200475 EXTLIBS += -lbfd
476 else
Ingo Molnar1c476612013-10-02 15:15:09 +0200477 $(feature_check,liberty)
478 ifeq ($(feature-liberty), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200479 EXTLIBS += -lbfd -liberty
480 else
Ingo Molnar1c476612013-10-02 15:15:09 +0200481 $(feature_check,liberty-z)
482 ifeq ($(feature-liberty-z), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200483 EXTLIBS += -lbfd -liberty -lz
484 else
Ingo Molnar1c476612013-10-02 15:15:09 +0200485 $(feature_check,cplus-demangle)
486 ifeq ($(feature-cplus-demangle), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200487 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200488 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200489 else
490 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
491 CFLAGS += -DNO_DEMANGLE
492 endif
493 endif
494 endif
495 endif
496 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100497endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100498
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100499ifndef NO_ON_EXIT
Ingo Molnar34ef2162013-09-30 16:46:49 +0200500 ifeq ($(feature-on-exit), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200501 CFLAGS += -DHAVE_ON_EXIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200502 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100503endif
504
505ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200506 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200507 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200508 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100509endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100510
511ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200512 ifeq ($(feature-libnuma), 0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200513 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
514 NO_LIBNUMA := 1
515 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200516 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200517 EXTLIBS += -lnuma
518 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100519endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100520
521# Among the variables below, these:
522# perfexecdir
523# template_dir
524# mandir
525# infodir
526# htmldir
527# ETC_PERFCONFIG (but not sysconfdir)
528# can be specified as a relative path some/where/else;
529# this is interpreted as relative to $(prefix) and "perf" at
530# runtime figures out where they are based on the path to the executable.
531# This can help installing the suite in a relocatable way.
532
533# Make the path relative to DESTDIR, not to prefix
534ifndef DESTDIR
535prefix = $(HOME)
536endif
537bindir_relative = bin
538bindir = $(prefix)/$(bindir_relative)
539mandir = share/man
540infodir = share/info
541perfexecdir = libexec/perf-core
542sharedir = $(prefix)/share
543template_dir = share/perf-core/templates
544htmldir = share/doc/perf-doc
545ifeq ($(prefix),/usr)
546sysconfdir = /etc
547ETC_PERFCONFIG = $(sysconfdir)/perfconfig
548else
549sysconfdir = $(prefix)/etc
550ETC_PERFCONFIG = etc/perfconfig
551endif
552lib = lib
553
554# Shell quote (do not use $(call) to accommodate ancient setups);
555ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
556DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
557bindir_SQ = $(subst ','\'',$(bindir))
558mandir_SQ = $(subst ','\'',$(mandir))
559infodir_SQ = $(subst ','\'',$(infodir))
560perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
561template_dir_SQ = $(subst ','\'',$(template_dir))
562htmldir_SQ = $(subst ','\'',$(htmldir))
563prefix_SQ = $(subst ','\'',$(prefix))
564sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
565
566ifneq ($(filter /%,$(firstword $(perfexecdir))),)
567perfexec_instdir = $(perfexecdir)
568else
569perfexec_instdir = $(prefix)/$(perfexecdir)
570endif
571perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))