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