xref: /linux/tools/perf/Makefile.perf (revision 8a54784e708b51c1dcead1471bbee5fb31ae92cc)
1# SPDX-License-Identifier: GPL-2.0-only
2include ../scripts/Makefile.include
3include ../scripts/Makefile.arch
4
5# The default target of this Makefile is...
6all:
7
8include ../scripts/utilities.mak
9
10# Define V to have a more verbose compile.
11#
12# Define VF to have a more verbose feature check output.
13#
14# Define O to save output files in a separate directory.
15#
16# Define ARCH as name of target architecture if you want cross-builds.
17#
18# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
19#
20# Define NO_LIBPERL to disable perl script extension.
21#
22# Define NO_LIBPYTHON to disable python script extension.
23#
24# Define PYTHON to point to the python binary if the default
25# `python' is not correct; for example: PYTHON=python2
26#
27# Define PYTHON_CONFIG to point to the python-config binary if
28# the default `$(PYTHON)-config' is not correct.
29#
30# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
31#
32# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
33#
34# Define LDFLAGS=-static to build a static binary.
35#
36# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
37#
38# Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
39# EXTLIBS.
40#
41# Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.
42#
43# Define NO_LIBDW if you do not want debug-info analysis feature at all.
44#
45# Define WERROR=0 to disable treating any warnings as errors.
46#
47# Define NO_SLANG if you do not want TUI support.
48#
49# Define GTK2 if you want GTK+ GUI support.
50#
51# Define NO_DEMANGLE if you do not want C++ symbol demangling.
52#
53# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
54#
55# Define LIBUNWIND if you do not want libunwind dependency for dwarf
56# backtrace post unwind.
57#
58# Define NO_BACKTRACE if you do not want stack backtrace debug feature
59#
60# Define NO_LIBNUMA if you do not want numa perf benchmark
61#
62# Define NO_LIBBIONIC if you do not want bionic support
63#
64# Define NO_LIBCRYPTO if you do not want libcrypto (openssl) support
65# used for generating build-ids for ELFs generated by jitdump.
66#
67# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
68# for dwarf backtrace post unwind.
69#
70# Define NO_LIBTRACEEVENT=1 if you don't want libtraceevent to be linked,
71# this will remove multiple features and tools, such as 'perf trace',
72# that need it to read tracefs event format files, etc.
73#
74# Define NO_PERF_READ_VDSO32 if you do not want to build perf-read-vdso32
75# for reading the 32-bit compatibility VDSO in 64-bit mode
76#
77# Define NO_PERF_READ_VDSOX32 if you do not want to build perf-read-vdsox32
78# for reading the x32 mode 32-bit compatibility VDSO in 64-bit mode
79#
80# Define NO_ZLIB if you do not want to support compressed kernel modules
81#
82# Define NO_LIBBABELTRACE if you do not want libbabeltrace support
83# for CTF data format.
84#
85# Define NO_CAPSTONE if you do not want libcapstone support
86# for disasm engine.
87#
88# Define NO_LZMA if you do not want to support compressed (xz) kernel modules
89#
90# Define NO_AUXTRACE if you do not want AUX area tracing support
91#
92# Define NO_LIBBPF if you do not want BPF support
93#
94# Define NO_LIBCAP if you do not want process capabilities considered by perf
95#
96# Define NO_SDT if you do not want to define SDT event in perf tools,
97# note that it doesn't disable SDT scanning support.
98#
99# Define FEATURES_DUMP to provide features detection dump file
100# and bypass the feature detection
101#
102# Define NO_JVMTI if you do not want jvmti agent built
103#
104# Define NO_JVMTI_CMLR (debug only) if you do not want to process CMLR
105# data for java source lines.
106#
107# Define CORESIGHT if you DO WANT support for CoreSight trace decoding.
108#
109# Define NO_AIO if you do not want support of Posix AIO based trace
110# streaming for record mode. Currently Posix AIO trace streaming is
111# supported only when linking with glibc.
112#
113# Define NO_LIBZSTD if you do not want support of Zstandard based runtime
114# trace compression in record mode.
115#
116# Define TCMALLOC to enable tcmalloc heap profiling.
117#
118# Define LIBBPF_DYNAMIC to enable libbpf dynamic linking.
119#
120# Define NO_LIBPFM4 to disable libpfm4 events extension.
121#
122# Define NO_LIBDEBUGINFOD if you do not want support debuginfod
123#
124# Set BUILD_BPF_SKEL to 0 to override BUILD_BPF_SKEL and not build BPF skeletons
125#
126# Define BUILD_NONDISTRO to enable building an linking against libbfd and
127# libiberty distribution license incompatible libraries.
128#
129# Define EXTRA_TESTS to enable building extra tests useful mainly to perf
130# developers, such as:
131#	x86 instruction decoder - new instructions test
132#
133# Define GEN_VMLINUX_H to generate vmlinux.h from the BTF.
134#
135# Define NO_SHELLCHECK if you do not want to run shellcheck during build
136
137# As per kernel Makefile, avoid funny character set dependencies
138unexport LC_ALL
139LC_COLLATE=C
140LC_NUMERIC=C
141export LC_COLLATE LC_NUMERIC
142
143ifeq ($(srctree),)
144srctree := $(patsubst %/,%,$(dir $(CURDIR)))
145srctree := $(patsubst %/,%,$(dir $(srctree)))
146#$(info Determined 'srctree' to be $(srctree))
147endif
148
149ifneq ($(objtree),)
150#$(info Determined 'objtree' to be $(objtree))
151endif
152
153ifneq ($(OUTPUT),)
154#$(info Determined 'OUTPUT' to be $(OUTPUT))
155# Adding $(OUTPUT) as a directory to look for source files,
156# because use generated output files as sources dependency
157# for flex/bison parsers.
158VPATH += $(OUTPUT)
159export VPATH
160# create symlink to the original source
161SOURCE := $(shell ln -sfn $(srctree)/tools/perf $(OUTPUT)/source)
162endif
163
164# Beautify output
165# ---------------------------------------------------------------------------
166#
167# Most of build commands in Kbuild start with "cmd_". You can optionally define
168# "quiet_cmd_*". If defined, the short log is printed. Otherwise, no log from
169# that command is printed by default.
170#
171# e.g.)
172#    quiet_cmd_depmod = DEPMOD  $(MODLIB)
173#          cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE)
174#
175# A simple variant is to prefix commands with $(Q) - that's useful
176# for commands that shall be hidden in non-verbose mode.
177#
178#    $(Q)$(MAKE) $(build)=scripts/basic
179#
180# To put more focus on warnings, be less verbose as default
181# Use 'make V=1' to see the full commands
182
183ifeq ($(V),1)
184  quiet =
185  Q =
186else
187  quiet=quiet_
188  Q=@
189endif
190
191# If the user is running make -s (silent mode), suppress echoing of commands
192# make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
193ifeq ($(filter 3.%,$(MAKE_VERSION)),)
194short-opts := $(firstword -$(MAKEFLAGS))
195else
196short-opts := $(filter-out --%,$(MAKEFLAGS))
197endif
198
199ifneq ($(findstring s,$(short-opts)),)
200  quiet=silent_
201endif
202
203export quiet Q
204
205# Do not use make's built-in rules
206# (this improves performance and avoids hard-to-debug behaviour);
207MAKEFLAGS += -r
208
209# Makefiles suck: This macro sets a default value of $(2) for the
210# variable named by $(1), unless the variable has been set by
211# environment or command line. This is necessary for CC and AR
212# because make sets default values, so the simpler ?= approach
213# won't work as expected.
214define allow-override
215  $(if $(or $(findstring environment,$(origin $(1))),\
216            $(findstring command line,$(origin $(1)))),,\
217    $(eval $(1) = $(2)))
218endef
219
220LD += $(EXTRA_LDFLAGS)
221
222HOSTCC  ?= gcc
223HOSTLD  ?= ld
224HOSTAR  ?= ar
225CLANG   ?= clang
226
227# Some distros provide the command $(CROSS_COMPILE)pkg-config for
228# searching packges installed with Multiarch. Use it for cross
229# compilation if it is existed.
230ifneq (, $(shell which $(CROSS_COMPILE)pkg-config))
231  PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
232else
233  PKG_CONFIG ?= pkg-config
234
235  # PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR
236  # for modified system root, is required for the cross compilation.
237  # If these PKG_CONFIG environment variables are not set, Multiarch library
238  # paths are used instead.
239  ifdef CROSS_COMPILE
240    ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),)
241      CROSS_ARCH = $(shell $(CC) -dumpmachine)
242      PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
243      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
244      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
245      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/
246      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/
247      export PKG_CONFIG_LIBDIR
248      $(warning Missing PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH and PKG_CONFIG_SYSROOT_DIR for cross compilation,)
249      $(warning set PKG_CONFIG_LIBDIR for using Multiarch libs.)
250    endif
251  endif
252endif
253
254RM      = rm -f
255LN      = ln -f
256MKDIR   = mkdir
257FIND    = find
258INSTALL = install
259FLEX    ?= flex
260BISON   ?= bison
261STRIP   = strip
262AWK     = awk
263READELF ?= readelf
264
265# include Makefile.config by default and rule out
266# non-config cases
267config := 1
268
269NON_CONFIG_TARGETS := clean python-clean TAGS tags cscope help
270
271ifdef MAKECMDGOALS
272ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
273  VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h
274  config := 0
275endif
276endif
277
278# The fixdep build - we force fixdep tool to be built as
279# the first target in the separate make session not to be
280# disturbed by any parallel make jobs. Once fixdep is done
281# we issue the requested build with FIXDEP=1 variable.
282#
283# The fixdep build is disabled for $(NON_CONFIG_TARGETS)
284# targets, because it's not necessary.
285
286ifdef FIXDEP
287  force_fixdep := 0
288else
289  force_fixdep := $(config)
290endif
291
292# Runs shellcheck on perf shell scripts
293ifeq ($(NO_SHELLCHECK),1)
294  SHELLCHECK :=
295else
296  SHELLCHECK := $(shell which shellcheck 2> /dev/null)
297endif
298
299# shellcheck is using in tools/perf/tests/Build with option -a/--check-sourced (
300# introduced in v0.4.7) and -S/--severity (introduced in v0.6.0). So make the
301# minimal shellcheck version as v0.6.0.
302ifneq ($(SHELLCHECK),)
303  ifeq ($(shell expr $(shell $(SHELLCHECK) --version | grep version: | \
304        sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \< 060), 1)
305    SHELLCHECK :=
306  endif
307endif
308
309# Runs mypy on perf python files
310ifeq ($(MYPY),1)
311  MYPY := $(shell which mypy 2> /dev/null)
312endif
313
314# Runs pylint on perf python files
315ifeq ($(PYLINT),1)
316  PYLINT := $(shell which pylint 2> /dev/null)
317endif
318
319export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK
320export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT
321
322include $(srctree)/tools/build/Makefile.include
323
324ifeq ($(force_fixdep),1)
325goals := $(filter-out all sub-make, $(MAKECMDGOALS))
326
327$(goals) all: sub-make
328
329sub-make: fixdep
330	@./check-headers.sh
331	$(Q)$(MAKE) FIXDEP=1 -f Makefile.perf $(goals)
332
333else # force_fixdep
334
335LIBAPI_DIR      = $(srctree)/tools/lib/api/
336LIBBPF_DIR      = $(srctree)/tools/lib/bpf/
337LIBSUBCMD_DIR   = $(srctree)/tools/lib/subcmd/
338LIBSYMBOL_DIR   = $(srctree)/tools/lib/symbol/
339LIBPERF_DIR     = $(srctree)/tools/lib/perf/
340DOC_DIR         = $(srctree)/tools/perf/Documentation/
341
342# Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
343# Without this setting the output feature dump file misses some features, for
344# example, liberty. Select all checkers so we won't get an incomplete feature
345# dump file.
346ifeq ($(config),1)
347ifdef MAKECMDGOALS
348ifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump)
349FEATURE_TESTS := all
350endif
351endif
352include Makefile.config
353endif
354
355ifeq ($(config),0)
356include $(srctree)/tools/scripts/Makefile.arch
357-include arch/$(SRCARCH)/Makefile
358endif
359
360# The FEATURE_DUMP_EXPORT holds location of the actual
361# FEATURE_DUMP file to be used to bypass feature detection
362# (for bpf or any other subproject)
363ifeq ($(FEATURES_DUMP),)
364FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
365else
366FEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP))
367endif
368
369export prefix bindir sharedir sysconfdir DESTDIR
370
371# sparse is architecture-neutral, which means that we need to tell it
372# explicitly what architecture to check for. Fix this up for yours..
373SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
374
375# Guard against environment variables
376PYRF_OBJS =
377SCRIPT_SH =
378
379SCRIPT_SH += perf-archive.sh
380SCRIPT_SH += perf-iostat.sh
381
382grep-libs = $(filter -l%,$(1))
383strip-libs = $(filter-out -l%,$(1))
384
385ifneq ($(OUTPUT),)
386  LIBAPI_OUTPUT = $(abspath $(OUTPUT))/libapi
387else
388  LIBAPI_OUTPUT = $(CURDIR)/libapi
389endif
390LIBAPI_DESTDIR = $(LIBAPI_OUTPUT)
391LIBAPI_INCLUDE = $(LIBAPI_DESTDIR)/include
392LIBAPI = $(LIBAPI_OUTPUT)/libapi.a
393export LIBAPI
394CFLAGS += -I$(LIBAPI_OUTPUT)/include
395
396ifneq ($(OUTPUT),)
397  LIBBPF_OUTPUT = $(abspath $(OUTPUT))/libbpf
398else
399  LIBBPF_OUTPUT = $(CURDIR)/libbpf
400endif
401ifdef LIBBPF_STATIC
402  LIBBPF_DESTDIR = $(LIBBPF_OUTPUT)
403  LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include
404  LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a
405  CFLAGS += -I$(LIBBPF_OUTPUT)/include
406endif
407
408ifneq ($(OUTPUT),)
409  LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd
410else
411  LIBSUBCMD_OUTPUT = $(CURDIR)/libsubcmd
412endif
413LIBSUBCMD_DESTDIR = $(LIBSUBCMD_OUTPUT)
414LIBSUBCMD_INCLUDE = $(LIBSUBCMD_DESTDIR)/include
415LIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.a
416CFLAGS += -I$(LIBSUBCMD_OUTPUT)/include
417
418ifneq ($(OUTPUT),)
419  LIBSYMBOL_OUTPUT = $(abspath $(OUTPUT))/libsymbol
420else
421  LIBSYMBOL_OUTPUT = $(CURDIR)/libsymbol
422endif
423LIBSYMBOL_DESTDIR = $(LIBSYMBOL_OUTPUT)
424LIBSYMBOL_INCLUDE = $(LIBSYMBOL_DESTDIR)/include
425LIBSYMBOL = $(LIBSYMBOL_OUTPUT)/libsymbol.a
426CFLAGS += -I$(LIBSYMBOL_OUTPUT)/include
427
428ifneq ($(OUTPUT),)
429  LIBPERF_OUTPUT = $(abspath $(OUTPUT))/libperf
430else
431  LIBPERF_OUTPUT = $(CURDIR)/libperf
432endif
433LIBPERF_DESTDIR = $(LIBPERF_OUTPUT)
434LIBPERF_INCLUDE = $(LIBPERF_DESTDIR)/include
435LIBPERF = $(LIBPERF_OUTPUT)/libperf.a
436export LIBPERF
437CFLAGS += -I$(LIBPERF_OUTPUT)/include
438
439# python extension build directories
440PYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
441PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
442PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
443export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
444
445python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
446
447# Use the detected configuration
448-include $(OUTPUT).config-detected
449
450SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
451
452PROGRAMS += $(OUTPUT)perf
453
454ifndef NO_PERF_READ_VDSO32
455PROGRAMS += $(OUTPUT)perf-read-vdso32
456endif
457
458ifndef NO_PERF_READ_VDSOX32
459PROGRAMS += $(OUTPUT)perf-read-vdsox32
460endif
461
462LIBJVMTI = libperf-jvmti.so
463
464ifndef NO_JVMTI
465PROGRAMS += $(OUTPUT)$(LIBJVMTI)
466endif
467
468DLFILTERS := dlfilter-test-api-v0.so dlfilter-test-api-v2.so dlfilter-show-cycles.so
469DLFILTERS := $(patsubst %,$(OUTPUT)dlfilters/%,$(DLFILTERS))
470
471# what 'all' will build and 'install' will install, in perfexecdir
472ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) $(DLFILTERS)
473
474# what 'all' will build but not install in perfexecdir
475OTHER_PROGRAMS = $(OUTPUT)perf
476
477# Set paths to tools early so that they can be used for version tests.
478ifndef SHELL_PATH
479  SHELL_PATH = /bin/sh
480endif
481ifndef PERL_PATH
482  PERL_PATH = /usr/bin/perl
483endif
484
485export PERL_PATH
486
487LIBPERF_BENCH_IN := $(OUTPUT)perf-bench-in.o
488LIBPERF_BENCH := $(OUTPUT)libperf-bench.a
489
490LIBPERF_TEST_IN := $(OUTPUT)perf-test-in.o
491LIBPERF_TEST := $(OUTPUT)libperf-test.a
492
493LIBPERF_UI_IN := $(OUTPUT)perf-ui-in.o
494LIBPERF_UI := $(OUTPUT)libperf-ui.a
495
496LIBPERF_UTIL_IN := $(OUTPUT)perf-util-in.o
497LIBPERF_UTIL := $(OUTPUT)libperf-util.a
498
499LIBPMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
500LIBPMU_EVENTS := $(OUTPUT)libpmu-events.a
501
502PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL)
503ifdef LIBBPF_STATIC
504  PERFLIBS += $(LIBBPF)
505endif
506PERFLIBS += $(LIBPERF_BENCH) $(LIBPERF_TEST) $(LIBPERF_UI) $(LIBPERF_UTIL)
507PERFLIBS += $(LIBPMU_EVENTS)
508
509# We choose to avoid "if .. else if .. else .. endif endif"
510# because maintaining the nesting to match is a pain.  If
511# we had "elif" things would have been much nicer...
512
513ifneq ($(OUTPUT),)
514  CFLAGS += -I$(OUTPUT)
515endif
516
517ifdef GTK2
518  ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
519  GTK_IN := $(OUTPUT)gtk-in.o
520endif
521
522ifdef ASCIIDOC8
523  export ASCIIDOC8
524endif
525
526EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
527LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
528
529PERFLIBS_PY := $(call filter-out,$(LIBPERF_BENCH) $(LIBPERF_TEST),$(PERFLIBS))
530LIBS_PY = -Wl,--whole-archive $(PERFLIBS_PY) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
531
532export INSTALL SHELL_PATH
533
534### Build rules
535
536SHELL = $(SHELL_PATH)
537
538arm64_gen_sysreg_dir := $(srctree)/tools/arch/arm64/tools
539ifneq ($(OUTPUT),)
540  arm64_gen_sysreg_outdir := $(abspath $(OUTPUT))
541else
542  arm64_gen_sysreg_outdir := $(CURDIR)
543endif
544
545arm64-sysreg-defs: FORCE
546	$(Q)$(MAKE) -C $(arm64_gen_sysreg_dir) O=$(arm64_gen_sysreg_outdir) \
547		prefix= subdir=
548
549arm64-sysreg-defs-clean:
550	$(call QUIET_CLEAN,arm64-sysreg-defs)
551	$(Q)$(MAKE) -C $(arm64_gen_sysreg_dir) O=$(arm64_gen_sysreg_outdir) \
552		prefix= subdir= clean > /dev/null
553
554beauty_linux_dir := $(srctree)/tools/perf/trace/beauty/include/linux/
555beauty_uapi_linux_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/linux/
556beauty_uapi_sound_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/sound/
557beauty_arch_asm_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/asm/
558beauty_x86_arch_asm_uapi_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/uapi/asm/
559
560linux_uapi_dir := $(srctree)/tools/include/uapi/linux
561asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic
562arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/
563x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/
564
565beauty_outdir := $(OUTPUT)trace/beauty/generated
566beauty_ioctl_outdir := $(beauty_outdir)/ioctl
567
568# Create output directory if not already present
569$(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)')
570
571syscall_array := $(beauty_outdir)/syscalltbl.c
572syscall_tbl := $(srctree)/tools/perf/trace/beauty/syscalltbl.sh
573syscall_tbl_data := $(srctree)/tools/scripts/syscall.tbl \
574	$(wildcard $(srctree)/tools/perf/arch/*/entry/syscalls/syscall*.tbl)
575
576$(syscall_array): $(syscall_tbl) $(syscall_tbl_data)
577	$(Q)$(SHELL) '$(syscall_tbl)' $(srctree)/tools $@
578
579fs_at_flags_array := $(beauty_outdir)/fs_at_flags_array.c
580fs_at_flags_tbl := $(srctree)/tools/perf/trace/beauty/fs_at_flags.sh
581
582$(fs_at_flags_array): $(beauty_uapi_linux_dir)/fcntl.h $(fs_at_flags_tbl)
583	$(Q)$(SHELL) '$(fs_at_flags_tbl)' $(beauty_uapi_linux_dir) > $@
584
585clone_flags_array := $(beauty_outdir)/clone_flags_array.c
586clone_flags_tbl := $(srctree)/tools/perf/trace/beauty/clone.sh
587
588$(clone_flags_array): $(beauty_uapi_linux_dir)/sched.h $(clone_flags_tbl)
589	$(Q)$(SHELL) '$(clone_flags_tbl)' $(beauty_uapi_linux_dir) > $@
590
591drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c
592drm_hdr_dir := $(srctree)/tools/include/uapi/drm
593drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh
594
595$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl)
596	$(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@
597
598fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c
599fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh
600
601$(fadvise_advice_array): $(linux_uapi_dir)/in.h $(fadvise_advice_tbl)
602	$(Q)$(SHELL) '$(fadvise_advice_tbl)' $(linux_uapi_dir) > $@
603
604fsmount_arrays := $(beauty_outdir)/fsmount_arrays.c
605fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh
606
607$(fsmount_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_tbls)
608	$(Q)$(SHELL) '$(fsmount_tbls)' $(beauty_uapi_linux_dir) > $@
609
610fspick_arrays := $(beauty_outdir)/fspick_arrays.c
611fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh
612
613$(fspick_arrays): $(beauty_uapi_linux_dir)/mount.h $(fspick_tbls)
614	$(Q)$(SHELL) '$(fspick_tbls)' $(beauty_uapi_linux_dir) > $@
615
616fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c
617fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh
618
619$(fsconfig_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsconfig_tbls)
620	$(Q)$(SHELL) '$(fsconfig_tbls)' $(beauty_uapi_linux_dir) > $@
621
622pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c
623asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
624pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
625
626$(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl)
627	$(Q)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@
628
629sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c
630sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound
631sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh
632
633$(sndrv_ctl_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_ctl_ioctl_tbl)
634	$(Q)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@
635
636sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c
637sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound
638sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh
639
640$(sndrv_pcm_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_pcm_ioctl_tbl)
641	$(Q)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@
642
643kcmp_type_array := $(beauty_outdir)/kcmp_type_array.c
644kcmp_hdr_dir := $(srctree)/tools/include/uapi/linux/
645kcmp_type_tbl := $(srctree)/tools/perf/trace/beauty/kcmp_type.sh
646
647$(kcmp_type_array): $(kcmp_hdr_dir)/kcmp.h $(kcmp_type_tbl)
648	$(Q)$(SHELL) '$(kcmp_type_tbl)' $(kcmp_hdr_dir) > $@
649
650kvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c
651kvm_hdr_dir := $(srctree)/tools/include/uapi/linux
652kvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh
653
654$(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl)
655	$(Q)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@
656
657socket_arrays := $(beauty_outdir)/socket.c
658socket_tbl := $(srctree)/tools/perf/trace/beauty/socket.sh
659
660$(socket_arrays): $(linux_uapi_dir)/in.h $(beauty_linux_dir)/socket.h $(socket_tbl)
661	$(Q)$(SHELL) '$(socket_tbl)' $(linux_uapi_dir) $(beauty_linux_dir) > $@
662
663sockaddr_arrays := $(beauty_outdir)/sockaddr.c
664sockaddr_tbl := $(srctree)/tools/perf/trace/beauty/sockaddr.sh
665
666$(sockaddr_arrays): $(beauty_linux_dir)/socket.h $(sockaddr_tbl)
667	$(Q)$(SHELL) '$(sockaddr_tbl)' $(beauty_linux_dir) > $@
668
669vhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c
670vhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh
671
672$(vhost_virtio_ioctl_array): $(beauty_uapi_linux_dir)/vhost.h $(vhost_virtio_ioctl_tbl)
673	$(Q)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@
674
675perf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c
676perf_hdr_dir := $(srctree)/tools/include/uapi/linux
677perf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh
678
679$(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl)
680	$(Q)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@
681
682madvise_behavior_array := $(beauty_outdir)/madvise_behavior_array.c
683madvise_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
684madvise_behavior_tbl := $(srctree)/tools/perf/trace/beauty/madvise_behavior.sh
685
686$(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_tbl)
687	$(Q)$(SHELL) '$(madvise_behavior_tbl)' $(madvise_hdr_dir) > $@
688
689mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c
690mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh
691
692$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl)
693	$(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@
694
695mremap_flags_array := $(beauty_outdir)/mremap_flags_array.c
696mremap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mremap_flags.sh
697
698$(mremap_flags_array): $(linux_uapi_dir)/mman.h $(mremap_flags_tbl)
699	$(Q)$(SHELL) '$(mremap_flags_tbl)' $(linux_uapi_dir) > $@
700
701mount_flags_array := $(beauty_outdir)/mount_flags_array.c
702mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh
703
704$(mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(mount_flags_tbl)
705	$(Q)$(SHELL) '$(mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@
706
707move_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c
708move_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh
709
710$(move_mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(move_mount_flags_tbl)
711	$(Q)$(SHELL) '$(move_mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@
712
713mmap_prot_array := $(beauty_outdir)/mmap_prot_array.c
714mmap_prot_tbl := $(srctree)/tools/perf/trace/beauty/mmap_prot.sh
715
716$(mmap_prot_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_prot_tbl)
717	$(Q)$(SHELL) '$(mmap_prot_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@
718
719prctl_option_array := $(beauty_outdir)/prctl_option_array.c
720prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh
721
722$(prctl_option_array): $(beauty_uapi_linux_dir)/prctl.h $(prctl_option_tbl)
723	$(Q)$(SHELL) '$(prctl_option_tbl)' $(beauty_uapi_linux_dir) > $@
724
725usbdevfs_ioctl_array := $(beauty_ioctl_outdir)/usbdevfs_ioctl_array.c
726usbdevfs_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/usbdevfs_ioctl.sh
727
728$(usbdevfs_ioctl_array): $(beauty_uapi_linux_dir)/usbdevice_fs.h $(usbdevfs_ioctl_tbl)
729	$(Q)$(SHELL) '$(usbdevfs_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@
730
731x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c
732x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh
733
734$(x86_arch_prctl_code_array): $(beauty_x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl)
735	$(Q)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(beauty_x86_arch_asm_uapi_dir) > $@
736
737x86_arch_irq_vectors_array := $(beauty_outdir)/x86_arch_irq_vectors_array.c
738x86_arch_irq_vectors_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh
739
740$(x86_arch_irq_vectors_array): $(beauty_arch_asm_dir)/irq_vectors.h $(x86_arch_irq_vectors_tbl)
741	$(Q)$(SHELL) '$(x86_arch_irq_vectors_tbl)' $(beauty_arch_asm_dir) > $@
742
743x86_arch_MSRs_array := $(beauty_outdir)/x86_arch_MSRs_array.c
744x86_arch_MSRs_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_msr.sh
745
746$(x86_arch_MSRs_array): $(x86_arch_asm_dir)/msr-index.h $(x86_arch_MSRs_tbl)
747	$(Q)$(SHELL) '$(x86_arch_MSRs_tbl)' $(x86_arch_asm_dir) > $@
748
749rename_flags_array := $(beauty_outdir)/rename_flags_array.c
750rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh
751
752$(rename_flags_array): $(beauty_uapi_linux_dir)/fs.h $(rename_flags_tbl)
753	$(Q)$(SHELL) '$(rename_flags_tbl)' $(beauty_uapi_linux_dir) > $@
754
755arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c
756arch_errno_hdr_dir := $(srctree)/tools
757arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
758
759$(arch_errno_name_array): $(arch_errno_tbl)
760	$(Q)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@
761
762statx_mask_array := $(beauty_outdir)/statx_mask_array.c
763statx_mask_tbl := $(srctree)/tools/perf/trace/beauty/statx_mask.sh
764
765$(statx_mask_array): $(beauty_uapi_linux_dir)/stat.h $(statx_mask_tbl)
766	$(Q)$(SHELL) '$(statx_mask_tbl)' $(beauty_uapi_linux_dir) > $@
767
768sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c
769sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh
770
771$(sync_file_range_arrays): $(beauty_uapi_linux_dir)/fs.h $(sync_file_range_tbls)
772	$(Q)$(SHELL) '$(sync_file_range_tbls)' $(beauty_uapi_linux_dir) > $@
773
774TESTS_CORESIGHT_DIR := $(srctree)/tools/perf/tests/shell/coresight
775
776tests-coresight-targets: FORCE
777	$(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR)
778
779tests-coresight-targets-clean:
780	$(call QUIET_CLEAN, coresight)
781	$(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) O=$(OUTPUT) clean >/dev/null
782
783all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-coresight-targets
784
785# Create python binding output directory if not already present
786$(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
787
788$(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): util/python.c util/setup.py $(PERFLIBS_PY)
789	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
790        CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBS_PY)' \
791	  $(PYTHON_WORD) util/setup.py \
792	  --quiet build_ext; \
793	cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
794
795python_perf_target:
796	@echo "Target is: $(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX)"
797
798please_set_SHELL_PATH_to_a_more_modern_shell:
799	$(Q)$$(:)
800
801shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
802
803strip: $(PROGRAMS) $(OUTPUT)perf
804	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
805
806PERF_IN := $(OUTPUT)perf-in.o
807export NO_JEVENTS
808
809build := -f $(srctree)/tools/build/Makefile.build dir=. obj
810
811$(PERF_IN): prepare FORCE
812	$(Q)$(MAKE) $(build)=perf
813
814$(LIBPMU_EVENTS_IN): FORCE prepare
815	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
816
817$(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN)
818	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
819
820$(LIBPERF_BENCH_IN): FORCE prepare
821	$(Q)$(MAKE) $(build)=perf-bench
822
823$(LIBPERF_BENCH): $(LIBPERF_BENCH_IN)
824	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
825
826$(LIBPERF_TEST_IN): FORCE prepare
827	$(Q)$(MAKE) $(build)=perf-test
828
829$(LIBPERF_TEST): $(LIBPERF_TEST_IN)
830	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
831
832$(LIBPERF_UI_IN): FORCE prepare
833	$(Q)$(MAKE) $(build)=perf-ui
834
835$(LIBPERF_UI): $(LIBPERF_UI_IN)
836	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
837
838$(LIBPERF_UTIL_IN): FORCE prepare
839	$(Q)$(MAKE) $(build)=perf-util
840
841$(LIBPERF_UTIL): $(LIBPERF_UTIL_IN)
842	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
843
844$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN)
845	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
846		$(PERF_IN) $(LIBS) -o $@
847
848$(GTK_IN): FORCE prepare
849	$(Q)$(MAKE) $(build)=gtk
850
851$(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
852	$(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
853
854$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
855
856$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
857	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
858
859$(SCRIPTS) : % : %.sh
860	$(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
861
862$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
863	$(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
864
865# These can record PERF_VERSION
866perf.spec $(SCRIPTS) \
867	: $(OUTPUT)PERF-VERSION-FILE
868
869.SUFFIXES:
870
871#
872# If a target does not match any of the later rules then prefix it by $(OUTPUT)
873# This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
874#
875ifneq ($(OUTPUT),)
876%.o: $(OUTPUT)%.o
877	@echo "    # Redirected target $@ => $(OUTPUT)$@"
878pmu-events/%.o: $(OUTPUT)pmu-events/%.o
879	@echo "    # Redirected target $@ => $(OUTPUT)$@"
880util/%.o: $(OUTPUT)util/%.o
881	@echo "    # Redirected target $@ => $(OUTPUT)$@"
882bench/%.o: $(OUTPUT)bench/%.o
883	@echo "    # Redirected target $@ => $(OUTPUT)$@"
884tests/%.o: $(OUTPUT)tests/%.o
885	@echo "    # Redirected target $@ => $(OUTPUT)$@"
886endif
887
888# These two need to be here so that when O= is not used they take precedence
889# over the general rule for .o
890
891# get relative building directory (to $(OUTPUT))
892# and '.' if it's $(OUTPUT) itself
893__build-dir = $(subst $(OUTPUT),,$(dir $@))
894build-dir   = $(or $(__build-dir),.)
895
896prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders \
897	arm64-sysreg-defs \
898	$(syscall_array) \
899	$(fs_at_flags_array) \
900	$(clone_flags_array) \
901	$(drm_ioctl_array) \
902	$(fadvise_advice_array) \
903	$(fsconfig_arrays) \
904	$(fsmount_arrays) \
905	$(fspick_arrays) \
906	$(pkey_alloc_access_rights_array) \
907	$(sndrv_pcm_ioctl_array) \
908	$(sndrv_ctl_ioctl_array) \
909	$(kcmp_type_array) \
910	$(kvm_ioctl_array) \
911	$(socket_arrays) \
912	$(sockaddr_arrays) \
913	$(vhost_virtio_ioctl_array) \
914	$(madvise_behavior_array) \
915	$(mmap_flags_array) \
916	$(mmap_prot_array) \
917	$(mremap_flags_array) \
918	$(mount_flags_array) \
919	$(move_mount_flags_array) \
920	$(perf_ioctl_array) \
921	$(prctl_option_array) \
922	$(usbdevfs_ioctl_array) \
923	$(x86_arch_irq_vectors_array) \
924	$(x86_arch_MSRs_array) \
925	$(x86_arch_prctl_code_array) \
926	$(rename_flags_array) \
927	$(arch_errno_name_array) \
928	$(statx_mask_array) \
929	$(sync_file_range_arrays) \
930	$(LIBAPI) \
931	$(LIBPERF) \
932	$(LIBSUBCMD) \
933	$(LIBSYMBOL) \
934	bpf-skel
935
936ifdef LIBBPF_STATIC
937prepare: $(LIBBPF)
938endif
939
940$(OUTPUT)%.o: %.c prepare FORCE
941	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
942
943$(OUTPUT)%.i: %.c prepare FORCE
944	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
945
946$(OUTPUT)%.s: %.c prepare FORCE
947	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
948
949$(OUTPUT)%-bison.o: %.c prepare FORCE
950	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
951
952$(OUTPUT)%-flex.o: %.c prepare FORCE
953	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
954
955$(OUTPUT)%.o: %.S prepare FORCE
956	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
957
958$(OUTPUT)%.i: %.S prepare FORCE
959	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
960
961$(OUTPUT)perf-%: %.o $(PERFLIBS)
962	$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
963
964ifndef NO_PERF_READ_VDSO32
965$(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-map.c
966	$(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
967endif
968
969ifndef NO_PERF_READ_VDSOX32
970$(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-map.c
971	$(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
972endif
973
974$(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h
975	$(Q)$(MKDIR) -p $(OUTPUT)dlfilters
976	$(QUIET_CC)$(CC) -c -Iinclude $(EXTRA_CFLAGS) -o $@ -fpic $<
977
978.SECONDARY: $(DLFILTERS:.so=.o)
979
980$(OUTPUT)dlfilters/%.so: $(OUTPUT)dlfilters/%.o
981	$(QUIET_LINK)$(CC) $(EXTRA_CFLAGS) -shared -o $@ $<
982
983ifndef NO_JVMTI
984LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
985
986$(LIBJVMTI_IN): FORCE
987	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
988
989$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
990	$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
991endif
992
993$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
994
995$(LIBAPI): FORCE | $(LIBAPI_OUTPUT)
996	$(Q)$(MAKE) -C $(LIBAPI_DIR) O=$(LIBAPI_OUTPUT) \
997		DESTDIR=$(LIBAPI_DESTDIR) prefix= subdir= \
998		$@ install_headers
999
1000$(LIBAPI)-clean:
1001	$(call QUIET_CLEAN, libapi)
1002	$(Q)$(RM) -r -- $(LIBAPI_OUTPUT)
1003
1004$(LIBBPF): FORCE | $(LIBBPF_OUTPUT)
1005	$(Q)$(MAKE) -C $(LIBBPF_DIR) FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) \
1006		O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= subdir= \
1007		EXTRA_CFLAGS="-fPIC" $@ install_headers
1008
1009$(LIBBPF)-clean:
1010	$(call QUIET_CLEAN, libbpf)
1011	$(Q)$(RM) -r -- $(LIBBPF_OUTPUT)
1012
1013$(LIBPERF): FORCE | $(LIBPERF_OUTPUT)
1014	$(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(LIBPERF_OUTPUT) \
1015		DESTDIR=$(LIBPERF_DESTDIR) prefix= subdir= \
1016		$@ install_headers
1017
1018$(LIBPERF)-clean:
1019	$(call QUIET_CLEAN, libperf)
1020	$(Q)$(RM) -r -- $(LIBPERF_OUTPUT)
1021
1022$(LIBSUBCMD): FORCE | $(LIBSUBCMD_OUTPUT)
1023	$(Q)$(MAKE) -C $(LIBSUBCMD_DIR) O=$(LIBSUBCMD_OUTPUT) \
1024		DESTDIR=$(LIBSUBCMD_DESTDIR) prefix= subdir= \
1025		$@ install_headers
1026
1027$(LIBSUBCMD)-clean:
1028	$(call QUIET_CLEAN, libsubcmd)
1029	$(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT)
1030
1031$(LIBSYMBOL): FORCE | $(LIBSYMBOL_OUTPUT)
1032	$(Q)$(MAKE) -C $(LIBSYMBOL_DIR) O=$(LIBSYMBOL_OUTPUT) \
1033		DESTDIR=$(LIBSYMBOL_DESTDIR) prefix= subdir= \
1034		$@ install_headers
1035
1036$(LIBSYMBOL)-clean:
1037	$(call QUIET_CLEAN, libsymbol)
1038	$(Q)$(RM) -r -- $(LIBSYMBOL_OUTPUT)
1039
1040help:
1041	@echo 'Perf make targets:'
1042	@echo '  doc		- make *all* documentation (see below)'
1043	@echo '  man		- make manpage documentation (access with man <foo>)'
1044	@echo '  html		- make html documentation'
1045	@echo '  info		- make GNU info documentation (access with info <foo>)'
1046	@echo '  pdf		- make pdf documentation'
1047	@echo '  TAGS		- use etags to make tag information for source browsing'
1048	@echo '  tags		- use ctags to make tag information for source browsing'
1049	@echo '  cscope	- use cscope to make interactive browsing database'
1050	@echo ''
1051	@echo 'Perf install targets:'
1052	@echo '  NOTE: documentation build requires asciidoc, xmlto packages to be installed'
1053	@echo '  HINT: use "prefix" or "DESTDIR" to install to a particular'
1054	@echo '        path like "make prefix=/usr/local install install-doc"'
1055	@echo '  install	- install compiled binaries'
1056	@echo '  install-doc	- install *all* documentation'
1057	@echo '  install-man	- install manpage documentation'
1058	@echo '  install-html	- install html documentation'
1059	@echo '  install-info	- install GNU info documentation'
1060	@echo '  install-pdf	- install pdf documentation'
1061	@echo ''
1062	@echo '  quick-install-doc	- alias for quick-install-man'
1063	@echo '  quick-install-man	- install the documentation quickly'
1064	@echo '  quick-install-html	- install the html documentation quickly'
1065	@echo ''
1066	@echo 'Perf maintainer targets:'
1067	@echo '  clean			- clean all binary objects and build output'
1068
1069
1070DOC_TARGETS := doc man html info pdf
1071
1072INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
1073INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
1074
1075# 'make doc' should call 'make -C Documentation all'
1076$(DOC_TARGETS):
1077	$(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:doc=all) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
1078
1079TAG_FOLDERS= . ../lib ../include
1080TAG_FILES= ../../include/uapi/linux/perf_event.h
1081
1082TAGS:
1083	$(QUIET_GEN)$(RM) TAGS; \
1084	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs etags -a $(TAG_FILES)
1085
1086tags:
1087	$(QUIET_GEN)$(RM) tags; \
1088	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs ctags -a $(TAG_FILES)
1089
1090cscope:
1091	$(QUIET_GEN)$(RM) cscope*; \
1092	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs cscope -b $(TAG_FILES)
1093
1094### Testing rules
1095
1096# GNU make supports exporting all variables by "export" without parameters.
1097# However, the environment gets quite big, and some programs have problems
1098# with that.
1099
1100check: $(OUTPUT)common-cmds.h
1101	if sparse; \
1102	then \
1103		for i in *.c */*.c; \
1104		do \
1105			sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
1106		done; \
1107	else \
1108		exit 1; \
1109	fi
1110
1111### Installation rules
1112
1113ifdef GTK2
1114install-gtk: $(OUTPUT)libperf-gtk.so
1115	$(call QUIET_INSTALL, 'GTK UI') \
1116		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
1117		$(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
1118else
1119install-gtk:
1120endif
1121
1122install-tools: all install-gtk
1123	$(call QUIET_INSTALL, binaries) \
1124		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
1125		$(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
1126		$(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'; \
1127		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(includedir_SQ)/perf'; \
1128		$(INSTALL) -m 644 include/perf/perf_dlfilter.h -t '$(DESTDIR_SQ)$(includedir_SQ)/perf'
1129ifndef NO_PERF_READ_VDSO32
1130	$(call QUIET_INSTALL, perf-read-vdso32) \
1131		$(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
1132endif
1133ifndef NO_PERF_READ_VDSOX32
1134	$(call QUIET_INSTALL, perf-read-vdsox32) \
1135		$(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
1136endif
1137ifndef NO_JVMTI
1138	$(call QUIET_INSTALL, $(LIBJVMTI)) \
1139		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
1140		$(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
1141endif
1142	$(call QUIET_INSTALL, libexec) \
1143		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
1144	$(call QUIET_INSTALL, perf-archive) \
1145		$(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
1146	$(call QUIET_INSTALL, perf-iostat) \
1147		$(INSTALL) $(OUTPUT)perf-iostat -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
1148ifndef NO_LIBPERL
1149	$(call QUIET_INSTALL, perl-scripts) \
1150		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
1151		$(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
1152		$(INSTALL) scripts/perl/*.pl -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
1153		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
1154		$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
1155endif
1156ifndef NO_LIBPYTHON
1157	$(call QUIET_INSTALL, python-scripts) \
1158		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
1159		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
1160		$(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'; \
1161		$(INSTALL) scripts/python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
1162		$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
1163endif
1164	$(call QUIET_INSTALL, dlfilters) \
1165		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/dlfilters'; \
1166		$(INSTALL) $(DLFILTERS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/dlfilters';
1167	$(call QUIET_INSTALL, perf_completion-script) \
1168		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
1169		$(INSTALL) perf-completion.sh -m 644 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
1170	$(call QUIET_INSTALL, perf-tip) \
1171		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
1172		$(INSTALL) Documentation/tips.txt -m 644 -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
1173
1174install-tests: all install-gtk
1175	$(call QUIET_INSTALL, tests) \
1176		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
1177		$(INSTALL) tests/pe-file.exe* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
1178		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
1179		$(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
1180		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/attr'; \
1181		$(INSTALL) tests/shell/attr/* -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/attr'; \
1182		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
1183		$(INSTALL) tests/shell/lib/*.sh -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
1184		$(INSTALL) tests/shell/lib/*.py -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
1185		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \
1186		$(INSTALL) tests/shell/common/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \
1187		$(INSTALL) tests/shell/common/*.pl '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \
1188		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_probe'; \
1189		$(INSTALL) tests/shell/base_probe/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_probe'; \
1190		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_report'; \
1191		$(INSTALL) tests/shell/base_probe/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_report'; \
1192		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight' ; \
1193		$(INSTALL) tests/shell/coresight/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight'
1194	$(Q)$(MAKE) -C tests/shell/coresight install-tests
1195
1196install-bin: install-tools install-tests
1197
1198install: install-bin try-install-man
1199
1200install-python_ext:
1201	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
1202
1203# 'make install-doc' should call 'make -C Documentation install'
1204$(INSTALL_DOC_TARGETS):
1205	$(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:-doc=) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA) subdir=
1206
1207### Cleaning rules
1208
1209python-clean:
1210	$(python-clean)
1211
1212SKEL_OUT := $(abspath $(OUTPUT)util/bpf_skel)
1213SKEL_TMP_OUT := $(abspath $(SKEL_OUT)/.tmp)
1214SKELETONS := $(SKEL_OUT)/bpf_prog_profiler.skel.h
1215SKELETONS += $(SKEL_OUT)/bperf_leader.skel.h $(SKEL_OUT)/bperf_follower.skel.h
1216SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h $(SKEL_OUT)/func_latency.skel.h
1217SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h
1218SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h $(SKEL_OUT)/sample_filter.skel.h
1219SKELETONS += $(SKEL_OUT)/kwork_top.skel.h
1220SKELETONS += $(SKEL_OUT)/bench_uprobe.skel.h
1221SKELETONS += $(SKEL_OUT)/augmented_raw_syscalls.skel.h
1222
1223$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT):
1224	$(Q)$(MKDIR) -p $@
1225
1226ifeq ($(CONFIG_PERF_BPF_SKEL),y)
1227BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool
1228# Get Clang's default includes on this system, as opposed to those seen by
1229# '--target=bpf'. This fixes "missing" files on some architectures/distros,
1230# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
1231#
1232# Use '-idirafter': Don't interfere with include mechanics except where the
1233# build would have failed anyways.
1234define get_sys_includes
1235$(shell $(1) $(2) -v -E - </dev/null 2>&1 \
1236       | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
1237$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
1238endef
1239
1240ifneq ($(CROSS_COMPILE),)
1241CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))
1242endif
1243
1244CLANG_OPTIONS = -Wall
1245CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
1246BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES)
1247TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi
1248
1249ifneq ($(WERROR),0)
1250  CLANG_OPTIONS += -Werror
1251endif
1252
1253$(BPFTOOL): | $(SKEL_TMP_OUT)
1254	$(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \
1255		OUTPUT=$(SKEL_TMP_OUT)/ bootstrap
1256
1257# Paths to search for a kernel to generate vmlinux.h from.
1258VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux)			\
1259		     $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)	\
1260		     ../../vmlinux					\
1261		     /boot/vmlinux-$(shell uname -r)
1262
1263# Paths to BTF information.
1264VMLINUX_BTF_BTF_PATHS ?= /sys/kernel/btf/vmlinux
1265
1266# Filter out kernels that don't exist or without a BTF section.
1267VMLINUX_BTF_ELF_ABSPATHS ?= $(abspath $(wildcard $(VMLINUX_BTF_ELF_PATHS)))
1268VMLINUX_BTF_PATHS ?= $(shell for file in $(VMLINUX_BTF_ELF_ABSPATHS); \
1269			do \
1270				if [ -f $$file ] && ($(READELF) -S "$$file" | grep -q .BTF); \
1271				then \
1272					echo "$$file"; \
1273				fi; \
1274			done) \
1275			$(wildcard $(VMLINUX_BTF_BTF_PATHS))
1276
1277# Select the first as the source of vmlinux.h.
1278VMLINUX_BTF ?= $(firstword $(VMLINUX_BTF_PATHS))
1279
1280ifeq ($(VMLINUX_H),)
1281  ifeq ($(VMLINUX_BTF),)
1282    $(error Missing bpftool input for generating vmlinux.h)
1283  endif
1284endif
1285
1286$(SKEL_OUT)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) $(VMLINUX_H)
1287ifeq ($(VMLINUX_H),)
1288	$(QUIET_GEN)$(BPFTOOL) btf dump file $< format c > $@
1289else
1290	$(Q)cp "$(VMLINUX_H)" $@
1291endif
1292
1293$(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h | $(SKEL_TMP_OUT)
1294	$(QUIET_CLANG)$(CLANG) -g -O2 --target=bpf $(CLANG_OPTIONS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
1295	  -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@
1296
1297$(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
1298	$(QUIET_GENSKEL)$(BPFTOOL) gen skeleton $< > $@
1299
1300bpf-skel: $(SKELETONS)
1301
1302.PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o
1303
1304else # CONFIG_PERF_BPF_SKEL
1305
1306bpf-skel:
1307
1308endif # CONFIG_PERF_BPF_SKEL
1309
1310bpf-skel-clean:
1311	$(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) $(SKEL_OUT)/vmlinux.h
1312
1313clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean \
1314		arm64-sysreg-defs-clean fixdep-clean python-clean bpf-skel-clean \
1315		tests-coresight-targets-clean
1316	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive \
1317		$(OUTPUT)perf-iostat $(LANG_BINDINGS)
1318	$(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '*.a' -delete -o \
1319		-name '\.*.cmd' -delete -o -name '\.*.d' -delete -o -name '*.shellcheck_log' -delete
1320	$(Q)$(RM) $(OUTPUT).config-detected
1321	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 \
1322		perf-read-vdsox32 $(OUTPUT)$(LIBJVMTI).so
1323	$(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc */*.pyo \
1324		$(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \
1325		$(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
1326		$(OUTPUT)util/intel-pt-decoder/inat-tables.c \
1327		$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
1328		$(OUTPUT)pmu-events/pmu-events.c \
1329		$(OUTPUT)pmu-events/test-empty-pmu-events.c \
1330		$(OUTPUT)pmu-events/empty-pmu-events.log \
1331		$(OUTPUT)pmu-events/metric_test.log \
1332		$(OUTPUT)$(fadvise_advice_array) \
1333		$(OUTPUT)$(fsconfig_arrays) \
1334		$(OUTPUT)$(fsmount_arrays) \
1335		$(OUTPUT)$(fspick_arrays) \
1336		$(OUTPUT)$(madvise_behavior_array) \
1337		$(OUTPUT)$(mmap_flags_array) \
1338		$(OUTPUT)$(mmap_prot_array) \
1339		$(OUTPUT)$(mremap_flags_array) \
1340		$(OUTPUT)$(mount_flags_array) \
1341		$(OUTPUT)$(move_mount_flags_array) \
1342		$(OUTPUT)$(drm_ioctl_array) \
1343		$(OUTPUT)$(pkey_alloc_access_rights_array) \
1344		$(OUTPUT)$(sndrv_ctl_ioctl_array) \
1345		$(OUTPUT)$(sndrv_pcm_ioctl_array) \
1346		$(OUTPUT)$(kvm_ioctl_array) \
1347		$(OUTPUT)$(kcmp_type_array) \
1348		$(OUTPUT)$(socket_arrays) \
1349		$(OUTPUT)$(sockaddr_arrays) \
1350		$(OUTPUT)$(vhost_virtio_ioctl_array) \
1351		$(OUTPUT)$(perf_ioctl_array) \
1352		$(OUTPUT)$(prctl_option_array) \
1353		$(OUTPUT)$(usbdevfs_ioctl_array) \
1354		$(OUTPUT)$(x86_arch_irq_vectors_array) \
1355		$(OUTPUT)$(x86_arch_MSRs_array) \
1356		$(OUTPUT)$(x86_arch_prctl_code_array) \
1357		$(OUTPUT)$(rename_flags_array) \
1358		$(OUTPUT)$(arch_errno_name_array) \
1359		$(OUTPUT)$(sync_file_range_arrays)
1360	$(call QUIET_CLEAN, Documentation) \
1361	$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null
1362
1363#
1364# To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
1365# file if defined, with no further action.
1366feature-dump:
1367ifdef FEATURE_DUMP_COPY
1368	@cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY)
1369	@echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)"
1370else
1371	@echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP"
1372endif
1373
1374
1375FORCE:
1376
1377.PHONY: all install clean config-clean strip install-gtk
1378.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
1379.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare
1380.PHONY: archheaders python_perf_target
1381
1382endif # force_fixdep
1383
1384# Delete partially updated (corrupted) files on error
1385.DELETE_ON_ERROR:
1386