0001
0002
0003 ifeq ($(src-perf),)
0004 src-perf := $(srctree)/tools/perf
0005 endif
0006
0007 ifeq ($(obj-perf),)
0008 obj-perf := $(OUTPUT)
0009 endif
0010
0011 ifneq ($(obj-perf),)
0012 obj-perf := $(abspath $(obj-perf))/
0013 endif
0014
0015 $(shell printf "" > $(OUTPUT).config-detected)
0016 detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
0017 detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
0018
0019 CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
0020 HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
0021
0022 include $(srctree)/tools/scripts/Makefile.arch
0023
0024 $(call detected_var,SRCARCH)
0025
0026 NO_PERF_REGS := 1
0027
0028 ifneq ($(NO_SYSCALL_TABLE),1)
0029 NO_SYSCALL_TABLE := 1
0030
0031 ifeq ($(SRCARCH),x86)
0032 ifeq (${IS_64_BIT}, 1)
0033 NO_SYSCALL_TABLE := 0
0034 endif
0035 else
0036 ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390 mips))
0037 NO_SYSCALL_TABLE := 0
0038 endif
0039 endif
0040
0041 ifneq ($(NO_SYSCALL_TABLE),1)
0042 CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT
0043 endif
0044 endif
0045
0046
0047 ifeq ($(SRCARCH),powerpc)
0048 NO_PERF_REGS := 0
0049 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated
0050 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
0051 endif
0052
0053
0054 ifeq ($(SRCARCH),x86)
0055 $(call detected,CONFIG_X86)
0056 ifeq (${IS_64_BIT}, 1)
0057 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated
0058 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
0059 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
0060 $(call detected,CONFIG_X86_64)
0061 else
0062 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
0063 endif
0064 NO_PERF_REGS := 0
0065 endif
0066
0067 ifeq ($(SRCARCH),arm)
0068 NO_PERF_REGS := 0
0069 LIBUNWIND_LIBS = -lunwind -lunwind-arm
0070 endif
0071
0072 ifeq ($(SRCARCH),arm64)
0073 NO_PERF_REGS := 0
0074 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
0075 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
0076 endif
0077
0078 ifeq ($(SRCARCH),riscv)
0079 NO_PERF_REGS := 0
0080 endif
0081
0082 ifeq ($(SRCARCH),csky)
0083 NO_PERF_REGS := 0
0084 endif
0085
0086 ifeq ($(ARCH),s390)
0087 NO_PERF_REGS := 0
0088 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
0089 endif
0090
0091 ifeq ($(ARCH),mips)
0092 NO_PERF_REGS := 0
0093 CFLAGS += -I$(OUTPUT)arch/mips/include/generated
0094 LIBUNWIND_LIBS = -lunwind -lunwind-mips
0095 endif
0096
0097 ifeq ($(NO_PERF_REGS),0)
0098 $(call detected,CONFIG_PERF_REGS)
0099 endif
0100
0101
0102
0103
0104
0105 ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv))
0106 NO_LIBDW_DWARF_UNWIND := 1
0107 endif
0108
0109 ifeq ($(LIBUNWIND_LIBS),)
0110 NO_LIBUNWIND := 1
0111 endif
0112
0113
0114
0115
0116
0117
0118 libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))
0119 define libunwind_arch_set_flags_code
0120 FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
0121 FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib
0122 endef
0123
0124 ifdef LIBUNWIND_DIR
0125 LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
0126 LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
0127 LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64
0128 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
0129 endif
0130
0131
0132 FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
0133 FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
0134 FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
0135 FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
0136
0137 FEATURE_CHECK_LDFLAGS-libunwind-arm += -lunwind -lunwind-arm
0138 FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
0139 FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
0140 FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
0141
0142 FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
0143
0144 ifdef CSINCLUDES
0145 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
0146 endif
0147 OPENCSDLIBS := -lopencsd_c_api
0148 ifeq ($(findstring -static,${LDFLAGS}),-static)
0149 OPENCSDLIBS += -lopencsd -lstdc++
0150 endif
0151 ifdef CSLIBS
0152 LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
0153 endif
0154 FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)
0155 FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS)
0156
0157 ifeq ($(NO_PERF_REGS),0)
0158 CFLAGS += -DHAVE_PERF_REGS_SUPPORT
0159 endif
0160
0161
0162
0163 ifdef LIBDW_DIR
0164 LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
0165 LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
0166 endif
0167 DWARFLIBS := -ldw
0168 ifeq ($(findstring -static,${LDFLAGS}),-static)
0169 DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
0170 endif
0171 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
0172 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
0173
0174
0175
0176 ifdef LIBBABELTRACE_DIR
0177 LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include
0178 LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib
0179 endif
0180 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
0181 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
0182
0183 ifdef LIBZSTD_DIR
0184 LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib
0185 LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
0186 endif
0187 FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
0188 FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
0189
0190 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
0191
0192 -include $(src-perf)/arch/$(SRCARCH)/Makefile
0193
0194 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
0195 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
0196 endif
0197
0198 include $(srctree)/tools/scripts/utilities.mak
0199
0200 ifeq ($(call get-executable,$(FLEX)),)
0201 dummy := $(error Error: $(FLEX) is missing on this system, please install it)
0202 endif
0203
0204 ifeq ($(call get-executable,$(BISON)),)
0205 dummy := $(error Error: $(BISON) is missing on this system, please install it)
0206 endif
0207
0208 ifneq ($(OUTPUT),)
0209 ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1)
0210 BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)=
0211 endif
0212 endif
0213
0214
0215 ifneq ($(WERROR),0)
0216 CORE_CFLAGS += -Werror
0217 CXXFLAGS += -Werror
0218 HOSTCFLAGS += -Werror
0219 endif
0220
0221 ifndef DEBUG
0222 DEBUG := 0
0223 endif
0224
0225 ifeq ($(DEBUG),0)
0226 ifeq ($(CC_NO_CLANG), 0)
0227 CORE_CFLAGS += -O3
0228 else
0229 CORE_CFLAGS += -O6
0230 endif
0231 endif
0232
0233 ifdef PARSER_DEBUG
0234 PARSER_DEBUG_BISON := -t
0235 PARSER_DEBUG_FLEX := -d
0236 CFLAGS += -DPARSER_DEBUG
0237 $(call detected_var,PARSER_DEBUG_BISON)
0238 $(call detected_var,PARSER_DEBUG_FLEX)
0239 endif
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249 PYTHON_AUTO := python-config
0250 PYTHON_AUTO := $(if $(call get-executable,python2-config),python2-config,$(PYTHON_AUTO))
0251 PYTHON_AUTO := $(if $(call get-executable,python-config),python-config,$(PYTHON_AUTO))
0252 PYTHON_AUTO := $(if $(call get-executable,python3-config),python3-config,$(PYTHON_AUTO))
0253
0254
0255
0256 ifdef PYTHON
0257 ifndef PYTHON_CONFIG
0258 PYTHON_CONFIG_AUTO := $(call get-executable,$(PYTHON)-config)
0259 PYTHON_CONFIG := $(if $(PYTHON_CONFIG_AUTO),$(PYTHON_CONFIG_AUTO),\
0260 $(call $(error $(PYTHON)-config not found)))
0261 endif
0262 endif
0263
0264
0265
0266
0267 override PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO))
0268 override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_CONFIG)))
0269
0270 grep-libs = $(filter -l%,$(1))
0271 strip-libs = $(filter-out -l%,$(1))
0272
0273 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
0274
0275
0276
0277
0278 ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
0279 PYTHON_CONFIG_LDFLAGS := --ldflags --embed
0280 else
0281 PYTHON_CONFIG_LDFLAGS := --ldflags
0282 endif
0283
0284 ifdef PYTHON_CONFIG
0285 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
0286 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
0287 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
0288 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
0289 FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
0290 ifeq ($(CC_NO_CLANG), 0)
0291 PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS))
0292 endif
0293 endif
0294
0295 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
0296 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
0297
0298 FEATURE_CHECK_LDFLAGS-libaio = -lrt
0299
0300 CORE_CFLAGS += -fno-omit-frame-pointer
0301 CORE_CFLAGS += -ggdb3
0302 CORE_CFLAGS += -funwind-tables
0303 CORE_CFLAGS += -Wall
0304 CORE_CFLAGS += -Wextra
0305 CORE_CFLAGS += -std=gnu99
0306
0307 CXXFLAGS += -std=gnu++14 -fno-exceptions -fno-rtti
0308 CXXFLAGS += -Wall
0309 CXXFLAGS += -fno-omit-frame-pointer
0310 CXXFLAGS += -ggdb3
0311 CXXFLAGS += -funwind-tables
0312 CXXFLAGS += -Wno-strict-aliasing
0313
0314 HOSTCFLAGS += -Wall
0315 HOSTCFLAGS += -Wextra
0316
0317
0318
0319 LDFLAGS += -Wl,-z,noexecstack
0320
0321 EXTLIBS = -lpthread -lrt -lm -ldl
0322
0323 ifneq ($(TCMALLOC),)
0324 CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
0325 EXTLIBS += -ltcmalloc
0326 endif
0327
0328 ifeq ($(FEATURES_DUMP),)
0329
0330
0331 FEATURE_DISPLAY_DEFERRED := 1
0332 include $(srctree)/tools/build/Makefile.feature
0333 else
0334 include $(FEATURES_DUMP)
0335 endif
0336
0337 ifeq ($(feature-stackprotector-all), 1)
0338 CORE_CFLAGS += -fstack-protector-all
0339 endif
0340
0341 ifeq ($(DEBUG),0)
0342 ifeq ($(feature-fortify-source), 1)
0343 CORE_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
0344 endif
0345 endif
0346
0347 INC_FLAGS += -I$(srctree)/tools/lib/perf/include
0348 INC_FLAGS += -I$(src-perf)/util/include
0349 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
0350 INC_FLAGS += -I$(srctree)/tools/include/
0351 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
0352 INC_FLAGS += -I$(srctree)/tools/include/uapi
0353 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
0354 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
0355
0356
0357
0358 ifneq ($(OUTPUT),)
0359 INC_FLAGS += -I$(obj-perf)/util
0360 INC_FLAGS += -I$(obj-perf)
0361 endif
0362
0363 INC_FLAGS += -I$(src-perf)/util
0364 INC_FLAGS += -I$(src-perf)
0365 INC_FLAGS += -I$(srctree)/tools/lib/
0366
0367 CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
0368
0369 CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)
0370 CXXFLAGS += $(INC_FLAGS)
0371
0372 LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)
0373
0374 ifeq ($(feature-pthread-attr-setaffinity-np), 1)
0375 CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
0376 endif
0377
0378 ifeq ($(feature-pthread-barrier), 1)
0379 CFLAGS += -DHAVE_PTHREAD_BARRIER
0380 endif
0381
0382 ifndef NO_BIONIC
0383 $(call feature_check,bionic)
0384 ifeq ($(feature-bionic), 1)
0385 BIONIC := 1
0386 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
0387 CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
0388 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
0389 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
0390 endif
0391 endif
0392
0393 ifeq ($(feature-eventfd), 1)
0394 CFLAGS += -DHAVE_EVENTFD_SUPPORT
0395 endif
0396
0397 ifeq ($(feature-get_current_dir_name), 1)
0398 CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
0399 endif
0400
0401 ifeq ($(feature-gettid), 1)
0402 CFLAGS += -DHAVE_GETTID
0403 endif
0404
0405 ifeq ($(feature-file-handle), 1)
0406 CFLAGS += -DHAVE_FILE_HANDLE
0407 endif
0408
0409 ifdef NO_LIBELF
0410 NO_DWARF := 1
0411 NO_DEMANGLE := 1
0412 NO_LIBUNWIND := 1
0413 NO_LIBDW_DWARF_UNWIND := 1
0414 NO_LIBBPF := 1
0415 NO_JVMTI := 1
0416 else
0417 ifeq ($(feature-libelf), 0)
0418 ifeq ($(feature-glibc), 1)
0419 LIBC_SUPPORT := 1
0420 endif
0421 ifeq ($(BIONIC),1)
0422 LIBC_SUPPORT := 1
0423 endif
0424 ifeq ($(LIBC_SUPPORT),1)
0425 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);
0426
0427 NO_LIBELF := 1
0428 NO_DWARF := 1
0429 NO_DEMANGLE := 1
0430 NO_LIBUNWIND := 1
0431 NO_LIBDW_DWARF_UNWIND := 1
0432 NO_LIBBPF := 1
0433 NO_JVMTI := 1
0434 else
0435 ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)
0436 ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)
0437 msg := $(error No libasan found, please install libasan);
0438 endif
0439 endif
0440
0441 ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),)
0442 ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0)
0443 msg := $(error No libubsan found, please install libubsan);
0444 endif
0445 endif
0446
0447 ifneq ($(filter s% -static%,$(LDFLAGS),),)
0448 msg := $(error No static glibc found, please install glibc-static);
0449 else
0450 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
0451 endif
0452 endif
0453 else
0454 ifndef NO_LIBDW_DWARF_UNWIND
0455 ifneq ($(feature-libdw-dwarf-unwind),1)
0456 NO_LIBDW_DWARF_UNWIND := 1
0457 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
0458 endif
0459 endif
0460 ifneq ($(feature-dwarf), 1)
0461 ifndef NO_DWARF
0462 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);
0463 NO_DWARF := 1
0464 endif
0465 else
0466 ifneq ($(feature-dwarf_getlocations), 1)
0467 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
0468 else
0469 CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
0470 endif
0471 endif
0472 endif
0473 endif
0474
0475 ifeq ($(feature-glibc), 1)
0476 CFLAGS += -DHAVE_GLIBC_SUPPORT
0477 endif
0478
0479 ifeq ($(feature-libaio), 1)
0480 ifndef NO_AIO
0481 CFLAGS += -DHAVE_AIO_SUPPORT
0482 endif
0483 endif
0484
0485 ifdef NO_DWARF
0486 NO_LIBDW_DWARF_UNWIND := 1
0487 endif
0488
0489 ifeq ($(feature-sched_getcpu), 1)
0490 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
0491 endif
0492
0493 ifeq ($(feature-setns), 1)
0494 CFLAGS += -DHAVE_SETNS_SUPPORT
0495 $(call detected,CONFIG_SETNS)
0496 endif
0497
0498 ifdef CORESIGHT
0499 $(call feature_check,libopencsd)
0500 ifeq ($(feature-libopencsd), 1)
0501 CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
0502 ifeq ($(feature-reallocarray), 0)
0503 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
0504 endif
0505 LDFLAGS += $(LIBOPENCSD_LDFLAGS)
0506 EXTLIBS += $(OPENCSDLIBS)
0507 $(call detected,CONFIG_LIBOPENCSD)
0508 ifdef CSTRACE_RAW
0509 CFLAGS += -DCS_DEBUG_RAW
0510 ifeq (${CSTRACE_RAW}, packed)
0511 CFLAGS += -DCS_RAW_PACKED
0512 endif
0513 endif
0514 else
0515 dummy := $(error Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1)
0516 endif
0517 endif
0518
0519 ifndef NO_LIBELF
0520 CFLAGS += -DHAVE_LIBELF_SUPPORT
0521 EXTLIBS += -lelf
0522 $(call detected,CONFIG_LIBELF)
0523
0524 ifeq ($(feature-libelf-getphdrnum), 1)
0525 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
0526 endif
0527
0528 ifeq ($(feature-libelf-gelf_getnote), 1)
0529 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
0530 else
0531 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
0532 endif
0533
0534 ifeq ($(feature-libelf-getshdrstrndx), 1)
0535 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
0536 endif
0537
0538 ifndef NO_LIBDEBUGINFOD
0539 $(call feature_check,libdebuginfod)
0540 ifeq ($(feature-libdebuginfod), 1)
0541 CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT
0542 EXTLIBS += -ldebuginfod
0543 endif
0544 endif
0545
0546 ifndef NO_DWARF
0547 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
0548 msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
0549 NO_DWARF := 1
0550 else
0551 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
0552 LDFLAGS += $(LIBDW_LDFLAGS)
0553 EXTLIBS += ${DWARFLIBS}
0554 $(call detected,CONFIG_DWARF)
0555 endif
0556 endif
0557
0558 ifndef NO_LIBBPF
0559 ifeq ($(feature-bpf), 1)
0560 CFLAGS += -DHAVE_LIBBPF_SUPPORT
0561 $(call detected,CONFIG_LIBBPF)
0562
0563
0564 $(call feature_check,libbpf)
0565 ifdef LIBBPF_DYNAMIC
0566 ifeq ($(feature-libbpf), 1)
0567 EXTLIBS += -lbpf
0568 $(call detected,CONFIG_LIBBPF_DYNAMIC)
0569
0570 $(call feature_check,libbpf-btf__load_from_kernel_by_id)
0571 ifeq ($(feature-libbpf-btf__load_from_kernel_by_id), 1)
0572 CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
0573 endif
0574 $(call feature_check,libbpf-bpf_prog_load)
0575 ifeq ($(feature-libbpf-bpf_prog_load), 1)
0576 CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
0577 endif
0578 $(call feature_check,libbpf-bpf_object__next_program)
0579 ifeq ($(feature-libbpf-bpf_object__next_program), 1)
0580 CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
0581 endif
0582 $(call feature_check,libbpf-bpf_object__next_map)
0583 ifeq ($(feature-libbpf-bpf_object__next_map), 1)
0584 CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
0585 endif
0586 $(call feature_check,libbpf-btf__raw_data)
0587 ifeq ($(feature-libbpf-btf__raw_data), 1)
0588 CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
0589 endif
0590 $(call feature_check,libbpf-bpf_map_create)
0591 ifeq ($(feature-libbpf-bpf_map_create), 1)
0592 CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
0593 endif
0594 else
0595 dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
0596 endif
0597 else
0598 CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
0599 CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
0600 CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
0601 CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
0602 CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
0603 CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
0604 endif
0605 endif
0606
0607 ifndef NO_DWARF
0608 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
0609 CFLAGS += -DHAVE_BPF_PROLOGUE
0610 $(call detected,CONFIG_BPF_PROLOGUE)
0611 else
0612 msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
0613 endif
0614 else
0615 msg := $(warning DWARF support is off, BPF prologue is disabled);
0616 endif
0617
0618 endif
0619 endif
0620
0621 ifndef NO_SDT
0622 ifneq ($(feature-sdt), 1)
0623 msg := $(warning No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev);
0624 NO_SDT := 1;
0625 else
0626 CFLAGS += -DHAVE_SDT_EVENT
0627 $(call detected,CONFIG_SDT_EVENT)
0628 endif
0629 endif
0630
0631 ifdef PERF_HAVE_JITDUMP
0632 ifndef NO_LIBELF
0633 $(call detected,CONFIG_JITDUMP)
0634 CFLAGS += -DHAVE_JITDUMP
0635 endif
0636 endif
0637
0638 ifeq ($(SRCARCH),powerpc)
0639 ifndef NO_DWARF
0640 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
0641 endif
0642 endif
0643
0644 ifndef NO_LIBUNWIND
0645 have_libunwind :=
0646
0647 $(call feature_check,libunwind-x86)
0648 ifeq ($(feature-libunwind-x86), 1)
0649 $(call detected,CONFIG_LIBUNWIND_X86)
0650 CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT
0651 LDFLAGS += -lunwind-x86
0652 EXTLIBS_LIBUNWIND += -lunwind-x86
0653 have_libunwind = 1
0654 endif
0655
0656 $(call feature_check,libunwind-aarch64)
0657 ifeq ($(feature-libunwind-aarch64), 1)
0658 $(call detected,CONFIG_LIBUNWIND_AARCH64)
0659 CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
0660 LDFLAGS += -lunwind-aarch64
0661 EXTLIBS_LIBUNWIND += -lunwind-aarch64
0662 have_libunwind = 1
0663 $(call feature_check,libunwind-debug-frame-aarch64)
0664 ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
0665 msg := $(warning No debug_frame support found in libunwind-aarch64);
0666 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
0667 endif
0668 endif
0669
0670 ifneq ($(feature-libunwind), 1)
0671 msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
0672 NO_LOCAL_LIBUNWIND := 1
0673 else
0674 have_libunwind := 1
0675 $(call detected,CONFIG_LOCAL_LIBUNWIND)
0676 endif
0677
0678 ifneq ($(have_libunwind), 1)
0679 NO_LIBUNWIND := 1
0680 endif
0681 else
0682 NO_LOCAL_LIBUNWIND := 1
0683 endif
0684
0685 ifndef NO_LIBBPF
0686 ifneq ($(feature-bpf), 1)
0687 msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
0688 NO_LIBBPF := 1
0689 endif
0690 endif
0691
0692 ifdef BUILD_BPF_SKEL
0693 $(call feature_check,clang-bpf-co-re)
0694 ifeq ($(feature-clang-bpf-co-re), 0)
0695 dummy := $(error Error: clang too old/not installed. Please install recent clang to build with BUILD_BPF_SKEL)
0696 endif
0697 ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),)
0698 dummy := $(error Error: BPF skeleton support requires libbpf)
0699 endif
0700 $(call detected,CONFIG_PERF_BPF_SKEL)
0701 CFLAGS += -DHAVE_BPF_SKEL
0702 endif
0703
0704 dwarf-post-unwind := 1
0705 dwarf-post-unwind-text := BUG
0706
0707
0708 ifdef NO_LIBUNWIND
0709 ifdef NO_LIBDW_DWARF_UNWIND
0710 msg := $(warning Disabling post unwind, no support found.);
0711 dwarf-post-unwind := 0
0712 else
0713 dwarf-post-unwind-text := libdw
0714 $(call detected,CONFIG_LIBDW_DWARF_UNWIND)
0715 endif
0716 else
0717 dwarf-post-unwind-text := libunwind
0718 $(call detected,CONFIG_LIBUNWIND)
0719
0720 ifndef NO_LIBDW_DWARF_UNWIND
0721 NO_LIBDW_DWARF_UNWIND := 1
0722 endif
0723 endif
0724
0725 ifeq ($(dwarf-post-unwind),1)
0726 CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
0727 $(call detected,CONFIG_DWARF_UNWIND)
0728 else
0729 NO_DWARF_UNWIND := 1
0730 endif
0731
0732 ifndef NO_LOCAL_LIBUNWIND
0733 ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
0734 $(call feature_check,libunwind-debug-frame)
0735 ifneq ($(feature-libunwind-debug-frame), 1)
0736 msg := $(warning No debug_frame support found in libunwind);
0737 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
0738 endif
0739 else
0740
0741 CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
0742 endif
0743 EXTLIBS += $(LIBUNWIND_LIBS)
0744 LDFLAGS += $(LIBUNWIND_LIBS)
0745 endif
0746 ifeq ($(findstring -static,${LDFLAGS}),-static)
0747
0748 LIBUNWIND_LDFLAGS += -Wl,--allow-multiple-definition
0749 endif
0750
0751 ifndef NO_LIBUNWIND
0752 CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
0753 CFLAGS += $(LIBUNWIND_CFLAGS)
0754 LDFLAGS += $(LIBUNWIND_LDFLAGS)
0755 EXTLIBS += $(EXTLIBS_LIBUNWIND)
0756 endif
0757
0758 ifeq ($(NO_SYSCALL_TABLE),0)
0759 $(call detected,CONFIG_TRACE)
0760 else
0761 ifndef NO_LIBAUDIT
0762 $(call feature_check,libaudit)
0763 ifneq ($(feature-libaudit), 1)
0764 msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
0765 NO_LIBAUDIT := 1
0766 else
0767 CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
0768 EXTLIBS += -laudit
0769 $(call detected,CONFIG_TRACE)
0770 endif
0771 endif
0772 endif
0773
0774 ifndef NO_LIBCRYPTO
0775 ifneq ($(feature-libcrypto), 1)
0776 msg := $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev);
0777 NO_LIBCRYPTO := 1
0778 else
0779 CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
0780 EXTLIBS += -lcrypto
0781 $(call detected,CONFIG_CRYPTO)
0782 endif
0783 endif
0784
0785 ifdef NO_NEWT
0786 NO_SLANG=1
0787 endif
0788
0789 ifndef NO_SLANG
0790 ifneq ($(feature-libslang), 1)
0791 ifneq ($(feature-libslang-include-subdir), 1)
0792 msg := $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev);
0793 NO_SLANG := 1
0794 else
0795 CFLAGS += -DHAVE_SLANG_INCLUDE_SUBDIR
0796 endif
0797 endif
0798 ifndef NO_SLANG
0799
0800 CFLAGS += -DHAVE_SLANG_SUPPORT
0801 EXTLIBS += -lslang
0802 $(call detected,CONFIG_SLANG)
0803 endif
0804 endif
0805
0806 ifdef GTK2
0807 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
0808 $(call feature_check,gtk2)
0809 ifneq ($(feature-gtk2), 1)
0810 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
0811 NO_GTK2 := 1
0812 else
0813 $(call feature_check,gtk2-infobar)
0814 ifeq ($(feature-gtk2-infobar), 1)
0815 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
0816 endif
0817 CFLAGS += -DHAVE_GTK2_SUPPORT
0818 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
0819 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
0820 EXTLIBS += -ldl
0821 endif
0822 endif
0823
0824 ifdef NO_LIBPERL
0825 CFLAGS += -DNO_LIBPERL
0826 else
0827 PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
0828 PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
0829 PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
0830 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
0831 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
0832 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
0833 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
0834 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
0835
0836 ifneq ($(feature-libperl), 1)
0837 CFLAGS += -DNO_LIBPERL
0838 NO_LIBPERL := 1
0839 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev);
0840 else
0841 LDFLAGS += $(PERL_EMBED_LDFLAGS)
0842 EXTLIBS += $(PERL_EMBED_LIBADD)
0843 CFLAGS += -DHAVE_LIBPERL_SUPPORT
0844 ifeq ($(CC_NO_CLANG), 0)
0845 CFLAGS += -Wno-compound-token-split-by-macro
0846 endif
0847 $(call detected,CONFIG_LIBPERL)
0848 endif
0849 endif
0850
0851 ifeq ($(feature-timerfd), 1)
0852 CFLAGS += -DHAVE_TIMERFD_SUPPORT
0853 else
0854 msg := $(warning No timerfd support. Disables 'perf kvm stat live');
0855 endif
0856
0857 disable-python = $(eval $(disable-python_code))
0858 define disable-python_code
0859 CFLAGS += -DNO_LIBPYTHON
0860 $(warning $1)
0861 NO_LIBPYTHON := 1
0862 endef
0863
0864 ifdef NO_LIBPYTHON
0865 $(call disable-python,Python support disabled by user)
0866 else
0867
0868 ifndef PYTHON
0869 $(call disable-python,No python interpreter was found: disables Python support - please install python-devel/python-dev)
0870 else
0871 PYTHON_WORD := $(call shell-wordify,$(PYTHON))
0872
0873 ifndef PYTHON_CONFIG
0874 $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
0875 else
0876
0877 ifneq ($(feature-libpython), 1)
0878 $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev)
0879 else
0880 LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
0881 EXTLIBS += $(PYTHON_EMBED_LIBADD)
0882 LANG_BINDINGS += $(obj-perf)python/perf.so
0883 CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
0884 $(call detected,CONFIG_LIBPYTHON)
0885 endif
0886 endif
0887 endif
0888 endif
0889
0890 ifneq ($(NO_JEVENTS),1)
0891 ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),)
0892 NO_JEVENTS := 1
0893 endif
0894 endif
0895 ifneq ($(NO_JEVENTS),1)
0896 NO_JEVENTS := 0
0897 ifndef PYTHON
0898 $(warning No python interpreter disabling jevent generation)
0899 NO_JEVENTS := 1
0900 else
0901
0902 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)
0903 ifneq ($(JEVENTS_PYTHON_GOOD), 1)
0904 $(warning Python interpreter too old (older than 3.6) disabling jevent generation)
0905 NO_JEVENTS := 1
0906 endif
0907 endif
0908 endif
0909
0910 ifndef NO_LIBBFD
0911 ifeq ($(feature-libbfd), 1)
0912 EXTLIBS += -lbfd -lopcodes
0913 else
0914
0915
0916
0917
0918
0919 $(call feature_check,libbfd-liberty)
0920 $(call feature_check,libbfd-liberty-z)
0921
0922 ifeq ($(feature-libbfd-liberty), 1)
0923 EXTLIBS += -lbfd -lopcodes -liberty
0924 else
0925 ifeq ($(feature-libbfd-liberty-z), 1)
0926 EXTLIBS += -lbfd -lopcodes -liberty -lz
0927 endif
0928 endif
0929 $(call feature_check,disassembler-four-args)
0930 $(call feature_check,disassembler-init-styled)
0931 endif
0932
0933 ifeq ($(feature-libbfd-buildid), 1)
0934 CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
0935 else
0936 msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available);
0937 endif
0938 endif
0939
0940 ifdef NO_DEMANGLE
0941 CFLAGS += -DNO_DEMANGLE
0942 else
0943 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
0944 EXTLIBS += -liberty
0945 else
0946 ifeq ($(filter -liberty,$(EXTLIBS)),)
0947 $(call feature_check,cplus-demangle)
0948
0949
0950
0951 ifeq ($(feature-cplus-demangle), 1)
0952 EXTLIBS += -liberty
0953 else
0954 msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
0955 CFLAGS += -DNO_DEMANGLE
0956 endif
0957 endif
0958 endif
0959
0960 ifneq ($(filter -liberty,$(EXTLIBS)),)
0961 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
0962 endif
0963 endif
0964
0965 ifneq ($(filter -lbfd,$(EXTLIBS)),)
0966 CFLAGS += -DHAVE_LIBBFD_SUPPORT
0967 endif
0968
0969 ifndef NO_ZLIB
0970 ifeq ($(feature-zlib), 1)
0971 CFLAGS += -DHAVE_ZLIB_SUPPORT
0972 EXTLIBS += -lz
0973 $(call detected,CONFIG_ZLIB)
0974 else
0975 NO_ZLIB := 1
0976 endif
0977 endif
0978
0979 ifndef NO_LZMA
0980 ifeq ($(feature-lzma), 1)
0981 CFLAGS += -DHAVE_LZMA_SUPPORT
0982 EXTLIBS += -llzma
0983 $(call detected,CONFIG_LZMA)
0984 else
0985 msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
0986 NO_LZMA := 1
0987 endif
0988 endif
0989
0990 ifndef NO_LIBZSTD
0991 ifeq ($(feature-libzstd), 1)
0992 CFLAGS += -DHAVE_ZSTD_SUPPORT
0993 CFLAGS += $(LIBZSTD_CFLAGS)
0994 LDFLAGS += $(LIBZSTD_LDFLAGS)
0995 EXTLIBS += -lzstd
0996 $(call detected,CONFIG_ZSTD)
0997 else
0998 msg := $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR);
0999 NO_LIBZSTD := 1
1000 endif
1001 endif
1002
1003 ifndef NO_LIBCAP
1004 ifeq ($(feature-libcap), 1)
1005 CFLAGS += -DHAVE_LIBCAP_SUPPORT
1006 EXTLIBS += -lcap
1007 $(call detected,CONFIG_LIBCAP)
1008 else
1009 msg := $(warning No libcap found, disables capability support, please install libcap-devel/libcap-dev);
1010 NO_LIBCAP := 1
1011 endif
1012 endif
1013
1014 ifndef NO_BACKTRACE
1015 ifeq ($(feature-backtrace), 1)
1016 CFLAGS += -DHAVE_BACKTRACE_SUPPORT
1017 endif
1018 endif
1019
1020 ifndef NO_LIBNUMA
1021 ifeq ($(feature-libnuma), 0)
1022 msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
1023 NO_LIBNUMA := 1
1024 else
1025 ifeq ($(feature-numa_num_possible_cpus), 0)
1026 msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
1027 NO_LIBNUMA := 1
1028 else
1029 CFLAGS += -DHAVE_LIBNUMA_SUPPORT
1030 EXTLIBS += -lnuma
1031 $(call detected,CONFIG_NUMA)
1032 endif
1033 endif
1034 endif
1035
1036 ifdef HAVE_KVM_STAT_SUPPORT
1037 CFLAGS += -DHAVE_KVM_STAT_SUPPORT
1038 endif
1039
1040 ifeq ($(feature-disassembler-four-args), 1)
1041 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
1042 endif
1043
1044 ifeq ($(feature-disassembler-init-styled), 1)
1045 CFLAGS += -DDISASM_INIT_STYLED
1046 endif
1047
1048 ifeq (${IS_64_BIT}, 1)
1049 ifndef NO_PERF_READ_VDSO32
1050 $(call feature_check,compile-32)
1051 ifeq ($(feature-compile-32), 1)
1052 CFLAGS += -DHAVE_PERF_READ_VDSO32
1053 else
1054 NO_PERF_READ_VDSO32 := 1
1055 endif
1056 endif
1057 ifneq ($(SRCARCH), x86)
1058 NO_PERF_READ_VDSOX32 := 1
1059 endif
1060 ifndef NO_PERF_READ_VDSOX32
1061 $(call feature_check,compile-x32)
1062 ifeq ($(feature-compile-x32), 1)
1063 CFLAGS += -DHAVE_PERF_READ_VDSOX32
1064 else
1065 NO_PERF_READ_VDSOX32 := 1
1066 endif
1067 endif
1068 else
1069 NO_PERF_READ_VDSO32 := 1
1070 NO_PERF_READ_VDSOX32 := 1
1071 endif
1072
1073 ifndef NO_LIBBABELTRACE
1074 $(call feature_check,libbabeltrace)
1075 ifeq ($(feature-libbabeltrace), 1)
1076 CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
1077 LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
1078 EXTLIBS += -lbabeltrace-ctf
1079 $(call detected,CONFIG_LIBBABELTRACE)
1080 else
1081 msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
1082 endif
1083 endif
1084
1085 ifndef NO_AUXTRACE
1086 ifeq ($(SRCARCH),x86)
1087 ifeq ($(feature-get_cpuid), 0)
1088 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
1089 NO_AUXTRACE := 1
1090 endif
1091 endif
1092 ifndef NO_AUXTRACE
1093 $(call detected,CONFIG_AUXTRACE)
1094 CFLAGS += -DHAVE_AUXTRACE_SUPPORT
1095 ifeq ($(feature-reallocarray), 0)
1096 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
1097 endif
1098 endif
1099 endif
1100
1101 ifndef NO_JVMTI
1102 ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
1103 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
1104 else
1105 ifneq (,$(wildcard /usr/sbin/alternatives))
1106 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')
1107 endif
1108 endif
1109 ifndef JDIR
1110 $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
1111 NO_JVMTI := 1
1112 endif
1113 endif
1114
1115 ifndef NO_JVMTI
1116 FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
1117 $(call feature_check,jvmti)
1118 ifeq ($(feature-jvmti), 1)
1119 $(call detected_var,JDIR)
1120 ifndef NO_JVMTI_CMLR
1121 FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
1122 $(call feature_check,jvmti-cmlr)
1123 ifeq ($(feature-jvmti-cmlr), 1)
1124 CFLAGS += -DHAVE_JVMTI_CMLR
1125 endif
1126 endif
1127 else
1128 $(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
1129 NO_JVMTI := 1
1130 endif
1131 endif
1132
1133 USE_CXX = 0
1134 USE_CLANGLLVM = 0
1135 ifdef LIBCLANGLLVM
1136 $(call feature_check,cxx)
1137 ifneq ($(feature-cxx), 1)
1138 msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
1139 else
1140 $(call feature_check,llvm)
1141 $(call feature_check,llvm-version)
1142 ifneq ($(feature-llvm), 1)
1143 msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
1144 else
1145 $(call feature_check,clang)
1146 ifneq ($(feature-clang), 1)
1147 msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
1148 else
1149 CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
1150 CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
1151 $(call detected,CONFIG_CXX)
1152 $(call detected,CONFIG_CLANGLLVM)
1153 USE_CXX = 1
1154 USE_LLVM = 1
1155 USE_CLANG = 1
1156 ifneq ($(feature-llvm-version),1)
1157 msg := $(warning This version of LLVM is not tested. May cause build errors)
1158 endif
1159 endif
1160 endif
1161 endif
1162 endif
1163
1164 ifdef LIBPFM4
1165 $(call feature_check,libpfm4)
1166 ifeq ($(feature-libpfm4), 1)
1167 CFLAGS += -DHAVE_LIBPFM
1168 EXTLIBS += -lpfm
1169 ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1
1170 $(call detected,CONFIG_LIBPFM4)
1171 else
1172 msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev);
1173 NO_LIBPFM4 := 1
1174 endif
1175 endif
1176
1177 ifdef LIBTRACEEVENT_DYNAMIC
1178 $(call feature_check,libtraceevent)
1179 ifeq ($(feature-libtraceevent), 1)
1180 EXTLIBS += -ltraceevent
1181 LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
1182 LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1183 LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1184 LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
1185 LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3))
1186 CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)
1187 else
1188 dummy := $(error Error: No libtraceevent devel library found, please install libtraceevent-devel);
1189 endif
1190 endif
1191
1192 ifdef LIBTRACEFS_DYNAMIC
1193 $(call feature_check,libtracefs)
1194 ifeq ($(feature-libtracefs), 1)
1195 EXTLIBS += -ltracefs
1196 LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs)
1197 LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION)))
1198 LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION)))
1199 LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION)))
1200 LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3))
1201 CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP)
1202 else
1203 dummy := $(error Error: No libtracefs devel library found, please install libtracefs-dev);
1204 endif
1205 endif
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222 ifndef DESTDIR
1223 prefix ?= $(HOME)
1224 endif
1225 bindir_relative = bin
1226 bindir = $(abspath $(prefix)/$(bindir_relative))
1227 includedir_relative = include
1228 includedir = $(abspath $(prefix)/$(includedir_relative))
1229 mandir = share/man
1230 infodir = share/info
1231 perfexecdir = libexec/perf-core
1232 perf_include_dir = lib/perf/include
1233 perf_examples_dir = lib/perf/examples
1234 sharedir = $(prefix)/share
1235 template_dir = share/perf-core/templates
1236 STRACE_GROUPS_DIR = share/perf-core/strace/groups
1237 htmldir = share/doc/perf-doc
1238 tipdir = share/doc/perf-tip
1239 srcdir = $(srctree)/tools/perf
1240 ifeq ($(prefix),/usr)
1241 sysconfdir = /etc
1242 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
1243 else
1244 sysconfdir = $(prefix)/etc
1245 ETC_PERFCONFIG = etc/perfconfig
1246 endif
1247 ifndef lib
1248 ifeq ($(SRCARCH)$(IS_64_BIT), x861)
1249 lib = lib64
1250 else
1251 lib = lib
1252 endif
1253 endif
1254 libdir = $(prefix)/$(lib)
1255
1256
1257 ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
1258 STRACE_GROUPS_DIR_SQ = $(subst ','\'',$(STRACE_GROUPS_DIR))
1259 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1260 bindir_SQ = $(subst ','\'',$(bindir))
1261 includedir_SQ = $(subst ','\'',$(includedir))
1262 mandir_SQ = $(subst ','\'',$(mandir))
1263 infodir_SQ = $(subst ','\'',$(infodir))
1264 perfexecdir_SQ = $(subst ','\'',$(perfexecdir))
1265 perf_include_dir_SQ = $(subst ','\'',$(perf_include_dir))
1266 perf_examples_dir_SQ = $(subst ','\'',$(perf_examples_dir))
1267 template_dir_SQ = $(subst ','\'',$(template_dir))
1268 htmldir_SQ = $(subst ','\'',$(htmldir))
1269 tipdir_SQ = $(subst ','\'',$(tipdir))
1270 prefix_SQ = $(subst ','\'',$(prefix))
1271 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
1272 libdir_SQ = $(subst ','\'',$(libdir))
1273 srcdir_SQ = $(subst ','\'',$(srcdir))
1274
1275 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
1276 perfexec_instdir = $(perfexecdir)
1277 perf_include_instdir = $(perf_include_dir)
1278 perf_examples_instdir = $(perf_examples_dir)
1279 STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR)
1280 tip_instdir = $(tipdir)
1281 else
1282 perfexec_instdir = $(prefix)/$(perfexecdir)
1283 perf_include_instdir = $(prefix)/$(perf_include_dir)
1284 perf_examples_instdir = $(prefix)/$(perf_examples_dir)
1285 STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR)
1286 tip_instdir = $(prefix)/$(tipdir)
1287 endif
1288 perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
1289 perf_include_instdir_SQ = $(subst ','\'',$(perf_include_instdir))
1290 perf_examples_instdir_SQ = $(subst ','\'',$(perf_examples_instdir))
1291 STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR))
1292 tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
1293
1294
1295
1296
1297 ifdef DESTDIR
1298 plugindir=$(libdir)/traceevent/plugins
1299 plugindir_SQ= $(subst ','\'',$(plugindir))
1300 endif
1301
1302 print_var = $(eval $(print_var_code)) $(info $(MSG))
1303 define print_var_code
1304 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
1305 endef
1306
1307 ifeq ($(VF),1)
1308
1309
1310
1311 $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),))
1312 $(call print_var,prefix)
1313 $(call print_var,bindir)
1314 $(call print_var,libdir)
1315 $(call print_var,sysconfdir)
1316 $(call print_var,LIBUNWIND_DIR)
1317 $(call print_var,LIBDW_DIR)
1318 $(call print_var,JDIR)
1319
1320 ifeq ($(dwarf-post-unwind),1)
1321 $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
1322 endif
1323 $(info )
1324 endif
1325
1326 $(call detected_var,bindir_SQ)
1327 $(call detected_var,PYTHON_WORD)
1328 ifneq ($(OUTPUT),)
1329 $(call detected_var,OUTPUT)
1330 endif
1331 $(call detected_var,htmldir_SQ)
1332 $(call detected_var,infodir_SQ)
1333 $(call detected_var,mandir_SQ)
1334 $(call detected_var,ETC_PERFCONFIG_SQ)
1335 $(call detected_var,STRACE_GROUPS_DIR_SQ)
1336 $(call detected_var,prefix_SQ)
1337 $(call detected_var,perfexecdir_SQ)
1338 $(call detected_var,perf_include_dir_SQ)
1339 $(call detected_var,perf_examples_dir_SQ)
1340 $(call detected_var,tipdir_SQ)
1341 $(call detected_var,srcdir_SQ)
1342 $(call detected_var,LIBDIR)
1343 $(call detected_var,GTK_CFLAGS)
1344 $(call detected_var,PERL_EMBED_CCOPTS)
1345 $(call detected_var,PYTHON_EMBED_CCOPTS)
1346 ifneq ($(BISON_FILE_PREFIX_MAP),)
1347 $(call detected_var,BISON_FILE_PREFIX_MAP)
1348 endif
1349
1350
1351
1352
1353 $(shell rm -f $(FEATURE_DUMP_FILENAME))
1354 $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))
1355
1356 ifeq ($(feature_display),1)
1357 $(call feature_display_entries)
1358 endif