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