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