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