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