diff options
Diffstat (limited to 'tools/perf/Makefile')
-rw-r--r-- | tools/perf/Makefile | 113 |
1 files changed, 58 insertions, 55 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index d75c28a825f5..26f626d45a9e 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -285,14 +285,10 @@ else | |||
285 | QUIET_STDERR = ">/dev/null 2>&1" | 285 | QUIET_STDERR = ">/dev/null 2>&1" |
286 | endif | 286 | endif |
287 | 287 | ||
288 | BITBUCKET = "/dev/null" | 288 | -include feature-tests.mak |
289 | 289 | ||
290 | ifneq ($(shell sh -c "(echo '\#include <stdio.h>'; echo 'int main(void) { return puts(\"hi\"); }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y) | 290 | ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y) |
291 | BITBUCKET = .perf.dev.null | 291 | CFLAGS := $(CFLAGS) -fstack-protector-all |
292 | endif | ||
293 | |||
294 | ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y) | ||
295 | CFLAGS := $(CFLAGS) -fstack-protector-all | ||
296 | endif | 292 | endif |
297 | 293 | ||
298 | 294 | ||
@@ -508,7 +504,8 @@ PERFLIBS = $(LIB_FILE) | |||
508 | -include config.mak | 504 | -include config.mak |
509 | 505 | ||
510 | ifndef NO_DWARF | 506 | ifndef NO_DWARF |
511 | ifneq ($(shell sh -c "(echo '\#include <dwarf.h>'; echo '\#include <libdw.h>'; echo '\#include <version.h>'; echo '\#ifndef _ELFUTILS_PREREQ'; echo '\#error'; echo '\#endif'; echo 'int main(void) { Dwarf *dbg; dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -I/usr/include/elfutils -ldw -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 507 | FLAGS_DWARF=$(ALL_CFLAGS) -I/usr/include/elfutils -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS) |
508 | ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y) | ||
512 | 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); | 509 | 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); |
513 | NO_DWARF := 1 | 510 | NO_DWARF := 1 |
514 | endif # Dwarf support | 511 | endif # Dwarf support |
@@ -536,16 +533,18 @@ ifneq ($(OUTPUT),) | |||
536 | BASIC_CFLAGS += -I$(OUTPUT) | 533 | BASIC_CFLAGS += -I$(OUTPUT) |
537 | endif | 534 | endif |
538 | 535 | ||
539 | ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 536 | FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) |
540 | ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 537 | ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y) |
541 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); | 538 | FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS) |
539 | ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y) | ||
540 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); | ||
541 | else | ||
542 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel); | ||
543 | endif | ||
542 | endif | 544 | endif |
543 | 545 | ||
544 | ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 546 | ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) |
545 | BASIC_CFLAGS += -DLIBELF_NO_MMAP | 547 | BASIC_CFLAGS += -DLIBELF_NO_MMAP |
546 | endif | ||
547 | else | ||
548 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); | ||
549 | endif | 548 | endif |
550 | 549 | ||
551 | ifndef NO_DWARF | 550 | ifndef NO_DWARF |
@@ -561,64 +560,73 @@ endif # NO_DWARF | |||
561 | ifdef NO_NEWT | 560 | ifdef NO_NEWT |
562 | BASIC_CFLAGS += -DNO_NEWT_SUPPORT | 561 | BASIC_CFLAGS += -DNO_NEWT_SUPPORT |
563 | else | 562 | else |
564 | ifneq ($(shell sh -c "(echo '\#include <newt.h>'; echo 'int main(void) { newtInit(); newtCls(); return newtFinished(); }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -lnewt -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 563 | FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt |
565 | msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev); | 564 | ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y) |
566 | BASIC_CFLAGS += -DNO_NEWT_SUPPORT | 565 | msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev); |
567 | else | 566 | BASIC_CFLAGS += -DNO_NEWT_SUPPORT |
568 | # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h | 567 | else |
569 | BASIC_CFLAGS += -I/usr/include/slang | 568 | # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h |
570 | EXTLIBS += -lnewt -lslang | 569 | BASIC_CFLAGS += -I/usr/include/slang |
571 | LIB_OBJS += $(OUTPUT)util/newt.o | 570 | EXTLIBS += -lnewt -lslang |
572 | endif | 571 | LIB_OBJS += $(OUTPUT)util/newt.o |
573 | endif # NO_NEWT | 572 | endif |
574 | |||
575 | ifndef NO_LIBPERL | ||
576 | PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null` | ||
577 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` | ||
578 | endif | 573 | endif |
579 | 574 | ||
580 | ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o $(BITBUCKET) $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y) | 575 | ifdef NO_LIBPERL |
581 | BASIC_CFLAGS += -DNO_LIBPERL | 576 | BASIC_CFLAGS += -DNO_LIBPERL |
582 | else | 577 | else |
583 | ALL_LDFLAGS += $(PERL_EMBED_LDOPTS) | 578 | PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null` |
584 | LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o | 579 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` |
585 | LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o | 580 | FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) |
586 | endif | ||
587 | 581 | ||
588 | ifndef NO_LIBPYTHON | 582 | ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y) |
589 | PYTHON_EMBED_LDOPTS = `python-config --ldflags 2>/dev/null` | 583 | BASIC_CFLAGS += -DNO_LIBPERL |
590 | PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null` | 584 | else |
585 | ALL_LDFLAGS += $(PERL_EMBED_LDOPTS) | ||
586 | LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o | ||
587 | LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o | ||
588 | endif | ||
591 | endif | 589 | endif |
592 | 590 | ||
593 | ifneq ($(shell sh -c "(echo '\#include <Python.h>'; echo 'int main(void) { Py_Initialize(); return 0; }') | $(CC) -x c - $(PYTHON_EMBED_CCOPTS) -o $(BITBUCKET) $(PYTHON_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y) | 591 | ifdef NO_LIBPYTHON |
594 | BASIC_CFLAGS += -DNO_LIBPYTHON | 592 | BASIC_CFLAGS += -DNO_LIBPYTHON |
595 | else | 593 | else |
596 | ALL_LDFLAGS += $(PYTHON_EMBED_LDOPTS) | 594 | PYTHON_EMBED_LDOPTS = `python-config --ldflags 2>/dev/null` |
597 | LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o | 595 | PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null` |
598 | LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o | 596 | FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) |
597 | ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y) | ||
598 | BASIC_CFLAGS += -DNO_LIBPYTHON | ||
599 | else | ||
600 | ALL_LDFLAGS += $(PYTHON_EMBED_LDOPTS) | ||
601 | LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o | ||
602 | LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o | ||
603 | endif | ||
599 | endif | 604 | endif |
600 | 605 | ||
601 | ifdef NO_DEMANGLE | 606 | ifdef NO_DEMANGLE |
602 | BASIC_CFLAGS += -DNO_DEMANGLE | 607 | BASIC_CFLAGS += -DNO_DEMANGLE |
603 | else | 608 | else |
604 | ifdef HAVE_CPLUS_DEMANGLE | 609 | ifdef HAVE_CPLUS_DEMANGLE |
605 | EXTLIBS += -liberty | 610 | EXTLIBS += -liberty |
606 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | 611 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE |
607 | else | 612 | else |
608 | has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y") | 613 | FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd |
609 | 614 | has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD)) | |
610 | ifeq ($(has_bfd),y) | 615 | ifeq ($(has_bfd),y) |
611 | EXTLIBS += -lbfd | 616 | EXTLIBS += -lbfd |
612 | else | 617 | else |
613 | has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y") | 618 | FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty |
619 | has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY)) | ||
614 | ifeq ($(has_bfd_iberty),y) | 620 | ifeq ($(has_bfd_iberty),y) |
615 | EXTLIBS += -lbfd -liberty | 621 | EXTLIBS += -lbfd -liberty |
616 | else | 622 | else |
617 | has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y") | 623 | FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz |
624 | has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z)) | ||
618 | ifeq ($(has_bfd_iberty_z),y) | 625 | ifeq ($(has_bfd_iberty_z),y) |
619 | EXTLIBS += -lbfd -liberty -lz | 626 | EXTLIBS += -lbfd -liberty -lz |
620 | else | 627 | else |
621 | has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y") | 628 | FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty |
629 | has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE)) | ||
622 | ifeq ($(has_cplus_demangle),y) | 630 | ifeq ($(has_cplus_demangle),y) |
623 | EXTLIBS += -liberty | 631 | EXTLIBS += -liberty |
624 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | 632 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE |
@@ -867,7 +875,7 @@ export TAR INSTALL DESTDIR SHELL_PATH | |||
867 | 875 | ||
868 | SHELL = $(SHELL_PATH) | 876 | SHELL = $(SHELL_PATH) |
869 | 877 | ||
870 | all:: .perf.dev.null shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS | 878 | all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS |
871 | ifneq (,$X) | 879 | ifneq (,$X) |
872 | $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';) | 880 | $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';) |
873 | endif | 881 | endif |
@@ -1197,11 +1205,6 @@ clean: | |||
1197 | .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS | 1205 | .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS |
1198 | .PHONY: .FORCE-PERF-BUILD-OPTIONS | 1206 | .PHONY: .FORCE-PERF-BUILD-OPTIONS |
1199 | 1207 | ||
1200 | .perf.dev.null: | ||
1201 | touch .perf.dev.null | ||
1202 | |||
1203 | .INTERMEDIATE: .perf.dev.null | ||
1204 | |||
1205 | ### Make sure built-ins do not have dups and listed in perf.c | 1208 | ### Make sure built-ins do not have dups and listed in perf.c |
1206 | # | 1209 | # |
1207 | check-builtins:: | 1210 | check-builtins:: |