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 500ifeq ($(feature-reallocarray), 0) 501 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY 502endif 503 504ifdef CORESIGHT 505 $(call feature_check,libopencsd) 506 ifeq ($(feature-libopencsd), 1) 507 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS) 508 LDFLAGS += $(LIBOPENCSD_LDFLAGS) 509 EXTLIBS += $(OPENCSDLIBS) 510 $(call detected,CONFIG_LIBOPENCSD) 511 ifdef CSTRACE_RAW 512 CFLAGS += -DCS_DEBUG_RAW 513 ifeq (${CSTRACE_RAW}, packed) 514 CFLAGS += -DCS_RAW_PACKED 515 endif 516 endif 517 else 518 $(error Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1) 519 endif 520endif 521 522ifndef NO_ZLIB 523 ifeq ($(feature-zlib), 1) 524 CFLAGS += -DHAVE_ZLIB_SUPPORT 525 EXTLIBS += -lz 526 $(call detected,CONFIG_ZLIB) 527 else 528 NO_ZLIB := 1 529 endif 530endif 531 532ifndef NO_LIBELF 533 CFLAGS += -DHAVE_LIBELF_SUPPORT 534 EXTLIBS += -lelf 535 $(call detected,CONFIG_LIBELF) 536 537 ifeq ($(feature-libelf-getphdrnum), 1) 538 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT 539 endif 540 541 ifeq ($(feature-libelf-gelf_getnote), 1) 542 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT 543 else 544 $(warning gelf_getnote() not found on libelf, SDT support disabled) 545 endif 546 547 ifeq ($(feature-libelf-getshdrstrndx), 1) 548 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT 549 endif 550 551 ifeq ($(feature-libelf-zstd), 1) 552 ifdef NO_LIBZSTD 553 $(error Error: libzstd is required by libelf, please do not set NO_LIBZSTD) 554 endif 555 endif 556 557 ifndef NO_LIBDEBUGINFOD 558 $(call feature_check,libdebuginfod) 559 ifeq ($(feature-libdebuginfod), 1) 560 CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT 561 EXTLIBS += -ldebuginfod 562 endif 563 endif 564 565 ifndef NO_LIBDW 566 CFLAGS += -DHAVE_LIBDW_SUPPORT $(LIBDW_CFLAGS) 567 LDFLAGS += $(LIBDW_LDFLAGS) 568 EXTLIBS += ${DWARFLIBS} 569 $(call detected,CONFIG_LIBDW) 570 endif # NO_LIBDW 571 572 ifndef NO_LIBBPF 573 ifeq ($(feature-bpf), 1) 574 # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status 575 $(call feature_check,libbpf) 576 577 ifdef LIBBPF_DYNAMIC 578 ifeq ($(feature-libbpf), 1) 579 EXTLIBS += -lbpf 580 CFLAGS += -DHAVE_LIBBPF_SUPPORT 581 $(call detected,CONFIG_LIBBPF) 582 $(call detected,CONFIG_LIBBPF_DYNAMIC) 583 else 584 $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel) 585 endif 586 else 587 ifeq ($(NO_ZLIB), 1) 588 $(warning Warning: Statically building libbpf not possible as zlib is missing) 589 NO_LIBBPF := 1 590 else 591 # Libbpf will be built as a static library from tools/lib/bpf. 592 LIBBPF_STATIC := 1 593 $(call detected,CONFIG_LIBBPF) 594 CFLAGS += -DHAVE_LIBBPF_SUPPORT 595 endif 596 endif 597 endif 598 endif # NO_LIBBPF 599endif # NO_LIBELF 600 601ifndef NO_SDT 602 ifneq ($(feature-sdt), 1) 603 $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev) 604 NO_SDT := 1; 605 else 606 CFLAGS += -DHAVE_SDT_EVENT 607 $(call detected,CONFIG_SDT_EVENT) 608 endif 609endif 610 611ifdef PERF_HAVE_JITDUMP 612 ifndef NO_LIBELF 613 $(call detected,CONFIG_JITDUMP) 614 CFLAGS += -DHAVE_JITDUMP 615 endif 616endif 617 618ifeq ($(SRCARCH),powerpc) 619 ifndef NO_LIBDW 620 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX 621 endif 622endif 623 624ifndef NO_LIBUNWIND 625 have_libunwind := 626 627 $(call feature_check,libunwind-x86) 628 ifeq ($(feature-libunwind-x86), 1) 629 $(call detected,CONFIG_LIBUNWIND_X86) 630 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT 631 LDFLAGS += -lunwind-x86 632 EXTLIBS_LIBUNWIND += -lunwind-x86 633 have_libunwind = 1 634 endif 635 636 $(call feature_check,libunwind-aarch64) 637 ifeq ($(feature-libunwind-aarch64), 1) 638 $(call detected,CONFIG_LIBUNWIND_AARCH64) 639 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT 640 LDFLAGS += -lunwind-aarch64 641 EXTLIBS_LIBUNWIND += -lunwind-aarch64 642 have_libunwind = 1 643 $(call feature_check,libunwind-debug-frame-aarch64) 644 ifneq ($(feature-libunwind-debug-frame-aarch64), 1) 645 $(warning No debug_frame support found in libunwind-aarch64) 646 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64 647 endif 648 endif 649 650 ifneq ($(feature-libunwind), 1) 651 $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR) 652 NO_LOCAL_LIBUNWIND := 1 653 else 654 have_libunwind := 1 655 $(call detected,CONFIG_LOCAL_LIBUNWIND) 656 endif 657 658 ifneq ($(have_libunwind), 1) 659 NO_LIBUNWIND := 1 660 endif 661else 662 NO_LOCAL_LIBUNWIND := 1 663endif 664 665ifndef NO_LIBBPF 666 ifneq ($(feature-bpf), 1) 667 $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.) 668 NO_LIBBPF := 1 669 endif 670endif 671 672ifndef BUILD_BPF_SKEL 673 # BPF skeletons control a large number of perf features, by default 674 # they are enabled. 675 BUILD_BPF_SKEL := 1 676endif 677 678ifeq ($(BUILD_BPF_SKEL),1) 679 ifeq ($(filter -DHAVE_LIBELF_SUPPORT, $(CFLAGS)),) 680 $(warning Warning: Disabled BPF skeletons as libelf is required by bpftool) 681 BUILD_BPF_SKEL := 0 682 else ifeq ($(filter -DHAVE_ZLIB_SUPPORT, $(CFLAGS)),) 683 $(warning Warning: Disabled BPF skeletons as zlib is required by bpftool) 684 BUILD_BPF_SKEL := 0 685 else ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),) 686 $(warning Warning: Disabled BPF skeletons as libbpf is required) 687 BUILD_BPF_SKEL := 0 688 else ifeq ($(call get-executable,$(CLANG)),) 689 $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) is missing) 690 BUILD_BPF_SKEL := 0 691 else 692 CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g') 693 ifeq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1) 694 $(warning Warning: Disabled BPF skeletons as reliable BTF generation needs at least $(CLANG) version 12.0.1) 695 BUILD_BPF_SKEL := 0 696 endif 697 endif 698 ifeq ($(BUILD_BPF_SKEL),1) 699 $(call feature_check,clang-bpf-co-re) 700 ifeq ($(feature-clang-bpf-co-re), 0) 701 $(warning Warning: Disabled BPF skeletons as clang is too old) 702 BUILD_BPF_SKEL := 0 703 endif 704 endif 705 ifeq ($(BUILD_BPF_SKEL),1) 706 $(call detected,CONFIG_PERF_BPF_SKEL) 707 CFLAGS += -DHAVE_BPF_SKEL 708 endif 709endif 710 711ifndef GEN_VMLINUX_H 712 VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h 713endif 714 715dwarf-post-unwind := 1 716dwarf-post-unwind-text := BUG 717 718# setup DWARF post unwinder 719ifdef NO_LIBUNWIND 720 ifdef NO_LIBDW_DWARF_UNWIND 721 $(warning Disabling post unwind, no support found.) 722 dwarf-post-unwind := 0 723 else 724 dwarf-post-unwind-text := libdw 725 $(call detected,CONFIG_LIBDW_DWARF_UNWIND) 726 endif 727else 728 dwarf-post-unwind-text := libunwind 729 $(call detected,CONFIG_LIBUNWIND) 730 # Enable libunwind support by default. 731 ifndef NO_LIBDW_DWARF_UNWIND 732 NO_LIBDW_DWARF_UNWIND := 1 733 endif 734endif 735 736ifeq ($(dwarf-post-unwind),1) 737 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT 738 $(call detected,CONFIG_DWARF_UNWIND) 739endif 740 741ifndef NO_LIBUNWIND 742 ifndef NO_LOCAL_LIBUNWIND 743 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64)) 744 $(call feature_check,libunwind-debug-frame) 745 ifneq ($(feature-libunwind-debug-frame), 1) 746 $(warning No debug_frame support found in libunwind) 747 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 748 endif 749 else 750 # non-ARM has no dwarf_find_debug_frame() function: 751 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 752 endif 753 EXTLIBS += $(LIBUNWIND_LIBS) 754 LDFLAGS += $(LIBUNWIND_LIBS) 755 endif 756 ifeq ($(findstring -static,${LDFLAGS}),-static) 757 # gcc -static links libgcc_eh which contans piece of libunwind 758 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition 759 endif 760 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT 761 CFLAGS += $(LIBUNWIND_CFLAGS) 762 LDFLAGS += $(LIBUNWIND_LDFLAGS) 763 EXTLIBS += $(EXTLIBS_LIBUNWIND) 764endif 765 766ifneq ($(NO_LIBTRACEEVENT),1) 767 $(call detected,CONFIG_TRACE) 768endif 769 770ifndef NO_LIBCRYPTO 771 ifneq ($(feature-libcrypto), 1) 772 $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev) 773 NO_LIBCRYPTO := 1 774 else 775 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT 776 EXTLIBS += -lcrypto 777 $(call detected,CONFIG_CRYPTO) 778 endif 779endif 780 781ifndef NO_SLANG 782 ifneq ($(feature-libslang), 1) 783 ifneq ($(feature-libslang-include-subdir), 1) 784 $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev) 785 NO_SLANG := 1 786 else 787 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR 788 endif 789 endif 790 ifndef NO_SLANG 791 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h 792 CFLAGS += -DHAVE_SLANG_SUPPORT 793 EXTLIBS += -lslang 794 $(call detected,CONFIG_SLANG) 795 endif 796endif 797 798ifdef GTK2 799 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) 800 $(call feature_check,gtk2) 801 ifneq ($(feature-gtk2), 1) 802 $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev) 803 NO_GTK2 := 1 804 else 805 $(call feature_check,gtk2-infobar) 806 ifeq ($(feature-gtk2-infobar), 1) 807 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT 808 endif 809 CFLAGS += -DHAVE_GTK2_SUPPORT 810 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null) 811 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null) 812 EXTLIBS += -ldl 813 endif 814endif 815 816ifdef NO_LIBPERL 817 CFLAGS += -DNO_LIBPERL 818else 819 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) 820 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) 821 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) 822 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) 823 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) 824 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS)) 825 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) 826 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) 827 828 ifneq ($(feature-libperl), 1) 829 CFLAGS += -DNO_LIBPERL 830 NO_LIBPERL := 1 831 $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev) 832 else 833 LDFLAGS += $(PERL_EMBED_LDFLAGS) 834 EXTLIBS += $(PERL_EMBED_LIBADD) 835 CFLAGS += -DHAVE_LIBPERL_SUPPORT 836 ifeq ($(CC_NO_CLANG), 0) 837 CFLAGS += -Wno-compound-token-split-by-macro 838 endif 839 $(call detected,CONFIG_LIBPERL) 840 endif 841endif 842 843ifeq ($(feature-timerfd), 1) 844 CFLAGS += -DHAVE_TIMERFD_SUPPORT 845else 846 $(warning No timerfd support. Disables 'perf kvm stat live') 847endif 848 849disable-python = $(eval $(disable-python_code)) 850define disable-python_code 851 CFLAGS += -DNO_LIBPYTHON 852 $(warning $1) 853 NO_LIBPYTHON := 1 854endef 855 856PYTHON_EXTENSION_SUFFIX := '.so' 857ifdef NO_LIBPYTHON 858 $(call disable-python,Python support disabled by user) 859else 860 861 ifndef PYTHON 862 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev) 863 else 864 PYTHON_WORD := $(call shell-wordify,$(PYTHON)) 865 866 ifndef PYTHON_CONFIG 867 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev) 868 else 869 870 ifneq ($(feature-libpython), 1) 871 $(call disable-python,No 'Python.h' was found: disables Python support - please install python-devel/python-dev) 872 else 873 LDFLAGS += $(PYTHON_EMBED_LDFLAGS) 874 EXTLIBS += $(PYTHON_EMBED_LIBADD) 875 PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no") 876 ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes) 877 PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])') 878 ifdef CROSS_COMPILE 879 PYTHON_EXTENSION_SUFFIX := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EXTENSION_SUFFIX)) 880 endif 881 LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX) 882 else 883 $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent) 884 endif 885 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT 886 $(call detected,CONFIG_LIBPYTHON) 887 ifeq ($(filter -fPIC,$(CFLAGS)),) 888 # Building a shared library requires position independent code. 889 CFLAGS += -fPIC 890 CXXFLAGS += -fPIC 891 endif 892 endif 893 endif 894 endif 895endif 896 897ifneq ($(NO_JEVENTS),1) 898 ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),) 899 NO_JEVENTS := 1 900 endif 901endif 902ifneq ($(NO_JEVENTS),1) 903 NO_JEVENTS := 0 904 ifndef PYTHON 905 $(error ERROR: No python interpreter needed for jevents generation. Install python or build with NO_JEVENTS=1.) 906 else 907 # jevents.py uses f-strings present in Python 3.6 released in Dec. 2016. 908 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) 909 ifneq ($(JEVENTS_PYTHON_GOOD), 1) 910 $(error ERROR: Python interpreter needed for jevents generation too old (older than 3.6). Install a newer python or build with NO_JEVENTS=1.) 911 endif 912 endif 913endif 914 915ifdef BUILD_NONDISTRO 916 ifeq ($(feature-libbfd), 1) 917 EXTLIBS += -lbfd -lopcodes 918 else 919 # we are on a system that requires -liberty and (maybe) -lz 920 # to link against -lbfd; test each case individually here 921 922 # call all detections now so we get correct 923 # status in VF output 924 $(call feature_check,libbfd-liberty) 925 $(call feature_check,libbfd-liberty-z) 926 927 ifeq ($(feature-libbfd-liberty), 1) 928 EXTLIBS += -lbfd -lopcodes -liberty 929 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl 930 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl 931 else 932 ifeq ($(feature-libbfd-liberty-z), 1) 933 EXTLIBS += -lbfd -lopcodes -liberty -lz 934 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl 935 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl 936 endif 937 endif 938 $(call feature_check,disassembler-four-args) 939 $(call feature_check,disassembler-init-styled) 940 endif 941 942 CFLAGS += -DHAVE_LIBBFD_SUPPORT 943 CXXFLAGS += -DHAVE_LIBBFD_SUPPORT 944 ifeq ($(feature-libbfd-buildid), 1) 945 CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT 946 else 947 $(warning Old version of libbfd/binutils things like PE executable profiling will not be available) 948 endif 949endif 950 951ifndef NO_LIBLLVM 952 $(call feature_check,llvm-perf) 953 ifeq ($(feature-llvm-perf), 1) 954 CFLAGS += -DHAVE_LIBLLVM_SUPPORT 955 CFLAGS += $(shell $(LLVM_CONFIG) --cflags) 956 CXXFLAGS += -DHAVE_LIBLLVM_SUPPORT 957 CXXFLAGS += $(shell $(LLVM_CONFIG) --cxxflags) 958 LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs) 959 EXTLIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM) 960 EXTLIBS += -lstdc++ 961 $(call detected,CONFIG_LIBLLVM) 962 else 963 $(warning No libllvm 13+ found, slower source file resolution, please install llvm-devel/llvm-dev) 964 NO_LIBLLVM := 1 965 endif 966endif 967 968ifndef NO_DEMANGLE 969 $(call feature_check,cxa-demangle) 970 ifeq ($(feature-cxa-demangle), 1) 971 EXTLIBS += -lstdc++ 972 CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT 973 CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT 974 $(call detected,CONFIG_CXX_DEMANGLE) 975 endif 976 ifdef BUILD_NONDISTRO 977 ifeq ($(filter -liberty,$(EXTLIBS)),) 978 $(call feature_check,cplus-demangle) 979 ifeq ($(feature-cplus-demangle), 1) 980 EXTLIBS += -liberty 981 endif 982 endif 983 ifneq ($(filter -liberty,$(EXTLIBS)),) 984 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 985 CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 986 endif 987 endif 988endif 989 990ifndef NO_LZMA 991 ifeq ($(feature-lzma), 1) 992 CFLAGS += -DHAVE_LZMA_SUPPORT 993 EXTLIBS += -llzma 994 $(call detected,CONFIG_LZMA) 995 else 996 $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev) 997 NO_LZMA := 1 998 endif 999endif 1000 1001ifndef NO_LIBZSTD 1002 ifeq ($(feature-libzstd), 1) 1003 CFLAGS += -DHAVE_ZSTD_SUPPORT 1004 CFLAGS += $(LIBZSTD_CFLAGS) 1005 LDFLAGS += $(LIBZSTD_LDFLAGS) 1006 EXTLIBS += -lzstd 1007 $(call detected,CONFIG_ZSTD) 1008 else 1009 $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR) 1010 NO_LIBZSTD := 1 1011 endif 1012endif 1013 1014ifndef NO_BACKTRACE 1015 ifeq ($(feature-backtrace), 1) 1016 CFLAGS += -DHAVE_BACKTRACE_SUPPORT 1017 endif 1018endif 1019 1020ifndef NO_LIBNUMA 1021 ifeq ($(feature-libnuma), 0) 1022 $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev) 1023 NO_LIBNUMA := 1 1024 else 1025 ifeq ($(feature-numa_num_possible_cpus), 0) 1026 $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8) 1027 NO_LIBNUMA := 1 1028 else 1029 CFLAGS += -DHAVE_LIBNUMA_SUPPORT 1030 EXTLIBS += -lnuma 1031 $(call detected,CONFIG_NUMA) 1032 endif 1033 endif 1034endif 1035 1036ifdef HAVE_KVM_STAT_SUPPORT 1037 CFLAGS += -DHAVE_KVM_STAT_SUPPORT 1038endif 1039 1040ifeq ($(feature-disassembler-four-args), 1) 1041 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE 1042endif 1043 1044ifeq ($(feature-disassembler-init-styled), 1) 1045 CFLAGS += -DDISASM_INIT_STYLED 1046endif 1047 1048ifeq (${IS_64_BIT}, 1) 1049 ifndef NO_PERF_READ_VDSO32 1050 $(call feature_check,compile-32) 1051 ifeq ($(feature-compile-32), 1) 1052 CFLAGS += -DHAVE_PERF_READ_VDSO32 1053 else 1054 NO_PERF_READ_VDSO32 := 1 1055 endif 1056 endif 1057 ifneq ($(SRCARCH), x86) 1058 NO_PERF_READ_VDSOX32 := 1 1059 endif 1060 ifndef NO_PERF_READ_VDSOX32 1061 $(call feature_check,compile-x32) 1062 ifeq ($(feature-compile-x32), 1) 1063 CFLAGS += -DHAVE_PERF_READ_VDSOX32 1064 else 1065 NO_PERF_READ_VDSOX32 := 1 1066 endif 1067 endif 1068else 1069 NO_PERF_READ_VDSO32 := 1 1070 NO_PERF_READ_VDSOX32 := 1 1071endif 1072 1073ifndef NO_LIBBABELTRACE 1074 $(call feature_check,libbabeltrace) 1075 ifeq ($(feature-libbabeltrace), 1) 1076 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS) 1077 LDFLAGS += $(LIBBABELTRACE_LDFLAGS) 1078 EXTLIBS += -lbabeltrace-ctf 1079 $(call detected,CONFIG_LIBBABELTRACE) 1080 else 1081 $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev) 1082 endif 1083endif 1084 1085ifndef NO_CAPSTONE 1086 $(call feature_check,libcapstone) 1087 ifeq ($(feature-libcapstone), 1) 1088 CFLAGS += -DHAVE_LIBCAPSTONE_SUPPORT $(LIBCAPSTONE_CFLAGS) 1089 LDFLAGS += $(LICAPSTONE_LDFLAGS) 1090 EXTLIBS += -lcapstone 1091 $(call detected,CONFIG_LIBCAPSTONE) 1092 else 1093 msg := $(warning No libcapstone found, disables disasm engine support for 'perf script', please install libcapstone-dev/capstone-devel); 1094 endif 1095endif 1096 1097ifndef NO_AUXTRACE 1098 ifeq ($(SRCARCH),x86) 1099 ifeq ($(feature-get_cpuid), 0) 1100 $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc) 1101 NO_AUXTRACE := 1 1102 endif 1103 endif 1104 ifndef NO_AUXTRACE 1105 $(call detected,CONFIG_AUXTRACE) 1106 CFLAGS += -DHAVE_AUXTRACE_SUPPORT 1107 endif 1108endif 1109 1110ifdef EXTRA_TESTS 1111 $(call detected,CONFIG_EXTRA_TESTS) 1112 CFLAGS += -DHAVE_EXTRA_TESTS 1113endif 1114 1115ifndef NO_JVMTI 1116 ifneq (,$(wildcard /usr/sbin/update-java-alternatives)) 1117 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}') 1118 else 1119 ifneq (,$(wildcard /usr/sbin/alternatives)) 1120 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') 1121 endif 1122 endif 1123 ifndef JDIR 1124 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory) 1125 NO_JVMTI := 1 1126 endif 1127endif 1128 1129ifndef NO_JVMTI 1130 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux 1131 $(call feature_check,jvmti) 1132 ifeq ($(feature-jvmti), 1) 1133 $(call detected_var,JDIR) 1134 ifndef NO_JVMTI_CMLR 1135 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti) 1136 $(call feature_check,jvmti-cmlr) 1137 ifeq ($(feature-jvmti-cmlr), 1) 1138 CFLAGS += -DHAVE_JVMTI_CMLR 1139 endif 1140 endif # NO_JVMTI_CMLR 1141 else 1142 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel) 1143 NO_JVMTI := 1 1144 endif 1145endif 1146 1147ifndef NO_LIBPFM4 1148 $(call feature_check,libpfm4) 1149 ifeq ($(feature-libpfm4), 1) 1150 CFLAGS += -DHAVE_LIBPFM 1151 EXTLIBS += -lpfm 1152 ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1 1153 $(call detected,CONFIG_LIBPFM4) 1154 else 1155 $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev) 1156 endif 1157endif 1158 1159# libtraceevent is a recommended dependency picked up from the system. 1160ifneq ($(NO_LIBTRACEEVENT),1) 1161 ifeq ($(feature-libtraceevent), 1) 1162 CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent) 1163 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent) 1164 EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent) 1165 LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent).0.0 1166 LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION))) 1167 LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION))) 1168 LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION))) 1169 LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3)) 1170 CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP) 1171 $(call detected,CONFIG_LIBTRACEEVENT) 1172 else 1173 $(error ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel and/or set LIBTRACEEVENT_DIR or build with NO_LIBTRACEEVENT=1) 1174 endif 1175 1176 ifeq ($(feature-libtracefs), 1) 1177 CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) 1178 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs) 1179 EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtracefs) 1180 LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs).0.0 1181 LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION))) 1182 LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION))) 1183 LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION))) 1184 LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3)) 1185 CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP) 1186 else 1187 $(warning libtracefs is missing. Please install libtracefs-dev/libtracefs-devel) 1188 endif 1189endif 1190 1191# Among the variables below, these: 1192# perfexecdir 1193# libbpf_include_dir 1194# perf_examples_dir 1195# template_dir 1196# mandir 1197# infodir 1198# htmldir 1199# ETC_PERFCONFIG (but not sysconfdir) 1200# can be specified as a relative path some/where/else; 1201# this is interpreted as relative to $(prefix) and "perf" at 1202# runtime figures out where they are based on the path to the executable. 1203# This can help installing the suite in a relocatable way. 1204 1205# Make the path relative to DESTDIR, not to prefix 1206ifndef DESTDIR 1207prefix ?= $(HOME) 1208endif 1209bindir_relative = bin 1210bindir = $(abspath $(prefix)/$(bindir_relative)) 1211includedir_relative = include 1212includedir = $(abspath $(prefix)/$(includedir_relative)) 1213mandir = share/man 1214infodir = share/info 1215perfexecdir = libexec/perf-core 1216# FIXME: system's libbpf header directory, where we expect to find bpf/bpf_helpers.h, for instance 1217libbpf_include_dir = /usr/include 1218perf_examples_dir = lib/perf/examples 1219sharedir = $(prefix)/share 1220template_dir = share/perf-core/templates 1221STRACE_GROUPS_DIR = share/perf-core/strace/groups 1222htmldir = share/doc/perf-doc 1223tipdir = share/doc/perf-tip 1224srcdir = $(srctree)/tools/perf 1225ifeq ($(prefix),/usr) 1226sysconfdir = /etc 1227ETC_PERFCONFIG = $(sysconfdir)/perfconfig 1228else 1229sysconfdir = $(prefix)/etc 1230ETC_PERFCONFIG = etc/perfconfig 1231endif 1232ifndef lib 1233ifeq ($(SRCARCH)$(IS_64_BIT), x861) 1234lib = lib64 1235else 1236lib = lib 1237endif 1238endif # lib 1239libdir = $(prefix)/$(lib) 1240 1241# Shell quote (do not use $(call) to accommodate ancient setups); 1242ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) 1243STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR)) 1244DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) 1245bindir_SQ = $(subst ','\'',$(bindir)) 1246includedir_SQ = $(subst ','\'',$(includedir)) 1247mandir_SQ = $(subst ','\'',$(mandir)) 1248infodir_SQ = $(subst ','\'',$(infodir)) 1249perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) 1250libbpf_include_dir_SQ = $(subst ','\'',$(libbpf_include_dir)) 1251perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir)) 1252template_dir_SQ = $(subst ','\'',$(template_dir)) 1253htmldir_SQ = $(subst ','\'',$(htmldir)) 1254tipdir_SQ = $(subst ','\'',$(tipdir)) 1255prefix_SQ = $(subst ','\'',$(prefix)) 1256sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) 1257libdir_SQ = $(subst ','\'',$(libdir)) 1258srcdir_SQ = $(subst ','\'',$(srcdir)) 1259 1260ifneq ($(filter /%,$(firstword $(perfexecdir))),) 1261perfexec_instdir = $(perfexecdir) 1262perf_include_instdir = $(libbpf_include_dir) 1263perf_examples_instdir = $(perf_examples_dir) 1264STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR) 1265tip_instdir = $(tipdir) 1266else 1267perfexec_instdir = $(prefix)/$(perfexecdir) 1268perf_include_instdir = $(prefix)/$(libbpf_include_dir) 1269perf_examples_instdir = $(prefix)/$(perf_examples_dir) 1270STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR) 1271tip_instdir = $(prefix)/$(tipdir) 1272endif 1273perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) 1274perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir)) 1275perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir)) 1276STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR)) 1277tip_instdir_SQ = $(subst ','\'',$(tip_instdir)) 1278 1279export perfexec_instdir_SQ 1280 1281print_var = $(eval $(print_var_code)) $(info $(MSG)) 1282define print_var_code 1283 MSG = $(shell printf '...%40s: %s' $(1) $($(1))) 1284endef 1285 1286ifeq ($(feature_display),1) 1287 $(call feature_display_entries) 1288endif 1289 1290ifeq ($(VF),1) 1291 # Display EXTRA features which are detected manualy 1292 # from here with feature_check call and thus cannot 1293 # be partof global state output. 1294 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),) $(info $(MSG))) 1295 $(call print_var,prefix) 1296 $(call print_var,bindir) 1297 $(call print_var,libdir) 1298 $(call print_var,sysconfdir) 1299 $(call print_var,LIBUNWIND_DIR) 1300 $(call print_var,LIBDW_DIR) 1301 $(call print_var,JDIR) 1302 1303 ifeq ($(dwarf-post-unwind),1) 1304 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG)) 1305 endif 1306endif 1307 1308$(info ) 1309 1310$(call detected_var,bindir_SQ) 1311$(call detected_var,PYTHON_WORD) 1312ifneq ($(OUTPUT),) 1313$(call detected_var,OUTPUT) 1314endif 1315$(call detected_var,htmldir_SQ) 1316$(call detected_var,infodir_SQ) 1317$(call detected_var,mandir_SQ) 1318$(call detected_var,ETC_PERFCONFIG_SQ) 1319$(call detected_var,STRACE_GROUPS_DIR_SQ) 1320$(call detected_var,prefix_SQ) 1321$(call detected_var,perfexecdir_SQ) 1322$(call detected_var,libbpf_include_dir_SQ) 1323$(call detected_var,perf_examples_dir_SQ) 1324$(call detected_var,tipdir_SQ) 1325$(call detected_var,srcdir_SQ) 1326$(call detected_var,LIBDIR) 1327$(call detected_var,GTK_CFLAGS) 1328$(call detected_var,PERL_EMBED_CCOPTS) 1329$(call detected_var,PYTHON_EMBED_CCOPTS) 1330ifneq ($(BISON_FILE_PREFIX_MAP),) 1331$(call detected_var,BISON_FILE_PREFIX_MAP) 1332endif 1333 1334# re-generate FEATURE-DUMP as we may have called feature_check, found out 1335# extra libraries to add to LDFLAGS of some other test and then redo those 1336# tests, see the block about libbfd, disassembler-four-args, for instance. 1337$(shell rm -f $(FEATURE_DUMP_FILENAME)) 1338$(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME))) 1339