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