1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0-only 2*4882a593Smuzhiyun 3*4882a593Smuzhiyunifeq ($(src-perf),) 4*4882a593Smuzhiyunsrc-perf := $(srctree)/tools/perf 5*4882a593Smuzhiyunendif 6*4882a593Smuzhiyun 7*4882a593Smuzhiyunifeq ($(obj-perf),) 8*4882a593Smuzhiyunobj-perf := $(OUTPUT) 9*4882a593Smuzhiyunendif 10*4882a593Smuzhiyun 11*4882a593Smuzhiyunifneq ($(obj-perf),) 12*4882a593Smuzhiyunobj-perf := $(abspath $(obj-perf))/ 13*4882a593Smuzhiyunendif 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun$(shell printf "" > $(OUTPUT).config-detected) 16*4882a593Smuzhiyundetected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) 17*4882a593Smuzhiyundetected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunCFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS)) 20*4882a593Smuzhiyun 21*4882a593Smuzhiyuninclude $(srctree)/tools/scripts/Makefile.arch 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun$(call detected_var,SRCARCH) 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunNO_PERF_REGS := 1 26*4882a593Smuzhiyun 27*4882a593Smuzhiyunifneq ($(NO_SYSCALL_TABLE),1) 28*4882a593Smuzhiyun NO_SYSCALL_TABLE := 1 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun ifeq ($(SRCARCH),x86) 31*4882a593Smuzhiyun ifeq (${IS_64_BIT}, 1) 32*4882a593Smuzhiyun NO_SYSCALL_TABLE := 0 33*4882a593Smuzhiyun endif 34*4882a593Smuzhiyun else 35*4882a593Smuzhiyun ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390)) 36*4882a593Smuzhiyun NO_SYSCALL_TABLE := 0 37*4882a593Smuzhiyun endif 38*4882a593Smuzhiyun endif 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun ifneq ($(NO_SYSCALL_TABLE),1) 41*4882a593Smuzhiyun CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT 42*4882a593Smuzhiyun endif 43*4882a593Smuzhiyunendif 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun# Additional ARCH settings for ppc 46*4882a593Smuzhiyunifeq ($(SRCARCH),powerpc) 47*4882a593Smuzhiyun NO_PERF_REGS := 0 48*4882a593Smuzhiyun CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated 49*4882a593Smuzhiyun LIBUNWIND_LIBS := -lunwind -lunwind-ppc64 50*4882a593Smuzhiyunendif 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun# Additional ARCH settings for x86 53*4882a593Smuzhiyunifeq ($(SRCARCH),x86) 54*4882a593Smuzhiyun $(call detected,CONFIG_X86) 55*4882a593Smuzhiyun ifeq (${IS_64_BIT}, 1) 56*4882a593Smuzhiyun CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated 57*4882a593Smuzhiyun ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 58*4882a593Smuzhiyun LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma 59*4882a593Smuzhiyun $(call detected,CONFIG_X86_64) 60*4882a593Smuzhiyun else 61*4882a593Smuzhiyun LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind 62*4882a593Smuzhiyun endif 63*4882a593Smuzhiyun NO_PERF_REGS := 0 64*4882a593Smuzhiyunendif 65*4882a593Smuzhiyun 66*4882a593Smuzhiyunifeq ($(SRCARCH),arm) 67*4882a593Smuzhiyun NO_PERF_REGS := 0 68*4882a593Smuzhiyun LIBUNWIND_LIBS = -lunwind -lunwind-arm 69*4882a593Smuzhiyunendif 70*4882a593Smuzhiyun 71*4882a593Smuzhiyunifeq ($(SRCARCH),arm64) 72*4882a593Smuzhiyun NO_PERF_REGS := 0 73*4882a593Smuzhiyun CFLAGS += -I$(OUTPUT)arch/arm64/include/generated 74*4882a593Smuzhiyun LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 75*4882a593Smuzhiyunendif 76*4882a593Smuzhiyun 77*4882a593Smuzhiyunifeq ($(SRCARCH),riscv) 78*4882a593Smuzhiyun NO_PERF_REGS := 0 79*4882a593Smuzhiyunendif 80*4882a593Smuzhiyun 81*4882a593Smuzhiyunifeq ($(SRCARCH),csky) 82*4882a593Smuzhiyun NO_PERF_REGS := 0 83*4882a593Smuzhiyunendif 84*4882a593Smuzhiyun 85*4882a593Smuzhiyunifeq ($(ARCH),s390) 86*4882a593Smuzhiyun NO_PERF_REGS := 0 87*4882a593Smuzhiyun CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated 88*4882a593Smuzhiyunendif 89*4882a593Smuzhiyun 90*4882a593Smuzhiyunifeq ($(NO_PERF_REGS),0) 91*4882a593Smuzhiyun $(call detected,CONFIG_PERF_REGS) 92*4882a593Smuzhiyunendif 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun# So far there's only x86 and arm libdw unwind support merged in perf. 95*4882a593Smuzhiyun# Disable it on all other architectures in case libdw unwind 96*4882a593Smuzhiyun# support is detected in system. Add supported architectures 97*4882a593Smuzhiyun# to the check. 98*4882a593Smuzhiyunifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv)) 99*4882a593Smuzhiyun NO_LIBDW_DWARF_UNWIND := 1 100*4882a593Smuzhiyunendif 101*4882a593Smuzhiyun 102*4882a593Smuzhiyunifeq ($(LIBUNWIND_LIBS),) 103*4882a593Smuzhiyun NO_LIBUNWIND := 1 104*4882a593Smuzhiyunendif 105*4882a593Smuzhiyun# 106*4882a593Smuzhiyun# For linking with debug library, run like: 107*4882a593Smuzhiyun# 108*4882a593Smuzhiyun# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ 109*4882a593Smuzhiyun# 110*4882a593Smuzhiyun 111*4882a593Smuzhiyunlibunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code)) 112*4882a593Smuzhiyundefine libunwind_arch_set_flags_code 113*4882a593Smuzhiyun FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include 114*4882a593Smuzhiyun FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib 115*4882a593Smuzhiyunendef 116*4882a593Smuzhiyun 117*4882a593Smuzhiyunifdef LIBUNWIND_DIR 118*4882a593Smuzhiyun LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include 119*4882a593Smuzhiyun LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib 120*4882a593Smuzhiyun LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 121*4882a593Smuzhiyun $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch))) 122*4882a593Smuzhiyunendif 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun# Set per-feature check compilation flags 125*4882a593SmuzhiyunFEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) 126*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 127*4882a593SmuzhiyunFEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) 128*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) 129*4882a593Smuzhiyun 130*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm 131*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64 132*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86 133*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64 134*4882a593Smuzhiyun 135*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto 136*4882a593Smuzhiyun 137*4882a593Smuzhiyunifdef CSINCLUDES 138*4882a593Smuzhiyun LIBOPENCSD_CFLAGS := -I$(CSINCLUDES) 139*4882a593Smuzhiyunendif 140*4882a593SmuzhiyunOPENCSDLIBS := -lopencsd_c_api -lopencsd 141*4882a593Smuzhiyunifdef CSLIBS 142*4882a593Smuzhiyun LIBOPENCSD_LDFLAGS := -L$(CSLIBS) 143*4882a593Smuzhiyunendif 144*4882a593SmuzhiyunFEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS) 145*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS) 146*4882a593Smuzhiyun 147*4882a593Smuzhiyunifeq ($(NO_PERF_REGS),0) 148*4882a593Smuzhiyun CFLAGS += -DHAVE_PERF_REGS_SUPPORT 149*4882a593Smuzhiyunendif 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun# for linking with debug library, run like: 152*4882a593Smuzhiyun# make DEBUG=1 LIBDW_DIR=/opt/libdw/ 153*4882a593Smuzhiyunifdef LIBDW_DIR 154*4882a593Smuzhiyun LIBDW_CFLAGS := -I$(LIBDW_DIR)/include 155*4882a593Smuzhiyun LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib 156*4882a593Smuzhiyunendif 157*4882a593SmuzhiyunDWARFLIBS := -ldw 158*4882a593Smuzhiyunifeq ($(findstring -static,${LDFLAGS}),-static) 159*4882a593Smuzhiyun DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2 160*4882a593Smuzhiyunendif 161*4882a593SmuzhiyunFEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) 162*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS) 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun# for linking with debug library, run like: 165*4882a593Smuzhiyun# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ 166*4882a593Smuzhiyunifdef LIBBABELTRACE_DIR 167*4882a593Smuzhiyun LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include 168*4882a593Smuzhiyun LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib 169*4882a593Smuzhiyunendif 170*4882a593SmuzhiyunFEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS) 171*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf 172*4882a593Smuzhiyun 173*4882a593Smuzhiyunifdef LIBZSTD_DIR 174*4882a593Smuzhiyun LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib 175*4882a593Smuzhiyun LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib 176*4882a593Smuzhiyunendif 177*4882a593SmuzhiyunFEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS) 178*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS) 179*4882a593Smuzhiyun 180*4882a593SmuzhiyunFEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi 181*4882a593Smuzhiyun# include ARCH specific config 182*4882a593Smuzhiyun-include $(src-perf)/arch/$(SRCARCH)/Makefile 183*4882a593Smuzhiyun 184*4882a593Smuzhiyunifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 185*4882a593Smuzhiyun CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 186*4882a593Smuzhiyunendif 187*4882a593Smuzhiyun 188*4882a593Smuzhiyuninclude $(srctree)/tools/scripts/utilities.mak 189*4882a593Smuzhiyun 190*4882a593Smuzhiyunifeq ($(call get-executable,$(FLEX)),) 191*4882a593Smuzhiyun dummy := $(error Error: $(FLEX) is missing on this system, please install it) 192*4882a593Smuzhiyunendif 193*4882a593Smuzhiyun 194*4882a593Smuzhiyunifeq ($(call get-executable,$(BISON)),) 195*4882a593Smuzhiyun dummy := $(error Error: $(BISON) is missing on this system, please install it) 196*4882a593Smuzhiyunendif 197*4882a593Smuzhiyun 198*4882a593Smuzhiyun# Treat warnings as errors unless directed not to 199*4882a593Smuzhiyunifneq ($(WERROR),0) 200*4882a593Smuzhiyun CORE_CFLAGS += -Werror 201*4882a593Smuzhiyun CXXFLAGS += -Werror 202*4882a593Smuzhiyunendif 203*4882a593Smuzhiyun 204*4882a593Smuzhiyunifndef DEBUG 205*4882a593Smuzhiyun DEBUG := 0 206*4882a593Smuzhiyunendif 207*4882a593Smuzhiyun 208*4882a593Smuzhiyunifeq ($(DEBUG),0) 209*4882a593Smuzhiyunifeq ($(CC_NO_CLANG), 0) 210*4882a593Smuzhiyun CORE_CFLAGS += -O3 211*4882a593Smuzhiyunelse 212*4882a593Smuzhiyun CORE_CFLAGS += -O6 213*4882a593Smuzhiyunendif 214*4882a593Smuzhiyunendif 215*4882a593Smuzhiyun 216*4882a593Smuzhiyunifdef PARSER_DEBUG 217*4882a593Smuzhiyun PARSER_DEBUG_BISON := -t 218*4882a593Smuzhiyun PARSER_DEBUG_FLEX := -d 219*4882a593Smuzhiyun CFLAGS += -DPARSER_DEBUG 220*4882a593Smuzhiyun $(call detected_var,PARSER_DEBUG_BISON) 221*4882a593Smuzhiyun $(call detected_var,PARSER_DEBUG_FLEX) 222*4882a593Smuzhiyunendif 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun# Try different combinations to accommodate systems that only have 225*4882a593Smuzhiyun# python[2][3]-config in weird combinations in the following order of 226*4882a593Smuzhiyun# priority from lowest to highest: 227*4882a593Smuzhiyun# * python3-config 228*4882a593Smuzhiyun# * python-config 229*4882a593Smuzhiyun# * python2-config as per pep-0394. 230*4882a593Smuzhiyun# * $(PYTHON)-config (If PYTHON is user supplied but PYTHON_CONFIG isn't) 231*4882a593Smuzhiyun# 232*4882a593SmuzhiyunPYTHON_AUTO := python-config 233*4882a593SmuzhiyunPYTHON_AUTO := $(if $(call get-executable,python3-config),python3-config,$(PYTHON_AUTO)) 234*4882a593SmuzhiyunPYTHON_AUTO := $(if $(call get-executable,python-config),python-config,$(PYTHON_AUTO)) 235*4882a593SmuzhiyunPYTHON_AUTO := $(if $(call get-executable,python2-config),python2-config,$(PYTHON_AUTO)) 236*4882a593Smuzhiyun 237*4882a593Smuzhiyun# If PYTHON is defined but PYTHON_CONFIG isn't, then take $(PYTHON)-config as if it was the user 238*4882a593Smuzhiyun# supplied value for PYTHON_CONFIG. Because it's "user supplied", error out if it doesn't exist. 239*4882a593Smuzhiyunifdef PYTHON 240*4882a593Smuzhiyun ifndef PYTHON_CONFIG 241*4882a593Smuzhiyun PYTHON_CONFIG_AUTO := $(call get-executable,$(PYTHON)-config) 242*4882a593Smuzhiyun PYTHON_CONFIG := $(if $(PYTHON_CONFIG_AUTO),$(PYTHON_CONFIG_AUTO),\ 243*4882a593Smuzhiyun $(call $(error $(PYTHON)-config not found))) 244*4882a593Smuzhiyun endif 245*4882a593Smuzhiyunendif 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun# Select either auto detected python and python-config or use user supplied values if they are 248*4882a593Smuzhiyun# defined. get-executable-or-default fails with an error if the first argument is supplied but 249*4882a593Smuzhiyun# doesn't exist. 250*4882a593Smuzhiyunoverride PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO)) 251*4882a593Smuzhiyunoverride PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_CONFIG))) 252*4882a593Smuzhiyun 253*4882a593Smuzhiyungrep-libs = $(filter -l%,$(1)) 254*4882a593Smuzhiyunstrip-libs = $(filter-out -l%,$(1)) 255*4882a593Smuzhiyun 256*4882a593SmuzhiyunPYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) 257*4882a593Smuzhiyun 258*4882a593Smuzhiyun# Python 3.8 changed the output of `python-config --ldflags` to not include the 259*4882a593Smuzhiyun# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for 260*4882a593Smuzhiyun# libpython fails if that flag is not included in LDFLAGS 261*4882a593Smuzhiyunifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0) 262*4882a593Smuzhiyun PYTHON_CONFIG_LDFLAGS := --ldflags --embed 263*4882a593Smuzhiyunelse 264*4882a593Smuzhiyun PYTHON_CONFIG_LDFLAGS := --ldflags 265*4882a593Smuzhiyunendif 266*4882a593Smuzhiyun 267*4882a593Smuzhiyunifdef PYTHON_CONFIG 268*4882a593Smuzhiyun PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null) 269*4882a593Smuzhiyun PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) 270*4882a593Smuzhiyun PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil 271*4882a593Smuzhiyun PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) 272*4882a593Smuzhiyun FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) 273*4882a593Smuzhiyun ifeq ($(CC_NO_CLANG), 0) 274*4882a593Smuzhiyun PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS)) 275*4882a593Smuzhiyun endif 276*4882a593Smuzhiyunendif 277*4882a593Smuzhiyun 278*4882a593SmuzhiyunFEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS) 279*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) 280*4882a593Smuzhiyun 281*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-libaio = -lrt 282*4882a593Smuzhiyun 283*4882a593SmuzhiyunFEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl 284*4882a593Smuzhiyun 285*4882a593SmuzhiyunCORE_CFLAGS += -fno-omit-frame-pointer 286*4882a593SmuzhiyunCORE_CFLAGS += -ggdb3 287*4882a593SmuzhiyunCORE_CFLAGS += -funwind-tables 288*4882a593SmuzhiyunCORE_CFLAGS += -Wall 289*4882a593SmuzhiyunCORE_CFLAGS += -Wextra 290*4882a593SmuzhiyunCORE_CFLAGS += -std=gnu99 291*4882a593Smuzhiyun 292*4882a593SmuzhiyunCXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti 293*4882a593SmuzhiyunCXXFLAGS += -Wall 294*4882a593SmuzhiyunCXXFLAGS += -fno-omit-frame-pointer 295*4882a593SmuzhiyunCXXFLAGS += -ggdb3 296*4882a593SmuzhiyunCXXFLAGS += -funwind-tables 297*4882a593SmuzhiyunCXXFLAGS += -Wno-strict-aliasing 298*4882a593Smuzhiyun 299*4882a593Smuzhiyun# Enforce a non-executable stack, as we may regress (again) in the future by 300*4882a593Smuzhiyun# adding assembler files missing the .GNU-stack linker note. 301*4882a593SmuzhiyunLDFLAGS += -Wl,-z,noexecstack 302*4882a593Smuzhiyun 303*4882a593SmuzhiyunEXTLIBS = -lpthread -lrt -lm -ldl 304*4882a593Smuzhiyun 305*4882a593Smuzhiyunifneq ($(TCMALLOC),) 306*4882a593Smuzhiyun CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free 307*4882a593Smuzhiyun EXTLIBS += -ltcmalloc 308*4882a593Smuzhiyunendif 309*4882a593Smuzhiyun 310*4882a593Smuzhiyunifeq ($(FEATURES_DUMP),) 311*4882a593Smuzhiyuninclude $(srctree)/tools/build/Makefile.feature 312*4882a593Smuzhiyunelse 313*4882a593Smuzhiyuninclude $(FEATURES_DUMP) 314*4882a593Smuzhiyunendif 315*4882a593Smuzhiyun 316*4882a593Smuzhiyunifeq ($(feature-stackprotector-all), 1) 317*4882a593Smuzhiyun CORE_CFLAGS += -fstack-protector-all 318*4882a593Smuzhiyunendif 319*4882a593Smuzhiyun 320*4882a593Smuzhiyunifeq ($(DEBUG),0) 321*4882a593Smuzhiyun ifeq ($(feature-fortify-source), 1) 322*4882a593Smuzhiyun CORE_CFLAGS += -D_FORTIFY_SOURCE=2 323*4882a593Smuzhiyun endif 324*4882a593Smuzhiyunendif 325*4882a593Smuzhiyun 326*4882a593SmuzhiyunINC_FLAGS += -I$(srctree)/tools/lib/perf/include 327*4882a593SmuzhiyunINC_FLAGS += -I$(src-perf)/util/include 328*4882a593SmuzhiyunINC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include 329*4882a593SmuzhiyunINC_FLAGS += -I$(srctree)/tools/include/ 330*4882a593SmuzhiyunINC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi 331*4882a593SmuzhiyunINC_FLAGS += -I$(srctree)/tools/include/uapi 332*4882a593SmuzhiyunINC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/ 333*4882a593SmuzhiyunINC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/ 334*4882a593Smuzhiyun 335*4882a593Smuzhiyun# $(obj-perf) for generated common-cmds.h 336*4882a593Smuzhiyun# $(obj-perf)/util for generated bison/flex headers 337*4882a593Smuzhiyunifneq ($(OUTPUT),) 338*4882a593SmuzhiyunINC_FLAGS += -I$(obj-perf)/util 339*4882a593SmuzhiyunINC_FLAGS += -I$(obj-perf) 340*4882a593Smuzhiyunendif 341*4882a593Smuzhiyun 342*4882a593SmuzhiyunINC_FLAGS += -I$(src-perf)/util 343*4882a593SmuzhiyunINC_FLAGS += -I$(src-perf) 344*4882a593SmuzhiyunINC_FLAGS += -I$(srctree)/tools/lib/ 345*4882a593Smuzhiyun 346*4882a593SmuzhiyunCORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 347*4882a593Smuzhiyun 348*4882a593SmuzhiyunCFLAGS += $(CORE_CFLAGS) $(INC_FLAGS) 349*4882a593SmuzhiyunCXXFLAGS += $(INC_FLAGS) 350*4882a593Smuzhiyun 351*4882a593SmuzhiyunLIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS) 352*4882a593Smuzhiyun 353*4882a593Smuzhiyunifeq ($(feature-sync-compare-and-swap), 1) 354*4882a593Smuzhiyun CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT 355*4882a593Smuzhiyunendif 356*4882a593Smuzhiyun 357*4882a593Smuzhiyunifeq ($(feature-pthread-attr-setaffinity-np), 1) 358*4882a593Smuzhiyun CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP 359*4882a593Smuzhiyunendif 360*4882a593Smuzhiyun 361*4882a593Smuzhiyunifeq ($(feature-pthread-barrier), 1) 362*4882a593Smuzhiyun CFLAGS += -DHAVE_PTHREAD_BARRIER 363*4882a593Smuzhiyunendif 364*4882a593Smuzhiyun 365*4882a593Smuzhiyunifndef NO_BIONIC 366*4882a593Smuzhiyun $(call feature_check,bionic) 367*4882a593Smuzhiyun ifeq ($(feature-bionic), 1) 368*4882a593Smuzhiyun BIONIC := 1 369*4882a593Smuzhiyun CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE 370*4882a593Smuzhiyun CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE 371*4882a593Smuzhiyun EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) 372*4882a593Smuzhiyun EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) 373*4882a593Smuzhiyun endif 374*4882a593Smuzhiyunendif 375*4882a593Smuzhiyun 376*4882a593Smuzhiyunifeq ($(feature-eventfd), 1) 377*4882a593Smuzhiyun CFLAGS += -DHAVE_EVENTFD_SUPPORT 378*4882a593Smuzhiyunendif 379*4882a593Smuzhiyun 380*4882a593Smuzhiyunifeq ($(feature-get_current_dir_name), 1) 381*4882a593Smuzhiyun CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME 382*4882a593Smuzhiyunendif 383*4882a593Smuzhiyun 384*4882a593Smuzhiyunifeq ($(feature-gettid), 1) 385*4882a593Smuzhiyun CFLAGS += -DHAVE_GETTID 386*4882a593Smuzhiyunendif 387*4882a593Smuzhiyun 388*4882a593Smuzhiyunifeq ($(feature-file-handle), 1) 389*4882a593Smuzhiyun CFLAGS += -DHAVE_FILE_HANDLE 390*4882a593Smuzhiyunendif 391*4882a593Smuzhiyun 392*4882a593Smuzhiyunifdef NO_LIBELF 393*4882a593Smuzhiyun NO_DWARF := 1 394*4882a593Smuzhiyun NO_DEMANGLE := 1 395*4882a593Smuzhiyun NO_LIBUNWIND := 1 396*4882a593Smuzhiyun NO_LIBDW_DWARF_UNWIND := 1 397*4882a593Smuzhiyun NO_LIBBPF := 1 398*4882a593Smuzhiyun NO_JVMTI := 1 399*4882a593Smuzhiyunelse 400*4882a593Smuzhiyun ifeq ($(feature-libelf), 0) 401*4882a593Smuzhiyun ifeq ($(feature-glibc), 1) 402*4882a593Smuzhiyun LIBC_SUPPORT := 1 403*4882a593Smuzhiyun endif 404*4882a593Smuzhiyun ifeq ($(BIONIC),1) 405*4882a593Smuzhiyun LIBC_SUPPORT := 1 406*4882a593Smuzhiyun endif 407*4882a593Smuzhiyun ifeq ($(LIBC_SUPPORT),1) 408*4882a593Smuzhiyun msg := $(warning No libelf found. Disables 'probe' tool, jvmti and BPF support in 'perf record'. Please install libelf-dev, libelf-devel or elfutils-libelf-devel); 409*4882a593Smuzhiyun 410*4882a593Smuzhiyun NO_LIBELF := 1 411*4882a593Smuzhiyun NO_DWARF := 1 412*4882a593Smuzhiyun NO_DEMANGLE := 1 413*4882a593Smuzhiyun NO_LIBUNWIND := 1 414*4882a593Smuzhiyun NO_LIBDW_DWARF_UNWIND := 1 415*4882a593Smuzhiyun NO_LIBBPF := 1 416*4882a593Smuzhiyun NO_JVMTI := 1 417*4882a593Smuzhiyun else 418*4882a593Smuzhiyun ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),) 419*4882a593Smuzhiyun ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0) 420*4882a593Smuzhiyun msg := $(error No libasan found, please install libasan); 421*4882a593Smuzhiyun endif 422*4882a593Smuzhiyun endif 423*4882a593Smuzhiyun 424*4882a593Smuzhiyun ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),) 425*4882a593Smuzhiyun ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0) 426*4882a593Smuzhiyun msg := $(error No libubsan found, please install libubsan); 427*4882a593Smuzhiyun endif 428*4882a593Smuzhiyun endif 429*4882a593Smuzhiyun 430*4882a593Smuzhiyun ifneq ($(filter s% -static%,$(LDFLAGS),),) 431*4882a593Smuzhiyun msg := $(error No static glibc found, please install glibc-static); 432*4882a593Smuzhiyun else 433*4882a593Smuzhiyun msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]); 434*4882a593Smuzhiyun endif 435*4882a593Smuzhiyun endif 436*4882a593Smuzhiyun else 437*4882a593Smuzhiyun ifndef NO_LIBDW_DWARF_UNWIND 438*4882a593Smuzhiyun ifneq ($(feature-libdw-dwarf-unwind),1) 439*4882a593Smuzhiyun NO_LIBDW_DWARF_UNWIND := 1 440*4882a593Smuzhiyun msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR); 441*4882a593Smuzhiyun endif 442*4882a593Smuzhiyun endif 443*4882a593Smuzhiyun ifneq ($(feature-dwarf), 1) 444*4882a593Smuzhiyun ifndef NO_DWARF 445*4882a593Smuzhiyun msg := $(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); 446*4882a593Smuzhiyun NO_DWARF := 1 447*4882a593Smuzhiyun endif 448*4882a593Smuzhiyun else 449*4882a593Smuzhiyun ifneq ($(feature-dwarf_getlocations), 1) 450*4882a593Smuzhiyun msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157); 451*4882a593Smuzhiyun else 452*4882a593Smuzhiyun CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT 453*4882a593Smuzhiyun endif # dwarf_getlocations 454*4882a593Smuzhiyun endif # Dwarf support 455*4882a593Smuzhiyun endif # libelf support 456*4882a593Smuzhiyunendif # NO_LIBELF 457*4882a593Smuzhiyun 458*4882a593Smuzhiyunifeq ($(feature-glibc), 1) 459*4882a593Smuzhiyun CFLAGS += -DHAVE_GLIBC_SUPPORT 460*4882a593Smuzhiyunendif 461*4882a593Smuzhiyun 462*4882a593Smuzhiyunifeq ($(feature-libaio), 1) 463*4882a593Smuzhiyun ifndef NO_AIO 464*4882a593Smuzhiyun CFLAGS += -DHAVE_AIO_SUPPORT 465*4882a593Smuzhiyun endif 466*4882a593Smuzhiyunendif 467*4882a593Smuzhiyun 468*4882a593Smuzhiyunifdef NO_DWARF 469*4882a593Smuzhiyun NO_LIBDW_DWARF_UNWIND := 1 470*4882a593Smuzhiyunendif 471*4882a593Smuzhiyun 472*4882a593Smuzhiyunifeq ($(feature-sched_getcpu), 1) 473*4882a593Smuzhiyun CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT 474*4882a593Smuzhiyunendif 475*4882a593Smuzhiyun 476*4882a593Smuzhiyunifeq ($(feature-setns), 1) 477*4882a593Smuzhiyun CFLAGS += -DHAVE_SETNS_SUPPORT 478*4882a593Smuzhiyun $(call detected,CONFIG_SETNS) 479*4882a593Smuzhiyunendif 480*4882a593Smuzhiyun 481*4882a593Smuzhiyunifdef CORESIGHT 482*4882a593Smuzhiyun $(call feature_check,libopencsd) 483*4882a593Smuzhiyun ifeq ($(feature-libopencsd), 1) 484*4882a593Smuzhiyun CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS) 485*4882a593Smuzhiyun ifeq ($(feature-reallocarray), 0) 486*4882a593Smuzhiyun CFLAGS += -DCOMPAT_NEED_REALLOCARRAY 487*4882a593Smuzhiyun endif 488*4882a593Smuzhiyun LDFLAGS += $(LIBOPENCSD_LDFLAGS) 489*4882a593Smuzhiyun EXTLIBS += $(OPENCSDLIBS) 490*4882a593Smuzhiyun $(call detected,CONFIG_LIBOPENCSD) 491*4882a593Smuzhiyun ifdef CSTRACE_RAW 492*4882a593Smuzhiyun CFLAGS += -DCS_DEBUG_RAW 493*4882a593Smuzhiyun ifeq (${CSTRACE_RAW}, packed) 494*4882a593Smuzhiyun CFLAGS += -DCS_RAW_PACKED 495*4882a593Smuzhiyun endif 496*4882a593Smuzhiyun endif 497*4882a593Smuzhiyun endif 498*4882a593Smuzhiyunendif 499*4882a593Smuzhiyun 500*4882a593Smuzhiyunifndef NO_LIBELF 501*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBELF_SUPPORT 502*4882a593Smuzhiyun EXTLIBS += -lelf 503*4882a593Smuzhiyun $(call detected,CONFIG_LIBELF) 504*4882a593Smuzhiyun 505*4882a593Smuzhiyun ifeq ($(feature-libelf-getphdrnum), 1) 506*4882a593Smuzhiyun CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT 507*4882a593Smuzhiyun endif 508*4882a593Smuzhiyun 509*4882a593Smuzhiyun ifeq ($(feature-libelf-gelf_getnote), 1) 510*4882a593Smuzhiyun CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT 511*4882a593Smuzhiyun else 512*4882a593Smuzhiyun msg := $(warning gelf_getnote() not found on libelf, SDT support disabled); 513*4882a593Smuzhiyun endif 514*4882a593Smuzhiyun 515*4882a593Smuzhiyun ifeq ($(feature-libelf-getshdrstrndx), 1) 516*4882a593Smuzhiyun CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT 517*4882a593Smuzhiyun endif 518*4882a593Smuzhiyun 519*4882a593Smuzhiyun ifndef NO_LIBDEBUGINFOD 520*4882a593Smuzhiyun $(call feature_check,libdebuginfod) 521*4882a593Smuzhiyun ifeq ($(feature-libdebuginfod), 1) 522*4882a593Smuzhiyun CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT 523*4882a593Smuzhiyun EXTLIBS += -ldebuginfod 524*4882a593Smuzhiyun endif 525*4882a593Smuzhiyun endif 526*4882a593Smuzhiyun 527*4882a593Smuzhiyun ifndef NO_DWARF 528*4882a593Smuzhiyun ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) 529*4882a593Smuzhiyun msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled); 530*4882a593Smuzhiyun NO_DWARF := 1 531*4882a593Smuzhiyun else 532*4882a593Smuzhiyun CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) 533*4882a593Smuzhiyun LDFLAGS += $(LIBDW_LDFLAGS) 534*4882a593Smuzhiyun EXTLIBS += ${DWARFLIBS} 535*4882a593Smuzhiyun $(call detected,CONFIG_DWARF) 536*4882a593Smuzhiyun endif # PERF_HAVE_DWARF_REGS 537*4882a593Smuzhiyun endif # NO_DWARF 538*4882a593Smuzhiyun 539*4882a593Smuzhiyun ifndef NO_LIBBPF 540*4882a593Smuzhiyun ifeq ($(feature-bpf), 1) 541*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBBPF_SUPPORT 542*4882a593Smuzhiyun $(call detected,CONFIG_LIBBPF) 543*4882a593Smuzhiyun 544*4882a593Smuzhiyun # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status 545*4882a593Smuzhiyun $(call feature_check,libbpf) 546*4882a593Smuzhiyun ifdef LIBBPF_DYNAMIC 547*4882a593Smuzhiyun ifeq ($(feature-libbpf), 1) 548*4882a593Smuzhiyun EXTLIBS += -lbpf 549*4882a593Smuzhiyun $(call detected,CONFIG_LIBBPF_DYNAMIC) 550*4882a593Smuzhiyun else 551*4882a593Smuzhiyun dummy := $(error Error: No libbpf devel library found, please install libbpf-devel); 552*4882a593Smuzhiyun endif 553*4882a593Smuzhiyun endif 554*4882a593Smuzhiyun endif 555*4882a593Smuzhiyun 556*4882a593Smuzhiyun ifndef NO_DWARF 557*4882a593Smuzhiyun ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 558*4882a593Smuzhiyun CFLAGS += -DHAVE_BPF_PROLOGUE 559*4882a593Smuzhiyun $(call detected,CONFIG_BPF_PROLOGUE) 560*4882a593Smuzhiyun else 561*4882a593Smuzhiyun msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset()); 562*4882a593Smuzhiyun endif 563*4882a593Smuzhiyun else 564*4882a593Smuzhiyun msg := $(warning DWARF support is off, BPF prologue is disabled); 565*4882a593Smuzhiyun endif 566*4882a593Smuzhiyun 567*4882a593Smuzhiyun endif # NO_LIBBPF 568*4882a593Smuzhiyunendif # NO_LIBELF 569*4882a593Smuzhiyun 570*4882a593Smuzhiyunifndef NO_SDT 571*4882a593Smuzhiyun ifneq ($(feature-sdt), 1) 572*4882a593Smuzhiyun msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev); 573*4882a593Smuzhiyun NO_SDT := 1; 574*4882a593Smuzhiyun else 575*4882a593Smuzhiyun CFLAGS += -DHAVE_SDT_EVENT 576*4882a593Smuzhiyun $(call detected,CONFIG_SDT_EVENT) 577*4882a593Smuzhiyun endif 578*4882a593Smuzhiyunendif 579*4882a593Smuzhiyun 580*4882a593Smuzhiyunifdef PERF_HAVE_JITDUMP 581*4882a593Smuzhiyun ifndef NO_LIBELF 582*4882a593Smuzhiyun $(call detected,CONFIG_JITDUMP) 583*4882a593Smuzhiyun CFLAGS += -DHAVE_JITDUMP 584*4882a593Smuzhiyun endif 585*4882a593Smuzhiyunendif 586*4882a593Smuzhiyun 587*4882a593Smuzhiyunifeq ($(SRCARCH),powerpc) 588*4882a593Smuzhiyun ifndef NO_DWARF 589*4882a593Smuzhiyun CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX 590*4882a593Smuzhiyun endif 591*4882a593Smuzhiyunendif 592*4882a593Smuzhiyun 593*4882a593Smuzhiyunifndef NO_LIBUNWIND 594*4882a593Smuzhiyun have_libunwind := 595*4882a593Smuzhiyun 596*4882a593Smuzhiyun $(call feature_check,libunwind-x86) 597*4882a593Smuzhiyun ifeq ($(feature-libunwind-x86), 1) 598*4882a593Smuzhiyun $(call detected,CONFIG_LIBUNWIND_X86) 599*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT 600*4882a593Smuzhiyun LDFLAGS += -lunwind-x86 601*4882a593Smuzhiyun EXTLIBS_LIBUNWIND += -lunwind-x86 602*4882a593Smuzhiyun have_libunwind = 1 603*4882a593Smuzhiyun endif 604*4882a593Smuzhiyun 605*4882a593Smuzhiyun $(call feature_check,libunwind-aarch64) 606*4882a593Smuzhiyun ifeq ($(feature-libunwind-aarch64), 1) 607*4882a593Smuzhiyun $(call detected,CONFIG_LIBUNWIND_AARCH64) 608*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT 609*4882a593Smuzhiyun LDFLAGS += -lunwind-aarch64 610*4882a593Smuzhiyun EXTLIBS_LIBUNWIND += -lunwind-aarch64 611*4882a593Smuzhiyun have_libunwind = 1 612*4882a593Smuzhiyun $(call feature_check,libunwind-debug-frame-aarch64) 613*4882a593Smuzhiyun ifneq ($(feature-libunwind-debug-frame-aarch64), 1) 614*4882a593Smuzhiyun msg := $(warning No debug_frame support found in libunwind-aarch64); 615*4882a593Smuzhiyun CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64 616*4882a593Smuzhiyun endif 617*4882a593Smuzhiyun endif 618*4882a593Smuzhiyun 619*4882a593Smuzhiyun ifneq ($(feature-libunwind), 1) 620*4882a593Smuzhiyun msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR); 621*4882a593Smuzhiyun NO_LOCAL_LIBUNWIND := 1 622*4882a593Smuzhiyun else 623*4882a593Smuzhiyun have_libunwind := 1 624*4882a593Smuzhiyun $(call detected,CONFIG_LOCAL_LIBUNWIND) 625*4882a593Smuzhiyun endif 626*4882a593Smuzhiyun 627*4882a593Smuzhiyun ifneq ($(have_libunwind), 1) 628*4882a593Smuzhiyun NO_LIBUNWIND := 1 629*4882a593Smuzhiyun endif 630*4882a593Smuzhiyunelse 631*4882a593Smuzhiyun NO_LOCAL_LIBUNWIND := 1 632*4882a593Smuzhiyunendif 633*4882a593Smuzhiyun 634*4882a593Smuzhiyunifndef NO_LIBBPF 635*4882a593Smuzhiyun ifneq ($(feature-bpf), 1) 636*4882a593Smuzhiyun msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.) 637*4882a593Smuzhiyun NO_LIBBPF := 1 638*4882a593Smuzhiyun endif 639*4882a593Smuzhiyunendif 640*4882a593Smuzhiyun 641*4882a593Smuzhiyundwarf-post-unwind := 1 642*4882a593Smuzhiyundwarf-post-unwind-text := BUG 643*4882a593Smuzhiyun 644*4882a593Smuzhiyun# setup DWARF post unwinder 645*4882a593Smuzhiyunifdef NO_LIBUNWIND 646*4882a593Smuzhiyun ifdef NO_LIBDW_DWARF_UNWIND 647*4882a593Smuzhiyun msg := $(warning Disabling post unwind, no support found.); 648*4882a593Smuzhiyun dwarf-post-unwind := 0 649*4882a593Smuzhiyun else 650*4882a593Smuzhiyun dwarf-post-unwind-text := libdw 651*4882a593Smuzhiyun $(call detected,CONFIG_LIBDW_DWARF_UNWIND) 652*4882a593Smuzhiyun endif 653*4882a593Smuzhiyunelse 654*4882a593Smuzhiyun dwarf-post-unwind-text := libunwind 655*4882a593Smuzhiyun $(call detected,CONFIG_LIBUNWIND) 656*4882a593Smuzhiyun # Enable libunwind support by default. 657*4882a593Smuzhiyun ifndef NO_LIBDW_DWARF_UNWIND 658*4882a593Smuzhiyun NO_LIBDW_DWARF_UNWIND := 1 659*4882a593Smuzhiyun endif 660*4882a593Smuzhiyunendif 661*4882a593Smuzhiyun 662*4882a593Smuzhiyunifeq ($(dwarf-post-unwind),1) 663*4882a593Smuzhiyun CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT 664*4882a593Smuzhiyun $(call detected,CONFIG_DWARF_UNWIND) 665*4882a593Smuzhiyunelse 666*4882a593Smuzhiyun NO_DWARF_UNWIND := 1 667*4882a593Smuzhiyunendif 668*4882a593Smuzhiyun 669*4882a593Smuzhiyunifndef NO_LOCAL_LIBUNWIND 670*4882a593Smuzhiyun ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64)) 671*4882a593Smuzhiyun $(call feature_check,libunwind-debug-frame) 672*4882a593Smuzhiyun ifneq ($(feature-libunwind-debug-frame), 1) 673*4882a593Smuzhiyun msg := $(warning No debug_frame support found in libunwind); 674*4882a593Smuzhiyun CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 675*4882a593Smuzhiyun endif 676*4882a593Smuzhiyun else 677*4882a593Smuzhiyun # non-ARM has no dwarf_find_debug_frame() function: 678*4882a593Smuzhiyun CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME 679*4882a593Smuzhiyun endif 680*4882a593Smuzhiyun EXTLIBS += $(LIBUNWIND_LIBS) 681*4882a593Smuzhiyun LDFLAGS += $(LIBUNWIND_LIBS) 682*4882a593Smuzhiyunendif 683*4882a593Smuzhiyunifeq ($(findstring -static,${LDFLAGS}),-static) 684*4882a593Smuzhiyun # gcc -static links libgcc_eh which contans piece of libunwind 685*4882a593Smuzhiyun LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition 686*4882a593Smuzhiyunendif 687*4882a593Smuzhiyun 688*4882a593Smuzhiyunifndef NO_LIBUNWIND 689*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBUNWIND_SUPPORT 690*4882a593Smuzhiyun CFLAGS += $(LIBUNWIND_CFLAGS) 691*4882a593Smuzhiyun LDFLAGS += $(LIBUNWIND_LDFLAGS) 692*4882a593Smuzhiyun EXTLIBS += $(EXTLIBS_LIBUNWIND) 693*4882a593Smuzhiyunendif 694*4882a593Smuzhiyun 695*4882a593Smuzhiyunifeq ($(NO_SYSCALL_TABLE),0) 696*4882a593Smuzhiyun $(call detected,CONFIG_TRACE) 697*4882a593Smuzhiyunelse 698*4882a593Smuzhiyun ifndef NO_LIBAUDIT 699*4882a593Smuzhiyun $(call feature_check,libaudit) 700*4882a593Smuzhiyun ifneq ($(feature-libaudit), 1) 701*4882a593Smuzhiyun msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); 702*4882a593Smuzhiyun NO_LIBAUDIT := 1 703*4882a593Smuzhiyun else 704*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBAUDIT_SUPPORT 705*4882a593Smuzhiyun EXTLIBS += -laudit 706*4882a593Smuzhiyun $(call detected,CONFIG_TRACE) 707*4882a593Smuzhiyun endif 708*4882a593Smuzhiyun endif 709*4882a593Smuzhiyunendif 710*4882a593Smuzhiyun 711*4882a593Smuzhiyunifndef NO_LIBCRYPTO 712*4882a593Smuzhiyun ifneq ($(feature-libcrypto), 1) 713*4882a593Smuzhiyun msg := $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev); 714*4882a593Smuzhiyun NO_LIBCRYPTO := 1 715*4882a593Smuzhiyun else 716*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT 717*4882a593Smuzhiyun EXTLIBS += -lcrypto 718*4882a593Smuzhiyun $(call detected,CONFIG_CRYPTO) 719*4882a593Smuzhiyun endif 720*4882a593Smuzhiyunendif 721*4882a593Smuzhiyun 722*4882a593Smuzhiyunifdef NO_NEWT 723*4882a593Smuzhiyun NO_SLANG=1 724*4882a593Smuzhiyunendif 725*4882a593Smuzhiyun 726*4882a593Smuzhiyunifndef NO_SLANG 727*4882a593Smuzhiyun ifneq ($(feature-libslang), 1) 728*4882a593Smuzhiyun ifneq ($(feature-libslang-include-subdir), 1) 729*4882a593Smuzhiyun msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev); 730*4882a593Smuzhiyun NO_SLANG := 1 731*4882a593Smuzhiyun else 732*4882a593Smuzhiyun CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR 733*4882a593Smuzhiyun endif 734*4882a593Smuzhiyun endif 735*4882a593Smuzhiyun ifndef NO_SLANG 736*4882a593Smuzhiyun # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h 737*4882a593Smuzhiyun CFLAGS += -DHAVE_SLANG_SUPPORT 738*4882a593Smuzhiyun EXTLIBS += -lslang 739*4882a593Smuzhiyun $(call detected,CONFIG_SLANG) 740*4882a593Smuzhiyun endif 741*4882a593Smuzhiyunendif 742*4882a593Smuzhiyun 743*4882a593Smuzhiyunifdef GTK2 744*4882a593Smuzhiyun FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) 745*4882a593Smuzhiyun $(call feature_check,gtk2) 746*4882a593Smuzhiyun ifneq ($(feature-gtk2), 1) 747*4882a593Smuzhiyun msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); 748*4882a593Smuzhiyun NO_GTK2 := 1 749*4882a593Smuzhiyun else 750*4882a593Smuzhiyun $(call feature_check,gtk2-infobar) 751*4882a593Smuzhiyun ifeq ($(feature-gtk2-infobar), 1) 752*4882a593Smuzhiyun GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT 753*4882a593Smuzhiyun endif 754*4882a593Smuzhiyun CFLAGS += -DHAVE_GTK2_SUPPORT 755*4882a593Smuzhiyun GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null) 756*4882a593Smuzhiyun GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null) 757*4882a593Smuzhiyun EXTLIBS += -ldl 758*4882a593Smuzhiyun endif 759*4882a593Smuzhiyunendif 760*4882a593Smuzhiyun 761*4882a593Smuzhiyunifdef NO_LIBPERL 762*4882a593Smuzhiyun CFLAGS += -DNO_LIBPERL 763*4882a593Smuzhiyunelse 764*4882a593Smuzhiyun PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) 765*4882a593Smuzhiyun PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) 766*4882a593Smuzhiyun PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) 767*4882a593Smuzhiyun PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) 768*4882a593Smuzhiyun PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) 769*4882a593Smuzhiyun PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS)) 770*4882a593Smuzhiyun PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) 771*4882a593Smuzhiyun FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) 772*4882a593Smuzhiyun 773*4882a593Smuzhiyun ifneq ($(feature-libperl), 1) 774*4882a593Smuzhiyun CFLAGS += -DNO_LIBPERL 775*4882a593Smuzhiyun NO_LIBPERL := 1 776*4882a593Smuzhiyun msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev); 777*4882a593Smuzhiyun else 778*4882a593Smuzhiyun LDFLAGS += $(PERL_EMBED_LDFLAGS) 779*4882a593Smuzhiyun EXTLIBS += $(PERL_EMBED_LIBADD) 780*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBPERL_SUPPORT 781*4882a593Smuzhiyun ifeq ($(CC_NO_CLANG), 0) 782*4882a593Smuzhiyun CFLAGS += -Wno-compound-token-split-by-macro 783*4882a593Smuzhiyun endif 784*4882a593Smuzhiyun $(call detected,CONFIG_LIBPERL) 785*4882a593Smuzhiyun endif 786*4882a593Smuzhiyunendif 787*4882a593Smuzhiyun 788*4882a593Smuzhiyunifeq ($(feature-timerfd), 1) 789*4882a593Smuzhiyun CFLAGS += -DHAVE_TIMERFD_SUPPORT 790*4882a593Smuzhiyunelse 791*4882a593Smuzhiyun msg := $(warning No timerfd support. Disables 'perf kvm stat live'); 792*4882a593Smuzhiyunendif 793*4882a593Smuzhiyun 794*4882a593Smuzhiyundisable-python = $(eval $(disable-python_code)) 795*4882a593Smuzhiyundefine disable-python_code 796*4882a593Smuzhiyun CFLAGS += -DNO_LIBPYTHON 797*4882a593Smuzhiyun $(warning $1) 798*4882a593Smuzhiyun NO_LIBPYTHON := 1 799*4882a593Smuzhiyunendef 800*4882a593Smuzhiyun 801*4882a593Smuzhiyunifdef NO_LIBPYTHON 802*4882a593Smuzhiyun $(call disable-python,Python support disabled by user) 803*4882a593Smuzhiyunelse 804*4882a593Smuzhiyun 805*4882a593Smuzhiyun ifndef PYTHON 806*4882a593Smuzhiyun $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev) 807*4882a593Smuzhiyun else 808*4882a593Smuzhiyun PYTHON_WORD := $(call shell-wordify,$(PYTHON)) 809*4882a593Smuzhiyun 810*4882a593Smuzhiyun ifndef PYTHON_CONFIG 811*4882a593Smuzhiyun $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev) 812*4882a593Smuzhiyun else 813*4882a593Smuzhiyun 814*4882a593Smuzhiyun ifneq ($(feature-libpython), 1) 815*4882a593Smuzhiyun $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev) 816*4882a593Smuzhiyun else 817*4882a593Smuzhiyun LDFLAGS += $(PYTHON_EMBED_LDFLAGS) 818*4882a593Smuzhiyun EXTLIBS += $(PYTHON_EMBED_LIBADD) 819*4882a593Smuzhiyun LANG_BINDINGS += $(obj-perf)python/perf.so 820*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBPYTHON_SUPPORT 821*4882a593Smuzhiyun $(call detected,CONFIG_LIBPYTHON) 822*4882a593Smuzhiyun endif 823*4882a593Smuzhiyun endif 824*4882a593Smuzhiyun endif 825*4882a593Smuzhiyunendif 826*4882a593Smuzhiyun 827*4882a593Smuzhiyunifeq ($(feature-libbfd), 1) 828*4882a593Smuzhiyun EXTLIBS += -lbfd -lopcodes 829*4882a593Smuzhiyunelse 830*4882a593Smuzhiyun # we are on a system that requires -liberty and (maybe) -lz 831*4882a593Smuzhiyun # to link against -lbfd; test each case individually here 832*4882a593Smuzhiyun 833*4882a593Smuzhiyun # call all detections now so we get correct 834*4882a593Smuzhiyun # status in VF output 835*4882a593Smuzhiyun $(call feature_check,libbfd-liberty) 836*4882a593Smuzhiyun $(call feature_check,libbfd-liberty-z) 837*4882a593Smuzhiyun 838*4882a593Smuzhiyun ifeq ($(feature-libbfd-liberty), 1) 839*4882a593Smuzhiyun EXTLIBS += -lbfd -lopcodes -liberty 840*4882a593Smuzhiyun FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl 841*4882a593Smuzhiyun else 842*4882a593Smuzhiyun ifeq ($(feature-libbfd-liberty-z), 1) 843*4882a593Smuzhiyun EXTLIBS += -lbfd -lopcodes -liberty -lz 844*4882a593Smuzhiyun FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl 845*4882a593Smuzhiyun endif 846*4882a593Smuzhiyun endif 847*4882a593Smuzhiyun $(call feature_check,disassembler-four-args) 848*4882a593Smuzhiyunendif 849*4882a593Smuzhiyun 850*4882a593Smuzhiyunifeq ($(feature-libbfd-buildid), 1) 851*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT 852*4882a593Smuzhiyunelse 853*4882a593Smuzhiyun msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available); 854*4882a593Smuzhiyunendif 855*4882a593Smuzhiyun 856*4882a593Smuzhiyunifdef NO_DEMANGLE 857*4882a593Smuzhiyun CFLAGS += -DNO_DEMANGLE 858*4882a593Smuzhiyunelse 859*4882a593Smuzhiyun ifdef HAVE_CPLUS_DEMANGLE_SUPPORT 860*4882a593Smuzhiyun EXTLIBS += -liberty 861*4882a593Smuzhiyun else 862*4882a593Smuzhiyun ifeq ($(filter -liberty,$(EXTLIBS)),) 863*4882a593Smuzhiyun $(call feature_check,cplus-demangle) 864*4882a593Smuzhiyun 865*4882a593Smuzhiyun # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT 866*4882a593Smuzhiyun # or any of 'bfd iberty z' trinity 867*4882a593Smuzhiyun ifeq ($(feature-cplus-demangle), 1) 868*4882a593Smuzhiyun EXTLIBS += -liberty 869*4882a593Smuzhiyun else 870*4882a593Smuzhiyun msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling) 871*4882a593Smuzhiyun CFLAGS += -DNO_DEMANGLE 872*4882a593Smuzhiyun endif 873*4882a593Smuzhiyun endif 874*4882a593Smuzhiyun endif 875*4882a593Smuzhiyun 876*4882a593Smuzhiyun ifneq ($(filter -liberty,$(EXTLIBS)),) 877*4882a593Smuzhiyun CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 878*4882a593Smuzhiyun endif 879*4882a593Smuzhiyunendif 880*4882a593Smuzhiyun 881*4882a593Smuzhiyunifneq ($(filter -lbfd,$(EXTLIBS)),) 882*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBBFD_SUPPORT 883*4882a593Smuzhiyunendif 884*4882a593Smuzhiyun 885*4882a593Smuzhiyunifndef NO_ZLIB 886*4882a593Smuzhiyun ifeq ($(feature-zlib), 1) 887*4882a593Smuzhiyun CFLAGS += -DHAVE_ZLIB_SUPPORT 888*4882a593Smuzhiyun EXTLIBS += -lz 889*4882a593Smuzhiyun $(call detected,CONFIG_ZLIB) 890*4882a593Smuzhiyun else 891*4882a593Smuzhiyun NO_ZLIB := 1 892*4882a593Smuzhiyun endif 893*4882a593Smuzhiyunendif 894*4882a593Smuzhiyun 895*4882a593Smuzhiyunifndef NO_LZMA 896*4882a593Smuzhiyun ifeq ($(feature-lzma), 1) 897*4882a593Smuzhiyun CFLAGS += -DHAVE_LZMA_SUPPORT 898*4882a593Smuzhiyun EXTLIBS += -llzma 899*4882a593Smuzhiyun $(call detected,CONFIG_LZMA) 900*4882a593Smuzhiyun else 901*4882a593Smuzhiyun msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev); 902*4882a593Smuzhiyun NO_LZMA := 1 903*4882a593Smuzhiyun endif 904*4882a593Smuzhiyunendif 905*4882a593Smuzhiyun 906*4882a593Smuzhiyunifndef NO_LIBZSTD 907*4882a593Smuzhiyun ifeq ($(feature-libzstd), 1) 908*4882a593Smuzhiyun CFLAGS += -DHAVE_ZSTD_SUPPORT 909*4882a593Smuzhiyun CFLAGS += $(LIBZSTD_CFLAGS) 910*4882a593Smuzhiyun LDFLAGS += $(LIBZSTD_LDFLAGS) 911*4882a593Smuzhiyun EXTLIBS += -lzstd 912*4882a593Smuzhiyun $(call detected,CONFIG_ZSTD) 913*4882a593Smuzhiyun else 914*4882a593Smuzhiyun msg := $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR); 915*4882a593Smuzhiyun NO_LIBZSTD := 1 916*4882a593Smuzhiyun endif 917*4882a593Smuzhiyunendif 918*4882a593Smuzhiyun 919*4882a593Smuzhiyunifndef NO_LIBCAP 920*4882a593Smuzhiyun ifeq ($(feature-libcap), 1) 921*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBCAP_SUPPORT 922*4882a593Smuzhiyun EXTLIBS += -lcap 923*4882a593Smuzhiyun $(call detected,CONFIG_LIBCAP) 924*4882a593Smuzhiyun else 925*4882a593Smuzhiyun msg := $(warning No libcap found, disables capability support, please install libcap-devel/libcap-dev); 926*4882a593Smuzhiyun NO_LIBCAP := 1 927*4882a593Smuzhiyun endif 928*4882a593Smuzhiyunendif 929*4882a593Smuzhiyun 930*4882a593Smuzhiyunifndef NO_BACKTRACE 931*4882a593Smuzhiyun ifeq ($(feature-backtrace), 1) 932*4882a593Smuzhiyun CFLAGS += -DHAVE_BACKTRACE_SUPPORT 933*4882a593Smuzhiyun endif 934*4882a593Smuzhiyunendif 935*4882a593Smuzhiyun 936*4882a593Smuzhiyunifndef NO_LIBNUMA 937*4882a593Smuzhiyun ifeq ($(feature-libnuma), 0) 938*4882a593Smuzhiyun msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev); 939*4882a593Smuzhiyun NO_LIBNUMA := 1 940*4882a593Smuzhiyun else 941*4882a593Smuzhiyun ifeq ($(feature-numa_num_possible_cpus), 0) 942*4882a593Smuzhiyun msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8); 943*4882a593Smuzhiyun NO_LIBNUMA := 1 944*4882a593Smuzhiyun else 945*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBNUMA_SUPPORT 946*4882a593Smuzhiyun EXTLIBS += -lnuma 947*4882a593Smuzhiyun $(call detected,CONFIG_NUMA) 948*4882a593Smuzhiyun endif 949*4882a593Smuzhiyun endif 950*4882a593Smuzhiyunendif 951*4882a593Smuzhiyun 952*4882a593Smuzhiyunifdef HAVE_KVM_STAT_SUPPORT 953*4882a593Smuzhiyun CFLAGS += -DHAVE_KVM_STAT_SUPPORT 954*4882a593Smuzhiyunendif 955*4882a593Smuzhiyun 956*4882a593Smuzhiyunifeq ($(feature-disassembler-four-args), 1) 957*4882a593Smuzhiyun CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE 958*4882a593Smuzhiyunendif 959*4882a593Smuzhiyun 960*4882a593Smuzhiyunifeq (${IS_64_BIT}, 1) 961*4882a593Smuzhiyun ifndef NO_PERF_READ_VDSO32 962*4882a593Smuzhiyun $(call feature_check,compile-32) 963*4882a593Smuzhiyun ifeq ($(feature-compile-32), 1) 964*4882a593Smuzhiyun CFLAGS += -DHAVE_PERF_READ_VDSO32 965*4882a593Smuzhiyun else 966*4882a593Smuzhiyun NO_PERF_READ_VDSO32 := 1 967*4882a593Smuzhiyun endif 968*4882a593Smuzhiyun endif 969*4882a593Smuzhiyun ifneq ($(SRCARCH), x86) 970*4882a593Smuzhiyun NO_PERF_READ_VDSOX32 := 1 971*4882a593Smuzhiyun endif 972*4882a593Smuzhiyun ifndef NO_PERF_READ_VDSOX32 973*4882a593Smuzhiyun $(call feature_check,compile-x32) 974*4882a593Smuzhiyun ifeq ($(feature-compile-x32), 1) 975*4882a593Smuzhiyun CFLAGS += -DHAVE_PERF_READ_VDSOX32 976*4882a593Smuzhiyun else 977*4882a593Smuzhiyun NO_PERF_READ_VDSOX32 := 1 978*4882a593Smuzhiyun endif 979*4882a593Smuzhiyun endif 980*4882a593Smuzhiyunelse 981*4882a593Smuzhiyun NO_PERF_READ_VDSO32 := 1 982*4882a593Smuzhiyun NO_PERF_READ_VDSOX32 := 1 983*4882a593Smuzhiyunendif 984*4882a593Smuzhiyun 985*4882a593Smuzhiyunifndef NO_LIBBABELTRACE 986*4882a593Smuzhiyun $(call feature_check,libbabeltrace) 987*4882a593Smuzhiyun ifeq ($(feature-libbabeltrace), 1) 988*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS) 989*4882a593Smuzhiyun LDFLAGS += $(LIBBABELTRACE_LDFLAGS) 990*4882a593Smuzhiyun EXTLIBS += -lbabeltrace-ctf 991*4882a593Smuzhiyun $(call detected,CONFIG_LIBBABELTRACE) 992*4882a593Smuzhiyun else 993*4882a593Smuzhiyun msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev); 994*4882a593Smuzhiyun endif 995*4882a593Smuzhiyunendif 996*4882a593Smuzhiyun 997*4882a593Smuzhiyunifndef NO_AUXTRACE 998*4882a593Smuzhiyun ifeq ($(SRCARCH),x86) 999*4882a593Smuzhiyun ifeq ($(feature-get_cpuid), 0) 1000*4882a593Smuzhiyun msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); 1001*4882a593Smuzhiyun NO_AUXTRACE := 1 1002*4882a593Smuzhiyun endif 1003*4882a593Smuzhiyun endif 1004*4882a593Smuzhiyun ifndef NO_AUXTRACE 1005*4882a593Smuzhiyun $(call detected,CONFIG_AUXTRACE) 1006*4882a593Smuzhiyun CFLAGS += -DHAVE_AUXTRACE_SUPPORT 1007*4882a593Smuzhiyun endif 1008*4882a593Smuzhiyunendif 1009*4882a593Smuzhiyun 1010*4882a593Smuzhiyunifndef NO_JVMTI 1011*4882a593Smuzhiyun ifneq (,$(wildcard /usr/sbin/update-java-alternatives)) 1012*4882a593Smuzhiyun JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}') 1013*4882a593Smuzhiyun else 1014*4882a593Smuzhiyun ifneq (,$(wildcard /usr/sbin/alternatives)) 1015*4882a593Smuzhiyun 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') 1016*4882a593Smuzhiyun endif 1017*4882a593Smuzhiyun endif 1018*4882a593Smuzhiyun ifndef JDIR 1019*4882a593Smuzhiyun $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory) 1020*4882a593Smuzhiyun NO_JVMTI := 1 1021*4882a593Smuzhiyun endif 1022*4882a593Smuzhiyunendif 1023*4882a593Smuzhiyun 1024*4882a593Smuzhiyunifndef NO_JVMTI 1025*4882a593Smuzhiyun FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux 1026*4882a593Smuzhiyun $(call feature_check,jvmti) 1027*4882a593Smuzhiyun ifeq ($(feature-jvmti), 1) 1028*4882a593Smuzhiyun $(call detected_var,JDIR) 1029*4882a593Smuzhiyun ifndef NO_JVMTI_CMLR 1030*4882a593Smuzhiyun FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti) 1031*4882a593Smuzhiyun $(call feature_check,jvmti-cmlr) 1032*4882a593Smuzhiyun ifeq ($(feature-jvmti-cmlr), 1) 1033*4882a593Smuzhiyun CFLAGS += -DHAVE_JVMTI_CMLR 1034*4882a593Smuzhiyun endif 1035*4882a593Smuzhiyun endif # NO_JVMTI_CMLR 1036*4882a593Smuzhiyun else 1037*4882a593Smuzhiyun $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel) 1038*4882a593Smuzhiyun NO_JVMTI := 1 1039*4882a593Smuzhiyun endif 1040*4882a593Smuzhiyunendif 1041*4882a593Smuzhiyun 1042*4882a593SmuzhiyunUSE_CXX = 0 1043*4882a593SmuzhiyunUSE_CLANGLLVM = 0 1044*4882a593Smuzhiyunifdef LIBCLANGLLVM 1045*4882a593Smuzhiyun $(call feature_check,cxx) 1046*4882a593Smuzhiyun ifneq ($(feature-cxx), 1) 1047*4882a593Smuzhiyun msg := $(warning No g++ found, disable clang and llvm support. Please install g++) 1048*4882a593Smuzhiyun else 1049*4882a593Smuzhiyun $(call feature_check,llvm) 1050*4882a593Smuzhiyun $(call feature_check,llvm-version) 1051*4882a593Smuzhiyun ifneq ($(feature-llvm), 1) 1052*4882a593Smuzhiyun msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0)) 1053*4882a593Smuzhiyun else 1054*4882a593Smuzhiyun $(call feature_check,clang) 1055*4882a593Smuzhiyun ifneq ($(feature-clang), 1) 1056*4882a593Smuzhiyun msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0)) 1057*4882a593Smuzhiyun else 1058*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT 1059*4882a593Smuzhiyun CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir) 1060*4882a593Smuzhiyun $(call detected,CONFIG_CXX) 1061*4882a593Smuzhiyun $(call detected,CONFIG_CLANGLLVM) 1062*4882a593Smuzhiyun USE_CXX = 1 1063*4882a593Smuzhiyun USE_LLVM = 1 1064*4882a593Smuzhiyun USE_CLANG = 1 1065*4882a593Smuzhiyun ifneq ($(feature-llvm-version),1) 1066*4882a593Smuzhiyun msg := $(warning This version of LLVM is not tested. May cause build errors) 1067*4882a593Smuzhiyun endif 1068*4882a593Smuzhiyun endif 1069*4882a593Smuzhiyun endif 1070*4882a593Smuzhiyun endif 1071*4882a593Smuzhiyunendif 1072*4882a593Smuzhiyun 1073*4882a593Smuzhiyunifdef LIBPFM4 1074*4882a593Smuzhiyun $(call feature_check,libpfm4) 1075*4882a593Smuzhiyun ifeq ($(feature-libpfm4), 1) 1076*4882a593Smuzhiyun CFLAGS += -DHAVE_LIBPFM 1077*4882a593Smuzhiyun EXTLIBS += -lpfm 1078*4882a593Smuzhiyun ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1 1079*4882a593Smuzhiyun $(call detected,CONFIG_LIBPFM4) 1080*4882a593Smuzhiyun else 1081*4882a593Smuzhiyun msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev); 1082*4882a593Smuzhiyun NO_LIBPFM4 := 1 1083*4882a593Smuzhiyun endif 1084*4882a593Smuzhiyunendif 1085*4882a593Smuzhiyun 1086*4882a593Smuzhiyun# Among the variables below, these: 1087*4882a593Smuzhiyun# perfexecdir 1088*4882a593Smuzhiyun# perf_include_dir 1089*4882a593Smuzhiyun# perf_examples_dir 1090*4882a593Smuzhiyun# template_dir 1091*4882a593Smuzhiyun# mandir 1092*4882a593Smuzhiyun# infodir 1093*4882a593Smuzhiyun# htmldir 1094*4882a593Smuzhiyun# ETC_PERFCONFIG (but not sysconfdir) 1095*4882a593Smuzhiyun# can be specified as a relative path some/where/else; 1096*4882a593Smuzhiyun# this is interpreted as relative to $(prefix) and "perf" at 1097*4882a593Smuzhiyun# runtime figures out where they are based on the path to the executable. 1098*4882a593Smuzhiyun# This can help installing the suite in a relocatable way. 1099*4882a593Smuzhiyun 1100*4882a593Smuzhiyun# Make the path relative to DESTDIR, not to prefix 1101*4882a593Smuzhiyunifndef DESTDIR 1102*4882a593Smuzhiyunprefix ?= $(HOME) 1103*4882a593Smuzhiyunendif 1104*4882a593Smuzhiyunbindir_relative = bin 1105*4882a593Smuzhiyunbindir = $(abspath $(prefix)/$(bindir_relative)) 1106*4882a593Smuzhiyunmandir = share/man 1107*4882a593Smuzhiyuninfodir = share/info 1108*4882a593Smuzhiyunperfexecdir = libexec/perf-core 1109*4882a593Smuzhiyunperf_include_dir = lib/perf/include 1110*4882a593Smuzhiyunperf_examples_dir = lib/perf/examples 1111*4882a593Smuzhiyunsharedir = $(prefix)/share 1112*4882a593Smuzhiyuntemplate_dir = share/perf-core/templates 1113*4882a593SmuzhiyunSTRACE_GROUPS_DIR = share/perf-core/strace/groups 1114*4882a593Smuzhiyunhtmldir = share/doc/perf-doc 1115*4882a593Smuzhiyuntipdir = share/doc/perf-tip 1116*4882a593Smuzhiyunsrcdir = $(srctree)/tools/perf 1117*4882a593Smuzhiyunifeq ($(prefix),/usr) 1118*4882a593Smuzhiyunsysconfdir = /etc 1119*4882a593SmuzhiyunETC_PERFCONFIG = $(sysconfdir)/perfconfig 1120*4882a593Smuzhiyunelse 1121*4882a593Smuzhiyunsysconfdir = $(prefix)/etc 1122*4882a593SmuzhiyunETC_PERFCONFIG = etc/perfconfig 1123*4882a593Smuzhiyunendif 1124*4882a593Smuzhiyunifndef lib 1125*4882a593Smuzhiyunifeq ($(SRCARCH)$(IS_64_BIT), x861) 1126*4882a593Smuzhiyunlib = lib64 1127*4882a593Smuzhiyunelse 1128*4882a593Smuzhiyunlib = lib 1129*4882a593Smuzhiyunendif 1130*4882a593Smuzhiyunendif # lib 1131*4882a593Smuzhiyunlibdir = $(prefix)/$(lib) 1132*4882a593Smuzhiyun 1133*4882a593Smuzhiyun# Shell quote (do not use $(call) to accommodate ancient setups); 1134*4882a593SmuzhiyunETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) 1135*4882a593SmuzhiyunSTRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR)) 1136*4882a593SmuzhiyunDESTDIR_SQ = $(subst ','\'',$(DESTDIR)) 1137*4882a593Smuzhiyunbindir_SQ = $(subst ','\'',$(bindir)) 1138*4882a593Smuzhiyunmandir_SQ = $(subst ','\'',$(mandir)) 1139*4882a593Smuzhiyuninfodir_SQ = $(subst ','\'',$(infodir)) 1140*4882a593Smuzhiyunperfexecdir_SQ = $(subst ','\'',$(perfexecdir)) 1141*4882a593Smuzhiyunperf_include_dir_SQ = $(subst ','\'',$(perf_include_dir)) 1142*4882a593Smuzhiyunperf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir)) 1143*4882a593Smuzhiyuntemplate_dir_SQ = $(subst ','\'',$(template_dir)) 1144*4882a593Smuzhiyunhtmldir_SQ = $(subst ','\'',$(htmldir)) 1145*4882a593Smuzhiyuntipdir_SQ = $(subst ','\'',$(tipdir)) 1146*4882a593Smuzhiyunprefix_SQ = $(subst ','\'',$(prefix)) 1147*4882a593Smuzhiyunsysconfdir_SQ = $(subst ','\'',$(sysconfdir)) 1148*4882a593Smuzhiyunlibdir_SQ = $(subst ','\'',$(libdir)) 1149*4882a593Smuzhiyunsrcdir_SQ = $(subst ','\'',$(srcdir)) 1150*4882a593Smuzhiyun 1151*4882a593Smuzhiyunifneq ($(filter /%,$(firstword $(perfexecdir))),) 1152*4882a593Smuzhiyunperfexec_instdir = $(perfexecdir) 1153*4882a593Smuzhiyunperf_include_instdir = $(perf_include_dir) 1154*4882a593Smuzhiyunperf_examples_instdir = $(perf_examples_dir) 1155*4882a593SmuzhiyunSTRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR) 1156*4882a593Smuzhiyuntip_instdir = $(tipdir) 1157*4882a593Smuzhiyunelse 1158*4882a593Smuzhiyunperfexec_instdir = $(prefix)/$(perfexecdir) 1159*4882a593Smuzhiyunperf_include_instdir = $(prefix)/$(perf_include_dir) 1160*4882a593Smuzhiyunperf_examples_instdir = $(prefix)/$(perf_examples_dir) 1161*4882a593SmuzhiyunSTRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR) 1162*4882a593Smuzhiyuntip_instdir = $(prefix)/$(tipdir) 1163*4882a593Smuzhiyunendif 1164*4882a593Smuzhiyunperfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) 1165*4882a593Smuzhiyunperf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir)) 1166*4882a593Smuzhiyunperf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir)) 1167*4882a593SmuzhiyunSTRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR)) 1168*4882a593Smuzhiyuntip_instdir_SQ = $(subst ','\'',$(tip_instdir)) 1169*4882a593Smuzhiyun 1170*4882a593Smuzhiyun# If we install to $(HOME) we keep the traceevent default: 1171*4882a593Smuzhiyun# $(HOME)/.traceevent/plugins 1172*4882a593Smuzhiyun# Otherwise we install plugins into the global $(libdir). 1173*4882a593Smuzhiyunifdef DESTDIR 1174*4882a593Smuzhiyunplugindir=$(libdir)/traceevent/plugins 1175*4882a593Smuzhiyunplugindir_SQ= $(subst ','\'',$(plugindir)) 1176*4882a593Smuzhiyunendif 1177*4882a593Smuzhiyun 1178*4882a593Smuzhiyunprint_var = $(eval $(print_var_code)) $(info $(MSG)) 1179*4882a593Smuzhiyundefine print_var_code 1180*4882a593Smuzhiyun MSG = $(shell printf '...%30s: %s' $(1) $($(1))) 1181*4882a593Smuzhiyunendef 1182*4882a593Smuzhiyun 1183*4882a593Smuzhiyunifeq ($(VF),1) 1184*4882a593Smuzhiyun # Display EXTRA features which are detected manualy 1185*4882a593Smuzhiyun # from here with feature_check call and thus cannot 1186*4882a593Smuzhiyun # be partof global state output. 1187*4882a593Smuzhiyun $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),)) 1188*4882a593Smuzhiyun $(call print_var,prefix) 1189*4882a593Smuzhiyun $(call print_var,bindir) 1190*4882a593Smuzhiyun $(call print_var,libdir) 1191*4882a593Smuzhiyun $(call print_var,sysconfdir) 1192*4882a593Smuzhiyun $(call print_var,LIBUNWIND_DIR) 1193*4882a593Smuzhiyun $(call print_var,LIBDW_DIR) 1194*4882a593Smuzhiyun $(call print_var,JDIR) 1195*4882a593Smuzhiyun 1196*4882a593Smuzhiyun ifeq ($(dwarf-post-unwind),1) 1197*4882a593Smuzhiyun $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) 1198*4882a593Smuzhiyun endif 1199*4882a593Smuzhiyun $(info ) 1200*4882a593Smuzhiyunendif 1201*4882a593Smuzhiyun 1202*4882a593Smuzhiyun$(call detected_var,bindir_SQ) 1203*4882a593Smuzhiyun$(call detected_var,PYTHON_WORD) 1204*4882a593Smuzhiyunifneq ($(OUTPUT),) 1205*4882a593Smuzhiyun$(call detected_var,OUTPUT) 1206*4882a593Smuzhiyunendif 1207*4882a593Smuzhiyun$(call detected_var,htmldir_SQ) 1208*4882a593Smuzhiyun$(call detected_var,infodir_SQ) 1209*4882a593Smuzhiyun$(call detected_var,mandir_SQ) 1210*4882a593Smuzhiyun$(call detected_var,ETC_PERFCONFIG_SQ) 1211*4882a593Smuzhiyun$(call detected_var,STRACE_GROUPS_DIR_SQ) 1212*4882a593Smuzhiyun$(call detected_var,prefix_SQ) 1213*4882a593Smuzhiyun$(call detected_var,perfexecdir_SQ) 1214*4882a593Smuzhiyun$(call detected_var,perf_include_dir_SQ) 1215*4882a593Smuzhiyun$(call detected_var,perf_examples_dir_SQ) 1216*4882a593Smuzhiyun$(call detected_var,tipdir_SQ) 1217*4882a593Smuzhiyun$(call detected_var,srcdir_SQ) 1218*4882a593Smuzhiyun$(call detected_var,LIBDIR) 1219*4882a593Smuzhiyun$(call detected_var,GTK_CFLAGS) 1220*4882a593Smuzhiyun$(call detected_var,PERL_EMBED_CCOPTS) 1221*4882a593Smuzhiyun$(call detected_var,PYTHON_EMBED_CCOPTS) 1222