diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-06-09 15:57:39 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-06-09 15:57:39 -0400 |
commit | f9af3a4c1f59753bdd5a49e3a34263005f96972e (patch) | |
tree | f6e773d22c83f550367931fd4fe7fb0b3d2e30d7 /tools/perf/Makefile | |
parent | c726b61c6a5acc54c55ed7a0e7638cc4c5a100a8 (diff) |
perf tools: Reorganize the Makefile feature tests
Moving the tests to a separate file, feature-tests.mak and using a try-cc
function similar to the try-run in Kbuild.
This also makes the output more quiet as we can stop using the INTERMEDIATE
target to remove the .perf.dev.null file needed for some gcc versions where
/dev/null can't be used as the output file name.
As the tests get shorter by uninlining the source code used to test for
features, we can more properly use identation.
The feature tests itself can be made more clear and reused, like when trying to
see what is needed to have bfd_demangle.
We also get a bit closer to reusing scripts/Kbuild.include, reducing the
distance from the kernel build system.
Tests performed:
[root@emilia perf]# make -j9 O=/tmp/perf
PERF_VERSION = 0.0.2.PERF
GEN /tmp/perf/common-cmds.h
* new build flags or prefix
GEN perf-archive
CC /tmp/perf/builtin-annotate.o
CC /tmp/perf/bench/sched-messaging.o
CC /tmp/perf/builtin-diff.o
<SNIP>
CC /tmp/perf/scripts/python/Perf-Trace-Util/Context.o
CC /tmp/perf/perf.o
CC /tmp/perf/builtin-help.o
AR /tmp/perf/libperf.a
LINK /tmp/perf/perf
[root@emilia perf]#
If we uninstall, for instance newt-devel we get:
[root@emilia perf]# rpm -e newt-devel
[root@emilia perf]# make -j9 O=/tmp/perf
Makefile:564: newt not found, disables TUI support. Please install newt-devel or libnewt-dev
* new build flags or prefix
GEN perf-archive
CC /tmp/perf/perf.o
CC /tmp/perf/builtin-annotate.o
<SNIP>
AR /tmp/perf/libperf.a
LINK /tmp/perf/perf
[root@emilia perf]#
And then binutils-devel:
[root@emilia perf]# make -j9 O=/tmp/perf
Makefile:564: newt not found, disables TUI support. Please install newt-devel or libnewt-dev
Makefile:632: No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling
* new build flags or prefix
GEN perf-archive
CC /tmp/perf/perf.o
<SNIP>
AR /tmp/perf/libperf.a
LINK /tmp/perf/perf
[root@emilia perf]#
And then strictly required devel packages:
[root@emilia perf]# rpm -e elfutils-libelf-devel elfutils-devel
[root@emilia perf]# make -j9 O=/tmp/perf
Makefile:509: 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
Makefile:542: *** No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel. Stop.
[root@emilia perf]#
After installing everything back on:
[root@emilia perf]# yum install elfutils-devel binutils-devel newt-devel
<SNIP>
Installed:
binutils-devel.x86_64 0:2.20.51.0.2-5.11.el6
elfutils-devel.x86_64 0:0.147-1.el6
elfutils-libelf-devel.x86_64 0:0.147-1.el6
newt-devel.x86_64 0:0.52.11-1.el6
Complete!
[root@emilia perf]# make -j9
PERF_VERSION = 0.0.2.PERF
GEN common-cmds.h
* new build flags or prefix
GEN perf-archive
CC builtin-annotate.o
<SNIP>
AR libperf.a
LINK perf
[root@emilia perf]# make -j9
[root@emilia perf]#
Thanks to Sam for pointing me to try-run.
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/Makefile')
-rw-r--r-- | tools/perf/Makefile | 109 |
1 files changed, 56 insertions, 53 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 3d8f31ed771d..6aa2fe323db1 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,41 +560,47 @@ 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 | PERL_EMBED_FLAGS=$(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 |
@@ -604,20 +609,23 @@ else ifdef HAVE_CPLUS_DEMANGLE | |||
604 | EXTLIBS += -liberty | 609 | EXTLIBS += -liberty |
605 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | 610 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE |
606 | else | 611 | else |
607 | 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") | 612 | FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd |
608 | 613 | has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD)) | |
609 | ifeq ($(has_bfd),y) | 614 | ifeq ($(has_bfd),y) |
610 | EXTLIBS += -lbfd | 615 | EXTLIBS += -lbfd |
611 | else | 616 | else |
612 | 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") | 617 | FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty |
618 | has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY)) | ||
613 | ifeq ($(has_bfd_iberty),y) | 619 | ifeq ($(has_bfd_iberty),y) |
614 | EXTLIBS += -lbfd -liberty | 620 | EXTLIBS += -lbfd -liberty |
615 | else | 621 | else |
616 | 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") | 622 | FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz |
623 | has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z)) | ||
617 | ifeq ($(has_bfd_iberty_z),y) | 624 | ifeq ($(has_bfd_iberty_z),y) |
618 | EXTLIBS += -lbfd -liberty -lz | 625 | EXTLIBS += -lbfd -liberty -lz |
619 | else | 626 | else |
620 | 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") | 627 | FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty |
628 | has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE)) | ||
621 | ifeq ($(has_cplus_demangle),y) | 629 | ifeq ($(has_cplus_demangle),y) |
622 | EXTLIBS += -liberty | 630 | EXTLIBS += -liberty |
623 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | 631 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE |
@@ -865,7 +873,7 @@ export TAR INSTALL DESTDIR SHELL_PATH | |||
865 | 873 | ||
866 | SHELL = $(SHELL_PATH) | 874 | SHELL = $(SHELL_PATH) |
867 | 875 | ||
868 | all:: .perf.dev.null shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS | 876 | all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS |
869 | ifneq (,$X) | 877 | ifneq (,$X) |
870 | $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';) | 878 | $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';) |
871 | endif | 879 | endif |
@@ -1195,11 +1203,6 @@ clean: | |||
1195 | .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS | 1203 | .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS |
1196 | .PHONY: .FORCE-PERF-BUILD-OPTIONS | 1204 | .PHONY: .FORCE-PERF-BUILD-OPTIONS |
1197 | 1205 | ||
1198 | .perf.dev.null: | ||
1199 | touch .perf.dev.null | ||
1200 | |||
1201 | .INTERMEDIATE: .perf.dev.null | ||
1202 | |||
1203 | ### Make sure built-ins do not have dups and listed in perf.c | 1206 | ### Make sure built-ins do not have dups and listed in perf.c |
1204 | # | 1207 | # |
1205 | check-builtins:: | 1208 | check-builtins:: |