blob: a53d2b37831a619f4178ba396871b5d0c59cdada [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/ \
4 -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/ )
8NO_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)
13 override ARCH := x86
14 NO_PERF_REGS := 0
15 LIBUNWIND_LIBS = -lunwind -lunwind-x86
16endif
17
18ifeq ($(ARCH),x86_64)
19 override ARCH := x86
20 IS_X86_64 := 0
Jiri Olsa9c12cf92013-03-21 11:30:54 +010021 ifeq (, $(findstring m32,$(CFLAGS)))
Jiri Olsa8bd407b2013-03-15 16:28:49 +010022 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
Jiri Olsa9c12cf92013-03-21 11:30:54 +010026 CFLAGS += -DARCH_X86_64
Jiri Olsa8bd407b2013-03-15 16:28:49 +010027 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
31endif
32
33ifeq ($(NO_PERF_REGS),0)
Jiri Olsa9c12cf92013-03-21 11:30:54 +010034 CFLAGS += -DHAVE_PERF_REGS
Jiri Olsa8bd407b2013-03-15 16:28:49 +010035endif
Jiri Olsaa32f4932013-03-25 00:32:01 +010036
37-include config/feature-tests.mak
38
39ifeq ($(call get-executable,$(FLEX)),)
40 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
41endif
42
43ifeq ($(call get-executable,$(BISON)),)
44 dummy := $(error Error: $(BISON) is missing on this system, please install it)
45endif
Jiri Olsa362493f2013-03-25 00:40:48 +010046
47# Treat warnings as errors unless directed not to
48ifneq ($(WERROR),0)
Jiri Olsa9c12cf92013-03-21 11:30:54 +010049 CFLAGS += -Werror
Jiri Olsa362493f2013-03-25 00:40:48 +010050endif
51
52ifeq ("$(origin DEBUG)", "command line")
53 PERF_DEBUG = $(DEBUG)
54endif
55ifndef PERF_DEBUG
Jiri Olsa9c12cf92013-03-21 11:30:54 +010056 CFLAGS += -O6
Jiri Olsa362493f2013-03-25 00:40:48 +010057endif
58
59ifdef PARSER_DEBUG
Jiri Olsa9c12cf92013-03-21 11:30:54 +010060 PARSER_DEBUG_BISON := -t
61 PARSER_DEBUG_FLEX := -d
62 CFLAGS += -DPARSER_DEBUG
Jiri Olsa362493f2013-03-25 00:40:48 +010063endif
64
Jiri Olsa9c12cf92013-03-21 11:30:54 +010065CFLAGS += \
66 -fno-omit-frame-pointer \
67 -ggdb3 \
68 -funwind-tables \
69 -Wall \
70 -Wextra \
71 -std=gnu99
72
Jiri Olsa362493f2013-03-25 00:40:48 +010073EXTLIBS = -lpthread -lrt -lelf -lm
Jiri Olsa362493f2013-03-25 00:40:48 +010074ALL_LDFLAGS = $(LDFLAGS)
75
76ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +010077 CFLAGS += -fstack-protector-all
Jiri Olsa362493f2013-03-25 00:40:48 +010078endif
79
80ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +010081 CFLAGS += -Wstack-protector
Jiri Olsa362493f2013-03-25 00:40:48 +010082endif
83
84ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +010085 CFLAGS += -Wvolatile-register-var
Jiri Olsa362493f2013-03-25 00:40:48 +010086endif
87
88ifndef PERF_DEBUG
89 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +010090 CFLAGS += -D_FORTIFY_SOURCE=2
Jiri Olsa362493f2013-03-25 00:40:48 +010091 endif
92endif
93
Jiri Olsa9c12cf92013-03-21 11:30:54 +010094CFLAGS += \
Jiri Olsa362493f2013-03-25 00:40:48 +010095 -Iutil/include \
96 -Iarch/$(ARCH)/include \
97 $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \
98 -I$(srctree)/arch/$(ARCH)/include/uapi \
99 -I$(srctree)/arch/$(ARCH)/include \
100 $(if $(objtree),-I$(objtree)/include/generated/uapi) \
101 -I$(srctree)/include/uapi \
102 -I$(srctree)/include \
103 -I$(OUTPUT)util \
104 -Iutil \
105 -I. \
106 -I$(TRACE_EVENT_DIR) \
107 -I../lib/ \
108 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
109
110BASIC_LDFLAGS =
111
112ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y)
113 BIONIC := 1
114 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
115 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
Jiri Olsa362493f2013-03-25 00:40:48 +0100116endif
Jiri Olsacf4cca12013-03-25 00:45:08 +0100117
118ifdef NO_LIBELF
119 NO_DWARF := 1
120 NO_DEMANGLE := 1
121 NO_LIBUNWIND := 1
122else
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100123FLAGS_LIBELF=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
Jiri Olsacf4cca12013-03-25 00:45:08 +0100124ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100125 FLAGS_GLIBC=$(CFLAGS) $(ALL_LDFLAGS)
Jiri Olsacf4cca12013-03-25 00:45:08 +0100126 ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y)
127 LIBC_SUPPORT := 1
128 endif
129 ifeq ($(BIONIC),1)
130 LIBC_SUPPORT := 1
131 endif
132 ifeq ($(LIBC_SUPPORT),1)
133 msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
134
135 NO_LIBELF := 1
136 NO_DWARF := 1
137 NO_DEMANGLE := 1
138 else
139 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
140 endif
141else
142 # for linking with debug library, run like:
143 # make DEBUG=1 LIBDW_DIR=/opt/libdw/
144 ifdef LIBDW_DIR
145 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
146 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
147 endif
148
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100149 FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
Jiri Olsacf4cca12013-03-25 00:45:08 +0100150 ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y)
151 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);
152 NO_DWARF := 1
153 endif # Dwarf support
154endif # SOURCE_LIBELF
155endif # NO_LIBELF
156
157ifndef NO_LIBELF
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100158CFLAGS += -DLIBELF_SUPPORT
159FLAGS_LIBELF=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
Jiri Olsacf4cca12013-03-25 00:45:08 +0100160ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100161 CFLAGS += -DLIBELF_MMAP
Jiri Olsacf4cca12013-03-25 00:45:08 +0100162endif
Jiri Olsa779724f2013-03-25 00:48:14 +0100163
164# include ARCH specific config
165-include arch/$(ARCH)/Makefile
166
167ifndef NO_DWARF
168ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
169 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
170 NO_DWARF := 1
171else
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100172 CFLAGS += -DDWARF_SUPPORT $(LIBDW_CFLAGS)
Jiri Olsa779724f2013-03-25 00:48:14 +0100173 BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS)
174 EXTLIBS += -lelf -ldw
175endif # PERF_HAVE_DWARF_REGS
176endif # NO_DWARF
177
Jiri Olsacf4cca12013-03-25 00:45:08 +0100178endif # NO_LIBELF
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100179
180# There's only x86 (both 32 and 64) support for CFI unwind so far
181ifneq ($(ARCH),x86)
182 NO_LIBUNWIND := 1
183endif
184
185ifndef NO_LIBUNWIND
186# for linking with debug library, run like:
187# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
188ifdef LIBUNWIND_DIR
189 LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
190 LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
191endif
192
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100193FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS)
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100194ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y)
195 msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99);
196 NO_LIBUNWIND := 1
197endif # Libunwind support
198endif # NO_LIBUNWIND
199
200ifndef NO_LIBUNWIND
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100201 CFLAGS += -DLIBUNWIND_SUPPORT
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100202 EXTLIBS += $(LIBUNWIND_LIBS)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100203 CFLAGS += $(LIBUNWIND_CFLAGS)
Jiri Olsa0e433fe2013-03-25 00:53:03 +0100204 BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS)
205endif # NO_LIBUNWIND
Jiri Olsaa8279522013-03-25 00:54:36 +0100206
207ifndef NO_LIBAUDIT
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100208 FLAGS_LIBAUDIT = $(CFLAGS) $(ALL_LDFLAGS) -laudit
Jiri Olsaa8279522013-03-25 00:54:36 +0100209 ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y)
210 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
211 NO_LIBAUDIT := 1
212 else
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100213 CFLAGS += -DLIBAUDIT_SUPPORT
Jiri Olsaa8279522013-03-25 00:54:36 +0100214 EXTLIBS += -laudit
215 endif
216endif
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100217
218ifdef NO_NEWT
219 NO_SLANG=1
220endif
221
222ifndef NO_SLANG
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100223 FLAGS_SLANG=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100224 ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y)
225 msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
226 NO_SLANG := 1
227 else
228 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100229 CFLAGS += -I/usr/include/slang
230 CFLAGS += -DSLANG_SUPPORT
Jiri Olsa4a8f8882013-03-25 00:56:08 +0100231 EXTLIBS += -lslang
232 endif
233endif
Jiri Olsa58cabf62013-03-18 00:09:24 +0100234
235ifndef NO_GTK2
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100236 FLAGS_GTK2=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
Jiri Olsa58cabf62013-03-18 00:09:24 +0100237 ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y)
238 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
239 NO_GTK2 := 1
240 else
241 ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100242 CFLAGS += -DHAVE_GTK_INFO_BAR
Jiri Olsa58cabf62013-03-18 00:09:24 +0100243 endif
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100244 CFLAGS += -DGTK2_SUPPORT
245 CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
Jiri Olsa58cabf62013-03-18 00:09:24 +0100246 EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
247 endif
248endif
Jiri Olsa3082cb32013-03-18 00:19:44 +0100249
250grep-libs = $(filter -l%,$(1))
251strip-libs = $(filter-out -l%,$(1))
252
253ifdef NO_LIBPERL
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100254 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100255else
256 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
257 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
258 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
259 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
260 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
261
262 ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100263 CFLAGS += -DNO_LIBPERL
Jiri Olsa3082cb32013-03-18 00:19:44 +0100264 NO_LIBPERL := 1
265 else
266 ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS)
267 EXTLIBS += $(PERL_EMBED_LIBADD)
268 endif
269endif
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100270
271disable-python = $(eval $(disable-python_code))
272define disable-python_code
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100273 CFLAGS += -DNO_LIBPYTHON
Jiri Olsa6e533cf2013-03-18 00:35:32 +0100274 $(if $(1),$(warning No $(1) was found))
275 $(warning Python support will not be built)
276 NO_LIBPYTHON := 1
277endef
278
279override PYTHON := \
280 $(call get-executable-or-default,PYTHON,python)
281
282ifndef PYTHON
283 $(call disable-python,python interpreter)
284else
285
286 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
287
288 ifdef NO_LIBPYTHON
289 $(call disable-python)
290 else
291
292 override PYTHON_CONFIG := \
293 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
294
295 ifndef PYTHON_CONFIG
296 $(call disable-python,python-config tool)
297 else
298
299 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
300
301 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
302 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
303 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
304 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
305 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
306
307 ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y)
308 $(call disable-python,Python.h (for Python 2.x))
309 else
310
311 ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y)
312 $(warning Python 3 is not yet supported; please set)
313 $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
314 $(warning If you also have Python 2 installed, then)
315 $(warning try something like:)
316 $(warning $(and ,))
317 $(warning $(and ,) make PYTHON=python2)
318 $(warning $(and ,))
319 $(warning Otherwise, disable Python support entirely:)
320 $(warning $(and ,))
321 $(warning $(and ,) make NO_LIBPYTHON=1)
322 $(warning $(and ,))
323 $(error $(and ,))
324 else
325 ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
326 EXTLIBS += $(PYTHON_EMBED_LIBADD)
327 LANG_BINDINGS += $(OUTPUT)python/perf.so
328 endif
329 endif
330 endif
331 endif
332endif
Jiri Olsac3cf8362013-03-18 00:38:16 +0100333
334ifdef NO_DEMANGLE
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100335 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100336else
337 ifdef HAVE_CPLUS_DEMANGLE
338 EXTLIBS += -liberty
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100339 CFLAGS += -DHAVE_CPLUS_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100340 else
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100341 FLAGS_BFD=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
Jiri Olsac3cf8362013-03-18 00:38:16 +0100342 has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd)
343 ifeq ($(has_bfd),y)
344 EXTLIBS += -lbfd
345 else
346 FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
347 has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty)
348 ifeq ($(has_bfd_iberty),y)
349 EXTLIBS += -lbfd -liberty
350 else
351 FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
352 has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz)
353 ifeq ($(has_bfd_iberty_z),y)
354 EXTLIBS += -lbfd -liberty -lz
355 else
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100356 FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty
Jiri Olsac3cf8362013-03-18 00:38:16 +0100357 has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle)
358 ifeq ($(has_cplus_demangle),y)
359 EXTLIBS += -liberty
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100360 CFLAGS += -DHAVE_CPLUS_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100361 else
362 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100363 CFLAGS += -DNO_DEMANGLE
Jiri Olsac3cf8362013-03-18 00:38:16 +0100364 endif
365 endif
366 endif
367 endif
368 endif
369endif
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100370
371ifndef NO_STRLCPY
372 ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100373 CFLAGS += -DHAVE_STRLCPY
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100374 endif
375endif
376
377ifndef NO_ON_EXIT
378 ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100379 CFLAGS += -DHAVE_ON_EXIT
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100380 endif
381endif
382
383ifndef NO_BACKTRACE
384 ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y)
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100385 CFLAGS += -DBACKTRACE_SUPPORT
Jiri Olsaa1c7c9e2013-03-18 00:41:04 +0100386 endif
387endif
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100388
389ifndef NO_LIBNUMA
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100390 FLAGS_LIBNUMA = $(CFLAGS) $(ALL_LDFLAGS) -lnuma
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100391 ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y)
392 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
393 NO_LIBNUMA := 1
394 else
Jiri Olsa9c12cf92013-03-21 11:30:54 +0100395 CFLAGS += -DLIBNUMA_SUPPORT
Jiri Olsa58a0abd2013-03-18 00:45:27 +0100396 EXTLIBS += -lnuma
397 endif
398endif
Jiri Olsacd1c39f2013-03-18 00:56:01 +0100399
400# Among the variables below, these:
401# perfexecdir
402# template_dir
403# mandir
404# infodir
405# htmldir
406# ETC_PERFCONFIG (but not sysconfdir)
407# can be specified as a relative path some/where/else;
408# this is interpreted as relative to $(prefix) and "perf" at
409# runtime figures out where they are based on the path to the executable.
410# This can help installing the suite in a relocatable way.
411
412# Make the path relative to DESTDIR, not to prefix
413ifndef DESTDIR
414prefix = $(HOME)
415endif
416bindir_relative = bin
417bindir = $(prefix)/$(bindir_relative)
418mandir = share/man
419infodir = share/info
420perfexecdir = libexec/perf-core
421sharedir = $(prefix)/share
422template_dir = share/perf-core/templates
423htmldir = share/doc/perf-doc
424ifeq ($(prefix),/usr)
425sysconfdir = /etc
426ETC_PERFCONFIG = $(sysconfdir)/perfconfig
427else
428sysconfdir = $(prefix)/etc
429ETC_PERFCONFIG = etc/perfconfig
430endif
431lib = lib
432
433# Shell quote (do not use $(call) to accommodate ancient setups);
434ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
435DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
436bindir_SQ = $(subst ','\'',$(bindir))
437mandir_SQ = $(subst ','\'',$(mandir))
438infodir_SQ = $(subst ','\'',$(infodir))
439perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
440template_dir_SQ = $(subst ','\'',$(template_dir))
441htmldir_SQ = $(subst ','\'',$(htmldir))
442prefix_SQ = $(subst ','\'',$(prefix))
443sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
444
445ifneq ($(filter /%,$(firstword $(perfexecdir))),)
446perfexec_instdir = $(perfexecdir)
447else
448perfexec_instdir = $(prefix)/$(perfexecdir)
449endif
450perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))