1################################################################################ 2# 3# perf 4# 5################################################################################ 6 7LINUX_TOOLS += perf 8 9PERF_DEPENDENCIES = host-flex host-bison 10 11ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_NEEDS_HOST_PYTHON3),y) 12PERF_DEPENDENCIES += host-python3 13endif 14 15ifeq ($(NORMALIZED_ARCH),x86_64) 16PERF_ARCH=x86 17else 18PERF_ARCH=$(NORMALIZED_ARCH) 19endif 20 21PERF_MAKE_FLAGS = \ 22 $(LINUX_MAKE_FLAGS) \ 23 JOBS=$(PARALLEL_JOBS) \ 24 ARCH=$(PERF_ARCH) \ 25 DESTDIR=$(TARGET_DIR) \ 26 prefix=/usr \ 27 NO_GTK2=1 \ 28 NO_LIBPERL=1 \ 29 NO_LIBPYTHON=1 \ 30 NO_LIBBIONIC=1 31 32ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_STATIC),y) 33PERF_MAKE_FLAGS += LDFLAGS="$(TARGET_LDFLAGS) -static" 34endif 35 36# We need to pass an argument to ld for setting the emulation when 37# building for MIPS architecture, otherwise the default one will always 38# be used and the compilation for most variants will fail. 39ifeq ($(BR2_mips),y) 40PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmip" 41else ifeq ($(BR2_mipsel),y) 42PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmip" 43else ifeq ($(BR2_mips64),y) 44ifeq ($(BR2_MIPS_NABI32),y) 45PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmipn32" 46else 47PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64btsmip" 48endif 49else ifeq ($(BR2_mips64el),y) 50ifeq ($(BR2_MIPS_NABI32),y) 51PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32" 52else 53PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip" 54endif 55endif 56 57# The call to backtrace() function fails for ARC, because for some 58# reason the unwinder from libgcc returns early. Thus the usage of 59# backtrace() should be disabled in perf explicitly: at build time 60# backtrace() appears to be available, but it fails at runtime: the 61# backtrace will contain only several functions from the top of stack, 62# instead of the complete backtrace. 63ifeq ($(BR2_arc),y) 64PERF_MAKE_FLAGS += NO_BACKTRACE=1 65endif 66 67ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI),y) 68PERF_DEPENDENCIES += slang 69else 70PERF_MAKE_FLAGS += NO_NEWT=1 NO_SLANG=1 71endif 72 73ifeq ($(BR2_PACKAGE_AUDIT),y) 74PERF_DEPENDENCIES += audit 75else 76PERF_MAKE_FLAGS += NO_LIBAUDIT=1 77endif 78 79ifeq ($(BR2_PACKAGE_ZSTD),y) 80PERF_DEPENDENCIES += zstd 81endif 82 83ifeq ($(BR2_PACKAGE_LIBUNWIND),y) 84PERF_DEPENDENCIES += libunwind 85else 86PERF_MAKE_FLAGS += NO_LIBUNWIND=1 87endif 88 89ifeq ($(BR2_PACKAGE_NUMACTL),y) 90PERF_DEPENDENCIES += numactl 91else 92PERF_MAKE_FLAGS += NO_LIBNUMA=1 93endif 94 95ifeq ($(BR2_PACKAGE_ELFUTILS),y) 96PERF_DEPENDENCIES += elfutils 97else 98PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1 99endif 100 101ifeq ($(BR2_PACKAGE_BINUTILS),y) 102PERF_DEPENDENCIES += binutils 103else 104PERF_MAKE_FLAGS += NO_DEMANGLE=1 105endif 106 107ifeq ($(BR2_PACKAGE_OPENSSL),y) 108PERF_DEPENDENCIES += openssl 109else 110PERF_MAKE_FLAGS += NO_LIBCRYPTO=1 111endif 112 113ifeq ($(BR2_PACKAGE_ZLIB),y) 114PERF_DEPENDENCIES += zlib 115else 116PERF_MAKE_FLAGS += NO_ZLIB=1 117endif 118 119# lzma is provided by xz 120ifeq ($(BR2_PACKAGE_XZ),y) 121PERF_DEPENDENCIES += xz 122else 123PERF_MAKE_FLAGS += NO_LZMA=1 124endif 125 126# We really do not want to build the perf documentation, because it 127# has stringent requirement on the documentation generation tools, 128# like xmlto and asciidoc), which may be lagging behind on some 129# distributions. 130# We name it 'GNUmakefile' so that GNU make will use it instead of 131# the existing 'Makefile'. 132define PERF_DISABLE_DOCUMENTATION 133 if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \ 134 printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \ 135 fi 136endef 137LINUX_TOOLS_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION 138 139# O must be redefined here to overwrite the one used by Buildroot for 140# out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just 141# $(LINUX_DIR) so that it isn't built in the root directory of the kernel 142# sources. 143define PERF_BUILD_CMDS 144 $(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \ 145 echo "Your kernel version is too old and does not have the perf tool." ; \ 146 echo "At least kernel 2.6.31 must be used." ; \ 147 exit 1 ; \ 148 fi 149 $(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \ 150 if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \ 151 if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \ 152 echo "The perf tool in your kernel cannot be built without libelf." ; \ 153 echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \ 154 exit 1 ; \ 155 fi \ 156 fi \ 157 fi 158 $(Q)if test "$(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI)" = "y" ; then \ 159 if ! grep -q NO_SLANG $(LINUX_DIR)/tools/perf/Makefile* ; then \ 160 echo "The perf tool in your kernel cannot be build with the TUI." ; \ 161 echo "Either upgrade your kernel to >= 3.10, or disable the TUI." ; \ 162 exit 1 ; \ 163 fi \ 164 fi 165 $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ 166 -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ 167endef 168 169# After installation, we remove the Perl and Python scripts from the 170# target unless BR2_PACKAGE_LINUX_TOOLS_PERF_SCRIPTS is enabled 171ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_SCRIPTS),) 172define PERF_INSTALL_REMOVE_SCRIPTS 173 $(RM) -r $(TARGET_DIR)/usr/libexec/perf-core/scripts/ 174 $(RM) -r $(TARGET_DIR)/usr/libexec/perf-core/tests/ 175endef 176endif 177 178define PERF_INSTALL_TARGET_CMDS 179 $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ 180 -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install 181 $(PERF_INSTALL_REMOVE_SCRIPTS) 182endef 183 184define PERF_LINUX_CONFIG_FIXUPS 185 $(call KCONFIG_ENABLE_OPT,CONFIG_PERF_EVENTS) 186endef 187