1 2ifeq ($(src-perf),) 3src-perf := $(srctree)/tools/perf 4endif 5 6ifeq ($(obj-perf),) 7obj-perf := $(OUTPUT) 8endif 9 10ifneq ($(obj-perf),) 11obj-perf := $(abspath $(obj-perf))/ 12endif 13 14$(shell printf "" > $(OUTPUT).config-detected) 15detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) 16detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) 17 18CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) 19 20include $(srctree)/tools/scripts/Makefile.arch 21 22$(call detected_var,SRCARCH) 23 24NO_PERF_REGS := 1 25 26# Additional ARCH settings for ppc 27ifeq ($(SRCARCH),powerpc) 28 NO_PERF_REGS := 0 29 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64 30endif 31 32# Additional ARCH settings for x86 33ifeq ($(SRCARCH),x86) 34 $(call detected,CONFIG_X86) 35 ifeq (${IS_64_BIT}, 1) 36 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE -I$(OUTPUT)arch/x86/include/generated 37 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 38 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma 39 $(call detected,CONFIG_X86_64) 40 else 41 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind 42 endif 43 NO_PERF_REGS := 0 44endif 45 46ifeq ($(SRCARCH),arm) 47 NO_PERF_REGS := 0 48 LIBUNWIND_LIBS = -lunwind -lunwind-arm 49endif 50 51ifeq ($(SRCARCH),arm64) 52 NO_PERF_REGS := 0 53 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 54endif 55 56ifeq ($(ARCH),s390) 57 NO_PERF_REGS := 0 58endif 59 60ifeq ($(NO_PERF_REGS),0) 61 $(call detected,CONFIG_PERF_REGS) 62endif 63 64# So far there's only x86 and arm libdw unwind support merged in perf. 65# Disable it on all other architectures in case libdw unwind 66# support is detected in system. Add supported architectures 67# to the check. 68ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm powerpc s390)) 69 NO_LIBDW_DWARF_UNWIND := 1 70endif 71 72ifeq ($(LIBUNWIND_LIBS),) 73 NO_LIBUNWIND := 1 74endif 75# 76# For linking with debug library, run like: 77# 78# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ 79# 80 81libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code)) 82define libunwind_arch_set_flags_code 83 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include 84 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib 85endef 86 87ifdef LIBUNWIND_DIR 88 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include 89 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib 90 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 91 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch))) 92endif 93 94# Set per-feature check compilation flags 95FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) 96FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 97FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) 98FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 99 100ifeq ($(NO_PERF_REGS),0) 101 CFLAGS += -DHAVE_PERF_REGS_SUPPORT 102endif 103 104# for linking with debug library, run like: 105# make DEBUG=1 LIBDW_DIR=/opt/libdw/ 106ifdef LIBDW_DIR 107 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include 108 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib 109endif 110DWARFLIBS := -ldw 111ifeq ($(findstring -static,${LDFLAGS}),-static) 112 DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2 113endif 114FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) 115FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS) 116 117# for linking with debug library, run like: 118# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ 119ifdef LIBBABELTRACE_DIR 120 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include 121 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib 122endif 123FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS) 124FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf 125 126FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi 127# include ARCH specific config 128-include $(src-perf)/arch/$(SRCARCH)/Makefile 129 130ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 131 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 132endif 133 134include $(srctree)/tools/scripts/utilities.mak 135 136ifeq ($(call get-executable,$(FLEX)),) 137 dummy := $(error Error: $(FLEX) is missing on this system, please install it) 138endif 139 140ifeq ($(call get-executable,$(BISON)),) 141 dummy := $(error Error: $(BISON) is missing on this system, please install it) 142endif 143 144# Treat warnings as errors unless directed not to 145ifneq ($(WERROR),0) 146 CFLAGS += -Werror 147 CXXFLAGS += -Werror 148endif 149 150ifndef DEBUG 151 DEBUG := 0 152endif 153 154ifeq ($(DEBUG),0) 155ifeq ($(CC_NO_CLANG), 0) 156 CFLAGS += -O3 157else 158 CFLAGS += -O6 159endif 160endif 161 162ifdef PARSER_DEBUG 163 PARSER_DEBUG_BISON := -t 164 PARSER_DEBUG_FLEX := -d 165 CFLAGS += -DPARSER_DEBUG 166 $(call detected_var,PARSER_DEBUG_BISON) 167 $(call detected_var,PARSER_DEBUG_FLEX) 168endif 169 170# Try different combinations to accommodate systems that only have 171# python[2][-config] in weird combinations but always preferring 172# python2 and python2-config as per pep-0394. If we catch a 173# python[-config] in version 3, the version check will kill it. 174PYTHON2 := $(if $(call get-executable,python2),python2,python) 175override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2)) 176PYTHON2_CONFIG := \ 177 $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config) 178override PYTHON_CONFIG := \ 179 $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG)) 180 181grep-libs = $(filter -l%,$(1)) 182strip-libs = $(filter-out -l%,$(1)) 183 184PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) 185 186ifdef PYTHON_CONFIG 187 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) 188 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) 189 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil 190 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) 191 PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) 192 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) 193endif 194 195FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS) 196FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) 197FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS) 198FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS) 199 200CFLAGS += -fno-omit-frame-pointer 201CFLAGS += -ggdb3 202CFLAGS += -funwind-tables 203CFLAGS += -Wall 204CFLAGS += -Wextra 205CFLAGS += -std=gnu99 206 207CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti 208CXXFLAGS += -Wall 209CXXFLAGS += -fno-omit-frame-pointer 210CXXFLAGS += -ggdb3 211CXXFLAGS += -funwind-tables 212CXXFLAGS += -Wno-strict-aliasing 213 214# Enforce a non-executable stack, as we may regress (again) in the future by 215# adding assembler files missing the .GNU-stack linker note. 216LDFLAGS += -Wl,-z,noexecstack 217 218EXTLIBS = -lpthread -lrt -lm -ldl 219 220ifeq ($(FEATURES_DUMP),) 221include $(srctree)/tools/build/Makefile.feature 222else 223include $(FEATURES_DUMP) 224endif 225 226ifeq ($(feature-stackprotector-all), 1) 227 CFLAGS += -fstack-protector-all 228endif 229 230ifeq ($(DEBUG),0) 231 ifeq ($(feature-fortify-source), 1) 232 CFLAGS += -D_FORTIFY_SOURCE=2 233 endif 234endif 235 236INC_FLAGS += -I$(src-perf)/util/include 237INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include 238INC_FLAGS += -I$(srctree)/tools/include/uapi 239INC_FLAGS += -I$(srctree)/tools/include/ 240INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi 241INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/ 242INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/ 243 244# $(obj-perf) for generated common-cmds.h 245# $(obj-perf)/util for generated bison/flex headers 246ifneq ($(OUTPUT),) 247INC_FLAGS += -I$(obj-perf)/util 248INC_FLAGS += -I$(obj-perf) 249endif 250 251INC_FLAGS += -I$(src-perf)/util 252INC_FLAGS += -I$(src-perf) 253INC_FLAGS += -I$(srctree)/tools/lib/ 254 255CFLAGS += $(INC_FLAGS) 256CXXFLAGS += $(INC_FLAGS) 257 258CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 259 260ifeq ($(feature-sync-compare-and-swap), 1) 261 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT 262endif 263 264ifeq ($(feature-pthread-attr-setaffinity-np), 1) 265 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP 266endif 267 268ifndef NO_BIONIC 269 $(call feature_check,bionic) 270 ifeq ($(feature-bionic), 1) 271 BIONIC := 1 272 EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) 273 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) 274 endif 275endif 276 277ifdef NO_LIBELF 278 NO_DWARF := 1 279 NO_DEMANGLE := 1 280 NO_LIBUNWIND := 1 281 NO_LIBDW_DWARF_UNWIND := 1 282 NO_LIBBPF := 1 283 NO_JVMTI := 1 284else 285 ifeq ($(feature-libelf), 0) 286 ifeq ($(feature-glibc), 1) 287 LIBC_SUPPORT := 1 288 endif 289 ifeq ($(BIONIC),1) 290 LIBC_SUPPORT := 1 291 endif 292 ifeq ($(LIBC_SUPPORT),1) 293 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); 294 295 NO_LIBELF := 1 296 NO_DWARF := 1 297 NO_DEMANGLE := 1 298 NO_LIBUNWIND := 1 299 NO_LIBDW_DWARF_UNWIND := 1 300 NO_LIBBPF := 1 301 NO_JVMTI := 1 302 else 303 ifneq ($(filter s% -static%,$(LDFLAGS),),) 304 msg := $(error No static glibc found, please install glibc-static); 305 else 306 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]); 307 endif 308 endif 309 else 310 ifndef NO_LIBDW_DWARF_UNWIND 311 ifneq ($(feature-libdw-dwarf-unwind),1) 312 NO_LIBDW_DWARF_UNWIND := 1 313 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR); 314 endif 315 endif 316 ifneq ($(feature-dwarf), 1) 317 ifndef NO_DWARF 318 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); 319 NO_DWARF := 1 320 endif 321 else 322 ifneq ($(feature-dwarf_getlocations), 1) 323 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157); 324 else 325 CFLAGS += -DHAVE_DWARF_GETLOCATIONS 326 endif # dwarf_getlocations 327 endif # Dwarf support 328 endif # libelf support 329endif # NO_LIBELF 330 331ifdef NO_DWARF 332 NO_LIBDW_DWARF_UNWIND := 1 333endif 334 335ifeq ($(feature-sched_getcpu), 1) 336 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT 337endif 338 339ifeq ($(feature-setns), 1) 340 CFLAGS += -DHAVE_SETNS_SUPPORT 341 $(call detected,CONFIG_SETNS) 342endif 343 344ifndef NO_LIBELF 345 CFLAGS += -DHAVE_LIBELF_SUPPORT 346 EXTLIBS += -lelf 347 $(call detected,CONFIG_LIBELF) 348 349 ifeq ($(feature-libelf-mmap), 1) 350 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT 351 endif 352 353 ifeq ($(feature-libelf-getphdrnum), 1) 354 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT 355 endif 356 357 ifeq ($(feature-libelf-gelf_getnote), 1) 358 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT 359 else 360 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled); 361 endif 362 363 ifeq ($(feature-libelf-getshdrstrndx), 1) 364 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT 365 endif 366 367 ifndef NO_DWARF 368 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) 369 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled); 370 NO_DWARF := 1 371 else 372 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) 373 LDFLAGS += $(LIBDW_LDFLAGS) 374 EXTLIBS += ${DWARFLIBS} 375 $(call detected,CONFIG_DWARF) 376 endif # PERF_HAVE_DWARF_REGS 377 endif # NO_DWARF 378 379 ifndef NO_LIBBPF 380 ifeq ($(feature-bpf), 1) 381 CFLAGS += -DHAVE_LIBBPF_SUPPORT 382 $(call detected,CONFIG_LIBBPF) 383 endif 384 385 ifndef NO_DWARF 386 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 387 CFLAGS += -DHAVE_BPF_PROLOGUE 388 $(call detected,CONFIG_BPF_PROLOGUE) 389 else 390 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset()); 391 endif 392 else 393 msg := $(warning DWARF support is off, BPF prologue is disabled); 394 endif 395 396 endif # NO_LIBBPF 397endif # NO_LIBELF 398 399ifndef NO_SDT 400 ifneq ($(feature-sdt), 1) 401 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev); 402 NO_SDT := 1; 403 else 404 CFLAGS += -DHAVE_SDT_EVENT 405 $(call detected,CONFIG_SDT_EVENT) 406 endif 407endif 408 409ifdef PERF_HAVE_JITDUMP 410 ifndef NO_LIBELF 411 $(call detected,CONFIG_JITDUMP) 412 CFLAGS += -DHAVE_JITDUMP 413 endif 414endif 415 416ifeq ($(SRCARCH),powerpc) 417 ifndef NO_DWARF 418 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX 419 endif 420endif 421 422ifndef NO_LIBUNWIND 423 have_libunwind := 424 425 ifeq ($(feature-libunwind-x86), 1) 426 $(call detected,CONFIG_LIBUNWIND_X86) 427 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT 428 LDFLAGS += -lunwind-x86 429 EXTLIBS_LIBUNWIND += -lunwind-x86 430 have_libunwind = 1 431 endif 432 433 ifeq ($(feature-libunwind-aarch64), 1) 434 $(call detected,CONFIG_LIBUNWIND_AARCH64) 435 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT 436 LDFLAGS += -lunwind-aarch64 437 EXTLIBS_LIBUNWIND += -lunwind-aarch64 438 have_libunwind = 1 439 $(call feature_check,libunwind-debug-frame-aarch64) 440 ifneq ($(feature-libunwind-debug-frame-aarch64), 1) 441 msg := $(warning No debug_frame support found in libunwind-aarch64); 442 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64 443 endif 444 endif 445 446 ifneq ($(feature-libunwind), 1) 447 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR); 448 NO_LOCAL_LIBUNWIND := 1 449 else 450 have_libunwind := 1 451 $(call detected,CONFIG_LOCAL_LIBUNWIND) 452 endif 453 454 ifneq ($(have_libunwind), 1) 455 NO_LIBUNWIND := 1 456 endif 457else 458 NO_LOCAL_LIBUNWIND := 1 459endif 460 461ifndef NO_LIBBPF 462 ifneq ($(feature-bpf), 1) 463 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.) 464 NO_LIBBPF := 1 465 endif 466endif 467 468dwarf-post-unwind := 1 469dwarf-post-unwind-text := BUG 470 471# setup DWARF post unwinder 472ifdef NO_LIBUNWIND 473 ifdef NO_LIBDW_DWARF_UNWIND 474 msg := $(warning Disabling post unwind, no support found.); 475 dwarf-post-unwind := 0 476 else 477 dwarf-post-unwind-text := libdw 478 $(call detected,CONFIG_LIBDW_DWARF_UNWIND) 479 endif 480else 481 dwarf-post-unwind-text := libunwind 482 $(call detected,CONFIG_LIBUNWIND) 483 # Enable libunwind support by default. 484 ifndef NO_LIBDW_DWARF_UNWIND 485 NO_LIBDW_DWARF_UNWIND := 1 486 endif 487endif 488 489ifeq ($(dwarf-post-unwind),1) 490 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT 491 $(call detected,CONFIG_DWARF_UNWIND) 492else 493 NO_DWARF_UNWIND := 1 494endif 495 496ifndef NO_LOCAL_LIBUNWIND 497 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64)) 498 $(call feature_check,libunwind-debug-frame) 499 ifneq ($(feature-libunwind-debug-frame), 1) 500 msg := $(warning No debug_frame support found in libunwind); 501 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 502 endif 503 else 504 # non-ARM has no dwarf_find_debug_frame() function: 505 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 506 endif 507 EXTLIBS += $(LIBUNWIND_LIBS) 508 LDFLAGS += $(LIBUNWIND_LIBS) 509endif 510ifeq ($(findstring -static,${LDFLAGS}),-static) 511 # gcc -static links libgcc_eh which contans piece of libunwind 512 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition 513endif 514 515ifndef NO_LIBUNWIND 516 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT 517 CFLAGS += $(LIBUNWIND_CFLAGS) 518 LDFLAGS += $(LIBUNWIND_LDFLAGS) 519 EXTLIBS += $(EXTLIBS_LIBUNWIND) 520endif 521 522ifndef NO_LIBAUDIT 523 ifneq ($(feature-libaudit), 1) 524 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); 525 NO_LIBAUDIT := 1 526 else 527 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT 528 EXTLIBS += -laudit 529 $(call detected,CONFIG_AUDIT) 530 endif 531endif 532 533ifndef NO_LIBCRYPTO 534 ifneq ($(feature-libcrypto), 1) 535 msg := $(warning No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev); 536 NO_LIBCRYPTO := 1 537 else 538 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT 539 EXTLIBS += -lcrypto 540 $(call detected,CONFIG_CRYPTO) 541 endif 542endif 543 544ifdef NO_NEWT 545 NO_SLANG=1 546endif 547 548ifndef NO_SLANG 549 ifneq ($(feature-libslang), 1) 550 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev); 551 NO_SLANG := 1 552 else 553 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h 554 CFLAGS += -I/usr/include/slang 555 CFLAGS += -DHAVE_SLANG_SUPPORT 556 EXTLIBS += -lslang 557 $(call detected,CONFIG_SLANG) 558 endif 559endif 560 561ifndef NO_GTK2 562 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) 563 ifneq ($(feature-gtk2), 1) 564 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); 565 NO_GTK2 := 1 566 else 567 ifeq ($(feature-gtk2-infobar), 1) 568 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT 569 endif 570 CFLAGS += -DHAVE_GTK2_SUPPORT 571 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null) 572 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null) 573 EXTLIBS += -ldl 574 endif 575endif 576 577ifdef NO_LIBPERL 578 CFLAGS += -DNO_LIBPERL 579else 580 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) 581 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) 582 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) 583 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) 584 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) 585 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) 586 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) 587 588 ifneq ($(feature-libperl), 1) 589 CFLAGS += -DNO_LIBPERL 590 NO_LIBPERL := 1 591 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev); 592 else 593 LDFLAGS += $(PERL_EMBED_LDFLAGS) 594 EXTLIBS += $(PERL_EMBED_LIBADD) 595 $(call detected,CONFIG_LIBPERL) 596 endif 597endif 598 599ifeq ($(feature-timerfd), 1) 600 CFLAGS += -DHAVE_TIMERFD_SUPPORT 601else 602 msg := $(warning No timerfd support. Disables 'perf kvm stat live'); 603endif 604 605disable-python = $(eval $(disable-python_code)) 606define disable-python_code 607 CFLAGS += -DNO_LIBPYTHON 608 $(warning $1) 609 NO_LIBPYTHON := 1 610endef 611 612ifdef NO_LIBPYTHON 613 $(call disable-python,Python support disabled by user) 614else 615 616 ifndef PYTHON 617 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev) 618 else 619 PYTHON_WORD := $(call shell-wordify,$(PYTHON)) 620 621 ifndef PYTHON_CONFIG 622 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev) 623 else 624 625 ifneq ($(feature-libpython), 1) 626 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev) 627 else 628 ifneq ($(feature-libpython-version), 1) 629 $(warning Python 3 is not yet supported; please set) 630 $(warning PYTHON and/or PYTHON_CONFIG appropriately.) 631 $(warning If you also have Python 2 installed, then) 632 $(warning try something like:) 633 $(warning $(and ,)) 634 $(warning $(and ,) make PYTHON=python2) 635 $(warning $(and ,)) 636 $(warning Otherwise, disable Python support entirely:) 637 $(warning $(and ,)) 638 $(warning $(and ,) make NO_LIBPYTHON=1) 639 $(warning $(and ,)) 640 $(error $(and ,)) 641 else 642 LDFLAGS += $(PYTHON_EMBED_LDFLAGS) 643 EXTLIBS += $(PYTHON_EMBED_LIBADD) 644 LANG_BINDINGS += $(obj-perf)python/perf.so 645 $(call detected,CONFIG_LIBPYTHON) 646 endif 647 endif 648 endif 649 endif 650endif 651 652ifeq ($(feature-libbfd), 1) 653 EXTLIBS += -lbfd 654 655 # call all detections now so we get correct 656 # status in VF output 657 $(call feature_check,liberty) 658 $(call feature_check,liberty-z) 659 $(call feature_check,cplus-demangle) 660 661 ifeq ($(feature-liberty), 1) 662 EXTLIBS += -liberty 663 else 664 ifeq ($(feature-liberty-z), 1) 665 EXTLIBS += -liberty -lz 666 endif 667 endif 668endif 669 670ifdef NO_DEMANGLE 671 CFLAGS += -DNO_DEMANGLE 672else 673 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT 674 EXTLIBS += -liberty 675 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 676 else 677 ifneq ($(feature-libbfd), 1) 678 ifneq ($(feature-liberty), 1) 679 ifneq ($(feature-liberty-z), 1) 680 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT 681 # or any of 'bfd iberty z' trinity 682 ifeq ($(feature-cplus-demangle), 1) 683 EXTLIBS += -liberty 684 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 685 else 686 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling) 687 CFLAGS += -DNO_DEMANGLE 688 endif 689 endif 690 endif 691 endif 692 endif 693endif 694 695ifneq ($(filter -lbfd,$(EXTLIBS)),) 696 CFLAGS += -DHAVE_LIBBFD_SUPPORT 697endif 698 699ifndef NO_ZLIB 700 ifeq ($(feature-zlib), 1) 701 CFLAGS += -DHAVE_ZLIB_SUPPORT 702 EXTLIBS += -lz 703 $(call detected,CONFIG_ZLIB) 704 else 705 NO_ZLIB := 1 706 endif 707endif 708 709ifndef NO_LZMA 710 ifeq ($(feature-lzma), 1) 711 CFLAGS += -DHAVE_LZMA_SUPPORT 712 EXTLIBS += -llzma 713 $(call detected,CONFIG_LZMA) 714 else 715 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev); 716 NO_LZMA := 1 717 endif 718endif 719 720ifndef NO_BACKTRACE 721 ifeq ($(feature-backtrace), 1) 722 CFLAGS += -DHAVE_BACKTRACE_SUPPORT 723 endif 724endif 725 726ifndef NO_LIBNUMA 727 ifeq ($(feature-libnuma), 0) 728 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev); 729 NO_LIBNUMA := 1 730 else 731 ifeq ($(feature-numa_num_possible_cpus), 0) 732 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8); 733 NO_LIBNUMA := 1 734 else 735 CFLAGS += -DHAVE_LIBNUMA_SUPPORT 736 EXTLIBS += -lnuma 737 $(call detected,CONFIG_NUMA) 738 endif 739 endif 740endif 741 742ifdef HAVE_KVM_STAT_SUPPORT 743 CFLAGS += -DHAVE_KVM_STAT_SUPPORT 744endif 745 746ifeq (${IS_64_BIT}, 1) 747 ifndef NO_PERF_READ_VDSO32 748 $(call feature_check,compile-32) 749 ifeq ($(feature-compile-32), 1) 750 CFLAGS += -DHAVE_PERF_READ_VDSO32 751 else 752 NO_PERF_READ_VDSO32 := 1 753 endif 754 endif 755 ifneq ($(SRCARCH), x86) 756 NO_PERF_READ_VDSOX32 := 1 757 endif 758 ifndef NO_PERF_READ_VDSOX32 759 $(call feature_check,compile-x32) 760 ifeq ($(feature-compile-x32), 1) 761 CFLAGS += -DHAVE_PERF_READ_VDSOX32 762 else 763 NO_PERF_READ_VDSOX32 := 1 764 endif 765 endif 766else 767 NO_PERF_READ_VDSO32 := 1 768 NO_PERF_READ_VDSOX32 := 1 769endif 770 771ifdef LIBBABELTRACE 772 $(call feature_check,libbabeltrace) 773 ifeq ($(feature-libbabeltrace), 1) 774 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS) 775 LDFLAGS += $(LIBBABELTRACE_LDFLAGS) 776 EXTLIBS += -lbabeltrace-ctf 777 $(call detected,CONFIG_LIBBABELTRACE) 778 else 779 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev); 780 endif 781endif 782 783ifndef NO_AUXTRACE 784 ifeq ($(SRCARCH),x86) 785 ifeq ($(feature-get_cpuid), 0) 786 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); 787 NO_AUXTRACE := 1 788 endif 789 endif 790 ifndef NO_AUXTRACE 791 $(call detected,CONFIG_AUXTRACE) 792 CFLAGS += -DHAVE_AUXTRACE_SUPPORT 793 endif 794endif 795 796ifndef NO_JVMTI 797 ifneq (,$(wildcard /usr/sbin/update-java-alternatives)) 798 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}') 799 else 800 ifneq (,$(wildcard /usr/sbin/alternatives)) 801 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g') 802 endif 803 endif 804 ifndef JDIR 805 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory) 806 NO_JVMTI := 1 807 endif 808endif 809 810ifndef NO_JVMTI 811 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux 812 $(call feature_check,jvmti) 813 ifeq ($(feature-jvmti), 1) 814 $(call detected_var,JDIR) 815 else 816 $(warning No openjdk development package found, please install JDK package) 817 NO_JVMTI := 1 818 endif 819endif 820 821USE_CXX = 0 822USE_CLANGLLVM = 0 823ifdef LIBCLANGLLVM 824 $(call feature_check,cxx) 825 ifneq ($(feature-cxx), 1) 826 msg := $(warning No g++ found, disable clang and llvm support. Please install g++) 827 else 828 $(call feature_check,llvm) 829 $(call feature_check,llvm-version) 830 ifneq ($(feature-llvm), 1) 831 msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0)) 832 else 833 $(call feature_check,clang) 834 ifneq ($(feature-clang), 1) 835 msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0)) 836 else 837 CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT 838 CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir) 839 $(call detected,CONFIG_CXX) 840 $(call detected,CONFIG_CLANGLLVM) 841 USE_CXX = 1 842 USE_LLVM = 1 843 USE_CLANG = 1 844 ifneq ($(feature-llvm-version),1) 845 msg := $(warning This version of LLVM is not tested. May cause build errors) 846 endif 847 endif 848 endif 849 endif 850endif 851 852# Among the variables below, these: 853# perfexecdir 854# template_dir 855# mandir 856# infodir 857# htmldir 858# ETC_PERFCONFIG (but not sysconfdir) 859# can be specified as a relative path some/where/else; 860# this is interpreted as relative to $(prefix) and "perf" at 861# runtime figures out where they are based on the path to the executable. 862# This can help installing the suite in a relocatable way. 863 864# Make the path relative to DESTDIR, not to prefix 865ifndef DESTDIR 866prefix ?= $(HOME) 867endif 868bindir_relative = bin 869bindir = $(abspath $(prefix)/$(bindir_relative)) 870mandir = share/man 871infodir = share/info 872perfexecdir = libexec/perf-core 873sharedir = $(prefix)/share 874template_dir = share/perf-core/templates 875STRACE_GROUPS_DIR = share/perf-core/strace/groups 876htmldir = share/doc/perf-doc 877tipdir = share/doc/perf-tip 878srcdir = $(srctree)/tools/perf 879ifeq ($(prefix),/usr) 880sysconfdir = /etc 881ETC_PERFCONFIG = $(sysconfdir)/perfconfig 882else 883sysconfdir = $(prefix)/etc 884ETC_PERFCONFIG = etc/perfconfig 885endif 886ifndef lib 887ifeq ($(SRCARCH)$(IS_64_BIT), x861) 888lib = lib64 889else 890lib = lib 891endif 892endif # lib 893libdir = $(prefix)/$(lib) 894 895# Shell quote (do not use $(call) to accommodate ancient setups); 896ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) 897STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR)) 898DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) 899bindir_SQ = $(subst ','\'',$(bindir)) 900mandir_SQ = $(subst ','\'',$(mandir)) 901infodir_SQ = $(subst ','\'',$(infodir)) 902perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) 903template_dir_SQ = $(subst ','\'',$(template_dir)) 904htmldir_SQ = $(subst ','\'',$(htmldir)) 905tipdir_SQ = $(subst ','\'',$(tipdir)) 906prefix_SQ = $(subst ','\'',$(prefix)) 907sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) 908libdir_SQ = $(subst ','\'',$(libdir)) 909srcdir_SQ = $(subst ','\'',$(srcdir)) 910 911ifneq ($(filter /%,$(firstword $(perfexecdir))),) 912perfexec_instdir = $(perfexecdir) 913STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR) 914tip_instdir = $(tipdir) 915else 916perfexec_instdir = $(prefix)/$(perfexecdir) 917STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR) 918tip_instdir = $(prefix)/$(tipdir) 919endif 920perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) 921STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR)) 922tip_instdir_SQ = $(subst ','\'',$(tip_instdir)) 923 924# If we install to $(HOME) we keep the traceevent default: 925# $(HOME)/.traceevent/plugins 926# Otherwise we install plugins into the global $(libdir). 927ifdef DESTDIR 928plugindir=$(libdir)/traceevent/plugins 929plugindir_SQ= $(subst ','\'',$(plugindir)) 930endif 931 932print_var = $(eval $(print_var_code)) $(info $(MSG)) 933define print_var_code 934 MSG = $(shell printf '...%30s: %s' $(1) $($(1))) 935endef 936 937ifeq ($(VF),1) 938 $(call print_var,prefix) 939 $(call print_var,bindir) 940 $(call print_var,libdir) 941 $(call print_var,sysconfdir) 942 $(call print_var,LIBUNWIND_DIR) 943 $(call print_var,LIBDW_DIR) 944 $(call print_var,JDIR) 945 946 ifeq ($(dwarf-post-unwind),1) 947 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) 948 endif 949 $(info ) 950endif 951 952$(call detected_var,bindir_SQ) 953$(call detected_var,PYTHON_WORD) 954ifneq ($(OUTPUT),) 955$(call detected_var,OUTPUT) 956endif 957$(call detected_var,htmldir_SQ) 958$(call detected_var,infodir_SQ) 959$(call detected_var,mandir_SQ) 960$(call detected_var,ETC_PERFCONFIG_SQ) 961$(call detected_var,STRACE_GROUPS_DIR_SQ) 962$(call detected_var,prefix_SQ) 963$(call detected_var,perfexecdir_SQ) 964$(call detected_var,tipdir_SQ) 965$(call detected_var,srcdir_SQ) 966$(call detected_var,LIBDIR) 967$(call detected_var,GTK_CFLAGS) 968$(call detected_var,PERL_EMBED_CCOPTS) 969$(call detected_var,PYTHON_EMBED_CCOPTS) 970