xref: /linux/tools/perf/Makefile.perf (revision ca0e19074bd6afcb9c7b23aa474ca17238cdb241)
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 LIBPERL to enable 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 EXTRA_BPF_FLAGS="--sysroot=<path>" or other custom include paths for
39# cross-compiling BPF skeletons
40#
41# Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
42# EXTLIBS.
43#
44# Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.
45#
46# Define NO_LIBDW if you do not want debug-info analysis feature at all.
47#
48# Define WERROR=0 to disable treating any warnings as errors.
49#
50# Define NO_SLANG if you do not want TUI support.
51#
52# Define GTK2 if you want GTK+ GUI support.
53#
54# Define NO_DEMANGLE if you do not want C++ symbol demangling.
55#
56# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
57#
58# Define LIBUNWIND if you do not want libunwind dependency for dwarf
59# backtrace post unwind.
60#
61# Define NO_BACKTRACE if you do not want stack backtrace debug feature
62#
63# Define NO_LIBNUMA if you do not want numa perf benchmark
64#
65# Define NO_LIBBIONIC if you do not want bionic support
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_BABELTRACE2 if you do not want babeltrace2-ctf-writer 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_LIBBPF if you do not want BPF support
91#
92# Define NO_SDT if you do not want to define SDT event in perf tools,
93# note that it doesn't disable SDT scanning support.
94#
95# Define FEATURES_DUMP to provide features detection dump file
96# and bypass the feature detection
97#
98# Define NO_JVMTI if you do not want jvmti agent built
99#
100# Define NO_JVMTI_CMLR (debug only) if you do not want to process CMLR
101# data for java source lines.
102#
103# Define CORESIGHT if you DO WANT support for CoreSight trace decoding.
104#
105# Define NO_AIO if you do not want support of Posix AIO based trace
106# streaming for record mode. Currently Posix AIO trace streaming is
107# supported only when linking with glibc.
108#
109# Define NO_LIBZSTD if you do not want support of Zstandard based runtime
110# trace compression in record mode.
111#
112# Define TCMALLOC to enable tcmalloc heap profiling.
113#
114# Define LIBBPF_DYNAMIC to enable libbpf dynamic linking.
115#
116# Define NO_LIBPFM4 to disable libpfm4 events extension.
117#
118# Define NO_LIBDEBUGINFOD if you do not want support debuginfod
119#
120# Set BUILD_BPF_SKEL to 0 to override BUILD_BPF_SKEL and not build BPF skeletons
121#
122# Define BUILD_NONDISTRO to enable building an linking against libbfd and
123# libiberty distribution license incompatible libraries.
124#
125# Define EXTRA_TESTS to enable building extra tests useful mainly to perf
126# developers, such as:
127#	x86 instruction decoder - new instructions test
128#
129# Define GEN_VMLINUX_H to generate vmlinux.h from the BTF.
130#
131# Define NO_SHELLCHECK if you do not want to run shellcheck during build
132
133# As per kernel Makefile, avoid funny character set dependencies
134unexport LC_ALL
135LC_COLLATE=C
136LC_NUMERIC=C
137export LC_COLLATE LC_NUMERIC
138
139ifeq ($(srctree),)
140srctree := $(patsubst %/,%,$(dir $(CURDIR)))
141srctree := $(patsubst %/,%,$(dir $(srctree)))
142#$(info Determined 'srctree' to be $(srctree))
143endif
144
145ifneq ($(objtree),)
146#$(info Determined 'objtree' to be $(objtree))
147endif
148
149ifneq ($(OUTPUT),)
150#$(info Determined 'OUTPUT' to be $(OUTPUT))
151# Adding $(OUTPUT) as a directory to look for source files,
152# because use generated output files as sources dependency
153# for flex/bison parsers.
154VPATH += $(OUTPUT)
155export VPATH
156# create symlink to the original source
157SOURCE := $(shell ln -sfn $(srctree)/tools/perf $(OUTPUT)/source)
158endif
159
160# Do not use make's built-in rules
161# (this improves performance and avoids hard-to-debug behaviour);
162MAKEFLAGS += -r
163
164# Makefiles suck: This macro sets a default value of $(2) for the
165# variable named by $(1), unless the variable has been set by
166# environment or command line. This is necessary for CC and AR
167# because make sets default values, so the simpler ?= approach
168# won't work as expected.
169define allow-override
170  $(if $(or $(findstring environment,$(origin $(1))),\
171            $(findstring command line,$(origin $(1)))),,\
172    $(eval $(1) = $(2)))
173endef
174
175LD += $(EXTRA_LDFLAGS)
176
177HOSTCC  ?= gcc
178HOSTLD  ?= ld
179HOSTAR  ?= ar
180CLANG   ?= clang
181
182# Some distros provide the command $(CROSS_COMPILE)pkg-config for
183# searching packges installed with Multiarch. Use it for cross
184# compilation if it is existed.
185ifneq (, $(shell which $(CROSS_COMPILE)pkg-config))
186  PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
187else
188  PKG_CONFIG ?= pkg-config
189
190  # PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR
191  # for modified system root, is required for the cross compilation.
192  # If these PKG_CONFIG environment variables are not set, Multiarch library
193  # paths are used instead.
194  ifdef CROSS_COMPILE
195    ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),)
196      CROSS_ARCH = $(notdir $(CROSS_COMPILE:%-=%))
197      PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
198      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
199      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
200      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/
201      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/
202      export PKG_CONFIG_LIBDIR
203      $(warning Missing PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH and PKG_CONFIG_SYSROOT_DIR for cross compilation,)
204      $(warning set PKG_CONFIG_LIBDIR for using Multiarch libs.)
205    endif
206  endif
207endif
208
209RM      = rm -f
210LN      = ln -f
211MKDIR   = mkdir
212FIND    = find
213INSTALL = install
214FLEX    ?= flex
215BISON   ?= bison
216STRIP   = strip
217AWK     = awk
218READELF ?= readelf
219
220# include Makefile.config by default and rule out
221# non-config cases
222config := 1
223
224NON_CONFIG_TARGETS := clean python-clean TAGS tags cscope help
225
226ifdef MAKECMDGOALS
227ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
228  VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h
229  config := 0
230endif
231endif
232
233# The fixdep build - we force fixdep tool to be built as
234# the first target in the separate make session not to be
235# disturbed by any parallel make jobs. Once fixdep is done
236# we issue the requested build with FIXDEP_BUILT=1 variable.
237#
238# The fixdep build is disabled for $(NON_CONFIG_TARGETS)
239# targets, because it's not necessary.
240
241ifdef FIXDEP_BUILT
242  force_fixdep := 0
243else
244  force_fixdep := $(config)
245endif
246
247# Runs shellcheck on perf shell scripts
248ifeq ($(NO_SHELLCHECK),1)
249  SHELLCHECK :=
250else
251  SHELLCHECK := $(shell which shellcheck 2> /dev/null)
252endif
253
254# shellcheck is using in tools/perf/tests/Build with option -a/--check-sourced (
255# introduced in v0.4.7) and -S/--severity (introduced in v0.6.0) as well as
256# dynamic source inclusions (properly handled since v0.7.2).
257# So make the minimal shellcheck version as v0.7.2.
258ifneq ($(SHELLCHECK),)
259  ifeq ($(shell expr $(shell $(SHELLCHECK) --version | grep version: | \
260        sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \< 072), 1)
261    SHELLCHECK :=
262  else
263    SHELLCHECK := $(SHELLCHECK) -s bash -a -S warning
264  endif
265endif
266
267# Runs mypy on perf python files
268ifeq ($(MYPY),1)
269  MYPY := $(shell which mypy 2> /dev/null)
270endif
271
272# Runs pylint on perf python files
273ifeq ($(PYLINT),1)
274  PYLINT := $(shell which pylint 2> /dev/null)
275endif
276
277export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF READELF
278export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT CONFIG_PERF_BPF_SKEL
279
280include $(srctree)/tools/build/Makefile.include
281
282ifeq ($(force_fixdep),1)
283goals := $(filter-out all sub-make, $(MAKECMDGOALS))
284
285$(goals) all: sub-make
286
287sub-make: fixdep
288	$(Q)$(MAKE) FIXDEP_BUILT=1 -f Makefile.perf $(goals)
289
290else # force_fixdep
291
292LIBAPI_DIR      = $(srctree)/tools/lib/api/
293LIBBPF_DIR      = $(srctree)/tools/lib/bpf/
294LIBSUBCMD_DIR   = $(srctree)/tools/lib/subcmd/
295LIBSYMBOL_DIR   = $(srctree)/tools/lib/symbol/
296LIBPERF_DIR     = $(srctree)/tools/lib/perf/
297DOC_DIR         = $(srctree)/tools/perf/Documentation/
298
299# Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
300# Without this setting the output feature dump file misses some features, for
301# example, liberty. Select all checkers so we won't get an incomplete feature
302# dump file.
303ifeq ($(config),1)
304ifdef MAKECMDGOALS
305ifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump)
306FEATURE_TESTS := all
307endif
308endif
309include Makefile.config
310endif
311
312ifeq ($(config),0)
313include $(srctree)/tools/scripts/Makefile.arch
314-include arch/$(SRCARCH)/Makefile
315endif
316
317# The FEATURE_DUMP_EXPORT holds location of the actual
318# FEATURE_DUMP file to be used to bypass feature detection
319# (for bpf or any other subproject)
320ifeq ($(FEATURES_DUMP),)
321FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
322else
323FEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP))
324endif
325
326export prefix bindir sharedir sysconfdir DESTDIR VMLINUX_H_FILE
327
328# sparse is architecture-neutral, which means that we need to tell it
329# explicitly what architecture to check for. Fix this up for yours..
330SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
331
332# Guard against environment variables
333PYRF_OBJS =
334SCRIPT_SH =
335
336SCRIPT_SH += perf-archive.sh
337SCRIPT_SH += perf-iostat.sh
338
339grep-libs = $(filter -l%,$(1))
340strip-libs = $(filter-out -l%,$(1))
341
342ifneq ($(OUTPUT),)
343  LIBAPI_OUTPUT = $(abspath $(OUTPUT))/libapi
344else
345  LIBAPI_OUTPUT = $(CURDIR)/libapi
346endif
347LIBAPI_DESTDIR = $(LIBAPI_OUTPUT)
348LIBAPI_INCLUDE = $(LIBAPI_DESTDIR)/include
349LIBAPI = $(LIBAPI_OUTPUT)/libapi.a
350export LIBAPI
351CFLAGS += -I$(LIBAPI_OUTPUT)/include
352
353ifneq ($(OUTPUT),)
354  LIBBPF_OUTPUT = $(abspath $(OUTPUT))/libbpf
355else
356  LIBBPF_OUTPUT = $(CURDIR)/libbpf
357endif
358ifdef LIBBPF_STATIC
359  LIBBPF_DESTDIR = $(LIBBPF_OUTPUT)
360  LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include
361  LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a
362  CFLAGS += -I$(LIBBPF_OUTPUT)/include
363endif
364
365ifneq ($(OUTPUT),)
366  LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd
367else
368  LIBSUBCMD_OUTPUT = $(CURDIR)/libsubcmd
369endif
370LIBSUBCMD_DESTDIR = $(LIBSUBCMD_OUTPUT)
371LIBSUBCMD_INCLUDE = $(LIBSUBCMD_DESTDIR)/include
372LIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.a
373CFLAGS += -I$(LIBSUBCMD_OUTPUT)/include
374
375ifneq ($(OUTPUT),)
376  LIBSYMBOL_OUTPUT = $(abspath $(OUTPUT))/libsymbol
377else
378  LIBSYMBOL_OUTPUT = $(CURDIR)/libsymbol
379endif
380LIBSYMBOL_DESTDIR = $(LIBSYMBOL_OUTPUT)
381LIBSYMBOL_INCLUDE = $(LIBSYMBOL_DESTDIR)/include
382LIBSYMBOL = $(LIBSYMBOL_OUTPUT)/libsymbol.a
383CFLAGS += -I$(LIBSYMBOL_OUTPUT)/include
384
385ifneq ($(OUTPUT),)
386  LIBPERF_OUTPUT = $(abspath $(OUTPUT))/libperf
387else
388  LIBPERF_OUTPUT = $(CURDIR)/libperf
389endif
390LIBPERF_DESTDIR = $(LIBPERF_OUTPUT)
391LIBPERF_INCLUDE = $(LIBPERF_DESTDIR)/include
392LIBPERF = $(LIBPERF_OUTPUT)/libperf.a
393export LIBPERF
394CFLAGS += -I$(LIBPERF_OUTPUT)/include
395
396# python extension build directories
397PYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
398PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
399PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
400export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
401
402python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
403
404ifneq ($(quiet),)
405python_setup_quiet=--quiet
406endif
407
408# Use the detected configuration
409-include $(OUTPUT).config-detected
410
411SCRIPTS = $(addprefix $(OUTPUT),$(patsubst %.sh,%,$(SCRIPT_SH)))
412
413PROGRAMS += $(OUTPUT)perf
414
415ifndef NO_PERF_READ_VDSO32
416PROGRAMS += $(OUTPUT)perf-read-vdso32
417endif
418
419ifndef NO_PERF_READ_VDSOX32
420PROGRAMS += $(OUTPUT)perf-read-vdsox32
421endif
422
423LIBJVMTI = libperf-jvmti.so
424
425ifndef NO_JVMTI
426PROGRAMS += $(OUTPUT)$(LIBJVMTI)
427endif
428
429DLFILTERS := dlfilter-test-api-v0.so dlfilter-test-api-v2.so dlfilter-show-cycles.so
430DLFILTERS := $(patsubst %,$(OUTPUT)dlfilters/%,$(DLFILTERS))
431
432# what 'all' will build and 'install' will install, in perfexecdir
433ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) $(DLFILTERS)
434
435# what 'all' will build but not install in perfexecdir
436OTHER_PROGRAMS = $(OUTPUT)perf
437
438# Set paths to tools early so that they can be used for version tests.
439ifndef SHELL_PATH
440  SHELL_PATH = /bin/sh
441endif
442ifndef PERL_PATH
443  PERL_PATH = /usr/bin/perl
444endif
445
446export PERL_PATH
447
448LIBPERF_BENCH_IN := $(OUTPUT)perf-bench-in.o
449LIBPERF_BENCH := $(OUTPUT)libperf-bench.a
450
451LIBPERF_TEST_IN := $(OUTPUT)perf-test-in.o
452LIBPERF_TEST := $(OUTPUT)libperf-test.a
453
454LIBPERF_UI_IN := $(OUTPUT)perf-ui-in.o
455LIBPERF_UI := $(OUTPUT)libperf-ui.a
456
457LIBPERF_UTIL_IN := $(OUTPUT)perf-util-in.o
458LIBPERF_UTIL := $(OUTPUT)libperf-util.a
459
460LIBPMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
461LIBPMU_EVENTS := $(OUTPUT)libpmu-events.a
462
463PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL)
464ifdef LIBBPF_STATIC
465  PERFLIBS += $(LIBBPF)
466endif
467PERFLIBS += $(LIBPERF_BENCH) $(LIBPERF_TEST) $(LIBPERF_UI) $(LIBPERF_UTIL)
468PERFLIBS += $(LIBPMU_EVENTS)
469
470# We choose to avoid "if .. else if .. else .. endif endif"
471# because maintaining the nesting to match is a pain.  If
472# we had "elif" things would have been much nicer...
473
474ifneq ($(OUTPUT),)
475  CFLAGS += -I$(OUTPUT)
476endif
477
478ifdef GTK2
479  ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
480  GTK_IN := $(OUTPUT)gtk-in.o
481endif
482
483ifdef ASCIIDOC8
484  export ASCIIDOC8
485endif
486
487EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
488LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
489
490PERFLIBS_PY := $(call filter-out,$(LIBPERF_BENCH) $(LIBPERF_TEST),$(PERFLIBS))
491LIBS_PY = -Wl,--whole-archive $(PERFLIBS_PY) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
492
493export INSTALL SHELL_PATH
494
495### Build rules
496
497SHELL = $(SHELL_PATH)
498
499arm64_gen_sysreg_dir := $(srctree)/tools/arch/arm64/tools
500ifneq ($(OUTPUT),)
501  arm64_gen_sysreg_outdir := $(abspath $(OUTPUT))
502else
503  arm64_gen_sysreg_outdir := $(CURDIR)
504endif
505
506arm64-sysreg-defs: FORCE
507	$(Q)$(MAKE) -C $(arm64_gen_sysreg_dir) O=$(arm64_gen_sysreg_outdir) \
508		prefix= subdir=
509
510arm64-sysreg-defs-clean:
511	$(call QUIET_CLEAN,arm64-sysreg-defs)
512	$(Q)$(MAKE) -C $(arm64_gen_sysreg_dir) O=$(arm64_gen_sysreg_outdir) \
513		prefix= subdir= clean > /dev/null
514
515all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
516
517# Create python binding output directory if not already present
518$(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
519
520$(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): util/python.c util/setup.py python/perf.pyi $(PERFLIBS_PY)
521	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
522        CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBS_PY)' \
523	  $(PYTHON_WORD) util/setup.py \
524	  $(python_setup_quiet) build_ext; \
525	cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/; \
526	if [ "$(abspath python/perf.pyi)" != "$(abspath $(OUTPUT)python/perf.pyi)" ]; then \
527		cp python/perf.pyi $(OUTPUT)python/; \
528	fi
529
530python_perf_target:
531	@echo "Target is: $(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX)"
532
533please_set_SHELL_PATH_to_a_more_modern_shell:
534	$(Q)$$(:)
535
536shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
537
538strip: $(PROGRAMS) $(OUTPUT)perf
539	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
540
541PERF_IN := $(OUTPUT)perf-in.o
542export NO_JEVENTS
543
544build := -f $(srctree)/tools/build/Makefile.build dir=. obj
545
546$(PERF_IN): prepare FORCE
547	$(Q)$(MAKE) $(build)=perf
548
549$(LIBPMU_EVENTS_IN): FORCE $(LIBPERF)
550	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
551
552$(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN)
553	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
554
555# The $(LIBPERF_UTIL) dependency is to ensure bpftool and vmlinux.h
556# aren't racily built for bench/bpf_skel/bench_uprobe.bpf.c
557$(LIBPERF_BENCH_IN): FORCE prepare $(LIBSYMBOL) | $(LIBPERF_UTIL)
558	$(Q)$(MAKE) $(build)=perf-bench
559
560$(LIBPERF_BENCH): $(LIBPERF_BENCH_IN)
561	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
562
563$(LIBPERF_TEST_IN): FORCE prepare
564	$(Q)$(MAKE) $(build)=perf-test
565
566$(LIBPERF_TEST): $(LIBPERF_TEST_IN)
567	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
568
569$(LIBPERF_UI_IN): FORCE prepare
570	$(Q)$(MAKE) $(build)=perf-ui
571
572$(LIBPERF_UI): $(LIBPERF_UI_IN)
573	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
574
575$(LIBPERF_UTIL_IN): FORCE prepare $(LIBSYMBOL)
576	$(Q)$(MAKE) $(build)=perf-util
577
578$(LIBPERF_UTIL): $(LIBPERF_UTIL_IN)
579	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
580
581$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN)
582	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
583		$(PERF_IN) $(LIBS) -o $@
584
585$(GTK_IN): FORCE prepare
586	$(Q)$(MAKE) $(build)=gtk
587
588$(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
589	$(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
590
591$(SCRIPTS) : $(OUTPUT)% : %.sh
592	$(QUIET_GEN)$(INSTALL) '$<' '$@'
593
594$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
595	$(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
596
597# These can record PERF_VERSION
598perf.spec $(SCRIPTS) \
599	: $(OUTPUT)PERF-VERSION-FILE
600
601.SUFFIXES:
602
603#
604# If a target does not match any of the later rules then prefix it by $(OUTPUT)
605# This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
606#
607ifneq ($(OUTPUT),)
608%.o: $(OUTPUT)%.o
609	@echo "    # Redirected target $@ => $(OUTPUT)$@"
610pmu-events/%.o: $(OUTPUT)pmu-events/%.o
611	@echo "    # Redirected target $@ => $(OUTPUT)$@"
612util/%.o: $(OUTPUT)util/%.o
613	@echo "    # Redirected target $@ => $(OUTPUT)$@"
614bench/%.o: $(OUTPUT)bench/%.o
615	@echo "    # Redirected target $@ => $(OUTPUT)$@"
616tests/%.o: $(OUTPUT)tests/%.o
617	@echo "    # Redirected target $@ => $(OUTPUT)$@"
618endif
619
620# These two need to be here so that when O= is not used they take precedence
621# over the general rule for .o
622
623# get relative building directory (to $(OUTPUT))
624# and '.' if it's $(OUTPUT) itself
625__build-dir = $(subst $(OUTPUT),,$(dir $@))
626build-dir   = $(or $(__build-dir),.)
627
628bpf-skel-prepare:
629	$(Q)$(MAKE) -f bpf_skel.mak bpf-skel-prepare
630
631prepare: $(OUTPUT)PERF-VERSION-FILE \
632	arm64-sysreg-defs \
633	bpf-skel-prepare \
634	$(LIBAPI) \
635	$(LIBPERF) \
636	$(LIBSUBCMD)
637
638ifdef LIBBPF_STATIC
639prepare: $(LIBBPF)
640endif
641
642$(OUTPUT)%.o: %.c prepare FORCE
643	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
644
645$(OUTPUT)%.i: %.c prepare FORCE
646	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
647
648$(OUTPUT)%.s: %.c prepare FORCE
649	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
650
651$(OUTPUT)%-bison.o: %.c prepare FORCE
652	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
653
654$(OUTPUT)%-flex.o: %.c prepare FORCE
655	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
656
657$(OUTPUT)%.o: %.S prepare FORCE
658	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
659
660$(OUTPUT)%.i: %.S prepare FORCE
661	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
662
663$(OUTPUT)perf-%: %.o $(PERFLIBS)
664	$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
665
666ifndef NO_PERF_READ_VDSO32
667$(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-map.c
668	$(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
669endif
670
671ifndef NO_PERF_READ_VDSOX32
672$(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-map.c
673	$(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
674endif
675
676$(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h
677	$(Q)$(MKDIR) -p $(OUTPUT)dlfilters
678	$(QUIET_CC)$(CC) -c -Iinclude $(EXTRA_CFLAGS) -o $@ -fpic $<
679
680.SECONDARY: $(DLFILTERS:.so=.o)
681
682$(OUTPUT)dlfilters/%.so: $(OUTPUT)dlfilters/%.o
683	$(QUIET_LINK)$(CC) $(LDFLAGS) $(EXTRA_CFLAGS) -shared -o $@ $<
684
685ifndef NO_JVMTI
686LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
687
688$(LIBJVMTI_IN): prepare FORCE
689	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
690
691$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
692	$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
693endif
694
695$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
696
697$(LIBAPI): FORCE | $(LIBAPI_OUTPUT)
698	$(Q)$(MAKE) -C $(LIBAPI_DIR) O=$(LIBAPI_OUTPUT) \
699		DESTDIR=$(LIBAPI_DESTDIR) prefix= subdir= \
700		$@ install_headers
701
702$(LIBAPI)-clean:
703	$(call QUIET_CLEAN, libapi)
704	$(Q)$(RM) -r -- $(LIBAPI_OUTPUT)
705
706$(LIBBPF): FORCE | $(LIBBPF_OUTPUT)
707	$(Q)$(MAKE) -C $(LIBBPF_DIR) FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) \
708		O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= subdir= \
709		EXTRA_CFLAGS="-fPIC" $@ install_headers
710
711$(LIBBPF)-clean:
712	$(call QUIET_CLEAN, libbpf)
713	$(Q)$(RM) -r -- $(LIBBPF_OUTPUT)
714
715$(LIBPERF): FORCE | $(LIBPERF_OUTPUT)
716	$(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(LIBPERF_OUTPUT) \
717		DESTDIR=$(LIBPERF_DESTDIR) prefix= subdir= \
718		$@ install_headers
719
720$(LIBPERF)-clean:
721	$(call QUIET_CLEAN, libperf)
722	$(Q)$(RM) -r -- $(LIBPERF_OUTPUT)
723
724$(LIBSUBCMD): FORCE | $(LIBSUBCMD_OUTPUT)
725	$(Q)$(MAKE) -C $(LIBSUBCMD_DIR) O=$(LIBSUBCMD_OUTPUT) \
726		DESTDIR=$(LIBSUBCMD_DESTDIR) prefix= subdir= \
727		$@ install_headers
728
729$(LIBSUBCMD)-clean:
730	$(call QUIET_CLEAN, libsubcmd)
731	$(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT)
732
733$(LIBSYMBOL): FORCE | $(LIBSYMBOL_OUTPUT)
734	$(Q)$(MAKE) -C $(LIBSYMBOL_DIR) O=$(LIBSYMBOL_OUTPUT) \
735		DESTDIR=$(LIBSYMBOL_DESTDIR) prefix= subdir= \
736		$@ install_headers
737
738$(LIBSYMBOL)-clean:
739	$(call QUIET_CLEAN, libsymbol)
740	$(Q)$(RM) -r -- $(LIBSYMBOL_OUTPUT)
741
742help:
743	@echo 'Perf make targets:'
744	@echo '  doc		- make *all* documentation (see below)'
745	@echo '  man		- make manpage documentation (access with man <foo>)'
746	@echo '  html		- make html documentation'
747	@echo '  info		- make GNU info documentation (access with info <foo>)'
748	@echo '  pdf		- make pdf documentation'
749	@echo '  TAGS		- use etags to make tag information for source browsing'
750	@echo '  tags		- use ctags to make tag information for source browsing'
751	@echo '  cscope	- use cscope to make interactive browsing database'
752	@echo ''
753	@echo 'Perf install targets:'
754	@echo '  NOTE: documentation build requires asciidoc, xmlto packages to be installed'
755	@echo '  HINT: use "prefix" or "DESTDIR" to install to a particular'
756	@echo '        path like "make prefix=/usr/local install install-doc"'
757	@echo '  install	- install compiled binaries'
758	@echo '  install-doc	- install *all* documentation'
759	@echo '  install-man	- install manpage documentation'
760	@echo '  install-html	- install html documentation'
761	@echo '  install-info	- install GNU info documentation'
762	@echo '  install-pdf	- install pdf documentation'
763	@echo ''
764	@echo '  quick-install-doc	- alias for quick-install-man'
765	@echo '  quick-install-man	- install the documentation quickly'
766	@echo '  quick-install-html	- install the html documentation quickly'
767	@echo ''
768	@echo 'Perf maintainer targets:'
769	@echo '  clean			- clean all binary objects and build output'
770
771
772DOC_TARGETS := doc man html info pdf
773
774INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
775INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
776
777# 'make doc' should call 'make -C Documentation all'
778$(DOC_TARGETS):
779	$(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:doc=all) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
780
781TAG_FOLDERS= . ../lib ../include
782TAG_FILES= ../../include/uapi/linux/perf_event.h
783
784TAGS:
785	$(QUIET_GEN)$(RM) TAGS; \
786	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs etags -a $(TAG_FILES)
787
788tags:
789	$(QUIET_GEN)$(RM) tags; \
790	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs ctags -a $(TAG_FILES)
791
792cscope:
793	$(QUIET_GEN)$(RM) cscope*; \
794	$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs cscope -b $(TAG_FILES)
795
796### Testing rules
797
798# GNU make supports exporting all variables by "export" without parameters.
799# However, the environment gets quite big, and some programs have problems
800# with that.
801
802check: prepare
803	if sparse; \
804	then \
805		for i in *.c */*.c; \
806		do \
807			sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
808		done; \
809	else \
810		exit 1; \
811	fi
812
813### Installation rules
814
815ifdef GTK2
816install-gtk: $(OUTPUT)libperf-gtk.so
817	$(call QUIET_INSTALL, 'GTK UI') \
818		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
819		$(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
820else
821install-gtk:
822endif
823
824install-tools: all install-gtk
825	$(call QUIET_INSTALL, binaries) \
826		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
827		$(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
828		$(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'; \
829		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(includedir_SQ)/perf'; \
830		$(INSTALL) -m 644 include/perf/perf_dlfilter.h -t '$(DESTDIR_SQ)$(includedir_SQ)/perf'
831ifndef NO_PERF_READ_VDSO32
832	$(call QUIET_INSTALL, perf-read-vdso32) \
833		$(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
834endif
835ifndef NO_PERF_READ_VDSOX32
836	$(call QUIET_INSTALL, perf-read-vdsox32) \
837		$(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
838endif
839ifndef NO_JVMTI
840	$(call QUIET_INSTALL, $(LIBJVMTI)) \
841		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
842		$(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
843endif
844	$(call QUIET_INSTALL, libexec) \
845		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
846	$(call QUIET_INSTALL, perf-archive) \
847		$(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
848	$(call QUIET_INSTALL, perf-iostat) \
849		$(INSTALL) $(OUTPUT)perf-iostat -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
850ifdef LIBPERL
851	$(call QUIET_INSTALL, perl-scripts) \
852		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
853		$(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'; \
854		$(INSTALL) scripts/perl/*.pl -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
855		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
856		$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
857endif
858ifndef NO_LIBPYTHON
859	$(call QUIET_INSTALL, python-scripts) \
860		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
861		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
862		$(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'; \
863		$(INSTALL) scripts/python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
864		$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
865endif
866	$(call QUIET_INSTALL, dlfilters) \
867		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/dlfilters'; \
868		$(INSTALL) $(DLFILTERS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/dlfilters';
869	$(call QUIET_INSTALL, perf_completion-script) \
870		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
871		$(INSTALL) perf-completion.sh -m 644 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
872	$(call QUIET_INSTALL, perf-tip) \
873		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
874		$(INSTALL) Documentation/tips.txt -m 644 -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
875
876install-tests: all install-gtk
877	$(call QUIET_INSTALL, tests) \
878		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
879		$(INSTALL) tests/pe-file.exe* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
880		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
881		$(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
882		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/attr'; \
883		$(INSTALL) tests/shell/attr/* -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/attr'; \
884		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
885		$(INSTALL) tests/shell/lib/*.sh -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
886		$(INSTALL) tests/shell/lib/*.py -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
887		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \
888		$(INSTALL) tests/shell/common/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \
889		$(INSTALL) tests/shell/common/*.pl '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/common'; \
890		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_probe'; \
891		$(INSTALL) tests/shell/base_probe/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_probe'; \
892		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_report'; \
893		$(INSTALL) tests/shell/base_report/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_report'; \
894		$(INSTALL) tests/shell/base_report/*.txt '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/base_report'; \
895		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight' ; \
896		$(INSTALL) tests/shell/coresight/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight'
897
898install-bin: install-tools install-tests
899
900install: install-bin try-install-man
901
902install-python_ext:
903	$(PYTHON_WORD) util/setup.py $(python_setup_quiet) install --root='/$(DESTDIR_SQ)'
904
905# 'make install-doc' should call 'make -C Documentation install'
906$(INSTALL_DOC_TARGETS):
907	$(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:-doc=) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA) subdir=
908
909### Cleaning rules
910
911python-clean:
912	$(python-clean)
913
914$(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT):
915	$(Q)$(MKDIR) -p $@
916
917bpf-skel-clean:
918	$(Q)$(MAKE) -f bpf_skel.mak clean
919
920pmu-events-clean:
921ifeq ($(OUTPUT),)
922	$(call QUIET_CLEAN, pmu-events) $(RM) \
923		pmu-events/pmu-events*.c \
924		pmu-events/metric_test.log \
925		pmu-events/test-empty-pmu-events.c \
926		pmu-events/empty-pmu-events.log
927	$(Q)find pmu-events/arch -name 'extra-metrics.json' -delete -o \
928		-name 'extra-metricgroups.json' -delete
929else # When an OUTPUT directory is present, clean up the copied pmu-events/arch directory.
930	$(call QUIET_CLEAN, pmu-events) $(RM) -r $(OUTPUT)pmu-events/arch \
931		$(OUTPUT)pmu-events/pmu-events*.c \
932		$(OUTPUT)pmu-events/metric_test.log \
933		$(OUTPUT)pmu-events/test-empty-pmu-events.c \
934		$(OUTPUT)pmu-events/empty-pmu-events.log
935endif
936
937clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean \
938		arm64-sysreg-defs-clean fixdep-clean python-clean bpf-skel-clean \
939		pmu-events-clean
940	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive \
941		$(OUTPUT)perf-iostat $(LANG_BINDINGS)
942	$(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '*.a' -delete -o \
943		-name '\.*.cmd' -delete -o -name '\.*.d' -delete -o -name '*.shellcheck_log' -delete
944	$(Q)$(RM) $(OUTPUT).config-detected
945	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 \
946		perf-read-vdsox32 $(OUTPUT)$(LIBJVMTI).so
947	$(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc */*.pyo \
948		TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \
949		$(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
950		$(OUTPUT)util/intel-pt-decoder/inat-tables.c \
951		$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c
952	$(Q)$(RM) -r $(OUTPUT)trace/beauty/generated
953	$(call QUIET_CLEAN, Documentation) \
954	$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null
955
956#
957# To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
958# file if defined, with no further action.
959feature-dump:
960ifdef FEATURE_DUMP_COPY
961	@cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY)
962	@echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)"
963else
964	@echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP"
965endif
966
967
968FORCE:
969
970.PHONY: all install clean config-clean strip install-gtk
971.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
972.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare bpf-skel-prepare
973.PHONY: python_perf_target
974
975endif # force_fixdep
976
977# Delete partially updated (corrupted) files on error
978.DELETE_ON_ERROR:
979