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