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