Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
0002 include ../scripts/Makefile.include
0003 include ../scripts/Makefile.arch
0004 
0005 # The default target of this Makefile is...
0006 all:
0007 
0008 include ../scripts/utilities.mak
0009 
0010 # Define V to have a more verbose compile.
0011 #
0012 # Define VF to have a more verbose feature check output.
0013 #
0014 # Define O to save output files in a separate directory.
0015 #
0016 # Define ARCH as name of target architecture if you want cross-builds.
0017 #
0018 # Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
0019 #
0020 # Define NO_LIBPERL to disable perl script extension.
0021 #
0022 # Define NO_LIBPYTHON to disable python script extension.
0023 #
0024 # Define PYTHON to point to the python binary if the default
0025 # `python' is not correct; for example: PYTHON=python2
0026 #
0027 # Define PYTHON_CONFIG to point to the python-config binary if
0028 # the default `$(PYTHON)-config' is not correct.
0029 #
0030 # Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
0031 #
0032 # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
0033 #
0034 # Define LDFLAGS=-static to build a static binary.
0035 #
0036 # Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
0037 #
0038 # Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
0039 # EXTLIBS.
0040 #
0041 # Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.
0042 #
0043 # Define NO_DWARF if you do not want debug-info analysis feature at all.
0044 #
0045 # Define WERROR=0 to disable treating any warnings as errors.
0046 #
0047 # Define NO_NEWT if you do not want TUI support. (deprecated)
0048 #
0049 # Define NO_SLANG if you do not want TUI support.
0050 #
0051 # Define GTK2 if you want GTK+ GUI support.
0052 #
0053 # Define NO_DEMANGLE if you do not want C++ symbol demangling.
0054 #
0055 # Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
0056 #
0057 # Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
0058 # backtrace post unwind.
0059 #
0060 # Define NO_BACKTRACE if you do not want stack backtrace debug feature
0061 #
0062 # Define NO_LIBNUMA if you do not want numa perf benchmark
0063 #
0064 # Define NO_LIBAUDIT if you do not want libaudit support
0065 #
0066 # Define NO_LIBBIONIC if you do not want bionic support
0067 #
0068 # Define NO_LIBCRYPTO if you do not want libcrypto (openssl) support
0069 # used for generating build-ids for ELFs generated by jitdump.
0070 #
0071 # Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
0072 # for dwarf backtrace post unwind.
0073 #
0074 # Define NO_PERF_READ_VDSO32 if you do not want to build perf-read-vdso32
0075 # for reading the 32-bit compatibility VDSO in 64-bit mode
0076 #
0077 # Define NO_PERF_READ_VDSOX32 if you do not want to build perf-read-vdsox32
0078 # for reading the x32 mode 32-bit compatibility VDSO in 64-bit mode
0079 #
0080 # Define NO_ZLIB if you do not want to support compressed kernel modules
0081 #
0082 # Define NO_LIBBABELTRACE if you do not want libbabeltrace support
0083 # for CTF data format.
0084 #
0085 # Define NO_LZMA if you do not want to support compressed (xz) kernel modules
0086 #
0087 # Define NO_AUXTRACE if you do not want AUX area tracing support
0088 #
0089 # Define NO_LIBBPF if you do not want BPF support
0090 #
0091 # Define NO_LIBCAP if you do not want process capabilities considered by perf
0092 #
0093 # Define NO_SDT if you do not want to define SDT event in perf tools,
0094 # note that it doesn't disable SDT scanning support.
0095 #
0096 # Define FEATURES_DUMP to provide features detection dump file
0097 # and bypass the feature detection
0098 #
0099 # Define NO_JVMTI if you do not want jvmti agent built
0100 #
0101 # Define NO_JVMTI_CMLR (debug only) if you do not want to process CMLR
0102 # data for java source lines.
0103 #
0104 # Define LIBCLANGLLVM if you DO want builtin clang and llvm support.
0105 # When selected, pass LLVM_CONFIG=/path/to/llvm-config to `make' if
0106 # llvm-config is not in $PATH.
0107 #
0108 # Define CORESIGHT if you DO WANT support for CoreSight trace decoding.
0109 #
0110 # Define NO_AIO if you do not want support of Posix AIO based trace
0111 # streaming for record mode. Currently Posix AIO trace streaming is
0112 # supported only when linking with glibc.
0113 #
0114 # Define NO_LIBZSTD if you do not want support of Zstandard based runtime
0115 # trace compression in record mode.
0116 #
0117 # Define TCMALLOC to enable tcmalloc heap profiling.
0118 #
0119 # Define LIBBPF_DYNAMIC to enable libbpf dynamic linking.
0120 #
0121 # Define NO_SYSCALL_TABLE=1 to disable the use of syscall id to/from name tables
0122 # generated from the kernel .tbl or unistd.h files and use, if available, libaudit
0123 # for doing the conversions to/from strings/id.
0124 #
0125 # Define LIBPFM4 to enable libpfm4 events extension.
0126 #
0127 # Define NO_LIBDEBUGINFOD if you do not want support debuginfod
0128 #
0129 # Define BUILD_BPF_SKEL to enable BPF skeletons
0130 #
0131 # Define LIBTRACEEVENT_DYNAMIC to enable libtraceevent dynamic linking
0132 #
0133 # Define LIBTRACEFS_DYNAMIC to enable libtracefs dynamic linking
0134 #
0135 
0136 # As per kernel Makefile, avoid funny character set dependencies
0137 unexport LC_ALL
0138 LC_COLLATE=C
0139 LC_NUMERIC=C
0140 export LC_COLLATE LC_NUMERIC
0141 
0142 ifeq ($(srctree),)
0143 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
0144 srctree := $(patsubst %/,%,$(dir $(srctree)))
0145 #$(info Determined 'srctree' to be $(srctree))
0146 endif
0147 
0148 ifneq ($(objtree),)
0149 #$(info Determined 'objtree' to be $(objtree))
0150 endif
0151 
0152 ifneq ($(OUTPUT),)
0153 #$(info Determined 'OUTPUT' to be $(OUTPUT))
0154 # Adding $(OUTPUT) as a directory to look for source files,
0155 # because use generated output files as sources dependency
0156 # for flex/bison parsers.
0157 VPATH += $(OUTPUT)
0158 export VPATH
0159 endif
0160 
0161 ifeq ($(V),1)
0162   Q =
0163 else
0164   Q = @
0165 endif
0166 
0167 # Do not use make's built-in rules
0168 # (this improves performance and avoids hard-to-debug behaviour);
0169 MAKEFLAGS += -r
0170 
0171 # Makefiles suck: This macro sets a default value of $(2) for the
0172 # variable named by $(1), unless the variable has been set by
0173 # environment or command line. This is necessary for CC and AR
0174 # because make sets default values, so the simpler ?= approach
0175 # won't work as expected.
0176 define allow-override
0177   $(if $(or $(findstring environment,$(origin $(1))),\
0178             $(findstring command line,$(origin $(1)))),,\
0179     $(eval $(1) = $(2)))
0180 endef
0181 
0182 LD += $(EXTRA_LDFLAGS)
0183 
0184 HOSTCC  ?= gcc
0185 HOSTLD  ?= ld
0186 HOSTAR  ?= ar
0187 CLANG   ?= clang
0188 LLVM_STRIP ?= llvm-strip
0189 
0190 PKG_CONFIG = $(CROSS_COMPILE)pkg-config
0191 
0192 RM      = rm -f
0193 LN      = ln -f
0194 MKDIR   = mkdir
0195 FIND    = find
0196 INSTALL = install
0197 FLEX    ?= flex
0198 BISON   ?= bison
0199 STRIP   = strip
0200 AWK     = awk
0201 
0202 # include Makefile.config by default and rule out
0203 # non-config cases
0204 config := 1
0205 
0206 NON_CONFIG_TARGETS := clean python-clean TAGS tags cscope help
0207 
0208 ifdef MAKECMDGOALS
0209 ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
0210   config := 0
0211 endif
0212 endif
0213 
0214 # The fixdep build - we force fixdep tool to be built as
0215 # the first target in the separate make session not to be
0216 # disturbed by any parallel make jobs. Once fixdep is done
0217 # we issue the requested build with FIXDEP=1 variable.
0218 #
0219 # The fixdep build is disabled for $(NON_CONFIG_TARGETS)
0220 # targets, because it's not necessary.
0221 
0222 ifdef FIXDEP
0223   force_fixdep := 0
0224 else
0225   force_fixdep := $(config)
0226 endif
0227 
0228 export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK
0229 export HOSTCC HOSTLD HOSTAR HOSTCFLAGS
0230 
0231 include $(srctree)/tools/build/Makefile.include
0232 
0233 ifeq ($(force_fixdep),1)
0234 goals := $(filter-out all sub-make, $(MAKECMDGOALS))
0235 
0236 $(goals) all: sub-make
0237 
0238 sub-make: fixdep
0239         @./check-headers.sh
0240         $(Q)$(MAKE) FIXDEP=1 -f Makefile.perf $(goals)
0241 
0242 else # force_fixdep
0243 
0244 LIB_DIR         = $(srctree)/tools/lib/api/
0245 TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
0246 LIBBPF_DIR      = $(srctree)/tools/lib/bpf/
0247 SUBCMD_DIR      = $(srctree)/tools/lib/subcmd/
0248 LIBPERF_DIR     = $(srctree)/tools/lib/perf/
0249 DOC_DIR         = $(srctree)/tools/perf/Documentation/
0250 
0251 # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
0252 # Without this setting the output feature dump file misses some features, for
0253 # example, liberty. Select all checkers so we won't get an incomplete feature
0254 # dump file.
0255 ifeq ($(config),1)
0256 ifdef MAKECMDGOALS
0257 ifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump)
0258 FEATURE_TESTS := all
0259 endif
0260 endif
0261 include Makefile.config
0262 endif
0263 
0264 ifeq ($(config),0)
0265 include $(srctree)/tools/scripts/Makefile.arch
0266 -include arch/$(SRCARCH)/Makefile
0267 endif
0268 
0269 # The FEATURE_DUMP_EXPORT holds location of the actual
0270 # FEATURE_DUMP file to be used to bypass feature detection
0271 # (for bpf or any other subproject)
0272 ifeq ($(FEATURES_DUMP),)
0273 FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
0274 else
0275 FEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP))
0276 endif
0277 
0278 export prefix bindir sharedir sysconfdir DESTDIR
0279 
0280 # sparse is architecture-neutral, which means that we need to tell it
0281 # explicitly what architecture to check for. Fix this up for yours..
0282 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
0283 
0284 # Guard against environment variables
0285 PYRF_OBJS =
0286 SCRIPT_SH =
0287 
0288 SCRIPT_SH += perf-archive.sh
0289 SCRIPT_SH += perf-iostat.sh
0290 
0291 grep-libs = $(filter -l%,$(1))
0292 strip-libs = $(filter-out -l%,$(1))
0293 
0294 ifneq ($(OUTPUT),)
0295   TE_PATH=$(OUTPUT)
0296   PLUGINS_PATH=$(OUTPUT)
0297   SUBCMD_PATH=$(OUTPUT)
0298   LIBPERF_PATH=$(OUTPUT)
0299 ifneq ($(subdir),)
0300   API_PATH=$(OUTPUT)/../lib/api/
0301 else
0302   API_PATH=$(OUTPUT)
0303 endif
0304 else
0305   TE_PATH=$(TRACE_EVENT_DIR)
0306   PLUGINS_PATH=$(TRACE_EVENT_DIR)plugins/
0307   API_PATH=$(LIB_DIR)
0308   SUBCMD_PATH=$(SUBCMD_DIR)
0309   LIBPERF_PATH=$(LIBPERF_DIR)
0310 endif
0311 
0312 LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
0313 export LIBTRACEEVENT
0314 LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list
0315 
0316 #
0317 # The static build has no dynsym table, so this does not work for
0318 # static build. Looks like linker starts to scream about that now
0319 # (in Fedora 26) so we need to switch it off for static build.
0320 DYNAMIC_LIST_LDFLAGS               = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
0321 LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS))
0322 
0323 LIBAPI = $(API_PATH)libapi.a
0324 export LIBAPI
0325 
0326 ifneq ($(OUTPUT),)
0327   LIBBPF_OUTPUT = $(abspath $(OUTPUT))/libbpf
0328 else
0329   LIBBPF_OUTPUT = $(CURDIR)/libbpf
0330 endif
0331 LIBBPF_DESTDIR = $(LIBBPF_OUTPUT)
0332 LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include
0333 LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a 
0334 
0335 LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
0336 
0337 LIBPERF = $(LIBPERF_PATH)libperf.a
0338 export LIBPERF
0339 
0340 # python extension build directories
0341 PYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
0342 PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
0343 PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
0344 export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
0345 
0346 python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
0347 
0348 PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
0349 PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
0350 
0351 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
0352 
0353 PROGRAMS += $(OUTPUT)perf
0354 
0355 ifndef NO_PERF_READ_VDSO32
0356 PROGRAMS += $(OUTPUT)perf-read-vdso32
0357 endif
0358 
0359 ifndef NO_PERF_READ_VDSOX32
0360 PROGRAMS += $(OUTPUT)perf-read-vdsox32
0361 endif
0362 
0363 LIBJVMTI = libperf-jvmti.so
0364 
0365 ifndef NO_JVMTI
0366 PROGRAMS += $(OUTPUT)$(LIBJVMTI)
0367 endif
0368 
0369 DLFILTERS := dlfilter-test-api-v0.so dlfilter-show-cycles.so
0370 DLFILTERS := $(patsubst %,$(OUTPUT)dlfilters/%,$(DLFILTERS))
0371 
0372 # what 'all' will build and 'install' will install, in perfexecdir
0373 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) $(DLFILTERS)
0374 
0375 # what 'all' will build but not install in perfexecdir
0376 OTHER_PROGRAMS = $(OUTPUT)perf
0377 
0378 # Set paths to tools early so that they can be used for version tests.
0379 ifndef SHELL_PATH
0380   SHELL_PATH = /bin/sh
0381 endif
0382 ifndef PERL_PATH
0383   PERL_PATH = /usr/bin/perl
0384 endif
0385 
0386 export PERL_PATH
0387 
0388 PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF)
0389 ifndef NO_LIBBPF
0390   ifndef LIBBPF_DYNAMIC
0391     PERFLIBS += $(LIBBPF)
0392   endif
0393 endif
0394 ifndef LIBTRACEEVENT_DYNAMIC
0395   PERFLIBS += $(LIBTRACEEVENT)
0396 endif
0397 
0398 # We choose to avoid "if .. else if .. else .. endif endif"
0399 # because maintaining the nesting to match is a pain.  If
0400 # we had "elif" things would have been much nicer...
0401 
0402 ifneq ($(OUTPUT),)
0403   CFLAGS += -I$(OUTPUT)
0404 endif
0405 
0406 ifdef GTK2
0407   ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
0408   GTK_IN := $(OUTPUT)gtk-in.o
0409 endif
0410 
0411 ifdef ASCIIDOC8
0412   export ASCIIDOC8
0413 endif
0414 
0415 EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
0416 LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
0417 
0418 ifeq ($(USE_CLANG), 1)
0419   CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
0420   CLANGLIBS_NOEXT_LIST = $(foreach l,$(CLANGLIBS_LIST),$(shell $(LLVM_CONFIG) --libdir)/libclang$(l))
0421   LIBCLANG = $(foreach l,$(CLANGLIBS_NOEXT_LIST),$(wildcard $(l).a $(l).so))
0422   LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-group
0423 endif
0424 
0425 ifeq ($(USE_LLVM), 1)
0426   LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)
0427   LIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)
0428 endif
0429 
0430 ifeq ($(USE_CXX), 1)
0431   LIBS += -lstdc++
0432 endif
0433 
0434 export INSTALL SHELL_PATH
0435 
0436 ### Build rules
0437 
0438 SHELL = $(SHELL_PATH)
0439 
0440 beauty_linux_dir := $(srctree)/tools/perf/trace/beauty/include/linux/
0441 linux_uapi_dir := $(srctree)/tools/include/uapi/linux
0442 asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic
0443 arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/
0444 x86_arch_asm_uapi_dir := $(srctree)/tools/arch/x86/include/uapi/asm/
0445 x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/
0446 
0447 beauty_outdir := $(OUTPUT)trace/beauty/generated
0448 beauty_ioctl_outdir := $(beauty_outdir)/ioctl
0449 drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c
0450 drm_hdr_dir := $(srctree)/tools/include/uapi/drm
0451 drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh
0452 
0453 # Create output directory if not already present
0454 _dummy := $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)')
0455 
0456 $(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl)
0457         $(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@
0458 
0459 fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c
0460 fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh
0461 
0462 $(fadvise_advice_array): $(linux_uapi_dir)/in.h $(fadvise_advice_tbl)
0463         $(Q)$(SHELL) '$(fadvise_advice_tbl)' $(linux_uapi_dir) > $@
0464 
0465 fsmount_arrays := $(beauty_outdir)/fsmount_arrays.c
0466 fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh
0467 
0468 $(fsmount_arrays): $(linux_uapi_dir)/fs.h $(fsmount_tbls)
0469         $(Q)$(SHELL) '$(fsmount_tbls)' $(linux_uapi_dir) > $@
0470 
0471 fspick_arrays := $(beauty_outdir)/fspick_arrays.c
0472 fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh
0473 
0474 $(fspick_arrays): $(linux_uapi_dir)/fs.h $(fspick_tbls)
0475         $(Q)$(SHELL) '$(fspick_tbls)' $(linux_uapi_dir) > $@
0476 
0477 fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c
0478 fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh
0479 
0480 $(fsconfig_arrays): $(linux_uapi_dir)/fs.h $(fsconfig_tbls)
0481         $(Q)$(SHELL) '$(fsconfig_tbls)' $(linux_uapi_dir) > $@
0482 
0483 pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c
0484 asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
0485 pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
0486 
0487 $(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl)
0488         $(Q)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@
0489 
0490 sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c
0491 sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound
0492 sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh
0493 
0494 $(sndrv_ctl_ioctl_array): $(sndrv_ctl_hdr_dir)/asound.h $(sndrv_ctl_ioctl_tbl)
0495         $(Q)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(sndrv_ctl_hdr_dir) > $@
0496 
0497 sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c
0498 sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound
0499 sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh
0500 
0501 $(sndrv_pcm_ioctl_array): $(sndrv_pcm_hdr_dir)/asound.h $(sndrv_pcm_ioctl_tbl)
0502         $(Q)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(sndrv_pcm_hdr_dir) > $@
0503 
0504 kcmp_type_array := $(beauty_outdir)/kcmp_type_array.c
0505 kcmp_hdr_dir := $(srctree)/tools/include/uapi/linux/
0506 kcmp_type_tbl := $(srctree)/tools/perf/trace/beauty/kcmp_type.sh
0507 
0508 $(kcmp_type_array): $(kcmp_hdr_dir)/kcmp.h $(kcmp_type_tbl)
0509         $(Q)$(SHELL) '$(kcmp_type_tbl)' $(kcmp_hdr_dir) > $@
0510 
0511 kvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c
0512 kvm_hdr_dir := $(srctree)/tools/include/uapi/linux
0513 kvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh
0514 
0515 $(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl)
0516         $(Q)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@
0517 
0518 socket_arrays := $(beauty_outdir)/socket.c
0519 socket_tbl := $(srctree)/tools/perf/trace/beauty/socket.sh
0520 
0521 $(socket_arrays): $(linux_uapi_dir)/in.h $(beauty_linux_dir)/socket.h $(socket_tbl)
0522         $(Q)$(SHELL) '$(socket_tbl)' $(linux_uapi_dir) $(beauty_linux_dir) > $@
0523 
0524 sockaddr_arrays := $(beauty_outdir)/sockaddr.c
0525 sockaddr_tbl := $(srctree)/tools/perf/trace/beauty/sockaddr.sh
0526 
0527 $(sockaddr_arrays): $(beauty_linux_dir)/socket.h $(sockaddr_tbl)
0528         $(Q)$(SHELL) '$(sockaddr_tbl)' $(beauty_linux_dir) > $@
0529 
0530 vhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c
0531 vhost_virtio_hdr_dir := $(srctree)/tools/include/uapi/linux
0532 vhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh
0533 
0534 $(vhost_virtio_ioctl_array): $(vhost_virtio_hdr_dir)/vhost.h $(vhost_virtio_ioctl_tbl)
0535         $(Q)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(vhost_virtio_hdr_dir) > $@
0536 
0537 perf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c
0538 perf_hdr_dir := $(srctree)/tools/include/uapi/linux
0539 perf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh
0540 
0541 $(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl)
0542         $(Q)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@
0543 
0544 madvise_behavior_array := $(beauty_outdir)/madvise_behavior_array.c
0545 madvise_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
0546 madvise_behavior_tbl := $(srctree)/tools/perf/trace/beauty/madvise_behavior.sh
0547 
0548 $(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_tbl)
0549         $(Q)$(SHELL) '$(madvise_behavior_tbl)' $(madvise_hdr_dir) > $@
0550 
0551 mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c
0552 mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh
0553 
0554 $(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl)
0555         $(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@
0556 
0557 mremap_flags_array := $(beauty_outdir)/mremap_flags_array.c
0558 mremap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mremap_flags.sh
0559 
0560 $(mremap_flags_array): $(linux_uapi_dir)/mman.h $(mremap_flags_tbl)
0561         $(Q)$(SHELL) '$(mremap_flags_tbl)' $(linux_uapi_dir) > $@
0562 
0563 mount_flags_array := $(beauty_outdir)/mount_flags_array.c
0564 mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh
0565 
0566 $(mount_flags_array): $(linux_uapi_dir)/fs.h $(mount_flags_tbl)
0567         $(Q)$(SHELL) '$(mount_flags_tbl)' $(linux_uapi_dir) > $@
0568 
0569 move_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c
0570 move_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh
0571 
0572 $(move_mount_flags_array): $(linux_uapi_dir)/fs.h $(move_mount_flags_tbl)
0573         $(Q)$(SHELL) '$(move_mount_flags_tbl)' $(linux_uapi_dir) > $@
0574 
0575 
0576 mmap_prot_array := $(beauty_outdir)/mmap_prot_array.c
0577 mmap_prot_tbl := $(srctree)/tools/perf/trace/beauty/mmap_prot.sh
0578 
0579 $(mmap_prot_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_prot_tbl)
0580         $(Q)$(SHELL) '$(mmap_prot_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@
0581 
0582 prctl_option_array := $(beauty_outdir)/prctl_option_array.c
0583 prctl_hdr_dir := $(srctree)/tools/include/uapi/linux/
0584 prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh
0585 
0586 $(prctl_option_array): $(prctl_hdr_dir)/prctl.h $(prctl_option_tbl)
0587         $(Q)$(SHELL) '$(prctl_option_tbl)' $(prctl_hdr_dir) > $@
0588 
0589 usbdevfs_ioctl_array := $(beauty_ioctl_outdir)/usbdevfs_ioctl_array.c
0590 usbdevfs_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/usbdevfs_ioctl.sh
0591 
0592 $(usbdevfs_ioctl_array): $(linux_uapi_dir)/usbdevice_fs.h $(usbdevfs_ioctl_tbl)
0593         $(Q)$(SHELL) '$(usbdevfs_ioctl_tbl)' $(linux_uapi_dir) > $@
0594 
0595 x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c
0596 x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh
0597 
0598 $(x86_arch_prctl_code_array): $(x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl)
0599         $(Q)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(x86_arch_asm_uapi_dir) > $@
0600 
0601 x86_arch_irq_vectors_array := $(beauty_outdir)/x86_arch_irq_vectors_array.c
0602 x86_arch_irq_vectors_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh
0603 
0604 $(x86_arch_irq_vectors_array): $(x86_arch_asm_dir)/irq_vectors.h $(x86_arch_irq_vectors_tbl)
0605         $(Q)$(SHELL) '$(x86_arch_irq_vectors_tbl)' $(x86_arch_asm_dir) > $@
0606 
0607 x86_arch_MSRs_array := $(beauty_outdir)/x86_arch_MSRs_array.c
0608 x86_arch_MSRs_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_msr.sh
0609 
0610 $(x86_arch_MSRs_array): $(x86_arch_asm_dir)/msr-index.h $(x86_arch_MSRs_tbl)
0611         $(Q)$(SHELL) '$(x86_arch_MSRs_tbl)' $(x86_arch_asm_dir) > $@
0612 
0613 rename_flags_array := $(beauty_outdir)/rename_flags_array.c
0614 rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh
0615 
0616 $(rename_flags_array): $(linux_uapi_dir)/fs.h $(rename_flags_tbl)
0617         $(Q)$(SHELL) '$(rename_flags_tbl)' $(linux_uapi_dir) > $@
0618 
0619 arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c
0620 arch_errno_hdr_dir := $(srctree)/tools
0621 arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
0622 
0623 $(arch_errno_name_array): $(arch_errno_tbl)
0624         $(Q)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@
0625 
0626 sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c
0627 sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh
0628 
0629 $(sync_file_range_arrays): $(linux_uapi_dir)/fs.h $(sync_file_range_tbls)
0630         $(Q)$(SHELL) '$(sync_file_range_tbls)' $(linux_uapi_dir) > $@
0631 
0632 all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
0633 
0634 # Create python binding output directory if not already present
0635 _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
0636 
0637 $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) $(LIBPERF)
0638         $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
0639         CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
0640           $(PYTHON_WORD) util/setup.py \
0641           --quiet build_ext; \
0642         cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
0643 
0644 please_set_SHELL_PATH_to_a_more_modern_shell:
0645         $(Q)$$(:)
0646 
0647 shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
0648 
0649 strip: $(PROGRAMS) $(OUTPUT)perf
0650         $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
0651 
0652 PERF_IN := $(OUTPUT)perf-in.o
0653 
0654 PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
0655 export NO_JEVENTS
0656 
0657 build := -f $(srctree)/tools/build/Makefile.build dir=. obj
0658 
0659 $(PERF_IN): prepare FORCE
0660         $(Q)$(MAKE) $(build)=perf
0661 
0662 $(PMU_EVENTS_IN): FORCE
0663         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
0664 
0665 $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
0666         $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
0667                 $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
0668 
0669 $(GTK_IN): FORCE
0670         $(Q)$(MAKE) $(build)=gtk
0671 
0672 $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
0673         $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
0674 
0675 $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
0676 
0677 $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
0678         $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
0679 
0680 $(SCRIPTS) : % : %.sh
0681         $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
0682 
0683 $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
0684         $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
0685 
0686 # These can record PERF_VERSION
0687 perf.spec $(SCRIPTS) \
0688         : $(OUTPUT)PERF-VERSION-FILE
0689 
0690 .SUFFIXES:
0691 
0692 #
0693 # If a target does not match any of the later rules then prefix it by $(OUTPUT)
0694 # This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
0695 #
0696 ifneq ($(OUTPUT),)
0697 %.o: $(OUTPUT)%.o
0698         @echo "    # Redirected target $@ => $(OUTPUT)$@"
0699 pmu-events/%.o: $(OUTPUT)pmu-events/%.o
0700         @echo "    # Redirected target $@ => $(OUTPUT)$@"
0701 util/%.o: $(OUTPUT)util/%.o
0702         @echo "    # Redirected target $@ => $(OUTPUT)$@"
0703 bench/%.o: $(OUTPUT)bench/%.o
0704         @echo "    # Redirected target $@ => $(OUTPUT)$@"
0705 tests/%.o: $(OUTPUT)tests/%.o
0706         @echo "    # Redirected target $@ => $(OUTPUT)$@"
0707 endif
0708 
0709 # These two need to be here so that when O= is not used they take precedence
0710 # over the general rule for .o
0711 
0712 # get relative building directory (to $(OUTPUT))
0713 # and '.' if it's $(OUTPUT) itself
0714 __build-dir = $(subst $(OUTPUT),,$(dir $@))
0715 build-dir   = $(or $(__build-dir),.)
0716 
0717 prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \
0718         $(fadvise_advice_array) \
0719         $(fsconfig_arrays) \
0720         $(fsmount_arrays) \
0721         $(fspick_arrays) \
0722         $(pkey_alloc_access_rights_array) \
0723         $(sndrv_pcm_ioctl_array) \
0724         $(sndrv_ctl_ioctl_array) \
0725         $(kcmp_type_array) \
0726         $(kvm_ioctl_array) \
0727         $(socket_arrays) \
0728         $(sockaddr_arrays) \
0729         $(vhost_virtio_ioctl_array) \
0730         $(madvise_behavior_array) \
0731         $(mmap_flags_array) \
0732         $(mmap_prot_array) \
0733         $(mremap_flags_array) \
0734         $(mount_flags_array) \
0735         $(move_mount_flags_array) \
0736         $(perf_ioctl_array) \
0737         $(prctl_option_array) \
0738         $(usbdevfs_ioctl_array) \
0739         $(x86_arch_irq_vectors_array) \
0740         $(x86_arch_MSRs_array) \
0741         $(x86_arch_prctl_code_array) \
0742         $(rename_flags_array) \
0743         $(arch_errno_name_array) \
0744         $(sync_file_range_arrays) \
0745         bpf-skel
0746 
0747 $(OUTPUT)%.o: %.c prepare FORCE
0748         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
0749 
0750 $(OUTPUT)%.i: %.c prepare FORCE
0751         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
0752 
0753 $(OUTPUT)%.s: %.c prepare FORCE
0754         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
0755 
0756 $(OUTPUT)%-bison.o: %.c prepare FORCE
0757         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
0758 
0759 $(OUTPUT)%-flex.o: %.c prepare FORCE
0760         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
0761 
0762 $(OUTPUT)%.o: %.S prepare FORCE
0763         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
0764 
0765 $(OUTPUT)%.i: %.S prepare FORCE
0766         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
0767 
0768 $(OUTPUT)perf-%: %.o $(PERFLIBS)
0769         $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
0770 
0771 ifndef NO_PERF_READ_VDSO32
0772 $(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-map.c
0773         $(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
0774 endif
0775 
0776 ifndef NO_PERF_READ_VDSOX32
0777 $(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-map.c
0778         $(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
0779 endif
0780 
0781 $(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h
0782         $(Q)$(MKDIR) -p $(OUTPUT)dlfilters
0783         $(QUIET_CC)$(CC) -c -Iinclude $(EXTRA_CFLAGS) -o $@ -fpic $< 
0784 
0785 .SECONDARY: $(DLFILTERS:.so=.o)
0786 
0787 $(OUTPUT)dlfilters/%.so: $(OUTPUT)dlfilters/%.o
0788         $(QUIET_LINK)$(CC) $(EXTRA_CFLAGS) -shared -o $@ $<
0789 
0790 ifndef NO_JVMTI
0791 LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
0792 
0793 $(LIBJVMTI_IN): FORCE
0794         $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
0795 
0796 $(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
0797         $(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
0798 endif
0799 
0800 $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
0801 
0802 LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(filter-out -static,$(LDFLAGS))'
0803 
0804 $(LIBTRACEEVENT): FORCE
0805         $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a
0806 
0807 libtraceevent_plugins: FORCE
0808         $(Q)$(MAKE) -C $(TRACE_EVENT_DIR)plugins $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins
0809 
0810 $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins
0811         $(Q)$(MAKE) -C $(TRACE_EVENT_DIR)plugins $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent-dynamic-list
0812 
0813 $(LIBTRACEEVENT)-clean:
0814         $(call QUIET_CLEAN, libtraceevent)
0815         $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean >/dev/null
0816 
0817 install-traceevent-plugins: libtraceevent_plugins
0818         $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins
0819 
0820 $(LIBAPI): FORCE
0821         $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
0822 
0823 $(LIBAPI)-clean:
0824         $(call QUIET_CLEAN, libapi)
0825         $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
0826 
0827 $(LIBBPF): FORCE | $(LIBBPF_OUTPUT)
0828         $(Q)$(MAKE) -C $(LIBBPF_DIR) FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) \
0829                 O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= \
0830                 $@ install_headers
0831 
0832 $(LIBBPF)-clean:
0833         $(call QUIET_CLEAN, libbpf)
0834         $(Q)$(RM) -r -- $(LIBBPF_OUTPUT)
0835 
0836 $(LIBPERF): FORCE
0837         $(Q)$(MAKE) -C $(LIBPERF_DIR) EXTRA_CFLAGS="$(LIBPERF_CFLAGS)" O=$(OUTPUT) $(OUTPUT)libperf.a
0838 
0839 $(LIBPERF)-clean:
0840         $(call QUIET_CLEAN, libperf)
0841         $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) clean >/dev/null
0842 
0843 $(LIBSUBCMD): FORCE
0844         $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
0845 
0846 $(LIBSUBCMD)-clean:
0847         $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) clean
0848 
0849 help:
0850         @echo 'Perf make targets:'
0851         @echo '  doc            - make *all* documentation (see below)'
0852         @echo '  man            - make manpage documentation (access with man <foo>)'
0853         @echo '  html           - make html documentation'
0854         @echo '  info           - make GNU info documentation (access with info <foo>)'
0855         @echo '  pdf            - make pdf documentation'
0856         @echo '  TAGS           - use etags to make tag information for source browsing'
0857         @echo '  tags           - use ctags to make tag information for source browsing'
0858         @echo '  cscope - use cscope to make interactive browsing database'
0859         @echo ''
0860         @echo 'Perf install targets:'
0861         @echo '  NOTE: documentation build requires asciidoc, xmlto packages to be installed'
0862         @echo '  HINT: use "prefix" or "DESTDIR" to install to a particular'
0863         @echo '        path like "make prefix=/usr/local install install-doc"'
0864         @echo '  install        - install compiled binaries'
0865         @echo '  install-doc    - install *all* documentation'
0866         @echo '  install-man    - install manpage documentation'
0867         @echo '  install-html   - install html documentation'
0868         @echo '  install-info   - install GNU info documentation'
0869         @echo '  install-pdf    - install pdf documentation'
0870         @echo ''
0871         @echo '  quick-install-doc      - alias for quick-install-man'
0872         @echo '  quick-install-man      - install the documentation quickly'
0873         @echo '  quick-install-html     - install the html documentation quickly'
0874         @echo ''
0875         @echo 'Perf maintainer targets:'
0876         @echo '  clean                  - clean all binary objects and build output'
0877 
0878 
0879 DOC_TARGETS := doc man html info pdf
0880 
0881 INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
0882 INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
0883 
0884 # 'make doc' should call 'make -C Documentation all'
0885 $(DOC_TARGETS):
0886         $(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:doc=all) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
0887 
0888 TAG_FOLDERS= . ../lib ../include
0889 TAG_FILES= ../../include/uapi/linux/perf_event.h 
0890 
0891 TAGS:
0892         $(QUIET_GEN)$(RM) TAGS; \
0893         $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs etags -a $(TAG_FILES)
0894 
0895 tags:
0896         $(QUIET_GEN)$(RM) tags; \
0897         $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs ctags -a $(TAG_FILES)
0898 
0899 cscope:
0900         $(QUIET_GEN)$(RM) cscope*; \
0901         $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print -o -name '*.cpp' -print | xargs cscope -b $(TAG_FILES)
0902 
0903 ### Testing rules
0904 
0905 # GNU make supports exporting all variables by "export" without parameters.
0906 # However, the environment gets quite big, and some programs have problems
0907 # with that.
0908 
0909 check: $(OUTPUT)common-cmds.h
0910         if sparse; \
0911         then \
0912                 for i in *.c */*.c; \
0913                 do \
0914                         sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
0915                 done; \
0916         else \
0917                 exit 1; \
0918         fi
0919 
0920 ### Installation rules
0921 
0922 ifdef GTK2
0923 install-gtk: $(OUTPUT)libperf-gtk.so
0924         $(call QUIET_INSTALL, 'GTK UI') \
0925                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
0926                 $(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
0927 else
0928 install-gtk:
0929 endif
0930 
0931 install-tools: all install-gtk
0932         $(call QUIET_INSTALL, binaries) \
0933                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
0934                 $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
0935                 $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'; \
0936                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(includedir_SQ)/perf'; \
0937                 $(INSTALL) -m 644 include/perf/perf_dlfilter.h -t '$(DESTDIR_SQ)$(includedir_SQ)/perf'
0938 ifndef NO_PERF_READ_VDSO32
0939         $(call QUIET_INSTALL, perf-read-vdso32) \
0940                 $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
0941 endif
0942 ifndef NO_PERF_READ_VDSOX32
0943         $(call QUIET_INSTALL, perf-read-vdsox32) \
0944                 $(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
0945 endif
0946 ifndef NO_JVMTI
0947         $(call QUIET_INSTALL, $(LIBJVMTI)) \
0948                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
0949                 $(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
0950 endif
0951         $(call QUIET_INSTALL, libexec) \
0952                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
0953 ifndef NO_LIBBPF
0954         $(call QUIET_INSTALL, bpf-headers) \
0955                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
0956                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'; \
0957                 $(INSTALL) include/bpf/*.h -m 644 -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
0958                 $(INSTALL) include/bpf/linux/*.h -m 644 -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'
0959         $(call QUIET_INSTALL, bpf-examples) \
0960                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'; \
0961                 $(INSTALL) examples/bpf/*.c -m 644 -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
0962 endif
0963         $(call QUIET_INSTALL, perf-archive) \
0964                 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
0965         $(call QUIET_INSTALL, perf-iostat) \
0966                 $(INSTALL) $(OUTPUT)perf-iostat -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
0967 ifndef NO_LIBAUDIT
0968         $(call QUIET_INSTALL, strace/groups) \
0969                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'; \
0970                 $(INSTALL) trace/strace/groups/* -m 644 -t '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'
0971 endif
0972 ifndef NO_LIBPERL
0973         $(call QUIET_INSTALL, perl-scripts) \
0974                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
0975                 $(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'; \
0976                 $(INSTALL) scripts/perl/*.pl -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
0977                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
0978                 $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
0979 endif
0980 ifndef NO_LIBPYTHON
0981         $(call QUIET_INSTALL, python-scripts) \
0982                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
0983                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
0984                 $(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'; \
0985                 $(INSTALL) scripts/python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
0986                 $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
0987 endif
0988         $(call QUIET_INSTALL, dlfilters) \
0989                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/dlfilters'; \
0990                 $(INSTALL) $(DLFILTERS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/dlfilters';
0991         $(call QUIET_INSTALL, perf_completion-script) \
0992                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
0993                 $(INSTALL) perf-completion.sh -m 644 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
0994         $(call QUIET_INSTALL, perf-tip) \
0995                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
0996                 $(INSTALL) Documentation/tips.txt -m 644 -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
0997 
0998 install-tests: all install-gtk
0999         $(call QUIET_INSTALL, tests) \
1000                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
1001                 $(INSTALL) tests/attr.py -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
1002                 $(INSTALL) tests/pe-file.exe* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
1003                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
1004                 $(INSTALL) tests/attr/* -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
1005                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
1006                 $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
1007                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
1008                 $(INSTALL) tests/shell/lib/*.sh -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
1009                 $(INSTALL) tests/shell/lib/*.py -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
1010 
1011 install-bin: install-tools install-tests install-traceevent-plugins
1012 
1013 install: install-bin try-install-man
1014 
1015 install-python_ext:
1016         $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
1017 
1018 # 'make install-doc' should call 'make -C Documentation install'
1019 $(INSTALL_DOC_TARGETS):
1020         $(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:-doc=) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
1021 
1022 ### Cleaning rules
1023 
1024 python-clean:
1025         $(python-clean)
1026 
1027 SKEL_OUT := $(abspath $(OUTPUT)util/bpf_skel)
1028 SKEL_TMP_OUT := $(abspath $(SKEL_OUT)/.tmp)
1029 SKELETONS := $(SKEL_OUT)/bpf_prog_profiler.skel.h
1030 SKELETONS += $(SKEL_OUT)/bperf_leader.skel.h $(SKEL_OUT)/bperf_follower.skel.h
1031 SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h $(SKEL_OUT)/func_latency.skel.h
1032 SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h
1033 SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h
1034 
1035 $(SKEL_TMP_OUT) $(LIBBPF_OUTPUT):
1036         $(Q)$(MKDIR) -p $@
1037 
1038 ifdef BUILD_BPF_SKEL
1039 BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool
1040 BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE)
1041 
1042 $(BPFTOOL): | $(SKEL_TMP_OUT)
1043         $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \
1044                 OUTPUT=$(SKEL_TMP_OUT)/ bootstrap
1045 
1046 VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux)                            \
1047                      $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)    \
1048                      ../../vmlinux                                      \
1049                      /sys/kernel/btf/vmlinux                            \
1050                      /boot/vmlinux-$(shell uname -r)
1051 VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
1052 
1053 $(SKEL_OUT)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL)
1054 ifeq ($(VMLINUX_H),)
1055         $(QUIET_GEN)$(BPFTOOL) btf dump file $< format c > $@
1056 else
1057         $(Q)cp "$(VMLINUX_H)" $@
1058 endif
1059 
1060 $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h | $(SKEL_TMP_OUT)
1061         $(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -Wall -Werror $(BPF_INCLUDE) \
1062           -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ && $(LLVM_STRIP) -g $@
1063 
1064 $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
1065         $(QUIET_GENSKEL)$(BPFTOOL) gen skeleton $< > $@
1066 
1067 bpf-skel: $(SKELETONS)
1068 
1069 .PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o
1070 
1071 else # BUILD_BPF_SKEL
1072 
1073 bpf-skel:
1074 
1075 endif # BUILD_BPF_SKEL
1076 
1077 bpf-skel-clean:
1078         $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)
1079 
1080 clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean
1081         $(call QUIET_CLEAN, core-objs)  $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS)
1082         $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
1083         $(Q)$(RM) $(OUTPUT).config-detected
1084         $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)$(LIBJVMTI).so
1085         $(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* \
1086                 $(OUTPUT)util/intel-pt-decoder/inat-tables.c \
1087                 $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
1088                 $(OUTPUT)pmu-events/pmu-events.c \
1089                 $(OUTPUT)$(fadvise_advice_array) \
1090                 $(OUTPUT)$(fsconfig_arrays) \
1091                 $(OUTPUT)$(fsmount_arrays) \
1092                 $(OUTPUT)$(fspick_arrays) \
1093                 $(OUTPUT)$(madvise_behavior_array) \
1094                 $(OUTPUT)$(mmap_flags_array) \
1095                 $(OUTPUT)$(mmap_prot_array) \
1096                 $(OUTPUT)$(mremap_flags_array) \
1097                 $(OUTPUT)$(mount_flags_array) \
1098                 $(OUTPUT)$(move_mount_flags_array) \
1099                 $(OUTPUT)$(drm_ioctl_array) \
1100                 $(OUTPUT)$(pkey_alloc_access_rights_array) \
1101                 $(OUTPUT)$(sndrv_ctl_ioctl_array) \
1102                 $(OUTPUT)$(sndrv_pcm_ioctl_array) \
1103                 $(OUTPUT)$(kvm_ioctl_array) \
1104                 $(OUTPUT)$(kcmp_type_array) \
1105                 $(OUTPUT)$(socket_arrays) \
1106                 $(OUTPUT)$(sockaddr_arrays) \
1107                 $(OUTPUT)$(vhost_virtio_ioctl_array) \
1108                 $(OUTPUT)$(perf_ioctl_array) \
1109                 $(OUTPUT)$(prctl_option_array) \
1110                 $(OUTPUT)$(usbdevfs_ioctl_array) \
1111                 $(OUTPUT)$(x86_arch_irq_vectors_array) \
1112                 $(OUTPUT)$(x86_arch_MSRs_array) \
1113                 $(OUTPUT)$(x86_arch_prctl_code_array) \
1114                 $(OUTPUT)$(rename_flags_array) \
1115                 $(OUTPUT)$(arch_errno_name_array) \
1116                 $(OUTPUT)$(sync_file_range_arrays)
1117         $(call QUIET_CLEAN, Documentation) \
1118         $(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null
1119 
1120 #
1121 # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
1122 # file if defined, with no further action.
1123 feature-dump:
1124 ifdef FEATURE_DUMP_COPY
1125         @cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY)
1126         @echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)"
1127 else
1128         @echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP"
1129 endif
1130 
1131 
1132 FORCE:
1133 
1134 .PHONY: all install clean config-clean strip install-gtk
1135 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
1136 .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare
1137 .PHONY: libtraceevent_plugins archheaders
1138 
1139 endif # force_fixdep