1375 lines · plain
1# SPDX-License-Identifier: GPL-2.0-only2 3ifeq ($(src-perf),)4src-perf := $(srctree)/tools/perf5endif6 7ifeq ($(obj-perf),)8obj-perf := $(OUTPUT)9endif10 11ifneq ($(obj-perf),)12obj-perf := $(abspath $(obj-perf))/13endif14 15$(shell printf "" > $(OUTPUT).config-detected)16detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)17detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)18 19CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))20HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))21 22# Enabled Wthread-safety analysis for clang builds.23ifeq ($(CC_NO_CLANG), 0)24 CFLAGS += -Wthread-safety25endif26 27include $(srctree)/tools/scripts/Makefile.arch28 29$(call detected_var,SRCARCH)30 31ifneq ($(NO_SYSCALL_TABLE),1)32 NO_SYSCALL_TABLE := 133 34 ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch))35 NO_SYSCALL_TABLE := 036 endif37 38 ifneq ($(NO_SYSCALL_TABLE),1)39 CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT40 endif41endif42 43# Additional ARCH settings for ppc44ifeq ($(SRCARCH),powerpc)45 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated46 LIBUNWIND_LIBS := -lunwind -lunwind-ppc6447endif48 49# Additional ARCH settings for x8650ifeq ($(SRCARCH),x86)51 $(call detected,CONFIG_X86)52 CFLAGS += -I$(OUTPUT)arch/x86/include/generated53 ifeq (${IS_64_BIT}, 1)54 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT55 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S56 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma57 $(call detected,CONFIG_X86_64)58 else59 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind60 endif61endif62 63ifeq ($(SRCARCH),arm)64 LIBUNWIND_LIBS = -lunwind -lunwind-arm65endif66 67ifeq ($(SRCARCH),arm64)68 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated69 LIBUNWIND_LIBS = -lunwind -lunwind-aarch6470endif71 72ifeq ($(SRCARCH),loongarch)73 CFLAGS += -I$(OUTPUT)arch/loongarch/include/generated74 LIBUNWIND_LIBS = -lunwind -lunwind-loongarch6475endif76 77ifeq ($(ARCH),s390)78 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated79endif80 81ifeq ($(ARCH),mips)82 CFLAGS += -I$(OUTPUT)arch/mips/include/generated83 LIBUNWIND_LIBS = -lunwind -lunwind-mips84endif85 86# So far there's only x86 and arm libdw unwind support merged in perf.87# Disable it on all other architectures in case libdw unwind88# support is detected in system. Add supported architectures89# to the check.90ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv loongarch))91 NO_LIBDW_DWARF_UNWIND := 192endif93 94ifeq ($(LIBUNWIND_LIBS),)95 NO_LIBUNWIND := 196endif97#98# For linking with debug library, run like:99#100# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/101#102 103libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))104define libunwind_arch_set_flags_code105 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include106 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib107endef108 109ifdef LIBUNWIND_DIR110 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include111 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib112 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 loongarch113 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))114endif115 116# Set per-feature check compilation flags117FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)118FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)119FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)120FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)121 122FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm123FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64124FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86125FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64126 127FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto128 129ifdef CSINCLUDES130 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)131endif132OPENCSDLIBS := -lopencsd_c_api -lopencsd133ifeq ($(findstring -static,${LDFLAGS}),-static)134 OPENCSDLIBS += -lstdc++135endif136ifdef CSLIBS137 LIBOPENCSD_LDFLAGS := -L$(CSLIBS)138endif139FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)140FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)141 142# for linking with debug library, run like:143# make DEBUG=1 LIBDW_DIR=/opt/libdw/144ifdef LIBDW_DIR145 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include146 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib147endif148DWARFLIBS := -ldw149ifeq ($(findstring -static,${LDFLAGS}),-static)150 DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd151 152 LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0153 LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))154 LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))155 156 # Elfutils merged libebl.a into libdw.a starting from version 0.177,157 # Link libebl.a only if libdw is older than this version.158 ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)159 DWARFLIBS += -lebl160 endif161 162 # Must put -ldl after -lebl for dependency163 DWARFLIBS += -ldl164endif165FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)166FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)167 168# for linking with debug library, run like:169# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/170ifdef LIBBABELTRACE_DIR171 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include172 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib173endif174FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)175FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf176 177# for linking with debug library, run like:178# make DEBUG=1 LIBCAPSTONE_DIR=/opt/capstone/179ifdef LIBCAPSTONE_DIR180 LIBCAPSTONE_CFLAGS := -I$(LIBCAPSTONE_DIR)/include181 LIBCAPSTONE_LDFLAGS := -L$(LIBCAPSTONE_DIR)/182endif183FEATURE_CHECK_CFLAGS-libcapstone := $(LIBCAPSTONE_CFLAGS)184FEATURE_CHECK_LDFLAGS-libcapstone := $(LIBCAPSTONE_LDFLAGS) -lcapstone185 186ifdef LIBZSTD_DIR187 LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib188 LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib189endif190FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)191FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)192 193# for linking with debug library, run like:194# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig195 196ifneq ($(NO_LIBTRACEEVENT),1)197 ifeq ($(call get-executable,$(PKG_CONFIG)),)198 $(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)199 endif200endif201 202FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi203# include ARCH specific config204-include $(src-perf)/arch/$(SRCARCH)/Makefile205 206ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET207 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET208endif209 210include $(srctree)/tools/scripts/utilities.mak211 212ifeq ($(call get-executable,$(FLEX)),)213 $(error Error: $(FLEX) is missing on this system, please install it)214endif215 216ifeq ($(call get-executable,$(BISON)),)217 $(error Error: $(BISON) is missing on this system, please install it)218endif219 220ifneq ($(OUTPUT),)221 ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1)222 BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)=223 endif224endif225 226# Treat warnings as errors unless directed not to227ifneq ($(WERROR),0)228 CORE_CFLAGS += -Werror229 CXXFLAGS += -Werror230 HOSTCFLAGS += -Werror231endif232 233ifndef DEBUG234 DEBUG := 0235endif236 237ifeq ($(DEBUG),0)238CORE_CFLAGS += -DNDEBUG=1239CORE_CFLAGS += -O3240else241 CORE_CFLAGS += -g242 CXXFLAGS += -g243endif244 245ifdef PARSER_DEBUG246 PARSER_DEBUG_BISON := -t247 PARSER_DEBUG_FLEX := -d248 CFLAGS += -DPARSER_DEBUG249 $(call detected_var,PARSER_DEBUG_BISON)250 $(call detected_var,PARSER_DEBUG_FLEX)251endif252 253ifdef LTO254 CORE_CFLAGS += -flto255 CXXFLAGS += -flto256endif257 258# Try different combinations to accommodate systems that only have259# python[2][3]-config in weird combinations in the following order of260# priority from lowest to highest:261# * python2-config as per pep-0394.262# * python-config263# * python3-config264# * $(PYTHON)-config (If PYTHON is user supplied but PYTHON_CONFIG isn't)265#266PYTHON_AUTO := python-config267PYTHON_AUTO := $(if $(call get-executable,python2-config),python2-config,$(PYTHON_AUTO))268PYTHON_AUTO := $(if $(call get-executable,python-config),python-config,$(PYTHON_AUTO))269PYTHON_AUTO := $(if $(call get-executable,python3-config),python3-config,$(PYTHON_AUTO))270 271# If PYTHON is defined but PYTHON_CONFIG isn't, then take $(PYTHON)-config as if it was the user272# supplied value for PYTHON_CONFIG. Because it's "user supplied", error out if it doesn't exist.273ifdef PYTHON274 ifndef PYTHON_CONFIG275 PYTHON_CONFIG_AUTO := $(call get-executable,$(PYTHON)-config)276 PYTHON_CONFIG := $(if $(PYTHON_CONFIG_AUTO),$(PYTHON_CONFIG_AUTO),\277 $(call $(error $(PYTHON)-config not found)))278 endif279endif280 281# Select either auto detected python and python-config or use user supplied values if they are282# defined. get-executable-or-default fails with an error if the first argument is supplied but283# doesn't exist.284override PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO))285override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_CONFIG)))286 287grep-libs = $(filter -l%,$(1))288strip-libs = $(filter-out -l%,$(1))289 290PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))291 292# Python 3.8 changed the output of `python-config --ldflags` to not include the293# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for294# libpython fails if that flag is not included in LDFLAGS295ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)296 PYTHON_CONFIG_LDFLAGS := --ldflags --embed297else298 PYTHON_CONFIG_LDFLAGS := --ldflags299endif300 301ifdef PYTHON_CONFIG302 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)303 # Update the python flags for cross compilation304 ifdef CROSS_COMPILE305 PYTHON_NATIVE := $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/\(-L.*\/\)\(.*-linux-gnu\).*/\2/')306 PYTHON_EMBED_LDOPTS := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EMBED_LDOPTS))307 endif308 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))309 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil310 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)311 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)312 ifeq ($(CC_NO_CLANG), 0)313 PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS))314 endif315endif316 317FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)318FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)319 320FEATURE_CHECK_LDFLAGS-libaio = -lrt321 322FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl323FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl324 325CORE_CFLAGS += -fno-omit-frame-pointer326CORE_CFLAGS += -Wall327CORE_CFLAGS += -Wextra328CORE_CFLAGS += -std=gnu11329 330CXXFLAGS += -std=gnu++17 -fno-exceptions -fno-rtti331CXXFLAGS += -Wall332CXXFLAGS += -Wextra333CXXFLAGS += -fno-omit-frame-pointer334 335HOSTCFLAGS += -Wall336HOSTCFLAGS += -Wextra337 338# Enforce a non-executable stack, as we may regress (again) in the future by339# adding assembler files missing the .GNU-stack linker note.340LDFLAGS += -Wl,-z,noexecstack341 342EXTLIBS = -lpthread -lrt -lm -ldl343 344ifneq ($(TCMALLOC),)345 CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free346 EXTLIBS += -ltcmalloc347endif348 349ifeq ($(FEATURES_DUMP),)350# We will display at the end of this Makefile.config, using $(call feature_display_entries)351# As we may retry some feature detection here, see the disassembler-four-args case, for instance352 FEATURE_DISPLAY_DEFERRED := 1353include $(srctree)/tools/build/Makefile.feature354else355include $(FEATURES_DUMP)356endif357 358ifeq ($(feature-stackprotector-all), 1)359 CORE_CFLAGS += -fstack-protector-all360endif361 362ifeq ($(DEBUG),0)363 ifeq ($(feature-fortify-source), 1)364 CORE_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2365 endif366endif367 368INC_FLAGS += -I$(src-perf)/util/include369INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include370INC_FLAGS += -I$(srctree)/tools/include/371INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi372INC_FLAGS += -I$(srctree)/tools/include/uapi373INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/374INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/375 376# $(obj-perf) for generated common-cmds.h377# $(obj-perf)/util for generated bison/flex headers378ifneq ($(OUTPUT),)379INC_FLAGS += -I$(obj-perf)/util380INC_FLAGS += -I$(obj-perf)381endif382 383INC_FLAGS += -I$(src-perf)/util384INC_FLAGS += -I$(src-perf)385 386CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE387 388CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)389CXXFLAGS += $(INC_FLAGS)390 391LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)392 393ifeq ($(feature-pthread-attr-setaffinity-np), 1)394 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP395endif396 397ifeq ($(feature-pthread-barrier), 1)398 CFLAGS += -DHAVE_PTHREAD_BARRIER399endif400 401ifndef NO_BIONIC402 $(call feature_check,bionic)403 ifeq ($(feature-bionic), 1)404 BIONIC := 1405 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE406 CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE407 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))408 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))409 endif410endif411 412ifeq ($(feature-eventfd), 1)413 CFLAGS += -DHAVE_EVENTFD_SUPPORT414endif415 416ifeq ($(feature-get_current_dir_name), 1)417 CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME418endif419 420ifeq ($(feature-gettid), 1)421 CFLAGS += -DHAVE_GETTID422endif423 424ifeq ($(feature-file-handle), 1)425 CFLAGS += -DHAVE_FILE_HANDLE426endif427 428ifdef NO_LIBELF429 NO_DWARF := 1430 NO_LIBUNWIND := 1431 NO_LIBDW_DWARF_UNWIND := 1432 NO_LIBBPF := 1433 NO_JVMTI := 1434else435 ifeq ($(feature-libelf), 0)436 ifeq ($(feature-glibc), 1)437 LIBC_SUPPORT := 1438 endif439 ifeq ($(BIONIC),1)440 LIBC_SUPPORT := 1441 endif442 ifeq ($(LIBC_SUPPORT),1)443 $(error ERROR: No libelf found. Disables 'probe' tool, jvmti and BPF support. Please install libelf-dev, libelf-devel, elfutils-libelf-devel or build with NO_LIBELF=1.)444 else445 ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)446 ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)447 $(error No libasan found, please install libasan)448 endif449 endif450 451 ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),)452 ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0)453 $(error No libubsan found, please install libubsan)454 endif455 endif456 457 ifneq ($(filter s% -static%,$(LDFLAGS),),)458 $(error No static glibc found, please install glibc-static)459 else460 $(error No gnu/libc-version.h found, please install glibc-dev[el])461 endif462 endif463 else464 ifndef NO_LIBDW_DWARF_UNWIND465 ifneq ($(feature-libdw-dwarf-unwind),1)466 NO_LIBDW_DWARF_UNWIND := 1467 $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR)468 endif469 endif470 ifneq ($(feature-dwarf), 1)471 ifndef NO_DWARF472 $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev)473 NO_DWARF := 1474 endif475 else476 ifneq ($(feature-dwarf_getlocations), 1)477 $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157)478 else479 CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT480 endif # dwarf_getlocations481 ifneq ($(feature-dwarf_getcfi), 1)482 $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.142)483 else484 CFLAGS += -DHAVE_DWARF_CFI_SUPPORT485 endif # dwarf_getcfi486 endif # Dwarf support487 endif # libelf support488endif # NO_LIBELF489 490ifeq ($(feature-libaio), 1)491 ifndef NO_AIO492 CFLAGS += -DHAVE_AIO_SUPPORT493 endif494endif495 496ifdef NO_DWARF497 NO_LIBDW_DWARF_UNWIND := 1498endif499 500ifeq ($(feature-scandirat), 1)501 # Ignore having scandirat with memory sanitizer that lacks an interceptor.502 ifeq ($(filter s% -fsanitize=memory%,$(EXTRA_CFLAGS),),)503 CFLAGS += -DHAVE_SCANDIRAT_SUPPORT504 endif505endif506 507ifeq ($(feature-sched_getcpu), 1)508 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT509endif510 511ifeq ($(feature-setns), 1)512 CFLAGS += -DHAVE_SETNS_SUPPORT513 $(call detected,CONFIG_SETNS)514endif515 516ifdef CORESIGHT517 $(call feature_check,libopencsd)518 ifeq ($(feature-libopencsd), 1)519 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)520 ifeq ($(feature-reallocarray), 0)521 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY522 endif523 LDFLAGS += $(LIBOPENCSD_LDFLAGS)524 EXTLIBS += $(OPENCSDLIBS)525 $(call detected,CONFIG_LIBOPENCSD)526 ifdef CSTRACE_RAW527 CFLAGS += -DCS_DEBUG_RAW528 ifeq (${CSTRACE_RAW}, packed)529 CFLAGS += -DCS_RAW_PACKED530 endif531 endif532 else533 $(error Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1)534 endif535endif536 537ifndef NO_ZLIB538 ifeq ($(feature-zlib), 1)539 CFLAGS += -DHAVE_ZLIB_SUPPORT540 EXTLIBS += -lz541 $(call detected,CONFIG_ZLIB)542 else543 NO_ZLIB := 1544 endif545endif546 547ifndef NO_LIBELF548 CFLAGS += -DHAVE_LIBELF_SUPPORT549 EXTLIBS += -lelf550 $(call detected,CONFIG_LIBELF)551 552 ifeq ($(feature-libelf-getphdrnum), 1)553 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT554 endif555 556 ifeq ($(feature-libelf-gelf_getnote), 1)557 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT558 else559 $(warning gelf_getnote() not found on libelf, SDT support disabled)560 endif561 562 ifeq ($(feature-libelf-getshdrstrndx), 1)563 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT564 endif565 566 ifndef NO_LIBDEBUGINFOD567 $(call feature_check,libdebuginfod)568 ifeq ($(feature-libdebuginfod), 1)569 CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT570 EXTLIBS += -ldebuginfod571 endif572 endif573 574 ifndef NO_DWARF575 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)576 $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled)577 NO_DWARF := 1578 else579 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)580 LDFLAGS += $(LIBDW_LDFLAGS)581 EXTLIBS += ${DWARFLIBS}582 $(call detected,CONFIG_DWARF)583 endif # PERF_HAVE_DWARF_REGS584 endif # NO_DWARF585 586 ifndef NO_LIBBPF587 ifeq ($(feature-bpf), 1)588 # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status589 $(call feature_check,libbpf)590 591 ifdef LIBBPF_DYNAMIC592 ifeq ($(feature-libbpf), 1)593 EXTLIBS += -lbpf594 CFLAGS += -DHAVE_LIBBPF_SUPPORT595 $(call detected,CONFIG_LIBBPF)596 $(call detected,CONFIG_LIBBPF_DYNAMIC)597 else598 $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel)599 endif600 else601 ifeq ($(NO_ZLIB), 1)602 $(warning Warning: Statically building libbpf not possible as zlib is missing)603 NO_LIBBPF := 1604 else605 # Libbpf will be built as a static library from tools/lib/bpf.606 LIBBPF_STATIC := 1607 $(call detected,CONFIG_LIBBPF)608 CFLAGS += -DHAVE_LIBBPF_SUPPORT609 endif610 endif611 endif612 endif # NO_LIBBPF613endif # NO_LIBELF614 615ifndef NO_SDT616 ifneq ($(feature-sdt), 1)617 $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev)618 NO_SDT := 1;619 else620 CFLAGS += -DHAVE_SDT_EVENT621 $(call detected,CONFIG_SDT_EVENT)622 endif623endif624 625ifdef PERF_HAVE_JITDUMP626 ifndef NO_LIBELF627 $(call detected,CONFIG_JITDUMP)628 CFLAGS += -DHAVE_JITDUMP629 endif630endif631 632ifeq ($(SRCARCH),powerpc)633 ifndef NO_DWARF634 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX635 endif636endif637 638ifndef NO_LIBUNWIND639 have_libunwind :=640 641 $(call feature_check,libunwind-x86)642 ifeq ($(feature-libunwind-x86), 1)643 $(call detected,CONFIG_LIBUNWIND_X86)644 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT645 LDFLAGS += -lunwind-x86646 EXTLIBS_LIBUNWIND += -lunwind-x86647 have_libunwind = 1648 endif649 650 $(call feature_check,libunwind-aarch64)651 ifeq ($(feature-libunwind-aarch64), 1)652 $(call detected,CONFIG_LIBUNWIND_AARCH64)653 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT654 LDFLAGS += -lunwind-aarch64655 EXTLIBS_LIBUNWIND += -lunwind-aarch64656 have_libunwind = 1657 $(call feature_check,libunwind-debug-frame-aarch64)658 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)659 $(warning No debug_frame support found in libunwind-aarch64)660 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64661 endif662 endif663 664 ifneq ($(feature-libunwind), 1)665 $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR)666 NO_LOCAL_LIBUNWIND := 1667 else668 have_libunwind := 1669 $(call detected,CONFIG_LOCAL_LIBUNWIND)670 endif671 672 ifneq ($(have_libunwind), 1)673 NO_LIBUNWIND := 1674 endif675else676 NO_LOCAL_LIBUNWIND := 1677endif678 679ifndef NO_LIBBPF680 ifneq ($(feature-bpf), 1)681 $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)682 NO_LIBBPF := 1683 endif684endif685 686ifndef BUILD_BPF_SKEL687 # BPF skeletons control a large number of perf features, by default688 # they are enabled.689 BUILD_BPF_SKEL := 1690endif691 692ifeq ($(BUILD_BPF_SKEL),1)693 ifeq ($(filter -DHAVE_LIBELF_SUPPORT, $(CFLAGS)),)694 $(warning Warning: Disabled BPF skeletons as libelf is required by bpftool)695 BUILD_BPF_SKEL := 0696 else ifeq ($(filter -DHAVE_ZLIB_SUPPORT, $(CFLAGS)),)697 $(warning Warning: Disabled BPF skeletons as zlib is required by bpftool)698 BUILD_BPF_SKEL := 0699 else ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),)700 $(warning Warning: Disabled BPF skeletons as libbpf is required)701 BUILD_BPF_SKEL := 0702 else ifeq ($(call get-executable,$(CLANG)),)703 $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) is missing)704 BUILD_BPF_SKEL := 0705 else706 CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')707 ifeq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1)708 $(warning Warning: Disabled BPF skeletons as reliable BTF generation needs at least $(CLANG) version 12.0.1)709 BUILD_BPF_SKEL := 0710 endif711 endif712 ifeq ($(BUILD_BPF_SKEL),1)713 $(call feature_check,clang-bpf-co-re)714 ifeq ($(feature-clang-bpf-co-re), 0)715 $(warning Warning: Disabled BPF skeletons as clang is too old)716 BUILD_BPF_SKEL := 0717 endif718 endif719 ifeq ($(BUILD_BPF_SKEL),1)720 $(call detected,CONFIG_PERF_BPF_SKEL)721 CFLAGS += -DHAVE_BPF_SKEL722 endif723endif724 725ifndef GEN_VMLINUX_H726 VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h727endif728 729dwarf-post-unwind := 1730dwarf-post-unwind-text := BUG731 732# setup DWARF post unwinder733ifdef NO_LIBUNWIND734 ifdef NO_LIBDW_DWARF_UNWIND735 $(warning Disabling post unwind, no support found.)736 dwarf-post-unwind := 0737 else738 dwarf-post-unwind-text := libdw739 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)740 endif741else742 dwarf-post-unwind-text := libunwind743 $(call detected,CONFIG_LIBUNWIND)744 # Enable libunwind support by default.745 ifndef NO_LIBDW_DWARF_UNWIND746 NO_LIBDW_DWARF_UNWIND := 1747 endif748endif749 750ifeq ($(dwarf-post-unwind),1)751 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT752 $(call detected,CONFIG_DWARF_UNWIND)753else754 NO_DWARF_UNWIND := 1755endif756 757ifndef NO_LOCAL_LIBUNWIND758 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))759 $(call feature_check,libunwind-debug-frame)760 ifneq ($(feature-libunwind-debug-frame), 1)761 $(warning No debug_frame support found in libunwind)762 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME763 endif764 else765 # non-ARM has no dwarf_find_debug_frame() function:766 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME767 endif768 EXTLIBS += $(LIBUNWIND_LIBS)769 LDFLAGS += $(LIBUNWIND_LIBS)770endif771ifeq ($(findstring -static,${LDFLAGS}),-static)772 # gcc -static links libgcc_eh which contans piece of libunwind773 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition774endif775 776ifndef NO_LIBUNWIND777 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT778 CFLAGS += $(LIBUNWIND_CFLAGS)779 LDFLAGS += $(LIBUNWIND_LDFLAGS)780 EXTLIBS += $(EXTLIBS_LIBUNWIND)781endif782 783ifneq ($(NO_LIBTRACEEVENT),1)784 ifeq ($(NO_SYSCALL_TABLE),0)785 $(call detected,CONFIG_TRACE)786 else787 ifndef NO_LIBAUDIT788 $(call feature_check,libaudit)789 ifneq ($(feature-libaudit), 1)790 $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev)791 NO_LIBAUDIT := 1792 else793 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT794 EXTLIBS += -laudit795 $(call detected,CONFIG_TRACE)796 endif797 endif798 endif799endif800 801ifndef NO_LIBCRYPTO802 ifneq ($(feature-libcrypto), 1)803 $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev)804 NO_LIBCRYPTO := 1805 else806 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT807 EXTLIBS += -lcrypto808 $(call detected,CONFIG_CRYPTO)809 endif810endif811 812ifndef NO_SLANG813 ifneq ($(feature-libslang), 1)814 ifneq ($(feature-libslang-include-subdir), 1)815 $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev)816 NO_SLANG := 1817 else818 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR819 endif820 endif821 ifndef NO_SLANG822 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h823 CFLAGS += -DHAVE_SLANG_SUPPORT824 EXTLIBS += -lslang825 $(call detected,CONFIG_SLANG)826 endif827endif828 829ifdef GTK2830 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)831 $(call feature_check,gtk2)832 ifneq ($(feature-gtk2), 1)833 $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev)834 NO_GTK2 := 1835 else836 $(call feature_check,gtk2-infobar)837 ifeq ($(feature-gtk2-infobar), 1)838 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT839 endif840 CFLAGS += -DHAVE_GTK2_SUPPORT841 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)842 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)843 EXTLIBS += -ldl844 endif845endif846 847ifdef NO_LIBPERL848 CFLAGS += -DNO_LIBPERL849else850 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)851 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))852 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))853 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)854 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))855 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))856 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))857 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)858 859 ifneq ($(feature-libperl), 1)860 CFLAGS += -DNO_LIBPERL861 NO_LIBPERL := 1862 $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev)863 else864 LDFLAGS += $(PERL_EMBED_LDFLAGS)865 EXTLIBS += $(PERL_EMBED_LIBADD)866 CFLAGS += -DHAVE_LIBPERL_SUPPORT867 ifeq ($(CC_NO_CLANG), 0)868 CFLAGS += -Wno-compound-token-split-by-macro869 endif870 $(call detected,CONFIG_LIBPERL)871 endif872endif873 874ifeq ($(feature-timerfd), 1)875 CFLAGS += -DHAVE_TIMERFD_SUPPORT876else877 $(warning No timerfd support. Disables 'perf kvm stat live')878endif879 880disable-python = $(eval $(disable-python_code))881define disable-python_code882 CFLAGS += -DNO_LIBPYTHON883 $(warning $1)884 NO_LIBPYTHON := 1885endef886 887PYTHON_EXTENSION_SUFFIX := '.so'888ifdef NO_LIBPYTHON889 $(call disable-python,Python support disabled by user)890else891 892 ifndef PYTHON893 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)894 else895 PYTHON_WORD := $(call shell-wordify,$(PYTHON))896 897 ifndef PYTHON_CONFIG898 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)899 else900 901 ifneq ($(feature-libpython), 1)902 $(call disable-python,No 'Python.h' was found: disables Python support - please install python-devel/python-dev)903 else904 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)905 EXTLIBS += $(PYTHON_EMBED_LIBADD)906 PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no")907 ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes)908 PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')909 ifdef CROSS_COMPILE910 PYTHON_EXTENSION_SUFFIX := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EXTENSION_SUFFIX))911 endif912 LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX)913 else914 $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent)915 endif916 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT917 $(call detected,CONFIG_LIBPYTHON)918 ifeq ($(filter -fPIC,$(CFLAGS)),)919 # Building a shared library requires position independent code.920 CFLAGS += -fPIC921 CXXFLAGS += -fPIC922 endif923 endif924 endif925 endif926endif927 928ifneq ($(NO_JEVENTS),1)929 ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),)930 NO_JEVENTS := 1931 endif932endif933ifneq ($(NO_JEVENTS),1)934 NO_JEVENTS := 0935 ifndef PYTHON936 $(error ERROR: No python interpreter needed for jevents generation. Install python or build with NO_JEVENTS=1.)937 else938 # jevents.py uses f-strings present in Python 3.6 released in Dec. 2016.939 JEVENTS_PYTHON_GOOD := $(shell $(PYTHON) -c 'import sys;print("1" if(sys.version_info.major >= 3 and sys.version_info.minor >= 6) else "0")' 2> /dev/null)940 ifneq ($(JEVENTS_PYTHON_GOOD), 1)941 $(error ERROR: Python interpreter needed for jevents generation too old (older than 3.6). Install a newer python or build with NO_JEVENTS=1.)942 endif943 endif944endif945 946ifdef BUILD_NONDISTRO947 ifeq ($(feature-libbfd), 1)948 EXTLIBS += -lbfd -lopcodes949 else950 # we are on a system that requires -liberty and (maybe) -lz951 # to link against -lbfd; test each case individually here952 953 # call all detections now so we get correct954 # status in VF output955 $(call feature_check,libbfd-liberty)956 $(call feature_check,libbfd-liberty-z)957 958 ifeq ($(feature-libbfd-liberty), 1)959 EXTLIBS += -lbfd -lopcodes -liberty960 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl961 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl962 else963 ifeq ($(feature-libbfd-liberty-z), 1)964 EXTLIBS += -lbfd -lopcodes -liberty -lz965 FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl966 FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl967 endif968 endif969 $(call feature_check,disassembler-four-args)970 $(call feature_check,disassembler-init-styled)971 endif972 973 CFLAGS += -DHAVE_LIBBFD_SUPPORT974 CXXFLAGS += -DHAVE_LIBBFD_SUPPORT975 ifeq ($(feature-libbfd-buildid), 1)976 CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT977 else978 $(warning Old version of libbfd/binutils things like PE executable profiling will not be available)979 endif980endif981 982ifndef NO_LIBLLVM983 $(call feature_check,llvm-perf)984 ifeq ($(feature-llvm-perf), 1)985 CFLAGS += -DHAVE_LIBLLVM_SUPPORT986 CFLAGS += $(shell $(LLVM_CONFIG) --cflags)987 CXXFLAGS += -DHAVE_LIBLLVM_SUPPORT988 CXXFLAGS += $(shell $(LLVM_CONFIG) --cxxflags)989 LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)990 EXTLIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)991 EXTLIBS += -lstdc++992 $(call detected,CONFIG_LIBLLVM)993 else994 $(warning No libllvm 13+ found, slower source file resolution, please install llvm-devel/llvm-dev)995 NO_LIBLLVM := 1996 endif997endif998 999ifndef NO_DEMANGLE1000 $(call feature_check,cxa-demangle)1001 ifeq ($(feature-cxa-demangle), 1)1002 EXTLIBS += -lstdc++1003 CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT1004 CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT1005 $(call detected,CONFIG_CXX_DEMANGLE)1006 endif1007 ifdef BUILD_NONDISTRO1008 ifeq ($(filter -liberty,$(EXTLIBS)),)1009 $(call feature_check,cplus-demangle)1010 ifeq ($(feature-cplus-demangle), 1)1011 EXTLIBS += -liberty1012 endif1013 endif1014 ifneq ($(filter -liberty,$(EXTLIBS)),)1015 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT1016 CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT1017 endif1018 endif1019endif1020 1021ifndef NO_LZMA1022 ifeq ($(feature-lzma), 1)1023 CFLAGS += -DHAVE_LZMA_SUPPORT1024 EXTLIBS += -llzma1025 $(call detected,CONFIG_LZMA)1026 else1027 $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev)1028 NO_LZMA := 11029 endif1030endif1031 1032ifndef NO_LIBZSTD1033 ifeq ($(feature-libzstd), 1)1034 CFLAGS += -DHAVE_ZSTD_SUPPORT1035 CFLAGS += $(LIBZSTD_CFLAGS)1036 LDFLAGS += $(LIBZSTD_LDFLAGS)1037 EXTLIBS += -lzstd1038 $(call detected,CONFIG_ZSTD)1039 else1040 $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR)1041 NO_LIBZSTD := 11042 endif1043endif1044 1045ifndef NO_BACKTRACE1046 ifeq ($(feature-backtrace), 1)1047 CFLAGS += -DHAVE_BACKTRACE_SUPPORT1048 endif1049endif1050 1051ifndef NO_LIBNUMA1052 ifeq ($(feature-libnuma), 0)1053 $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev)1054 NO_LIBNUMA := 11055 else1056 ifeq ($(feature-numa_num_possible_cpus), 0)1057 $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8)1058 NO_LIBNUMA := 11059 else1060 CFLAGS += -DHAVE_LIBNUMA_SUPPORT1061 EXTLIBS += -lnuma1062 $(call detected,CONFIG_NUMA)1063 endif1064 endif1065endif1066 1067ifdef HAVE_KVM_STAT_SUPPORT1068 CFLAGS += -DHAVE_KVM_STAT_SUPPORT1069endif1070 1071ifeq ($(feature-disassembler-four-args), 1)1072 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE1073endif1074 1075ifeq ($(feature-disassembler-init-styled), 1)1076 CFLAGS += -DDISASM_INIT_STYLED1077endif1078 1079ifeq (${IS_64_BIT}, 1)1080 ifndef NO_PERF_READ_VDSO321081 $(call feature_check,compile-32)1082 ifeq ($(feature-compile-32), 1)1083 CFLAGS += -DHAVE_PERF_READ_VDSO321084 else1085 NO_PERF_READ_VDSO32 := 11086 endif1087 endif1088 ifneq ($(SRCARCH), x86)1089 NO_PERF_READ_VDSOX32 := 11090 endif1091 ifndef NO_PERF_READ_VDSOX321092 $(call feature_check,compile-x32)1093 ifeq ($(feature-compile-x32), 1)1094 CFLAGS += -DHAVE_PERF_READ_VDSOX321095 else1096 NO_PERF_READ_VDSOX32 := 11097 endif1098 endif1099else1100 NO_PERF_READ_VDSO32 := 11101 NO_PERF_READ_VDSOX32 := 11102endif1103 1104ifndef NO_LIBBABELTRACE1105 $(call feature_check,libbabeltrace)1106 ifeq ($(feature-libbabeltrace), 1)1107 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)1108 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)1109 EXTLIBS += -lbabeltrace-ctf1110 $(call detected,CONFIG_LIBBABELTRACE)1111 else1112 $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev)1113 endif1114endif1115 1116ifndef NO_CAPSTONE1117 $(call feature_check,libcapstone)1118 ifeq ($(feature-libcapstone), 1)1119 CFLAGS += -DHAVE_LIBCAPSTONE_SUPPORT $(LIBCAPSTONE_CFLAGS)1120 LDFLAGS += $(LICAPSTONE_LDFLAGS)1121 EXTLIBS += -lcapstone1122 $(call detected,CONFIG_LIBCAPSTONE)1123 else1124 msg := $(warning No libcapstone found, disables disasm engine support for 'perf script', please install libcapstone-dev/capstone-devel);1125 endif1126endif1127 1128ifndef NO_AUXTRACE1129 ifeq ($(SRCARCH),x86)1130 ifeq ($(feature-get_cpuid), 0)1131 $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc)1132 NO_AUXTRACE := 11133 endif1134 endif1135 ifndef NO_AUXTRACE1136 $(call detected,CONFIG_AUXTRACE)1137 CFLAGS += -DHAVE_AUXTRACE_SUPPORT1138 ifeq ($(feature-reallocarray), 0)1139 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY1140 endif1141 endif1142endif1143 1144ifdef EXTRA_TESTS1145 $(call detected,CONFIG_EXTRA_TESTS)1146 CFLAGS += -DHAVE_EXTRA_TESTS1147endif1148 1149ifndef NO_JVMTI1150 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))1151 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')1152 else1153 ifneq (,$(wildcard /usr/sbin/alternatives))1154 JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g')1155 endif1156 endif1157 ifndef JDIR1158 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)1159 NO_JVMTI := 11160 endif1161endif1162 1163ifndef NO_JVMTI1164 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux1165 $(call feature_check,jvmti)1166 ifeq ($(feature-jvmti), 1)1167 $(call detected_var,JDIR)1168 ifndef NO_JVMTI_CMLR1169 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)1170 $(call feature_check,jvmti-cmlr)1171 ifeq ($(feature-jvmti-cmlr), 1)1172 CFLAGS += -DHAVE_JVMTI_CMLR1173 endif1174 endif # NO_JVMTI_CMLR1175 else1176 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)1177 NO_JVMTI := 11178 endif1179endif1180 1181ifndef NO_LIBPFM41182 $(call feature_check,libpfm4)1183 ifeq ($(feature-libpfm4), 1)1184 CFLAGS += -DHAVE_LIBPFM1185 EXTLIBS += -lpfm1186 ASCIIDOC_EXTRA = -aHAVE_LIBPFM=11187 $(call detected,CONFIG_LIBPFM4)1188 else1189 $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev)1190 endif1191endif1192 1193# libtraceevent is a recommended dependency picked up from the system.1194ifneq ($(NO_LIBTRACEEVENT),1)1195 $(call feature_check,libtraceevent)1196 ifeq ($(feature-libtraceevent), 1)1197 CFLAGS += -DHAVE_LIBTRACEEVENT1198 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent)1199 EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent)1200 LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent).0.01201 LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))1202 LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))1203 LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))1204 LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3))1205 CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)1206 $(call detected,CONFIG_LIBTRACEEVENT)1207 else1208 $(error ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel and/or set LIBTRACEEVENT_DIR or build with NO_LIBTRACEEVENT=1)1209 endif1210 1211 $(call feature_check,libtracefs)1212 ifeq ($(feature-libtracefs), 1)1213 CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs)1214 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)1215 EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtracefs)1216 LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs).0.01217 LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION)))1218 LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION)))1219 LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION)))1220 LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3))1221 CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP)1222 else1223 $(warning libtracefs is missing. Please install libtracefs-dev/libtracefs-devel)1224 endif1225endif1226 1227# Among the variables below, these:1228# perfexecdir1229# libbpf_include_dir1230# perf_examples_dir1231# template_dir1232# mandir1233# infodir1234# htmldir1235# ETC_PERFCONFIG (but not sysconfdir)1236# can be specified as a relative path some/where/else;1237# this is interpreted as relative to $(prefix) and "perf" at1238# runtime figures out where they are based on the path to the executable.1239# This can help installing the suite in a relocatable way.1240 1241# Make the path relative to DESTDIR, not to prefix1242ifndef DESTDIR1243prefix ?= $(HOME)1244endif1245bindir_relative = bin1246bindir = $(abspath $(prefix)/$(bindir_relative))1247includedir_relative = include1248includedir = $(abspath $(prefix)/$(includedir_relative))1249mandir = share/man1250infodir = share/info1251perfexecdir = libexec/perf-core1252# FIXME: system's libbpf header directory, where we expect to find bpf/bpf_helpers.h, for instance1253libbpf_include_dir = /usr/include1254perf_examples_dir = lib/perf/examples1255sharedir = $(prefix)/share1256template_dir = share/perf-core/templates1257STRACE_GROUPS_DIR = share/perf-core/strace/groups1258htmldir = share/doc/perf-doc1259tipdir = share/doc/perf-tip1260srcdir = $(srctree)/tools/perf1261ifeq ($(prefix),/usr)1262sysconfdir = /etc1263ETC_PERFCONFIG = $(sysconfdir)/perfconfig1264else1265sysconfdir = $(prefix)/etc1266ETC_PERFCONFIG = etc/perfconfig1267endif1268ifndef lib1269ifeq ($(SRCARCH)$(IS_64_BIT), x861)1270lib = lib641271else1272lib = lib1273endif1274endif # lib1275libdir = $(prefix)/$(lib)1276 1277# Shell quote (do not use $(call) to accommodate ancient setups);1278ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))1279STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))1280DESTDIR_SQ = $(subst ','\'',$(DESTDIR))1281bindir_SQ = $(subst ','\'',$(bindir))1282includedir_SQ = $(subst ','\'',$(includedir))1283mandir_SQ = $(subst ','\'',$(mandir))1284infodir_SQ = $(subst ','\'',$(infodir))1285perfexecdir_SQ = $(subst ','\'',$(perfexecdir))1286libbpf_include_dir_SQ = $(subst ','\'',$(libbpf_include_dir))1287perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))1288template_dir_SQ = $(subst ','\'',$(template_dir))1289htmldir_SQ = $(subst ','\'',$(htmldir))1290tipdir_SQ = $(subst ','\'',$(tipdir))1291prefix_SQ = $(subst ','\'',$(prefix))1292sysconfdir_SQ = $(subst ','\'',$(sysconfdir))1293libdir_SQ = $(subst ','\'',$(libdir))1294srcdir_SQ = $(subst ','\'',$(srcdir))1295 1296ifneq ($(filter /%,$(firstword $(perfexecdir))),)1297perfexec_instdir = $(perfexecdir)1298perf_include_instdir = $(libbpf_include_dir)1299perf_examples_instdir = $(perf_examples_dir)1300STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)1301tip_instdir = $(tipdir)1302else1303perfexec_instdir = $(prefix)/$(perfexecdir)1304perf_include_instdir = $(prefix)/$(libbpf_include_dir)1305perf_examples_instdir = $(prefix)/$(perf_examples_dir)1306STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)1307tip_instdir = $(prefix)/$(tipdir)1308endif1309perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))1310perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))1311perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))1312STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))1313tip_instdir_SQ = $(subst ','\'',$(tip_instdir))1314 1315export perfexec_instdir_SQ1316 1317print_var = $(eval $(print_var_code)) $(info $(MSG))1318define print_var_code1319 MSG = $(shell printf '...%40s: %s' $(1) $($(1)))1320endef1321 1322ifeq ($(feature_display),1)1323 $(call feature_display_entries)1324endif1325 1326ifeq ($(VF),1)1327 # Display EXTRA features which are detected manualy1328 # from here with feature_check call and thus cannot1329 # be partof global state output.1330 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),) $(info $(MSG)))1331 $(call print_var,prefix)1332 $(call print_var,bindir)1333 $(call print_var,libdir)1334 $(call print_var,sysconfdir)1335 $(call print_var,LIBUNWIND_DIR)1336 $(call print_var,LIBDW_DIR)1337 $(call print_var,JDIR)1338 1339 ifeq ($(dwarf-post-unwind),1)1340 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG))1341 endif1342endif1343 1344$(info )1345 1346$(call detected_var,bindir_SQ)1347$(call detected_var,PYTHON_WORD)1348ifneq ($(OUTPUT),)1349$(call detected_var,OUTPUT)1350endif1351$(call detected_var,htmldir_SQ)1352$(call detected_var,infodir_SQ)1353$(call detected_var,mandir_SQ)1354$(call detected_var,ETC_PERFCONFIG_SQ)1355$(call detected_var,STRACE_GROUPS_DIR_SQ)1356$(call detected_var,prefix_SQ)1357$(call detected_var,perfexecdir_SQ)1358$(call detected_var,libbpf_include_dir_SQ)1359$(call detected_var,perf_examples_dir_SQ)1360$(call detected_var,tipdir_SQ)1361$(call detected_var,srcdir_SQ)1362$(call detected_var,LIBDIR)1363$(call detected_var,GTK_CFLAGS)1364$(call detected_var,PERL_EMBED_CCOPTS)1365$(call detected_var,PYTHON_EMBED_CCOPTS)1366ifneq ($(BISON_FILE_PREFIX_MAP),)1367$(call detected_var,BISON_FILE_PREFIX_MAP)1368endif1369 1370# re-generate FEATURE-DUMP as we may have called feature_check, found out1371# extra libraries to add to LDFLAGS of some other test and then redo those1372# tests, see the block about libbfd, disassembler-four-args, for instance.1373$(shell rm -f $(FEATURE_DUMP_FILENAME))1374$(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))1375