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