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