blob: fde196fe9366575f1f1a546b70c558f49e5e7661 [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...
6all::
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
Ingo Molnard24e4732009-04-20 13:32:07 +020014# Define V=1 to have a more verbose compile.
Michael S. Tsirkin7baed9a2009-11-22 13:27:27 +020015# Define V=2 to have an even more verbose compile.
Ingo Molnard24e4732009-04-20 13:32:07 +020016#
Ingo Molnard24e4732009-04-20 13:32:07 +020017# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
18#
19# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
20#
Michael S. Tsirkin75138652009-10-29 17:20:02 +020021# Define LDFLAGS=-static to build a static binary.
Michael S. Tsirkin81516c52009-11-22 14:13:35 +020022#
23# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
Masami Hiramatsuca721e42010-03-22 13:10:27 -030024#
25# Define NO_DWARF if you do not want debug-info analysis feature at all.
Ingo Molnare0143ba2009-03-23 21:29:59 +010026
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -030027$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
28 @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
29-include $(OUTPUT)PERF-VERSION-FILE
Ingo Molnare0143ba2009-03-23 21:29:59 +010030
Ingo Molnard24e4732009-04-20 13:32:07 +020031uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
32uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
33uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
34uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
35uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
36uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
Peter Zijlstrade9ac072009-04-08 15:01:31 +020037
Ian Munsiecd932c52010-04-20 16:58:32 +100038ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
39 -e s/arm.*/arm/ -e s/sa110/arm/ \
40 -e s/s390x/s390/ -e s/parisc64/parisc/ \
41 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
42 -e s/sh[234].*/sh/ )
43
44# Additional ARCH settings for x86
45ifeq ($(ARCH),i386)
46 ARCH := x86
47endif
48ifeq ($(ARCH),x86_64)
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +090049 RAW_ARCH := x86_64
Ian Munsiecd932c52010-04-20 16:58:32 +100050 ARCH := x86
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +090051 ARCH_CFLAGS := -DARCH_X86_64
52 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S
Ian Munsiecd932c52010-04-20 16:58:32 +100053endif
54
Ingo Molnard24e4732009-04-20 13:32:07 +020055# CFLAGS and LDFLAGS are for the users to override from the command line.
Peter Zijlstrade9ac072009-04-08 15:01:31 +020056
Ingo Molnar83a09442009-08-15 12:26:57 +020057#
58# Include saner warnings here, which can catch bugs:
59#
Ingo Molnar61562442009-09-02 14:50:23 +020060
Paul Mundtec29b8d2009-10-26 14:40:01 +090061EXTRA_WARNINGS := -Wformat
Ingo Molnar61562442009-09-02 14:50:23 +020062EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
63EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
64EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
65EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
66EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
67EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
Ingo Molnar61562442009-09-02 14:50:23 +020068EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
69EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
70EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
71EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
72EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
Ingo Molnar61562442009-09-02 14:50:23 +020073EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
74EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
75EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
76EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes
77EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs
78EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
79EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
80EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
Ingo Molnar83a09442009-08-15 12:26:57 +020081
Steven Rostedt60d526f2009-10-20 19:19:34 -040082ifeq ("$(origin DEBUG)", "command line")
83 PERF_DEBUG = $(DEBUG)
84endif
85ifndef PERF_DEBUG
86 CFLAGS_OPTIMIZE = -O6
87endif
88
Frederic Weisbecker6b01f2c2011-01-06 15:51:53 +010089CFLAGS = -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 +020090EXTLIBS = -lpthread -lrt -lelf -lm
Borislav Petkovb0f86f52010-03-29 18:47:55 +020091ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
Ingo Molnard24e4732009-04-20 13:32:07 +020092ALL_LDFLAGS = $(LDFLAGS)
93STRIP ?= strip
94
95# Among the variables below, these:
Ingo Molnar07800602009-04-20 15:00:56 +020096# perfexecdir
Ingo Molnard24e4732009-04-20 13:32:07 +020097# template_dir
98# mandir
99# infodir
100# htmldir
Ingo Molnar07800602009-04-20 15:00:56 +0200101# ETC_PERFCONFIG (but not sysconfdir)
Ingo Molnard24e4732009-04-20 13:32:07 +0200102# can be specified as a relative path some/where/else;
Ingo Molnar07800602009-04-20 15:00:56 +0200103# this is interpreted as relative to $(prefix) and "perf" at
Ingo Molnard24e4732009-04-20 13:32:07 +0200104# runtime figures out where they are based on the path to the executable.
105# This can help installing the suite in a relocatable way.
106
John Kacur7ae5f2132010-03-11 13:57:00 +0100107# Make the path relative to DESTDIR, not to prefix
108ifndef DESTDIR
Ingo Molnard24e4732009-04-20 13:32:07 +0200109prefix = $(HOME)
John Kacur7ae5f2132010-03-11 13:57:00 +0100110endif
Ingo Molnard24e4732009-04-20 13:32:07 +0200111bindir_relative = bin
112bindir = $(prefix)/$(bindir_relative)
113mandir = share/man
114infodir = share/info
Ingo Molnar07800602009-04-20 15:00:56 +0200115perfexecdir = libexec/perf-core
Ingo Molnard24e4732009-04-20 13:32:07 +0200116sharedir = $(prefix)/share
Ingo Molnar07800602009-04-20 15:00:56 +0200117template_dir = share/perf-core/templates
118htmldir = share/doc/perf-doc
Ingo Molnard24e4732009-04-20 13:32:07 +0200119ifeq ($(prefix),/usr)
120sysconfdir = /etc
Ingo Molnar07800602009-04-20 15:00:56 +0200121ETC_PERFCONFIG = $(sysconfdir)/perfconfig
Ingo Molnard24e4732009-04-20 13:32:07 +0200122else
123sysconfdir = $(prefix)/etc
Ingo Molnar07800602009-04-20 15:00:56 +0200124ETC_PERFCONFIG = etc/perfconfig
Ingo Molnard24e4732009-04-20 13:32:07 +0200125endif
126lib = lib
Ingo Molnard24e4732009-04-20 13:32:07 +0200127
Ingo Molnard24e4732009-04-20 13:32:07 +0200128export prefix bindir sharedir sysconfdir
129
Jamie Ilescc835752009-12-11 09:21:00 +0000130CC = $(CROSS_COMPILE)gcc
131AR = $(CROSS_COMPILE)ar
Ingo Molnard24e4732009-04-20 13:32:07 +0200132RM = rm -f
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300133MKDIR = mkdir
Ingo Molnard24e4732009-04-20 13:32:07 +0200134TAR = tar
135FIND = find
136INSTALL = install
137RPMBUILD = rpmbuild
Ingo Molnard24e4732009-04-20 13:32:07 +0200138PTHREAD_LIBS = -lpthread
139
Ingo Molnard24e4732009-04-20 13:32:07 +0200140# sparse is architecture-neutral, which means that we need to tell it
141# explicitly what architecture to check for. Fix this up for yours..
142SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
143
Arnaldo Carvalho de Melo83039512010-01-12 08:58:29 -0200144ifeq ($(V), 2)
145 QUIET_STDERR = ">/dev/null"
146else
147 QUIET_STDERR = ">/dev/null 2>&1"
148endif
149
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300150-include feature-tests.mak
Arnaldo Carvalho de Melo1703f2c2010-01-12 08:58:30 -0200151
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300152ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y)
153 CFLAGS := $(CFLAGS) -fstack-protector-all
Michael Cree5d7bdab2009-11-11 20:43:03 +1300154endif
Ingo Molnard24e4732009-04-20 13:32:07 +0200155
Arnaldo Carvalho de Melo065bef52011-01-22 19:29:53 -0200156ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wstack-protector),y)
157 CFLAGS := $(CFLAGS) -Wstack-protector
158endif
159
160ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wvolatile-register-var),y)
161 CFLAGS := $(CFLAGS) -Wvolatile-register-var
162endif
Ingo Molnard24e4732009-04-20 13:32:07 +0200163
164### --- END CONFIGURATION SECTION ---
165
166# Those must not be GNU-specific; they are shared with perl/ which may
167# be built by a different compiler. (Note that this is an artifact now
168# but it still might be nice to keep that distinction.)
Ian Munsiecd932c52010-04-20 16:58:32 +1000169BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include
Ingo Molnard24e4732009-04-20 13:32:07 +0200170BASIC_LDFLAGS =
171
172# Guard against environment variables
173BUILTIN_OBJS =
174BUILT_INS =
Ingo Molnard24e4732009-04-20 13:32:07 +0200175LIB_H =
176LIB_OBJS =
Arnaldo Carvalho de Melo877108e2011-01-29 15:44:29 -0200177PYRF_OBJS =
Ingo Molnard24e4732009-04-20 13:32:07 +0200178SCRIPT_SH =
179TEST_PROGRAMS =
180
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -0200181SCRIPT_SH += perf-archive.sh
Ingo Molnar07800602009-04-20 15:00:56 +0200182
Tom Zanussif2481f32010-08-24 00:23:50 -0500183grep-libs = $(filter -l%,$(1))
184strip-libs = $(filter-out -l%,$(1))
185
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200186$(OUTPUT)python/perf.so: $(PYRF_OBJS)
Michael Witten9c56dfe2011-02-03 22:10:55 -0600187 $(QUIET_GEN)python util/setup.py --quiet build_ext --build-lib='$(OUTPUT)python' \
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200188 --build-temp='$(OUTPUT)python/temp'
Ingo Molnar07800602009-04-20 15:00:56 +0200189#
190# No Perl scripts right now:
191#
192
Michael Witten0a54fb62011-02-02 12:04:27 -0600193SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
Ingo Molnard24e4732009-04-20 13:32:07 +0200194
195# Empty...
196EXTRA_PROGRAMS =
197
Ingo Molnar07800602009-04-20 15:00:56 +0200198# ... and all the rest that could be moved out of bindir to perfexecdir
Ingo Molnard24e4732009-04-20 13:32:07 +0200199PROGRAMS += $(EXTRA_PROGRAMS)
Ingo Molnar07800602009-04-20 15:00:56 +0200200
201#
Ingo Molnar125e7022009-04-20 16:13:46 +0200202# Single 'perf' binary right now:
Ingo Molnar07800602009-04-20 15:00:56 +0200203#
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300204PROGRAMS += $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200205
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200206LANG_BINDINGS =
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200207
Ingo Molnard24e4732009-04-20 13:32:07 +0200208# List built-in command $C whose implementation cmd_$C() is not in
209# builtin-$C.o but is linked in as part of some other command.
Ingo Molnar07800602009-04-20 15:00:56 +0200210#
Ingo Molnard24e4732009-04-20 13:32:07 +0200211
Ingo Molnar07800602009-04-20 15:00:56 +0200212# what 'all' will build and 'install' will install, in perfexecdir
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200213ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200214
Ingo Molnar07800602009-04-20 15:00:56 +0200215# what 'all' will build but not install in perfexecdir
Michael Witten8796cb92011-02-02 11:57:41 -0600216OTHER_PROGRAMS = $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200217
218# Set paths to tools early so that they can be used for version tests.
219ifndef SHELL_PATH
220 SHELL_PATH = /bin/sh
221endif
222ifndef PERL_PATH
223 PERL_PATH = /usr/bin/perl
224endif
225
226export PERL_PATH
227
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300228LIB_FILE=$(OUTPUT)libperf.a
Ingo Molnard24e4732009-04-20 13:32:07 +0200229
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200230LIB_H += ../../include/linux/perf_event.h
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -0300231LIB_H += ../../include/linux/rbtree.h
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -0300232LIB_H += ../../include/linux/list.h
Hitoshi Mitake18e97e02010-01-30 20:43:24 +0900233LIB_H += ../../include/linux/hash.h
Masami Hiramatsu97698332009-10-16 20:08:18 -0400234LIB_H += ../../include/linux/stringify.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200235LIB_H += util/include/linux/bitmap.h
236LIB_H += util/include/linux/bitops.h
237LIB_H += util/include/linux/compiler.h
238LIB_H += util/include/linux/ctype.h
239LIB_H += util/include/linux/kernel.h
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -0300240LIB_H += util/include/linux/list.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200241LIB_H += util/include/linux/module.h
242LIB_H += util/include/linux/poison.h
243LIB_H += util/include/linux/prefetch.h
244LIB_H += util/include/linux/rbtree.h
Arnaldo Carvalho de Melo20639c12009-10-19 15:11:36 -0200245LIB_H += util/include/linux/string.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200246LIB_H += util/include/linux/types.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900247LIB_H += util/include/linux/linkage.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200248LIB_H += util/include/asm/asm-offsets.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200249LIB_H += util/include/asm/bug.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200250LIB_H += util/include/asm/byteorder.h
Arnaldo Carvalho de Melofb720142010-04-30 19:31:12 -0300251LIB_H += util/include/asm/hweight.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200252LIB_H += util/include/asm/swab.h
253LIB_H += util/include/asm/system.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200254LIB_H += util/include/asm/uaccess.h
Ian Munsiecd932c52010-04-20 16:58:32 +1000255LIB_H += util/include/dwarf-regs.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900256LIB_H += util/include/asm/dwarf2.h
257LIB_H += util/include/asm/cpufeature.h
Thomas Gleixner6eda5832009-05-01 18:29:57 +0200258LIB_H += perf.h
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200259LIB_H += util/annotate.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200260LIB_H += util/cache.h
261LIB_H += util/callchain.h
Arnaldo Carvalho de Melo7b2567c2010-02-03 16:52:04 -0200262LIB_H += util/build-id.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200263LIB_H += util/debug.h
Clark Williamsafe61f62009-11-08 09:01:37 -0600264LIB_H += util/debugfs.h
Arnaldo Carvalho de Meloec218fc2009-10-03 20:30:48 -0300265LIB_H += util/event.h
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200266LIB_H += util/evsel.h
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -0200267LIB_H += util/evlist.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200268LIB_H += util/exec_cmd.h
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +0200269LIB_H += util/types.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200270LIB_H += util/levenshtein.h
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -0200271LIB_H += util/map.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200272LIB_H += util/parse-options.h
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200273LIB_H += util/parse-events.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200274LIB_H += util/quote.h
275LIB_H += util/util.h
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200276LIB_H += util/xyarray.h
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200277LIB_H += util/header.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200278LIB_H += util/help.h
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200279LIB_H += util/session.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200280LIB_H += util/strbuf.h
Arnaldo Carvalho de Melo25903402009-06-30 19:01:20 -0300281LIB_H += util/strlist.h
Masami Hiramatsu68baa432011-01-20 23:15:30 +0900282LIB_H += util/strfilter.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200283LIB_H += util/svghelper.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200284LIB_H += util/run-command.h
Ingo Molnara930d2c2009-05-27 09:50:13 +0200285LIB_H += util/sigchain.h
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300286LIB_H += util/symbol.h
Ingo Molnar8fc03212009-06-04 15:19:47 +0200287LIB_H += util/color.h
Brice Goglin8d513272009-08-07 13:55:24 +0200288LIB_H += util/values.h
John Kacurdd68ada2009-09-24 18:02:49 +0200289LIB_H += util/sort.h
John Kacur3d1d07e2009-09-28 15:32:55 +0200290LIB_H += util/hist.h
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -0300291LIB_H += util/thread.h
Arnaldo Carvalho de Melofd782602011-01-18 15:15:24 -0200292LIB_H += util/thread_map.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200293LIB_H += util/trace-event.h
Masami Hiramatsu57d250d2009-11-30 19:19:34 -0500294LIB_H += util/probe-finder.h
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500295LIB_H += util/probe-event.h
Arnaldo Carvalho de Melo3e1bbdc32010-05-14 20:05:21 -0300296LIB_H += util/pstack.h
Paul Mackerrasa12b51c2010-03-10 20:36:09 +1100297LIB_H += util/cpumap.h
Arnaldo Carvalho de Melo8c3e10e2011-01-31 14:50:39 -0200298LIB_H += util/top.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900299LIB_H += $(ARCH_INCLUDE)
Stephane Eranian023695d2011-02-14 11:20:01 +0200300LIB_H += util/cgroup.h
Ingo Molnard24e4732009-04-20 13:32:07 +0200301
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300302LIB_OBJS += $(OUTPUT)util/abspath.o
303LIB_OBJS += $(OUTPUT)util/alias.o
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200304LIB_OBJS += $(OUTPUT)util/annotate.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300305LIB_OBJS += $(OUTPUT)util/build-id.o
306LIB_OBJS += $(OUTPUT)util/config.o
307LIB_OBJS += $(OUTPUT)util/ctype.o
308LIB_OBJS += $(OUTPUT)util/debugfs.o
309LIB_OBJS += $(OUTPUT)util/environment.o
310LIB_OBJS += $(OUTPUT)util/event.o
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -0200311LIB_OBJS += $(OUTPUT)util/evlist.o
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200312LIB_OBJS += $(OUTPUT)util/evsel.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300313LIB_OBJS += $(OUTPUT)util/exec_cmd.o
314LIB_OBJS += $(OUTPUT)util/help.o
315LIB_OBJS += $(OUTPUT)util/levenshtein.o
316LIB_OBJS += $(OUTPUT)util/parse-options.o
317LIB_OBJS += $(OUTPUT)util/parse-events.o
318LIB_OBJS += $(OUTPUT)util/path.o
319LIB_OBJS += $(OUTPUT)util/rbtree.o
320LIB_OBJS += $(OUTPUT)util/bitmap.o
321LIB_OBJS += $(OUTPUT)util/hweight.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300322LIB_OBJS += $(OUTPUT)util/run-command.o
323LIB_OBJS += $(OUTPUT)util/quote.o
324LIB_OBJS += $(OUTPUT)util/strbuf.o
325LIB_OBJS += $(OUTPUT)util/string.o
326LIB_OBJS += $(OUTPUT)util/strlist.o
Masami Hiramatsu68baa432011-01-20 23:15:30 +0900327LIB_OBJS += $(OUTPUT)util/strfilter.o
Arnaldo Carvalho de Melo8c3e10e2011-01-31 14:50:39 -0200328LIB_OBJS += $(OUTPUT)util/top.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300329LIB_OBJS += $(OUTPUT)util/usage.o
330LIB_OBJS += $(OUTPUT)util/wrapper.o
331LIB_OBJS += $(OUTPUT)util/sigchain.o
332LIB_OBJS += $(OUTPUT)util/symbol.o
333LIB_OBJS += $(OUTPUT)util/color.o
334LIB_OBJS += $(OUTPUT)util/pager.o
335LIB_OBJS += $(OUTPUT)util/header.o
336LIB_OBJS += $(OUTPUT)util/callchain.o
337LIB_OBJS += $(OUTPUT)util/values.o
338LIB_OBJS += $(OUTPUT)util/debug.o
339LIB_OBJS += $(OUTPUT)util/map.o
Arnaldo Carvalho de Melo3e1bbdc32010-05-14 20:05:21 -0300340LIB_OBJS += $(OUTPUT)util/pstack.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300341LIB_OBJS += $(OUTPUT)util/session.o
342LIB_OBJS += $(OUTPUT)util/thread.o
Arnaldo Carvalho de Melofd782602011-01-18 15:15:24 -0200343LIB_OBJS += $(OUTPUT)util/thread_map.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300344LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
345LIB_OBJS += $(OUTPUT)util/trace-event-read.o
346LIB_OBJS += $(OUTPUT)util/trace-event-info.o
347LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
348LIB_OBJS += $(OUTPUT)util/svghelper.o
349LIB_OBJS += $(OUTPUT)util/sort.o
350LIB_OBJS += $(OUTPUT)util/hist.o
351LIB_OBJS += $(OUTPUT)util/probe-event.o
352LIB_OBJS += $(OUTPUT)util/util.o
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200353LIB_OBJS += $(OUTPUT)util/xyarray.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300354LIB_OBJS += $(OUTPUT)util/cpumap.o
Stephane Eranian023695d2011-02-14 11:20:01 +0200355LIB_OBJS += $(OUTPUT)util/cgroup.o
Ingo Molnard24e4732009-04-20 13:32:07 +0200356
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300357BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900358
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300359BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900360
361# Benchmark modules
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300362BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
363BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900364ifeq ($(RAW_ARCH),x86_64)
365BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
366endif
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300367BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900368
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300369BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
370BUILTIN_OBJS += $(OUTPUT)builtin-help.o
371BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
372BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
373BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
374BUILTIN_OBJS += $(OUTPUT)builtin-list.o
375BUILTIN_OBJS += $(OUTPUT)builtin-record.o
376BUILTIN_OBJS += $(OUTPUT)builtin-report.o
377BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
378BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
379BUILTIN_OBJS += $(OUTPUT)builtin-top.o
Ingo Molnar133dc4c2010-11-16 18:45:39 +0100380BUILTIN_OBJS += $(OUTPUT)builtin-script.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300381BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
382BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
383BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800384BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
Arnaldo Carvalho de Melo1c6a8002010-04-29 18:58:32 -0300385BUILTIN_OBJS += $(OUTPUT)builtin-test.o
Tom Zanussi454c4072010-05-01 01:41:20 -0500386BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
Ingo Molnard24e4732009-04-20 13:32:07 +0200387
Ingo Molnar07800602009-04-20 15:00:56 +0200388PERFLIBS = $(LIB_FILE)
Ingo Molnard24e4732009-04-20 13:32:07 +0200389
Arnaldo Carvalho de Melo877108e2011-01-29 15:44:29 -0200390# Files needed for the python binding, perf.so
391# pyrf is just an internal name needed for all those wrappers.
392# This has to be in sync with what is in the 'sources' variable in
393# tools/perf/util/setup.py
394
395PYRF_OBJS += $(OUTPUT)util/cpumap.o
396PYRF_OBJS += $(OUTPUT)util/ctype.o
397PYRF_OBJS += $(OUTPUT)util/evlist.o
398PYRF_OBJS += $(OUTPUT)util/evsel.o
399PYRF_OBJS += $(OUTPUT)util/python.o
400PYRF_OBJS += $(OUTPUT)util/thread_map.o
401PYRF_OBJS += $(OUTPUT)util/util.o
402PYRF_OBJS += $(OUTPUT)util/xyarray.o
403
Ingo Molnard24e4732009-04-20 13:32:07 +0200404#
405# Platform specific tweaks
406#
407
408# We choose to avoid "if .. else if .. else .. endif endif"
409# because maintaining the nesting to match is a pain. If
410# we had "elif" things would have been much nicer...
411
Ingo Molnard24e4732009-04-20 13:32:07 +0200412-include config.mak.autogen
413-include config.mak
414
Ian Munsiecd932c52010-04-20 16:58:32 +1000415ifndef NO_DWARF
Robert Morella7112392010-11-16 14:16:33 -0800416FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300417ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y)
Masami Hiramatsu6b3c4ef2010-05-11 00:59:53 -0400418 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 +1000419 NO_DWARF := 1
420endif # Dwarf support
421endif # NO_DWARF
422
423-include arch/$(ARCH)/Makefile
424
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300425ifneq ($(OUTPUT),)
426 BASIC_CFLAGS += -I$(OUTPUT)
427endif
428
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300429FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
430ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y)
431 FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS)
432 ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y)
433 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
434 else
435 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel);
436 endif
Randy Dunlap1abc7f552009-10-18 19:20:24 -0700437endif
438
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300439ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y)
440 BASIC_CFLAGS += -DLIBELF_NO_MMAP
Peter Zijlstra9424edc2009-08-05 14:05:16 +0200441endif
442
Masami Hiramatsuca721e42010-03-22 13:10:27 -0300443ifndef NO_DWARF
Ian Munsiecd932c52010-04-20 16:58:32 +1000444ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
445 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
446else
Robert Morella7112392010-11-16 14:16:33 -0800447 BASIC_CFLAGS += -DDWARF_SUPPORT
Masami Hiramatsu804b3602010-02-25 08:35:42 -0500448 EXTLIBS += -lelf -ldw
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300449 LIB_OBJS += $(OUTPUT)util/probe-finder.o
Ian Munsiecd932c52010-04-20 16:58:32 +1000450endif # PERF_HAVE_DWARF_REGS
451endif # NO_DWARF
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -0400452
Arnaldo Carvalho de Melo94f3ca92010-05-17 18:18:11 -0300453ifdef NO_NEWT
454 BASIC_CFLAGS += -DNO_NEWT_SUPPORT
455else
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300456 FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt
457 ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y)
458 msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev);
459 BASIC_CFLAGS += -DNO_NEWT_SUPPORT
460 else
461 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
462 BASIC_CFLAGS += -I/usr/include/slang
463 EXTLIBS += -lnewt -lslang
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300464 LIB_OBJS += $(OUTPUT)util/ui/setup.o
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300465 LIB_OBJS += $(OUTPUT)util/ui/browser.o
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300466 LIB_OBJS += $(OUTPUT)util/ui/browsers/annotate.o
Arnaldo Carvalho de Melod1b4f242010-08-10 15:49:07 -0300467 LIB_OBJS += $(OUTPUT)util/ui/browsers/hists.o
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300468 LIB_OBJS += $(OUTPUT)util/ui/browsers/map.o
Arnaldo Carvalho de Meloc0443df2011-01-31 18:19:33 -0200469 LIB_OBJS += $(OUTPUT)util/ui/browsers/top.o
Arnaldo Carvalho de Melo55755362010-08-08 19:48:31 -0300470 LIB_OBJS += $(OUTPUT)util/ui/helpline.o
Arnaldo Carvalho de Melo34cea7f2010-08-08 19:56:47 -0300471 LIB_OBJS += $(OUTPUT)util/ui/progress.o
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300472 LIB_OBJS += $(OUTPUT)util/ui/util.o
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300473 LIB_H += util/ui/browser.h
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300474 LIB_H += util/ui/browsers/map.h
Arnaldo Carvalho de Melo55755362010-08-08 19:48:31 -0300475 LIB_H += util/ui/helpline.h
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300476 LIB_H += util/ui/libslang.h
Arnaldo Carvalho de Melo34cea7f2010-08-08 19:56:47 -0300477 LIB_H += util/ui/progress.h
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300478 LIB_H += util/ui/util.h
Arnaldo Carvalho de Melo5c35d692011-02-09 11:38:43 -0200479 LIB_H += util/ui/ui.h
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300480 endif
Jamie Ilescc835752009-12-11 09:21:00 +0000481endif
Tom Zanussi16c632d2009-11-25 01:15:48 -0600482
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300483ifdef NO_LIBPERL
Tom Zanussi16c632d2009-11-25 01:15:48 -0600484 BASIC_CFLAGS += -DNO_LIBPERL
485else
Tom Zanussif2481f32010-08-24 00:23:50 -0500486 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
487 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
488 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300489 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
Tom Zanussibfde7442010-06-17 23:40:06 -0500490 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300491
492 ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y)
493 BASIC_CFLAGS += -DNO_LIBPERL
494 else
Tom Zanussif2481f32010-08-24 00:23:50 -0500495 ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS)
496 EXTLIBS += $(PERL_EMBED_LIBADD)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300497 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
498 LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
499 endif
Tom Zanussi16c632d2009-11-25 01:15:48 -0600500endif
501
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300502ifdef NO_LIBPYTHON
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600503 BASIC_CFLAGS += -DNO_LIBPYTHON
504else
Tom Zanussif2481f32010-08-24 00:23:50 -0500505 PYTHON_EMBED_LDOPTS = $(shell python-config --ldflags 2>/dev/null)
506 PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
507 PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300508 PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
509 FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
510 ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200511 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 -0300512 BASIC_CFLAGS += -DNO_LIBPYTHON
513 else
Tom Zanussif2481f32010-08-24 00:23:50 -0500514 ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
515 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300516 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
517 LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200518 LANG_BINDINGS += $(OUTPUT)python/perf.so
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300519 endif
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600520endif
521
Peter Zijlstra2cdbc462009-08-05 14:05:16 +0200522ifdef NO_DEMANGLE
523 BASIC_CFLAGS += -DNO_DEMANGLE
524else
Conny Seidel167a58f2010-07-01 15:19:26 +0200525 ifdef HAVE_CPLUS_DEMANGLE
526 EXTLIBS += -liberty
527 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
528 else
529 FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd
530 has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
531 ifeq ($(has_bfd),y)
532 EXTLIBS += -lbfd
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300533 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200534 FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
535 has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY))
536 ifeq ($(has_bfd_iberty),y)
537 EXTLIBS += -lbfd -liberty
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300538 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200539 FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
540 has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z))
541 ifeq ($(has_bfd_iberty_z),y)
542 EXTLIBS += -lbfd -liberty -lz
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300543 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200544 FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty
545 has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE))
546 ifeq ($(has_cplus_demangle),y)
547 EXTLIBS += -liberty
548 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
549 else
550 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
551 BASIC_CFLAGS += -DNO_DEMANGLE
552 endif
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300553 endif
554 endif
555 endif
Peter Zijlstra2cdbc462009-08-05 14:05:16 +0200556 endif
557endif
558
Kirill A. Shutemovf4e7ac02010-08-21 03:38:20 +0300559
560ifdef NO_STRLCPY
561 BASIC_CFLAGS += -DNO_STRLCPY
562else
563 ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
564 BASIC_CFLAGS += -DNO_STRLCPY
565 endif
566endif
567
Ingo Molnard24e4732009-04-20 13:32:07 +0200568ifdef RUNTIME_PREFIX
569 COMPAT_CFLAGS += -DRUNTIME_PREFIX
570endif
571
Ingo Molnard24e4732009-04-20 13:32:07 +0200572QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
573QUIET_SUBDIR1 =
574
575ifneq ($(findstring $(MAKEFLAGS),w),w)
576PRINT_DIR = --no-print-directory
577else # "make -w"
578NO_SUBDIR = :
579endif
580
581ifneq ($(findstring $(MAKEFLAGS),s),s)
582ifndef V
583 QUIET_CC = @echo ' ' CC $@;
584 QUIET_AR = @echo ' ' AR $@;
585 QUIET_LINK = @echo ' ' LINK $@;
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300586 QUIET_MKDIR = @echo ' ' MKDIR $@;
Ingo Molnard24e4732009-04-20 13:32:07 +0200587 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
588 QUIET_GEN = @echo ' ' GEN $@;
589 QUIET_SUBDIR0 = +@subdir=
590 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
591 $(MAKE) $(PRINT_DIR) -C $$subdir
592 export V
593 export QUIET_GEN
594 export QUIET_BUILT_IN
595endif
596endif
597
598ifdef ASCIIDOC8
599 export ASCIIDOC8
600endif
601
602# Shell quote (do not use $(call) to accommodate ancient setups);
603
Ingo Molnar07800602009-04-20 15:00:56 +0200604ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
Ingo Molnard24e4732009-04-20 13:32:07 +0200605
606DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
607bindir_SQ = $(subst ','\'',$(bindir))
608bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
609mandir_SQ = $(subst ','\'',$(mandir))
610infodir_SQ = $(subst ','\'',$(infodir))
Ingo Molnar07800602009-04-20 15:00:56 +0200611perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
Ingo Molnard24e4732009-04-20 13:32:07 +0200612template_dir_SQ = $(subst ','\'',$(template_dir))
613htmldir_SQ = $(subst ','\'',$(htmldir))
614prefix_SQ = $(subst ','\'',$(prefix))
615
616SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
Ingo Molnard24e4732009-04-20 13:32:07 +0200617
Ian Munsieb38aa892010-11-29 11:53:07 +1100618LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive $(EXTLIBS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200619
Ingo Molnard24e4732009-04-20 13:32:07 +0200620ALL_CFLAGS += $(BASIC_CFLAGS)
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900621ALL_CFLAGS += $(ARCH_CFLAGS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200622ALL_LDFLAGS += $(BASIC_LDFLAGS)
623
624export TAR INSTALL DESTDIR SHELL_PATH
625
626
627### Build rules
628
629SHELL = $(SHELL_PATH)
630
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200631all:: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS
Ingo Molnard24e4732009-04-20 13:32:07 +0200632
633all::
Ingo Molnard24e4732009-04-20 13:32:07 +0200634
635please_set_SHELL_PATH_to_a_more_modern_shell:
636 @$$(:)
637
638shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
639
Michael Witten8796cb92011-02-02 11:57:41 -0600640strip: $(PROGRAMS) $(OUTPUT)perf
641 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200642
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300643$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
Ingo Molnar07800602009-04-20 15:00:56 +0200644 $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
645 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300646 $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200647
Michael Witten8796cb92011-02-02 11:57:41 -0600648$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
Tom Zanussif2481f32010-08-24 00:23:50 -0500649 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
650 $(BUILTIN_OBJS) $(LIBS) -o $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200651
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300652$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
653 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Ingo Molnar07800602009-04-20 15:00:56 +0200654 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
655 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
656 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200657
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300658$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
659 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Arjan van de Ven10274982009-09-12 07:53:05 +0200660 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
661 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
662 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
663
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300664$(BUILT_INS): $(OUTPUT)perf$X
Ingo Molnard24e4732009-04-20 13:32:07 +0200665 $(QUIET_BUILT_IN)$(RM) $@ && \
Ingo Molnar07800602009-04-20 15:00:56 +0200666 ln perf$X $@ 2>/dev/null || \
667 ln -s perf$X $@ 2>/dev/null || \
668 cp perf$X $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200669
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300670$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
Ingo Molnard24e4732009-04-20 13:32:07 +0200671
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300672$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
Mulyadi Santosa1ad05602009-09-26 02:01:41 +0700673 $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200674
675$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
Kusanagi Kouichiecafda62010-08-18 13:32:37 -0300676 $(QUIET_GEN)$(RM) $(OUTPUT)$@ $(OUTPUT)$@+ && \
Ingo Molnard24e4732009-04-20 13:32:07 +0200677 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
678 -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
Ingo Molnar07800602009-04-20 15:00:56 +0200679 -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
Ingo Molnard24e4732009-04-20 13:32:07 +0200680 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
Kusanagi Kouichiecafda62010-08-18 13:32:37 -0300681 $@.sh > $(OUTPUT)$@+ && \
682 chmod +x $(OUTPUT)$@+ && \
683 mv $(OUTPUT)$@+ $(OUTPUT)$@
Ingo Molnard24e4732009-04-20 13:32:07 +0200684
Ingo Molnard24e4732009-04-20 13:32:07 +0200685configure: configure.ac
686 $(QUIET_GEN)$(RM) $@ $<+ && \
Ingo Molnar07800602009-04-20 15:00:56 +0200687 sed -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
Ingo Molnard24e4732009-04-20 13:32:07 +0200688 $< > $<+ && \
689 autoconf -o $@ $<+ && \
690 $(RM) $<+
691
Ingo Molnar07800602009-04-20 15:00:56 +0200692# These can record PERF_VERSION
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300693$(OUTPUT)perf.o perf.spec \
Ingo Molnard24e4732009-04-20 13:32:07 +0200694 $(patsubst %.sh,%,$(SCRIPT_SH)) \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300695 : $(OUTPUT)PERF-VERSION-FILE
Ingo Molnard24e4732009-04-20 13:32:07 +0200696
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300697$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
698 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
699$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
Ingo Molnard24e4732009-04-20 13:32:07 +0200700 $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300701$(OUTPUT)%.o: %.S
702 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200703
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300704$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
705 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Ingo Molnar07800602009-04-20 15:00:56 +0200706 '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
Ingo Molnard24e4732009-04-20 13:32:07 +0200707 '-DBINDIR="$(bindir_relative_SQ)"' \
708 '-DPREFIX="$(prefix_SQ)"' \
709 $<
710
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300711$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
712 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200713
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300714$(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS
715 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
716
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300717$(OUTPUT)util/ui/browsers/annotate.o: util/ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
718 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
719
Arnaldo Carvalho de Meloc0443df2011-01-31 18:19:33 -0200720$(OUTPUT)util/ui/browsers/top.o: util/ui/browsers/top.c $(OUTPUT)PERF-CFLAGS
721 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
722
Arnaldo Carvalho de Melod1b4f242010-08-10 15:49:07 -0300723$(OUTPUT)util/ui/browsers/hists.o: util/ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
724 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
725
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300726$(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
727 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
728
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300729$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
730 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -0300731
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300732$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
733 $(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 -0600734
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300735$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
736 $(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 -0600737
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300738$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
739 $(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 -0600740
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300741$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
742 $(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 -0600743
Michael Witten8796cb92011-02-02 11:57:41 -0600744$(OUTPUT)perf-%: %.o $(PERFLIBS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200745 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
746
Ingo Molnard24e4732009-04-20 13:32:07 +0200747$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
Michael Witten8796cb92011-02-02 11:57:41 -0600748$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
Ingo Molnard24e4732009-04-20 13:32:07 +0200749
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300750# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So
751# we depend the various files onto their directories.
752DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
Kusanagi Kouichi39cfae62010-09-26 14:17:42 -0300753$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300754# In the second step, we make a rule to actually create these directories
755$(sort $(dir $(DIRECTORY_DEPS))):
756 $(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
757
Ingo Molnard24e4732009-04-20 13:32:07 +0200758$(LIB_FILE): $(LIB_OBJS)
759 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
760
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800761help:
762 @echo 'Perf make targets:'
763 @echo ' doc - make *all* documentation (see below)'
764 @echo ' man - make manpage documentation (access with man <foo>)'
765 @echo ' html - make html documentation'
766 @echo ' info - make GNU info documentation (access with info <foo>)'
767 @echo ' pdf - make pdf documentation'
768 @echo ' TAGS - use etags to make tag information for source browsing'
769 @echo ' tags - use ctags to make tag information for source browsing'
770 @echo ' cscope - use cscope to make interactive browsing database'
771 @echo ''
772 @echo 'Perf install targets:'
773 @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
774 @echo ' HINT: use "make prefix=<path> <install target>" to install to a particular'
775 @echo ' path like make prefix=/usr/local install install-doc'
776 @echo ' install - install compiled binaries'
777 @echo ' install-doc - install *all* documentation'
778 @echo ' install-man - install manpage documentation'
779 @echo ' install-html - install html documentation'
780 @echo ' install-info - install GNU info documentation'
781 @echo ' install-pdf - install pdf documentation'
782 @echo ''
783 @echo ' quick-install-doc - alias for quick-install-man'
784 @echo ' quick-install-man - install the documentation quickly'
785 @echo ' quick-install-html - install the html documentation quickly'
786 @echo ''
787 @echo 'Perf maintainer targets:'
788 @echo ' distclean - alias to clean'
789 @echo ' clean - clean all binary objects and build output'
790
Ingo Molnarc1c23652009-05-30 12:38:51 +0200791doc:
792 $(MAKE) -C Documentation all
793
794man:
795 $(MAKE) -C Documentation man
796
797html:
798 $(MAKE) -C Documentation html
799
800info:
801 $(MAKE) -C Documentation info
802
803pdf:
804 $(MAKE) -C Documentation pdf
805
Ingo Molnard24e4732009-04-20 13:32:07 +0200806TAGS:
807 $(RM) TAGS
808 $(FIND) . -name '*.[hcS]' -print | xargs etags -a
809
810tags:
811 $(RM) tags
812 $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
813
814cscope:
815 $(RM) cscope*
816 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
817
818### Detect prefix changes
819TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
Ingo Molnar07800602009-04-20 15:00:56 +0200820 $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
Ingo Molnard24e4732009-04-20 13:32:07 +0200821
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300822$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
Ingo Molnard24e4732009-04-20 13:32:07 +0200823 @FLAGS='$(TRACK_CFLAGS)'; \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300824 if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
Ingo Molnard24e4732009-04-20 13:32:07 +0200825 echo 1>&2 " * new build flags or prefix"; \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300826 echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
Ingo Molnard24e4732009-04-20 13:32:07 +0200827 fi
828
829# We need to apply sq twice, once to protect from the shell
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300830# that runs $(OUTPUT)PERF-BUILD-OPTIONS, and then again to protect it
Ingo Molnard24e4732009-04-20 13:32:07 +0200831# and the first level quoting from the shell that runs "echo".
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300832$(OUTPUT)PERF-BUILD-OPTIONS: .FORCE-PERF-BUILD-OPTIONS
Ingo Molnard24e4732009-04-20 13:32:07 +0200833 @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
834 @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
835 @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
Ingo Molnard24e4732009-04-20 13:32:07 +0200836
Ingo Molnard24e4732009-04-20 13:32:07 +0200837### Testing rules
838
Ingo Molnar6f06ccb2009-04-20 15:22:22 +0200839#
840# None right now:
841#
842# TEST_PROGRAMS += test-something$X
Ingo Molnard24e4732009-04-20 13:32:07 +0200843
844all:: $(TEST_PROGRAMS)
845
846# GNU make supports exporting all variables by "export" without parameters.
847# However, the environment gets quite big, and some programs have problems
848# with that.
849
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300850check: $(OUTPUT)common-cmds.h
Ingo Molnard24e4732009-04-20 13:32:07 +0200851 if sparse; \
852 then \
Ingo Molnar148be2c2009-04-27 08:02:14 +0200853 for i in *.c */*.c; \
Ingo Molnard24e4732009-04-20 13:32:07 +0200854 do \
855 sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
856 done; \
857 else \
858 echo 2>&1 "Did you mean 'make test'?"; \
859 exit 1; \
860 fi
861
862remove-dashes:
863 ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
864
865### Installation rules
866
867ifneq ($(filter /%,$(firstword $(template_dir))),)
868template_instdir = $(template_dir)
869else
870template_instdir = $(prefix)/$(template_dir)
871endif
872export template_instdir
873
Ingo Molnar07800602009-04-20 15:00:56 +0200874ifneq ($(filter /%,$(firstword $(perfexecdir))),)
875perfexec_instdir = $(perfexecdir)
Ingo Molnard24e4732009-04-20 13:32:07 +0200876else
Ingo Molnar07800602009-04-20 15:00:56 +0200877perfexec_instdir = $(prefix)/$(perfexecdir)
Ingo Molnard24e4732009-04-20 13:32:07 +0200878endif
Ingo Molnar07800602009-04-20 15:00:56 +0200879perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
880export perfexec_instdir
Ingo Molnard24e4732009-04-20 13:32:07 +0200881
882install: all
883 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
Michael Witten8796cb92011-02-02 11:57:41 -0600884 $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
Tom Zanussibcefe122009-11-25 01:15:49 -0600885 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
886 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300887 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
Tom Zanussibcefe122009-11-25 01:15:49 -0600888 $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
889 $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
890 $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600891 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
Tom Zanussi4d161f02010-01-27 02:27:58 -0600892 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600893 $(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 -0600894 $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
895 $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
Tom Zanussi82d156c2010-01-27 02:27:55 -0600896
Mike Galbraithc1079ab2009-06-02 10:17:34 +0200897ifdef BUILT_INS
898 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
899 $(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
Ingo Molnard24e4732009-04-20 13:32:07 +0200900ifneq (,$X)
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300901 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) $(OUTPUT)perf$X)), $(RM) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$p';)
Ingo Molnard24e4732009-04-20 13:32:07 +0200902endif
Mike Galbraithc1079ab2009-06-02 10:17:34 +0200903endif
Ingo Molnard24e4732009-04-20 13:32:07 +0200904
Ingo Molnarc1c23652009-05-30 12:38:51 +0200905install-doc:
906 $(MAKE) -C Documentation install
907
908install-man:
909 $(MAKE) -C Documentation install-man
910
911install-html:
912 $(MAKE) -C Documentation install-html
913
914install-info:
915 $(MAKE) -C Documentation install-info
916
917install-pdf:
918 $(MAKE) -C Documentation install-pdf
919
920quick-install-doc:
921 $(MAKE) -C Documentation quick-install
922
923quick-install-man:
924 $(MAKE) -C Documentation quick-install-man
925
926quick-install-html:
927 $(MAKE) -C Documentation quick-install-html
928
929
Ingo Molnard24e4732009-04-20 13:32:07 +0200930### Maintainer's dist rules
Mike Galbraithc1079ab2009-06-02 10:17:34 +0200931#
932# None right now
933#
934#
935# perf.spec: perf.spec.in
936# sed -e 's/@@VERSION@@/$(PERF_VERSION)/g' < $< > $@+
937# mv $@+ $@
938#
939# PERF_TARNAME=perf-$(PERF_VERSION)
940# dist: perf.spec perf-archive$(X) configure
941# ./perf-archive --format=tar \
942# --prefix=$(PERF_TARNAME)/ HEAD^{tree} > $(PERF_TARNAME).tar
943# @mkdir -p $(PERF_TARNAME)
944# @cp perf.spec configure $(PERF_TARNAME)
945# @echo $(PERF_VERSION) > $(PERF_TARNAME)/version
946# $(TAR) rf $(PERF_TARNAME).tar \
947# $(PERF_TARNAME)/perf.spec \
948# $(PERF_TARNAME)/configure \
949# $(PERF_TARNAME)/version
950# @$(RM) -r $(PERF_TARNAME)
951# gzip -f -9 $(PERF_TARNAME).tar
952#
953# htmldocs = perf-htmldocs-$(PERF_VERSION)
954# manpages = perf-manpages-$(PERF_VERSION)
955# dist-doc:
956# $(RM) -r .doc-tmp-dir
957# mkdir .doc-tmp-dir
958# $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
959# cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
960# gzip -n -9 -f $(htmldocs).tar
961# :
962# $(RM) -r .doc-tmp-dir
963# mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
964# $(MAKE) -C Documentation DESTDIR=./ \
965# man1dir=../.doc-tmp-dir/man1 \
966# man5dir=../.doc-tmp-dir/man5 \
967# man7dir=../.doc-tmp-dir/man7 \
968# install
969# cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
970# gzip -n -9 -f $(manpages).tar
971# $(RM) -r .doc-tmp-dir
972#
973# rpm: dist
974# $(RPMBUILD) -ta $(PERF_TARNAME).tar.gz
Ingo Molnard24e4732009-04-20 13:32:07 +0200975
Ingo Molnard24e4732009-04-20 13:32:07 +0200976### Cleaning rules
977
978distclean: clean
Mike Galbraithc1079ab2009-06-02 10:17:34 +0200979# $(RM) configure
Ingo Molnare0143ba2009-03-23 21:29:59 +0100980
981clean:
Arnaldo Carvalho de Melo568bb7b2011-02-01 15:05:00 -0200982 $(RM) $(OUTPUT){*.o,*/*.o,*/*/*.o,*/*/*/*.o,$(LIB_FILE),perf-archive}
Michael Witten8796cb92011-02-02 11:57:41 -0600983 $(RM) $(ALL_PROGRAMS) $(BUILT_INS) perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200984 $(RM) $(TEST_PROGRAMS)
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300985 $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
Ingo Molnar07800602009-04-20 15:00:56 +0200986 $(RM) -r $(PERF_TARNAME) .doc-tmp-dir
987 $(RM) $(PERF_TARNAME).tar.gz perf-core_$(PERF_VERSION)-*.tar.gz
Ingo Molnard24e4732009-04-20 13:32:07 +0200988 $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
Ingo Molnarc1c23652009-05-30 12:38:51 +0200989 $(MAKE) -C Documentation/ clean
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300990 $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)PERF-BUILD-OPTIONS
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200991 @python util/setup.py clean --build-lib='$(OUTPUT)python' \
992 --build-temp='$(OUTPUT)python/temp'
Ingo Molnard24e4732009-04-20 13:32:07 +0200993
994.PHONY: all install clean strip
995.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
Ingo Molnar07800602009-04-20 15:00:56 +0200996.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
997.PHONY: .FORCE-PERF-BUILD-OPTIONS
Ingo Molnard24e4732009-04-20 13:32:07 +0200998
Ingo Molnar07800602009-04-20 15:00:56 +0200999### Make sure built-ins do not have dups and listed in perf.c
Ingo Molnard24e4732009-04-20 13:32:07 +02001000#
1001check-builtins::
1002 ./check-builtins.sh
1003
1004### Test suite coverage testing
1005#
Mike Galbraithc1079ab2009-06-02 10:17:34 +02001006# None right now
1007#
1008# .PHONY: coverage coverage-clean coverage-build coverage-report
1009#
1010# coverage:
1011# $(MAKE) coverage-build
1012# $(MAKE) coverage-report
1013#
1014# coverage-clean:
1015# rm -f *.gcda *.gcno
1016#
1017# COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
1018# COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov
1019#
1020# coverage-build: coverage-clean
1021# $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
1022# $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
1023# -j1 test
1024#
1025# coverage-report:
1026# gcov -b *.c */*.c
1027# grep '^function.*called 0 ' *.c.gcov */*.c.gcov \
1028# | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
1029# | tee coverage-untested-functions