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