linux-tool-perf.mk.in 5.5 KB

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