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