1# SPDX-License-Identifier: GPL-2.0-only 2 3ifeq ($(src-perf),) 4src-perf := $(srctree)/tools/perf 5endif 6 7ifeq ($(obj-perf),) 8obj-perf := $(OUTPUT) 9endif 10 11ifneq ($(obj-perf),) 12obj-perf := $(abspath $(obj-perf))/ 13endif 14 15$(shell printf "" > $(OUTPUT).config-detected) 16detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) 17detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) 18 19CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS)) 20HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS)) 21 22# Enabled Wthread-safety analysis for clang builds. 23ifeq ($(CC_NO_CLANG), 0) 24 CFLAGS += -Wthread-safety 25endif 26 27include $(srctree)/tools/scripts/Makefile.arch 28 29$(call detected_var,SRCARCH) 30 31ifneq ($(NO_SYSCALL_TABLE),1) 32 NO_SYSCALL_TABLE := 1 33 34 ifeq ($(SRCARCH),x86) 35 ifeq (${IS_64_BIT}, 1) 36 NO_SYSCALL_TABLE := 0 37 endif 38 else 39 ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390 mips loongarch)) 40 NO_SYSCALL_TABLE := 0 41 endif 42 endif 43 44 ifneq ($(NO_SYSCALL_TABLE),1) 45 CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT 46 endif 47endif 48 49# Additional ARCH settings for ppc 50ifeq ($(SRCARCH),powerpc) 51 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated 52 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64 53endif 54 55# Additional ARCH settings for x86 56ifeq ($(SRCARCH),x86) 57 $(call detected,CONFIG_X86) 58 ifeq (${IS_64_BIT}, 1) 59 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated 60 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 61 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma 62 $(call detected,CONFIG_X86_64) 63 else 64 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind 65 endif 66endif 67 68ifeq ($(SRCARCH),arm) 69 LIBUNWIND_LIBS = -lunwind -lunwind-arm 70endif 71 72ifeq ($(SRCARCH),arm64) 73 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated 74 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 75endif 76 77ifeq ($(SRCARCH),loongarch) 78 CFLAGS += -I$(OUTPUT)arch/loongarch/include/generated 79 LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64 80endif 81 82ifeq ($(ARCH),s390) 83 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated 84endif 85 86ifeq ($(ARCH),mips) 87 CFLAGS += -I$(OUTPUT)arch/mips/include/generated 88 LIBUNWIND_LIBS = -lunwind -lunwind-mips 89endif 90 91# So far there's only x86 and arm libdw unwind support merged in perf. 92# Disable it on all other architectures in case libdw unwind 93# support is detected in system. Add supported architectures 94# to the check. 95ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv loongarch)) 96 NO_LIBDW_DWARF_UNWIND := 1 97endif 98 99ifeq ($(LIBUNWIND_LIBS),) 100 NO_LIBUNWIND := 1 101endif 102# 103# For linking with debug library, run like: 104# 105# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ 106# 107 108libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code)) 109define libunwind_arch_set_flags_code 110 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include 111 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib 112endef 113 114ifdef LIBUNWIND_DIR 115 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include 116 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib 117 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 loongarch 118 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch))) 119endif 120 121# Set per-feature check compilation flags 122FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) 123FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 124FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) 125FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 126 127FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm 128FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64 129FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86 130FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64 131 132FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto 133 134ifdef CSINCLUDES 135 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES) 136endif 137OPENCSDLIBS := -lopencsd_c_api -lopencsd 138ifeq ($(findstring -static,${LDFLAGS}),-static) 139 OPENCSDLIBS += -lstdc++ 140endif 141ifdef CSLIBS 142 LIBOPENCSD_LDFLAGS := -L$(CSLIBS) 143endif 144FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS) 145FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS) 146 147# for linking with debug library, run like: 148# make DEBUG=1 LIBDW_DIR=/opt/libdw/ 149ifdef LIBDW_DIR 150 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include 151 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib 152endif 153DWARFLIBS := -ldw 154ifeq ($(findstring -static,${LDFLAGS}),-static) 155 DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2 156endif 157FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) 158FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS) 159 160# for linking with debug library, run like: 161# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ 162ifdef LIBBABELTRACE_DIR 163 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include 164 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib 165endif 166FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS) 167FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf 168 169ifdef LIBZSTD_DIR 170 LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib 171 LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib 172endif 173FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS) 174FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS) 175 176FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi 177# include ARCH specific config 178-include $(src-perf)/arch/$(SRCARCH)/Makefile 179 180ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 181 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 182endif 183 184include $(srctree)/tools/scripts/utilities.mak 185 186ifeq ($(call get-executable,$(FLEX)),) 187 dummy := $(error Error: $(FLEX) is missing on this system, please install it) 188endif 189 190ifeq ($(call get-executable,$(BISON)),) 191 dummy := $(error Error: $(BISON) is missing on this system, please install it) 192endif 193 194ifneq ($(NO_LIBTRACEEVENT),1) 195 ifeq ($(call get-executable,$(PKG_CONFIG)),) 196 dummy := $(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it) 197 endif 198endif 199 200ifneq ($(OUTPUT),) 201 ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1) 202 BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)= 203 endif 204endif 205 206# Treat warnings as errors unless directed not to 207ifneq ($(WERROR),0) 208 CORE_CFLAGS += -Werror 209 CXXFLAGS += -Werror 210 HOSTCFLAGS += -Werror 211endif 212 213ifndef DEBUG 214 DEBUG := 0 215endif 216 217ifeq ($(DEBUG),0) 218CORE_CFLAGS += -DNDEBUG=1 219ifeq ($(CC_NO_CLANG), 0) 220 CORE_CFLAGS += -O3 221else 222 CORE_CFLAGS += -O6 223endif 224else 225 CORE_CFLAGS += -g 226 CXXFLAGS += -g 227endif 228 229ifdef PARSER_DEBUG 230 PARSER_DEBUG_BISON := -t 231 PARSER_DEBUG_FLEX := -d 232 CFLAGS += -DPARSER_DEBUG 233 $(call detected_var,PARSER_DEBUG_BISON) 234 $(call detected_var,PARSER_DEBUG_FLEX) 235endif 236 237ifdef LTO 238 CORE_CFLAGS += -flto 239 CXXFLAGS += -flto 240endif 241 242# Try different combinations to accommodate systems that only have 243# python[2][3]-config in weird combinations in the following order of 244# priority from lowest to highest: 245# * python2-config as per pep-0394. 246# * python-config 247# * python3-config 248# * $(PYTHON)-config (If PYTHON is user supplied but PYTHON_CONFIG isn't) 249# 250PYTHON_AUTO := python-config 251PYTHON_AUTO := $(if $(call get-executable,python2-config),python2-config,$(PYTHON_AUTO)) 252PYTHON_AUTO := $(if $(call get-executable,python-config),python-config,$(PYTHON_AUTO)) 253PYTHON_AUTO := $(if $(call get-executable,python3-config),python3-config,$(PYTHON_AUTO)) 254 255# If PYTHON is defined but PYTHON_CONFIG isn't, then take $(PYTHON)-config as if it was the user 256# supplied value for PYTHON_CONFIG. Because it's "user supplied", error out if it doesn't exist. 257ifdef PYTHON 258 ifndef PYTHON_CONFIG 259 PYTHON_CONFIG_AUTO := $(call get-executable,$(PYTHON)-config) 260 PYTHON_CONFIG := $(if $(PYTHON_CONFIG_AUTO),$(PYTHON_CONFIG_AUTO),\ 261 $(call $(error $(PYTHON)-config not found))) 262 endif 263endif 264 265# Select either auto detected python and python-config or use user supplied values if they are 266# defined. get-executable-or-default fails with an error if the first argument is supplied but 267# doesn't exist. 268override PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO)) 269override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_CONFIG))) 270 271grep-libs = $(filter -l%,$(1)) 272strip-libs = $(filter-out -l%,$(1)) 273 274PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) 275 276# Python 3.8 changed the output of `python-config --ldflags` to not include the 277# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for 278# libpython fails if that flag is not included in LDFLAGS 279ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0) 280 PYTHON_CONFIG_LDFLAGS := --ldflags --embed 281else 282 PYTHON_CONFIG_LDFLAGS := --ldflags 283endif 284 285ifdef PYTHON_CONFIG 286 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null) 287 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) 288 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil 289 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) 290 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) 291 ifeq ($(CC_NO_CLANG), 0) 292 PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS)) 293 endif 294endif 295 296FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS) 297FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) 298 299FEATURE_CHECK_LDFLAGS-libaio = -lrt 300 301FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl 302FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl 303 304CORE_CFLAGS += -fno-omit-frame-pointer 305CORE_CFLAGS += -Wall 306CORE_CFLAGS += -Wextra 307CORE_CFLAGS += -std=gnu11 308 309CXXFLAGS += -std=gnu++17 -fno-exceptions -fno-rtti 310CXXFLAGS += -Wall 311CXXFLAGS += -Wextra 312CXXFLAGS += -fno-omit-frame-pointer 313 314HOSTCFLAGS += -Wall 315HOSTCFLAGS += -Wextra 316 317# Enforce a non-executable stack, as we may regress (again) in the future by 318# adding assembler files missing the .GNU-stack linker note. 319LDFLAGS += -Wl,-z,noexecstack 320 321EXTLIBS = -lpthread -lrt -lm -ldl 322 323ifneq ($(TCMALLOC),) 324 CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free 325 EXTLIBS += -ltcmalloc 326endif 327 328ifeq ($(FEATURES_DUMP),) 329# We will display at the end of this Makefile.config, using $(call feature_display_entries) 330# As we may retry some feature detection here, see the disassembler-four-args case, for instance 331 FEATURE_DISPLAY_DEFERRED := 1 332include $(srctree)/tools/build/Makefile.feature 333else 334include $(FEATURES_DUMP) 335endif 336 337ifeq ($(feature-stackprotector-all), 1) 338 CORE_CFLAGS += -fstack-protector-all 339endif 340 341ifeq ($(DEBUG),0) 342 ifeq ($(feature-fortify-source), 1) 343 CORE_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 344 endif 345endif 346 347INC_FLAGS += -I$(src-perf)/util/include 348INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include 349INC_FLAGS += -I$(srctree)/tools/include/ 350INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi 351INC_FLAGS += -I$(srctree)/tools/include/uapi 352INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/ 353INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/ 354 355# $(obj-perf) for generated common-cmds.h 356# $(obj-perf)/util for generated bison/flex headers 357ifneq ($(OUTPUT),) 358INC_FLAGS += -I$(obj-perf)/util 359INC_FLAGS += -I$(obj-perf) 360endif 361 362INC_FLAGS += -I$(src-perf)/util 363INC_FLAGS += -I$(src-perf) 364 365CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 366 367CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS) 368CXXFLAGS += $(INC_FLAGS) 369 370LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS) 371 372ifeq ($(feature-pthread-attr-setaffinity-np), 1) 373 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP 374endif 375 376ifeq ($(feature-pthread-barrier), 1) 377 CFLAGS += -DHAVE_PTHREAD_BARRIER 378endif 379 380ifndef NO_BIONIC 381 $(call feature_check,bionic) 382 ifeq ($(feature-bionic), 1) 383 BIONIC := 1 384 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE 385 CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE 386 EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) 387 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) 388 endif 389endif 390 391ifeq ($(feature-eventfd), 1) 392 CFLAGS += -DHAVE_EVENTFD_SUPPORT 393endif 394 395ifeq ($(feature-get_current_dir_name), 1) 396 CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME 397endif 398 399ifeq ($(feature-gettid), 1) 400 CFLAGS += -DHAVE_GETTID 401endif 402 403ifeq ($(feature-file-handle), 1) 404 CFLAGS += -DHAVE_FILE_HANDLE 405endif 406 407ifdef NO_LIBELF 408 NO_DWARF := 1 409 NO_LIBUNWIND := 1 410 NO_LIBDW_DWARF_UNWIND := 1 411 NO_LIBBPF := 1 412 NO_JVMTI := 1 413else 414 ifeq ($(feature-libelf), 0) 415 ifeq ($(feature-glibc), 1) 416 LIBC_SUPPORT := 1 417 endif 418 ifeq ($(BIONIC),1) 419 LIBC_SUPPORT := 1 420 endif 421 ifeq ($(LIBC_SUPPORT),1) 422 msg := $(error ERROR: No libelf found. Disables 'probe' tool, jvmti and BPF support. Please install libelf-dev, libelf-devel, elfutils-libelf-devel or build with NO_LIBELF=1.) 423 else 424 ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),) 425 ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0) 426 msg := $(error No libasan found, please install libasan); 427 endif 428 endif 429 430 ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),) 431 ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0) 432 msg := $(error No libubsan found, please install libubsan); 433 endif 434 endif 435 436 ifneq ($(filter s% -static%,$(LDFLAGS),),) 437 msg := $(error No static glibc found, please install glibc-static); 438 else 439 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]); 440 endif 441 endif 442 else 443 ifndef NO_LIBDW_DWARF_UNWIND 444 ifneq ($(feature-libdw-dwarf-unwind),1) 445 NO_LIBDW_DWARF_UNWIND := 1 446 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR); 447 endif 448 endif 449 ifneq ($(feature-dwarf), 1) 450 ifndef NO_DWARF 451 msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); 452 NO_DWARF := 1 453 endif 454 else 455 ifneq ($(feature-dwarf_getlocations), 1) 456 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157); 457 else 458 CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT 459 endif # dwarf_getlocations 460 ifneq ($(feature-dwarf_getcfi), 1) 461 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.142); 462 else 463 CFLAGS += -DHAVE_DWARF_CFI_SUPPORT 464 endif # dwarf_getcfi 465 endif # Dwarf support 466 endif # libelf support 467endif # NO_LIBELF 468 469ifeq ($(feature-libaio), 1) 470 ifndef NO_AIO 471 CFLAGS += -DHAVE_AIO_SUPPORT 472 endif 473endif 474 475ifdef NO_DWARF 476 NO_LIBDW_DWARF_UNWIND := 1 477endif 478 479ifeq ($(feature-scandirat), 1) 480 CFLAGS += -DHAVE_SCANDIRAT_SUPPORT 481endif 482 483ifeq ($(feature-sched_getcpu), 1) 484 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT 485endif 486 487ifeq ($(feature-setns), 1) 488 CFLAGS += -DHAVE_SETNS_SUPPORT 489 $(call detected,CONFIG_SETNS) 490endif 491 492ifdef CORESIGHT 493 $(call feature_check,libopencsd) 494 ifeq ($(feature-libopencsd), 1) 495 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS) 496 ifeq ($(feature-reallocarray), 0) 497 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY 498 endif 499 LDFLAGS += $(LIBOPENCSD_LDFLAGS) 500 EXTLIBS += $(OPENCSDLIBS) 501 $(call detected,CONFIG_LIBOPENCSD) 502 ifdef CSTRACE_RAW 503 CFLAGS += -DCS_DEBUG_RAW 504 ifeq (${CSTRACE_RAW}, packed) 505 CFLAGS += -DCS_RAW_PACKED 506 endif 507 endif 508 else 509 dummy := $(error Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1) 510 endif 511endif 512 513ifndef NO_ZLIB 514 ifeq ($(feature-zlib), 1) 515 CFLAGS += -DHAVE_ZLIB_SUPPORT 516 EXTLIBS += -lz 517 $(call detected,CONFIG_ZLIB) 518 else 519 NO_ZLIB := 1 520 endif 521endif 522 523ifndef NO_LIBELF 524 CFLAGS += -DHAVE_LIBELF_SUPPORT 525 EXTLIBS += -lelf 526 $(call detected,CONFIG_LIBELF) 527 528 ifeq ($(feature-libelf-getphdrnum), 1) 529 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT 530 endif 531 532 ifeq ($(feature-libelf-gelf_getnote), 1) 533 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT 534 else 535 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled); 536 endif 537 538 ifeq ($(feature-libelf-getshdrstrndx), 1) 539 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT 540 endif 541 542 ifndef NO_LIBDEBUGINFOD 543 $(call feature_check,libdebuginfod) 544 ifeq ($(feature-libdebuginfod), 1) 545 CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT 546 EXTLIBS += -ldebuginfod 547 endif 548 endif 549 550 ifndef NO_DWARF 551 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) 552 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled); 553 NO_DWARF := 1 554 else 555 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) 556 LDFLAGS += $(LIBDW_LDFLAGS) 557 EXTLIBS += ${DWARFLIBS} 558 $(call detected,CONFIG_DWARF) 559 endif # PERF_HAVE_DWARF_REGS 560 endif # NO_DWARF 561 562 ifndef NO_LIBBPF 563 ifeq ($(feature-bpf), 1) 564 # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status 565 $(call feature_check,libbpf) 566 567 ifdef LIBBPF_DYNAMIC 568 ifeq ($(feature-libbpf), 1) 569 EXTLIBS += -lbpf 570 CFLAGS += -DHAVE_LIBBPF_SUPPORT 571 $(call detected,CONFIG_LIBBPF) 572 $(call detected,CONFIG_LIBBPF_DYNAMIC) 573 else 574 dummy := $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel); 575 endif 576 else 577 ifeq ($(NO_ZLIB), 1) 578 dummy := $(warning Warning: Statically building libbpf not possible as zlib is missing) 579 NO_LIBBPF := 1 580 else 581 # Libbpf will be built as a static library from tools/lib/bpf. 582 LIBBPF_STATIC := 1 583 $(call detected,CONFIG_LIBBPF) 584 CFLAGS += -DHAVE_LIBBPF_SUPPORT 585 endif 586 endif 587 endif 588 endif # NO_LIBBPF 589endif # NO_LIBELF 590 591ifndef NO_SDT 592 ifneq ($(feature-sdt), 1) 593 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev); 594 NO_SDT := 1; 595 else 596 CFLAGS += -DHAVE_SDT_EVENT 597 $(call detected,CONFIG_SDT_EVENT) 598 endif 599endif 600 601ifdef PERF_HAVE_JITDUMP 602 ifndef NO_LIBELF 603 $(call detected,CONFIG_JITDUMP) 604 CFLAGS += -DHAVE_JITDUMP 605 endif 606endif 607 608ifeq ($(SRCARCH),powerpc) 609 ifndef NO_DWARF 610 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX 611 endif 612endif 613 614ifndef NO_LIBUNWIND 615 have_libunwind := 616 617 $(call feature_check,libunwind-x86) 618 ifeq ($(feature-libunwind-x86), 1) 619 $(call detected,CONFIG_LIBUNWIND_X86) 620 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT 621 LDFLAGS += -lunwind-x86 622 EXTLIBS_LIBUNWIND += -lunwind-x86 623 have_libunwind = 1 624 endif 625 626 $(call feature_check,libunwind-aarch64) 627 ifeq ($(feature-libunwind-aarch64), 1) 628 $(call detected,CONFIG_LIBUNWIND_AARCH64) 629 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT 630 LDFLAGS += -lunwind-aarch64 631 EXTLIBS_LIBUNWIND += -lunwind-aarch64 632 have_libunwind = 1 633 $(call feature_check,libunwind-debug-frame-aarch64) 634 ifneq ($(feature-libunwind-debug-frame-aarch64), 1) 635 msg := $(warning No debug_frame support found in libunwind-aarch64); 636 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64 637 endif 638 endif 639 640 ifneq ($(feature-libunwind), 1) 641 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR); 642 NO_LOCAL_LIBUNWIND := 1 643 else 644 have_libunwind := 1 645 $(call detected,CONFIG_LOCAL_LIBUNWIND) 646 endif 647 648 ifneq ($(have_libunwind), 1) 649 NO_LIBUNWIND := 1 650 endif 651else 652 NO_LOCAL_LIBUNWIND := 1 653endif 654 655ifndef NO_LIBBPF 656 ifneq ($(feature-bpf), 1) 657 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.) 658 NO_LIBBPF := 1 659 endif 660endif 661 662ifndef BUILD_BPF_SKEL 663 # BPF skeletons control a large number of perf features, by default 664 # they are enabled. 665 BUILD_BPF_SKEL := 1 666endif 667 668ifeq ($(BUILD_BPF_SKEL),1) 669 ifeq ($(filter -DHAVE_LIBELF_SUPPORT, $(CFLAGS)),) 670 dummy := $(warning Warning: Disabled BPF skeletons as libelf is required by bpftool) 671 BUILD_BPF_SKEL := 0 672 else ifeq ($(filter -DHAVE_ZLIB_SUPPORT, $(CFLAGS)),) 673 dummy := $(warning Warning: Disabled BPF skeletons as zlib is required by bpftool) 674 BUILD_BPF_SKEL := 0 675 else ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),) 676 dummy := $(warning Warning: Disabled BPF skeletons as libbpf is required) 677 BUILD_BPF_SKEL := 0 678 else ifeq ($(call get-executable,$(CLANG)),) 679 dummy := $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) is missing) 680 BUILD_BPF_SKEL := 0 681 else 682 CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g') 683 ifeq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1) 684 dummy := $(warning Warning: Disabled BPF skeletons as reliable BTF generation needs at least $(CLANG) version 12.0.1) 685 BUILD_BPF_SKEL := 0 686 endif 687 endif 688 ifeq ($(BUILD_BPF_SKEL),1) 689 $(call feature_check,clang-bpf-co-re) 690 ifeq ($(feature-clang-bpf-co-re), 0) 691 dummy := $(warning Warning: Disabled BPF skeletons as clang is too old) 692 BUILD_BPF_SKEL := 0 693 endif 694 endif 695 ifeq ($(BUILD_BPF_SKEL),1) 696 $(call detected,CONFIG_PERF_BPF_SKEL) 697 CFLAGS += -DHAVE_BPF_SKEL 698 endif 699endif 700 701ifndef GEN_VMLINUX_H 702 VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h 703endif 704 705dwarf-post-unwind := 1 706dwarf-post-unwind-text := BUG 707 708# setup DWARF post unwinder 709ifdef NO_LIBUNWIND 710 ifdef NO_LIBDW_DWARF_UNWIND 711 msg := $(warning Disabling post unwind, no support found.); 712 dwarf-post-unwind := 0 713 else 714 dwarf-post-unwind-text := libdw 715 $(call detected,CONFIG_LIBDW_DWARF_UNWIND) 716 endif 717else 718 dwarf-post-unwind-text := libunwind 719 $(call detected,CONFIG_LIBUNWIND) 720 # Enable libunwind support by default. 721 ifndef NO_LIBDW_DWARF_UNWIND 722 NO_LIBDW_DWARF_UNWIND := 1 723 endif 724endif 725 726ifeq ($(dwarf-post-unwind),1) 727 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT 728 $(call detected,CONFIG_DWARF_UNWIND) 729else 730 NO_DWARF_UNWIND := 1 731endif 732 733ifndef NO_LOCAL_LIBUNWIND 734 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64)) 735 $(call feature_check,libunwind-debug-frame) 736 ifneq ($(feature-libunwind-debug-frame), 1) 737 msg := $(warning No debug_frame support found in libunwind); 738 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 739 endif 740 else 741 # non-ARM has no dwarf_find_debug_frame() function: 742 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 743 endif 744 EXTLIBS += $(LIBUNWIND_LIBS) 745 LDFLAGS += $(LIBUNWIND_LIBS) 746endif 747ifeq ($(findstring -static,${LDFLAGS}),-static) 748 # gcc -static links libgcc_eh which contans piece of libunwind 749 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition 750endif 751 752ifndef NO_LIBUNWIND 753 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT 754 CFLAGS += $(LIBUNWIND_CFLAGS) 755 LDFLAGS += $(LIBUNWIND_LDFLAGS) 756 EXTLIBS += $(EXTLIBS_LIBUNWIND) 757endif 758 759ifneq ($(NO_LIBTRACEEVENT),1) 760 ifeq ($(NO_SYSCALL_TABLE),0) 761 $(call detected,CONFIG_TRACE) 762 else 763 ifndef NO_LIBAUDIT 764 $(call feature_check,libaudit) 765 ifneq ($(feature-libaudit), 1) 766 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); 767 NO_LIBAUDIT := 1 768 else 769 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT 770 EXTLIBS += -laudit 771 $(call detected,CONFIG_TRACE) 772 endif 773 endif 774 endif 775endif 776 777ifndef NO_LIBCRYPTO 778 ifneq ($(feature-libcrypto), 1) 779 msg := $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev); 780 NO_LIBCRYPTO := 1 781 else 782 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT 783 EXTLIBS += -lcrypto 784 $(call detected,CONFIG_CRYPTO) 785 endif 786endif 787 788ifndef NO_SLANG 789 ifneq ($(feature-libslang), 1) 790 ifneq ($(feature-libslang-include-subdir), 1) 791 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev); 792 NO_SLANG := 1 793 else 794 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR 795 endif 796 endif 797 ifndef NO_SLANG 798 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h 799 CFLAGS += -DHAVE_SLANG_SUPPORT 800 EXTLIBS += -lslang 801 $(call detected,CONFIG_SLANG) 802 endif 803endif 804 805ifdef GTK2 806 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) 807 $(call feature_check,gtk2) 808 ifneq ($(feature-gtk2), 1) 809 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); 810 NO_GTK2 := 1 811 else 812 $(call feature_check,gtk2-infobar) 813 ifeq ($(feature-gtk2-infobar), 1) 814 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT 815 endif 816 CFLAGS += -DHAVE_GTK2_SUPPORT 817 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null) 818 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null) 819 EXTLIBS += -ldl 820 endif 821endif 822 823ifdef NO_LIBPERL 824 CFLAGS += -DNO_LIBPERL 825else 826 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) 827 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) 828 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) 829 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) 830 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) 831 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS)) 832 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) 833 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) 834 835 ifneq ($(feature-libperl), 1) 836 CFLAGS += -DNO_LIBPERL 837 NO_LIBPERL := 1 838 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev); 839 else 840 LDFLAGS += $(PERL_EMBED_LDFLAGS) 841 EXTLIBS += $(PERL_EMBED_LIBADD) 842 CFLAGS += -DHAVE_LIBPERL_SUPPORT 843 ifeq ($(CC_NO_CLANG), 0) 844 CFLAGS += -Wno-compound-token-split-by-macro 845 endif 846 $(call detected,CONFIG_LIBPERL) 847 endif 848endif 849 850ifeq ($(feature-timerfd), 1) 851 CFLAGS += -DHAVE_TIMERFD_SUPPORT 852else 853 msg := $(warning No timerfd support. Disables 'perf kvm stat live'); 854endif 855 856disable-python = $(eval $(disable-python_code)) 857define disable-python_code 858 CFLAGS += -DNO_LIBPYTHON 859 $(warning $1) 860 NO_LIBPYTHON := 1 861endef 862 863PYTHON_EXTENSION_SUFFIX := '.so' 864ifdef NO_LIBPYTHON 865 $(call disable-python,Python support disabled by user) 866else 867 868 ifndef PYTHON 869 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev) 870 else 871 PYTHON_WORD := $(call shell-wordify,$(PYTHON)) 872 873 ifndef PYTHON_CONFIG 874 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev) 875 else 876 877 ifneq ($(feature-libpython), 1) 878 $(call disable-python,No 'Python.h' was found: disables Python support - please install python-devel/python-dev) 879 else 880 LDFLAGS += $(PYTHON_EMBED_LDFLAGS) 881 EXTLIBS += $(PYTHON_EMBED_LIBADD) 882 PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no") 883 ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes) 884 PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])') 885 LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX) 886 else 887 msg := $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent); 888 endif 889 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT 890 $(call detected,CONFIG_LIBPYTHON) 891 endif 892 endif 893 endif 894endif 895 896ifneq ($(NO_JEVENTS),1) 897 ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),) 898 NO_JEVENTS := 1 899 endif 900endif 901ifneq ($(NO_JEVENTS),1) 902 NO_JEVENTS := 0 903 ifndef PYTHON 904 $(error ERROR: No python interpreter needed for jevents generation. Install python or build with NO_JEVENTS=1.) 905 else 906 # jevents.py uses f-strings present in Python 3.6 released in Dec. 2016. 907 JEVENTS_PYTHON_GOOD := $(shell $(PYTHON) -c 'import sys;print("1" if(sys.version_info.major >= 3 and sys.version_info.minor >= 6) else "0")' 2> /dev/null) 908 ifneq ($(JEVENTS_PYTHON_GOOD), 1) 909 $(error ERROR: Python interpreter needed for jevents generation too old (older than 3.6). Install a newer python or build with NO_JEVENTS=1.) 910 endif 911 endif 912endif 913 914ifdef BUILD_NONDISTRO 915 ifeq ($(feature-libbfd), 1) 916 EXTLIBS += -lbfd -lopcodes 917 else 918 # we are on a system that requires -liberty and (maybe) -lz 919 # to link against -lbfd; test each case individually here 920 921 # call all detections now so we get correct 922 # status in VF output 923 $(call feature_check,libbfd-liberty) 924 $(call feature_check,libbfd-liberty-z) 925 926 ifeq ($(feature-libbfd-liberty), 1) 927 EXTLIBS += -lbfd -lopcodes -liberty 928 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl 929 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl 930 else 931 ifeq ($(feature-libbfd-liberty-z), 1) 932 EXTLIBS += -lbfd -lopcodes -liberty -lz 933 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl 934 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl 935 endif 936 endif 937 $(call feature_check,disassembler-four-args) 938 $(call feature_check,disassembler-init-styled) 939 endif 940 941 CFLAGS += -DHAVE_LIBBFD_SUPPORT 942 CXXFLAGS += -DHAVE_LIBBFD_SUPPORT 943 ifeq ($(feature-libbfd-buildid), 1) 944 CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT 945 else 946 msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available); 947 endif 948endif 949 950ifndef NO_DEMANGLE 951 $(call feature_check,cxa-demangle) 952 ifeq ($(feature-cxa-demangle), 1) 953 EXTLIBS += -lstdc++ 954 CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT 955 CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT 956 $(call detected,CONFIG_CXX_DEMANGLE) 957 endif 958 ifdef BUILD_NONDISTRO 959 ifeq ($(filter -liberty,$(EXTLIBS)),) 960 $(call feature_check,cplus-demangle) 961 ifeq ($(feature-cplus-demangle), 1) 962 EXTLIBS += -liberty 963 endif 964 endif 965 ifneq ($(filter -liberty,$(EXTLIBS)),) 966 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 967 CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 968 endif 969 endif 970endif 971 972ifndef NO_LZMA 973 ifeq ($(feature-lzma), 1) 974 CFLAGS += -DHAVE_LZMA_SUPPORT 975 EXTLIBS += -llzma 976 $(call detected,CONFIG_LZMA) 977 else 978 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev); 979 NO_LZMA := 1 980 endif 981endif 982 983ifndef NO_LIBZSTD 984 ifeq ($(feature-libzstd), 1) 985 CFLAGS += -DHAVE_ZSTD_SUPPORT 986 CFLAGS += $(LIBZSTD_CFLAGS) 987 LDFLAGS += $(LIBZSTD_LDFLAGS) 988 EXTLIBS += -lzstd 989 $(call detected,CONFIG_ZSTD) 990 else 991 msg := $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR); 992 NO_LIBZSTD := 1 993 endif 994endif 995 996ifndef NO_LIBCAP 997 ifeq ($(feature-libcap), 1) 998 CFLAGS += -DHAVE_LIBCAP_SUPPORT 999 EXTLIBS += -lcap 1000 $(call detected,CONFIG_LIBCAP) 1001 else 1002 msg := $(warning No libcap found, disables capability support, please install libcap-devel/libcap-dev); 1003 NO_LIBCAP := 1 1004 endif 1005endif 1006 1007ifndef NO_BACKTRACE 1008 ifeq ($(feature-backtrace), 1) 1009 CFLAGS += -DHAVE_BACKTRACE_SUPPORT 1010 endif 1011endif 1012 1013ifndef NO_LIBNUMA 1014 ifeq ($(feature-libnuma), 0) 1015 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev); 1016 NO_LIBNUMA := 1 1017 else 1018 ifeq ($(feature-numa_num_possible_cpus), 0) 1019 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8); 1020 NO_LIBNUMA := 1 1021 else 1022 CFLAGS += -DHAVE_LIBNUMA_SUPPORT 1023 EXTLIBS += -lnuma 1024 $(call detected,CONFIG_NUMA) 1025 endif 1026 endif 1027endif 1028 1029ifdef HAVE_KVM_STAT_SUPPORT 1030 CFLAGS += -DHAVE_KVM_STAT_SUPPORT 1031endif 1032 1033ifeq ($(feature-disassembler-four-args), 1) 1034 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE 1035endif 1036 1037ifeq ($(feature-disassembler-init-styled), 1) 1038 CFLAGS += -DDISASM_INIT_STYLED 1039endif 1040 1041ifeq (${IS_64_BIT}, 1) 1042 ifndef NO_PERF_READ_VDSO32 1043 $(call feature_check,compile-32) 1044 ifeq ($(feature-compile-32), 1) 1045 CFLAGS += -DHAVE_PERF_READ_VDSO32 1046 else 1047 NO_PERF_READ_VDSO32 := 1 1048 endif 1049 endif 1050 ifneq ($(SRCARCH), x86) 1051 NO_PERF_READ_VDSOX32 := 1 1052 endif 1053 ifndef NO_PERF_READ_VDSOX32 1054 $(call feature_check,compile-x32) 1055 ifeq ($(feature-compile-x32), 1) 1056 CFLAGS += -DHAVE_PERF_READ_VDSOX32 1057 else 1058 NO_PERF_READ_VDSOX32 := 1 1059 endif 1060 endif 1061else 1062 NO_PERF_READ_VDSO32 := 1 1063 NO_PERF_READ_VDSOX32 := 1 1064endif 1065 1066ifndef NO_LIBBABELTRACE 1067 $(call feature_check,libbabeltrace) 1068 ifeq ($(feature-libbabeltrace), 1) 1069 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS) 1070 LDFLAGS += $(LIBBABELTRACE_LDFLAGS) 1071 EXTLIBS += -lbabeltrace-ctf 1072 $(call detected,CONFIG_LIBBABELTRACE) 1073 else 1074 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev); 1075 endif 1076endif 1077 1078ifndef NO_AUXTRACE 1079 ifeq ($(SRCARCH),x86) 1080 ifeq ($(feature-get_cpuid), 0) 1081 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); 1082 NO_AUXTRACE := 1 1083 endif 1084 endif 1085 ifndef NO_AUXTRACE 1086 $(call detected,CONFIG_AUXTRACE) 1087 CFLAGS += -DHAVE_AUXTRACE_SUPPORT 1088 ifeq ($(feature-reallocarray), 0) 1089 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY 1090 endif 1091 endif 1092endif 1093 1094ifdef EXTRA_TESTS 1095 $(call detected,CONFIG_EXTRA_TESTS) 1096 CFLAGS += -DHAVE_EXTRA_TESTS 1097endif 1098 1099ifndef NO_JVMTI 1100 ifneq (,$(wildcard /usr/sbin/update-java-alternatives)) 1101 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}') 1102 else 1103 ifneq (,$(wildcard /usr/sbin/alternatives)) 1104 JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g') 1105 endif 1106 endif 1107 ifndef JDIR 1108 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory) 1109 NO_JVMTI := 1 1110 endif 1111endif 1112 1113ifndef NO_JVMTI 1114 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux 1115 $(call feature_check,jvmti) 1116 ifeq ($(feature-jvmti), 1) 1117 $(call detected_var,JDIR) 1118 ifndef NO_JVMTI_CMLR 1119 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti) 1120 $(call feature_check,jvmti-cmlr) 1121 ifeq ($(feature-jvmti-cmlr), 1) 1122 CFLAGS += -DHAVE_JVMTI_CMLR 1123 endif 1124 endif # NO_JVMTI_CMLR 1125 else 1126 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel) 1127 NO_JVMTI := 1 1128 endif 1129endif 1130 1131ifndef NO_LIBPFM4 1132 $(call feature_check,libpfm4) 1133 ifeq ($(feature-libpfm4), 1) 1134 CFLAGS += -DHAVE_LIBPFM 1135 EXTLIBS += -lpfm 1136 ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1 1137 $(call detected,CONFIG_LIBPFM4) 1138 else 1139 msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev); 1140 endif 1141endif 1142 1143# libtraceevent is a recommended dependency picked up from the system. 1144ifneq ($(NO_LIBTRACEEVENT),1) 1145 $(call feature_check,libtraceevent) 1146 ifeq ($(feature-libtraceevent), 1) 1147 CFLAGS += -DHAVE_LIBTRACEEVENT 1148 EXTLIBS += -ltraceevent 1149 LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent) 1150 LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION))) 1151 LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION))) 1152 LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION))) 1153 LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3)) 1154 CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP) 1155 $(call detected,CONFIG_LIBTRACEEVENT) 1156 else 1157 dummy := $(error ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel or build with NO_LIBTRACEEVENT=1) 1158 endif 1159 1160 $(call feature_check,libtracefs) 1161 ifeq ($(feature-libtracefs), 1) 1162 EXTLIBS += -ltracefs 1163 LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs) 1164 LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION))) 1165 LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION))) 1166 LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION))) 1167 LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3)) 1168 CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP) 1169 endif 1170endif 1171 1172# Among the variables below, these: 1173# perfexecdir 1174# libbpf_include_dir 1175# perf_examples_dir 1176# template_dir 1177# mandir 1178# infodir 1179# htmldir 1180# ETC_PERFCONFIG (but not sysconfdir) 1181# can be specified as a relative path some/where/else; 1182# this is interpreted as relative to $(prefix) and "perf" at 1183# runtime figures out where they are based on the path to the executable. 1184# This can help installing the suite in a relocatable way. 1185 1186# Make the path relative to DESTDIR, not to prefix 1187ifndef DESTDIR 1188prefix ?= $(HOME) 1189endif 1190bindir_relative = bin 1191bindir = $(abspath $(prefix)/$(bindir_relative)) 1192includedir_relative = include 1193includedir = $(abspath $(prefix)/$(includedir_relative)) 1194mandir = share/man 1195infodir = share/info 1196perfexecdir = libexec/perf-core 1197# FIXME: system's libbpf header directory, where we expect to find bpf/bpf_helpers.h, for instance 1198libbpf_include_dir = /usr/include 1199perf_examples_dir = lib/perf/examples 1200sharedir = $(prefix)/share 1201template_dir = share/perf-core/templates 1202STRACE_GROUPS_DIR = share/perf-core/strace/groups 1203htmldir = share/doc/perf-doc 1204tipdir = share/doc/perf-tip 1205srcdir = $(srctree)/tools/perf 1206ifeq ($(prefix),/usr) 1207sysconfdir = /etc 1208ETC_PERFCONFIG = $(sysconfdir)/perfconfig 1209else 1210sysconfdir = $(prefix)/etc 1211ETC_PERFCONFIG = etc/perfconfig 1212endif 1213ifndef lib 1214ifeq ($(SRCARCH)$(IS_64_BIT), x861) 1215lib = lib64 1216else 1217lib = lib 1218endif 1219endif # lib 1220libdir = $(prefix)/$(lib) 1221 1222# Shell quote (do not use $(call) to accommodate ancient setups); 1223ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) 1224STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR)) 1225DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) 1226bindir_SQ = $(subst ','\'',$(bindir)) 1227includedir_SQ = $(subst ','\'',$(includedir)) 1228mandir_SQ = $(subst ','\'',$(mandir)) 1229infodir_SQ = $(subst ','\'',$(infodir)) 1230perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) 1231libbpf_include_dir_SQ = $(subst ','\'',$(libbpf_include_dir)) 1232perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir)) 1233template_dir_SQ = $(subst ','\'',$(template_dir)) 1234htmldir_SQ = $(subst ','\'',$(htmldir)) 1235tipdir_SQ = $(subst ','\'',$(tipdir)) 1236prefix_SQ = $(subst ','\'',$(prefix)) 1237sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) 1238libdir_SQ = $(subst ','\'',$(libdir)) 1239srcdir_SQ = $(subst ','\'',$(srcdir)) 1240 1241ifneq ($(filter /%,$(firstword $(perfexecdir))),) 1242perfexec_instdir = $(perfexecdir) 1243perf_include_instdir = $(libbpf_include_dir) 1244perf_examples_instdir = $(perf_examples_dir) 1245STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR) 1246tip_instdir = $(tipdir) 1247else 1248perfexec_instdir = $(prefix)/$(perfexecdir) 1249perf_include_instdir = $(prefix)/$(libbpf_include_dir) 1250perf_examples_instdir = $(prefix)/$(perf_examples_dir) 1251STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR) 1252tip_instdir = $(prefix)/$(tipdir) 1253endif 1254perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) 1255perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir)) 1256perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir)) 1257STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR)) 1258tip_instdir_SQ = $(subst ','\'',$(tip_instdir)) 1259 1260export perfexec_instdir_SQ 1261 1262print_var = $(eval $(print_var_code)) $(info $(MSG)) 1263define print_var_code 1264 MSG = $(shell printf '...%40s: %s' $(1) $($(1))) 1265endef 1266 1267ifeq ($(feature_display),1) 1268 $(call feature_display_entries) 1269endif 1270 1271ifeq ($(VF),1) 1272 # Display EXTRA features which are detected manualy 1273 # from here with feature_check call and thus cannot 1274 # be partof global state output. 1275 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),) $(info $(MSG))) 1276 $(call print_var,prefix) 1277 $(call print_var,bindir) 1278 $(call print_var,libdir) 1279 $(call print_var,sysconfdir) 1280 $(call print_var,LIBUNWIND_DIR) 1281 $(call print_var,LIBDW_DIR) 1282 $(call print_var,JDIR) 1283 1284 ifeq ($(dwarf-post-unwind),1) 1285 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG)) 1286 endif 1287endif 1288 1289$(info ) 1290 1291$(call detected_var,bindir_SQ) 1292$(call detected_var,PYTHON_WORD) 1293ifneq ($(OUTPUT),) 1294$(call detected_var,OUTPUT) 1295endif 1296$(call detected_var,htmldir_SQ) 1297$(call detected_var,infodir_SQ) 1298$(call detected_var,mandir_SQ) 1299$(call detected_var,ETC_PERFCONFIG_SQ) 1300$(call detected_var,STRACE_GROUPS_DIR_SQ) 1301$(call detected_var,prefix_SQ) 1302$(call detected_var,perfexecdir_SQ) 1303$(call detected_var,libbpf_include_dir_SQ) 1304$(call detected_var,perf_examples_dir_SQ) 1305$(call detected_var,tipdir_SQ) 1306$(call detected_var,srcdir_SQ) 1307$(call detected_var,LIBDIR) 1308$(call detected_var,GTK_CFLAGS) 1309$(call detected_var,PERL_EMBED_CCOPTS) 1310$(call detected_var,PYTHON_EMBED_CCOPTS) 1311ifneq ($(BISON_FILE_PREFIX_MAP),) 1312$(call detected_var,BISON_FILE_PREFIX_MAP) 1313endif 1314 1315# re-generate FEATURE-DUMP as we may have called feature_check, found out 1316# extra libraries to add to LDFLAGS of some other test and then redo those 1317# tests, see the block about libbfd, disassembler-four-args, for instance. 1318$(shell rm -f $(FEATURE_DUMP_FILENAME)) 1319$(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME))) 1320