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