xref: /linux/tools/perf/util/Build (revision 8d3b6649499edd85e88b763e77bbce2ab016eb47)
1878460e8SArnaldo Carvalho de Meloinclude $(srctree)/tools/scripts/Makefile.include
210c775afSIan Rogersinclude $(srctree)/tools/scripts/utilities.mak
310c775afSIan Rogers
4e467705aSIan Rogersperf-util-y += arm64-frame-pointer-unwind-support.o
5257046a3SIan Rogersperf-util-y += addr2line.o
6e467705aSIan Rogersperf-util-y += addr_location.o
7e467705aSIan Rogersperf-util-y += annotate.o
8*8d3b6649SEric Biggersperf-util-y += blake2s.o
9e467705aSIan Rogersperf-util-y += block-info.o
10e467705aSIan Rogersperf-util-y += block-range.o
11e467705aSIan Rogersperf-util-y += build-id.o
12e467705aSIan Rogersperf-util-y += cacheline.o
13bbb99668SIan Rogersperf-util-y += capstone.o
14e467705aSIan Rogersperf-util-y += config.o
15e467705aSIan Rogersperf-util-y += copyfile.o
16e467705aSIan Rogersperf-util-y += ctype.o
17e467705aSIan Rogersperf-util-y += db-export.o
18e467705aSIan Rogersperf-util-y += disasm.o
19e467705aSIan Rogersperf-util-y += env.o
20e467705aSIan Rogersperf-util-y += event.o
21e467705aSIan Rogersperf-util-y += evlist.o
22e467705aSIan Rogersperf-util-y += sideband_evlist.o
23e467705aSIan Rogersperf-util-y += evsel.o
24e467705aSIan Rogersperf-util-y += evsel_fprintf.o
25e467705aSIan Rogersperf-util-y += perf_event_attr_fprintf.o
26e467705aSIan Rogersperf-util-y += evswitch.o
27e467705aSIan Rogersperf-util-y += find_bit.o
28e467705aSIan Rogersperf-util-y += levenshtein.o
2995931d9aSIan Rogersperf-util-$(CONFIG_LIBBFD) += libbfd.o
30d9007afcSIan Rogersperf-util-y += llvm.o
31e467705aSIan Rogersperf-util-y += mmap.o
32e467705aSIan Rogersperf-util-y += memswap.o
33e467705aSIan Rogersperf-util-y += parse-events.o
34e467705aSIan Rogersperf-util-y += print-events.o
35e467705aSIan Rogersperf-util-y += tracepoint.o
36e467705aSIan Rogersperf-util-y += perf_regs.o
37e467705aSIan Rogersperf-util-y += perf-regs-arch/
38e467705aSIan Rogersperf-util-y += path.o
39e467705aSIan Rogersperf-util-y += print_binary.o
40e467705aSIan Rogersperf-util-y += print_insn.o
41e467705aSIan Rogersperf-util-y += rlimit.o
42e467705aSIan Rogersperf-util-y += argv_split.o
43e467705aSIan Rogersperf-util-y += rbtree.o
44e467705aSIan Rogersperf-util-y += libstring.o
45e467705aSIan Rogersperf-util-y += bitmap.o
46e467705aSIan Rogersperf-util-y += hweight.o
4743830468SEric Biggersperf-util-y += sha1.o
48e467705aSIan Rogersperf-util-y += smt.o
49e467705aSIan Rogersperf-util-y += strbuf.o
50e467705aSIan Rogersperf-util-y += string.o
51e467705aSIan Rogersperf-util-y += strlist.o
52e467705aSIan Rogersperf-util-y += strfilter.o
53e467705aSIan Rogersperf-util-y += top.o
54e467705aSIan Rogersperf-util-y += usage.o
55e467705aSIan Rogersperf-util-y += dso.o
56e467705aSIan Rogersperf-util-y += dsos.o
57e467705aSIan Rogersperf-util-y += symbol.o
58e467705aSIan Rogersperf-util-y += symbol_fprintf.o
59e467705aSIan Rogersperf-util-y += map_symbol.o
60e467705aSIan Rogersperf-util-y += color.o
61e467705aSIan Rogersperf-util-y += color_config.o
62e467705aSIan Rogersperf-util-y += metricgroup.o
63e467705aSIan Rogersperf-util-y += header.o
64e467705aSIan Rogersperf-util-y += callchain.o
65e467705aSIan Rogersperf-util-y += values.o
66e467705aSIan Rogersperf-util-y += debug.o
67e467705aSIan Rogersperf-util-y += fncache.o
68e467705aSIan Rogersperf-util-y += machine.o
69e467705aSIan Rogersperf-util-y += map.o
70e467705aSIan Rogersperf-util-y += maps.o
71e467705aSIan Rogersperf-util-y += pstack.o
72e467705aSIan Rogersperf-util-y += session.o
73564e5cbcSIan Rogersperf-util-y += tool.o
74dc6d2bc2SIan Rogersperf-util-y += sample.o
75e467705aSIan Rogersperf-util-y += sample-raw.o
76e467705aSIan Rogersperf-util-y += s390-sample-raw.o
77e467705aSIan Rogersperf-util-y += amd-sample-raw.o
78e467705aSIan Rogersperf-util-$(CONFIG_TRACE) += syscalltbl.o
79e467705aSIan Rogersperf-util-y += ordered-events.o
80e467705aSIan Rogersperf-util-y += namespaces.o
81e467705aSIan Rogersperf-util-y += comm.o
82e467705aSIan Rogersperf-util-y += thread.o
83e467705aSIan Rogersperf-util-y += threads.o
84e467705aSIan Rogersperf-util-y += thread_map.o
85e467705aSIan Rogersperf-util-y += parse-events-flex.o
86e467705aSIan Rogersperf-util-y += parse-events-bison.o
87e467705aSIan Rogersperf-util-y += pmu.o
88e467705aSIan Rogersperf-util-y += pmus.o
89e467705aSIan Rogersperf-util-y += pmu-flex.o
90e467705aSIan Rogersperf-util-y += pmu-bison.o
9128917cb1SIan Rogersperf-util-y += drm_pmu.o
924810b761SIan Rogersperf-util-y += hwmon_pmu.o
93240505b2SIan Rogersperf-util-y += tool_pmu.o
94d002aab8SIan Rogersperf-util-y += tp_pmu.o
95e467705aSIan Rogersperf-util-y += svghelper.o
96800c93ffSIan Rogersperf-util-y += trace-event-info.o
97e467705aSIan Rogersperf-util-y += trace-event-scripting.o
98e467705aSIan Rogersperf-util-$(CONFIG_LIBTRACEEVENT) += trace-event.o
99e467705aSIan Rogersperf-util-$(CONFIG_LIBTRACEEVENT) += trace-event-parse.o
100e467705aSIan Rogersperf-util-$(CONFIG_LIBTRACEEVENT) += trace-event-read.o
101e467705aSIan Rogersperf-util-y += sort.o
102e467705aSIan Rogersperf-util-y += hist.o
103e467705aSIan Rogersperf-util-y += util.o
104e467705aSIan Rogersperf-util-y += cpumap.o
105e467705aSIan Rogersperf-util-y += affinity.o
106e467705aSIan Rogersperf-util-y += cputopo.o
107e467705aSIan Rogersperf-util-y += cgroup.o
108e467705aSIan Rogersperf-util-y += target.o
109e467705aSIan Rogersperf-util-y += rblist.o
110e467705aSIan Rogersperf-util-y += intlist.o
111e467705aSIan Rogersperf-util-y += vdso.o
112e467705aSIan Rogersperf-util-y += counts.o
113e467705aSIan Rogersperf-util-y += stat.o
114e467705aSIan Rogersperf-util-y += stat-shadow.o
115e467705aSIan Rogersperf-util-y += stat-display.o
116e467705aSIan Rogersperf-util-y += perf_api_probe.o
117e467705aSIan Rogersperf-util-y += record.o
118e467705aSIan Rogersperf-util-y += srcline.o
119e467705aSIan Rogersperf-util-y += srccode.o
120e467705aSIan Rogersperf-util-y += synthetic-events.o
121e467705aSIan Rogersperf-util-y += data.o
122e467705aSIan Rogersperf-util-y += tsc.o
123e467705aSIan Rogersperf-util-y += cloexec.o
124e467705aSIan Rogersperf-util-y += call-path.o
125e467705aSIan Rogersperf-util-y += rwsem.o
126e467705aSIan Rogersperf-util-y += thread-stack.o
127e467705aSIan Rogersperf-util-y += spark.o
128e467705aSIan Rogersperf-util-y += topdown.o
129e467705aSIan Rogersperf-util-y += iostat.o
130e467705aSIan Rogersperf-util-y += stream.o
1313f188942SIan Rogersperf-util-y += kvm-stat.o
1321a12ed09SIan Rogersperf-util-y += lock-contention.o
133754187adSIan Rogersperf-util-y += auxtrace.o
134e7bb49e3SIan Rogersperf-util-y += intel-pt-decoder/
135754187adSIan Rogersperf-util-y += intel-pt.o
136754187adSIan Rogersperf-util-y += intel-bts.o
137754187adSIan Rogersperf-util-y += arm-spe.o
138754187adSIan Rogersperf-util-y += arm-spe-decoder/
139754187adSIan Rogersperf-util-y += hisi-ptt.o
140754187adSIan Rogersperf-util-y += hisi-ptt-decoder/
141754187adSIan Rogersperf-util-y += s390-cpumsf.o
142754187adSIan Rogersperf-util-y += powerpc-vpadtl.o
143440a23b3SMathieu Poirier
144440a23b3SMathieu Poirierifdef CONFIG_LIBOPENCSD
145754187adSIan Rogersperf-util-y += cs-etm.o
146754187adSIan Rogersperf-util-y += cs-etm-decoder/
147440a23b3SMathieu Poirierendif
148754187adSIan Rogersperf-util-y += cs-etm-base.o
149440a23b3SMathieu Poirier
150e467705aSIan Rogersperf-util-y += parse-branch-options.o
151e467705aSIan Rogersperf-util-y += dump-insn.o
152e467705aSIan Rogersperf-util-y += parse-regs-options.o
153e467705aSIan Rogersperf-util-y += parse-sublevel-options.o
154e467705aSIan Rogersperf-util-y += term.o
155e467705aSIan Rogersperf-util-y += help-unknown-cmd.o
156e467705aSIan Rogersperf-util-y += dlfilter.o
157e467705aSIan Rogersperf-util-y += mem-events.o
158e467705aSIan Rogersperf-util-y += mem-info.o
159e467705aSIan Rogersperf-util-y += vsprintf.o
160e467705aSIan Rogersperf-util-y += units.o
161e467705aSIan Rogersperf-util-y += time-utils.o
162e467705aSIan Rogersperf-util-y += expr-flex.o
163e467705aSIan Rogersperf-util-y += expr-bison.o
164e467705aSIan Rogersperf-util-y += expr.o
165e467705aSIan Rogersperf-util-y += branch.o
166e467705aSIan Rogersperf-util-y += mem2node.o
167e467705aSIan Rogersperf-util-y += clockid.o
168e467705aSIan Rogersperf-util-y += list_sort.o
169e467705aSIan Rogersperf-util-y += mutex.o
170e467705aSIan Rogersperf-util-y += sharded_mutex.o
171eb493c28SIan Rogersperf-util-y += intel-tpebs.o
1729352aabaSJiri Olsa
173e467705aSIan Rogersperf-util-$(CONFIG_LIBBPF) += bpf_map.o
174e467705aSIan Rogersperf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter.o
175e467705aSIan Rogersperf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter_cgroup.o
176e467705aSIan Rogersperf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_ftrace.o
177e467705aSIan Rogersperf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_off_cpu.o
178e467705aSIan Rogersperf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter.o
179e467705aSIan Rogersperf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter-flex.o
180e467705aSIan Rogersperf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter-bison.o
181dcf90042SArnaldo Carvalho de Meloperf-util-$(CONFIG_PERF_BPF_SKEL) += btf.o
18216cad1d3SNamhyung Kim
1831bec43f5SNamhyung Kimifeq ($(CONFIG_TRACE),y)
1841bec43f5SNamhyung Kim  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-trace-summary.o
185f6109fb6SNamhyung Kim  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_trace_augment.o
1861bec43f5SNamhyung Kimendif
1871bec43f5SNamhyung Kim
18816cad1d3SNamhyung Kimifeq ($(CONFIG_LIBTRACEEVENT),y)
189e467705aSIan Rogers  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_lock_contention.o
19016cad1d3SNamhyung Kimendif
191378ef0f5SIan Rogers
192378ef0f5SIan Rogersifeq ($(CONFIG_LIBTRACEEVENT),y)
193e467705aSIan Rogers  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_kwork.o
194e467705aSIan Rogers  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_kwork_top.o
195378ef0f5SIan Rogersendif
196378ef0f5SIan Rogers
197e467705aSIan Rogersperf-util-$(CONFIG_LIBELF) += symbol-elf.o
198e467705aSIan Rogersperf-util-$(CONFIG_LIBELF) += probe-file.o
199e467705aSIan Rogersperf-util-$(CONFIG_LIBELF) += probe-event.o
200709e6791SJiri Olsa
201ad1237c3SJiri Olsaifdef CONFIG_LIBBPF_DYNAMIC
202ad1237c3SJiri Olsa  hashmap := 1
203ad1237c3SJiri Olsaendif
204eee19501SIan Rogersifndef CONFIG_LIBBPF
205ad1237c3SJiri Olsa  hashmap := 1
206ad1237c3SJiri Olsaendif
207ad1237c3SJiri Olsa
208ad1237c3SJiri Olsaifdef hashmap
209e467705aSIan Rogersperf-util-y += hashmap.o
210eee19501SIan Rogersendif
211eee19501SIan Rogers
212709e6791SJiri Olsaifndef CONFIG_LIBELF
213e467705aSIan Rogersperf-util-y += symbol-minimal.o
214709e6791SJiri Olsaendif
215709e6791SJiri Olsa
21686bcdb5aSArnaldo Carvalho de Meloifndef CONFIG_SETNS
217e467705aSIan Rogersperf-util-y += setns.o
21886bcdb5aSArnaldo Carvalho de Meloendif
21986bcdb5aSArnaldo Carvalho de Melo
2205455d89bSIan Rogersperf-util-$(CONFIG_LIBDW) += probe-finder.o
2215455d89bSIan Rogersperf-util-$(CONFIG_LIBDW) += dwarf-aux.o
2225455d89bSIan Rogersperf-util-$(CONFIG_LIBDW) += dwarf-regs.o
223d4a0c4f2SIan Rogersperf-util-$(CONFIG_LIBDW) += dwarf-regs-csky.o
224285b523cSIan Rogersperf-util-$(CONFIG_LIBDW) += dwarf-regs-powerpc.o
225bf4e799aSIan Rogersperf-util-$(CONFIG_LIBDW) += dwarf-regs-x86.o
2265455d89bSIan Rogersperf-util-$(CONFIG_LIBDW) += debuginfo.o
2275455d89bSIan Rogersperf-util-$(CONFIG_LIBDW) += annotate-data.o
22888c51002SIan Rogersperf-util-$(CONFIG_LIBDW) += libdw.o
2298379fce4SJiri Olsa
230e467705aSIan Rogersperf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
231e467705aSIan Rogersperf-util-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
232e467705aSIan Rogersperf-util-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
233e467705aSIan Rogersperf-util-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
234e467705aSIan Rogersperf-util-$(CONFIG_LIBUNWIND_AARCH64)  += libunwind/arm64.o
235b2e45c32SJiri Olsa
236378ef0f5SIan Rogersifeq ($(CONFIG_LIBTRACEEVENT),y)
237e467705aSIan Rogers  perf-util-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
238378ef0f5SIan Rogersendif
239378ef0f5SIan Rogers
240e467705aSIan Rogersperf-util-y += data-convert-json.o
241edbe9817SJiri Olsa
242e467705aSIan Rogersperf-util-y += scripting-engines/
243c7355f84SJiri Olsa
244e467705aSIan Rogersperf-util-$(CONFIG_ZLIB) += zlib.o
245e467705aSIan Rogersperf-util-$(CONFIG_LZMA) += lzma.o
246e467705aSIan Rogersperf-util-$(CONFIG_ZSTD) += zstd.o
247f24c1d75SAlexey Budankov
248e25ebda7SIan Rogersperf-util-y += cap.o
249c22e150eSIgor Lubashev
250e467705aSIan Rogersperf-util-$(CONFIG_CXX_DEMANGLE) += demangle-cxx.o
251e467705aSIan Rogersperf-util-y += demangle-ocaml.o
252e467705aSIan Rogersperf-util-y += demangle-java.o
253e20848c3SIan Rogersperf-util-y += demangle-rust-v0.o
254c3f8644cSSteinar H. Gundersonperf-util-$(CONFIG_LIBLLVM) += llvm-c-helpers.o
25546dad054SArnaldo Carvalho de Melo
256e20848c3SIan RogersCFLAGS_demangle-rust-v0.o += -Wno-shadow -Wno-declaration-after-statement \
257e20848c3SIan Rogers    -Wno-switch-default -Wno-switch-enum -Wno-missing-field-initializers
258e20848c3SIan Rogers
259e12b202fSJiri Olsaifdef CONFIG_JITDUMP
260e467705aSIan Rogersperf-util-$(CONFIG_LIBELF) += jitdump.o
261e467705aSIan Rogersperf-util-$(CONFIG_LIBELF) += genelf.o
2625455d89bSIan Rogersperf-util-$(CONFIG_LIBDW) += genelf_debug.o
26346dad054SArnaldo Carvalho de Meloendif
2643bc3374cSJiri Olsa
265e467705aSIan Rogersperf-util-y += perf-hooks.o
266a074865eSWang Nan
267e467705aSIan Rogersperf-util-$(CONFIG_LIBBPF) += bpf-event.o
268e467705aSIan Rogersperf-util-$(CONFIG_LIBBPF) += bpf-utils.o
26945178a92SSong Liu
270e467705aSIan Rogersperf-util-$(CONFIG_LIBPFM4) += pfm.o
27170943490SStephane Eranian
2729352aabaSJiri OlsaCFLAGS_config.o   += -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
2731b16fffaSArnaldo Carvalho de Melo
274598b7c69SStephane Eranian# avoid compiler warnings in 32-bit mode
275598b7c69SStephane EranianCFLAGS_genelf_debug.o  += -Wno-packed
2769352aabaSJiri Olsa
2774b971df9SIan Rogers$(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-flex.h: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
2781999307bSJiri Olsa	$(call rule_mkdir)
2794b971df9SIan Rogers	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/parse-events-flex.c \
2804b971df9SIan Rogers		--header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) $<
2819352aabaSJiri Olsa
282ef9894d9SIan Rogers$(OUTPUT)util/parse-events-bison.c $(OUTPUT)util/parse-events-bison.h: util/parse-events.y
2831999307bSJiri Olsa	$(call rule_mkdir)
2849462e4deSIan Rogers	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) $(BISON_FALLBACK_FLAGS) \
285ef9894d9SIan Rogers		-o $(OUTPUT)util/parse-events-bison.c -p parse_events_
2869352aabaSJiri Olsa
2874b971df9SIan Rogers$(OUTPUT)util/expr-flex.c $(OUTPUT)util/expr-flex.h: util/expr.l $(OUTPUT)util/expr-bison.c
28826226a97SJiri Olsa	$(call rule_mkdir)
2894b971df9SIan Rogers	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/expr-flex.c \
2904b971df9SIan Rogers		--header-file=$(OUTPUT)util/expr-flex.h $(PARSER_DEBUG_FLEX) $<
29126226a97SJiri Olsa
292ef9894d9SIan Rogers$(OUTPUT)util/expr-bison.c $(OUTPUT)util/expr-bison.h: util/expr.y
29307516736SAndi Kleen	$(call rule_mkdir)
2946793672aSDenys Zagorui	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
295ef9894d9SIan Rogers		-o $(OUTPUT)util/expr-bison.c -p expr_
29607516736SAndi Kleen
2974b971df9SIan Rogers$(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-flex.h: util/pmu.l $(OUTPUT)util/pmu-bison.c
2981999307bSJiri Olsa	$(call rule_mkdir)
2994b971df9SIan Rogers	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/pmu-flex.c \
3004b971df9SIan Rogers		--header-file=$(OUTPUT)util/pmu-flex.h $(PARSER_DEBUG_FLEX) $<
3019352aabaSJiri Olsa
302ef9894d9SIan Rogers$(OUTPUT)util/pmu-bison.c $(OUTPUT)util/pmu-bison.h: util/pmu.y
3031999307bSJiri Olsa	$(call rule_mkdir)
3046793672aSDenys Zagorui	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
305ef9894d9SIan Rogers		-o $(OUTPUT)util/pmu-bison.c -p perf_pmu_
3069352aabaSJiri Olsa
307591156f2SNamhyung Kim$(OUTPUT)util/bpf-filter-flex.c $(OUTPUT)util/bpf-filter-flex.h: util/bpf-filter.l $(OUTPUT)util/bpf-filter-bison.c util/bpf-filter.h util/bpf_skel/sample-filter.h
308990a71e9SNamhyung Kim	$(call rule_mkdir)
309990a71e9SNamhyung Kim	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/bpf-filter-flex.c \
310990a71e9SNamhyung Kim		--header-file=$(OUTPUT)util/bpf-filter-flex.h $(PARSER_DEBUG_FLEX) $<
311990a71e9SNamhyung Kim
312591156f2SNamhyung Kim$(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filter.y util/bpf-filter.h util/bpf_skel/sample-filter.h
313990a71e9SNamhyung Kim	$(call rule_mkdir)
314990a71e9SNamhyung Kim	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
315990a71e9SNamhyung Kim		-o $(OUTPUT)util/bpf-filter-bison.c -p perf_bpf_filter_
316990a71e9SNamhyung Kim
31710c775afSIan RogersFLEX_VERSION := $(shell $(FLEX) --version | cut -d' ' -f2)
31810c775afSIan Rogers
31910c775afSIan RogersFLEX_GE_260 := $(call version-ge3,$(FLEX_VERSION),2.6.0)
32010c775afSIan Rogersifeq ($(FLEX_GE_260),1)
32110c775afSIan Rogers  flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function -Wno-misleading-indentation
32210c775afSIan Rogers
32310c775afSIan Rogers  # Some newer clang and gcc version complain about this
32410c775afSIan Rogers  # util/parse-events-bison.c:1317:9: error: variable 'parse_events_nerrs' set but not used [-Werror,-Wunused-but-set-variable]
32510c775afSIan Rogers  #  int yynerrs = 0;
32610c775afSIan Rogers
32710c775afSIan Rogers  flex_flags += -Wno-unused-but-set-variable
32810c775afSIan Rogers
32910c775afSIan Rogers  FLEX_LT_262 := $(call version-lt3,$(FLEX_VERSION),2.6.2)
33010c775afSIan Rogers  ifeq ($(FLEX_LT_262),1)
33110c775afSIan Rogers    flex_flags += -Wno-sign-compare
332304d7a90SIan Rogers  endif
333304d7a90SIan Rogerselse
334304d7a90SIan Rogers  flex_flags := -w
335304d7a90SIan Rogersendif
33610c775afSIan Rogers
337ddc8e4c9SIan Rogers# Some newer clang and gcc version complain about this
338ddc8e4c9SIan Rogers# util/parse-events-bison.c:1317:9: error: variable 'parse_events_nerrs' set but not used [-Werror,-Wunused-but-set-variable]
339ddc8e4c9SIan Rogers#  int yynerrs = 0;
340ddc8e4c9SIan Rogers
341ddc8e4c9SIan Rogersbison_flags := -DYYENABLE_NLS=0 -Wno-unused-but-set-variable
342878460e8SArnaldo Carvalho de Melo
343878460e8SArnaldo Carvalho de Melo# Old clangs don't grok -Wno-unused-but-set-variable, remove it
344878460e8SArnaldo Carvalho de Meloifeq ($(CC_NO_CLANG), 0)
345878460e8SArnaldo Carvalho de Melo  CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')
346878460e8SArnaldo Carvalho de Melo  ifeq ($(call version-lt3,$(CLANG_VERSION),13.0.0),1)
347878460e8SArnaldo Carvalho de Melo    bison_flags := $(subst -Wno-unused-but-set-variable,,$(bison_flags))
348878460e8SArnaldo Carvalho de Melo    flex_flags := $(subst -Wno-unused-but-set-variable,,$(flex_flags))
349878460e8SArnaldo Carvalho de Melo  endif
350878460e8SArnaldo Carvalho de Meloendif
351878460e8SArnaldo Carvalho de Melo
352ddc8e4c9SIan RogersBISON_GE_382 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 382)
353ddc8e4c9SIan Rogersifeq ($(BISON_GE_382),1)
354ddc8e4c9SIan Rogers  bison_flags += -Wno-switch-enum
3551f16fcadSIan Rogerselse
3561f16fcadSIan Rogers  bison_flags += -w
3571f16fcadSIan Rogersendif
35888cc47e2SArnaldo Carvalho de Melo
35988cc47e2SArnaldo Carvalho de MeloBISON_LT_381 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \< 381)
36088cc47e2SArnaldo Carvalho de Meloifeq ($(BISON_LT_381),1)
36188cc47e2SArnaldo Carvalho de Melo  bison_flags += -DYYNOMEM=YYABORT
36288cc47e2SArnaldo Carvalho de Meloendif
36388cc47e2SArnaldo Carvalho de Melo
3643d6dfae8SIan RogersCFLAGS_parse-events-flex.o  += $(flex_flags) -Wno-unused-label
365878460e8SArnaldo Carvalho de MeloCFLAGS_pmu-flex.o           += $(flex_flags)
366878460e8SArnaldo Carvalho de MeloCFLAGS_expr-flex.o          += $(flex_flags)
367878460e8SArnaldo Carvalho de MeloCFLAGS_bpf-filter-flex.o    += $(flex_flags)
368878460e8SArnaldo Carvalho de Melo
3691f16fcadSIan RogersCFLAGS_parse-events-bison.o += $(bison_flags)
3701f16fcadSIan RogersCFLAGS_pmu-bison.o          += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
3711f16fcadSIan RogersCFLAGS_expr-bison.o         += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
372990a71e9SNamhyung KimCFLAGS_bpf-filter-bison.o   += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
3739352aabaSJiri Olsa
3749352aabaSJiri Olsa$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
3759352aabaSJiri Olsa$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
37626226a97SJiri Olsa$(OUTPUT)util/expr.o: $(OUTPUT)util/expr-flex.c $(OUTPUT)util/expr-bison.c
377990a71e9SNamhyung Kim$(OUTPUT)util/bpf-filter.o: $(OUTPUT)util/bpf-filter-flex.c $(OUTPUT)util/bpf-filter-bison.c
3789352aabaSJiri Olsa
379915b0882SArnaldo Carvalho de MeloCFLAGS_bitmap.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
380552eb975SArnaldo Carvalho de MeloCFLAGS_find_bit.o      += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
3819352aabaSJiri OlsaCFLAGS_rbtree.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
3824ddd3274SArnaldo Carvalho de MeloCFLAGS_libstring.o     += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
3839352aabaSJiri OlsaCFLAGS_hweight.o       += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
384d25ed5d9SSoramichi AKIYAMACFLAGS_header.o        += -include $(OUTPUT)PERF-VERSION-FILE
385a29ee6aeSOliver UptonCFLAGS_arm-spe.o       += -I$(srctree)/tools/arch/arm64/include/ -I$(OUTPUT)arch/arm64/include/generated/
3869352aabaSJiri Olsa
3879c10548cSArnaldo Carvalho de Melo$(OUTPUT)util/argv_split.o: ../lib/argv_split.c FORCE
3889c10548cSArnaldo Carvalho de Melo	$(call rule_mkdir)
3899c10548cSArnaldo Carvalho de Melo	$(call if_changed_dep,cc_o_c)
3909c10548cSArnaldo Carvalho de Melo
391915b0882SArnaldo Carvalho de Melo$(OUTPUT)util/bitmap.o: ../lib/bitmap.c FORCE
392915b0882SArnaldo Carvalho de Melo	$(call rule_mkdir)
393915b0882SArnaldo Carvalho de Melo	$(call if_changed_dep,cc_o_c)
394915b0882SArnaldo Carvalho de Melo
3953052ba56SArnaldo Carvalho de Melo$(OUTPUT)util/ctype.o: ../lib/ctype.c FORCE
3963052ba56SArnaldo Carvalho de Melo	$(call rule_mkdir)
3973052ba56SArnaldo Carvalho de Melo	$(call if_changed_dep,cc_o_c)
3983052ba56SArnaldo Carvalho de Melo
399552eb975SArnaldo Carvalho de Melo$(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE
4001999307bSJiri Olsa	$(call rule_mkdir)
4019352aabaSJiri Olsa	$(call if_changed_dep,cc_o_c)
4029352aabaSJiri Olsa
4033f735377SArnaldo Carvalho de Melo$(OUTPUT)util/rbtree.o: ../lib/rbtree.c FORCE
4041999307bSJiri Olsa	$(call rule_mkdir)
4059352aabaSJiri Olsa	$(call if_changed_dep,cc_o_c)
4069352aabaSJiri Olsa
4074ddd3274SArnaldo Carvalho de Melo$(OUTPUT)util/libstring.o: ../lib/string.c FORCE
4084ddd3274SArnaldo Carvalho de Melo	$(call rule_mkdir)
4094ddd3274SArnaldo Carvalho de Melo	$(call if_changed_dep,cc_o_c)
4104ddd3274SArnaldo Carvalho de Melo
4110aefc359SArnaldo Carvalho de Melo$(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
4121999307bSJiri Olsa	$(call rule_mkdir)
4139352aabaSJiri Olsa	$(call if_changed_dep,cc_o_c)
414d0761e37SArnaldo Carvalho de Melo
415d0761e37SArnaldo Carvalho de Melo$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
416d0761e37SArnaldo Carvalho de Melo	$(call rule_mkdir)
417d0761e37SArnaldo Carvalho de Melo	$(call if_changed_dep,cc_o_c)
41892ec3cc9SIan Rogers
41992ec3cc9SIan Rogers$(OUTPUT)util/list_sort.o: ../lib/list_sort.c FORCE
42092ec3cc9SIan Rogers	$(call rule_mkdir)
42192ec3cc9SIan Rogers	$(call if_changed_dep,cc_o_c)
42261ff60aaSIan Rogers
42361ff60aaSIan Rogersifdef SHELLCHECK
42461ff60aaSIan Rogers  SHELL_TESTS := generate-cmdlist.sh
425ef238109SIan Rogers  SHELL_TEST_LOGS := $(SHELL_TESTS:%=%.shellcheck_log)
42661ff60aaSIan Rogerselse
42761ff60aaSIan Rogers  SHELL_TESTS :=
428ef238109SIan Rogers  SHELL_TEST_LOGS :=
42961ff60aaSIan Rogersendif
43061ff60aaSIan Rogers
43161ff60aaSIan Rogers$(OUTPUT)%.shellcheck_log: %
43261ff60aaSIan Rogers	$(call rule_mkdir)
433114339eeSCollin Funk	$(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)
43461ff60aaSIan Rogers
435ef238109SIan Rogersperf-util-y += $(SHELL_TEST_LOGS)
436168910d0SIan Rogers
437168910d0SIan RogersPY_TESTS := setup.py
438168910d0SIan Rogersifdef MYPY
439168910d0SIan Rogers  MYPY_TEST_LOGS := $(PY_TESTS:%=%.mypy_log)
440168910d0SIan Rogerselse
441168910d0SIan Rogers  MYPY_TEST_LOGS :=
442168910d0SIan Rogersendif
443168910d0SIan Rogers
444168910d0SIan Rogers$(OUTPUT)%.mypy_log: %
445168910d0SIan Rogers	$(call rule_mkdir)
446168910d0SIan Rogers	$(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
447168910d0SIan Rogers
448168910d0SIan Rogersperf-util-y += $(MYPY_TEST_LOGS)
4498a54784eSIan Rogers
4508a54784eSIan Rogersifdef PYLINT
4518a54784eSIan Rogers  PYLINT_TEST_LOGS := $(PY_TESTS:%=%.pylint_log)
4528a54784eSIan Rogerselse
4538a54784eSIan Rogers  PYLINT_TEST_LOGS :=
4548a54784eSIan Rogersendif
4558a54784eSIan Rogers
4568a54784eSIan Rogers$(OUTPUT)%.pylint_log: %
4578a54784eSIan Rogers	$(call rule_mkdir)
4588a54784eSIan Rogers	$(Q)$(call echo-cmd,test)pylint "$<" > $@ || (cat $@ && rm $@ && false)
4598a54784eSIan Rogers
4608a54784eSIan Rogersperf-util-y += $(PYLINT_TEST_LOGS)
461