blob: aaf4dd3fd80330e780c4896c3cf6e08ba7a2c04d [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 Witten3643b132011-04-09 01:12:56 +0000168 $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' python util/setup.py \
169 --quiet build_ext \
170 --build-lib='$(OUTPUT)python' \
171 --build-temp='$(OUTPUT)python/temp'
Ingo Molnar07800602009-04-20 15:00:56 +0200172#
173# No Perl scripts right now:
174#
175
Michael Witten0a54fb62011-02-02 12:04:27 -0600176SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
Ingo Molnard24e4732009-04-20 13:32:07 +0200177
Ingo Molnar07800602009-04-20 15:00:56 +0200178#
Ingo Molnar125e7022009-04-20 16:13:46 +0200179# Single 'perf' binary right now:
Ingo Molnar07800602009-04-20 15:00:56 +0200180#
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300181PROGRAMS += $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200182
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200183LANG_BINDINGS =
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200184
Ingo Molnar07800602009-04-20 15:00:56 +0200185# what 'all' will build and 'install' will install, in perfexecdir
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200186ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200187
Ingo Molnar07800602009-04-20 15:00:56 +0200188# what 'all' will build but not install in perfexecdir
Michael Witten8796cb92011-02-02 11:57:41 -0600189OTHER_PROGRAMS = $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200190
191# Set paths to tools early so that they can be used for version tests.
192ifndef SHELL_PATH
193 SHELL_PATH = /bin/sh
194endif
195ifndef PERL_PATH
196 PERL_PATH = /usr/bin/perl
197endif
198
199export PERL_PATH
200
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300201LIB_FILE=$(OUTPUT)libperf.a
Ingo Molnard24e4732009-04-20 13:32:07 +0200202
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200203LIB_H += ../../include/linux/perf_event.h
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -0300204LIB_H += ../../include/linux/rbtree.h
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -0300205LIB_H += ../../include/linux/list.h
Hitoshi Mitake18e97e02010-01-30 20:43:24 +0900206LIB_H += ../../include/linux/hash.h
Masami Hiramatsu97698332009-10-16 20:08:18 -0400207LIB_H += ../../include/linux/stringify.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200208LIB_H += util/include/linux/bitmap.h
209LIB_H += util/include/linux/bitops.h
210LIB_H += util/include/linux/compiler.h
211LIB_H += util/include/linux/ctype.h
212LIB_H += util/include/linux/kernel.h
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -0300213LIB_H += util/include/linux/list.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200214LIB_H += util/include/linux/module.h
215LIB_H += util/include/linux/poison.h
216LIB_H += util/include/linux/prefetch.h
217LIB_H += util/include/linux/rbtree.h
Arnaldo Carvalho de Melo20639c12009-10-19 15:11:36 -0200218LIB_H += util/include/linux/string.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200219LIB_H += util/include/linux/types.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900220LIB_H += util/include/linux/linkage.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200221LIB_H += util/include/asm/asm-offsets.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200222LIB_H += util/include/asm/bug.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200223LIB_H += util/include/asm/byteorder.h
Arnaldo Carvalho de Melofb720142010-04-30 19:31:12 -0300224LIB_H += util/include/asm/hweight.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200225LIB_H += util/include/asm/swab.h
226LIB_H += util/include/asm/system.h
Arnaldo Carvalho de Melo79b9ad32009-10-19 15:31:31 -0200227LIB_H += util/include/asm/uaccess.h
Ian Munsiecd932c52010-04-20 16:58:32 +1000228LIB_H += util/include/dwarf-regs.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900229LIB_H += util/include/asm/dwarf2.h
230LIB_H += util/include/asm/cpufeature.h
Thomas Gleixner6eda5832009-05-01 18:29:57 +0200231LIB_H += perf.h
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200232LIB_H += util/annotate.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200233LIB_H += util/cache.h
234LIB_H += util/callchain.h
Arnaldo Carvalho de Melo7b2567c2010-02-03 16:52:04 -0200235LIB_H += util/build-id.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200236LIB_H += util/debug.h
Clark Williamsafe61f62009-11-08 09:01:37 -0600237LIB_H += util/debugfs.h
Arnaldo Carvalho de Meloec218fc2009-10-03 20:30:48 -0300238LIB_H += util/event.h
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200239LIB_H += util/evsel.h
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -0200240LIB_H += util/evlist.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200241LIB_H += util/exec_cmd.h
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +0200242LIB_H += util/types.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200243LIB_H += util/levenshtein.h
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -0200244LIB_H += util/map.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200245LIB_H += util/parse-options.h
Ingo Molnar8ad8db32009-05-26 11:10:09 +0200246LIB_H += util/parse-events.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200247LIB_H += util/quote.h
248LIB_H += util/util.h
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200249LIB_H += util/xyarray.h
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200250LIB_H += util/header.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200251LIB_H += util/help.h
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200252LIB_H += util/session.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200253LIB_H += util/strbuf.h
Arnaldo Carvalho de Melo25903402009-06-30 19:01:20 -0300254LIB_H += util/strlist.h
Masami Hiramatsu68baa432011-01-20 23:15:30 +0900255LIB_H += util/strfilter.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200256LIB_H += util/svghelper.h
Ingo Molnar148be2c2009-04-27 08:02:14 +0200257LIB_H += util/run-command.h
Ingo Molnara930d2c2009-05-27 09:50:13 +0200258LIB_H += util/sigchain.h
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300259LIB_H += util/symbol.h
Ingo Molnar8fc03212009-06-04 15:19:47 +0200260LIB_H += util/color.h
Brice Goglin8d513272009-08-07 13:55:24 +0200261LIB_H += util/values.h
John Kacurdd68ada2009-09-24 18:02:49 +0200262LIB_H += util/sort.h
John Kacur3d1d07e2009-09-28 15:32:55 +0200263LIB_H += util/hist.h
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -0300264LIB_H += util/thread.h
Arnaldo Carvalho de Melofd782602011-01-18 15:15:24 -0200265LIB_H += util/thread_map.h
Arnaldo Carvalho de Melo049ae802009-12-27 21:36:58 -0200266LIB_H += util/trace-event.h
Masami Hiramatsu57d250d2009-11-30 19:19:34 -0500267LIB_H += util/probe-finder.h
Masami Hiramatsu50656ee2009-11-30 19:19:58 -0500268LIB_H += util/probe-event.h
Arnaldo Carvalho de Melo3e1bbdc32010-05-14 20:05:21 -0300269LIB_H += util/pstack.h
Paul Mackerrasa12b51c2010-03-10 20:36:09 +1100270LIB_H += util/cpumap.h
Arnaldo Carvalho de Melo8c3e10e2011-01-31 14:50:39 -0200271LIB_H += util/top.h
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900272LIB_H += $(ARCH_INCLUDE)
Stephane Eranian023695d2011-02-14 11:20:01 +0200273LIB_H += util/cgroup.h
Ingo Molnard24e4732009-04-20 13:32:07 +0200274
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300275LIB_OBJS += $(OUTPUT)util/abspath.o
276LIB_OBJS += $(OUTPUT)util/alias.o
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200277LIB_OBJS += $(OUTPUT)util/annotate.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300278LIB_OBJS += $(OUTPUT)util/build-id.o
279LIB_OBJS += $(OUTPUT)util/config.o
280LIB_OBJS += $(OUTPUT)util/ctype.o
281LIB_OBJS += $(OUTPUT)util/debugfs.o
282LIB_OBJS += $(OUTPUT)util/environment.o
283LIB_OBJS += $(OUTPUT)util/event.o
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -0200284LIB_OBJS += $(OUTPUT)util/evlist.o
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200285LIB_OBJS += $(OUTPUT)util/evsel.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300286LIB_OBJS += $(OUTPUT)util/exec_cmd.o
287LIB_OBJS += $(OUTPUT)util/help.o
288LIB_OBJS += $(OUTPUT)util/levenshtein.o
289LIB_OBJS += $(OUTPUT)util/parse-options.o
290LIB_OBJS += $(OUTPUT)util/parse-events.o
291LIB_OBJS += $(OUTPUT)util/path.o
292LIB_OBJS += $(OUTPUT)util/rbtree.o
293LIB_OBJS += $(OUTPUT)util/bitmap.o
294LIB_OBJS += $(OUTPUT)util/hweight.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300295LIB_OBJS += $(OUTPUT)util/run-command.o
296LIB_OBJS += $(OUTPUT)util/quote.o
297LIB_OBJS += $(OUTPUT)util/strbuf.o
298LIB_OBJS += $(OUTPUT)util/string.o
299LIB_OBJS += $(OUTPUT)util/strlist.o
Masami Hiramatsu68baa432011-01-20 23:15:30 +0900300LIB_OBJS += $(OUTPUT)util/strfilter.o
Arnaldo Carvalho de Melo8c3e10e2011-01-31 14:50:39 -0200301LIB_OBJS += $(OUTPUT)util/top.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300302LIB_OBJS += $(OUTPUT)util/usage.o
303LIB_OBJS += $(OUTPUT)util/wrapper.o
304LIB_OBJS += $(OUTPUT)util/sigchain.o
305LIB_OBJS += $(OUTPUT)util/symbol.o
306LIB_OBJS += $(OUTPUT)util/color.o
307LIB_OBJS += $(OUTPUT)util/pager.o
308LIB_OBJS += $(OUTPUT)util/header.o
309LIB_OBJS += $(OUTPUT)util/callchain.o
310LIB_OBJS += $(OUTPUT)util/values.o
311LIB_OBJS += $(OUTPUT)util/debug.o
312LIB_OBJS += $(OUTPUT)util/map.o
Arnaldo Carvalho de Melo3e1bbdc32010-05-14 20:05:21 -0300313LIB_OBJS += $(OUTPUT)util/pstack.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300314LIB_OBJS += $(OUTPUT)util/session.o
315LIB_OBJS += $(OUTPUT)util/thread.o
Arnaldo Carvalho de Melofd782602011-01-18 15:15:24 -0200316LIB_OBJS += $(OUTPUT)util/thread_map.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300317LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
318LIB_OBJS += $(OUTPUT)util/trace-event-read.o
319LIB_OBJS += $(OUTPUT)util/trace-event-info.o
320LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
321LIB_OBJS += $(OUTPUT)util/svghelper.o
322LIB_OBJS += $(OUTPUT)util/sort.o
323LIB_OBJS += $(OUTPUT)util/hist.o
324LIB_OBJS += $(OUTPUT)util/probe-event.o
325LIB_OBJS += $(OUTPUT)util/util.o
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -0200326LIB_OBJS += $(OUTPUT)util/xyarray.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300327LIB_OBJS += $(OUTPUT)util/cpumap.o
Stephane Eranian023695d2011-02-14 11:20:01 +0200328LIB_OBJS += $(OUTPUT)util/cgroup.o
Ingo Molnard24e4732009-04-20 13:32:07 +0200329
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300330BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900331
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300332BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900333
334# Benchmark modules
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300335BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
336BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900337ifeq ($(RAW_ARCH),x86_64)
338BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
339endif
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300340BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
Hitoshi Mitakebfde82e2009-11-05 09:31:37 +0900341
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300342BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
Arnaldo Carvalho de Melo43adec92011-03-15 11:04:13 -0300343BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300344BUILTIN_OBJS += $(OUTPUT)builtin-help.o
345BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
346BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
347BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
348BUILTIN_OBJS += $(OUTPUT)builtin-list.o
349BUILTIN_OBJS += $(OUTPUT)builtin-record.o
350BUILTIN_OBJS += $(OUTPUT)builtin-report.o
351BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
352BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
353BUILTIN_OBJS += $(OUTPUT)builtin-top.o
Ingo Molnar133dc4c2010-11-16 18:45:39 +0100354BUILTIN_OBJS += $(OUTPUT)builtin-script.o
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300355BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
356BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
357BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800358BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
Arnaldo Carvalho de Melo1c6a8002010-04-29 18:58:32 -0300359BUILTIN_OBJS += $(OUTPUT)builtin-test.o
Tom Zanussi454c4072010-05-01 01:41:20 -0500360BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
Ingo Molnard24e4732009-04-20 13:32:07 +0200361
Ingo Molnar07800602009-04-20 15:00:56 +0200362PERFLIBS = $(LIB_FILE)
Ingo Molnard24e4732009-04-20 13:32:07 +0200363
Arnaldo Carvalho de Melo877108e2011-01-29 15:44:29 -0200364# Files needed for the python binding, perf.so
365# pyrf is just an internal name needed for all those wrappers.
366# This has to be in sync with what is in the 'sources' variable in
367# tools/perf/util/setup.py
368
369PYRF_OBJS += $(OUTPUT)util/cpumap.o
370PYRF_OBJS += $(OUTPUT)util/ctype.o
371PYRF_OBJS += $(OUTPUT)util/evlist.o
372PYRF_OBJS += $(OUTPUT)util/evsel.o
373PYRF_OBJS += $(OUTPUT)util/python.o
374PYRF_OBJS += $(OUTPUT)util/thread_map.o
375PYRF_OBJS += $(OUTPUT)util/util.o
376PYRF_OBJS += $(OUTPUT)util/xyarray.o
377
Ingo Molnard24e4732009-04-20 13:32:07 +0200378#
379# Platform specific tweaks
380#
381
382# We choose to avoid "if .. else if .. else .. endif endif"
383# because maintaining the nesting to match is a pain. If
384# we had "elif" things would have been much nicer...
385
Ingo Molnard24e4732009-04-20 13:32:07 +0200386-include config.mak.autogen
387-include config.mak
388
Ian Munsiecd932c52010-04-20 16:58:32 +1000389ifndef NO_DWARF
Robert Morella7112392010-11-16 14:16:33 -0800390FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300391ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y)
Masami Hiramatsu6b3c4ef2010-05-11 00:59:53 -0400392 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 +1000393 NO_DWARF := 1
394endif # Dwarf support
395endif # NO_DWARF
396
397-include arch/$(ARCH)/Makefile
398
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300399ifneq ($(OUTPUT),)
400 BASIC_CFLAGS += -I$(OUTPUT)
401endif
402
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300403FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
404ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y)
405 FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS)
406 ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y)
407 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
408 else
409 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel);
410 endif
Randy Dunlap1abc7f52009-10-18 19:20:24 -0700411endif
412
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300413ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y)
414 BASIC_CFLAGS += -DLIBELF_NO_MMAP
Peter Zijlstra9424edc2009-08-05 14:05:16 +0200415endif
416
Masami Hiramatsuca721e42010-03-22 13:10:27 -0300417ifndef NO_DWARF
Ian Munsiecd932c52010-04-20 16:58:32 +1000418ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
419 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
420else
Robert Morella7112392010-11-16 14:16:33 -0800421 BASIC_CFLAGS += -DDWARF_SUPPORT
Masami Hiramatsu804b3602010-02-25 08:35:42 -0500422 EXTLIBS += -lelf -ldw
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300423 LIB_OBJS += $(OUTPUT)util/probe-finder.o
Ian Munsiecd932c52010-04-20 16:58:32 +1000424endif # PERF_HAVE_DWARF_REGS
425endif # NO_DWARF
Masami Hiramatsu4ea42b12009-10-08 17:17:38 -0400426
Arnaldo Carvalho de Melo94f3ca92010-05-17 18:18:11 -0300427ifdef NO_NEWT
428 BASIC_CFLAGS += -DNO_NEWT_SUPPORT
429else
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300430 FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt
431 ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y)
432 msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev);
433 BASIC_CFLAGS += -DNO_NEWT_SUPPORT
434 else
435 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
436 BASIC_CFLAGS += -I/usr/include/slang
437 EXTLIBS += -lnewt -lslang
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300438 LIB_OBJS += $(OUTPUT)util/ui/setup.o
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300439 LIB_OBJS += $(OUTPUT)util/ui/browser.o
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300440 LIB_OBJS += $(OUTPUT)util/ui/browsers/annotate.o
Arnaldo Carvalho de Melod1b4f242010-08-10 15:49:07 -0300441 LIB_OBJS += $(OUTPUT)util/ui/browsers/hists.o
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300442 LIB_OBJS += $(OUTPUT)util/ui/browsers/map.o
Arnaldo Carvalho de Meloc0443df2011-01-31 18:19:33 -0200443 LIB_OBJS += $(OUTPUT)util/ui/browsers/top.o
Arnaldo Carvalho de Melo55755362010-08-08 19:48:31 -0300444 LIB_OBJS += $(OUTPUT)util/ui/helpline.o
Arnaldo Carvalho de Melo34cea7f2010-08-08 19:56:47 -0300445 LIB_OBJS += $(OUTPUT)util/ui/progress.o
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300446 LIB_OBJS += $(OUTPUT)util/ui/util.o
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300447 LIB_H += util/ui/browser.h
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300448 LIB_H += util/ui/browsers/map.h
Arnaldo Carvalho de Melo55755362010-08-08 19:48:31 -0300449 LIB_H += util/ui/helpline.h
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300450 LIB_H += util/ui/libslang.h
Arnaldo Carvalho de Melo34cea7f2010-08-08 19:56:47 -0300451 LIB_H += util/ui/progress.h
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -0300452 LIB_H += util/ui/util.h
Arnaldo Carvalho de Melo5c35d692011-02-09 11:38:43 -0200453 LIB_H += util/ui/ui.h
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300454 endif
Jamie Ilescc835752009-12-11 09:21:00 +0000455endif
Tom Zanussi16c632d2009-11-25 01:15:48 -0600456
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300457ifdef NO_LIBPERL
Tom Zanussi16c632d2009-11-25 01:15:48 -0600458 BASIC_CFLAGS += -DNO_LIBPERL
459else
Tom Zanussif2481f32010-08-24 00:23:50 -0500460 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
461 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
462 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300463 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
Tom Zanussibfde7442010-06-17 23:40:06 -0500464 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300465
466 ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y)
467 BASIC_CFLAGS += -DNO_LIBPERL
468 else
Tom Zanussif2481f32010-08-24 00:23:50 -0500469 ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS)
470 EXTLIBS += $(PERL_EMBED_LIBADD)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300471 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
472 LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
473 endif
Tom Zanussi16c632d2009-11-25 01:15:48 -0600474endif
475
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300476ifdef NO_LIBPYTHON
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600477 BASIC_CFLAGS += -DNO_LIBPYTHON
478else
Tom Zanussif2481f32010-08-24 00:23:50 -0500479 PYTHON_EMBED_LDOPTS = $(shell python-config --ldflags 2>/dev/null)
480 PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
481 PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300482 PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
483 FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
484 ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200485 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 -0300486 BASIC_CFLAGS += -DNO_LIBPYTHON
487 else
Tom Zanussif2481f32010-08-24 00:23:50 -0500488 ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
489 EXTLIBS += $(PYTHON_EMBED_LIBADD)
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300490 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
491 LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
Arnaldo Carvalho de Melo978f6262011-02-01 16:40:51 -0200492 LANG_BINDINGS += $(OUTPUT)python/perf.so
Arnaldo Carvalho de Melof9af3a42010-06-09 16:57:39 -0300493 endif
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600494endif
495
Peter Zijlstra2cdbc462009-08-05 14:05:16 +0200496ifdef NO_DEMANGLE
497 BASIC_CFLAGS += -DNO_DEMANGLE
498else
Conny Seidel167a58f2010-07-01 15:19:26 +0200499 ifdef HAVE_CPLUS_DEMANGLE
500 EXTLIBS += -liberty
501 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
502 else
503 FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd
504 has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
505 ifeq ($(has_bfd),y)
506 EXTLIBS += -lbfd
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300507 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200508 FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
509 has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY))
510 ifeq ($(has_bfd_iberty),y)
511 EXTLIBS += -lbfd -liberty
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300512 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200513 FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
514 has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z))
515 ifeq ($(has_bfd_iberty_z),y)
516 EXTLIBS += -lbfd -liberty -lz
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300517 else
Conny Seidel167a58f2010-07-01 15:19:26 +0200518 FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty
519 has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE))
520 ifeq ($(has_cplus_demangle),y)
521 EXTLIBS += -liberty
522 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
523 else
524 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
525 BASIC_CFLAGS += -DNO_DEMANGLE
526 endif
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -0300527 endif
528 endif
529 endif
Peter Zijlstra2cdbc462009-08-05 14:05:16 +0200530 endif
531endif
532
Kirill A. Shutemovf4e7ac02010-08-21 03:38:20 +0300533
534ifdef NO_STRLCPY
535 BASIC_CFLAGS += -DNO_STRLCPY
536else
537 ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
538 BASIC_CFLAGS += -DNO_STRLCPY
539 endif
540endif
541
Ingo Molnard24e4732009-04-20 13:32:07 +0200542ifneq ($(findstring $(MAKEFLAGS),s),s)
543ifndef V
544 QUIET_CC = @echo ' ' CC $@;
545 QUIET_AR = @echo ' ' AR $@;
546 QUIET_LINK = @echo ' ' LINK $@;
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300547 QUIET_MKDIR = @echo ' ' MKDIR $@;
Ingo Molnard24e4732009-04-20 13:32:07 +0200548 QUIET_GEN = @echo ' ' GEN $@;
Ingo Molnard24e4732009-04-20 13:32:07 +0200549endif
550endif
551
552ifdef ASCIIDOC8
553 export ASCIIDOC8
554endif
555
556# Shell quote (do not use $(call) to accommodate ancient setups);
557
Ingo Molnar07800602009-04-20 15:00:56 +0200558ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
Ingo Molnard24e4732009-04-20 13:32:07 +0200559
560DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
561bindir_SQ = $(subst ','\'',$(bindir))
562bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
563mandir_SQ = $(subst ','\'',$(mandir))
564infodir_SQ = $(subst ','\'',$(infodir))
Ingo Molnar07800602009-04-20 15:00:56 +0200565perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
Ingo Molnard24e4732009-04-20 13:32:07 +0200566template_dir_SQ = $(subst ','\'',$(template_dir))
567htmldir_SQ = $(subst ','\'',$(htmldir))
568prefix_SQ = $(subst ','\'',$(prefix))
569
570SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
Ingo Molnard24e4732009-04-20 13:32:07 +0200571
Ian Munsieb38aa892010-11-29 11:53:07 +1100572LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive $(EXTLIBS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200573
Ingo Molnard24e4732009-04-20 13:32:07 +0200574ALL_CFLAGS += $(BASIC_CFLAGS)
Hitoshi Mitakeea7872b2010-11-25 16:04:53 +0900575ALL_CFLAGS += $(ARCH_CFLAGS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200576ALL_LDFLAGS += $(BASIC_LDFLAGS)
577
Michael Wittena3d1ee12011-02-02 14:22:08 -0600578export INSTALL SHELL_PATH
Ingo Molnard24e4732009-04-20 13:32:07 +0200579
580
581### Build rules
582
583SHELL = $(SHELL_PATH)
584
Michael Wittena3d1ee12011-02-02 14:22:08 -0600585all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200586
587please_set_SHELL_PATH_to_a_more_modern_shell:
588 @$$(:)
589
590shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
591
Michael Witten8796cb92011-02-02 11:57:41 -0600592strip: $(PROGRAMS) $(OUTPUT)perf
593 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
Ingo Molnard24e4732009-04-20 13:32:07 +0200594
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300595$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
Ingo Molnar07800602009-04-20 15:00:56 +0200596 $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
597 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300598 $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200599
Michael Witten8796cb92011-02-02 11:57:41 -0600600$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
Tom Zanussif2481f32010-08-24 00:23:50 -0500601 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
602 $(BUILTIN_OBJS) $(LIBS) -o $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200603
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300604$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
605 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Ingo Molnar07800602009-04-20 15:00:56 +0200606 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
607 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
608 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200609
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300610$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
611 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Arjan van de Ven10274982009-09-12 07:53:05 +0200612 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
613 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
614 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
615
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300616$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
Ingo Molnard24e4732009-04-20 13:32:07 +0200617
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300618$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
Mulyadi Santosa1ad05602009-09-26 02:01:41 +0700619 $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
Ingo Molnard24e4732009-04-20 13:32:07 +0200620
Michael Wittena3d1ee12011-02-02 14:22:08 -0600621$(SCRIPTS) : % : %.sh
622 $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
Ingo Molnard24e4732009-04-20 13:32:07 +0200623
Ingo Molnar07800602009-04-20 15:00:56 +0200624# These can record PERF_VERSION
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300625$(OUTPUT)perf.o perf.spec \
Michael Wittena3d1ee12011-02-02 14:22:08 -0600626 $(SCRIPTS) \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300627 : $(OUTPUT)PERF-VERSION-FILE
Ingo Molnard24e4732009-04-20 13:32:07 +0200628
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300629$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
630 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
631$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
Ingo Molnard24e4732009-04-20 13:32:07 +0200632 $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300633$(OUTPUT)%.o: %.S
634 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200635
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300636$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
637 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
Ingo Molnar07800602009-04-20 15:00:56 +0200638 '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
Ingo Molnard24e4732009-04-20 13:32:07 +0200639 '-DBINDIR="$(bindir_relative_SQ)"' \
640 '-DPREFIX="$(prefix_SQ)"' \
641 $<
642
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300643$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
644 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
Ingo Molnard24e4732009-04-20 13:32:07 +0200645
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -0300646$(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS
647 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
648
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -0300649$(OUTPUT)util/ui/browsers/annotate.o: util/ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
650 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
651
Arnaldo Carvalho de Meloc0443df2011-01-31 18:19:33 -0200652$(OUTPUT)util/ui/browsers/top.o: util/ui/browsers/top.c $(OUTPUT)PERF-CFLAGS
653 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
654
Arnaldo Carvalho de Melod1b4f242010-08-10 15:49:07 -0300655$(OUTPUT)util/ui/browsers/hists.o: util/ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
656 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
657
Arnaldo Carvalho de Melob1b02672010-08-10 15:37:34 -0300658$(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
659 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
660
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300661$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
662 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -0300663
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300664$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.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-shadow $<
Tom Zanussi16c632d2009-11-25 01:15:48 -0600666
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300667$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
668 $(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 -0600669
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300670$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.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-shadow $<
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600672
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300673$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
674 $(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 -0600675
Michael Witten8796cb92011-02-02 11:57:41 -0600676$(OUTPUT)perf-%: %.o $(PERFLIBS)
Ingo Molnard24e4732009-04-20 13:32:07 +0200677 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
678
Ingo Molnard24e4732009-04-20 13:32:07 +0200679$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
Michael Witten8796cb92011-02-02 11:57:41 -0600680$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
Ingo Molnard24e4732009-04-20 13:32:07 +0200681
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300682# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So
683# we depend the various files onto their directories.
684DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
Kusanagi Kouichi39cfae62010-09-26 14:17:42 -0300685$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
Bernd Petrovitsch033a2732010-08-17 12:22:08 -0300686# In the second step, we make a rule to actually create these directories
687$(sort $(dir $(DIRECTORY_DEPS))):
688 $(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
689
Ingo Molnard24e4732009-04-20 13:32:07 +0200690$(LIB_FILE): $(LIB_OBJS)
691 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
692
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800693help:
694 @echo 'Perf make targets:'
695 @echo ' doc - make *all* documentation (see below)'
696 @echo ' man - make manpage documentation (access with man <foo>)'
697 @echo ' html - make html documentation'
698 @echo ' info - make GNU info documentation (access with info <foo>)'
699 @echo ' pdf - make pdf documentation'
700 @echo ' TAGS - use etags to make tag information for source browsing'
701 @echo ' tags - use ctags to make tag information for source browsing'
702 @echo ' cscope - use cscope to make interactive browsing database'
703 @echo ''
704 @echo 'Perf install targets:'
705 @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
706 @echo ' HINT: use "make prefix=<path> <install target>" to install to a particular'
707 @echo ' path like make prefix=/usr/local install install-doc'
708 @echo ' install - install compiled binaries'
709 @echo ' install-doc - install *all* documentation'
710 @echo ' install-man - install manpage documentation'
711 @echo ' install-html - install html documentation'
712 @echo ' install-info - install GNU info documentation'
713 @echo ' install-pdf - install pdf documentation'
714 @echo ''
715 @echo ' quick-install-doc - alias for quick-install-man'
716 @echo ' quick-install-man - install the documentation quickly'
717 @echo ' quick-install-html - install the html documentation quickly'
718 @echo ''
719 @echo 'Perf maintainer targets:'
720 @echo ' distclean - alias to clean'
721 @echo ' clean - clean all binary objects and build output'
722
Ingo Molnarc1c23652009-05-30 12:38:51 +0200723doc:
724 $(MAKE) -C Documentation all
725
726man:
727 $(MAKE) -C Documentation man
728
729html:
730 $(MAKE) -C Documentation html
731
732info:
733 $(MAKE) -C Documentation info
734
735pdf:
736 $(MAKE) -C Documentation pdf
737
Ingo Molnard24e4732009-04-20 13:32:07 +0200738TAGS:
739 $(RM) TAGS
740 $(FIND) . -name '*.[hcS]' -print | xargs etags -a
741
742tags:
743 $(RM) tags
744 $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
745
746cscope:
747 $(RM) cscope*
748 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
749
750### Detect prefix changes
751TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
Ingo Molnar07800602009-04-20 15:00:56 +0200752 $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
Ingo Molnard24e4732009-04-20 13:32:07 +0200753
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300754$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
Ingo Molnard24e4732009-04-20 13:32:07 +0200755 @FLAGS='$(TRACK_CFLAGS)'; \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300756 if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
Ingo Molnard24e4732009-04-20 13:32:07 +0200757 echo 1>&2 " * new build flags or prefix"; \
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300758 echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
Ingo Molnard24e4732009-04-20 13:32:07 +0200759 fi
760
Ingo Molnard24e4732009-04-20 13:32:07 +0200761### Testing rules
762
Ingo Molnard24e4732009-04-20 13:32:07 +0200763# GNU make supports exporting all variables by "export" without parameters.
764# However, the environment gets quite big, and some programs have problems
765# with that.
766
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300767check: $(OUTPUT)common-cmds.h
Ingo Molnard24e4732009-04-20 13:32:07 +0200768 if sparse; \
769 then \
Ingo Molnar148be2c2009-04-27 08:02:14 +0200770 for i in *.c */*.c; \
Ingo Molnard24e4732009-04-20 13:32:07 +0200771 do \
772 sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
773 done; \
774 else \
Ingo Molnard24e4732009-04-20 13:32:07 +0200775 exit 1; \
776 fi
777
Ingo Molnard24e4732009-04-20 13:32:07 +0200778### Installation rules
779
Ingo Molnar07800602009-04-20 15:00:56 +0200780ifneq ($(filter /%,$(firstword $(perfexecdir))),)
781perfexec_instdir = $(perfexecdir)
Ingo Molnard24e4732009-04-20 13:32:07 +0200782else
Ingo Molnar07800602009-04-20 15:00:56 +0200783perfexec_instdir = $(prefix)/$(perfexecdir)
Ingo Molnard24e4732009-04-20 13:32:07 +0200784endif
Ingo Molnar07800602009-04-20 15:00:56 +0200785perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
Ingo Molnard24e4732009-04-20 13:32:07 +0200786
787install: all
788 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
Michael Witten8796cb92011-02-02 11:57:41 -0600789 $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
Tom Zanussibcefe122009-11-25 01:15:49 -0600790 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
791 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300792 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
Tom Zanussibcefe122009-11-25 01:15:49 -0600793 $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
794 $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
795 $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600796 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
Tom Zanussi4d161f02010-01-27 02:27:58 -0600797 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
Tom Zanussi7e4b21b2010-01-27 02:27:57 -0600798 $(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 -0600799 $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
800 $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
Tom Zanussi82d156c2010-01-27 02:27:55 -0600801
Ingo Molnarc1c23652009-05-30 12:38:51 +0200802install-doc:
803 $(MAKE) -C Documentation install
804
805install-man:
806 $(MAKE) -C Documentation install-man
807
808install-html:
809 $(MAKE) -C Documentation install-html
810
811install-info:
812 $(MAKE) -C Documentation install-info
813
814install-pdf:
815 $(MAKE) -C Documentation install-pdf
816
817quick-install-doc:
818 $(MAKE) -C Documentation quick-install
819
820quick-install-man:
821 $(MAKE) -C Documentation quick-install-man
822
823quick-install-html:
824 $(MAKE) -C Documentation quick-install-html
825
Ingo Molnard24e4732009-04-20 13:32:07 +0200826### Cleaning rules
827
Ingo Molnare0143ba2009-03-23 21:29:59 +0100828clean:
Arnaldo Carvalho de Melo568bb7b2011-02-01 15:05:00 -0200829 $(RM) $(OUTPUT){*.o,*/*.o,*/*/*.o,*/*/*/*.o,$(LIB_FILE),perf-archive}
Michael Wittena3d1ee12011-02-02 14:22:08 -0600830 $(RM) $(ALL_PROGRAMS) perf
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -0300831 $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
Ingo Molnarc1c23652009-05-30 12:38:51 +0200832 $(MAKE) -C Documentation/ clean
Michael Wittena3d1ee12011-02-02 14:22:08 -0600833 $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS
Arnaldo Carvalho de Melo067187f2011-02-01 14:57:02 -0200834 @python util/setup.py clean --build-lib='$(OUTPUT)python' \
835 --build-temp='$(OUTPUT)python/temp'
Ingo Molnard24e4732009-04-20 13:32:07 +0200836
837.PHONY: all install clean strip
838.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
Ingo Molnar07800602009-04-20 15:00:56 +0200839.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS