986 lines · 33.3 KB · Text
RawDownload
# SPDX-License-Identifier: GPL-2.0-onlyinclude ../scripts/Makefile.includeinclude ../scripts/Makefile.arch # The default target of this Makefile is...all: include ../scripts/utilities.mak # Define V to have a more verbose compile.## Define VF to have a more verbose feature check output.## Define O to save output files in a separate directory.## Define ARCH as name of target architecture if you want cross-builds.## Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.## Define LIBPERL to enable perl script extension.## Define NO_LIBPYTHON to disable python script extension.## Define PYTHON to point to the python binary if the default# `python' is not correct; for example: PYTHON=python2## Define PYTHON_CONFIG to point to the python-config binary if# the default `$(PYTHON)-config' is not correct.## Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8## Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.## Define LDFLAGS=-static to build a static binary.## Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.## Define EXTRA_BPF_FLAGS="--sysroot=<path>" or other custom include paths for# cross-compiling BPF skeletons## Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated# EXTLIBS.## Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.## Define NO_LIBDW if you do not want debug-info analysis feature at all.## Define WERROR=0 to disable treating any warnings as errors.## Define NO_SLANG if you do not want TUI support.## Define GTK2 if you want GTK+ GUI support.## Define NO_DEMANGLE if you do not want C++ symbol demangling.## Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)## Define LIBUNWIND if you do not want libunwind dependency for dwarf# backtrace post unwind.## Define NO_BACKTRACE if you do not want stack backtrace debug feature## Define NO_LIBNUMA if you do not want numa perf benchmark## Define NO_LIBBIONIC if you do not want bionic support## Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support# for dwarf backtrace post unwind.## Define NO_LIBTRACEEVENT=1 if you don't want libtraceevent to be linked,# this will remove multiple features and tools, such as 'perf trace',# that need it to read tracefs event format files, etc.## Define NO_PERF_READ_VDSO32 if you do not want to build perf-read-vdso32# for reading the 32-bit compatibility VDSO in 64-bit mode## Define NO_PERF_READ_VDSOX32 if you do not want to build perf-read-vdsox32# for reading the x32 mode 32-bit compatibility VDSO in 64-bit mode## Define NO_ZLIB if you do not want to support compressed kernel modules## Define NO_BABELTRACE2 if you do not want babeltrace2-ctf-writer support# for CTF data format.## Define NO_CAPSTONE if you do not want libcapstone support# for disasm engine.## Define NO_LZMA if you do not want to support compressed (xz) kernel modules## Define NO_LIBBPF if you do not want BPF support## Define NO_SDT if you do not want to define SDT event in perf tools,# note that it doesn't disable SDT scanning support.## Define FEATURES_DUMP to provide features detection dump file# and bypass the feature detection## Define NO_JVMTI if you do not want jvmti agent built## Define NO_JVMTI_CMLR (debug only) if you do not want to process CMLR# data for java source lines.## Define CORESIGHT if you DO WANT support for CoreSight trace decoding.## Define NO_AIO if you do not want support of Posix AIO based trace# streaming for record mode. Currently Posix AIO trace streaming is# supported only when linking with glibc.## Define NO_LIBZSTD if you do not want support of Zstandard based runtime# trace compression in record mode.## Define TCMALLOC to enable tcmalloc heap profiling.## Define LIBBPF_DYNAMIC to enable libbpf dynamic linking.## Define NO_LIBPFM4 to disable libpfm4 events extension.## Define NO_LIBDEBUGINFOD if you do not want support debuginfod## Set BUILD_BPF_SKEL to 0 to override BUILD_BPF_SKEL and not build BPF skeletons## Define BUILD_NONDISTRO to enable building an linking against libbfd and# libiberty distribution license incompatible libraries.## Define EXTRA_TESTS to enable building extra tests useful mainly to perf# developers, such as:#	x86 instruction decoder - new instructions test## Define GEN_VMLINUX_H to generate vmlinux.h from the BTF.## Define NO_SHELLCHECK if you do not want to run shellcheck during build # As per kernel Makefile, avoid funny character set dependenciesunexport LC_ALLLC_COLLATE=CLC_NUMERIC=Cexport LC_COLLATE LC_NUMERIC ifeq ($(srctree),)srctree := $(patsubst %/,%,$(dir $(CURDIR)))srctree := $(patsubst %/,%,$(dir $(srctree)))#$(info Determined 'srctree' to be $(srctree))endif ifneq ($(objtree),)#$(info Determined 'objtree' to be $(objtree))endif ifneq ($(OUTPUT),)#$(info Determined 'OUTPUT' to be $(OUTPUT))# Adding $(OUTPUT) as a directory to look for source files,# because use generated output files as sources dependency# for flex/bison parsers.VPATH += $(OUTPUT)export VPATH# create symlink to the original sourceSOURCE := $(shell ln -sfn $(srctree)/tools/perf $(OUTPUT)/source)endif # Do not use make's built-in rules# (this improves performance and avoids hard-to-debug behaviour);MAKEFLAGS += -r # Makefiles suck: This macro sets a default value of $(2) for the# variable named by $(1), unless the variable has been set by# environment or command line. This is necessary for CC and AR# because make sets default values, so the simpler ?= approach# won't work as expected.define allow-override  $(if $(or $(findstring environment,$(origin $(1))),\            $(findstring command line,$(origin $(1)))),,\    $(eval $(1) = $(2)))endef LD += $(EXTRA_LDFLAGS) # Some distros provide the command $(CROSS_COMPILE)pkg-config for# searching packges installed with Multiarch. Use it for cross# compilation if it is existed.ifneq (, $(shell command -v $(CROSS_COMPILE)pkg-config 2>/dev/null))  PKG_CONFIG ?= $(CROSS_COMPILE)pkg-configelse  PKG_CONFIG ?= pkg-config   # PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR  # for modified system root, is required for the cross compilation.  # If these PKG_CONFIG environment variables are not set, Multiarch library  # paths are used instead.  ifdef CROSS_COMPILE    ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),)      CROSS_ARCH = $(notdir $(CROSS_COMPILE:%-=%))      PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/      PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/      export PKG_CONFIG_LIBDIR      $(warning Missing PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH and PKG_CONFIG_SYSROOT_DIR for cross compilation,)      $(warning set PKG_CONFIG_LIBDIR for using Multiarch libs.)    endif  endifendif RM      = rm -fLN      = ln -fMKDIR   = mkdirFIND    = findINSTALL = installFLEX    ?= flexBISON   ?= bisonAWK     = awk # include Makefile.config by default and rule out# non-config casesconfig := 1 # install-build-deps runs the install-build-deps.sh script, which# derives the package list from the feature test sources in# tools/build/feature/, so it needs neither the fixdep build nor a# config/feature detection pass: in a fresh container without gcc or# pkg-config those would fail before the script could install them.NON_CONFIG_TARGETS := clean python-clean TAGS tags cscope help install-build-deps ifdef MAKECMDGOALSifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)  VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h  config := 0endifendif # The fixdep build - we force fixdep tool to be built as# the first target in the separate make session not to be# disturbed by any parallel make jobs. Once fixdep is done# we issue the requested build with FIXDEP_BUILT=1 variable.## The fixdep build is disabled for $(NON_CONFIG_TARGETS)# targets, because it's not necessary. ifdef FIXDEP_BUILT  force_fixdep := 0else  force_fixdep := $(config)endif # Runs shellcheck on perf shell scriptsifeq ($(NO_SHELLCHECK),1)  SHELLCHECK :=else  SHELLCHECK := $(shell which shellcheck 2> /dev/null)endif # shellcheck is using in tools/perf/tests/Build with option -a/--check-sourced (# introduced in v0.4.7) and -S/--severity (introduced in v0.6.0) as well as# dynamic source inclusions (properly handled since v0.7.2).# So make the minimal shellcheck version as v0.7.2.ifneq ($(SHELLCHECK),)  ifeq ($(shell expr $(shell $(SHELLCHECK) --version | grep version: | \        sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \< 072), 1)    SHELLCHECK :=  else    SHELLCHECK := $(SHELLCHECK) -s bash -a -S warning  endifendif # Runs mypy on perf python filesifeq ($(MYPY),1)  MYPY := $(shell which mypy 2> /dev/null)endif # Runs pylint on perf python filesifeq ($(PYLINT),1)  PYLINT := $(shell which pylint 2> /dev/null)endif export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF READELFexport HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT CONFIG_PERF_BPF_SKEL include $(srctree)/tools/build/Makefile.include ifeq ($(force_fixdep),1)goals := $(filter-out all sub-make, $(MAKECMDGOALS)) $(goals) all: sub-make sub-make: fixdep	$(Q)$(MAKE) FIXDEP_BUILT=1 -f Makefile.perf $(goals) else # force_fixdep LIBAPI_DIR      = $(srctree)/tools/lib/api/LIBBPF_DIR      = $(srctree)/tools/lib/bpf/LIBSUBCMD_DIR   = $(srctree)/tools/lib/subcmd/LIBSYMBOL_DIR   = $(srctree)/tools/lib/symbol/LIBPERF_DIR     = $(srctree)/tools/lib/perf/DOC_DIR         = $(srctree)/tools/perf/Documentation/ # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.# Without this setting the output feature dump file misses some features, for# example, liberty. Select all checkers so we won't get an incomplete feature# dump file.ifeq ($(config),1)ifdef MAKECMDGOALSifeq ($(filter feature-dump,$(MAKECMDGOALS)),feature-dump)FEATURE_TESTS := allendifendifinclude Makefile.configendif ifeq ($(config),0)include $(srctree)/tools/scripts/Makefile.arch-include arch/$(SRCARCH)/Makefileendif # The FEATURE_DUMP_EXPORT holds location of the actual# FEATURE_DUMP file to be used to bypass feature detection# (for bpf or any other subproject)ifeq ($(FEATURES_DUMP),)FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)elseFEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP))endif export prefix bindir sharedir sysconfdir DESTDIR VMLINUX_H_FILE # sparse is architecture-neutral, which means that we need to tell it# explicitly what architecture to check for. Fix this up for yours..SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ # Guard against environment variablesPYRF_OBJS =SCRIPT_SH = SCRIPT_SH += perf-archive.shSCRIPT_SH += perf-iostat.sh grep-libs = $(filter -l%,$(1))strip-libs = $(filter-out -l%,$(1)) ifneq ($(OUTPUT),)  LIBAPI_OUTPUT = $(abspath $(OUTPUT))/libapielse  LIBAPI_OUTPUT = $(CURDIR)/libapiendifLIBAPI_DESTDIR = $(LIBAPI_OUTPUT)LIBAPI_INCLUDE = $(LIBAPI_DESTDIR)/includeLIBAPI = $(LIBAPI_OUTPUT)/libapi.aexport LIBAPICFLAGS += -I$(LIBAPI_OUTPUT)/include ifneq ($(OUTPUT),)  LIBBPF_OUTPUT = $(abspath $(OUTPUT))/libbpfelse  LIBBPF_OUTPUT = $(CURDIR)/libbpfendififdef LIBBPF_STATIC  LIBBPF_DESTDIR = $(LIBBPF_OUTPUT)  LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include  LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a  CFLAGS += -I$(LIBBPF_OUTPUT)/includeendif ifneq ($(OUTPUT),)  LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmdelse  LIBSUBCMD_OUTPUT = $(CURDIR)/libsubcmdendifLIBSUBCMD_DESTDIR = $(LIBSUBCMD_OUTPUT)LIBSUBCMD_INCLUDE = $(LIBSUBCMD_DESTDIR)/includeLIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.aCFLAGS += -I$(LIBSUBCMD_OUTPUT)/include ifneq ($(OUTPUT),)  LIBSYMBOL_OUTPUT = $(abspath $(OUTPUT))/libsymbolelse  LIBSYMBOL_OUTPUT = $(CURDIR)/libsymbolendifLIBSYMBOL_DESTDIR = $(LIBSYMBOL_OUTPUT)LIBSYMBOL_INCLUDE = $(LIBSYMBOL_DESTDIR)/includeLIBSYMBOL = $(LIBSYMBOL_OUTPUT)/libsymbol.aCFLAGS += -I$(LIBSYMBOL_OUTPUT)/include ifneq ($(OUTPUT),)  LIBPERF_OUTPUT = $(abspath $(OUTPUT))/libperfelse  LIBPERF_OUTPUT = $(CURDIR)/libperfendifLIBPERF_DESTDIR = $(LIBPERF_OUTPUT)LIBPERF_INCLUDE = $(LIBPERF_DESTDIR)/includeLIBPERF = $(LIBPERF_OUTPUT)/libperf.aexport LIBPERFCFLAGS += -I$(LIBPERF_OUTPUT)/include # python extension build directoriesPYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so ifneq ($(quiet),)python_setup_quiet=--quietendif # Use the detected configuration-include $(OUTPUT).config-detected SCRIPTS = $(addprefix $(OUTPUT),$(patsubst %.sh,%,$(SCRIPT_SH))) PROGRAMS += $(OUTPUT)perf ifndef NO_PERF_READ_VDSO32PROGRAMS += $(OUTPUT)perf-read-vdso32endif ifndef NO_PERF_READ_VDSOX32PROGRAMS += $(OUTPUT)perf-read-vdsox32endif LIBJVMTI = libperf-jvmti.so ifndef NO_JVMTIPROGRAMS += $(OUTPUT)$(LIBJVMTI)endif DLFILTERS := dlfilter-test-api-v0.so dlfilter-test-api-v2.so dlfilter-show-cycles.soDLFILTERS := $(patsubst %,$(OUTPUT)dlfilters/%,$(DLFILTERS)) # what 'all' will build and 'install' will install, in perfexecdirALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) $(DLFILTERS) # what 'all' will build but not install in perfexecdirOTHER_PROGRAMS = $(OUTPUT)perf # Set paths to tools early so that they can be used for version tests.ifndef SHELL_PATH  SHELL_PATH = /bin/shendififndef PERL_PATH  PERL_PATH = /usr/bin/perlendif export PERL_PATH LIBPERF_BENCH_IN := $(OUTPUT)perf-bench-in.oLIBPERF_BENCH := $(OUTPUT)libperf-bench.a LIBPERF_TEST_IN := $(OUTPUT)perf-test-in.oLIBPERF_TEST := $(OUTPUT)libperf-test.a LIBPERF_UI_IN := $(OUTPUT)perf-ui-in.oLIBPERF_UI := $(OUTPUT)libperf-ui.a LIBPERF_UTIL_IN := $(OUTPUT)perf-util-in.oLIBPERF_UTIL := $(OUTPUT)libperf-util.a LIBPMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.oLIBPMU_EVENTS := $(OUTPUT)libpmu-events.a PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL)ifdef LIBBPF_STATIC  PERFLIBS += $(LIBBPF)endifPERFLIBS += $(LIBPERF_BENCH) $(LIBPERF_TEST) $(LIBPERF_UI) $(LIBPERF_UTIL)PERFLIBS += $(LIBPMU_EVENTS) # We choose to avoid "if .. else if .. else .. endif endif"# because maintaining the nesting to match is a pain.  If# we had "elif" things would have been much nicer... ifneq ($(OUTPUT),)  CFLAGS += -I$(OUTPUT)endif ifdef GTK2  ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so  GTK_IN := $(OUTPUT)gtk-in.oendif ifdef ASCIIDOC8  export ASCIIDOC8endif EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group PERFLIBS_PY := $(call filter-out,$(LIBPERF_BENCH) $(LIBPERF_TEST),$(PERFLIBS))LIBS_PY = -Wl,--whole-archive $(PERFLIBS_PY) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group export INSTALL SHELL_PATH ### Build rules SHELL = $(SHELL_PATH) arm64_gen_sysreg_dir := $(srctree)/tools/arch/arm64/toolsifneq ($(OUTPUT),)  arm64_gen_sysreg_outdir := $(abspath $(OUTPUT))else

Lines 1–500 of 986.