xref: /linux/tools/perf/util/Build (revision 062d02a96d810d55afdc594ceeb52223d8b36b5c)
1include $(srctree)/tools/scripts/Makefile.include
2include $(srctree)/tools/scripts/utilities.mak
3
4perf-util-y += arm64-frame-pointer-unwind-support.o
5perf-util-y += addr_location.o
6perf-util-y += annotate.o
7perf-util-y += block-info.o
8perf-util-y += block-range.o
9perf-util-y += build-id.o
10perf-util-y += cacheline.o
11perf-util-y += capstone.o
12perf-util-y += config.o
13perf-util-y += copyfile.o
14perf-util-y += ctype.o
15perf-util-y += db-export.o
16perf-util-y += disasm.o
17perf-util-y += env.o
18perf-util-y += event.o
19perf-util-y += evlist.o
20perf-util-y += sideband_evlist.o
21perf-util-y += evsel.o
22perf-util-y += evsel_fprintf.o
23perf-util-y += perf_event_attr_fprintf.o
24perf-util-y += evswitch.o
25perf-util-y += find_bit.o
26perf-util-y += levenshtein.o
27perf-util-$(CONFIG_LIBBFD) += libbfd.o
28perf-util-y += llvm.o
29perf-util-y += mmap.o
30perf-util-y += memswap.o
31perf-util-y += parse-events.o
32perf-util-y += print-events.o
33perf-util-y += tracepoint.o
34perf-util-y += perf_regs.o
35perf-util-y += perf-regs-arch/
36perf-util-y += path.o
37perf-util-y += print_binary.o
38perf-util-y += print_insn.o
39perf-util-y += rlimit.o
40perf-util-y += argv_split.o
41perf-util-y += rbtree.o
42perf-util-y += libstring.o
43perf-util-y += bitmap.o
44perf-util-y += hweight.o
45perf-util-y += sha1.o
46perf-util-y += smt.o
47perf-util-y += strbuf.o
48perf-util-y += string.o
49perf-util-y += strlist.o
50perf-util-y += strfilter.o
51perf-util-y += top.o
52perf-util-y += usage.o
53perf-util-y += dso.o
54perf-util-y += dsos.o
55perf-util-y += symbol.o
56perf-util-y += symbol_fprintf.o
57perf-util-y += map_symbol.o
58perf-util-y += color.o
59perf-util-y += color_config.o
60perf-util-y += metricgroup.o
61perf-util-y += header.o
62perf-util-y += callchain.o
63perf-util-y += values.o
64perf-util-y += debug.o
65perf-util-y += fncache.o
66perf-util-y += machine.o
67perf-util-y += map.o
68perf-util-y += maps.o
69perf-util-y += pstack.o
70perf-util-y += session.o
71perf-util-y += tool.o
72perf-util-y += sample.o
73perf-util-y += sample-raw.o
74perf-util-y += s390-sample-raw.o
75perf-util-y += amd-sample-raw.o
76perf-util-$(CONFIG_TRACE) += syscalltbl.o
77perf-util-y += ordered-events.o
78perf-util-y += namespaces.o
79perf-util-y += comm.o
80perf-util-y += thread.o
81perf-util-y += threads.o
82perf-util-y += thread_map.o
83perf-util-y += parse-events-flex.o
84perf-util-y += parse-events-bison.o
85perf-util-y += pmu.o
86perf-util-y += pmus.o
87perf-util-y += pmu-flex.o
88perf-util-y += pmu-bison.o
89perf-util-y += drm_pmu.o
90perf-util-y += hwmon_pmu.o
91perf-util-y += tool_pmu.o
92perf-util-y += tp_pmu.o
93perf-util-y += svghelper.o
94perf-util-y += trace-event-info.o
95perf-util-y += trace-event-scripting.o
96perf-util-$(CONFIG_LIBTRACEEVENT) += trace-event.o
97perf-util-$(CONFIG_LIBTRACEEVENT) += trace-event-parse.o
98perf-util-$(CONFIG_LIBTRACEEVENT) += trace-event-read.o
99perf-util-y += sort.o
100perf-util-y += hist.o
101perf-util-y += util.o
102perf-util-y += cpumap.o
103perf-util-y += affinity.o
104perf-util-y += cputopo.o
105perf-util-y += cgroup.o
106perf-util-y += target.o
107perf-util-y += rblist.o
108perf-util-y += intlist.o
109perf-util-y += vdso.o
110perf-util-y += counts.o
111perf-util-y += stat.o
112perf-util-y += stat-shadow.o
113perf-util-y += stat-display.o
114perf-util-y += perf_api_probe.o
115perf-util-y += record.o
116perf-util-y += srcline.o
117perf-util-y += srccode.o
118perf-util-y += synthetic-events.o
119perf-util-y += data.o
120perf-util-y += tsc.o
121perf-util-y += cloexec.o
122perf-util-y += call-path.o
123perf-util-y += rwsem.o
124perf-util-y += thread-stack.o
125perf-util-y += spark.o
126perf-util-y += topdown.o
127perf-util-y += iostat.o
128perf-util-y += stream.o
129perf-util-y += kvm-stat.o
130perf-util-y += lock-contention.o
131perf-util-$(CONFIG_AUXTRACE) += auxtrace.o
132perf-util-y += intel-pt-decoder/
133perf-util-$(CONFIG_AUXTRACE) += intel-pt.o
134perf-util-$(CONFIG_AUXTRACE) += intel-bts.o
135perf-util-$(CONFIG_AUXTRACE) += arm-spe.o
136perf-util-$(CONFIG_AUXTRACE) += arm-spe-decoder/
137perf-util-$(CONFIG_AUXTRACE) += hisi-ptt.o
138perf-util-$(CONFIG_AUXTRACE) += hisi-ptt-decoder/
139perf-util-$(CONFIG_AUXTRACE) += s390-cpumsf.o
140perf-util-$(CONFIG_AUXTRACE) += powerpc-vpadtl.o
141
142ifdef CONFIG_LIBOPENCSD
143perf-util-$(CONFIG_AUXTRACE) += cs-etm.o
144perf-util-$(CONFIG_AUXTRACE) += cs-etm-decoder/
145endif
146perf-util-$(CONFIG_AUXTRACE) += cs-etm-base.o
147
148perf-util-y += parse-branch-options.o
149perf-util-y += dump-insn.o
150perf-util-y += parse-regs-options.o
151perf-util-y += parse-sublevel-options.o
152perf-util-y += term.o
153perf-util-y += help-unknown-cmd.o
154perf-util-y += dlfilter.o
155perf-util-y += mem-events.o
156perf-util-y += mem-info.o
157perf-util-y += vsprintf.o
158perf-util-y += units.o
159perf-util-y += time-utils.o
160perf-util-y += expr-flex.o
161perf-util-y += expr-bison.o
162perf-util-y += expr.o
163perf-util-y += branch.o
164perf-util-y += mem2node.o
165perf-util-y += clockid.o
166perf-util-y += list_sort.o
167perf-util-y += mutex.o
168perf-util-y += sharded_mutex.o
169perf-util-y += intel-tpebs.o
170
171perf-util-$(CONFIG_LIBBPF) += bpf_map.o
172perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter.o
173perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter_cgroup.o
174perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_ftrace.o
175perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_off_cpu.o
176perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter.o
177perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter-flex.o
178perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter-bison.o
179perf-util-$(CONFIG_PERF_BPF_SKEL) += btf.o
180
181ifeq ($(CONFIG_TRACE),y)
182  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-trace-summary.o
183  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_trace_augment.o
184endif
185
186ifeq ($(CONFIG_LIBTRACEEVENT),y)
187  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_lock_contention.o
188endif
189
190ifeq ($(CONFIG_LIBTRACEEVENT),y)
191  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_kwork.o
192  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_kwork_top.o
193endif
194
195perf-util-$(CONFIG_LIBELF) += symbol-elf.o
196perf-util-$(CONFIG_LIBELF) += probe-file.o
197perf-util-$(CONFIG_LIBELF) += probe-event.o
198
199ifdef CONFIG_LIBBPF_DYNAMIC
200  hashmap := 1
201endif
202ifndef CONFIG_LIBBPF
203  hashmap := 1
204endif
205
206ifdef hashmap
207perf-util-y += hashmap.o
208endif
209
210ifndef CONFIG_LIBELF
211perf-util-y += symbol-minimal.o
212endif
213
214ifndef CONFIG_SETNS
215perf-util-y += setns.o
216endif
217
218perf-util-$(CONFIG_LIBDW) += probe-finder.o
219perf-util-$(CONFIG_LIBDW) += dwarf-aux.o
220perf-util-$(CONFIG_LIBDW) += dwarf-regs.o
221perf-util-$(CONFIG_LIBDW) += dwarf-regs-csky.o
222perf-util-$(CONFIG_LIBDW) += dwarf-regs-powerpc.o
223perf-util-$(CONFIG_LIBDW) += dwarf-regs-x86.o
224perf-util-$(CONFIG_LIBDW) += debuginfo.o
225perf-util-$(CONFIG_LIBDW) += annotate-data.o
226
227perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
228perf-util-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
229perf-util-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
230perf-util-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
231perf-util-$(CONFIG_LIBUNWIND_AARCH64)  += libunwind/arm64.o
232
233ifeq ($(CONFIG_LIBTRACEEVENT),y)
234  perf-util-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
235endif
236
237perf-util-y += data-convert-json.o
238
239perf-util-y += scripting-engines/
240
241perf-util-$(CONFIG_ZLIB) += zlib.o
242perf-util-$(CONFIG_LZMA) += lzma.o
243perf-util-$(CONFIG_ZSTD) += zstd.o
244
245perf-util-y += cap.o
246
247perf-util-$(CONFIG_CXX_DEMANGLE) += demangle-cxx.o
248perf-util-y += demangle-ocaml.o
249perf-util-y += demangle-java.o
250perf-util-y += demangle-rust-v0.o
251perf-util-$(CONFIG_LIBLLVM) += llvm-c-helpers.o
252
253CFLAGS_demangle-rust-v0.o += -Wno-shadow -Wno-declaration-after-statement \
254    -Wno-switch-default -Wno-switch-enum -Wno-missing-field-initializers
255
256ifdef CONFIG_JITDUMP
257perf-util-$(CONFIG_LIBELF) += jitdump.o
258perf-util-$(CONFIG_LIBELF) += genelf.o
259perf-util-$(CONFIG_LIBDW) += genelf_debug.o
260endif
261
262perf-util-y += perf-hooks.o
263
264perf-util-$(CONFIG_LIBBPF) += bpf-event.o
265perf-util-$(CONFIG_LIBBPF) += bpf-utils.o
266
267perf-util-$(CONFIG_LIBPFM4) += pfm.o
268
269CFLAGS_config.o   += -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
270
271# avoid compiler warnings in 32-bit mode
272CFLAGS_genelf_debug.o  += -Wno-packed
273
274$(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-flex.h: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
275	$(call rule_mkdir)
276	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/parse-events-flex.c \
277		--header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) $<
278
279$(OUTPUT)util/parse-events-bison.c $(OUTPUT)util/parse-events-bison.h: util/parse-events.y
280	$(call rule_mkdir)
281	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) $(BISON_FALLBACK_FLAGS) \
282		-o $(OUTPUT)util/parse-events-bison.c -p parse_events_
283
284$(OUTPUT)util/expr-flex.c $(OUTPUT)util/expr-flex.h: util/expr.l $(OUTPUT)util/expr-bison.c
285	$(call rule_mkdir)
286	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/expr-flex.c \
287		--header-file=$(OUTPUT)util/expr-flex.h $(PARSER_DEBUG_FLEX) $<
288
289$(OUTPUT)util/expr-bison.c $(OUTPUT)util/expr-bison.h: util/expr.y
290	$(call rule_mkdir)
291	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
292		-o $(OUTPUT)util/expr-bison.c -p expr_
293
294$(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-flex.h: util/pmu.l $(OUTPUT)util/pmu-bison.c
295	$(call rule_mkdir)
296	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/pmu-flex.c \
297		--header-file=$(OUTPUT)util/pmu-flex.h $(PARSER_DEBUG_FLEX) $<
298
299$(OUTPUT)util/pmu-bison.c $(OUTPUT)util/pmu-bison.h: util/pmu.y
300	$(call rule_mkdir)
301	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
302		-o $(OUTPUT)util/pmu-bison.c -p perf_pmu_
303
304$(OUTPUT)util/bpf-filter-flex.c $(OUTPUT)util/bpf-filter-flex.h: util/bpf-filter.l $(OUTPUT)util/bpf-filter-bison.c util/bpf-filter.h util/bpf_skel/sample-filter.h
305	$(call rule_mkdir)
306	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/bpf-filter-flex.c \
307		--header-file=$(OUTPUT)util/bpf-filter-flex.h $(PARSER_DEBUG_FLEX) $<
308
309$(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filter.y util/bpf-filter.h util/bpf_skel/sample-filter.h
310	$(call rule_mkdir)
311	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
312		-o $(OUTPUT)util/bpf-filter-bison.c -p perf_bpf_filter_
313
314FLEX_VERSION := $(shell $(FLEX) --version | cut -d' ' -f2)
315
316FLEX_GE_260 := $(call version-ge3,$(FLEX_VERSION),2.6.0)
317ifeq ($(FLEX_GE_260),1)
318  flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function -Wno-misleading-indentation
319
320  # Some newer clang and gcc version complain about this
321  # util/parse-events-bison.c:1317:9: error: variable 'parse_events_nerrs' set but not used [-Werror,-Wunused-but-set-variable]
322  #  int yynerrs = 0;
323
324  flex_flags += -Wno-unused-but-set-variable
325
326  FLEX_LT_262 := $(call version-lt3,$(FLEX_VERSION),2.6.2)
327  ifeq ($(FLEX_LT_262),1)
328    flex_flags += -Wno-sign-compare
329  endif
330else
331  flex_flags := -w
332endif
333
334# Some newer clang and gcc version complain about this
335# util/parse-events-bison.c:1317:9: error: variable 'parse_events_nerrs' set but not used [-Werror,-Wunused-but-set-variable]
336#  int yynerrs = 0;
337
338bison_flags := -DYYENABLE_NLS=0 -Wno-unused-but-set-variable
339
340# Old clangs don't grok -Wno-unused-but-set-variable, remove it
341ifeq ($(CC_NO_CLANG), 0)
342  CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')
343  ifeq ($(call version-lt3,$(CLANG_VERSION),13.0.0),1)
344    bison_flags := $(subst -Wno-unused-but-set-variable,,$(bison_flags))
345    flex_flags := $(subst -Wno-unused-but-set-variable,,$(flex_flags))
346  endif
347endif
348
349BISON_GE_382 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 382)
350ifeq ($(BISON_GE_382),1)
351  bison_flags += -Wno-switch-enum
352else
353  bison_flags += -w
354endif
355
356BISON_LT_381 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \< 381)
357ifeq ($(BISON_LT_381),1)
358  bison_flags += -DYYNOMEM=YYABORT
359endif
360
361CFLAGS_parse-events-flex.o  += $(flex_flags) -Wno-unused-label
362CFLAGS_pmu-flex.o           += $(flex_flags)
363CFLAGS_expr-flex.o          += $(flex_flags)
364CFLAGS_bpf-filter-flex.o    += $(flex_flags)
365
366CFLAGS_parse-events-bison.o += $(bison_flags)
367CFLAGS_pmu-bison.o          += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
368CFLAGS_expr-bison.o         += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
369CFLAGS_bpf-filter-bison.o   += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
370
371$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
372$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
373$(OUTPUT)util/expr.o: $(OUTPUT)util/expr-flex.c $(OUTPUT)util/expr-bison.c
374$(OUTPUT)util/bpf-filter.o: $(OUTPUT)util/bpf-filter-flex.c $(OUTPUT)util/bpf-filter-bison.c
375
376CFLAGS_bitmap.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
377CFLAGS_find_bit.o      += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
378CFLAGS_rbtree.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
379CFLAGS_libstring.o     += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
380CFLAGS_hweight.o       += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
381CFLAGS_header.o        += -include $(OUTPUT)PERF-VERSION-FILE
382CFLAGS_arm-spe.o       += -I$(srctree)/tools/arch/arm64/include/ -I$(OUTPUT)arch/arm64/include/generated/
383
384$(OUTPUT)util/argv_split.o: ../lib/argv_split.c FORCE
385	$(call rule_mkdir)
386	$(call if_changed_dep,cc_o_c)
387
388$(OUTPUT)util/bitmap.o: ../lib/bitmap.c FORCE
389	$(call rule_mkdir)
390	$(call if_changed_dep,cc_o_c)
391
392$(OUTPUT)util/ctype.o: ../lib/ctype.c FORCE
393	$(call rule_mkdir)
394	$(call if_changed_dep,cc_o_c)
395
396$(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE
397	$(call rule_mkdir)
398	$(call if_changed_dep,cc_o_c)
399
400$(OUTPUT)util/rbtree.o: ../lib/rbtree.c FORCE
401	$(call rule_mkdir)
402	$(call if_changed_dep,cc_o_c)
403
404$(OUTPUT)util/libstring.o: ../lib/string.c FORCE
405	$(call rule_mkdir)
406	$(call if_changed_dep,cc_o_c)
407
408$(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
409	$(call rule_mkdir)
410	$(call if_changed_dep,cc_o_c)
411
412$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
413	$(call rule_mkdir)
414	$(call if_changed_dep,cc_o_c)
415
416$(OUTPUT)util/list_sort.o: ../lib/list_sort.c FORCE
417	$(call rule_mkdir)
418	$(call if_changed_dep,cc_o_c)
419
420ifdef SHELLCHECK
421  SHELL_TESTS := generate-cmdlist.sh
422  SHELL_TEST_LOGS := $(SHELL_TESTS:%=%.shellcheck_log)
423else
424  SHELL_TESTS :=
425  SHELL_TEST_LOGS :=
426endif
427
428$(OUTPUT)%.shellcheck_log: %
429	$(call rule_mkdir)
430	$(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)
431
432perf-util-y += $(SHELL_TEST_LOGS)
433
434PY_TESTS := setup.py
435ifdef MYPY
436  MYPY_TEST_LOGS := $(PY_TESTS:%=%.mypy_log)
437else
438  MYPY_TEST_LOGS :=
439endif
440
441$(OUTPUT)%.mypy_log: %
442	$(call rule_mkdir)
443	$(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
444
445perf-util-y += $(MYPY_TEST_LOGS)
446
447ifdef PYLINT
448  PYLINT_TEST_LOGS := $(PY_TESTS:%=%.pylint_log)
449else
450  PYLINT_TEST_LOGS :=
451endif
452
453$(OUTPUT)%.pylint_log: %
454	$(call rule_mkdir)
455	$(Q)$(call echo-cmd,test)pylint "$<" > $@ || (cat $@ && rm $@ && false)
456
457perf-util-y += $(PYLINT_TEST_LOGS)
458