perf tools: Makefile: Remove tool-specific cruft
[deliverable/linux.git] / tools / perf / Makefile
CommitLineData
c29ede61
ACM
1ifeq ("$(origin O)", "command line")
2 OUTPUT := $(O)/
3endif
4
d24e473e
IM
5# The default target of this Makefile is...
6all::
e0143bad 7
ecafda60
KK
8ifneq ($(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
d24e473e 14# Define V=1 to have a more verbose compile.
7baed9af 15# Define V=2 to have an even more verbose compile.
d24e473e 16#
d24e473e
IM
17# 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#
75138650 21# Define LDFLAGS=-static to build a static binary.
81516c5f
MT
22#
23# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
ca721e45
MH
24#
25# Define NO_DWARF if you do not want debug-info analysis feature at all.
e0143bad 26
c29ede61
ACM
27$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
28 @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
29-include $(OUTPUT)PERF-VERSION-FILE
e0143bad 30
d24e473e
IM
31uname_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')
de9ac07b 37
cd932c59
IM
38ARCH ?= $(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)
ea7872b9 49 RAW_ARCH := x86_64
cd932c59 50 ARCH := x86
ea7872b9
HM
51 ARCH_CFLAGS := -DARCH_X86_64
52 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S
cd932c59
IM
53endif
54
d24e473e 55# CFLAGS and LDFLAGS are for the users to override from the command line.
de9ac07b 56
83a0944f
IM
57#
58# Include saner warnings here, which can catch bugs:
59#
61562445 60
ec29b8d2 61EXTRA_WARNINGS := -Wformat
61562445
IM
62EXTRA_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
61562445
IM
68EXTRA_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
61562445
IM
73EXTRA_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
83a0944f 81
60d526f7
SR
82ifeq ("$(origin DEBUG)", "command line")
83 PERF_DEBUG = $(DEBUG)
84endif
85ifndef PERF_DEBUG
86 CFLAGS_OPTIMIZE = -O6
87endif
88
6b01f2c4 89CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
75138650 90EXTLIBS = -lpthread -lrt -lelf -lm
b0f86f5a 91ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
d24e473e
IM
92ALL_LDFLAGS = $(LDFLAGS)
93STRIP ?= strip
94
95# Among the variables below, these:
07800601 96# perfexecdir
d24e473e
IM
97# template_dir
98# mandir
99# infodir
100# htmldir
07800601 101# ETC_PERFCONFIG (but not sysconfdir)
d24e473e 102# can be specified as a relative path some/where/else;
07800601 103# this is interpreted as relative to $(prefix) and "perf" at
d24e473e
IM
104# 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
7ae5f213
JK
107# Make the path relative to DESTDIR, not to prefix
108ifndef DESTDIR
d24e473e 109prefix = $(HOME)
7ae5f213 110endif
d24e473e
IM
111bindir_relative = bin
112bindir = $(prefix)/$(bindir_relative)
113mandir = share/man
114infodir = share/info
07800601 115perfexecdir = libexec/perf-core
d24e473e 116sharedir = $(prefix)/share
07800601
IM
117template_dir = share/perf-core/templates
118htmldir = share/doc/perf-doc
d24e473e
IM
119ifeq ($(prefix),/usr)
120sysconfdir = /etc
07800601 121ETC_PERFCONFIG = $(sysconfdir)/perfconfig
d24e473e
IM
122else
123sysconfdir = $(prefix)/etc
07800601 124ETC_PERFCONFIG = etc/perfconfig
d24e473e
IM
125endif
126lib = lib
d24e473e 127
d24e473e
IM
128export prefix bindir sharedir sysconfdir
129
cc835752
JI
130CC = $(CROSS_COMPILE)gcc
131AR = $(CROSS_COMPILE)ar
d24e473e 132RM = rm -f
033a273f 133MKDIR = mkdir
d24e473e
IM
134TAR = tar
135FIND = find
136INSTALL = install
137RPMBUILD = rpmbuild
d24e473e
IM
138PTHREAD_LIBS = -lpthread
139
d24e473e
IM
140# 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
83039518
ACM
144ifeq ($(V), 2)
145 QUIET_STDERR = ">/dev/null"
146else
147 QUIET_STDERR = ">/dev/null 2>&1"
148endif
149
f9af3a4c 150-include feature-tests.mak
1703f2c3 151
f9af3a4c
ACM
152ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y)
153 CFLAGS := $(CFLAGS) -fstack-protector-all
5d7bdab7 154endif
d24e473e 155
065bef5a
ACM
156ifeq ($(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
d24e473e
IM
163
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.)
cd932c59 169BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include
d24e473e
IM
170BASIC_LDFLAGS =
171
172# Guard against environment variables
173BUILTIN_OBJS =
174BUILT_INS =
d24e473e
IM
175LIB_H =
176LIB_OBJS =
877108e4 177PYRF_OBJS =
d24e473e
IM
178SCRIPT_SH =
179TEST_PROGRAMS =
180
2c585174 181SCRIPT_SH += perf-archive.sh
07800601 182
f2481f3d
TZ
183grep-libs = $(filter -l%,$(1))
184strip-libs = $(filter-out -l%,$(1))
185
067187fc 186$(OUTPUT)python/perf.so: $(PYRF_OBJS)
9c56dfeb 187 $(QUIET_GEN)python util/setup.py --quiet build_ext --build-lib='$(OUTPUT)python' \
067187fc 188 --build-temp='$(OUTPUT)python/temp'
07800601
IM
189#
190# No Perl scripts right now:
191#
192
0a54fb63 193SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
d24e473e
IM
194
195# Empty...
196EXTRA_PROGRAMS =
197
07800601 198# ... and all the rest that could be moved out of bindir to perfexecdir
d24e473e 199PROGRAMS += $(EXTRA_PROGRAMS)
07800601
IM
200
201#
125e702b 202# Single 'perf' binary right now:
07800601 203#
c29ede61 204PROGRAMS += $(OUTPUT)perf
d24e473e 205
978f626c 206LANG_BINDINGS =
067187fc 207
d24e473e
IM
208# 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.
07800601 210#
07800601
IM
211
212# what 'all' will build and 'install' will install, in perfexecdir
978f626c 213ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
d24e473e 214
07800601 215# what 'all' will build but not install in perfexecdir
8796cb9d 216OTHER_PROGRAMS = $(OUTPUT)perf
d24e473e
IM
217
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
c29ede61 228LIB_FILE=$(OUTPUT)libperf.a
07800601 229
cdd6c482 230LIB_H += ../../include/linux/perf_event.h
43cbcd8a 231LIB_H += ../../include/linux/rbtree.h
5da50258 232LIB_H += ../../include/linux/list.h
18e97e06 233LIB_H += ../../include/linux/hash.h
9769833b 234LIB_H += ../../include/linux/stringify.h
79b9ad36
ACM
235LIB_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
5da50258 240LIB_H += util/include/linux/list.h
79b9ad36
ACM
241LIB_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
20639c15 245LIB_H += util/include/linux/string.h
79b9ad36 246LIB_H += util/include/linux/types.h
ea7872b9 247LIB_H += util/include/linux/linkage.h
79b9ad36 248LIB_H += util/include/asm/asm-offsets.h
049ae80b 249LIB_H += util/include/asm/bug.h
79b9ad36 250LIB_H += util/include/asm/byteorder.h
fb72014d 251LIB_H += util/include/asm/hweight.h
79b9ad36
ACM
252LIB_H += util/include/asm/swab.h
253LIB_H += util/include/asm/system.h
79b9ad36 254LIB_H += util/include/asm/uaccess.h
cd932c59 255LIB_H += util/include/dwarf-regs.h
ea7872b9
HM
256LIB_H += util/include/asm/dwarf2.h
257LIB_H += util/include/asm/cpufeature.h
6eda5838 258LIB_H += perf.h
78f7defe 259LIB_H += util/annotate.h
049ae80b
ACM
260LIB_H += util/cache.h
261LIB_H += util/callchain.h
7b2567c1 262LIB_H += util/build-id.h
049ae80b 263LIB_H += util/debug.h
afe61f67 264LIB_H += util/debugfs.h
ec218fc4 265LIB_H += util/event.h
69aad6f1 266LIB_H += util/evsel.h
361c99a6 267LIB_H += util/evlist.h
049ae80b 268LIB_H += util/exec_cmd.h
7c6a1c65 269LIB_H += util/types.h
148be2c1 270LIB_H += util/levenshtein.h
4a58e611 271LIB_H += util/map.h
148be2c1 272LIB_H += util/parse-options.h
8ad8db37 273LIB_H += util/parse-events.h
148be2c1
IM
274LIB_H += util/quote.h
275LIB_H += util/util.h
69aad6f1 276LIB_H += util/xyarray.h
94c744b6 277LIB_H += util/header.h
148be2c1 278LIB_H += util/help.h
94c744b6 279LIB_H += util/session.h
148be2c1 280LIB_H += util/strbuf.h
25903407 281LIB_H += util/strlist.h
68baa431 282LIB_H += util/strfilter.h
049ae80b 283LIB_H += util/svghelper.h
148be2c1 284LIB_H += util/run-command.h
a930d2c0 285LIB_H += util/sigchain.h
a2928c42 286LIB_H += util/symbol.h
8fc0321f 287LIB_H += util/color.h
8d513270 288LIB_H += util/values.h
dd68ada2 289LIB_H += util/sort.h
3d1d07ec 290LIB_H += util/hist.h
1b46cddf 291LIB_H += util/thread.h
fd78260b 292LIB_H += util/thread_map.h
049ae80b 293LIB_H += util/trace-event.h
57d250df 294LIB_H += util/probe-finder.h
50656eec 295LIB_H += util/probe-event.h
3e1bbdc3 296LIB_H += util/pstack.h
a12b51c4 297LIB_H += util/cpumap.h
8c3e10eb 298LIB_H += util/top.h
ea7872b9 299LIB_H += $(ARCH_INCLUDE)
023695d9 300LIB_H += util/cgroup.h
148be2c1 301
c29ede61
ACM
302LIB_OBJS += $(OUTPUT)util/abspath.o
303LIB_OBJS += $(OUTPUT)util/alias.o
78f7defe 304LIB_OBJS += $(OUTPUT)util/annotate.o
c29ede61
ACM
305LIB_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
361c99a6 311LIB_OBJS += $(OUTPUT)util/evlist.o
69aad6f1 312LIB_OBJS += $(OUTPUT)util/evsel.o
c29ede61
ACM
313LIB_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
c29ede61
ACM
322LIB_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
68baa431 327LIB_OBJS += $(OUTPUT)util/strfilter.o
8c3e10eb 328LIB_OBJS += $(OUTPUT)util/top.o
c29ede61
ACM
329LIB_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
3e1bbdc3 340LIB_OBJS += $(OUTPUT)util/pstack.o
c29ede61
ACM
341LIB_OBJS += $(OUTPUT)util/session.o
342LIB_OBJS += $(OUTPUT)util/thread.o
fd78260b 343LIB_OBJS += $(OUTPUT)util/thread_map.o
c29ede61
ACM
344LIB_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
69aad6f1 353LIB_OBJS += $(OUTPUT)util/xyarray.o
c29ede61 354LIB_OBJS += $(OUTPUT)util/cpumap.o
023695d9 355LIB_OBJS += $(OUTPUT)util/cgroup.o
c29ede61
ACM
356
357BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
358
359BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
bfde82ef
HM
360
361# Benchmark modules
c29ede61
ACM
362BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
363BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
ea7872b9
HM
364ifeq ($(RAW_ARCH),x86_64)
365BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
366endif
c29ede61
ACM
367BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
368
369BUILTIN_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
133dc4c3 380BUILTIN_OBJS += $(OUTPUT)builtin-script.o
c29ede61
ACM
381BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
382BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
383BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
a1645ce1 384BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
1c6a800c 385BUILTIN_OBJS += $(OUTPUT)builtin-test.o
454c407e 386BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
07800601
IM
387
388PERFLIBS = $(LIB_FILE)
d24e473e 389
877108e4
ACM
390# 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
d24e473e
IM
404#
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
d24e473e
IM
412-include config.mak.autogen
413-include config.mak
414
cd932c59 415ifndef NO_DWARF
a7112397 416FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
f9af3a4c 417ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y)
6b3c4ef5 418 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);
cd932c59
IM
419 NO_DWARF := 1
420endif # Dwarf support
421endif # NO_DWARF
422
423-include arch/$(ARCH)/Makefile
424
c29ede61
ACM
425ifneq ($(OUTPUT),)
426 BASIC_CFLAGS += -I$(OUTPUT)
427endif
428
f9af3a4c
ACM
429FLAGS_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
1abc7f55
RD
437endif
438
f9af3a4c
ACM
439ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y)
440 BASIC_CFLAGS += -DLIBELF_NO_MMAP
9424edc2
PZ
441endif
442
ca721e45 443ifndef NO_DWARF
cd932c59
IM
444ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
445 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
446else
a7112397 447 BASIC_CFLAGS += -DDWARF_SUPPORT
804b3606 448 EXTLIBS += -lelf -ldw
c29ede61 449 LIB_OBJS += $(OUTPUT)util/probe-finder.o
cd932c59
IM
450endif # PERF_HAVE_DWARF_REGS
451endif # NO_DWARF
4ea42b18 452
94f3ca95
ACM
453ifdef NO_NEWT
454 BASIC_CFLAGS += -DNO_NEWT_SUPPORT
455else
f9af3a4c
ACM
456 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
1e6dd077 464 LIB_OBJS += $(OUTPUT)util/ui/setup.o
ef8f34aa 465 LIB_OBJS += $(OUTPUT)util/ui/browser.o
211ef127 466 LIB_OBJS += $(OUTPUT)util/ui/browsers/annotate.o
d1b4f249 467 LIB_OBJS += $(OUTPUT)util/ui/browsers/hists.o
b1b02673 468 LIB_OBJS += $(OUTPUT)util/ui/browsers/map.o
c0443df1 469 LIB_OBJS += $(OUTPUT)util/ui/browsers/top.o
5575536f 470 LIB_OBJS += $(OUTPUT)util/ui/helpline.o
34cea7f7 471 LIB_OBJS += $(OUTPUT)util/ui/progress.o
1e6dd077 472 LIB_OBJS += $(OUTPUT)util/ui/util.o
ef8f34aa 473 LIB_H += util/ui/browser.h
b1b02673 474 LIB_H += util/ui/browsers/map.h
5575536f 475 LIB_H += util/ui/helpline.h
211ef127 476 LIB_H += util/ui/libslang.h
34cea7f7 477 LIB_H += util/ui/progress.h
1e6dd077 478 LIB_H += util/ui/util.h
5c35d69f 479 LIB_H += util/ui/ui.h
f9af3a4c 480 endif
cc835752 481endif
16c632de 482
f9af3a4c 483ifdef NO_LIBPERL
16c632de
TZ
484 BASIC_CFLAGS += -DNO_LIBPERL
485else
f2481f3d
TZ
486 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))
f9af3a4c 489 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
bfde7448 490 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
16c632de 491
f9af3a4c
ACM
492 ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y)
493 BASIC_CFLAGS += -DNO_LIBPERL
494 else
f2481f3d
TZ
495 ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS)
496 EXTLIBS += $(PERL_EMBED_LIBADD)
f9af3a4c
ACM
497 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
498 LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
499 endif
7e4b21b8
TZ
500endif
501
f9af3a4c 502ifdef NO_LIBPYTHON
7e4b21b8
TZ
503 BASIC_CFLAGS += -DNO_LIBPYTHON
504else
f2481f3d
TZ
505 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))
f9af3a4c
ACM
508 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)
978f626c 511 msg := $(warning No Python.h found, install python-dev[el] to have python support in 'perf script' and to build the python bindings)
f9af3a4c
ACM
512 BASIC_CFLAGS += -DNO_LIBPYTHON
513 else
f2481f3d
TZ
514 ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
515 EXTLIBS += $(PYTHON_EMBED_LIBADD)
f9af3a4c
ACM
516 LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
517 LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
978f626c 518 LANG_BINDINGS += $(OUTPUT)python/perf.so
f9af3a4c 519 endif
7e4b21b8
TZ
520endif
521
2cdbc46d
PZ
522ifdef NO_DEMANGLE
523 BASIC_CFLAGS += -DNO_DEMANGLE
524else
167a58f1
CS
525 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
247648e3 533 else
167a58f1
CS
534 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
247648e3 538 else
167a58f1
CS
539 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
247648e3 543 else
167a58f1
CS
544 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
247648e3
ACM
553 endif
554 endif
555 endif
2cdbc46d
PZ
556 endif
557endif
558
f4e7ac0a
KS
559
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
d24e473e
IM
568ifdef RUNTIME_PREFIX
569 COMPAT_CFLAGS += -DRUNTIME_PREFIX
570endif
571
d24e473e
IM
572QUIET_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 $@;
033a273f 586 QUIET_MKDIR = @echo ' ' MKDIR $@;
d24e473e
IM
587 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
07800601 604ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
d24e473e
IM
605
606DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
607bindir_SQ = $(subst ','\'',$(bindir))
608bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
609mandir_SQ = $(subst ','\'',$(mandir))
610infodir_SQ = $(subst ','\'',$(infodir))
07800601 611perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
d24e473e
IM
612template_dir_SQ = $(subst ','\'',$(template_dir))
613htmldir_SQ = $(subst ','\'',$(htmldir))
614prefix_SQ = $(subst ','\'',$(prefix))
615
616SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
d24e473e 617
b38aa896 618LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive $(EXTLIBS)
d24e473e 619
d24e473e 620ALL_CFLAGS += $(BASIC_CFLAGS)
ea7872b9 621ALL_CFLAGS += $(ARCH_CFLAGS)
d24e473e
IM
622ALL_LDFLAGS += $(BASIC_LDFLAGS)
623
624export TAR INSTALL DESTDIR SHELL_PATH
625
626
627### Build rules
628
629SHELL = $(SHELL_PATH)
630
978f626c 631all:: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(BUILT_INS) $(OTHER_PROGRAMS) $(OUTPUT)PERF-BUILD-OPTIONS
d24e473e
IM
632
633all::
d24e473e
IM
634
635please_set_SHELL_PATH_to_a_more_modern_shell:
636 @$$(:)
637
638shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
639
8796cb9d
MW
640strip: $(PROGRAMS) $(OUTPUT)perf
641 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
d24e473e 642
c29ede61 643$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
07800601
IM
644 $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
645 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
c29ede61 646 $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
d24e473e 647
8796cb9d 648$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
f2481f3d
TZ
649 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
650 $(BUILTIN_OBJS) $(LIBS) -o $@
d24e473e 651
c29ede61
ACM
652$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
653 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
07800601
IM
654 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
655 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
10274989
AV
656 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
657
c29ede61
ACM
658$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
659 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
10274989
AV
660 '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
661 '-DPERF_MAN_PATH="$(mandir_SQ)"' \
07800601 662 '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
d24e473e 663
c29ede61 664$(BUILT_INS): $(OUTPUT)perf$X
d24e473e 665 $(QUIET_BUILT_IN)$(RM) $@ && \
07800601
IM
666 ln perf$X $@ 2>/dev/null || \
667 ln -s perf$X $@ 2>/dev/null || \
668 cp perf$X $@
d24e473e 669
c29ede61 670$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
d24e473e 671
c29ede61 672$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
1ad0560e 673 $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
d24e473e
IM
674
675$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
ecafda60 676 $(QUIET_GEN)$(RM) $(OUTPUT)$@ $(OUTPUT)$@+ && \
d24e473e
IM
677 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
678 -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
07800601 679 -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
d24e473e 680 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
ecafda60
KK
681 $@.sh > $(OUTPUT)$@+ && \
682 chmod +x $(OUTPUT)$@+ && \
683 mv $(OUTPUT)$@+ $(OUTPUT)$@
d24e473e 684
d24e473e
IM
685configure: configure.ac
686 $(QUIET_GEN)$(RM) $@ $<+ && \
07800601 687 sed -e 's/@@PERF_VERSION@@/$(PERF_VERSION)/g' \
d24e473e
IM
688 $< > $<+ && \
689 autoconf -o $@ $<+ && \
690 $(RM) $<+
691
07800601 692# These can record PERF_VERSION
c29ede61 693$(OUTPUT)perf.o perf.spec \
d24e473e 694 $(patsubst %.sh,%,$(SCRIPT_SH)) \
c29ede61 695 : $(OUTPUT)PERF-VERSION-FILE
d24e473e 696
c29ede61
ACM
697$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
698 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
699$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
d24e473e 700 $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
c29ede61
ACM
701$(OUTPUT)%.o: %.S
702 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
d24e473e 703
c29ede61
ACM
704$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
705 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
07800601 706 '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
d24e473e
IM
707 '-DBINDIR="$(bindir_relative_SQ)"' \
708 '-DPREFIX="$(prefix_SQ)"' \
709 $<
710
c29ede61
ACM
711$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
712 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
d24e473e 713
ef8f34aa
ACM
714$(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS
715 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
716
211ef127
ACM
717$(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
c0443df1
ACM
720$(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
d1b4f249
ACM
723$(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
b1b02673
ACM
726$(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
c29ede61
ACM
729$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
730 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
43cbcd8a 731
c29ede61
ACM
732$(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 $<
16c632de 734
c29ede61
ACM
735$(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 $<
d1b93772 737
c29ede61
ACM
738$(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 $<
7e4b21b8 740
c29ede61
ACM
741$(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 $<
7e4b21b8 743
8796cb9d 744$(OUTPUT)perf-%: %.o $(PERFLIBS)
d24e473e
IM
745 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
746
d24e473e 747$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
8796cb9d 748$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
d24e473e 749
033a273f
BP
750# 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
39cfae64 753$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
033a273f
BP
754# 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
d24e473e
IM
758$(LIB_FILE): $(LIB_OBJS)
759 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
760
4187e262
JB
761help:
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
c1c2365a
IM
791doc:
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
d24e473e
IM
806TAGS:
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)):\
07800601 820 $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
d24e473e 821
c29ede61 822$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
d24e473e 823 @FLAGS='$(TRACK_CFLAGS)'; \
c29ede61 824 if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
d24e473e 825 echo 1>&2 " * new build flags or prefix"; \
c29ede61 826 echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
d24e473e
IM
827 fi
828
829# We need to apply sq twice, once to protect from the shell
c29ede61 830# that runs $(OUTPUT)PERF-BUILD-OPTIONS, and then again to protect it
d24e473e 831# and the first level quoting from the shell that runs "echo".
c29ede61 832$(OUTPUT)PERF-BUILD-OPTIONS: .FORCE-PERF-BUILD-OPTIONS
d24e473e
IM
833 @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
834 @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
835 @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
d24e473e 836
d24e473e
IM
837### Testing rules
838
6f06ccbc
IM
839#
840# None right now:
841#
842# TEST_PROGRAMS += test-something$X
d24e473e
IM
843
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
c29ede61 850check: $(OUTPUT)common-cmds.h
d24e473e
IM
851 if sparse; \
852 then \
148be2c1 853 for i in *.c */*.c; \
d24e473e
IM
854 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
07800601
IM
874ifneq ($(filter /%,$(firstword $(perfexecdir))),)
875perfexec_instdir = $(perfexecdir)
d24e473e 876else
07800601 877perfexec_instdir = $(prefix)/$(perfexecdir)
d24e473e 878endif
07800601
IM
879perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
880export perfexec_instdir
d24e473e
IM
881
882install: all
883 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
8796cb9d 884 $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
bcefe12e
TZ
885 $(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'
c29ede61 887 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
bcefe12e
TZ
888 $(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'
7e4b21b8 891 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
4d161f03 892 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
7e4b21b8 893 $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
4d161f03
TZ
894 $(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'
82d156cd 896
c1079abd
MG
897ifdef BUILT_INS
898 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
899 $(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
d24e473e 900ifneq (,$X)
c29ede61 901 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) $(OUTPUT)perf$X)), $(RM) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$p';)
d24e473e 902endif
c1079abd 903endif
d24e473e 904
c1c2365a
IM
905install-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
d24e473e 930### Maintainer's dist rules
c1079abd
MG
931#
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
d24e473e 975
d24e473e
IM
976### Cleaning rules
977
978distclean: clean
c1079abd 979# $(RM) configure
e0143bad
IM
980
981clean:
568bb7b8 982 $(RM) $(OUTPUT){*.o,*/*.o,*/*/*.o,*/*/*/*.o,$(LIB_FILE),perf-archive}
8796cb9d 983 $(RM) $(ALL_PROGRAMS) $(BUILT_INS) perf
d24e473e 984 $(RM) $(TEST_PROGRAMS)
c29ede61 985 $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
07800601
IM
986 $(RM) -r $(PERF_TARNAME) .doc-tmp-dir
987 $(RM) $(PERF_TARNAME).tar.gz perf-core_$(PERF_VERSION)-*.tar.gz
d24e473e 988 $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
c1c2365a 989 $(MAKE) -C Documentation/ clean
c29ede61 990 $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)PERF-BUILD-OPTIONS
067187fc
ACM
991 @python util/setup.py clean --build-lib='$(OUTPUT)python' \
992 --build-temp='$(OUTPUT)python/temp'
d24e473e
IM
993
994.PHONY: all install clean strip
995.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
07800601
IM
996.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
997.PHONY: .FORCE-PERF-BUILD-OPTIONS
d24e473e 998
07800601 999### Make sure built-ins do not have dups and listed in perf.c
d24e473e
IM
1000#
1001check-builtins::
1002 ./check-builtins.sh
1003
1004### Test suite coverage testing
1005#
c1079abd
MG
1006# 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
This page took 0.167825 seconds and 5 git commands to generate.