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