diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2009-10-29 11:20:02 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-17 04:18:15 -0500 |
commit | 751386507701010831d72c522171753d2cd903d2 (patch) | |
tree | 5d834aca33db0fac7fb5dce032d289a3ce6bdea2 /tools/perf/Makefile | |
parent | a7b63425a41cd6a8d50f76fef0660c5110f97e91 (diff) |
perf tools: Support static build
This makes it possible to build perf statically, by
performing:
make LDFLAGS=-static
Since static libraries are only searched in the order they are
specified, move library list from LDFLAGS to EXTLIBS, so that
they are put at the end of linker command line.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <20091029152002.GA5406@redhat.com>
[ v2: resolved conflicts ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/Makefile')
-rw-r--r-- | tools/perf/Makefile | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 3dbb5c5bb8c6..5d1a8b0dff8f 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -145,6 +145,8 @@ all:: | |||
145 | # Define NO_EXTERNAL_GREP if you don't want "perf grep" to ever call | 145 | # Define NO_EXTERNAL_GREP if you don't want "perf grep" to ever call |
146 | # your external grep (e.g., if your system lacks grep, if its grep is | 146 | # your external grep (e.g., if your system lacks grep, if its grep is |
147 | # broken, or spawning external process is slower than built-in grep perf has). | 147 | # broken, or spawning external process is slower than built-in grep perf has). |
148 | # | ||
149 | # Define LDFLAGS=-static to build a static binary. | ||
148 | 150 | ||
149 | PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE | 151 | PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE |
150 | @$(SHELL_PATH) util/PERF-VERSION-GEN | 152 | @$(SHELL_PATH) util/PERF-VERSION-GEN |
@@ -208,7 +210,7 @@ ifndef PERF_DEBUG | |||
208 | endif | 210 | endif |
209 | 211 | ||
210 | CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) | 212 | CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) |
211 | LDFLAGS = -lpthread -lrt -lelf -lm | 213 | EXTLIBS = -lpthread -lrt -lelf -lm |
212 | ALL_CFLAGS = $(CFLAGS) | 214 | ALL_CFLAGS = $(CFLAGS) |
213 | ALL_LDFLAGS = $(LDFLAGS) | 215 | ALL_LDFLAGS = $(LDFLAGS) |
214 | STRIP ?= strip | 216 | STRIP ?= strip |
@@ -470,19 +472,19 @@ ifeq ($(uname_S),Darwin) | |||
470 | PTHREAD_LIBS = | 472 | PTHREAD_LIBS = |
471 | endif | 473 | endif |
472 | 474 | ||
473 | 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) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) | 475 | 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) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) > /dev/null 2>&1 && echo y"), y) |
474 | 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) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) | 476 | 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) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) > /dev/null 2>&1 && echo y"), y) |
475 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]); | 477 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]); |
476 | endif | 478 | endif |
477 | 479 | ||
478 | 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) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) | 480 | 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) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) > /dev/null 2>&1 && echo y"), y) |
479 | BASIC_CFLAGS += -DLIBELF_NO_MMAP | 481 | BASIC_CFLAGS += -DLIBELF_NO_MMAP |
480 | endif | 482 | endif |
481 | else | 483 | else |
482 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); | 484 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); |
483 | endif | 485 | endif |
484 | 486 | ||
485 | ifneq ($(shell sh -c "(echo '\#include <libdwarf/dwarf.h>'; echo '\#include <libdwarf/libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) | 487 | ifneq ($(shell sh -c "(echo '\#include <libdwarf/dwarf.h>'; echo '\#include <libdwarf/libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) > /dev/null 2>&1 && echo y"), y) |
486 | msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231); | 488 | msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231); |
487 | BASIC_CFLAGS += -DNO_LIBDWARF | 489 | BASIC_CFLAGS += -DNO_LIBDWARF |
488 | else | 490 | else |
@@ -494,20 +496,20 @@ endif | |||
494 | ifdef NO_DEMANGLE | 496 | ifdef NO_DEMANGLE |
495 | BASIC_CFLAGS += -DNO_DEMANGLE | 497 | BASIC_CFLAGS += -DNO_DEMANGLE |
496 | else | 498 | else |
497 | 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 /dev/null $(ALL_LDFLAGS) -lbfd > /dev/null 2>&1 && echo y") | 499 | 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 /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd > /dev/null 2>&1 && echo y") |
498 | 500 | ||
499 | ifeq ($(has_bfd),y) | 501 | ifeq ($(has_bfd),y) |
500 | EXTLIBS += -lbfd | 502 | EXTLIBS += -lbfd |
501 | else | 503 | else |
502 | 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 /dev/null $(ALL_LDFLAGS) -lbfd -liberty > /dev/null 2>&1 && echo y") | 504 | 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 /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty > /dev/null 2>&1 && echo y") |
503 | ifeq ($(has_bfd_iberty),y) | 505 | ifeq ($(has_bfd_iberty),y) |
504 | EXTLIBS += -lbfd -liberty | 506 | EXTLIBS += -lbfd -liberty |
505 | else | 507 | else |
506 | 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 /dev/null $(ALL_LDFLAGS) -lbfd -liberty -lz > /dev/null 2>&1 && echo y") | 508 | 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 /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz > /dev/null 2>&1 && echo y") |
507 | ifeq ($(has_bfd_iberty_z),y) | 509 | ifeq ($(has_bfd_iberty_z),y) |
508 | EXTLIBS += -lbfd -liberty -lz | 510 | EXTLIBS += -lbfd -liberty -lz |
509 | else | 511 | else |
510 | 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 /dev/null $(ALL_LDFLAGS) -liberty > /dev/null 2>&1 && echo y") | 512 | 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 /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -liberty > /dev/null 2>&1 && echo y") |
511 | ifeq ($(has_cplus_demangle),y) | 513 | ifeq ($(has_cplus_demangle),y) |
512 | EXTLIBS += -liberty | 514 | EXTLIBS += -liberty |
513 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | 515 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE |