blob: c0c83440de9794b0bb68d98d807ece895f8e362a [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 Molnarb6aa9972013-09-30 10:08:24 +020092feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1))
93define feature_check_code
94 feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
95endef
96
97#
98# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
99#
100$(info Testing features:)
101$(shell make -i -j -C config/feature-checks >/dev/null 2>&1)
102$(info done)
103
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200104FEATURE_TESTS = \
105 hello \
Ingo Molnar90ac5422013-09-30 13:48:44 +0200106 stackprotector-all \
Ingo Molnar430be5a2013-10-07 09:47:00 +0200107 stackprotector \
Ingo Molnarc2510442013-09-30 13:58:12 +0200108 volatile-register-var \
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200109 fortify-source \
Ingo Molnar78e9d652013-09-30 14:11:46 +0200110 bionic \
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200111 libelf \
Ingo Molnare12762c2013-10-07 10:34:20 +0200112 glibc \
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200113 dwarf \
Ingo Molnar8869b172013-09-30 15:02:28 +0200114 libelf-mmap \
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200115 libelf-getphdrnum \
Ingo Molnar058f9522013-09-30 14:45:44 +0200116 libunwind \
Ingo Molnard795a652013-09-30 14:55:31 +0200117 libaudit \
Ingo Molnarb9498b52013-09-30 14:57:54 +0200118 libslang \
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200119 gtk2 \
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200120 gtk2-infobar \
Ingo Molnar7181a672013-09-30 15:15:36 +0200121 libperl \
Ingo Molnar97341632013-09-30 15:18:37 +0200122 libpython \
Ingo Molnar95d061c2013-09-30 15:40:04 +0200123 libpython-version \
Ingo Molnard0707c92013-10-08 10:10:45 +0200124 strlcpy \
Ingo Molnar3b7646e2013-09-30 15:53:31 +0200125 libbfd \
Ingo Molnar34ef2162013-09-30 16:46:49 +0200126 on-exit \
Ingo Molnar4cc91172013-09-30 16:49:38 +0200127 backtrace \
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200128 libnuma
Ingo Molnarb6aa9972013-09-30 10:08:24 +0200129
130$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
131
Ingo Molnar90ac5422013-09-30 13:48:44 +0200132ifeq ($(feature-stackprotector-all), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200133 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +0100134endif
135
Ingo Molnar430be5a2013-10-07 09:47:00 +0200136ifeq ($(feature-stackprotector), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200137 CFLAGS += -Wstack-protector
Jiri Olsa362493f2013-03-25 00:40:48 +0100138endif
139
Ingo Molnarc2510442013-09-30 13:58:12 +0200140ifeq ($(feature-volatile-register-var), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200141 CFLAGS += -Wvolatile-register-var
Jiri Olsa362493f2013-03-25 00:40:48 +0100142endif
143
144ifndef PERF_DEBUG
Ingo Molnar1ea6f992013-10-07 09:38:28 +0200145 ifeq ($(feature-fortify-source), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200146 CFLAGS += -D_FORTIFY_SOURCE=2
147 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100148endif
149
Jiri Olsa2fe73742013-04-15 04:32:28 +0200150CFLAGS += -I$(src-perf)/util/include
151CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
152CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi
153CFLAGS += -I$(srctree)/arch/$(ARCH)/include
154CFLAGS += -I$(srctree)/include/uapi
155CFLAGS += -I$(srctree)/include
Jiri Olsa7c537462013-05-24 14:35:23 +0200156
157# $(obj-perf) for generated common-cmds.h
158# $(obj-perf)/util for generated bison/flex headers
159ifneq ($(OUTPUT),)
Jiri Olsa2fe73742013-04-15 04:32:28 +0200160CFLAGS += -I$(obj-perf)/util
161CFLAGS += -I$(obj-perf)
Jiri Olsa7c537462013-05-24 14:35:23 +0200162endif
163
Jiri Olsa2fe73742013-04-15 04:32:28 +0200164CFLAGS += -I$(src-perf)/util
165CFLAGS += -I$(src-perf)
Robert Richter4e319022013-06-11 17:29:18 +0200166CFLAGS += -I$(LIB_INCLUDE)
Jiri Olsa7c537462013-05-24 14:35:23 +0200167
Jiri Olsa2fe73742013-04-15 04:32:28 +0200168CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Jiri Olsa362493f2013-03-25 00:40:48 +0100169
Jiri Olsa4e22db42013-05-24 14:35:24 +0200170ifndef NO_BIONIC
Ingo Molnar78e9d652013-09-30 14:11:46 +0200171 $(feature_check,bionic)
172 ifeq ($(feature-bionic), 1)
173 BIONIC := 1
174 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
175 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
176 endif
Jiri Olsa362493f2013-03-25 00:40:48 +0100177endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100178
179ifdef NO_LIBELF
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200180 NO_DWARF := 1
181 NO_DEMANGLE := 1
182 NO_LIBUNWIND := 1
Jiri Olsacf4cca12013-03-25 00:45:08 +0100183else
Ingo Molnar8f7f8002013-09-30 14:20:25 +0200184 ifeq ($(feature-libelf), 0)
Ingo Molnare12762c2013-10-07 10:34:20 +0200185 ifeq ($(feature-glibc), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200186 LIBC_SUPPORT := 1
187 endif
188 ifeq ($(BIONIC),1)
189 LIBC_SUPPORT := 1
190 endif
191 ifeq ($(LIBC_SUPPORT),1)
192 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
Jiri Olsacf4cca12013-03-25 00:45:08 +0100193
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200194 NO_LIBELF := 1
195 NO_DWARF := 1
196 NO_DEMANGLE := 1
197 else
198 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
199 endif
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200200 else
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200201 # for linking with debug library, run like:
202 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
203 ifdef LIBDW_DIR
204 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
205 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
206 endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100207
Ingo Molnar8295d4e2013-10-07 10:35:39 +0200208 ifneq ($(feature-dwarf), 1)
Ingo Molnar50eed7a2013-09-30 14:11:16 +0200209 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);
210 NO_DWARF := 1
211 endif # Dwarf support
212 endif # SOURCE_LIBELF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100213endif # NO_LIBELF
214
215ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200216 CFLAGS += -DHAVE_LIBELF_SUPPORT
217 FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
Jiri Olsa779724f2013-03-25 00:48:14 +0100218
Ingo Molnar8869b172013-09-30 15:02:28 +0200219 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200220 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
221 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100222
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200223 ifeq ($(feature-libelf-getphdrnum), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200224 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
225 endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100226
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200227 # include ARCH specific config
228 -include $(src-perf)/arch/$(ARCH)/Makefile
229
230 ifndef NO_DWARF
231 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
232 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
233 NO_DWARF := 1
234 else
235 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
236 LDFLAGS += $(LIBDW_LDFLAGS)
237 EXTLIBS += -lelf -ldw
238 endif # PERF_HAVE_DWARF_REGS
239 endif # NO_DWARF
Jiri Olsacf4cca12013-03-25 00:45:08 +0100240endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100241
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100242ifndef NO_LIBELF
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200243 CFLAGS += -DHAVE_LIBELF_SUPPORT
Ingo Molnar8869b172013-09-30 15:02:28 +0200244 ifeq ($(feature-libelf-mmap), 1)
Ingo Molnarfb3d3332013-10-07 10:05:51 +0200245 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
Ingo Molnarb7bcef62013-09-30 14:35:27 +0200246 endif
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100247endif # NO_LIBELF
248
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100249# There's only x86 (both 32 and 64) support for CFI unwind so far
250ifneq ($(ARCH),x86)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200251 NO_LIBUNWIND := 1
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100252endif
253
254ifndef NO_LIBUNWIND
Ingo Molnar058f9522013-09-30 14:45:44 +0200255 #
256 # For linking with debug library, run like:
257 #
258 # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
259 #
Ingo Molnar308e1e72013-10-07 10:30:47 +0200260 ifdef LIBUNWIND_DIR
261 LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
262 LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
263 endif
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100264
Ingo Molnar058f9522013-09-30 14:45:44 +0200265 ifneq ($(feature-libunwind), 1)
Ingo Molnar308e1e72013-10-07 10:30:47 +0200266 msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99);
267 NO_LIBUNWIND := 1
268 endif
269endif
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100270
271ifndef NO_LIBUNWIND
Ingo Molnar89fe8082013-09-30 12:07:11 +0200272 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200273 EXTLIBS += $(LIBUNWIND_LIBS)
274 CFLAGS += $(LIBUNWIND_CFLAGS)
275 LDFLAGS += $(LIBUNWIND_LDFLAGS)
Ingo Molnar058f9522013-09-30 14:45:44 +0200276endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100277
278ifndef NO_LIBAUDIT
Ingo Molnard795a652013-09-30 14:55:31 +0200279 ifneq ($(feature-libaudit), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200280 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
281 NO_LIBAUDIT := 1
282 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200283 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200284 EXTLIBS += -laudit
285 endif
Jiri Olsaa8279522013-03-25 00:54:36 +0100286endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100287
288ifdef NO_NEWT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200289 NO_SLANG=1
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100290endif
291
292ifndef NO_SLANG
Ingo Molnarb9498b52013-09-30 14:57:54 +0200293 ifneq ($(feature-libslang), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200294 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
295 NO_SLANG := 1
296 else
297 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
298 CFLAGS += -I/usr/include/slang
Ingo Molnar89fe8082013-09-30 12:07:11 +0200299 CFLAGS += -DHAVE_SLANG_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200300 EXTLIBS += -lslang
301 endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100302endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100303
304ifndef NO_GTK2
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200305 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
Ingo Molnar7ef9e052013-09-30 15:01:56 +0200306 ifneq ($(feature-gtk2), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200307 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
308 NO_GTK2 := 1
309 else
Ingo Molnarc7a79e92013-09-30 15:08:30 +0200310 ifeq ($(feature-gtk2-infobar), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200311 CFLAGS += -DHAVE_GTK_INFO_BAR_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200312 endif
Ingo Molnar89fe8082013-09-30 12:07:11 +0200313 CFLAGS += -DHAVE_GTK2_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200314 CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
315 EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
316 endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100317endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100318
319grep-libs = $(filter -l%,$(1))
320strip-libs = $(filter-out -l%,$(1))
321
322ifdef NO_LIBPERL
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200323 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100324else
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200325 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
326 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
327 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
328 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
329 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Jiri Olsa3082cb32013-03-18 00:19:44 +0100330
Ingo Molnar7181a672013-09-30 15:15:36 +0200331 ifneq ($(feature-libperl), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200332 CFLAGS += -DNO_LIBPERL
333 NO_LIBPERL := 1
334 else
335 LDFLAGS += $(PERL_EMBED_LDFLAGS)
336 EXTLIBS += $(PERL_EMBED_LIBADD)
337 endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100338endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100339
340disable-python = $(eval $(disable-python_code))
341define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100342 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100343 $(if $(1),$(warning No $(1) was found))
344 $(warning Python support will not be built)
345 NO_LIBPYTHON := 1
346endef
347
348override PYTHON := \
349 $(call get-executable-or-default,PYTHON,python)
350
351ifndef PYTHON
352 $(call disable-python,python interpreter)
353else
354
355 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
356
357 ifdef NO_LIBPYTHON
358 $(call disable-python)
359 else
360
361 override PYTHON_CONFIG := \
362 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
363
364 ifndef PYTHON_CONFIG
365 $(call disable-python,python-config tool)
366 else
367
368 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
369
370 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
371 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
372 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
373 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
374 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
375
Ingo Molnar97341632013-09-30 15:18:37 +0200376 ifneq ($(feature-libpython), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100377 $(call disable-python,Python.h (for Python 2.x))
378 else
379
Ingo Molnar95d061c2013-09-30 15:40:04 +0200380 ifneq ($(feature-libpython-version), 1)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100381 $(warning Python 3 is not yet supported; please set)
382 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
383 $(warning If you also have Python 2 installed, then)
384 $(warning try something like:)
385 $(warning $(and ,))
386 $(warning $(and ,) make PYTHON=python2)
387 $(warning $(and ,))
388 $(warning Otherwise, disable Python support entirely:)
389 $(warning $(and ,))
390 $(warning $(and ,) make NO_LIBPYTHON=1)
391 $(warning $(and ,))
392 $(error $(and ,))
393 else
Jiri Olsa1e9f7aa2013-03-21 11:41:05 +0100394 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100395 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Jiri Olsa7c537462013-05-24 14:35:23 +0200396 LANG_BINDINGS += $(obj-perf)python/perf.so
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100397 endif
398 endif
399 endif
400 endif
401endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100402
403ifdef NO_DEMANGLE
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200404 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100405else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200406 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200407 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200408 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200409 else
410 FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
Ingo Molnar3b7646e2013-09-30 15:53:31 +0200411 ifeq ($(feature-libbfd), 1)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200412 EXTLIBS += -lbfd
413 else
414 FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
415 has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty)
416 ifeq ($(has_bfd_iberty),y)
417 EXTLIBS += -lbfd -liberty
418 else
419 FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
420 has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz)
421 ifeq ($(has_bfd_iberty_z),y)
422 EXTLIBS += -lbfd -liberty -lz
423 else
424 FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -liberty
425 has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle)
426 ifeq ($(has_cplus_demangle),y)
427 EXTLIBS += -liberty
Ingo Molnar89fe8082013-09-30 12:07:11 +0200428 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200429 else
430 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
431 CFLAGS += -DNO_DEMANGLE
432 endif
433 endif
434 endif
435 endif
436 endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100437endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100438
439ifndef NO_STRLCPY
Ingo Molnard0707c92013-10-08 10:10:45 +0200440 ifeq ($(feature-strlcpy), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200441 CFLAGS += -DHAVE_STRLCPY_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200442 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100443endif
444
445ifndef NO_ON_EXIT
Ingo Molnar34ef2162013-09-30 16:46:49 +0200446 ifeq ($(feature-on-exit), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200447 CFLAGS += -DHAVE_ON_EXIT_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200448 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100449endif
450
451ifndef NO_BACKTRACE
Ingo Molnar4cc91172013-09-30 16:49:38 +0200452 ifeq ($(feature-backtrace), 1)
Ingo Molnar89fe8082013-09-30 12:07:11 +0200453 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200454 endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100455endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100456
457ifndef NO_LIBNUMA
Ingo Molnar3ae069c2013-09-30 13:37:10 +0200458 ifeq ($(feature-libnuma), 0)
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200459 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
460 NO_LIBNUMA := 1
461 else
Ingo Molnar89fe8082013-09-30 12:07:11 +0200462 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
Jiri Olsa8e1b3f62013-04-15 04:06:58 +0200463 EXTLIBS += -lnuma
464 endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100465endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100466
467# Among the variables below, these:
468# perfexecdir
469# template_dir
470# mandir
471# infodir
472# htmldir
473# ETC_PERFCONFIG (but not sysconfdir)
474# can be specified as a relative path some/where/else;
475# this is interpreted as relative to $(prefix) and "perf" at
476# runtime figures out where they are based on the path to the executable.
477# This can help installing the suite in a relocatable way.
478
479# Make the path relative to DESTDIR, not to prefix
480ifndef DESTDIR
481prefix = $(HOME)
482endif
483bindir_relative = bin
484bindir = $(prefix)/$(bindir_relative)
485mandir = share/man
486infodir = share/info
487perfexecdir = libexec/perf-core
488sharedir = $(prefix)/share
489template_dir = share/perf-core/templates
490htmldir = share/doc/perf-doc
491ifeq ($(prefix),/usr)
492sysconfdir = /etc
493ETC_PERFCONFIG = $(sysconfdir)/perfconfig
494else
495sysconfdir = $(prefix)/etc
496ETC_PERFCONFIG = etc/perfconfig
497endif
498lib = lib
499
500# Shell quote (do not use $(call) to accommodate ancient setups);
501ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
502DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
503bindir_SQ = $(subst ','\'',$(bindir))
504mandir_SQ = $(subst ','\'',$(mandir))
505infodir_SQ = $(subst ','\'',$(infodir))
506perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
507template_dir_SQ = $(subst ','\'',$(template_dir))
508htmldir_SQ = $(subst ','\'',$(htmldir))
509prefix_SQ = $(subst ','\'',$(prefix))
510sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
511
512ifneq ($(filter /%,$(firstword $(perfexecdir))),)
513perfexec_instdir = $(perfexecdir)
514else
515perfexec_instdir = $(prefix)/$(perfexecdir)
516endif
517perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))