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