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