769 lines · 24.3 KB · Text
RawDownload
include ../scripts/Makefile.include # 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 NO_LIBPERL to disable 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 NO_DWARF if you do not want debug-info analysis feature at all.## Define WERROR=0 to disable treating any warnings as errors.## Define NO_NEWT if you do not want TUI support. (deprecated)## Define NO_SLANG if you do not want TUI support.## Define NO_GTK2 if you do not 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 NO_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_LIBAUDIT if you do not want libaudit support## Define NO_LIBBIONIC if you do not want bionic support## Define NO_LIBCRYPTO if you do not want libcrypto (openssl) support# used for generating build-ids for ELFs generated by jitdump.## Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support# for dwarf backtrace post unwind.## 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 LIBBABELTRACE if you DO want libbabeltrace support# for CTF data format.## Define NO_LZMA if you do not want to support compressed (xz) kernel modules## Define NO_AUXTRACE if you do not want AUX area tracing support## 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 LIBCLANGLLVM if you DO want builtin clang and llvm support.# When selected, pass LLVM_CONFIG=/path/to/llvm-config to `make' if# llvm-config is not in $PATH. # 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 VPATHendif ifeq ($(V),1)  Q =else  Q = @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 # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.$(call allow-override,CC,$(CROSS_COMPILE)gcc)$(call allow-override,AR,$(CROSS_COMPILE)ar)$(call allow-override,LD,$(CROSS_COMPILE)ld)$(call allow-override,CXX,$(CROSS_COMPILE)g++) LD += $(EXTRA_LDFLAGS) HOSTCC  ?= gccHOSTLD  ?= ldHOSTAR  ?= ar PKG_CONFIG = $(CROSS_COMPILE)pkg-configLLVM_CONFIG ?= llvm-config RM      = rm -fLN      = ln -fMKDIR   = mkdirFIND    = findINSTALL = installFLEX    = flexBISON   = bisonSTRIP   = stripAWK     = awk # include Makefile.config by default and rule out# non-config casesconfig := 1 NON_CONFIG_TARGETS := clean TAGS tags cscope help install-doc install-man install-html install-info install-pdf doc man html info pdf ifdef MAKECMDGOALSifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)  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=1 variable.## The fixdep build is disabled for $(NON_CONFIG_TARGETS)# targets, because it's not necessary. ifdef FIXDEP  force_fixdep := 0else  force_fixdep := $(config)endif export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWKexport HOSTCC HOSTLD HOSTAR include $(srctree)/tools/build/Makefile.include ifeq ($(force_fixdep),1)goals := $(filter-out all sub-make, $(MAKECMDGOALS)) $(goals) all: sub-make sub-make: fixdep	@./check-headers.sh	$(Q)$(MAKE) FIXDEP=1 -f Makefile.perf $(goals) else # force_fixdep LIB_DIR         = $(srctree)/tools/lib/api/TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/BPF_DIR         = $(srctree)/tools/lib/bpf/SUBCMD_DIR      = $(srctree)/tools/lib/subcmd/ # 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 := $(FEATURES_DUMP)endif export prefix bindir sharedir sysconfdir DESTDIR # 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-with-kcore.sh grep-libs = $(filter -l%,$(1))strip-libs = $(filter-out -l%,$(1)) ifneq ($(OUTPUT),)  TE_PATH=$(OUTPUT)  BPF_PATH=$(OUTPUT)  SUBCMD_PATH=$(OUTPUT)ifneq ($(subdir),)  API_PATH=$(OUTPUT)/../lib/api/else  API_PATH=$(OUTPUT)endifelse  TE_PATH=$(TRACE_EVENT_DIR)  API_PATH=$(LIB_DIR)  BPF_PATH=$(BPF_DIR)  SUBCMD_PATH=$(SUBCMD_DIR)endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.aexport LIBTRACEEVENT LIBTRACEEVENT_DYNAMIC_LIST = $(TE_PATH)libtraceevent-dynamic-listLIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST) LIBAPI = $(API_PATH)libapi.aexport LIBAPI LIBBPF = $(BPF_PATH)libbpf.a LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a # 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 PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI) SCRIPTS = $(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 # what 'all' will build and 'install' will install, in perfexecdirALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) # 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 LIB_FILE=$(OUTPUT)libperf.a PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD)ifndef NO_LIBBPF  PERFLIBS += $(LIBBPF)endif # 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 ifndef NO_GTK2  ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so  GTK_IN := $(OUTPUT)gtk-in.oendif ifdef ASCIIDOC8  export ASCIIDOC8endif LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group ifeq ($(USE_CLANG), 1)  CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization  LIBCLANG = $(foreach l,$(CLANGLIBS_LIST),$(wildcard $(shell $(LLVM_CONFIG) --libdir)/libclang$(l).a))  LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-groupendif ifeq ($(USE_LLVM), 1)  LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)  LIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)endif ifeq ($(USE_CXX), 1)  LIBS += -lstdc++endif export INSTALL SHELL_PATH ### Build rules SHELL = $(SHELL_PATH) all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \        CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \	  $(PYTHON_WORD) util/setup.py \	  --quiet build_ext; \	mkdir -p $(OUTPUT)python && \	cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/ please_set_SHELL_PATH_to_a_more_modern_shell:	$(Q)$$(:) shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell strip: $(PROGRAMS) $(OUTPUT)perf	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf PERF_IN := $(OUTPUT)perf-in.o JEVENTS       := $(OUTPUT)pmu-events/jeventsJEVENTS_IN    := $(OUTPUT)pmu-events/jevents-in.o PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o export JEVENTS build := -f $(srctree)/tools/build/Makefile.build dir=. obj $(PERF_IN): prepare FORCE	$(Q)$(MAKE) $(build)=perf $(JEVENTS_IN): FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=jevents $(JEVENTS): $(JEVENTS_IN)	$(QUIET_LINK)$(HOSTCC) $(JEVENTS_IN) -o $@ $(PMU_EVENTS_IN): $(JEVENTS) FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \		$(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@ $(GTK_IN): FORCE	$(Q)$(MAKE) $(build)=gtk $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)	$(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS) $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@ $(SCRIPTS) : % : %.sh	$(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@' $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD	$(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)	$(Q)touch $(OUTPUT)PERF-VERSION-FILE # These can record PERF_VERSIONperf.spec $(SCRIPTS) \	: $(OUTPUT)PERF-VERSION-FILE .SUFFIXES: ## If a target does not match any of the later rules then prefix it by $(OUTPUT)# This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.#ifneq ($(OUTPUT),)%.o: $(OUTPUT)%.o	@echo "    # Redirected target $@ => $(OUTPUT)$@"pmu-events/%.o: $(OUTPUT)pmu-events/%.o	@echo "    # Redirected target $@ => $(OUTPUT)$@"util/%.o: $(OUTPUT)util/%.o	@echo "    # Redirected target $@ => $(OUTPUT)$@"bench/%.o: $(OUTPUT)bench/%.o	@echo "    # Redirected target $@ => $(OUTPUT)$@"tests/%.o: $(OUTPUT)tests/%.o	@echo "    # Redirected target $@ => $(OUTPUT)$@"endif # These two need to be here so that when O= is not used they take precedence# over the general rule for .o # get relative building directory (to $(OUTPUT))# and '.' if it's $(OUTPUT) itself__build-dir = $(subst $(OUTPUT),,$(dir $@))build-dir   = $(if $(__build-dir),$(__build-dir),.) prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(OUTPUT)%.o: %.c prepare FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ $(OUTPUT)%.i: %.c prepare FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ $(OUTPUT)%.s: %.c prepare FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ $(OUTPUT)%-bison.o: %.c prepare FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ $(OUTPUT)%-flex.o: %.c prepare FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ $(OUTPUT)%.o: %.S prepare FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ $(OUTPUT)%.i: %.S prepare FORCE	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ $(OUTPUT)perf-%: %.o $(PERFLIBS)	$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS) ifndef NO_PERF_READ_VDSO32$(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-vdso-map.c	$(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c

Lines 1–500 of 769.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t