xref: /OK3568_Linux_fs/kernel/tools/perf/Makefile.perf (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyuninclude ../scripts/Makefile.include
3*4882a593Smuzhiyuninclude ../scripts/Makefile.arch
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun# The default target of this Makefile is...
6*4882a593Smuzhiyunall:
7*4882a593Smuzhiyun
8*4882a593Smuzhiyuninclude ../scripts/utilities.mak
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun# Define V to have a more verbose compile.
11*4882a593Smuzhiyun#
12*4882a593Smuzhiyun# Define VF to have a more verbose feature check output.
13*4882a593Smuzhiyun#
14*4882a593Smuzhiyun# Define O to save output files in a separate directory.
15*4882a593Smuzhiyun#
16*4882a593Smuzhiyun# Define ARCH as name of target architecture if you want cross-builds.
17*4882a593Smuzhiyun#
18*4882a593Smuzhiyun# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
19*4882a593Smuzhiyun#
20*4882a593Smuzhiyun# Define NO_LIBPERL to disable perl script extension.
21*4882a593Smuzhiyun#
22*4882a593Smuzhiyun# Define NO_LIBPYTHON to disable python script extension.
23*4882a593Smuzhiyun#
24*4882a593Smuzhiyun# Define PYTHON to point to the python binary if the default
25*4882a593Smuzhiyun# `python' is not correct; for example: PYTHON=python2
26*4882a593Smuzhiyun#
27*4882a593Smuzhiyun# Define PYTHON_CONFIG to point to the python-config binary if
28*4882a593Smuzhiyun# the default `$(PYTHON)-config' is not correct.
29*4882a593Smuzhiyun#
30*4882a593Smuzhiyun# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
31*4882a593Smuzhiyun#
32*4882a593Smuzhiyun# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
33*4882a593Smuzhiyun#
34*4882a593Smuzhiyun# Define LDFLAGS=-static to build a static binary.
35*4882a593Smuzhiyun#
36*4882a593Smuzhiyun# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
37*4882a593Smuzhiyun#
38*4882a593Smuzhiyun# Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
39*4882a593Smuzhiyun# EXTLIBS.
40*4882a593Smuzhiyun#
41*4882a593Smuzhiyun# Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.
42*4882a593Smuzhiyun#
43*4882a593Smuzhiyun# Define NO_DWARF if you do not want debug-info analysis feature at all.
44*4882a593Smuzhiyun#
45*4882a593Smuzhiyun# Define WERROR=0 to disable treating any warnings as errors.
46*4882a593Smuzhiyun#
47*4882a593Smuzhiyun# Define NO_NEWT if you do not want TUI support. (deprecated)
48*4882a593Smuzhiyun#
49*4882a593Smuzhiyun# Define NO_SLANG if you do not want TUI support.
50*4882a593Smuzhiyun#
51*4882a593Smuzhiyun# Define GTK2 if you want GTK+ GUI support.
52*4882a593Smuzhiyun#
53*4882a593Smuzhiyun# Define NO_DEMANGLE if you do not want C++ symbol demangling.
54*4882a593Smuzhiyun#
55*4882a593Smuzhiyun# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
56*4882a593Smuzhiyun#
57*4882a593Smuzhiyun# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
58*4882a593Smuzhiyun# backtrace post unwind.
59*4882a593Smuzhiyun#
60*4882a593Smuzhiyun# Define NO_BACKTRACE if you do not want stack backtrace debug feature
61*4882a593Smuzhiyun#
62*4882a593Smuzhiyun# Define NO_LIBNUMA if you do not want numa perf benchmark
63*4882a593Smuzhiyun#
64*4882a593Smuzhiyun# Define NO_LIBAUDIT if you do not want libaudit support
65*4882a593Smuzhiyun#
66*4882a593Smuzhiyun# Define NO_LIBBIONIC if you do not want bionic support
67*4882a593Smuzhiyun#
68*4882a593Smuzhiyun# Define NO_LIBCRYPTO if you do not want libcrypto (openssl) support
69*4882a593Smuzhiyun# used for generating build-ids for ELFs generated by jitdump.
70*4882a593Smuzhiyun#
71*4882a593Smuzhiyun# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
72*4882a593Smuzhiyun# for dwarf backtrace post unwind.
73*4882a593Smuzhiyun#
74*4882a593Smuzhiyun# Define NO_PERF_READ_VDSO32 if you do not want to build perf-read-vdso32
75*4882a593Smuzhiyun# for reading the 32-bit compatibility VDSO in 64-bit mode
76*4882a593Smuzhiyun#
77*4882a593Smuzhiyun# Define NO_PERF_READ_VDSOX32 if you do not want to build perf-read-vdsox32
78*4882a593Smuzhiyun# for reading the x32 mode 32-bit compatibility VDSO in 64-bit mode
79*4882a593Smuzhiyun#
80*4882a593Smuzhiyun# Define NO_ZLIB if you do not want to support compressed kernel modules
81*4882a593Smuzhiyun#
82*4882a593Smuzhiyun# Define NO_LIBBABELTRACE if you do not want libbabeltrace support
83*4882a593Smuzhiyun# for CTF data format.
84*4882a593Smuzhiyun#
85*4882a593Smuzhiyun# Define NO_LZMA if you do not want to support compressed (xz) kernel modules
86*4882a593Smuzhiyun#
87*4882a593Smuzhiyun# Define NO_AUXTRACE if you do not want AUX area tracing support
88*4882a593Smuzhiyun#
89*4882a593Smuzhiyun# Define NO_LIBBPF if you do not want BPF support
90*4882a593Smuzhiyun#
91*4882a593Smuzhiyun# Define NO_LIBCAP if you do not want process capabilities considered by perf
92*4882a593Smuzhiyun#
93*4882a593Smuzhiyun# Define NO_SDT if you do not want to define SDT event in perf tools,
94*4882a593Smuzhiyun# note that it doesn't disable SDT scanning support.
95*4882a593Smuzhiyun#
96*4882a593Smuzhiyun# Define FEATURES_DUMP to provide features detection dump file
97*4882a593Smuzhiyun# and bypass the feature detection
98*4882a593Smuzhiyun#
99*4882a593Smuzhiyun# Define NO_JVMTI if you do not want jvmti agent built
100*4882a593Smuzhiyun#
101*4882a593Smuzhiyun# Define NO_JVMTI_CMLR (debug only) if you do not want to process CMLR
102*4882a593Smuzhiyun# data for java source lines.
103*4882a593Smuzhiyun#
104*4882a593Smuzhiyun# Define LIBCLANGLLVM if you DO want builtin clang and llvm support.
105*4882a593Smuzhiyun# When selected, pass LLVM_CONFIG=/path/to/llvm-config to `make' if
106*4882a593Smuzhiyun# llvm-config is not in $PATH.
107*4882a593Smuzhiyun#
108*4882a593Smuzhiyun# Define CORESIGHT if you DO WANT support for CoreSight trace decoding.
109*4882a593Smuzhiyun#
110*4882a593Smuzhiyun# Define NO_AIO if you do not want support of Posix AIO based trace
111*4882a593Smuzhiyun# streaming for record mode. Currently Posix AIO trace streaming is
112*4882a593Smuzhiyun# supported only when linking with glibc.
113*4882a593Smuzhiyun#
114*4882a593Smuzhiyun# Define NO_LIBZSTD if you do not want support of Zstandard based runtime
115*4882a593Smuzhiyun# trace compression in record mode.
116*4882a593Smuzhiyun#
117*4882a593Smuzhiyun# Define TCMALLOC to enable tcmalloc heap profiling.
118*4882a593Smuzhiyun#
119*4882a593Smuzhiyun# Define LIBBPF_DYNAMIC to enable libbpf dynamic linking.
120*4882a593Smuzhiyun#
121*4882a593Smuzhiyun# Define NO_SYSCALL_TABLE=1 to disable the use of syscall id to/from name tables
122*4882a593Smuzhiyun# generated from the kernel .tbl or unistd.h files and use, if available, libaudit
123*4882a593Smuzhiyun# for doing the conversions to/from strings/id.
124*4882a593Smuzhiyun#
125*4882a593Smuzhiyun# Define LIBPFM4 to enable libpfm4 events extension.
126*4882a593Smuzhiyun#
127*4882a593Smuzhiyun# Define NO_LIBDEBUGINFOD if you do not want support debuginfod
128*4882a593Smuzhiyun#
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun# As per kernel Makefile, avoid funny character set dependencies
131*4882a593Smuzhiyununexport LC_ALL
132*4882a593SmuzhiyunLC_COLLATE=C
133*4882a593SmuzhiyunLC_NUMERIC=C
134*4882a593Smuzhiyunexport LC_COLLATE LC_NUMERIC
135*4882a593Smuzhiyun
136*4882a593Smuzhiyunifeq ($(srctree),)
137*4882a593Smuzhiyunsrctree := $(patsubst %/,%,$(dir $(CURDIR)))
138*4882a593Smuzhiyunsrctree := $(patsubst %/,%,$(dir $(srctree)))
139*4882a593Smuzhiyun#$(info Determined 'srctree' to be $(srctree))
140*4882a593Smuzhiyunendif
141*4882a593Smuzhiyun
142*4882a593Smuzhiyunifneq ($(objtree),)
143*4882a593Smuzhiyun#$(info Determined 'objtree' to be $(objtree))
144*4882a593Smuzhiyunendif
145*4882a593Smuzhiyun
146*4882a593Smuzhiyunifneq ($(OUTPUT),)
147*4882a593Smuzhiyun#$(info Determined 'OUTPUT' to be $(OUTPUT))
148*4882a593Smuzhiyun# Adding $(OUTPUT) as a directory to look for source files,
149*4882a593Smuzhiyun# because use generated output files as sources dependency
150*4882a593Smuzhiyun# for flex/bison parsers.
151*4882a593SmuzhiyunVPATH += $(OUTPUT)
152*4882a593Smuzhiyunexport VPATH
153*4882a593Smuzhiyunendif
154*4882a593Smuzhiyun
155*4882a593Smuzhiyunifeq ($(V),1)
156*4882a593Smuzhiyun  Q =
157*4882a593Smuzhiyunelse
158*4882a593Smuzhiyun  Q = @
159*4882a593Smuzhiyunendif
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun# Do not use make's built-in rules
162*4882a593Smuzhiyun# (this improves performance and avoids hard-to-debug behaviour);
163*4882a593SmuzhiyunMAKEFLAGS += -r
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun# Makefiles suck: This macro sets a default value of $(2) for the
166*4882a593Smuzhiyun# variable named by $(1), unless the variable has been set by
167*4882a593Smuzhiyun# environment or command line. This is necessary for CC and AR
168*4882a593Smuzhiyun# because make sets default values, so the simpler ?= approach
169*4882a593Smuzhiyun# won't work as expected.
170*4882a593Smuzhiyundefine allow-override
171*4882a593Smuzhiyun  $(if $(or $(findstring environment,$(origin $(1))),\
172*4882a593Smuzhiyun            $(findstring command line,$(origin $(1)))),,\
173*4882a593Smuzhiyun    $(eval $(1) = $(2)))
174*4882a593Smuzhiyunendef
175*4882a593Smuzhiyun
176*4882a593SmuzhiyunLD += $(EXTRA_LDFLAGS)
177*4882a593Smuzhiyun
178*4882a593SmuzhiyunPKG_CONFIG = $(CROSS_COMPILE)pkg-config
179*4882a593SmuzhiyunLLVM_CONFIG ?= llvm-config
180*4882a593Smuzhiyun
181*4882a593SmuzhiyunRM      = rm -f
182*4882a593SmuzhiyunLN      = ln -f
183*4882a593SmuzhiyunMKDIR   = mkdir
184*4882a593SmuzhiyunFIND    = find
185*4882a593SmuzhiyunINSTALL = install
186*4882a593SmuzhiyunFLEX    ?= flex
187*4882a593SmuzhiyunBISON   ?= bison
188*4882a593SmuzhiyunSTRIP   = strip
189*4882a593SmuzhiyunAWK     = awk
190*4882a593Smuzhiyun
191*4882a593Smuzhiyun# include Makefile.config by default and rule out
192*4882a593Smuzhiyun# non-config cases
193*4882a593Smuzhiyunconfig := 1
194*4882a593Smuzhiyun
195*4882a593SmuzhiyunNON_CONFIG_TARGETS := clean python-clean TAGS tags cscope help
196*4882a593Smuzhiyun
197*4882a593Smuzhiyunifdef MAKECMDGOALS
198*4882a593Smuzhiyunifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
199*4882a593Smuzhiyun  config := 0
200*4882a593Smuzhiyunendif
201*4882a593Smuzhiyunendif
202*4882a593Smuzhiyun
203*4882a593Smuzhiyun# The fixdep build - we force fixdep tool to be built as
204*4882a593Smuzhiyun# the first target in the separate make session not to be
205*4882a593Smuzhiyun# disturbed by any parallel make jobs. Once fixdep is done
206*4882a593Smuzhiyun# we issue the requested build with FIXDEP=1 variable.
207*4882a593Smuzhiyun#
208*4882a593Smuzhiyun# The fixdep build is disabled for $(NON_CONFIG_TARGETS)
209*4882a593Smuzhiyun# targets, because it's not necessary.
210*4882a593Smuzhiyun
211*4882a593Smuzhiyunifdef FIXDEP
212*4882a593Smuzhiyun  force_fixdep := 0
213*4882a593Smuzhiyunelse
214*4882a593Smuzhiyun  force_fixdep := $(config)
215*4882a593Smuzhiyunendif
216*4882a593Smuzhiyun
217*4882a593Smuzhiyunexport srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK
218*4882a593Smuzhiyunexport HOSTCC HOSTLD HOSTAR
219*4882a593Smuzhiyun
220*4882a593Smuzhiyuninclude $(srctree)/tools/build/Makefile.include
221*4882a593Smuzhiyun
222*4882a593Smuzhiyunifeq ($(force_fixdep),1)
223*4882a593Smuzhiyungoals := $(filter-out all sub-make, $(MAKECMDGOALS))
224*4882a593Smuzhiyun
225*4882a593Smuzhiyun$(goals) all: sub-make
226*4882a593Smuzhiyun
227*4882a593Smuzhiyunsub-make: fixdep
228*4882a593Smuzhiyun	@./check-headers.sh
229*4882a593Smuzhiyun	$(Q)$(MAKE) FIXDEP=1 -f Makefile.perf $(goals)
230*4882a593Smuzhiyun
231*4882a593Smuzhiyunelse # force_fixdep
232*4882a593Smuzhiyun
233*4882a593SmuzhiyunLIB_DIR         = $(srctree)/tools/lib/api/
234*4882a593SmuzhiyunTRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
235*4882a593SmuzhiyunBPF_DIR         = $(srctree)/tools/lib/bpf/
236*4882a593SmuzhiyunSUBCMD_DIR      = $(srctree)/tools/lib/subcmd/
237*4882a593SmuzhiyunLIBPERF_DIR     = $(srctree)/tools/lib/perf/
238*4882a593SmuzhiyunDOC_DIR         = $(srctree)/tools/perf/Documentation/
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun# Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
241*4882a593Smuzhiyun# Without this setting the output feature dump file misses some features, for
242*4882a593Smuzhiyun# example, liberty. Select all checkers so we won't get an incomplete feature
243*4882a593Smuzhiyun# dump file.
244*4882a593Smuzhiyunifeq ($(config),1)
245*4882a593Smuzhiyunifdef MAKECMDGOALS
246*4882a593Smuzhiyunifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump)
247*4882a593SmuzhiyunFEATURE_TESTS := all
248*4882a593Smuzhiyunendif
249*4882a593Smuzhiyunendif
250*4882a593Smuzhiyuninclude Makefile.config
251*4882a593Smuzhiyunendif
252*4882a593Smuzhiyun
253*4882a593Smuzhiyunifeq ($(config),0)
254*4882a593Smuzhiyuninclude $(srctree)/tools/scripts/Makefile.arch
255*4882a593Smuzhiyun-include arch/$(SRCARCH)/Makefile
256*4882a593Smuzhiyunendif
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun# The FEATURE_DUMP_EXPORT holds location of the actual
259*4882a593Smuzhiyun# FEATURE_DUMP file to be used to bypass feature detection
260*4882a593Smuzhiyun# (for bpf or any other subproject)
261*4882a593Smuzhiyunifeq ($(FEATURES_DUMP),)
262*4882a593SmuzhiyunFEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
263*4882a593Smuzhiyunelse
264*4882a593SmuzhiyunFEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP))
265*4882a593Smuzhiyunendif
266*4882a593Smuzhiyun
267*4882a593Smuzhiyunexport prefix bindir sharedir sysconfdir DESTDIR
268*4882a593Smuzhiyun
269*4882a593Smuzhiyun# sparse is architecture-neutral, which means that we need to tell it
270*4882a593Smuzhiyun# explicitly what architecture to check for. Fix this up for yours..
271*4882a593SmuzhiyunSPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
272*4882a593Smuzhiyun
273*4882a593Smuzhiyun# Guard against environment variables
274*4882a593SmuzhiyunPYRF_OBJS =
275*4882a593SmuzhiyunSCRIPT_SH =
276*4882a593Smuzhiyun
277*4882a593SmuzhiyunSCRIPT_SH += perf-archive.sh
278*4882a593SmuzhiyunSCRIPT_SH += perf-with-kcore.sh
279*4882a593Smuzhiyun
280*4882a593Smuzhiyungrep-libs = $(filter -l%,$(1))
281*4882a593Smuzhiyunstrip-libs = $(filter-out -l%,$(1))
282*4882a593Smuzhiyun
283*4882a593Smuzhiyunifneq ($(OUTPUT),)
284*4882a593Smuzhiyun  TE_PATH=$(OUTPUT)
285*4882a593Smuzhiyun  PLUGINS_PATH=$(OUTPUT)
286*4882a593Smuzhiyun  BPF_PATH=$(OUTPUT)
287*4882a593Smuzhiyun  SUBCMD_PATH=$(OUTPUT)
288*4882a593Smuzhiyun  LIBPERF_PATH=$(OUTPUT)
289*4882a593Smuzhiyunifneq ($(subdir),)
290*4882a593Smuzhiyun  API_PATH=$(OUTPUT)/../lib/api/
291*4882a593Smuzhiyunelse
292*4882a593Smuzhiyun  API_PATH=$(OUTPUT)
293*4882a593Smuzhiyunendif
294*4882a593Smuzhiyunelse
295*4882a593Smuzhiyun  TE_PATH=$(TRACE_EVENT_DIR)
296*4882a593Smuzhiyun  PLUGINS_PATH=$(TRACE_EVENT_DIR)plugins/
297*4882a593Smuzhiyun  API_PATH=$(LIB_DIR)
298*4882a593Smuzhiyun  BPF_PATH=$(BPF_DIR)
299*4882a593Smuzhiyun  SUBCMD_PATH=$(SUBCMD_DIR)
300*4882a593Smuzhiyun  LIBPERF_PATH=$(LIBPERF_DIR)
301*4882a593Smuzhiyunendif
302*4882a593Smuzhiyun
303*4882a593SmuzhiyunLIBTRACEEVENT = $(TE_PATH)libtraceevent.a
304*4882a593Smuzhiyunexport LIBTRACEEVENT
305*4882a593Smuzhiyun
306*4882a593SmuzhiyunLIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list
307*4882a593Smuzhiyun
308*4882a593Smuzhiyun#
309*4882a593Smuzhiyun# The static build has no dynsym table, so this does not work for
310*4882a593Smuzhiyun# static build. Looks like linker starts to scream about that now
311*4882a593Smuzhiyun# (in Fedora 26) so we need to switch it off for static build.
312*4882a593SmuzhiyunDYNAMIC_LIST_LDFLAGS               = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
313*4882a593SmuzhiyunLIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS))
314*4882a593Smuzhiyun
315*4882a593SmuzhiyunLIBAPI = $(API_PATH)libapi.a
316*4882a593Smuzhiyunexport LIBAPI
317*4882a593Smuzhiyun
318*4882a593SmuzhiyunLIBBPF = $(BPF_PATH)libbpf.a
319*4882a593Smuzhiyun
320*4882a593SmuzhiyunLIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
321*4882a593Smuzhiyun
322*4882a593SmuzhiyunLIBPERF = $(LIBPERF_PATH)libperf.a
323*4882a593Smuzhiyunexport LIBPERF
324*4882a593Smuzhiyun
325*4882a593Smuzhiyun# python extension build directories
326*4882a593SmuzhiyunPYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
327*4882a593SmuzhiyunPYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
328*4882a593SmuzhiyunPYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
329*4882a593Smuzhiyunexport PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
330*4882a593Smuzhiyun
331*4882a593Smuzhiyunpython-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
332*4882a593Smuzhiyun
333*4882a593SmuzhiyunPYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
334*4882a593SmuzhiyunPYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
335*4882a593Smuzhiyun
336*4882a593SmuzhiyunSCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
337*4882a593Smuzhiyun
338*4882a593SmuzhiyunPROGRAMS += $(OUTPUT)perf
339*4882a593Smuzhiyun
340*4882a593Smuzhiyunifndef NO_PERF_READ_VDSO32
341*4882a593SmuzhiyunPROGRAMS += $(OUTPUT)perf-read-vdso32
342*4882a593Smuzhiyunendif
343*4882a593Smuzhiyun
344*4882a593Smuzhiyunifndef NO_PERF_READ_VDSOX32
345*4882a593SmuzhiyunPROGRAMS += $(OUTPUT)perf-read-vdsox32
346*4882a593Smuzhiyunendif
347*4882a593Smuzhiyun
348*4882a593SmuzhiyunLIBJVMTI = libperf-jvmti.so
349*4882a593Smuzhiyun
350*4882a593Smuzhiyunifndef NO_JVMTI
351*4882a593SmuzhiyunPROGRAMS += $(OUTPUT)$(LIBJVMTI)
352*4882a593Smuzhiyunendif
353*4882a593Smuzhiyun
354*4882a593Smuzhiyun# what 'all' will build and 'install' will install, in perfexecdir
355*4882a593SmuzhiyunALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
356*4882a593Smuzhiyun
357*4882a593Smuzhiyun# what 'all' will build but not install in perfexecdir
358*4882a593SmuzhiyunOTHER_PROGRAMS = $(OUTPUT)perf
359*4882a593Smuzhiyun
360*4882a593Smuzhiyun# Set paths to tools early so that they can be used for version tests.
361*4882a593Smuzhiyunifndef SHELL_PATH
362*4882a593Smuzhiyun  SHELL_PATH = /bin/sh
363*4882a593Smuzhiyunendif
364*4882a593Smuzhiyunifndef PERL_PATH
365*4882a593Smuzhiyun  PERL_PATH = /usr/bin/perl
366*4882a593Smuzhiyunendif
367*4882a593Smuzhiyun
368*4882a593Smuzhiyunexport PERL_PATH
369*4882a593Smuzhiyun
370*4882a593SmuzhiyunPERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF)
371*4882a593Smuzhiyunifndef NO_LIBBPF
372*4882a593Smuzhiyun  ifndef LIBBPF_DYNAMIC
373*4882a593Smuzhiyun    PERFLIBS += $(LIBBPF)
374*4882a593Smuzhiyun  endif
375*4882a593Smuzhiyunendif
376*4882a593Smuzhiyun
377*4882a593Smuzhiyun# We choose to avoid "if .. else if .. else .. endif endif"
378*4882a593Smuzhiyun# because maintaining the nesting to match is a pain.  If
379*4882a593Smuzhiyun# we had "elif" things would have been much nicer...
380*4882a593Smuzhiyun
381*4882a593Smuzhiyunifneq ($(OUTPUT),)
382*4882a593Smuzhiyun  CFLAGS += -I$(OUTPUT)
383*4882a593Smuzhiyunendif
384*4882a593Smuzhiyun
385*4882a593Smuzhiyunifdef GTK2
386*4882a593Smuzhiyun  ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
387*4882a593Smuzhiyun  GTK_IN := $(OUTPUT)gtk-in.o
388*4882a593Smuzhiyunendif
389*4882a593Smuzhiyun
390*4882a593Smuzhiyunifdef ASCIIDOC8
391*4882a593Smuzhiyun  export ASCIIDOC8
392*4882a593Smuzhiyunendif
393*4882a593Smuzhiyun
394*4882a593SmuzhiyunEXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
395*4882a593SmuzhiyunLIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
396*4882a593Smuzhiyun
397*4882a593Smuzhiyunifeq ($(USE_CLANG), 1)
398*4882a593Smuzhiyun  CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
399*4882a593Smuzhiyun  CLANGLIBS_NOEXT_LIST = $(foreach l,$(CLANGLIBS_LIST),$(shell $(LLVM_CONFIG) --libdir)/libclang$(l))
400*4882a593Smuzhiyun  LIBCLANG = $(foreach l,$(CLANGLIBS_NOEXT_LIST),$(wildcard $(l).a $(l).so))
401*4882a593Smuzhiyun  LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-group
402*4882a593Smuzhiyunendif
403*4882a593Smuzhiyun
404*4882a593Smuzhiyunifeq ($(USE_LLVM), 1)
405*4882a593Smuzhiyun  LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)
406*4882a593Smuzhiyun  LIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)
407*4882a593Smuzhiyunendif
408*4882a593Smuzhiyun
409*4882a593Smuzhiyunifeq ($(USE_CXX), 1)
410*4882a593Smuzhiyun  LIBS += -lstdc++
411*4882a593Smuzhiyunendif
412*4882a593Smuzhiyun
413*4882a593Smuzhiyunexport INSTALL SHELL_PATH
414*4882a593Smuzhiyun
415*4882a593Smuzhiyun### Build rules
416*4882a593Smuzhiyun
417*4882a593SmuzhiyunSHELL = $(SHELL_PATH)
418*4882a593Smuzhiyun
419*4882a593Smuzhiyunbeauty_linux_dir := $(srctree)/tools/perf/trace/beauty/include/linux/
420*4882a593Smuzhiyunlinux_uapi_dir := $(srctree)/tools/include/uapi/linux
421*4882a593Smuzhiyunasm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic
422*4882a593Smuzhiyunarch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/
423*4882a593Smuzhiyunx86_arch_asm_uapi_dir := $(srctree)/tools/arch/x86/include/uapi/asm/
424*4882a593Smuzhiyunx86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/
425*4882a593Smuzhiyun
426*4882a593Smuzhiyunbeauty_outdir := $(OUTPUT)trace/beauty/generated
427*4882a593Smuzhiyunbeauty_ioctl_outdir := $(beauty_outdir)/ioctl
428*4882a593Smuzhiyundrm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c
429*4882a593Smuzhiyundrm_hdr_dir := $(srctree)/tools/include/uapi/drm
430*4882a593Smuzhiyundrm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh
431*4882a593Smuzhiyun
432*4882a593Smuzhiyun# Create output directory if not already present
433*4882a593Smuzhiyun_dummy := $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)')
434*4882a593Smuzhiyun
435*4882a593Smuzhiyun$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl)
436*4882a593Smuzhiyun	$(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@
437*4882a593Smuzhiyun
438*4882a593Smuzhiyunfadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c
439*4882a593Smuzhiyunfadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh
440*4882a593Smuzhiyun
441*4882a593Smuzhiyun$(fadvise_advice_array): $(linux_uapi_dir)/in.h $(fadvise_advice_tbl)
442*4882a593Smuzhiyun	$(Q)$(SHELL) '$(fadvise_advice_tbl)' $(linux_uapi_dir) > $@
443*4882a593Smuzhiyun
444*4882a593Smuzhiyunfsmount_arrays := $(beauty_outdir)/fsmount_arrays.c
445*4882a593Smuzhiyunfsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh
446*4882a593Smuzhiyun
447*4882a593Smuzhiyun$(fsmount_arrays): $(linux_uapi_dir)/fs.h $(fsmount_tbls)
448*4882a593Smuzhiyun	$(Q)$(SHELL) '$(fsmount_tbls)' $(linux_uapi_dir) > $@
449*4882a593Smuzhiyun
450*4882a593Smuzhiyunfspick_arrays := $(beauty_outdir)/fspick_arrays.c
451*4882a593Smuzhiyunfspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh
452*4882a593Smuzhiyun
453*4882a593Smuzhiyun$(fspick_arrays): $(linux_uapi_dir)/fs.h $(fspick_tbls)
454*4882a593Smuzhiyun	$(Q)$(SHELL) '$(fspick_tbls)' $(linux_uapi_dir) > $@
455*4882a593Smuzhiyun
456*4882a593Smuzhiyunfsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c
457*4882a593Smuzhiyunfsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh
458*4882a593Smuzhiyun
459*4882a593Smuzhiyun$(fsconfig_arrays): $(linux_uapi_dir)/fs.h $(fsconfig_tbls)
460*4882a593Smuzhiyun	$(Q)$(SHELL) '$(fsconfig_tbls)' $(linux_uapi_dir) > $@
461*4882a593Smuzhiyun
462*4882a593Smuzhiyunpkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c
463*4882a593Smuzhiyunasm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
464*4882a593Smuzhiyunpkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
465*4882a593Smuzhiyun
466*4882a593Smuzhiyun$(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl)
467*4882a593Smuzhiyun	$(Q)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@
468*4882a593Smuzhiyun
469*4882a593Smuzhiyunsndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c
470*4882a593Smuzhiyunsndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound
471*4882a593Smuzhiyunsndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh
472*4882a593Smuzhiyun
473*4882a593Smuzhiyun$(sndrv_ctl_ioctl_array): $(sndrv_ctl_hdr_dir)/asound.h $(sndrv_ctl_ioctl_tbl)
474*4882a593Smuzhiyun	$(Q)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(sndrv_ctl_hdr_dir) > $@
475*4882a593Smuzhiyun
476*4882a593Smuzhiyunsndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c
477*4882a593Smuzhiyunsndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound
478*4882a593Smuzhiyunsndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh
479*4882a593Smuzhiyun
480*4882a593Smuzhiyun$(sndrv_pcm_ioctl_array): $(sndrv_pcm_hdr_dir)/asound.h $(sndrv_pcm_ioctl_tbl)
481*4882a593Smuzhiyun	$(Q)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(sndrv_pcm_hdr_dir) > $@
482*4882a593Smuzhiyun
483*4882a593Smuzhiyunkcmp_type_array := $(beauty_outdir)/kcmp_type_array.c
484*4882a593Smuzhiyunkcmp_hdr_dir := $(srctree)/tools/include/uapi/linux/
485*4882a593Smuzhiyunkcmp_type_tbl := $(srctree)/tools/perf/trace/beauty/kcmp_type.sh
486*4882a593Smuzhiyun
487*4882a593Smuzhiyun$(kcmp_type_array): $(kcmp_hdr_dir)/kcmp.h $(kcmp_type_tbl)
488*4882a593Smuzhiyun	$(Q)$(SHELL) '$(kcmp_type_tbl)' $(kcmp_hdr_dir) > $@
489*4882a593Smuzhiyun
490*4882a593Smuzhiyunkvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c
491*4882a593Smuzhiyunkvm_hdr_dir := $(srctree)/tools/include/uapi/linux
492*4882a593Smuzhiyunkvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh
493*4882a593Smuzhiyun
494*4882a593Smuzhiyun$(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl)
495*4882a593Smuzhiyun	$(Q)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@
496*4882a593Smuzhiyun
497*4882a593Smuzhiyunsocket_ipproto_array := $(beauty_outdir)/socket_ipproto_array.c
498*4882a593Smuzhiyunsocket_ipproto_tbl := $(srctree)/tools/perf/trace/beauty/socket_ipproto.sh
499*4882a593Smuzhiyun
500*4882a593Smuzhiyun$(socket_ipproto_array): $(linux_uapi_dir)/in.h $(socket_ipproto_tbl)
501*4882a593Smuzhiyun	$(Q)$(SHELL) '$(socket_ipproto_tbl)' $(linux_uapi_dir) > $@
502*4882a593Smuzhiyun
503*4882a593Smuzhiyunsocket_arrays := $(beauty_outdir)/socket_arrays.c
504*4882a593Smuzhiyunsocket_tbl := $(srctree)/tools/perf/trace/beauty/socket.sh
505*4882a593Smuzhiyun
506*4882a593Smuzhiyun$(socket_arrays): $(beauty_linux_dir)/socket.h $(socket_tbl)
507*4882a593Smuzhiyun	$(Q)$(SHELL) '$(socket_tbl)' $(beauty_linux_dir) > $@
508*4882a593Smuzhiyun
509*4882a593Smuzhiyunvhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c
510*4882a593Smuzhiyunvhost_virtio_hdr_dir := $(srctree)/tools/include/uapi/linux
511*4882a593Smuzhiyunvhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh
512*4882a593Smuzhiyun
513*4882a593Smuzhiyun$(vhost_virtio_ioctl_array): $(vhost_virtio_hdr_dir)/vhost.h $(vhost_virtio_ioctl_tbl)
514*4882a593Smuzhiyun	$(Q)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(vhost_virtio_hdr_dir) > $@
515*4882a593Smuzhiyun
516*4882a593Smuzhiyunperf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c
517*4882a593Smuzhiyunperf_hdr_dir := $(srctree)/tools/include/uapi/linux
518*4882a593Smuzhiyunperf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh
519*4882a593Smuzhiyun
520*4882a593Smuzhiyun$(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl)
521*4882a593Smuzhiyun	$(Q)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@
522*4882a593Smuzhiyun
523*4882a593Smuzhiyunmadvise_behavior_array := $(beauty_outdir)/madvise_behavior_array.c
524*4882a593Smuzhiyunmadvise_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
525*4882a593Smuzhiyunmadvise_behavior_tbl := $(srctree)/tools/perf/trace/beauty/madvise_behavior.sh
526*4882a593Smuzhiyun
527*4882a593Smuzhiyun$(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_tbl)
528*4882a593Smuzhiyun	$(Q)$(SHELL) '$(madvise_behavior_tbl)' $(madvise_hdr_dir) > $@
529*4882a593Smuzhiyun
530*4882a593Smuzhiyunmmap_flags_array := $(beauty_outdir)/mmap_flags_array.c
531*4882a593Smuzhiyunmmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh
532*4882a593Smuzhiyun
533*4882a593Smuzhiyun$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl)
534*4882a593Smuzhiyun	$(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@
535*4882a593Smuzhiyun
536*4882a593Smuzhiyunmremap_flags_array := $(beauty_outdir)/mremap_flags_array.c
537*4882a593Smuzhiyunmremap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mremap_flags.sh
538*4882a593Smuzhiyun
539*4882a593Smuzhiyun$(mremap_flags_array): $(linux_uapi_dir)/mman.h $(mremap_flags_tbl)
540*4882a593Smuzhiyun	$(Q)$(SHELL) '$(mremap_flags_tbl)' $(linux_uapi_dir) > $@
541*4882a593Smuzhiyun
542*4882a593Smuzhiyunmount_flags_array := $(beauty_outdir)/mount_flags_array.c
543*4882a593Smuzhiyunmount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh
544*4882a593Smuzhiyun
545*4882a593Smuzhiyun$(mount_flags_array): $(linux_uapi_dir)/fs.h $(mount_flags_tbl)
546*4882a593Smuzhiyun	$(Q)$(SHELL) '$(mount_flags_tbl)' $(linux_uapi_dir) > $@
547*4882a593Smuzhiyun
548*4882a593Smuzhiyunmove_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c
549*4882a593Smuzhiyunmove_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh
550*4882a593Smuzhiyun
551*4882a593Smuzhiyun$(move_mount_flags_array): $(linux_uapi_dir)/fs.h $(move_mount_flags_tbl)
552*4882a593Smuzhiyun	$(Q)$(SHELL) '$(move_mount_flags_tbl)' $(linux_uapi_dir) > $@
553*4882a593Smuzhiyun
554*4882a593Smuzhiyun
555*4882a593Smuzhiyunmmap_prot_array := $(beauty_outdir)/mmap_prot_array.c
556*4882a593Smuzhiyunmmap_prot_tbl := $(srctree)/tools/perf/trace/beauty/mmap_prot.sh
557*4882a593Smuzhiyun
558*4882a593Smuzhiyun$(mmap_prot_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_prot_tbl)
559*4882a593Smuzhiyun	$(Q)$(SHELL) '$(mmap_prot_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@
560*4882a593Smuzhiyun
561*4882a593Smuzhiyunprctl_option_array := $(beauty_outdir)/prctl_option_array.c
562*4882a593Smuzhiyunprctl_hdr_dir := $(srctree)/tools/include/uapi/linux/
563*4882a593Smuzhiyunprctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh
564*4882a593Smuzhiyun
565*4882a593Smuzhiyun$(prctl_option_array): $(prctl_hdr_dir)/prctl.h $(prctl_option_tbl)
566*4882a593Smuzhiyun	$(Q)$(SHELL) '$(prctl_option_tbl)' $(prctl_hdr_dir) > $@
567*4882a593Smuzhiyun
568*4882a593Smuzhiyunusbdevfs_ioctl_array := $(beauty_ioctl_outdir)/usbdevfs_ioctl_array.c
569*4882a593Smuzhiyunusbdevfs_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/usbdevfs_ioctl.sh
570*4882a593Smuzhiyun
571*4882a593Smuzhiyun$(usbdevfs_ioctl_array): $(linux_uapi_dir)/usbdevice_fs.h $(usbdevfs_ioctl_tbl)
572*4882a593Smuzhiyun	$(Q)$(SHELL) '$(usbdevfs_ioctl_tbl)' $(linux_uapi_dir) > $@
573*4882a593Smuzhiyun
574*4882a593Smuzhiyunx86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c
575*4882a593Smuzhiyunx86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh
576*4882a593Smuzhiyun
577*4882a593Smuzhiyun$(x86_arch_prctl_code_array): $(x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl)
578*4882a593Smuzhiyun	$(Q)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(x86_arch_asm_uapi_dir) > $@
579*4882a593Smuzhiyun
580*4882a593Smuzhiyunx86_arch_irq_vectors_array := $(beauty_outdir)/x86_arch_irq_vectors_array.c
581*4882a593Smuzhiyunx86_arch_irq_vectors_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh
582*4882a593Smuzhiyun
583*4882a593Smuzhiyun$(x86_arch_irq_vectors_array): $(x86_arch_asm_dir)/irq_vectors.h $(x86_arch_irq_vectors_tbl)
584*4882a593Smuzhiyun	$(Q)$(SHELL) '$(x86_arch_irq_vectors_tbl)' $(x86_arch_asm_dir) > $@
585*4882a593Smuzhiyun
586*4882a593Smuzhiyunx86_arch_MSRs_array := $(beauty_outdir)/x86_arch_MSRs_array.c
587*4882a593Smuzhiyunx86_arch_MSRs_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_msr.sh
588*4882a593Smuzhiyun
589*4882a593Smuzhiyun$(x86_arch_MSRs_array): $(x86_arch_asm_dir)/msr-index.h $(x86_arch_MSRs_tbl)
590*4882a593Smuzhiyun	$(Q)$(SHELL) '$(x86_arch_MSRs_tbl)' $(x86_arch_asm_dir) > $@
591*4882a593Smuzhiyun
592*4882a593Smuzhiyunrename_flags_array := $(beauty_outdir)/rename_flags_array.c
593*4882a593Smuzhiyunrename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh
594*4882a593Smuzhiyun
595*4882a593Smuzhiyun$(rename_flags_array): $(linux_uapi_dir)/fs.h $(rename_flags_tbl)
596*4882a593Smuzhiyun	$(Q)$(SHELL) '$(rename_flags_tbl)' $(linux_uapi_dir) > $@
597*4882a593Smuzhiyun
598*4882a593Smuzhiyunarch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c
599*4882a593Smuzhiyunarch_errno_hdr_dir := $(srctree)/tools
600*4882a593Smuzhiyunarch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
601*4882a593Smuzhiyun
602*4882a593Smuzhiyun$(arch_errno_name_array): $(arch_errno_tbl)
603*4882a593Smuzhiyun	$(Q)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@
604*4882a593Smuzhiyun
605*4882a593Smuzhiyunsync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c
606*4882a593Smuzhiyunsync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh
607*4882a593Smuzhiyun
608*4882a593Smuzhiyun$(sync_file_range_arrays): $(linux_uapi_dir)/fs.h $(sync_file_range_tbls)
609*4882a593Smuzhiyun	$(Q)$(SHELL) '$(sync_file_range_tbls)' $(linux_uapi_dir) > $@
610*4882a593Smuzhiyun
611*4882a593Smuzhiyunall: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
612*4882a593Smuzhiyun
613*4882a593Smuzhiyun# Create python binding output directory if not already present
614*4882a593Smuzhiyun_dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
615*4882a593Smuzhiyun
616*4882a593Smuzhiyun$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) $(LIBPERF)
617*4882a593Smuzhiyun	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
618*4882a593Smuzhiyun        CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
619*4882a593Smuzhiyun	  $(PYTHON_WORD) util/setup.py \
620*4882a593Smuzhiyun	  --quiet build_ext; \
621*4882a593Smuzhiyun	cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
622*4882a593Smuzhiyun
623*4882a593Smuzhiyunplease_set_SHELL_PATH_to_a_more_modern_shell:
624*4882a593Smuzhiyun	$(Q)$$(:)
625*4882a593Smuzhiyun
626*4882a593Smuzhiyunshell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
627*4882a593Smuzhiyun
628*4882a593Smuzhiyunstrip: $(PROGRAMS) $(OUTPUT)perf
629*4882a593Smuzhiyun	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
630*4882a593Smuzhiyun
631*4882a593SmuzhiyunPERF_IN := $(OUTPUT)perf-in.o
632*4882a593Smuzhiyun
633*4882a593SmuzhiyunJEVENTS       := $(OUTPUT)pmu-events/jevents
634*4882a593SmuzhiyunJEVENTS_IN    := $(OUTPUT)pmu-events/jevents-in.o
635*4882a593Smuzhiyun
636*4882a593SmuzhiyunPMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
637*4882a593Smuzhiyun
638*4882a593Smuzhiyunexport JEVENTS
639*4882a593Smuzhiyun
640*4882a593Smuzhiyunbuild := -f $(srctree)/tools/build/Makefile.build dir=. obj
641*4882a593Smuzhiyun
642*4882a593Smuzhiyun$(PERF_IN): prepare FORCE
643*4882a593Smuzhiyun	$(Q)$(MAKE) $(build)=perf
644*4882a593Smuzhiyun
645*4882a593Smuzhiyun$(JEVENTS_IN): FORCE
646*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=jevents
647*4882a593Smuzhiyun
648*4882a593Smuzhiyun$(JEVENTS): $(JEVENTS_IN)
649*4882a593Smuzhiyun	$(QUIET_LINK)$(HOSTCC) $(JEVENTS_IN) -o $@
650*4882a593Smuzhiyun
651*4882a593Smuzhiyun$(PMU_EVENTS_IN): $(JEVENTS) FORCE
652*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
653*4882a593Smuzhiyun
654*4882a593Smuzhiyun$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
655*4882a593Smuzhiyun	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
656*4882a593Smuzhiyun		$(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
657*4882a593Smuzhiyun
658*4882a593Smuzhiyun$(GTK_IN): FORCE
659*4882a593Smuzhiyun	$(Q)$(MAKE) $(build)=gtk
660*4882a593Smuzhiyun
661*4882a593Smuzhiyun$(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
662*4882a593Smuzhiyun	$(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
663*4882a593Smuzhiyun
664*4882a593Smuzhiyun$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
665*4882a593Smuzhiyun
666*4882a593Smuzhiyun$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
667*4882a593Smuzhiyun	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
668*4882a593Smuzhiyun
669*4882a593Smuzhiyun$(SCRIPTS) : % : %.sh
670*4882a593Smuzhiyun	$(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
671*4882a593Smuzhiyun
672*4882a593Smuzhiyun$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
673*4882a593Smuzhiyun	$(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
674*4882a593Smuzhiyun	$(Q)touch $(OUTPUT)PERF-VERSION-FILE
675*4882a593Smuzhiyun
676*4882a593Smuzhiyun# These can record PERF_VERSION
677*4882a593Smuzhiyunperf.spec $(SCRIPTS) \
678*4882a593Smuzhiyun	: $(OUTPUT)PERF-VERSION-FILE
679*4882a593Smuzhiyun
680*4882a593Smuzhiyun.SUFFIXES:
681*4882a593Smuzhiyun
682*4882a593Smuzhiyun#
683*4882a593Smuzhiyun# If a target does not match any of the later rules then prefix it by $(OUTPUT)
684*4882a593Smuzhiyun# This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
685*4882a593Smuzhiyun#
686*4882a593Smuzhiyunifneq ($(OUTPUT),)
687*4882a593Smuzhiyun%.o: $(OUTPUT)%.o
688*4882a593Smuzhiyun	@echo "    # Redirected target $@ => $(OUTPUT)$@"
689*4882a593Smuzhiyunpmu-events/%.o: $(OUTPUT)pmu-events/%.o
690*4882a593Smuzhiyun	@echo "    # Redirected target $@ => $(OUTPUT)$@"
691*4882a593Smuzhiyunutil/%.o: $(OUTPUT)util/%.o
692*4882a593Smuzhiyun	@echo "    # Redirected target $@ => $(OUTPUT)$@"
693*4882a593Smuzhiyunbench/%.o: $(OUTPUT)bench/%.o
694*4882a593Smuzhiyun	@echo "    # Redirected target $@ => $(OUTPUT)$@"
695*4882a593Smuzhiyuntests/%.o: $(OUTPUT)tests/%.o
696*4882a593Smuzhiyun	@echo "    # Redirected target $@ => $(OUTPUT)$@"
697*4882a593Smuzhiyunendif
698*4882a593Smuzhiyun
699*4882a593Smuzhiyun# These two need to be here so that when O= is not used they take precedence
700*4882a593Smuzhiyun# over the general rule for .o
701*4882a593Smuzhiyun
702*4882a593Smuzhiyun# get relative building directory (to $(OUTPUT))
703*4882a593Smuzhiyun# and '.' if it's $(OUTPUT) itself
704*4882a593Smuzhiyun__build-dir = $(subst $(OUTPUT),,$(dir $@))
705*4882a593Smuzhiyunbuild-dir   = $(if $(__build-dir),$(__build-dir),.)
706*4882a593Smuzhiyun
707*4882a593Smuzhiyunprepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \
708*4882a593Smuzhiyun	$(fadvise_advice_array) \
709*4882a593Smuzhiyun	$(fsconfig_arrays) \
710*4882a593Smuzhiyun	$(fsmount_arrays) \
711*4882a593Smuzhiyun	$(fspick_arrays) \
712*4882a593Smuzhiyun	$(pkey_alloc_access_rights_array) \
713*4882a593Smuzhiyun	$(sndrv_pcm_ioctl_array) \
714*4882a593Smuzhiyun	$(sndrv_ctl_ioctl_array) \
715*4882a593Smuzhiyun	$(kcmp_type_array) \
716*4882a593Smuzhiyun	$(kvm_ioctl_array) \
717*4882a593Smuzhiyun	$(socket_ipproto_array) \
718*4882a593Smuzhiyun	$(socket_arrays) \
719*4882a593Smuzhiyun	$(vhost_virtio_ioctl_array) \
720*4882a593Smuzhiyun	$(madvise_behavior_array) \
721*4882a593Smuzhiyun	$(mmap_flags_array) \
722*4882a593Smuzhiyun	$(mmap_prot_array) \
723*4882a593Smuzhiyun	$(mremap_flags_array) \
724*4882a593Smuzhiyun	$(mount_flags_array) \
725*4882a593Smuzhiyun	$(move_mount_flags_array) \
726*4882a593Smuzhiyun	$(perf_ioctl_array) \
727*4882a593Smuzhiyun	$(prctl_option_array) \
728*4882a593Smuzhiyun	$(usbdevfs_ioctl_array) \
729*4882a593Smuzhiyun	$(x86_arch_irq_vectors_array) \
730*4882a593Smuzhiyun	$(x86_arch_MSRs_array) \
731*4882a593Smuzhiyun	$(x86_arch_prctl_code_array) \
732*4882a593Smuzhiyun	$(rename_flags_array) \
733*4882a593Smuzhiyun	$(arch_errno_name_array) \
734*4882a593Smuzhiyun	$(sync_file_range_arrays)
735*4882a593Smuzhiyun
736*4882a593Smuzhiyun$(OUTPUT)%.o: %.c prepare FORCE
737*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
738*4882a593Smuzhiyun
739*4882a593Smuzhiyun$(OUTPUT)%.i: %.c prepare FORCE
740*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
741*4882a593Smuzhiyun
742*4882a593Smuzhiyun$(OUTPUT)%.s: %.c prepare FORCE
743*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
744*4882a593Smuzhiyun
745*4882a593Smuzhiyun$(OUTPUT)%-bison.o: %.c prepare FORCE
746*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
747*4882a593Smuzhiyun
748*4882a593Smuzhiyun$(OUTPUT)%-flex.o: %.c prepare FORCE
749*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
750*4882a593Smuzhiyun
751*4882a593Smuzhiyun$(OUTPUT)%.o: %.S prepare FORCE
752*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
753*4882a593Smuzhiyun
754*4882a593Smuzhiyun$(OUTPUT)%.i: %.S prepare FORCE
755*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
756*4882a593Smuzhiyun
757*4882a593Smuzhiyun$(OUTPUT)perf-%: %.o $(PERFLIBS)
758*4882a593Smuzhiyun	$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
759*4882a593Smuzhiyun
760*4882a593Smuzhiyunifndef NO_PERF_READ_VDSO32
761*4882a593Smuzhiyun$(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-map.c
762*4882a593Smuzhiyun	$(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
763*4882a593Smuzhiyunendif
764*4882a593Smuzhiyun
765*4882a593Smuzhiyunifndef NO_PERF_READ_VDSOX32
766*4882a593Smuzhiyun$(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-map.c
767*4882a593Smuzhiyun	$(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
768*4882a593Smuzhiyunendif
769*4882a593Smuzhiyun
770*4882a593Smuzhiyunifndef NO_JVMTI
771*4882a593SmuzhiyunLIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
772*4882a593Smuzhiyun
773*4882a593Smuzhiyun$(LIBJVMTI_IN): FORCE
774*4882a593Smuzhiyun	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
775*4882a593Smuzhiyun
776*4882a593Smuzhiyun$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
777*4882a593Smuzhiyun	$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
778*4882a593Smuzhiyunendif
779*4882a593Smuzhiyun
780*4882a593Smuzhiyun$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
781*4882a593Smuzhiyun
782*4882a593SmuzhiyunLIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(LDFLAGS)'
783*4882a593Smuzhiyun
784*4882a593Smuzhiyun$(LIBTRACEEVENT): FORCE
785*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a
786*4882a593Smuzhiyun
787*4882a593Smuzhiyunlibtraceevent_plugins: FORCE
788*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(TRACE_EVENT_DIR)plugins $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins
789*4882a593Smuzhiyun
790*4882a593Smuzhiyun$(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins
791*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(TRACE_EVENT_DIR)plugins $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent-dynamic-list
792*4882a593Smuzhiyun
793*4882a593Smuzhiyun$(LIBTRACEEVENT)-clean:
794*4882a593Smuzhiyun	$(call QUIET_CLEAN, libtraceevent)
795*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean >/dev/null
796*4882a593Smuzhiyun
797*4882a593Smuzhiyuninstall-traceevent-plugins: libtraceevent_plugins
798*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins
799*4882a593Smuzhiyun
800*4882a593Smuzhiyun$(LIBAPI): FORCE
801*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
802*4882a593Smuzhiyun
803*4882a593Smuzhiyun$(LIBAPI)-clean:
804*4882a593Smuzhiyun	$(call QUIET_CLEAN, libapi)
805*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
806*4882a593Smuzhiyun
807*4882a593Smuzhiyun$(LIBBPF): FORCE
808*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
809*4882a593Smuzhiyun
810*4882a593Smuzhiyun$(LIBBPF)-clean:
811*4882a593Smuzhiyun	$(call QUIET_CLEAN, libbpf)
812*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
813*4882a593Smuzhiyun
814*4882a593Smuzhiyun$(LIBPERF): FORCE
815*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(LIBPERF_DIR) EXTRA_CFLAGS="$(LIBPERF_CFLAGS)" O=$(OUTPUT) $(OUTPUT)libperf.a
816*4882a593Smuzhiyun
817*4882a593Smuzhiyun$(LIBPERF)-clean:
818*4882a593Smuzhiyun	$(call QUIET_CLEAN, libperf)
819*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) clean >/dev/null
820*4882a593Smuzhiyun
821*4882a593Smuzhiyun$(LIBSUBCMD): FORCE
822*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
823*4882a593Smuzhiyun
824*4882a593Smuzhiyun$(LIBSUBCMD)-clean:
825*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) clean
826*4882a593Smuzhiyun
827*4882a593Smuzhiyunhelp:
828*4882a593Smuzhiyun	@echo 'Perf make targets:'
829*4882a593Smuzhiyun	@echo '  doc		- make *all* documentation (see below)'
830*4882a593Smuzhiyun	@echo '  man		- make manpage documentation (access with man <foo>)'
831*4882a593Smuzhiyun	@echo '  html		- make html documentation'
832*4882a593Smuzhiyun	@echo '  info		- make GNU info documentation (access with info <foo>)'
833*4882a593Smuzhiyun	@echo '  pdf		- make pdf documentation'
834*4882a593Smuzhiyun	@echo '  TAGS		- use etags to make tag information for source browsing'
835*4882a593Smuzhiyun	@echo '  tags		- use ctags to make tag information for source browsing'
836*4882a593Smuzhiyun	@echo '  cscope	- use cscope to make interactive browsing database'
837*4882a593Smuzhiyun	@echo ''
838*4882a593Smuzhiyun	@echo 'Perf install targets:'
839*4882a593Smuzhiyun	@echo '  NOTE: documentation build requires asciidoc, xmlto packages to be installed'
840*4882a593Smuzhiyun	@echo '  HINT: use "prefix" or "DESTDIR" to install to a particular'
841*4882a593Smuzhiyun	@echo '        path like "make prefix=/usr/local install install-doc"'
842*4882a593Smuzhiyun	@echo '  install	- install compiled binaries'
843*4882a593Smuzhiyun	@echo '  install-doc	- install *all* documentation'
844*4882a593Smuzhiyun	@echo '  install-man	- install manpage documentation'
845*4882a593Smuzhiyun	@echo '  install-html	- install html documentation'
846*4882a593Smuzhiyun	@echo '  install-info	- install GNU info documentation'
847*4882a593Smuzhiyun	@echo '  install-pdf	- install pdf documentation'
848*4882a593Smuzhiyun	@echo ''
849*4882a593Smuzhiyun	@echo '  quick-install-doc	- alias for quick-install-man'
850*4882a593Smuzhiyun	@echo '  quick-install-man	- install the documentation quickly'
851*4882a593Smuzhiyun	@echo '  quick-install-html	- install the html documentation quickly'
852*4882a593Smuzhiyun	@echo ''
853*4882a593Smuzhiyun	@echo 'Perf maintainer targets:'
854*4882a593Smuzhiyun	@echo '  clean			- clean all binary objects and build output'
855*4882a593Smuzhiyun
856*4882a593Smuzhiyun
857*4882a593SmuzhiyunDOC_TARGETS := doc man html info pdf
858*4882a593Smuzhiyun
859*4882a593SmuzhiyunINSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
860*4882a593SmuzhiyunINSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
861*4882a593Smuzhiyun
862*4882a593Smuzhiyun# 'make doc' should call 'make -C Documentation all'
863*4882a593Smuzhiyun$(DOC_TARGETS):
864*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:doc=all) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
865*4882a593Smuzhiyun
866*4882a593SmuzhiyunTAG_FOLDERS= . ../lib ../include
867*4882a593SmuzhiyunTAG_FILES= ../../include/uapi/linux/perf_event.h
868*4882a593Smuzhiyun
869*4882a593SmuzhiyunTAGS:
870*4882a593Smuzhiyun	$(QUIET_GEN)$(RM) TAGS; \
871*4882a593Smuzhiyun	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs etags -a $(TAG_FILES)
872*4882a593Smuzhiyun
873*4882a593Smuzhiyuntags:
874*4882a593Smuzhiyun	$(QUIET_GEN)$(RM) tags; \
875*4882a593Smuzhiyun	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs ctags -a $(TAG_FILES)
876*4882a593Smuzhiyun
877*4882a593Smuzhiyuncscope:
878*4882a593Smuzhiyun	$(QUIET_GEN)$(RM) cscope*; \
879*4882a593Smuzhiyun	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs cscope -b $(TAG_FILES)
880*4882a593Smuzhiyun
881*4882a593Smuzhiyun### Testing rules
882*4882a593Smuzhiyun
883*4882a593Smuzhiyun# GNU make supports exporting all variables by "export" without parameters.
884*4882a593Smuzhiyun# However, the environment gets quite big, and some programs have problems
885*4882a593Smuzhiyun# with that.
886*4882a593Smuzhiyun
887*4882a593Smuzhiyuncheck: $(OUTPUT)common-cmds.h
888*4882a593Smuzhiyun	if sparse; \
889*4882a593Smuzhiyun	then \
890*4882a593Smuzhiyun		for i in *.c */*.c; \
891*4882a593Smuzhiyun		do \
892*4882a593Smuzhiyun			sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
893*4882a593Smuzhiyun		done; \
894*4882a593Smuzhiyun	else \
895*4882a593Smuzhiyun		exit 1; \
896*4882a593Smuzhiyun	fi
897*4882a593Smuzhiyun
898*4882a593Smuzhiyun### Installation rules
899*4882a593Smuzhiyun
900*4882a593Smuzhiyunifdef GTK2
901*4882a593Smuzhiyuninstall-gtk: $(OUTPUT)libperf-gtk.so
902*4882a593Smuzhiyun	$(call QUIET_INSTALL, 'GTK UI') \
903*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
904*4882a593Smuzhiyun		$(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
905*4882a593Smuzhiyunelse
906*4882a593Smuzhiyuninstall-gtk:
907*4882a593Smuzhiyunendif
908*4882a593Smuzhiyun
909*4882a593Smuzhiyuninstall-tools: all install-gtk
910*4882a593Smuzhiyun	$(call QUIET_INSTALL, binaries) \
911*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
912*4882a593Smuzhiyun		$(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
913*4882a593Smuzhiyun		$(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'
914*4882a593Smuzhiyunifndef NO_PERF_READ_VDSO32
915*4882a593Smuzhiyun	$(call QUIET_INSTALL, perf-read-vdso32) \
916*4882a593Smuzhiyun		$(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
917*4882a593Smuzhiyunendif
918*4882a593Smuzhiyunifndef NO_PERF_READ_VDSOX32
919*4882a593Smuzhiyun	$(call QUIET_INSTALL, perf-read-vdsox32) \
920*4882a593Smuzhiyun		$(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
921*4882a593Smuzhiyunendif
922*4882a593Smuzhiyunifndef NO_JVMTI
923*4882a593Smuzhiyun	$(call QUIET_INSTALL, $(LIBJVMTI)) \
924*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
925*4882a593Smuzhiyun		$(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
926*4882a593Smuzhiyunendif
927*4882a593Smuzhiyun	$(call QUIET_INSTALL, libexec) \
928*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
929*4882a593Smuzhiyunifndef NO_LIBBPF
930*4882a593Smuzhiyun	$(call QUIET_INSTALL, bpf-headers) \
931*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
932*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'; \
933*4882a593Smuzhiyun		$(INSTALL) include/bpf/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
934*4882a593Smuzhiyun		$(INSTALL) include/bpf/linux/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'
935*4882a593Smuzhiyun	$(call QUIET_INSTALL, bpf-examples) \
936*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'; \
937*4882a593Smuzhiyun		$(INSTALL) examples/bpf/*.c -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
938*4882a593Smuzhiyunendif
939*4882a593Smuzhiyun	$(call QUIET_INSTALL, perf-archive) \
940*4882a593Smuzhiyun		$(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
941*4882a593Smuzhiyun	$(call QUIET_INSTALL, perf-with-kcore) \
942*4882a593Smuzhiyun		$(INSTALL) $(OUTPUT)perf-with-kcore -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
943*4882a593Smuzhiyunifndef NO_LIBAUDIT
944*4882a593Smuzhiyun	$(call QUIET_INSTALL, strace/groups) \
945*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'; \
946*4882a593Smuzhiyun		$(INSTALL) trace/strace/groups/* -t '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'
947*4882a593Smuzhiyunendif
948*4882a593Smuzhiyunifndef NO_LIBPERL
949*4882a593Smuzhiyun	$(call QUIET_INSTALL, perl-scripts) \
950*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
951*4882a593Smuzhiyun		$(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
952*4882a593Smuzhiyun		$(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
953*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
954*4882a593Smuzhiyun		$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
955*4882a593Smuzhiyunendif
956*4882a593Smuzhiyunifndef NO_LIBPYTHON
957*4882a593Smuzhiyun	$(call QUIET_INSTALL, python-scripts) \
958*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
959*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
960*4882a593Smuzhiyun		$(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
961*4882a593Smuzhiyun		$(INSTALL) scripts/python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
962*4882a593Smuzhiyun		$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
963*4882a593Smuzhiyunendif
964*4882a593Smuzhiyun	$(call QUIET_INSTALL, perf_completion-script) \
965*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
966*4882a593Smuzhiyun		$(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
967*4882a593Smuzhiyun	$(call QUIET_INSTALL, perf-tip) \
968*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
969*4882a593Smuzhiyun		$(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
970*4882a593Smuzhiyun
971*4882a593Smuzhiyuninstall-tests: all install-gtk
972*4882a593Smuzhiyun	$(call QUIET_INSTALL, tests) \
973*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
974*4882a593Smuzhiyun		$(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
975*4882a593Smuzhiyun		$(INSTALL) tests/pe-file.exe* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
976*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
977*4882a593Smuzhiyun		$(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
978*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
979*4882a593Smuzhiyun		$(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
980*4882a593Smuzhiyun		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
981*4882a593Smuzhiyun		$(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
982*4882a593Smuzhiyun
983*4882a593Smuzhiyuninstall-bin: install-tools install-tests install-traceevent-plugins
984*4882a593Smuzhiyun
985*4882a593Smuzhiyuninstall: install-bin try-install-man
986*4882a593Smuzhiyun
987*4882a593Smuzhiyuninstall-python_ext:
988*4882a593Smuzhiyun	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
989*4882a593Smuzhiyun
990*4882a593Smuzhiyun# 'make install-doc' should call 'make -C Documentation install'
991*4882a593Smuzhiyun$(INSTALL_DOC_TARGETS):
992*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:-doc=) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
993*4882a593Smuzhiyun
994*4882a593Smuzhiyun### Cleaning rules
995*4882a593Smuzhiyun
996*4882a593Smuzhiyun#
997*4882a593Smuzhiyun# This is here, not in Makefile.config, because Makefile.config does
998*4882a593Smuzhiyun# not get included for the clean target:
999*4882a593Smuzhiyun#
1000*4882a593Smuzhiyunconfig-clean:
1001*4882a593Smuzhiyun	$(call QUIET_CLEAN, config)
1002*4882a593Smuzhiyun	$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null
1003*4882a593Smuzhiyun
1004*4882a593Smuzhiyunpython-clean:
1005*4882a593Smuzhiyun	$(python-clean)
1006*4882a593Smuzhiyun
1007*4882a593Smuzhiyunclean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean config-clean fixdep-clean python-clean
1008*4882a593Smuzhiyun	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
1009*4882a593Smuzhiyun	$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
1010*4882a593Smuzhiyun	$(Q)$(RM) $(OUTPUT).config-detected
1011*4882a593Smuzhiyun	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
1012*4882a593Smuzhiyun	$(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
1013*4882a593Smuzhiyun		$(OUTPUT)util/intel-pt-decoder/inat-tables.c \
1014*4882a593Smuzhiyun		$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
1015*4882a593Smuzhiyun		$(OUTPUT)pmu-events/pmu-events.c \
1016*4882a593Smuzhiyun		$(OUTPUT)$(fadvise_advice_array) \
1017*4882a593Smuzhiyun		$(OUTPUT)$(fsconfig_arrays) \
1018*4882a593Smuzhiyun		$(OUTPUT)$(fsmount_arrays) \
1019*4882a593Smuzhiyun		$(OUTPUT)$(fspick_arrays) \
1020*4882a593Smuzhiyun		$(OUTPUT)$(madvise_behavior_array) \
1021*4882a593Smuzhiyun		$(OUTPUT)$(mmap_flags_array) \
1022*4882a593Smuzhiyun		$(OUTPUT)$(mmap_prot_array) \
1023*4882a593Smuzhiyun		$(OUTPUT)$(mremap_flags_array) \
1024*4882a593Smuzhiyun		$(OUTPUT)$(mount_flags_array) \
1025*4882a593Smuzhiyun		$(OUTPUT)$(move_mount_flags_array) \
1026*4882a593Smuzhiyun		$(OUTPUT)$(drm_ioctl_array) \
1027*4882a593Smuzhiyun		$(OUTPUT)$(pkey_alloc_access_rights_array) \
1028*4882a593Smuzhiyun		$(OUTPUT)$(sndrv_ctl_ioctl_array) \
1029*4882a593Smuzhiyun		$(OUTPUT)$(sndrv_pcm_ioctl_array) \
1030*4882a593Smuzhiyun		$(OUTPUT)$(kvm_ioctl_array) \
1031*4882a593Smuzhiyun		$(OUTPUT)$(kcmp_type_array) \
1032*4882a593Smuzhiyun		$(OUTPUT)$(socket_ipproto_array) \
1033*4882a593Smuzhiyun		$(OUTPUT)$(socket_arrays) \
1034*4882a593Smuzhiyun		$(OUTPUT)$(vhost_virtio_ioctl_array) \
1035*4882a593Smuzhiyun		$(OUTPUT)$(perf_ioctl_array) \
1036*4882a593Smuzhiyun		$(OUTPUT)$(prctl_option_array) \
1037*4882a593Smuzhiyun		$(OUTPUT)$(usbdevfs_ioctl_array) \
1038*4882a593Smuzhiyun		$(OUTPUT)$(x86_arch_irq_vectors_array) \
1039*4882a593Smuzhiyun		$(OUTPUT)$(x86_arch_MSRs_array) \
1040*4882a593Smuzhiyun		$(OUTPUT)$(x86_arch_prctl_code_array) \
1041*4882a593Smuzhiyun		$(OUTPUT)$(rename_flags_array) \
1042*4882a593Smuzhiyun		$(OUTPUT)$(arch_errno_name_array) \
1043*4882a593Smuzhiyun		$(OUTPUT)$(sync_file_range_arrays)
1044*4882a593Smuzhiyun	$(call QUIET_CLEAN, Documentation) \
1045*4882a593Smuzhiyun	$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null
1046*4882a593Smuzhiyun
1047*4882a593Smuzhiyun#
1048*4882a593Smuzhiyun# To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
1049*4882a593Smuzhiyun# file if defined, with no further action.
1050*4882a593Smuzhiyunfeature-dump:
1051*4882a593Smuzhiyunifdef FEATURE_DUMP_COPY
1052*4882a593Smuzhiyun	@cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY)
1053*4882a593Smuzhiyun	@echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)"
1054*4882a593Smuzhiyunelse
1055*4882a593Smuzhiyun	@echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP"
1056*4882a593Smuzhiyunendif
1057*4882a593Smuzhiyun
1058*4882a593Smuzhiyun#
1059*4882a593Smuzhiyun# Trick: if ../../.git does not exist - we are building out of tree for example,
1060*4882a593Smuzhiyun# then force version regeneration:
1061*4882a593Smuzhiyun#
1062*4882a593Smuzhiyunifeq ($(wildcard ../../.git/HEAD),)
1063*4882a593Smuzhiyun    GIT-HEAD-PHONY = ../../.git/HEAD
1064*4882a593Smuzhiyunelse
1065*4882a593Smuzhiyun    GIT-HEAD-PHONY =
1066*4882a593Smuzhiyunendif
1067*4882a593Smuzhiyun
1068*4882a593SmuzhiyunFORCE:
1069*4882a593Smuzhiyun
1070*4882a593Smuzhiyun.PHONY: all install clean config-clean strip install-gtk
1071*4882a593Smuzhiyun.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
1072*4882a593Smuzhiyun.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare
1073*4882a593Smuzhiyun.PHONY: libtraceevent_plugins archheaders
1074*4882a593Smuzhiyun
1075*4882a593Smuzhiyunendif # force_fixdep
1076