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