blob: 9b8421805c5ca465a954ef6624ca63101a5af312 [file] [log] [blame]
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -03001ifeq ("$(origin O)", "command line")
2 OUTPUT := $(O)/
3endif
4
Ingo Molnard24e4732009-04-20 13:32:07 +02005# The default target of this Makefile is...
Michael Wittena3d1ee12011-02-02 14:22:08 -06006all:
Ingo Molnare0143ba2009-03-23 21:29:59 +01007
Kusanagi Kouichiecafda62010-08-18 13:32:37 -03008ifneq ($(OUTPUT),)
9# check that the output directory actually exists
10OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
11$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
12endif
13
Michael Wittena3d1ee12011-02-02 14:22:08 -060014# Define V to have a more verbose compile.
Ingo Molnard24e4732009-04-20 13:32:07 +020015#
Ingo Molnard24e4732009-04-20 13:32:07 +020016# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
17#
18# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
19#
Michael S. Tsirkin75138652009-10-29 17:20:02 +020020# Define LDFLAGS=-static to build a static binary.
Michael S. Tsirkin81516c52009-11-22 14:13:35 +020021#
22# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
Masami Hiramatsuca721e42010-03-22 13:10:27 -030023#
24# Define NO_DWARF if you do not want debug-info analysis feature at all.
Ingo Molnare0143ba2009-03-23 21:29:59 +010025
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -030026$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
27 @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
28-include $(OUTPUT)PERF-VERSION-FILE
Ingo Molnare0143ba2009-03-23 21:29:59 +010029
Michael Wittena3d1ee12011-02-02 14:22:08 -060030uname_M := $(shell uname -m 2>/dev/null || echo not)
Peter Zijlstrade9ac072009-04-08 15:01:31 +020031
Ian Munsiecd932c52010-04-20 16:58:32 +100032ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
33 -e s/arm.*/arm/ -e s/sa110/arm/ \
34 -e s/s390x/s390/ -e s/parisc64/parisc/ \
35 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
36 -e s/sh[234].*/sh/ )
37
38# Additional ARCH settings for x86
39ifeq ($(ARCH),i386)
40 ARCH := x86
41endif
42ifeq ($(ARCH),x86_64)
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +090043 RAW_ARCH := x86_64
Ian Munsiecd932c52010-04-20 16:58:32 +100044 ARCH := x86
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +090045 ARCH_CFLAGS := -DARCH_X86_64
46 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S
Ian Munsiecd932c52010-04-20 16:58:32 +100047endif
48
Ingo Molnar83a09442009-08-15 12:26:57 +020049#
50# Include saner warnings here, which can catch bugs:
51#
Ingo Molnar61562442009-09-02 14:50:23 +020052
Paul Mundtec29b8d2009-10-26 14:40:01 +090053EXTRA_WARNINGS := -Wformat
Ingo Molnar61562442009-09-02 14:50:23 +020054EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
55EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
56EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
57EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
58EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
59EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
Ingo Molnar61562442009-09-02 14:50:23 +020060EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
61EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
62EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
63EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
64EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
Ingo Molnar61562442009-09-02 14:50:23 +020065EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
66EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
67EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
68EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes
69EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs
70EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
71EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
72EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
Ingo Molnar83a09442009-08-15 12:26:57 +020073
Steven Rostedt60d526f2009-10-20 19:19:34 -040074ifeq ("$(origin DEBUG)", "command line")
75 PERF_DEBUG = $(DEBUG)
76endif
77ifndef PERF_DEBUG
78 CFLAGS_OPTIMIZE = -O6
79endif
80
Frederic Weisbecker6b01f2c2011-01-06 15:51:53 +010081CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
Michael S. Tsirkin75138652009-10-29 17:20:02 +020082EXTLIBS = -lpthread -lrt -lelf -lm
Borislav Petkovb0f86f52010-03-29 18:47:55 +020083ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
Ingo Molnard24e4732009-04-20 13:32:07 +020084ALL_LDFLAGS = $(LDFLAGS)
85STRIP ?= strip
86
87# Among the variables below, these:
Ingo Molnar07800602009-04-20 15:00:56 +020088# perfexecdir
Ingo Molnard24e4732009-04-20 13:32:07 +020089# template_dir
90# mandir
91# infodir
92# htmldir
Ingo Molnar07800602009-04-20 15:00:56 +020093# ETC_PERFCONFIG (but not sysconfdir)
Ingo Molnard24e4732009-04-20 13:32:07 +020094# can be specified as a relative path some/where/else;
Ingo Molnar07800602009-04-20 15:00:56 +020095# this is interpreted as relative to $(prefix) and "perf" at
Ingo Molnard24e4732009-04-20 13:32:07 +020096# runtime figures out where they are based on the path to the executable.
97# This can help installing the suite in a relocatable way.
98
John Kacur7ae5f2132010-03-11 13:57:00 +010099# Make the path relative to DESTDIR, not to prefix
100ifndef DESTDIR
Ingo Molnard24e4732009-04-20 13:32:07 +0200101prefix = $(HOME)
John Kacur7ae5f2132010-03-11 13:57:00 +0100102endif
Ingo Molnard24e4732009-04-20 13:32:07 +0200103bindir_relative = bin
104bindir = $(prefix)/$(bindir_relative)
105mandir = share/man
106infodir = share/info
Ingo Molnar07800602009-04-20 15:00:56 +0200107perfexecdir = libexec/perf-core
Ingo Molnard24e4732009-04-20 13:32:07 +0200108sharedir = $(prefix)/share
Ingo Molnar07800602009-04-20 15:00:56 +0200109template_dir = share/perf-core/templates
110htmldir = share/doc/perf-doc
Ingo Molnard24e4732009-04-20 13:32:07 +0200111ifeq ($(prefix),/usr)
112sysconfdir = /etc
Ingo Molnar07800602009-04-20 15:00:56 +0200113ETC_PERFCONFIG = $(sysconfdir)/perfconfig
Ingo Molnard24e4732009-04-20 13:32:07 +0200114else
115sysconfdir = $(prefix)/etc
Ingo Molnar07800602009-04-20 15:00:56 +0200116ETC_PERFCONFIG = etc/perfconfig
Ingo Molnard24e4732009-04-20 13:32:07 +0200117endif
118lib = lib
Ingo Molnard24e4732009-04-20 13:32:07 +0200119
Ingo Molnard24e4732009-04-20 13:32:07 +0200120export prefix bindir sharedir sysconfdir
121
Jamie Ilescc835752009-12-11 09:21:00 +0000122CC = $(CROSS_COMPILE)gcc
123AR = $(CROSS_COMPILE)ar
Ingo Molnard24e4732009-04-20 13:32:07 +0200124RM = rm -f
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300125MKDIR = mkdir
Ingo Molnard24e4732009-04-20 13:32:07 +0200126FIND = find
127INSTALL = install
Ingo Molnard24e4732009-04-20 13:32:07 +0200128
Ingo Molnard24e4732009-04-20 13:32:07 +0200129# sparse is architecture-neutral, which means that we need to tell it
130# explicitly what architecture to check for. Fix this up for yours..
131SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
132
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300133-include feature-tests.mak
Arnaldo Carvalho de Melo1703f2c2010-01-12 08:58:30 -0200134
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300135ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y)
136 CFLAGS := $(CFLAGS) -fstack-protector-all
Michael Cree5d7bdab2009-11-11 20:43:03 +1300137endif
Ingo Molnard24e4732009-04-20 13:32:07 +0200138
Arnaldo Carvalho de Melo065bef52011-01-22 19:29:53 -0200139ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wstack-protector),y)
140 CFLAGS := $(CFLAGS) -Wstack-protector
141endif
142
143ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wvolatile-register-var),y)
144 CFLAGS := $(CFLAGS) -Wvolatile-register-var
145endif
Ingo Molnard24e4732009-04-20 13:32:07 +0200146
147### --- END CONFIGURATION SECTION ---
148
149# Those must not be GNU-specific; they are shared with perl/ which may
150# be built by a different compiler. (Note that this is an artifact now
151# but it still might be nice to keep that distinction.)
Ian Munsiecd932c52010-04-20 16:58:32 +1000152BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include
Ingo Molnard24e4732009-04-20 13:32:07 +0200153BASIC_LDFLAGS =
154
155# Guard against environment variables
156BUILTIN_OBJS =
Ingo Molnard24e4732009-04-20 13:32:07 +0200157LIB_H =
158LIB_OBJS =
Arnaldo Carvalho de Melo877108e2011-01-29 15:44:29 -0200159PYRF_OBJS =
Ingo Molnard24e4732009-04-20 13:32:07 +0200160SCRIPT_SH =
Ingo Molnard24e4732009-04-20 13:32:07 +0200161
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -0200162SCRIPT_SH += perf-archive.sh
Ingo Molnar07800602009-04-20 15:00:56 +0200163
Tom Zanussif2481f32010-08-24 00:23:50 -0500164grep-libs = $(filter -l%,$(1))
165strip-libs = $(filter-out -l%,$(1))
166
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200167$(OUTPUT)python/perf.so: $(PYRF_OBJS)
Michael Witten9c56dfe2011-02-03 22:10:55 -0600168 $(QUIET_GEN)python util/setup.py --quiet build_ext --build-lib='$(OUTPUT)python' \
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200169 --build-temp='$(OUTPUT)python/temp'
Ingo Molnar07800602009-04-20 15:00:56 +0200170#
171# No Perl scripts right now:
172#
173
Michael Witten0a54fb62011-02-02 12:04:27 -0600174SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
Ingo Molnard24e4732009-04-20 13:32:07 +0200175
Ingo Molnar07800602009-04-20 15:00:56 +0200176#
Ingo Molnar125e7022009-04-20 16:13:46 +0200177# Single 'perf' binary right now:
Ingo Molnar07800602009-04-20 15:00:56 +0200178#
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300179PROGRAMS += $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200180
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200181LANG_BINDINGS =
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200182
Ingo Molnar07800602009-04-20 15:00:56 +0200183# what 'all' will build and 'install' will install, in perfexecdir
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200184ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200185
Ingo Molnar07800602009-04-20 15:00:56 +0200186# what 'all' will build but not install in perfexecdir
Michael Witten8796cb92011-02-02 11:57:41 -0600187OTHER_PROGRAMS = $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200188
189# Set paths to tools early so that they can be used for version tests.
190ifndef SHELL_PATH
191 SHELL_PATH = /bin/sh
192endif
193ifndef PERL_PATH
194 PERL_PATH = /usr/bin/perl
195endif
196
197export PERL_PATH
198
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300199LIB_FILE=$(OUTPUT)libperf.a
Ingo Molnard24e4732009-04-20 13:32:07 +0200200
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200201LIB_H += ../../include/linux/perf_event.h
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -0300202LIB_H += ../../include/linux/rbtree.h
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -0300203LIB_H += ../../include/linux/list.h
Hitoshi Mitake18e97e02010-01-30 20:43:24 +0900204LIB_H += ../../include/linux/hash.h
Masami Hiramatsu97698332009-10-16 20:08:18 -0400205LIB_H += ../../include/linux/stringify.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200206LIB_H += util/include/linux/bitmap.h
207LIB_H += util/include/linux/bitops.h
208LIB_H += util/include/linux/compiler.h
209LIB_H += util/include/linux/ctype.h
210LIB_H += util/include/linux/kernel.h
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -0300211LIB_H += util/include/linux/list.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200212LIB_H += util/include/linux/module.h
213LIB_H += util/include/linux/poison.h
214LIB_H += util/include/linux/prefetch.h
215LIB_H += util/include/linux/rbtree.h
Arnaldo Carvalho de Melo20639c12009-10-19 15:11:36 -0200216LIB_H += util/include/linux/string.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200217LIB_H += util/include/linux/types.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900218LIB_H += util/include/linux/linkage.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200219LIB_H += util/include/asm/asm-offsets.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200220LIB_H += util/include/asm/bug.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200221LIB_H += util/include/asm/byteorder.h
Arnaldo Carvalho de Melofb720142010-04-30 19:31:12 -0300222LIB_H += util/include/asm/hweight.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200223LIB_H += util/include/asm/swab.h
224LIB_H += util/include/asm/system.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200225LIB_H += util/include/asm/uaccess.h
Ian Munsiecd932c52010-04-20 16:58:32 +1000226LIB_H += util/include/dwarf-regs.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900227LIB_H += util/include/asm/dwarf2.h
228LIB_H += util/include/asm/cpufeature.h
Thomas Gleixner6eda5832009-05-01 18:29:57 +0200229LIB_H += perf.h
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200230LIB_H += util/annotate.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200231LIB_H += util/cache.h
232LIB_H += util/callchain.h
Arnaldo Carvalho de Melo7b2567c2010-02-03 16:52:04 -0200233LIB_H += util/build-id.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200234LIB_H += util/debug.h
Clark Williamsafe61f62009-11-08 09:01:37 -0600235LIB_H += util/debugfs.h
Arnaldo Carvalho de Meloec218fc2009-10-03 20:30:48 -0300236LIB_H += util/event.h
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200237LIB_H += util/evsel.h
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -0200238LIB_H += util/evlist.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200239LIB_H += util/exec_cmd.h
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +0200240LIB_H += util/types.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200241LIB_H += util/levenshtein.h
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -0200242LIB_H += util/map.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200243LIB_H += util/parse-options.h
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200244LIB_H += util/parse-events.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200245LIB_H += util/quote.h
246LIB_H += util/util.h
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200247LIB_H += util/xyarray.h
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200248LIB_H += util/header.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200249LIB_H += util/help.h
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200250LIB_H += util/session.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200251LIB_H += util/strbuf.h
Arnaldo Carvalho de Melo25903402009-06-30 19:01:20 -0300252LIB_H += util/strlist.h
Masami Hiramatsu68baa432011-01-20 23:15:30 +0900253LIB_H += util/strfilter.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200254LIB_H += util/svghelper.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200255LIB_H += util/run-command.h
Ingo Molnara930d2c2009-05-27 09:50:13 +0200256LIB_H += util/sigchain.h
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300257LIB_H += util/symbol.h
Ingo Molnar8fc03212009-06-04 15:19:47 +0200258LIB_H += util/color.h
Brice Goglin8d513272009-08-07 13:55:24 +0200259LIB_H += util/values.h
John Kacurdd68ada2009-09-24 18:02:49 +0200260LIB_H += util/sort.h
John Kacur3d1d07e2009-09-28 15:32:55 +0200261LIB_H += util/hist.h
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -0300262LIB_H += util/thread.h
Arnaldo Carvalho de Melofd782602011-01-18 15:15:24 -0200263LIB_H += util/thread_map.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200264LIB_H += util/trace-event.h
Masami Hiramatsu57d250d2009-11-30 19:19:34 -0500265LIB_H += util/probe-finder.h
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500266LIB_H += util/probe-event.h
Arnaldo Carvalho de Melo3e1bbdc32010-05-14 20:05:21 -0300267LIB_H += util/pstack.h
Paul Mackerrasa12b51c2010-03-10 20:36:09 +1100268LIB_H += util/cpumap.h
Arnaldo Carvalho de Melo8c3e10e2011-01-31 14:50:39 -0200269LIB_H += util/top.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900270LIB_H += $(ARCH_INCLUDE)
Stephane Eranian023695d2011-02-14 11:20:01 +0200271LIB_H += util/cgroup.h
Ingo Molnard24e4732009-04-20 13:32:07 +0200272
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300273LIB_OBJS += $(OUTPUT)util/abspath.o
274LIB_OBJS += $(OUTPUT)util/alias.o
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200275LIB_OBJS += $(OUTPUT)util/annotate.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300276LIB_OBJS += $(OUTPUT)util/build-id.o
277LIB_OBJS += $(OUTPUT)util/config.o
278LIB_OBJS += $(OUTPUT)util/ctype.o
279LIB_OBJS += $(OUTPUT)util/debugfs.o
280LIB_OBJS += $(OUTPUT)util/environment.o
281LIB_OBJS += $(OUTPUT)util/event.o
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -0200282LIB_OBJS += $(OUTPUT)util/evlist.o
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200283LIB_OBJS += $(OUTPUT)util/evsel.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300284LIB_OBJS += $(OUTPUT)util/exec_cmd.o
285LIB_OBJS += $(OUTPUT)util/help.o
286LIB_OBJS += $(OUTPUT)util/levenshtein.o
287LIB_OBJS += $(OUTPUT)util/parse-options.o
288LIB_OBJS += $(OUTPUT)util/parse-events.o
289LIB_OBJS += $(OUTPUT)util/path.o
290LIB_OBJS += $(OUTPUT)util/rbtree.o
291LIB_OBJS += $(OUTPUT)util/bitmap.o
292LIB_OBJS += $(OUTPUT)util/hweight.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300293LIB_OBJS += $(OUTPUT)util/run-command.o
294LIB_OBJS += $(OUTPUT)util/quote.o
295LIB_OBJS += $(OUTPUT)util/strbuf.o
296LIB_OBJS += $(OUTPUT)util/string.o
297LIB_OBJS += $(OUTPUT)util/strlist.o
Masami Hiramatsu68baa432011-01-20 23:15:30 +0900298LIB_OBJS += $(OUTPUT)util/strfilter.o
Arnaldo Carvalho de Melo8c3e10e2011-01-31 14:50:39 -0200299LIB_OBJS += $(OUTPUT)util/top.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300300LIB_OBJS += $(OUTPUT)util/usage.o
301LIB_OBJS += $(OUTPUT)util/wrapper.o
302LIB_OBJS += $(OUTPUT)util/sigchain.o
303LIB_OBJS += $(OUTPUT)util/symbol.o
304LIB_OBJS += $(OUTPUT)util/color.o
305LIB_OBJS += $(OUTPUT)util/pager.o
306LIB_OBJS += $(OUTPUT)util/header.o
307LIB_OBJS += $(OUTPUT)util/callchain.o
308LIB_OBJS += $(OUTPUT)util/values.o
309LIB_OBJS += $(OUTPUT)util/debug.o
310LIB_OBJS += $(OUTPUT)util/map.o
Arnaldo Carvalho de Melo3e1bbdc32010-05-14 20:05:21 -0300311LIB_OBJS += $(OUTPUT)util/pstack.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300312LIB_OBJS += $(OUTPUT)util/session.o
313LIB_OBJS += $(OUTPUT)util/thread.o
Arnaldo Carvalho de Melofd782602011-01-18 15:15:24 -0200314LIB_OBJS += $(OUTPUT)util/thread_map.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300315LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
316LIB_OBJS += $(OUTPUT)util/trace-event-read.o
317LIB_OBJS += $(OUTPUT)util/trace-event-info.o
318LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
319LIB_OBJS += $(OUTPUT)util/svghelper.o
320LIB_OBJS += $(OUTPUT)util/sort.o
321LIB_OBJS += $(OUTPUT)util/hist.o
322LIB_OBJS += $(OUTPUT)util/probe-event.o
323LIB_OBJS += $(OUTPUT)util/util.o
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200324LIB_OBJS += $(OUTPUT)util/xyarray.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300325LIB_OBJS += $(OUTPUT)util/cpumap.o
Stephane Eranian023695d2011-02-14 11:20:01 +0200326LIB_OBJS += $(OUTPUT)util/cgroup.o
Ingo Molnard24e4732009-04-20 13:32:07 +0200327
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300328BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900329
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300330BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900331
332# Benchmark modules
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300333BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
334BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900335ifeq ($(RAW_ARCH),x86_64)
336BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
337endif
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300338BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900339
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300340BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
341BUILTIN_OBJS += $(OUTPUT)builtin-help.o
342BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
343BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
344BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
345BUILTIN_OBJS += $(OUTPUT)builtin-list.o
346BUILTIN_OBJS += $(OUTPUT)builtin-record.o
347BUILTIN_OBJS += $(OUTPUT)builtin-report.o
348BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
349BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
350BUILTIN_OBJS += $(OUTPUT)builtin-top.o
Ingo Molnar133dc4c2010-11-16 18:45:39 +0100351BUILTIN_OBJS += $(OUTPUT)builtin-script.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300352BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
353BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
354BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800355BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
Arnaldo Carvalho de Melo1c6a8002010-04-29 18:58:32 -0300356BUILTIN_OBJS += $(OUTPUT)builtin-test.o
Tom Zanussi454c4072010-05-01 01:41:20 -0500357BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
Ingo Molnard24e4732009-04-20 13:32:07 +0200358
Ingo Molnar07800602009-04-20 15:00:56 +0200359PERFLIBS = $(LIB_FILE)
Ingo Molnard24e4732009-04-20 13:32:07 +0200360
Arnaldo Carvalho de Melo877108e2011-01-29 15:44:29 -0200361# Files needed for the python binding, perf.so
362# pyrf is just an internal name needed for all those wrappers.
363# This has to be in sync with what is in the 'sources' variable in
364# tools/perf/util/setup.py
365
366PYRF_OBJS += $(OUTPUT)util/cpumap.o
367PYRF_OBJS += $(OUTPUT)util/ctype.o
368PYRF_OBJS += $(OUTPUT)util/evlist.o
369PYRF_OBJS += $(OUTPUT)util/evsel.o
370PYRF_OBJS += $(OUTPUT)util/python.o
371PYRF_OBJS += $(OUTPUT)util/thread_map.o
372PYRF_OBJS += $(OUTPUT)util/util.o
373PYRF_OBJS += $(OUTPUT)util/xyarray.o
374
Ingo Molnard24e4732009-04-20 13:32:07 +0200375#
376# Platform specific tweaks
377#
378
379# We choose to avoid "if .. else if .. else .. endif endif"
380# because maintaining the nesting to match is a pain. If
381# we had "elif" things would have been much nicer...
382
Ingo Molnard24e4732009-04-20 13:32:07 +0200383-include config.mak.autogen
384-include config.mak
385
Ian Munsiecd932c52010-04-20 16:58:32 +1000386ifndef NO_DWARF
Robert Morella7112392010-11-16 14:16:33 -0800387FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300388ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y)
Masami Hiramatsu6b3c4ef2010-05-11 00:59:53 -0400389 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);
Ian Munsiecd932c52010-04-20 16:58:32 +1000390 NO_DWARF := 1
391endif # Dwarf support
392endif # NO_DWARF
393
394-include arch/$(ARCH)/Makefile
395
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300396ifneq ($(OUTPUT),)
397 BASIC_CFLAGS += -I$(OUTPUT)
398endif
399
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300400FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
401ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y)
402 FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS)
403 ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y)
404 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
405 else
406 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel);
407 endif
Randy Dunlap1abc7f52009-10-18 19:20:24 -0700408endif
409
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300410ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y)
411 BASIC_CFLAGS += -DLIBELF_NO_MMAP
Peter Zijlstra9424edc2009-08-05 14:05:16 +0200412endif
413
Masami Hiramatsuca721e42010-03-22 13:10:27 -0300414ifndef NO_DWARF
Ian Munsiecd932c52010-04-20 16:58:32 +1000415ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
416 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
417else
Robert Morella7112392010-11-16 14:16:33 -0800418 BASIC_CFLAGS += -DDWARF_SUPPORT
Masami Hiramatsu804b3602010-02-25 08:35:42 -0500419 EXTLIBS += -lelf -ldw
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300420 LIB_OBJS += $(OUTPUT)util/probe-finder.o
Ian Munsiecd932c52010-04-20 16:58:32 +1000421endif # PERF_HAVE_DWARF_REGS
422endif # NO_DWARF
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -0400423
Arnaldo Carvalho de Melo94f3ca92010-05-17 18:18:11 -0300424ifdef NO_NEWT
425 BASIC_CFLAGS += -DNO_NEWT_SUPPORT
426else
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300427 FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt
428 ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y)
429 msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev);
430 BASIC_CFLAGS += -DNO_NEWT_SUPPORT
431 else
432 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
433 BASIC_CFLAGS += -I/usr/include/slang
434 EXTLIBS += -lnewt -lslang
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300435 LIB_OBJS += $(OUTPUT)util/ui/setup.o
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300436 LIB_OBJS += $(OUTPUT)util/ui/browser.o
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300437 LIB_OBJS += $(OUTPUT)util/ui/browsers/annotate.o
Arnaldo Carvalho de Melod1b4f242010-08-10 15:49:07 -0300438 LIB_OBJS += $(OUTPUT)util/ui/browsers/hists.o
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300439 LIB_OBJS += $(OUTPUT)util/ui/browsers/map.o
Arnaldo Carvalho de Meloc0443df2011-01-31 18:19:33 -0200440 LIB_OBJS += $(OUTPUT)util/ui/browsers/top.o
Arnaldo Carvalho de Melo55755362010-08-08 19:48:31 -0300441 LIB_OBJS += $(OUTPUT)util/ui/helpline.o
Arnaldo Carvalho de Melo34cea7f2010-08-08 19:56:47 -0300442 LIB_OBJS += $(OUTPUT)util/ui/progress.o
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300443 LIB_OBJS += $(OUTPUT)util/ui/util.o
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300444 LIB_H += util/ui/browser.h
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300445 LIB_H += util/ui/browsers/map.h
Arnaldo Carvalho de Melo55755362010-08-08 19:48:31 -0300446 LIB_H += util/ui/helpline.h
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300447 LIB_H += util/ui/libslang.h
Arnaldo Carvalho de Melo34cea7f2010-08-08 19:56:47 -0300448 LIB_H += util/ui/progress.h
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300449 LIB_H += util/ui/util.h
Arnaldo Carvalho de Melo5c35d692011-02-09 11:38:43 -0200450 LIB_H += util/ui/ui.h
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300451 endif
Jamie Ilescc835752009-12-11 09:21:00 +0000452endif
Tom Zanussi16c632d2009-11-25 01:15:48 -0600453
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300454ifdef NO_LIBPERL
Tom Zanussi16c632d2009-11-25 01:15:48 -0600455 BASIC_CFLAGS += -DNO_LIBPERL
456else
Tom Zanussif2481f32010-08-24 00:23:50 -0500457 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
458 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
459 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300460 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
Tom Zanussibfde7442010-06-17 23:40:06 -0500461 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300462
463 ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y)
464 BASIC_CFLAGS += -DNO_LIBPERL
465 else
Tom Zanussif2481f32010-08-24 00:23:50 -0500466 ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS)
467 EXTLIBS += $(PERL_EMBED_LIBADD)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300468 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
469 LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
470 endif
Tom Zanussi16c632d2009-11-25 01:15:48 -0600471endif
472
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300473ifdef NO_LIBPYTHON
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600474 BASIC_CFLAGS += -DNO_LIBPYTHON
475else
Tom Zanussif2481f32010-08-24 00:23:50 -0500476 PYTHON_EMBED_LDOPTS = $(shell python-config --ldflags 2>/dev/null)
477 PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
478 PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300479 PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
480 FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
481 ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200482 msg := $(warning No Python.h found, install python-dev[el] to have python support in 'perf script' and to build the python bindings)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300483 BASIC_CFLAGS += -DNO_LIBPYTHON
484 else
Tom Zanussif2481f32010-08-24 00:23:50 -0500485 ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
486 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300487 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
488 LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200489 LANG_BINDINGS += $(OUTPUT)python/perf.so
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300490 endif
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600491endif
492
Peter Zijlstra2cdbc462009-08-05 14:05:16 +0200493ifdef NO_DEMANGLE
494 BASIC_CFLAGS += -DNO_DEMANGLE
495else
Conny Seidel167a58f2010-07-01 15:19:26 +0200496 ifdef HAVE_CPLUS_DEMANGLE
497 EXTLIBS += -liberty
498 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
499 else
500 FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd
501 has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
502 ifeq ($(has_bfd),y)
503 EXTLIBS += -lbfd
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300504 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200505 FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
506 has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY))
507 ifeq ($(has_bfd_iberty),y)
508 EXTLIBS += -lbfd -liberty
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300509 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200510 FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
511 has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z))
512 ifeq ($(has_bfd_iberty_z),y)
513 EXTLIBS += -lbfd -liberty -lz
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300514 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200515 FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty
516 has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE))
517 ifeq ($(has_cplus_demangle),y)
518 EXTLIBS += -liberty
519 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
520 else
521 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
522 BASIC_CFLAGS += -DNO_DEMANGLE
523 endif
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300524 endif
525 endif
526 endif
Peter Zijlstra2cdbc462009-08-05 14:05:16 +0200527 endif
528endif
529
Kirill A. Shutemovf4e7ac02010-08-21 03:38:20 +0300530
531ifdef NO_STRLCPY
532 BASIC_CFLAGS += -DNO_STRLCPY
533else
534 ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
535 BASIC_CFLAGS += -DNO_STRLCPY
536 endif
537endif
538
Ingo Molnard24e4732009-04-20 13:32:07 +0200539ifneq ($(findstring $(MAKEFLAGS),s),s)
540ifndef V
541 QUIET_CC = @echo ' ' CC $@;
542 QUIET_AR = @echo ' ' AR $@;
543 QUIET_LINK = @echo ' ' LINK $@;
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300544 QUIET_MKDIR = @echo ' ' MKDIR $@;
Ingo Molnard24e4732009-04-20 13:32:07 +0200545 QUIET_GEN = @echo ' ' GEN $@;
Ingo Molnard24e4732009-04-20 13:32:07 +0200546endif
547endif
548
549ifdef ASCIIDOC8
550 export ASCIIDOC8
551endif
552
553# Shell quote (do not use $(call) to accommodate ancient setups);
554
Ingo Molnar07800602009-04-20 15:00:56 +0200555ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
Ingo Molnard24e4732009-04-20 13:32:07 +0200556
557DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
558bindir_SQ = $(subst ','\'',$(bindir))
559bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
560mandir_SQ = $(subst ','\'',$(mandir))
561infodir_SQ = $(subst ','\'',$(infodir))
Ingo Molnar07800602009-04-20 15:00:56 +0200562perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
Ingo Molnard24e4732009-04-20 13:32:07 +0200563template_dir_SQ = $(subst ','\'',$(template_dir))
564htmldir_SQ = $(subst ','\'',$(htmldir))
565prefix_SQ = $(subst ','\'',$(prefix))
566
567SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
Ingo Molnard24e4732009-04-20 13:32:07 +0200568
Ian Munsieb38aa892010-11-29 11:53:07 +1100569LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive $(EXTLIBS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200570
Ingo Molnard24e4732009-04-20 13:32:07 +0200571ALL_CFLAGS += $(BASIC_CFLAGS)
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900572ALL_CFLAGS += $(ARCH_CFLAGS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200573ALL_LDFLAGS += $(BASIC_LDFLAGS)
574
Michael Wittena3d1ee12011-02-02 14:22:08 -0600575export INSTALL SHELL_PATH
Ingo Molnard24e4732009-04-20 13:32:07 +0200576
577
578### Build rules
579
580SHELL = $(SHELL_PATH)
581
Michael Wittena3d1ee12011-02-02 14:22:08 -0600582all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200583
584please_set_SHELL_PATH_to_a_more_modern_shell:
585 @$$(:)
586
587shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
588
Michael Witten8796cb92011-02-02 11:57:41 -0600589strip: $(PROGRAMS) $(OUTPUT)perf
590 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200591
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300592$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
Ingo Molnar07800602009-04-20 15:00:56 +0200593 $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
594 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300595 $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200596
Michael Witten8796cb92011-02-02 11:57:41 -0600597$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
Tom Zanussif2481f32010-08-24 00:23:50 -0500598 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
599 $(BUILTIN_OBJS) $(LIBS) -o $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200600
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300601$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
602 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Ingo Molnar07800602009-04-20 15:00:56 +0200603 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
604 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
605 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200606
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300607$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
608 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Arjan van de Ven10274982009-09-12 07:53:05 +0200609 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
610 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
611 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
612
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300613$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
Ingo Molnard24e4732009-04-20 13:32:07 +0200614
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300615$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
Mulyadi Santosa1ad05602009-09-26 02:01:41 +0700616 $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200617
Michael Wittena3d1ee12011-02-02 14:22:08 -0600618$(SCRIPTS) : % : %.sh
619 $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
Ingo Molnard24e4732009-04-20 13:32:07 +0200620
Ingo Molnar07800602009-04-20 15:00:56 +0200621# These can record PERF_VERSION
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300622$(OUTPUT)perf.o perf.spec \
Michael Wittena3d1ee12011-02-02 14:22:08 -0600623 $(SCRIPTS) \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300624 : $(OUTPUT)PERF-VERSION-FILE
Ingo Molnard24e4732009-04-20 13:32:07 +0200625
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300626$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
627 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
628$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
Ingo Molnard24e4732009-04-20 13:32:07 +0200629 $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300630$(OUTPUT)%.o: %.S
631 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200632
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300633$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
634 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Ingo Molnar07800602009-04-20 15:00:56 +0200635 '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
Ingo Molnard24e4732009-04-20 13:32:07 +0200636 '-DBINDIR="$(bindir_relative_SQ)"' \
637 '-DPREFIX="$(prefix_SQ)"' \
638 $<
639
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300640$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
641 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200642
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300643$(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS
644 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
645
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300646$(OUTPUT)util/ui/browsers/annotate.o: util/ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
647 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
648
Arnaldo Carvalho de Meloc0443df2011-01-31 18:19:33 -0200649$(OUTPUT)util/ui/browsers/top.o: util/ui/browsers/top.c $(OUTPUT)PERF-CFLAGS
650 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
651
Arnaldo Carvalho de Melod1b4f242010-08-10 15:49:07 -0300652$(OUTPUT)util/ui/browsers/hists.o: util/ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
653 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
654
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300655$(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
656 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
657
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300658$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
659 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -0300660
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300661$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
662 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
Tom Zanussi16c632d2009-11-25 01:15:48 -0600663
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300664$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
665 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
Tom Zanussid1b93772009-11-25 01:15:50 -0600666
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300667$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
668 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600669
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300670$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
671 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600672
Michael Witten8796cb92011-02-02 11:57:41 -0600673$(OUTPUT)perf-%: %.o $(PERFLIBS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200674 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
675
Ingo Molnard24e4732009-04-20 13:32:07 +0200676$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
Michael Witten8796cb92011-02-02 11:57:41 -0600677$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
Ingo Molnard24e4732009-04-20 13:32:07 +0200678
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300679# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So
680# we depend the various files onto their directories.
681DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
Kusanagi Kouichi39cfae62010-09-26 14:17:42 -0300682$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300683# In the second step, we make a rule to actually create these directories
684$(sort $(dir $(DIRECTORY_DEPS))):
685 $(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
686
Ingo Molnard24e4732009-04-20 13:32:07 +0200687$(LIB_FILE): $(LIB_OBJS)
688 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
689
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800690help:
691 @echo 'Perf make targets:'
692 @echo ' doc - make *all* documentation (see below)'
693 @echo ' man - make manpage documentation (access with man <foo>)'
694 @echo ' html - make html documentation'
695 @echo ' info - make GNU info documentation (access with info <foo>)'
696 @echo ' pdf - make pdf documentation'
697 @echo ' TAGS - use etags to make tag information for source browsing'
698 @echo ' tags - use ctags to make tag information for source browsing'
699 @echo ' cscope - use cscope to make interactive browsing database'
700 @echo ''
701 @echo 'Perf install targets:'
702 @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
703 @echo ' HINT: use "make prefix=<path> <install target>" to install to a particular'
704 @echo ' path like make prefix=/usr/local install install-doc'
705 @echo ' install - install compiled binaries'
706 @echo ' install-doc - install *all* documentation'
707 @echo ' install-man - install manpage documentation'
708 @echo ' install-html - install html documentation'
709 @echo ' install-info - install GNU info documentation'
710 @echo ' install-pdf - install pdf documentation'
711 @echo ''
712 @echo ' quick-install-doc - alias for quick-install-man'
713 @echo ' quick-install-man - install the documentation quickly'
714 @echo ' quick-install-html - install the html documentation quickly'
715 @echo ''
716 @echo 'Perf maintainer targets:'
717 @echo ' distclean - alias to clean'
718 @echo ' clean - clean all binary objects and build output'
719
Ingo Molnarc1c23652009-05-30 12:38:51 +0200720doc:
721 $(MAKE) -C Documentation all
722
723man:
724 $(MAKE) -C Documentation man
725
726html:
727 $(MAKE) -C Documentation html
728
729info:
730 $(MAKE) -C Documentation info
731
732pdf:
733 $(MAKE) -C Documentation pdf
734
Ingo Molnard24e4732009-04-20 13:32:07 +0200735TAGS:
736 $(RM) TAGS
737 $(FIND) . -name '*.[hcS]' -print | xargs etags -a
738
739tags:
740 $(RM) tags
741 $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
742
743cscope:
744 $(RM) cscope*
745 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
746
747### Detect prefix changes
748TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
Ingo Molnar07800602009-04-20 15:00:56 +0200749 $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
Ingo Molnard24e4732009-04-20 13:32:07 +0200750
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300751$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
Ingo Molnard24e4732009-04-20 13:32:07 +0200752 @FLAGS='$(TRACK_CFLAGS)'; \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300753 if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
Ingo Molnard24e4732009-04-20 13:32:07 +0200754 echo 1>&2 " * new build flags or prefix"; \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300755 echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
Ingo Molnard24e4732009-04-20 13:32:07 +0200756 fi
757
Ingo Molnard24e4732009-04-20 13:32:07 +0200758### Testing rules
759
Ingo Molnard24e4732009-04-20 13:32:07 +0200760# GNU make supports exporting all variables by "export" without parameters.
761# However, the environment gets quite big, and some programs have problems
762# with that.
763
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300764check: $(OUTPUT)common-cmds.h
Ingo Molnard24e4732009-04-20 13:32:07 +0200765 if sparse; \
766 then \
Ingo Molnar148be2c2009-04-27 08:02:14 +0200767 for i in *.c */*.c; \
Ingo Molnard24e4732009-04-20 13:32:07 +0200768 do \
769 sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
770 done; \
771 else \
Ingo Molnard24e4732009-04-20 13:32:07 +0200772 exit 1; \
773 fi
774
Ingo Molnard24e4732009-04-20 13:32:07 +0200775### Installation rules
776
Ingo Molnar07800602009-04-20 15:00:56 +0200777ifneq ($(filter /%,$(firstword $(perfexecdir))),)
778perfexec_instdir = $(perfexecdir)
Ingo Molnard24e4732009-04-20 13:32:07 +0200779else
Ingo Molnar07800602009-04-20 15:00:56 +0200780perfexec_instdir = $(prefix)/$(perfexecdir)
Ingo Molnard24e4732009-04-20 13:32:07 +0200781endif
Ingo Molnar07800602009-04-20 15:00:56 +0200782perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Ingo Molnard24e4732009-04-20 13:32:07 +0200783
784install: all
785 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
Michael Witten8796cb92011-02-02 11:57:41 -0600786 $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
Tom Zanussibcefe122009-11-25 01:15:49 -0600787 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
788 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300789 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
Tom Zanussibcefe122009-11-25 01:15:49 -0600790 $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
791 $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
792 $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600793 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
Tom Zanussi4d161f02010-01-27 02:27:58 -0600794 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600795 $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
Tom Zanussi4d161f02010-01-27 02:27:58 -0600796 $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
797 $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
Tom Zanussi82d156c2010-01-27 02:27:55 -0600798
Ingo Molnarc1c23652009-05-30 12:38:51 +0200799install-doc:
800 $(MAKE) -C Documentation install
801
802install-man:
803 $(MAKE) -C Documentation install-man
804
805install-html:
806 $(MAKE) -C Documentation install-html
807
808install-info:
809 $(MAKE) -C Documentation install-info
810
811install-pdf:
812 $(MAKE) -C Documentation install-pdf
813
814quick-install-doc:
815 $(MAKE) -C Documentation quick-install
816
817quick-install-man:
818 $(MAKE) -C Documentation quick-install-man
819
820quick-install-html:
821 $(MAKE) -C Documentation quick-install-html
822
Ingo Molnard24e4732009-04-20 13:32:07 +0200823### Cleaning rules
824
Ingo Molnare0143ba2009-03-23 21:29:59 +0100825clean:
Arnaldo Carvalho de Melo568bb7b2011-02-01 15:05:00 -0200826 $(RM) $(OUTPUT){*.o,*/*.o,*/*/*.o,*/*/*/*.o,$(LIB_FILE),perf-archive}
Michael Wittena3d1ee12011-02-02 14:22:08 -0600827 $(RM) $(ALL_PROGRAMS) perf
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300828 $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
Ingo Molnarc1c23652009-05-30 12:38:51 +0200829 $(MAKE) -C Documentation/ clean
Michael Wittena3d1ee12011-02-02 14:22:08 -0600830 $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200831 @python util/setup.py clean --build-lib='$(OUTPUT)python' \
832 --build-temp='$(OUTPUT)python/temp'
Ingo Molnard24e4732009-04-20 13:32:07 +0200833
834.PHONY: all install clean strip
835.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
Ingo Molnar07800602009-04-20 15:00:56 +0200836.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS