blob: 581a94211fea21666fea56eaaf5f9445af5c0411 [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
54include $(src-perf)/config/feature-tests.mak
55include $(src-perf)/config/utilities.mak
Jiri Olsaa32f4932013-03-25 00:32:01 +010056
57ifeq ($(call get-executable,$(FLEX)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020058 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +010059endif
60
61ifeq ($(call get-executable,$(BISON)),)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020062 dummy := $(error Error: $(BISON) is missing on this system, please install it)
Jiri Olsaa32f4932013-03-25 00:32:01 +010063endif
Jiri Olsa362493f2013-03-25 00:40:48 +010064
65# Treat warnings as errors unless directed not to
66ifneq ($(WERROR),0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020067 CFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +010068endif
69
70ifeq ("$(origin DEBUG)", "command line")
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020071 PERF_DEBUG = $(DEBUG)
Jiri Olsa362493f2013-03-25 00:40:48 +010072endif
73ifndef PERF_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020074 CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +010075endif
76
77ifdef PARSER_DEBUG
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020078 PARSER_DEBUG_BISON := -t
79 PARSER_DEBUG_FLEX := -d
80 CFLAGS += -DPARSER_DEBUG
Jiri Olsa362493f2013-03-25 00:40:48 +010081endif
82
Jiri Olsa2fe73742013-04-15 04:32:28 +020083CFLAGS += -fno-omit-frame-pointer
84CFLAGS += -ggdb3
85CFLAGS += -funwind-tables
86CFLAGS += -Wall
87CFLAGS += -Wextra
88CFLAGS += -std=gnu99
Jiri Olsa9c12cf92013-03-21 11:30:54 +010089
David Ahern6d199122013-09-22 19:44:57 -060090EXTLIBS = -lelf -lpthread -lrt -lm -ldl
Jiri Olsa362493f2013-03-25 00:40:48 +010091
Ingo Molnarbaa9c302013-10-01 14:14:31 +020092feature_check = $(eval $(feature_check_code))
Ingo Molnarb6aa9972013-09-30 10:08:24 +020093define feature_check_code
Ingo Molnarbaa9c302013-10-01 14:14:31 +020094 feature-$(1) := $(shell $(MAKE) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
95endef
96
97feature_set = $(eval $(feature_set_code))
98define feature_set_code
99 feature-$(1) := 1
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200100endef
101
102#
103# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
104#
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200105$(info )
106$(info Auto-detecting system features:)
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200107
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200108#
109# Note that this is not a complete list of all feature tests, just
110# those that are typically built on a fully configured system.
111#
112# [ Feature tests not mentioned here have to be built explicitly in
113# the rule that uses them - an example for that is the 'bionic'
114# feature check. ]
115#
116CORE_FEATURE_TESTS = \
117 backtrace \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200118 dwarf \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200119 fortify-source \
120 glibc \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200121 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200122 gtk2-infobar \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200123 libaudit \
124 libbfd \
125 libelf \
126 libelf-getphdrnum \
127 libelf-mmap \
128 libnuma \
Ingo Molnar7181a672013-09-30 15:15:36 +0200129 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200130 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200131 libpython-version \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200132 libslang \
133 libunwind \
Ingo Molnar34ef2162013-09-30 16:46:49 +0200134 on-exit \
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200135 stackprotector \
136 stackprotector-all \
137 volatile-register-var
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200138
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200139#
140# Special fast-path for the 'all features are available' case:
141#
142$(call feature_check,all)
143
144ifeq ($(feature-all), 1)
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200145 #
146 # test-all.c passed - just set all the core feature flags to 1:
147 #
148 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200149else
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200150 $(shell $(MAKE) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
151 $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200152endif
153
154feature_print = $(eval $(feature_print_code))
155
156#
157# Print the result of the feature test:
158#
159define feature_print_code
160 ifeq ($(feature-$(1)), 1)
161 MSG := $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
162 else
163 MSG := $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
164 endif
165 $(info $(MSG))
166endef
167
Ingo Molnarf1138ec2013-10-02 09:54:43 +0200168$(foreach feat,$(CORE_FEATURE_TESTS) DUMMY,$(call feature_print,$(feat)))
Ingo Molnarbaa9c302013-10-01 14:14:31 +0200169
170# newline at the end of the feature printouts:
171$(info )
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200172
Ingo Molnar90ac5422013-09-30 13:48:44 +0200173ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200174 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100175endif
176
Ingo Molnar430be5a2013-10-07 09:47:00 +0200177ifeq ($(feature-stackprotector), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200178 CFLAGS += -Wstack-protector
Jiri Olsa362493f2013-03-25 00:40:48 +0100179endif
180
Ingo Molnarc2510442013-09-30 13:58:12 +0200181ifeq ($(feature-volatile-register-var), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200182 CFLAGS += -Wvolatile-register-var
Jiri Olsa362493f2013-03-25 00:40:48 +0100183endif
184
185ifndef PERF_DEBUG
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200186 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200187 CFLAGS += -D_FORTIFY_SOURCE=2
188 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100189endif
190
Jiri Olsa2fe73742013-04-15 04:32:28 +0200191CFLAGS += -I$(src-perf)/util/include
192CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
193CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
194CFLAGS += -I$(srctree)/arch/$(ARCH)/include
195CFLAGS += -I$(srctree)/include/uapi
196CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200197
198# $(obj-perf) for generated common-cmds.h
199# $(obj-perf)/util for generated bison/flex headers
200ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200201CFLAGS += -I$(obj-perf)/util
202CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200203endif
204
Jiri Olsa2fe73742013-04-15 04:32:28 +0200205CFLAGS += -I$(src-perf)/util
206CFLAGS += -I$(src-perf)
Robert Richter4e319022013-06-11 17:29:18 +0200207CFLAGS += -I$(LIB_INCLUDE)
Jiri Olsa7c537462013-05-24 14:35:23 +0200208
Jiri Olsa2fe73742013-04-15 04:32:28 +0200209CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100210
Jiri Olsa4e22db42013-05-24 14:35:24 +0200211ifndef NO_BIONIC
Ingo Molnar78e9d652013-09-30 14:11:46 +0200212 $(feature_check,bionic)
213 ifeq ($(feature-bionic), 1)
214 BIONIC := 1
215 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
216 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
217 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100218endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100219
220ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200221 NO_DWARF := 1
222 NO_DEMANGLE := 1
223 NO_LIBUNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100224else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200225 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200226 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200227 LIBC_SUPPORT := 1
228 endif
229 ifeq ($(BIONIC),1)
230 LIBC_SUPPORT := 1
231 endif
232 ifeq ($(LIBC_SUPPORT),1)
233 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100234
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200235 NO_LIBELF := 1
236 NO_DWARF := 1
237 NO_DEMANGLE := 1
238 else
239 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
240 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200241 else
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200242 # for linking with debug library, run like:
243 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
244 ifdef LIBDW_DIR
245 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
246 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
247 endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100248
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200249 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200250 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);
251 NO_DWARF := 1
252 endif # Dwarf support
253 endif # SOURCE_LIBELF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100254endif # NO_LIBELF
255
256ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200257 CFLAGS += -DHAVE_LIBELF_SUPPORT
258 FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
Jiri Olsa779724f2013-03-25 00:48:14 +0100259
Ingo Molnar8869b172013-09-30 15:02:28 +0200260 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200261 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
262 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100263
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200264 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200265 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
266 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100267
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200268 # include ARCH specific config
269 -include $(src-perf)/arch/$(ARCH)/Makefile
270
271 ifndef NO_DWARF
272 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
273 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
274 NO_DWARF := 1
275 else
276 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
277 LDFLAGS += $(LIBDW_LDFLAGS)
278 EXTLIBS += -lelf -ldw
279 endif # PERF_HAVE_DWARF_REGS
280 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100281endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100282
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100283ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200284 CFLAGS += -DHAVE_LIBELF_SUPPORT
Ingo Molnar8869b172013-09-30 15:02:28 +0200285 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200286 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200287 endif
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100288endif # NO_LIBELF
289
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100290# There's only x86 (both 32 and 64) support for CFI unwind so far
291ifneq ($(ARCH),x86)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200292 NO_LIBUNWIND := 1
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100293endif
294
295ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200296 #
297 # For linking with debug library, run like:
298 #
299 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
300 #
Ingo Molnar308e1e72013-10-07 10:30:47 +0200301 ifdef LIBUNWIND_DIR
302 LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
303 LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
304 endif
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100305
Ingo Molnar058f9522013-09-30 14:45:44 +0200306 ifneq ($(feature-libunwind), 1)
Ingo Molnar308e1e72013-10-07 10:30:47 +0200307 msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99);
308 NO_LIBUNWIND := 1
309 endif
310endif
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100311
312ifndef NO_LIBUNWIND
Ingo Molnar89fe8082013-09-30 12:07:11 +0200313 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200314 EXTLIBS += $(LIBUNWIND_LIBS)
315 CFLAGS += $(LIBUNWIND_CFLAGS)
316 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200317endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100318
319ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200320 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200321 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
322 NO_LIBAUDIT := 1
323 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200324 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200325 EXTLIBS += -laudit
326 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100327endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100328
329ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200330 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100331endif
332
333ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200334 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200335 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
336 NO_SLANG := 1
337 else
338 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
339 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200340 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200341 EXTLIBS += -lslang
342 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100343endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100344
345ifndef NO_GTK2
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200346 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200347 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200348 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
349 NO_GTK2 := 1
350 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200351 ifeq ($(feature-gtk2-infobar), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200352 CFLAGS += -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200353 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200354 CFLAGS += -DHAVE_GTK2_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200355 CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
356 EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
357 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100358endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100359
360grep-libs = $(filter -l%,$(1))
361strip-libs = $(filter-out -l%,$(1))
362
363ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200364 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100365else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200366 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
367 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
368 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
369 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
370 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100371
Ingo Molnar7181a672013-09-30 15:15:36 +0200372 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200373 CFLAGS += -DNO_LIBPERL
374 NO_LIBPERL := 1
375 else
376 LDFLAGS += $(PERL_EMBED_LDFLAGS)
377 EXTLIBS += $(PERL_EMBED_LIBADD)
378 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100379endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100380
381disable-python = $(eval $(disable-python_code))
382define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100383 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100384 $(if $(1),$(warning No $(1) was found))
385 $(warning Python support will not be built)
386 NO_LIBPYTHON := 1
387endef
388
389override PYTHON := \
390 $(call get-executable-or-default,PYTHON,python)
391
392ifndef PYTHON
393 $(call disable-python,python interpreter)
394else
395
396 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
397
398 ifdef NO_LIBPYTHON
399 $(call disable-python)
400 else
401
402 override PYTHON_CONFIG := \
403 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
404
405 ifndef PYTHON_CONFIG
406 $(call disable-python,python-config tool)
407 else
408
409 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
410
411 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
412 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
413 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
414 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
415 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
416
Ingo Molnar97341632013-09-30 15:18:37 +0200417 ifneq ($(feature-libpython), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100418 $(call disable-python,Python.h (for Python 2.x))
419 else
420
Ingo Molnar95d061c2013-09-30 15:40:04 +0200421 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100422 $(warning Python 3 is not yet supported; please set)
423 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
424 $(warning If you also have Python 2 installed, then)
425 $(warning try something like:)
426 $(warning $(and ,))
427 $(warning $(and ,) make PYTHON=python2)
428 $(warning $(and ,))
429 $(warning Otherwise, disable Python support entirely:)
430 $(warning $(and ,))
431 $(warning $(and ,) make NO_LIBPYTHON=1)
432 $(warning $(and ,))
433 $(error $(and ,))
434 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100435 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100436 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200437 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100438 endif
439 endif
440 endif
441 endif
442endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100443
444ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200445 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100446else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200447 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200448 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200449 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200450 else
451 FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
Ingo Molnar3b7646e2013-09-30 15:53:31 +0200452 ifeq ($(feature-libbfd), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200453 EXTLIBS += -lbfd
454 else
455 FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
456 has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty)
457 ifeq ($(has_bfd_iberty),y)
458 EXTLIBS += -lbfd -liberty
459 else
460 FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
461 has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz)
462 ifeq ($(has_bfd_iberty_z),y)
463 EXTLIBS += -lbfd -liberty -lz
464 else
465 FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -liberty
466 has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle)
467 ifeq ($(has_cplus_demangle),y)
468 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200469 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200470 else
471 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
472 CFLAGS += -DNO_DEMANGLE
473 endif
474 endif
475 endif
476 endif
477 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100478endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100479
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100480ifndef NO_ON_EXIT
Ingo Molnar34ef2162013-09-30 16:46:49 +0200481 ifeq ($(feature-on-exit), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200482 CFLAGS += -DHAVE_ON_EXIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200483 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100484endif
485
486ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200487 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200488 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200489 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100490endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100491
492ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200493 ifeq ($(feature-libnuma), 0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200494 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
495 NO_LIBNUMA := 1
496 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200497 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200498 EXTLIBS += -lnuma
499 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100500endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100501
502# Among the variables below, these:
503# perfexecdir
504# template_dir
505# mandir
506# infodir
507# htmldir
508# ETC_PERFCONFIG (but not sysconfdir)
509# can be specified as a relative path some/where/else;
510# this is interpreted as relative to $(prefix) and "perf" at
511# runtime figures out where they are based on the path to the executable.
512# This can help installing the suite in a relocatable way.
513
514# Make the path relative to DESTDIR, not to prefix
515ifndef DESTDIR
516prefix = $(HOME)
517endif
518bindir_relative = bin
519bindir = $(prefix)/$(bindir_relative)
520mandir = share/man
521infodir = share/info
522perfexecdir = libexec/perf-core
523sharedir = $(prefix)/share
524template_dir = share/perf-core/templates
525htmldir = share/doc/perf-doc
526ifeq ($(prefix),/usr)
527sysconfdir = /etc
528ETC_PERFCONFIG = $(sysconfdir)/perfconfig
529else
530sysconfdir = $(prefix)/etc
531ETC_PERFCONFIG = etc/perfconfig
532endif
533lib = lib
534
535# Shell quote (do not use $(call) to accommodate ancient setups);
536ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
537DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
538bindir_SQ = $(subst ','\'',$(bindir))
539mandir_SQ = $(subst ','\'',$(mandir))
540infodir_SQ = $(subst ','\'',$(infodir))
541perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
542template_dir_SQ = $(subst ','\'',$(template_dir))
543htmldir_SQ = $(subst ','\'',$(htmldir))
544prefix_SQ = $(subst ','\'',$(prefix))
545sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
546
547ifneq ($(filter /%,$(firstword $(perfexecdir))),)
548perfexec_instdir = $(perfexecdir)
549else
550perfexec_instdir = $(prefix)/$(perfexecdir)
551endif
552perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))