Commit | Line | Data |
---|---|---|
8bd407b9 JO |
1 | uname_M := $(shell uname -m 2>/dev/null || echo not) |
2 | ||
3 | ARCH ?= $(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/ ) | |
8 | NO_PERF_REGS := 1 | |
9c12cf95 | 9 | CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) |
8bd407b9 JO |
10 | |
11 | # Additional ARCH settings for x86 | |
12 | ifeq ($(ARCH),i386) | |
13 | override ARCH := x86 | |
14 | NO_PERF_REGS := 0 | |
15 | LIBUNWIND_LIBS = -lunwind -lunwind-x86 | |
16 | endif | |
17 | ||
18 | ifeq ($(ARCH),x86_64) | |
19 | override ARCH := x86 | |
20 | IS_X86_64 := 0 | |
9c12cf95 | 21 | ifeq (, $(findstring m32,$(CFLAGS))) |
8bd407b9 JO |
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 | |
9c12cf95 | 26 | CFLAGS += -DARCH_X86_64 |
8bd407b9 JO |
27 | 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 | |
31 | endif | |
32 | ||
33 | ifeq ($(NO_PERF_REGS),0) | |
9c12cf95 | 34 | CFLAGS += -DHAVE_PERF_REGS |
8bd407b9 | 35 | endif |
a32f4936 | 36 | |
7c53746e JO |
37 | ifeq ($(src-perf),) |
38 | src-perf := $(srctree)/tools/perf | |
39 | endif | |
40 | ||
41 | ifeq ($(obj-perf),) | |
42 | obj-perf := $(objtree) | |
43 | endif | |
44 | ||
45 | ifneq ($(obj-perf),) | |
46 | obj-perf := $(abspath $(obj-perf))/ | |
47 | endif | |
48 | ||
49 | # include ARCH specific config | |
50 | -include $(src-perf)/arch/$(ARCH)/Makefile | |
51 | ||
52 | include $(src-perf)/config/feature-tests.mak | |
53 | include $(src-perf)/config/utilities.mak | |
a32f4936 JO |
54 | |
55 | ifeq ($(call get-executable,$(FLEX)),) | |
56 | dummy := $(error Error: $(FLEX) is missing on this system, please install it) | |
57 | endif | |
58 | ||
59 | ifeq ($(call get-executable,$(BISON)),) | |
60 | dummy := $(error Error: $(BISON) is missing on this system, please install it) | |
61 | endif | |
362493f0 JO |
62 | |
63 | # Treat warnings as errors unless directed not to | |
64 | ifneq ($(WERROR),0) | |
9c12cf95 | 65 | CFLAGS += -Werror |
362493f0 JO |
66 | endif |
67 | ||
68 | ifeq ("$(origin DEBUG)", "command line") | |
69 | PERF_DEBUG = $(DEBUG) | |
70 | endif | |
71 | ifndef PERF_DEBUG | |
9c12cf95 | 72 | CFLAGS += -O6 |
362493f0 JO |
73 | endif |
74 | ||
75 | ifdef PARSER_DEBUG | |
9c12cf95 JO |
76 | PARSER_DEBUG_BISON := -t |
77 | PARSER_DEBUG_FLEX := -d | |
78 | CFLAGS += -DPARSER_DEBUG | |
362493f0 JO |
79 | endif |
80 | ||
9c12cf95 JO |
81 | CFLAGS += \ |
82 | -fno-omit-frame-pointer \ | |
83 | -ggdb3 \ | |
84 | -funwind-tables \ | |
85 | -Wall \ | |
86 | -Wextra \ | |
87 | -std=gnu99 | |
88 | ||
362493f0 | 89 | EXTLIBS = -lpthread -lrt -lelf -lm |
362493f0 JO |
90 | |
91 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) | |
9c12cf95 | 92 | CFLAGS += -fstack-protector-all |
362493f0 JO |
93 | endif |
94 | ||
95 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) | |
9c12cf95 | 96 | CFLAGS += -Wstack-protector |
362493f0 JO |
97 | endif |
98 | ||
99 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) | |
9c12cf95 | 100 | CFLAGS += -Wvolatile-register-var |
362493f0 JO |
101 | endif |
102 | ||
103 | ifndef PERF_DEBUG | |
104 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) | |
9c12cf95 | 105 | CFLAGS += -D_FORTIFY_SOURCE=2 |
362493f0 JO |
106 | endif |
107 | endif | |
108 | ||
9c12cf95 | 109 | CFLAGS += \ |
7c53746e JO |
110 | -I$(src-perf)/util/include \ |
111 | -I$(src-perf)/arch/$(ARCH)/include \ | |
362493f0 JO |
112 | -I$(srctree)/arch/$(ARCH)/include/uapi \ |
113 | -I$(srctree)/arch/$(ARCH)/include \ | |
362493f0 | 114 | -I$(srctree)/include/uapi \ |
7c53746e JO |
115 | -I$(srctree)/include |
116 | ||
117 | # $(obj-perf) for generated common-cmds.h | |
118 | # $(obj-perf)/util for generated bison/flex headers | |
119 | ifneq ($(OUTPUT),) | |
120 | CFLAGS += \ | |
121 | -I$(obj-perf)/util \ | |
122 | -I$(obj-perf) | |
123 | endif | |
124 | ||
125 | CFLAGS += \ | |
126 | -I$(src-perf)/util \ | |
127 | -I$(src-perf) \ | |
362493f0 | 128 | -I$(TRACE_EVENT_DIR) \ |
7c53746e JO |
129 | -I$(srctree)/tools/lib/ |
130 | ||
131 | CFLAGS += \ | |
362493f0 JO |
132 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE |
133 | ||
362493f0 JO |
134 | ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) |
135 | BIONIC := 1 | |
136 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) | |
137 | EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) | |
362493f0 | 138 | endif |
cf4cca10 JO |
139 | |
140 | ifdef NO_LIBELF | |
141 | NO_DWARF := 1 | |
142 | NO_DEMANGLE := 1 | |
143 | NO_LIBUNWIND := 1 | |
144 | else | |
1e9f7aad | 145 | FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) |
cf4cca10 | 146 | ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) |
1e9f7aad | 147 | FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS) |
cf4cca10 JO |
148 | ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) |
149 | LIBC_SUPPORT := 1 | |
150 | endif | |
151 | ifeq ($(BIONIC),1) | |
152 | LIBC_SUPPORT := 1 | |
153 | endif | |
154 | ifeq ($(LIBC_SUPPORT),1) | |
155 | msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); | |
156 | ||
157 | NO_LIBELF := 1 | |
158 | NO_DWARF := 1 | |
159 | NO_DEMANGLE := 1 | |
160 | else | |
161 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); | |
162 | endif | |
163 | else | |
164 | # for linking with debug library, run like: | |
165 | # make DEBUG=1 LIBDW_DIR=/opt/libdw/ | |
166 | ifdef LIBDW_DIR | |
167 | LIBDW_CFLAGS := -I$(LIBDW_DIR)/include | |
168 | LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib | |
169 | endif | |
170 | ||
1e9f7aad | 171 | FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) |
cf4cca10 JO |
172 | ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) |
173 | 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); | |
174 | NO_DWARF := 1 | |
175 | endif # Dwarf support | |
176 | endif # SOURCE_LIBELF | |
177 | endif # NO_LIBELF | |
178 | ||
179 | ifndef NO_LIBELF | |
9c12cf95 | 180 | CFLAGS += -DLIBELF_SUPPORT |
1e9f7aad | 181 | FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) |
cf4cca10 | 182 | ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) |
9c12cf95 | 183 | CFLAGS += -DLIBELF_MMAP |
cf4cca10 | 184 | endif |
779724fd JO |
185 | |
186 | # include ARCH specific config | |
7c53746e | 187 | -include $(src-perf)/arch/$(ARCH)/Makefile |
779724fd JO |
188 | |
189 | ifndef NO_DWARF | |
190 | ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) | |
191 | msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); | |
192 | NO_DWARF := 1 | |
193 | else | |
9c12cf95 | 194 | CFLAGS += -DDWARF_SUPPORT $(LIBDW_CFLAGS) |
1e9f7aad | 195 | LDFLAGS += $(LIBDW_LDFLAGS) |
779724fd JO |
196 | EXTLIBS += -lelf -ldw |
197 | endif # PERF_HAVE_DWARF_REGS | |
198 | endif # NO_DWARF | |
199 | ||
cf4cca10 | 200 | endif # NO_LIBELF |
0e433feb | 201 | |
1e9f7aad JO |
202 | ifndef NO_LIBELF |
203 | CFLAGS += -DLIBELF_SUPPORT | |
204 | FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) | |
205 | ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) | |
206 | CFLAGS += -DLIBELF_MMAP | |
207 | endif # try-cc | |
208 | endif # NO_LIBELF | |
209 | ||
0e433feb JO |
210 | # There's only x86 (both 32 and 64) support for CFI unwind so far |
211 | ifneq ($(ARCH),x86) | |
212 | NO_LIBUNWIND := 1 | |
213 | endif | |
214 | ||
215 | ifndef NO_LIBUNWIND | |
216 | # for linking with debug library, run like: | |
217 | # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ | |
218 | ifdef LIBUNWIND_DIR | |
219 | LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include | |
220 | LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib | |
221 | endif | |
222 | ||
1e9f7aad | 223 | FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) |
0e433feb JO |
224 | ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) |
225 | msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); | |
226 | NO_LIBUNWIND := 1 | |
227 | endif # Libunwind support | |
228 | endif # NO_LIBUNWIND | |
229 | ||
230 | ifndef NO_LIBUNWIND | |
9c12cf95 | 231 | CFLAGS += -DLIBUNWIND_SUPPORT |
0e433feb | 232 | EXTLIBS += $(LIBUNWIND_LIBS) |
9c12cf95 | 233 | CFLAGS += $(LIBUNWIND_CFLAGS) |
1e9f7aad | 234 | LDFLAGS += $(LIBUNWIND_LDFLAGS) |
0e433feb | 235 | endif # NO_LIBUNWIND |
a8279525 JO |
236 | |
237 | ifndef NO_LIBAUDIT | |
1e9f7aad | 238 | FLAGS_LIBAUDIT = $(CFLAGS) $(LDFLAGS) -laudit |
a8279525 JO |
239 | ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y) |
240 | msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); | |
241 | NO_LIBAUDIT := 1 | |
242 | else | |
9c12cf95 | 243 | CFLAGS += -DLIBAUDIT_SUPPORT |
a8279525 JO |
244 | EXTLIBS += -laudit |
245 | endif | |
246 | endif | |
4a8f888a JO |
247 | |
248 | ifdef NO_NEWT | |
249 | NO_SLANG=1 | |
250 | endif | |
251 | ||
252 | ifndef NO_SLANG | |
1e9f7aad | 253 | FLAGS_SLANG=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang |
4a8f888a JO |
254 | ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y) |
255 | msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); | |
256 | NO_SLANG := 1 | |
257 | else | |
258 | # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h | |
9c12cf95 JO |
259 | CFLAGS += -I/usr/include/slang |
260 | CFLAGS += -DSLANG_SUPPORT | |
4a8f888a JO |
261 | EXTLIBS += -lslang |
262 | endif | |
263 | endif | |
58cabf6a JO |
264 | |
265 | ifndef NO_GTK2 | |
1e9f7aad | 266 | FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) |
58cabf6a JO |
267 | ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y) |
268 | msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); | |
269 | NO_GTK2 := 1 | |
270 | else | |
271 | ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y) | |
9c12cf95 | 272 | CFLAGS += -DHAVE_GTK_INFO_BAR |
58cabf6a | 273 | endif |
9c12cf95 JO |
274 | CFLAGS += -DGTK2_SUPPORT |
275 | CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) | |
58cabf6a JO |
276 | EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null) |
277 | endif | |
278 | endif | |
3082cb33 JO |
279 | |
280 | grep-libs = $(filter -l%,$(1)) | |
281 | strip-libs = $(filter-out -l%,$(1)) | |
282 | ||
283 | ifdef NO_LIBPERL | |
9c12cf95 | 284 | CFLAGS += -DNO_LIBPERL |
3082cb33 JO |
285 | else |
286 | PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) | |
287 | PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) | |
288 | PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) | |
289 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` | |
290 | FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) | |
291 | ||
292 | ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y) | |
9c12cf95 | 293 | CFLAGS += -DNO_LIBPERL |
3082cb33 JO |
294 | NO_LIBPERL := 1 |
295 | else | |
1e9f7aad | 296 | LDFLAGS += $(PERL_EMBED_LDFLAGS) |
3082cb33 JO |
297 | EXTLIBS += $(PERL_EMBED_LIBADD) |
298 | endif | |
299 | endif | |
6e533cf1 JO |
300 | |
301 | disable-python = $(eval $(disable-python_code)) | |
302 | define disable-python_code | |
9c12cf95 | 303 | CFLAGS += -DNO_LIBPYTHON |
6e533cf1 JO |
304 | $(if $(1),$(warning No $(1) was found)) |
305 | $(warning Python support will not be built) | |
306 | NO_LIBPYTHON := 1 | |
307 | endef | |
308 | ||
309 | override PYTHON := \ | |
310 | $(call get-executable-or-default,PYTHON,python) | |
311 | ||
312 | ifndef PYTHON | |
313 | $(call disable-python,python interpreter) | |
314 | else | |
315 | ||
316 | PYTHON_WORD := $(call shell-wordify,$(PYTHON)) | |
317 | ||
318 | ifdef NO_LIBPYTHON | |
319 | $(call disable-python) | |
320 | else | |
321 | ||
322 | override PYTHON_CONFIG := \ | |
323 | $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config) | |
324 | ||
325 | ifndef PYTHON_CONFIG | |
326 | $(call disable-python,python-config tool) | |
327 | else | |
328 | ||
329 | PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) | |
330 | ||
331 | PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) | |
332 | PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) | |
333 | PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) | |
334 | PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) | |
335 | FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) | |
336 | ||
337 | ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y) | |
338 | $(call disable-python,Python.h (for Python 2.x)) | |
339 | else | |
340 | ||
341 | ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y) | |
342 | $(warning Python 3 is not yet supported; please set) | |
343 | $(warning PYTHON and/or PYTHON_CONFIG appropriately.) | |
344 | $(warning If you also have Python 2 installed, then) | |
345 | $(warning try something like:) | |
346 | $(warning $(and ,)) | |
347 | $(warning $(and ,) make PYTHON=python2) | |
348 | $(warning $(and ,)) | |
349 | $(warning Otherwise, disable Python support entirely:) | |
350 | $(warning $(and ,)) | |
351 | $(warning $(and ,) make NO_LIBPYTHON=1) | |
352 | $(warning $(and ,)) | |
353 | $(error $(and ,)) | |
354 | else | |
1e9f7aad | 355 | LDFLAGS += $(PYTHON_EMBED_LDFLAGS) |
6e533cf1 | 356 | EXTLIBS += $(PYTHON_EMBED_LIBADD) |
7c53746e | 357 | LANG_BINDINGS += $(obj-perf)python/perf.so |
6e533cf1 JO |
358 | endif |
359 | endif | |
360 | endif | |
361 | endif | |
362 | endif | |
c3cf8368 JO |
363 | |
364 | ifdef NO_DEMANGLE | |
9c12cf95 | 365 | CFLAGS += -DNO_DEMANGLE |
c3cf8368 JO |
366 | else |
367 | ifdef HAVE_CPLUS_DEMANGLE | |
368 | EXTLIBS += -liberty | |
9c12cf95 | 369 | CFLAGS += -DHAVE_CPLUS_DEMANGLE |
c3cf8368 | 370 | else |
1e9f7aad | 371 | FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd |
c3cf8368 JO |
372 | has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd) |
373 | ifeq ($(has_bfd),y) | |
374 | EXTLIBS += -lbfd | |
375 | else | |
376 | FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty | |
377 | has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty) | |
378 | ifeq ($(has_bfd_iberty),y) | |
379 | EXTLIBS += -lbfd -liberty | |
380 | else | |
381 | FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz | |
382 | has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz) | |
383 | ifeq ($(has_bfd_iberty_z),y) | |
384 | EXTLIBS += -lbfd -liberty -lz | |
385 | else | |
1e9f7aad | 386 | FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -liberty |
c3cf8368 JO |
387 | has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle) |
388 | ifeq ($(has_cplus_demangle),y) | |
389 | EXTLIBS += -liberty | |
9c12cf95 | 390 | CFLAGS += -DHAVE_CPLUS_DEMANGLE |
c3cf8368 JO |
391 | else |
392 | msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) | |
9c12cf95 | 393 | CFLAGS += -DNO_DEMANGLE |
c3cf8368 JO |
394 | endif |
395 | endif | |
396 | endif | |
397 | endif | |
398 | endif | |
399 | endif | |
a1c7c9e7 JO |
400 | |
401 | ifndef NO_STRLCPY | |
402 | ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y) | |
9c12cf95 | 403 | CFLAGS += -DHAVE_STRLCPY |
a1c7c9e7 JO |
404 | endif |
405 | endif | |
406 | ||
407 | ifndef NO_ON_EXIT | |
408 | ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y) | |
9c12cf95 | 409 | CFLAGS += -DHAVE_ON_EXIT |
a1c7c9e7 JO |
410 | endif |
411 | endif | |
412 | ||
413 | ifndef NO_BACKTRACE | |
414 | ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y) | |
9c12cf95 | 415 | CFLAGS += -DBACKTRACE_SUPPORT |
a1c7c9e7 JO |
416 | endif |
417 | endif | |
58a0abd7 JO |
418 | |
419 | ifndef NO_LIBNUMA | |
1e9f7aad | 420 | FLAGS_LIBNUMA = $(CFLAGS) $(LDFLAGS) -lnuma |
58a0abd7 JO |
421 | ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y) |
422 | msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev); | |
423 | NO_LIBNUMA := 1 | |
424 | else | |
9c12cf95 | 425 | CFLAGS += -DLIBNUMA_SUPPORT |
58a0abd7 JO |
426 | EXTLIBS += -lnuma |
427 | endif | |
428 | endif | |
cd1c39f2 JO |
429 | |
430 | # Among the variables below, these: | |
431 | # perfexecdir | |
432 | # template_dir | |
433 | # mandir | |
434 | # infodir | |
435 | # htmldir | |
436 | # ETC_PERFCONFIG (but not sysconfdir) | |
437 | # can be specified as a relative path some/where/else; | |
438 | # this is interpreted as relative to $(prefix) and "perf" at | |
439 | # runtime figures out where they are based on the path to the executable. | |
440 | # This can help installing the suite in a relocatable way. | |
441 | ||
442 | # Make the path relative to DESTDIR, not to prefix | |
443 | ifndef DESTDIR | |
444 | prefix = $(HOME) | |
445 | endif | |
446 | bindir_relative = bin | |
447 | bindir = $(prefix)/$(bindir_relative) | |
448 | mandir = share/man | |
449 | infodir = share/info | |
450 | perfexecdir = libexec/perf-core | |
451 | sharedir = $(prefix)/share | |
452 | template_dir = share/perf-core/templates | |
453 | htmldir = share/doc/perf-doc | |
454 | ifeq ($(prefix),/usr) | |
455 | sysconfdir = /etc | |
456 | ETC_PERFCONFIG = $(sysconfdir)/perfconfig | |
457 | else | |
458 | sysconfdir = $(prefix)/etc | |
459 | ETC_PERFCONFIG = etc/perfconfig | |
460 | endif | |
461 | lib = lib | |
462 | ||
463 | # Shell quote (do not use $(call) to accommodate ancient setups); | |
464 | ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) | |
465 | DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) | |
466 | bindir_SQ = $(subst ','\'',$(bindir)) | |
467 | mandir_SQ = $(subst ','\'',$(mandir)) | |
468 | infodir_SQ = $(subst ','\'',$(infodir)) | |
469 | perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) | |
470 | template_dir_SQ = $(subst ','\'',$(template_dir)) | |
471 | htmldir_SQ = $(subst ','\'',$(htmldir)) | |
472 | prefix_SQ = $(subst ','\'',$(prefix)) | |
473 | sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) | |
474 | ||
475 | ifneq ($(filter /%,$(firstword $(perfexecdir))),) | |
476 | perfexec_instdir = $(perfexecdir) | |
477 | else | |
478 | perfexec_instdir = $(prefix)/$(perfexecdir) | |
479 | endif | |
480 | perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) |