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