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