xref: /openbmc/linux/tools/perf/Makefile (revision 393be2e3)
1include ../scripts/Makefile.include
2
3# The default target of this Makefile is...
4all:
5
6include config/utilities.mak
7
8# Define V to have a more verbose compile.
9#
10# Define O to save output files in a separate directory.
11#
12# Define ARCH as name of target architecture if you want cross-builds.
13#
14# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
15#
16# Define NO_LIBPERL to disable perl script extension.
17#
18# Define NO_LIBPYTHON to disable python script extension.
19#
20# Define PYTHON to point to the python binary if the default
21# `python' is not correct; for example: PYTHON=python2
22#
23# Define PYTHON_CONFIG to point to the python-config binary if
24# the default `$(PYTHON)-config' is not correct.
25#
26# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
27#
28# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
29#
30# Define LDFLAGS=-static to build a static binary.
31#
32# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
33#
34# Define NO_DWARF if you do not want debug-info analysis feature at all.
35#
36# Define WERROR=0 to disable treating any warnings as errors.
37#
38# Define NO_NEWT if you do not want TUI support.
39#
40# Define NO_GTK2 if you do not want GTK+ GUI support.
41#
42# Define NO_DEMANGLE if you do not want C++ symbol demangling.
43#
44# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
45#
46
47$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
48	@$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
49-include $(OUTPUT)PERF-VERSION-FILE
50
51uname_M := $(shell uname -m 2>/dev/null || echo not)
52
53ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
54				  -e s/arm.*/arm/ -e s/sa110/arm/ \
55				  -e s/s390x/s390/ -e s/parisc64/parisc/ \
56				  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
57				  -e s/sh[234].*/sh/ )
58
59CC = $(CROSS_COMPILE)gcc
60AR = $(CROSS_COMPILE)ar
61
62# Additional ARCH settings for x86
63ifeq ($(ARCH),i386)
64        ARCH := x86
65endif
66ifeq ($(ARCH),x86_64)
67	ARCH := x86
68	IS_X86_64 := 0
69	ifeq (, $(findstring m32,$(EXTRA_CFLAGS)))
70		IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
71	endif
72	ifeq (${IS_X86_64}, 1)
73		RAW_ARCH := x86_64
74		ARCH_CFLAGS := -DARCH_X86_64
75		ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
76	endif
77endif
78
79# Treat warnings as errors unless directed not to
80ifneq ($(WERROR),0)
81	CFLAGS_WERROR := -Werror
82endif
83
84ifeq ("$(origin DEBUG)", "command line")
85  PERF_DEBUG = $(DEBUG)
86endif
87ifndef PERF_DEBUG
88  CFLAGS_OPTIMIZE = -O6 -D_FORTIFY_SOURCE=2
89endif
90
91ifdef PARSER_DEBUG
92	PARSER_DEBUG_BISON  := -t
93	PARSER_DEBUG_FLEX   := -d
94	PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG
95endif
96
97CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS)
98EXTLIBS = -lpthread -lrt -lelf -lm
99ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
100ALL_LDFLAGS = $(LDFLAGS)
101STRIP ?= strip
102
103# Among the variables below, these:
104#   perfexecdir
105#   template_dir
106#   mandir
107#   infodir
108#   htmldir
109#   ETC_PERFCONFIG (but not sysconfdir)
110# can be specified as a relative path some/where/else;
111# this is interpreted as relative to $(prefix) and "perf" at
112# runtime figures out where they are based on the path to the executable.
113# This can help installing the suite in a relocatable way.
114
115# Make the path relative to DESTDIR, not to prefix
116ifndef DESTDIR
117prefix = $(HOME)
118endif
119bindir_relative = bin
120bindir = $(prefix)/$(bindir_relative)
121mandir = share/man
122infodir = share/info
123perfexecdir = libexec/perf-core
124sharedir = $(prefix)/share
125template_dir = share/perf-core/templates
126htmldir = share/doc/perf-doc
127ifeq ($(prefix),/usr)
128sysconfdir = /etc
129ETC_PERFCONFIG = $(sysconfdir)/perfconfig
130else
131sysconfdir = $(prefix)/etc
132ETC_PERFCONFIG = etc/perfconfig
133endif
134lib = lib
135
136export prefix bindir sharedir sysconfdir
137
138RM = rm -f
139MKDIR = mkdir
140FIND = find
141INSTALL = install
142
143# sparse is architecture-neutral, which means that we need to tell it
144# explicitly what architecture to check for. Fix this up for yours..
145SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
146
147-include config/feature-tests.mak
148
149ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y)
150	CFLAGS := $(CFLAGS) -fstack-protector-all
151endif
152
153ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wstack-protector),y)
154       CFLAGS := $(CFLAGS) -Wstack-protector
155endif
156
157ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wvolatile-register-var),y)
158       CFLAGS := $(CFLAGS) -Wvolatile-register-var
159endif
160
161### --- END CONFIGURATION SECTION ---
162
163BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
164BASIC_LDFLAGS =
165
166# Guard against environment variables
167BUILTIN_OBJS =
168LIB_H =
169LIB_OBJS =
170PYRF_OBJS =
171SCRIPT_SH =
172
173SCRIPT_SH += perf-archive.sh
174
175grep-libs = $(filter -l%,$(1))
176strip-libs = $(filter-out -l%,$(1))
177
178PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
179PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py
180
181$(OUTPUT)python/perf.so: $(PYRF_OBJS) $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
182	$(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
183	  --quiet build_ext; \
184	mkdir -p $(OUTPUT)python && \
185	cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
186#
187# No Perl scripts right now:
188#
189
190SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
191
192TRACE_EVENT_DIR = ../lib/traceevent/
193
194ifneq ($(OUTPUT),)
195	TE_PATH=$(OUTPUT)
196else
197	TE_PATH=$(TRACE_EVENT_DIR)
198endif
199
200LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
201TE_LIB := -L$(TE_PATH) -ltraceevent
202
203#
204# Single 'perf' binary right now:
205#
206PROGRAMS += $(OUTPUT)perf
207
208LANG_BINDINGS =
209
210# what 'all' will build and 'install' will install, in perfexecdir
211ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
212
213# what 'all' will build but not install in perfexecdir
214OTHER_PROGRAMS = $(OUTPUT)perf
215
216# Set paths to tools early so that they can be used for version tests.
217ifndef SHELL_PATH
218	SHELL_PATH = /bin/sh
219endif
220ifndef PERL_PATH
221	PERL_PATH = /usr/bin/perl
222endif
223
224export PERL_PATH
225
226FLEX = flex
227BISON= bison
228
229$(OUTPUT)util/parse-events-flex.c: util/parse-events.l
230	$(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
231
232$(OUTPUT)util/parse-events-bison.c: util/parse-events.y
233	$(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c
234
235$(OUTPUT)util/pmu-flex.c: util/pmu.l
236	$(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c
237
238$(OUTPUT)util/pmu-bison.c: util/pmu.y
239	$(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c
240
241$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
242$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
243
244LIB_FILE=$(OUTPUT)libperf.a
245
246LIB_H += ../../include/linux/perf_event.h
247LIB_H += ../../include/linux/rbtree.h
248LIB_H += ../../include/linux/list.h
249LIB_H += ../../include/linux/const.h
250LIB_H += ../../include/linux/hash.h
251LIB_H += ../../include/linux/stringify.h
252LIB_H += util/include/linux/bitmap.h
253LIB_H += util/include/linux/bitops.h
254LIB_H += util/include/linux/compiler.h
255LIB_H += util/include/linux/const.h
256LIB_H += util/include/linux/ctype.h
257LIB_H += util/include/linux/kernel.h
258LIB_H += util/include/linux/list.h
259LIB_H += util/include/linux/export.h
260LIB_H += util/include/linux/poison.h
261LIB_H += util/include/linux/prefetch.h
262LIB_H += util/include/linux/rbtree.h
263LIB_H += util/include/linux/string.h
264LIB_H += util/include/linux/types.h
265LIB_H += util/include/linux/linkage.h
266LIB_H += util/include/asm/asm-offsets.h
267LIB_H += util/include/asm/bug.h
268LIB_H += util/include/asm/byteorder.h
269LIB_H += util/include/asm/hweight.h
270LIB_H += util/include/asm/swab.h
271LIB_H += util/include/asm/system.h
272LIB_H += util/include/asm/uaccess.h
273LIB_H += util/include/dwarf-regs.h
274LIB_H += util/include/asm/dwarf2.h
275LIB_H += util/include/asm/cpufeature.h
276LIB_H += util/include/asm/unistd_32.h
277LIB_H += util/include/asm/unistd_64.h
278LIB_H += perf.h
279LIB_H += util/annotate.h
280LIB_H += util/cache.h
281LIB_H += util/callchain.h
282LIB_H += util/build-id.h
283LIB_H += util/debug.h
284LIB_H += util/debugfs.h
285LIB_H += util/sysfs.h
286LIB_H += util/pmu.h
287LIB_H += util/event.h
288LIB_H += util/evsel.h
289LIB_H += util/evlist.h
290LIB_H += util/exec_cmd.h
291LIB_H += util/types.h
292LIB_H += util/levenshtein.h
293LIB_H += util/map.h
294LIB_H += util/parse-options.h
295LIB_H += util/parse-events.h
296LIB_H += util/quote.h
297LIB_H += util/util.h
298LIB_H += util/xyarray.h
299LIB_H += util/header.h
300LIB_H += util/help.h
301LIB_H += util/session.h
302LIB_H += util/strbuf.h
303LIB_H += util/strlist.h
304LIB_H += util/strfilter.h
305LIB_H += util/svghelper.h
306LIB_H += util/tool.h
307LIB_H += util/run-command.h
308LIB_H += util/sigchain.h
309LIB_H += util/symbol.h
310LIB_H += util/color.h
311LIB_H += util/values.h
312LIB_H += util/sort.h
313LIB_H += util/hist.h
314LIB_H += util/thread.h
315LIB_H += util/thread_map.h
316LIB_H += util/trace-event.h
317LIB_H += util/probe-finder.h
318LIB_H += util/dwarf-aux.h
319LIB_H += util/probe-event.h
320LIB_H += util/pstack.h
321LIB_H += util/cpumap.h
322LIB_H += util/top.h
323LIB_H += $(ARCH_INCLUDE)
324LIB_H += util/cgroup.h
325LIB_H += $(TRACE_EVENT_DIR)event-parse.h
326LIB_H += util/target.h
327LIB_H += util/rblist.h
328LIB_H += util/intlist.h
329
330LIB_OBJS += $(OUTPUT)util/abspath.o
331LIB_OBJS += $(OUTPUT)util/alias.o
332LIB_OBJS += $(OUTPUT)util/annotate.o
333LIB_OBJS += $(OUTPUT)util/build-id.o
334LIB_OBJS += $(OUTPUT)util/config.o
335LIB_OBJS += $(OUTPUT)util/ctype.o
336LIB_OBJS += $(OUTPUT)util/debugfs.o
337LIB_OBJS += $(OUTPUT)util/sysfs.o
338LIB_OBJS += $(OUTPUT)util/pmu.o
339LIB_OBJS += $(OUTPUT)util/environment.o
340LIB_OBJS += $(OUTPUT)util/event.o
341LIB_OBJS += $(OUTPUT)util/evlist.o
342LIB_OBJS += $(OUTPUT)util/evsel.o
343LIB_OBJS += $(OUTPUT)util/exec_cmd.o
344LIB_OBJS += $(OUTPUT)util/help.o
345LIB_OBJS += $(OUTPUT)util/levenshtein.o
346LIB_OBJS += $(OUTPUT)util/parse-options.o
347LIB_OBJS += $(OUTPUT)util/parse-events.o
348LIB_OBJS += $(OUTPUT)util/parse-events-test.o
349LIB_OBJS += $(OUTPUT)util/path.o
350LIB_OBJS += $(OUTPUT)util/rbtree.o
351LIB_OBJS += $(OUTPUT)util/bitmap.o
352LIB_OBJS += $(OUTPUT)util/hweight.o
353LIB_OBJS += $(OUTPUT)util/run-command.o
354LIB_OBJS += $(OUTPUT)util/quote.o
355LIB_OBJS += $(OUTPUT)util/strbuf.o
356LIB_OBJS += $(OUTPUT)util/string.o
357LIB_OBJS += $(OUTPUT)util/strlist.o
358LIB_OBJS += $(OUTPUT)util/strfilter.o
359LIB_OBJS += $(OUTPUT)util/top.o
360LIB_OBJS += $(OUTPUT)util/usage.o
361LIB_OBJS += $(OUTPUT)util/wrapper.o
362LIB_OBJS += $(OUTPUT)util/sigchain.o
363LIB_OBJS += $(OUTPUT)util/symbol.o
364LIB_OBJS += $(OUTPUT)util/symbol-elf.o
365LIB_OBJS += $(OUTPUT)util/dso-test-data.o
366LIB_OBJS += $(OUTPUT)util/color.o
367LIB_OBJS += $(OUTPUT)util/pager.o
368LIB_OBJS += $(OUTPUT)util/header.o
369LIB_OBJS += $(OUTPUT)util/callchain.o
370LIB_OBJS += $(OUTPUT)util/values.o
371LIB_OBJS += $(OUTPUT)util/debug.o
372LIB_OBJS += $(OUTPUT)util/map.o
373LIB_OBJS += $(OUTPUT)util/pstack.o
374LIB_OBJS += $(OUTPUT)util/session.o
375LIB_OBJS += $(OUTPUT)util/thread.o
376LIB_OBJS += $(OUTPUT)util/thread_map.o
377LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
378LIB_OBJS += $(OUTPUT)util/parse-events-flex.o
379LIB_OBJS += $(OUTPUT)util/parse-events-bison.o
380LIB_OBJS += $(OUTPUT)util/pmu-flex.o
381LIB_OBJS += $(OUTPUT)util/pmu-bison.o
382LIB_OBJS += $(OUTPUT)util/trace-event-read.o
383LIB_OBJS += $(OUTPUT)util/trace-event-info.o
384LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
385LIB_OBJS += $(OUTPUT)util/svghelper.o
386LIB_OBJS += $(OUTPUT)util/sort.o
387LIB_OBJS += $(OUTPUT)util/hist.o
388LIB_OBJS += $(OUTPUT)util/probe-event.o
389LIB_OBJS += $(OUTPUT)util/util.o
390LIB_OBJS += $(OUTPUT)util/xyarray.o
391LIB_OBJS += $(OUTPUT)util/cpumap.o
392LIB_OBJS += $(OUTPUT)util/cgroup.o
393LIB_OBJS += $(OUTPUT)util/target.o
394LIB_OBJS += $(OUTPUT)util/rblist.o
395LIB_OBJS += $(OUTPUT)util/intlist.o
396
397BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
398
399BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
400
401# Benchmark modules
402BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
403BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
404ifeq ($(RAW_ARCH),x86_64)
405BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
406BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
407endif
408BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
409BUILTIN_OBJS += $(OUTPUT)bench/mem-memset.o
410
411BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
412BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o
413BUILTIN_OBJS += $(OUTPUT)builtin-help.o
414BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
415BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
416BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
417BUILTIN_OBJS += $(OUTPUT)builtin-list.o
418BUILTIN_OBJS += $(OUTPUT)builtin-record.o
419BUILTIN_OBJS += $(OUTPUT)builtin-report.o
420BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
421BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
422BUILTIN_OBJS += $(OUTPUT)builtin-top.o
423BUILTIN_OBJS += $(OUTPUT)builtin-script.o
424BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
425BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
426BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
427BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
428BUILTIN_OBJS += $(OUTPUT)builtin-test.o
429BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
430
431PERFLIBS = $(LIB_FILE) $(LIBTRACEEVENT)
432
433# Files needed for the python binding, perf.so
434# pyrf is just an internal name needed for all those wrappers.
435# This has to be in sync with what is in the 'sources' variable in
436# tools/perf/util/setup.py
437
438PYRF_OBJS += $(OUTPUT)util/cpumap.o
439PYRF_OBJS += $(OUTPUT)util/ctype.o
440PYRF_OBJS += $(OUTPUT)util/evlist.o
441PYRF_OBJS += $(OUTPUT)util/evsel.o
442PYRF_OBJS += $(OUTPUT)util/python.o
443PYRF_OBJS += $(OUTPUT)util/thread_map.o
444PYRF_OBJS += $(OUTPUT)util/util.o
445PYRF_OBJS += $(OUTPUT)util/xyarray.o
446
447#
448# Platform specific tweaks
449#
450
451# We choose to avoid "if .. else if .. else .. endif endif"
452# because maintaining the nesting to match is a pain.  If
453# we had "elif" things would have been much nicer...
454
455-include config.mak.autogen
456-include config.mak
457
458ifdef NO_LIBELF
459	NO_DWARF := 1
460	NO_DEMANGLE := 1
461else
462FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
463ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y)
464	FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS)
465	ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y)
466		msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
467	else
468		NO_LIBELF := 1
469		NO_DWARF := 1
470		NO_DEMANGLE := 1
471	endif
472endif
473endif # NO_LIBELF
474
475-include arch/$(ARCH)/Makefile
476
477ifneq ($(OUTPUT),)
478	BASIC_CFLAGS += -I$(OUTPUT)
479endif
480
481ifdef NO_LIBELF
482BASIC_CFLAGS += -DNO_LIBELF_SUPPORT
483
484EXTLIBS := $(filter-out -lelf,$(EXTLIBS))
485
486# Remove ELF/DWARF dependent codes
487LIB_OBJS := $(filter-out $(OUTPUT)util/symbol-elf.o,$(LIB_OBJS))
488LIB_OBJS := $(filter-out $(OUTPUT)util/dwarf-aux.o,$(LIB_OBJS))
489LIB_OBJS := $(filter-out $(OUTPUT)util/probe-event.o,$(LIB_OBJS))
490LIB_OBJS := $(filter-out $(OUTPUT)util/probe-finder.o,$(LIB_OBJS))
491
492BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS))
493
494# Use minimal symbol handling
495LIB_OBJS += $(OUTPUT)util/symbol-minimal.o
496
497else # NO_LIBELF
498
499ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y)
500	BASIC_CFLAGS += -DLIBELF_NO_MMAP
501endif
502
503FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
504ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y)
505	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);
506	NO_DWARF := 1
507endif # Dwarf support
508
509ifndef NO_DWARF
510ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
511	msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
512else
513	BASIC_CFLAGS += -DDWARF_SUPPORT
514	EXTLIBS += -lelf -ldw
515	LIB_OBJS += $(OUTPUT)util/probe-finder.o
516	LIB_OBJS += $(OUTPUT)util/dwarf-aux.o
517endif # PERF_HAVE_DWARF_REGS
518endif # NO_DWARF
519endif # NO_LIBELF
520
521ifdef NO_NEWT
522	BASIC_CFLAGS += -DNO_NEWT_SUPPORT
523else
524	FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt
525	ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y)
526		msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev);
527		BASIC_CFLAGS += -DNO_NEWT_SUPPORT
528	else
529		# Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
530		BASIC_CFLAGS += -I/usr/include/slang
531		EXTLIBS += -lnewt -lslang
532		LIB_OBJS += $(OUTPUT)ui/setup.o
533		LIB_OBJS += $(OUTPUT)ui/browser.o
534		LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o
535		LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
536		LIB_OBJS += $(OUTPUT)ui/browsers/map.o
537		LIB_OBJS += $(OUTPUT)ui/helpline.o
538		LIB_OBJS += $(OUTPUT)ui/progress.o
539		LIB_OBJS += $(OUTPUT)ui/util.o
540		LIB_OBJS += $(OUTPUT)ui/tui/setup.o
541		LIB_OBJS += $(OUTPUT)ui/tui/util.o
542		LIB_H += ui/browser.h
543		LIB_H += ui/browsers/map.h
544		LIB_H += ui/helpline.h
545		LIB_H += ui/keysyms.h
546		LIB_H += ui/libslang.h
547		LIB_H += ui/progress.h
548		LIB_H += ui/util.h
549		LIB_H += ui/ui.h
550	endif
551endif
552
553ifdef NO_GTK2
554	BASIC_CFLAGS += -DNO_GTK2_SUPPORT
555else
556	FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0)
557	ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2)),y)
558		msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
559		BASIC_CFLAGS += -DNO_GTK2_SUPPORT
560	else
561		ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2)),y)
562			BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR
563		endif
564		BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0)
565		EXTLIBS += $(shell pkg-config --libs gtk+-2.0)
566		LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
567		LIB_OBJS += $(OUTPUT)ui/gtk/setup.o
568		LIB_OBJS += $(OUTPUT)ui/gtk/util.o
569		# Make sure that it'd be included only once.
570		ifneq ($(findstring -DNO_NEWT_SUPPORT,$(BASIC_CFLAGS)),)
571			LIB_OBJS += $(OUTPUT)ui/setup.o
572			LIB_OBJS += $(OUTPUT)ui/util.o
573		endif
574	endif
575endif
576
577ifdef NO_LIBPERL
578	BASIC_CFLAGS += -DNO_LIBPERL
579else
580       PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
581       PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
582       PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
583	PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
584	FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
585
586	ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y)
587		BASIC_CFLAGS += -DNO_LIBPERL
588	else
589               ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS)
590               EXTLIBS += $(PERL_EMBED_LIBADD)
591		LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
592		LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
593	endif
594endif
595
596disable-python = $(eval $(disable-python_code))
597define disable-python_code
598  BASIC_CFLAGS += -DNO_LIBPYTHON
599  $(if $(1),$(warning No $(1) was found))
600  $(warning Python support won't be built)
601endef
602
603override PYTHON := \
604  $(call get-executable-or-default,PYTHON,python)
605
606ifndef PYTHON
607  $(call disable-python,python interpreter)
608  python-clean :=
609else
610
611  PYTHON_WORD := $(call shell-wordify,$(PYTHON))
612
613  # python extension build directories
614  PYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
615  PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
616  PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
617  export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
618
619  python-clean := rm -rf $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
620
621  ifdef NO_LIBPYTHON
622    $(call disable-python)
623  else
624
625    override PYTHON_CONFIG := \
626      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
627
628    ifndef PYTHON_CONFIG
629      $(call disable-python,python-config tool)
630    else
631
632      PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
633
634      PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
635      PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
636      PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
637      PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
638      FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
639
640      ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
641        $(call disable-python,Python.h (for Python 2.x))
642      else
643
644        ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED)),y)
645          $(warning Python 3 is not yet supported; please set)
646          $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
647          $(warning If you also have Python 2 installed, then)
648          $(warning try something like:)
649          $(warning $(and ,))
650          $(warning $(and ,)  make PYTHON=python2)
651          $(warning $(and ,))
652          $(warning Otherwise, disable Python support entirely:)
653          $(warning $(and ,))
654          $(warning $(and ,)  make NO_LIBPYTHON=1)
655          $(warning $(and ,))
656          $(error   $(and ,))
657        else
658          ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
659          EXTLIBS += $(PYTHON_EMBED_LIBADD)
660          LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
661          LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
662          LANG_BINDINGS += $(OUTPUT)python/perf.so
663        endif
664
665      endif
666    endif
667  endif
668endif
669
670ifdef NO_DEMANGLE
671	BASIC_CFLAGS += -DNO_DEMANGLE
672else
673        ifdef HAVE_CPLUS_DEMANGLE
674		EXTLIBS += -liberty
675		BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
676        else
677		FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd
678		has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
679		ifeq ($(has_bfd),y)
680			EXTLIBS += -lbfd
681		else
682			FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
683			has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY))
684			ifeq ($(has_bfd_iberty),y)
685				EXTLIBS += -lbfd -liberty
686			else
687				FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
688				has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z))
689				ifeq ($(has_bfd_iberty_z),y)
690					EXTLIBS += -lbfd -liberty -lz
691				else
692					FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty
693					has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE))
694					ifeq ($(has_cplus_demangle),y)
695						EXTLIBS += -liberty
696						BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
697					else
698						msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
699						BASIC_CFLAGS += -DNO_DEMANGLE
700					endif
701				endif
702			endif
703		endif
704	endif
705endif
706
707
708ifdef NO_STRLCPY
709	BASIC_CFLAGS += -DNO_STRLCPY
710else
711	ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
712		BASIC_CFLAGS += -DNO_STRLCPY
713	endif
714endif
715
716ifdef ASCIIDOC8
717	export ASCIIDOC8
718endif
719
720# Shell quote (do not use $(call) to accommodate ancient setups);
721
722ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
723
724DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
725bindir_SQ = $(subst ','\'',$(bindir))
726bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
727mandir_SQ = $(subst ','\'',$(mandir))
728infodir_SQ = $(subst ','\'',$(infodir))
729perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
730template_dir_SQ = $(subst ','\'',$(template_dir))
731htmldir_SQ = $(subst ','\'',$(htmldir))
732prefix_SQ = $(subst ','\'',$(prefix))
733sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
734
735SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
736
737LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
738
739ALL_CFLAGS += $(BASIC_CFLAGS)
740ALL_CFLAGS += $(ARCH_CFLAGS)
741ALL_LDFLAGS += $(BASIC_LDFLAGS)
742
743export INSTALL SHELL_PATH
744
745
746### Build rules
747
748SHELL = $(SHELL_PATH)
749
750all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
751
752please_set_SHELL_PATH_to_a_more_modern_shell:
753	@$$(:)
754
755shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
756
757strip: $(PROGRAMS) $(OUTPUT)perf
758	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
759
760$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
761	$(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
762		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
763		$(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
764
765$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
766	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
767               $(BUILTIN_OBJS) $(LIBS) -o $@
768
769$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
770	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
771		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
772		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
773		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
774
775$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
776	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
777		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
778		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
779		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
780
781$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
782
783$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
784	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
785
786$(SCRIPTS) : % : %.sh
787	$(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
788
789# These can record PERF_VERSION
790$(OUTPUT)perf.o perf.spec \
791	$(SCRIPTS) \
792	: $(OUTPUT)PERF-VERSION-FILE
793
794.SUFFIXES:
795.SUFFIXES: .o .c .S .s
796
797# These two need to be here so that when O= is not used they take precedence
798# over the general rule for .o
799
800$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS
801	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Iutil/ -w $<
802
803$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS
804	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -Iutil/ -w $<
805
806$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
807	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
808$(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS
809	$(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $<
810$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
811	$(QUIET_CC)$(CC) -o $@ -S $(ALL_CFLAGS) $<
812$(OUTPUT)%.o: %.S
813	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
814$(OUTPUT)%.s: %.S
815	$(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $<
816
817$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
818	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
819		'-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
820		'-DBINDIR="$(bindir_relative_SQ)"' \
821		'-DPREFIX="$(prefix_SQ)"' \
822		$<
823
824$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
825	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
826
827$(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS
828	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
829
830$(OUTPUT)ui/browsers/annotate.o: ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
831	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
832
833$(OUTPUT)ui/browsers/hists.o: ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
834	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
835
836$(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
837	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
838
839$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
840	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
841
842$(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS
843	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls $<
844
845$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
846	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
847
848$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
849	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
850
851$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
852	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
853
854$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
855	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
856
857$(OUTPUT)perf-%: %.o $(PERFLIBS)
858	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
859
860$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
861$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
862
863# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So
864# we depend the various files onto their directories.
865DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
866$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
867# In the second step, we make a rule to actually create these directories
868$(sort $(dir $(DIRECTORY_DEPS))):
869	$(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
870
871$(LIB_FILE): $(LIB_OBJS)
872	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
873
874# libtraceevent.a
875$(LIBTRACEEVENT):
876	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a
877
878help:
879	@echo 'Perf make targets:'
880	@echo '  doc		- make *all* documentation (see below)'
881	@echo '  man		- make manpage documentation (access with man <foo>)'
882	@echo '  html		- make html documentation'
883	@echo '  info		- make GNU info documentation (access with info <foo>)'
884	@echo '  pdf		- make pdf documentation'
885	@echo '  TAGS		- use etags to make tag information for source browsing'
886	@echo '  tags		- use ctags to make tag information for source browsing'
887	@echo '  cscope	- use cscope to make interactive browsing database'
888	@echo ''
889	@echo 'Perf install targets:'
890	@echo '  NOTE: documentation build requires asciidoc, xmlto packages to be installed'
891	@echo '  HINT: use "make prefix=<path> <install target>" to install to a particular'
892	@echo '        path like make prefix=/usr/local install install-doc'
893	@echo '  install	- install compiled binaries'
894	@echo '  install-doc	- install *all* documentation'
895	@echo '  install-man	- install manpage documentation'
896	@echo '  install-html	- install html documentation'
897	@echo '  install-info	- install GNU info documentation'
898	@echo '  install-pdf	- install pdf documentation'
899	@echo ''
900	@echo '  quick-install-doc	- alias for quick-install-man'
901	@echo '  quick-install-man	- install the documentation quickly'
902	@echo '  quick-install-html	- install the html documentation quickly'
903	@echo ''
904	@echo 'Perf maintainer targets:'
905	@echo '  clean			- clean all binary objects and build output'
906
907doc:
908	$(MAKE) -C Documentation all
909
910man:
911	$(MAKE) -C Documentation man
912
913html:
914	$(MAKE) -C Documentation html
915
916info:
917	$(MAKE) -C Documentation info
918
919pdf:
920	$(MAKE) -C Documentation pdf
921
922TAGS:
923	$(RM) TAGS
924	$(FIND) . -name '*.[hcS]' -print | xargs etags -a
925
926tags:
927	$(RM) tags
928	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
929
930cscope:
931	$(RM) cscope*
932	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
933
934### Detect prefix changes
935TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
936             $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
937
938$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
939	@FLAGS='$(TRACK_CFLAGS)'; \
940	    if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
941		echo 1>&2 "    * new build flags or prefix"; \
942		echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
943            fi
944
945### Testing rules
946
947# GNU make supports exporting all variables by "export" without parameters.
948# However, the environment gets quite big, and some programs have problems
949# with that.
950
951check: $(OUTPUT)common-cmds.h
952	if sparse; \
953	then \
954		for i in *.c */*.c; \
955		do \
956			sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
957		done; \
958	else \
959		exit 1; \
960	fi
961
962### Installation rules
963
964ifneq ($(filter /%,$(firstword $(perfexecdir))),)
965perfexec_instdir = $(perfexecdir)
966else
967perfexec_instdir = $(prefix)/$(perfexecdir)
968endif
969perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
970
971install: all
972	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
973	$(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
974	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
975	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
976	$(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
977	$(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
978	$(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
979	$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
980	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
981	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
982	$(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
983	$(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
984	$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
985	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'
986	$(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
987
988install-python_ext:
989	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
990
991install-doc:
992	$(MAKE) -C Documentation install
993
994install-man:
995	$(MAKE) -C Documentation install-man
996
997install-html:
998	$(MAKE) -C Documentation install-html
999
1000install-info:
1001	$(MAKE) -C Documentation install-info
1002
1003install-pdf:
1004	$(MAKE) -C Documentation install-pdf
1005
1006quick-install-doc:
1007	$(MAKE) -C Documentation quick-install
1008
1009quick-install-man:
1010	$(MAKE) -C Documentation quick-install-man
1011
1012quick-install-html:
1013	$(MAKE) -C Documentation quick-install-html
1014
1015### Cleaning rules
1016
1017clean:
1018	$(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS)
1019	$(RM) $(ALL_PROGRAMS) perf
1020	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
1021	$(MAKE) -C Documentation/ clean
1022	$(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS
1023	$(RM) $(OUTPUT)util/*-bison*
1024	$(RM) $(OUTPUT)util/*-flex*
1025	$(python-clean)
1026
1027.PHONY: all install clean strip $(LIBTRACEEVENT)
1028.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
1029.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
1030